Skip to content

Commit 0f59694

Browse files
shravankumarrjwrdegoede
authored andcommitted
platform/mellanox: mlxbf-pmc: Fix reading of unprogrammed events
This fix involves 2 changes: - All event regs have a reset value of 0, which is not a valid event_number as per the event_list for most blocks and hence seen as an error. Add a "disable" event with event_number 0 for all blocks. - The enable bit for each counter need not be checked before reading the event info, and hence removed. Fixes: 1a218d3 ("platform/mellanox: mlxbf-pmc: Add Mellanox BlueField PMC driver") Signed-off-by: Shravan Kumar Ramani <shravankr@nvidia.com> Reviewed-by: Vadim Pasternak <vadimp@nvidia.com> Reviewed-by: David Thompson <davthompson@nvidia.com> Link: https://lore.kernel.org/r/04d0213932d32681de1c716b54320ed894e52425.1693917738.git.shravankr@nvidia.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent 80ccd40 commit 0f59694

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

drivers/platform/mellanox/mlxbf-pmc.c

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ static const struct mlxbf_pmc_events mlxbf_pmc_smgen_events[] = {
191191
};
192192

193193
static const struct mlxbf_pmc_events mlxbf_pmc_trio_events_1[] = {
194+
{ 0x0, "DISABLE" },
194195
{ 0xa0, "TPIO_DATA_BEAT" },
195196
{ 0xa1, "TDMA_DATA_BEAT" },
196197
{ 0xa2, "MAP_DATA_BEAT" },
@@ -214,6 +215,7 @@ static const struct mlxbf_pmc_events mlxbf_pmc_trio_events_1[] = {
214215
};
215216

216217
static const struct mlxbf_pmc_events mlxbf_pmc_trio_events_2[] = {
218+
{ 0x0, "DISABLE" },
217219
{ 0xa0, "TPIO_DATA_BEAT" },
218220
{ 0xa1, "TDMA_DATA_BEAT" },
219221
{ 0xa2, "MAP_DATA_BEAT" },
@@ -246,6 +248,7 @@ static const struct mlxbf_pmc_events mlxbf_pmc_trio_events_2[] = {
246248
};
247249

248250
static const struct mlxbf_pmc_events mlxbf_pmc_ecc_events[] = {
251+
{ 0x0, "DISABLE" },
249252
{ 0x100, "ECC_SINGLE_ERROR_CNT" },
250253
{ 0x104, "ECC_DOUBLE_ERROR_CNT" },
251254
{ 0x114, "SERR_INJ" },
@@ -258,13 +261,15 @@ static const struct mlxbf_pmc_events mlxbf_pmc_ecc_events[] = {
258261
};
259262

260263
static const struct mlxbf_pmc_events mlxbf_pmc_mss_events[] = {
264+
{ 0x0, "DISABLE" },
261265
{ 0xc0, "RXREQ_MSS" },
262266
{ 0xc1, "RXDAT_MSS" },
263267
{ 0xc2, "TXRSP_MSS" },
264268
{ 0xc3, "TXDAT_MSS" },
265269
};
266270

267271
static const struct mlxbf_pmc_events mlxbf_pmc_hnf_events[] = {
272+
{ 0x0, "DISABLE" },
268273
{ 0x45, "HNF_REQUESTS" },
269274
{ 0x46, "HNF_REJECTS" },
270275
{ 0x47, "ALL_BUSY" },
@@ -323,6 +328,7 @@ static const struct mlxbf_pmc_events mlxbf_pmc_hnf_events[] = {
323328
};
324329

325330
static const struct mlxbf_pmc_events mlxbf_pmc_hnfnet_events[] = {
331+
{ 0x0, "DISABLE" },
326332
{ 0x12, "CDN_REQ" },
327333
{ 0x13, "DDN_REQ" },
328334
{ 0x14, "NDN_REQ" },
@@ -892,7 +898,7 @@ static int mlxbf_pmc_read_event(int blk_num, uint32_t cnt_num, bool is_l3,
892898
uint64_t *result)
893899
{
894900
uint32_t perfcfg_offset, perfval_offset;
895-
uint64_t perfmon_cfg, perfevt, perfctl;
901+
uint64_t perfmon_cfg, perfevt;
896902

897903
if (cnt_num >= pmc->block[blk_num].counters)
898904
return -EINVAL;
@@ -904,25 +910,6 @@ static int mlxbf_pmc_read_event(int blk_num, uint32_t cnt_num, bool is_l3,
904910
perfval_offset = perfcfg_offset +
905911
pmc->block[blk_num].counters * MLXBF_PMC_REG_SIZE;
906912

907-
/* Set counter in "read" mode */
908-
perfmon_cfg = FIELD_PREP(MLXBF_PMC_PERFMON_CONFIG_ADDR,
909-
MLXBF_PMC_PERFCTL);
910-
perfmon_cfg |= FIELD_PREP(MLXBF_PMC_PERFMON_CONFIG_STROBE, 1);
911-
perfmon_cfg |= FIELD_PREP(MLXBF_PMC_PERFMON_CONFIG_WR_R_B, 0);
912-
913-
if (mlxbf_pmc_write(pmc->block[blk_num].mmio_base + perfcfg_offset,
914-
MLXBF_PMC_WRITE_REG_64, perfmon_cfg))
915-
return -EFAULT;
916-
917-
/* Check if the counter is enabled */
918-
919-
if (mlxbf_pmc_read(pmc->block[blk_num].mmio_base + perfval_offset,
920-
MLXBF_PMC_READ_REG_64, &perfctl))
921-
return -EFAULT;
922-
923-
if (!FIELD_GET(MLXBF_PMC_PERFCTL_EN0, perfctl))
924-
return -EINVAL;
925-
926913
/* Set counter in "read" mode */
927914
perfmon_cfg = FIELD_PREP(MLXBF_PMC_PERFMON_CONFIG_ADDR,
928915
MLXBF_PMC_PERFEVT);

0 commit comments

Comments
 (0)