On Fri, 1 Sep 2023, Shravan Kumar Ramani wrote: > Add new access mechanism and list of supported events to program > and read the counters in BlueField-3. > Performance counter blocks being added for BlueField-3 include: > - Memory Sub-system (mss) which has counters for monitoring > various DRAM and related skylib events > - Last level Tile, which has 2 sets of counters (llt, llt_miss) > for monitoring Tile and cache metrics > > Signed-off-by: Shravan Kumar Ramani <shravankr@xxxxxxxxxx> > Reviewed-by: Vadim Pasternak <vadimp@xxxxxxxxxx> > Reviewed-by: David Thompson <davthompson@xxxxxxxxxx> > --- > drivers/platform/mellanox/mlxbf-pmc.c | 685 ++++++++++++++++++++++++-- > 1 file changed, 653 insertions(+), 32 deletions(-) > > diff --git a/drivers/platform/mellanox/mlxbf-pmc.c b/drivers/platform/mellanox/mlxbf-pmc.c > index 2d4bbe99959e..ddd91f298721 100644 > --- a/drivers/platform/mellanox/mlxbf-pmc.c > +++ b/drivers/platform/mellanox/mlxbf-pmc.c > @@ -712,6 +1160,42 @@ static int mlxbf_pmc_program_l3_counter(int blk_num, uint32_t cnt_num, > return mlxbf_pmc_write(pmcaddr, MLXBF_PMC_WRITE_REG_32, *wordaddr); > } > > +/* Method to handle crspace counter programming */ > +static int mlxbf_pmc_program_crspace_counter(int blk_num, uint32_t cnt_num, > + uint32_t evt) > +{ > + uint32_t word; > + void *addr; > + int ret; > + > + addr = pmc->block[blk_num].mmio_base + (rounddown(cnt_num, 2) * 4); > + addr = pmc->block[blk_num].mmio_base + > + MLXBF_PMC_CRSPACE_PERFMON_VAL0(pmc->block[blk_num].counters) + > + (cnt_num * 4); > + status = mlxbf_pmc_readl(pmc->block[blk_num].mmio_base + > + MLXBF_PMC_CRSPACE_PERFMON_VAL0(pmc->block[blk_num].counters) + > + (cnt_num * 4), &value); > + addr = pmc->block[blk_num].mmio_base + (rounddown(cnt_num, 2) * 4); Should those * 4 be sizeof(something) or defined? -- i.