[SRU][F:linux-bluefield][PATCH v2 1/1] UBUNTU: SAUCE: mlxbf-pmc: Fix error when reading unprogrammed events

Shravan Kumar Ramani shravankr at nvidia.com
Tue Sep 20 11:41:54 UTC 2022


BugLink: https://bugs.launchpad.net/bugs/1989172

Firstly, all events have a reset value of 0, which is not a valid
event 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.
Second, the enable bit for each counter need not be checked before
reading the event info, and hence removed.
Also increment the driver version so that the user can verify
using modinfo if the driver has the required updates.

Signed-off-by: Shravan Kumar Ramani <shravankr at nvidia.com>
---
 drivers/platform/mellanox/mlxbf-pmc.c | 24 ++----------------------
 drivers/platform/mellanox/mlxbf-pmc.h |  6 ++++++
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/platform/mellanox/mlxbf-pmc.c b/drivers/platform/mellanox/mlxbf-pmc.c
index f1c6af2a9213..9c15bd419c58 100644
--- a/drivers/platform/mellanox/mlxbf-pmc.c
+++ b/drivers/platform/mellanox/mlxbf-pmc.c
@@ -19,7 +19,7 @@
 
 #include "mlxbf-pmc.h"
 
-#define DRIVER_VERSION		2.2
+#define DRIVER_VERSION		2.3
 
 static struct mlxbf_pmc_context *pmc;
 
@@ -562,7 +562,7 @@ int mlxbf_read_event(int blk_num, uint32_t cnt_num, bool is_l3,
 		     uint64_t *result)
 {
 	uint32_t perfcfg_offset, perfval_offset;
-	uint64_t perfmon_cfg, perfevt, perfctl;
+	uint64_t perfmon_cfg, perfevt;
 
 	if (cnt_num >= pmc->block[blk_num].counters)
 		return -EINVAL;
@@ -573,26 +573,6 @@ int mlxbf_read_event(int blk_num, uint32_t cnt_num, bool is_l3,
 	perfcfg_offset = cnt_num * 8;
 	perfval_offset = perfcfg_offset + pmc->block[blk_num].counters * 8;
 
-	/* Set counter in "read" mode */
-	perfmon_cfg = 0;
-	perfmon_cfg |= FIELD_PREP(MLXBF_GEN_PERFMON_CONFIG__ADDR,
-				  MLXBF_PERFCTL);
-	perfmon_cfg |= FIELD_PREP(MLXBF_GEN_PERFMON_CONFIG__STROBE, 1);
-	perfmon_cfg |= FIELD_PREP(MLXBF_GEN_PERFMON_CONFIG__WR_R_B, 0);
-
-	if (mlxbf_pmc_writeq(perfmon_cfg,
-		       pmc->block[blk_num].mmio_base + perfcfg_offset))
-		return -EFAULT;
-
-	/* Check if the counter is enabled */
-
-	if (mlxbf_pmc_readq(&perfctl,
-		      pmc->block[blk_num].mmio_base + perfval_offset))
-		return -EFAULT;
-
-	if (FIELD_GET(MLXBF_GEN_PERFCTL__EN0, perfctl) == 0)
-		return -EINVAL;
-
 	/* Set counter in "read" mode */
 	perfmon_cfg = 0;
 	perfmon_cfg |= FIELD_PREP(MLXBF_GEN_PERFMON_CONFIG__ADDR,
diff --git a/drivers/platform/mellanox/mlxbf-pmc.h b/drivers/platform/mellanox/mlxbf-pmc.h
index b15614e9056a..894c3cc8814d 100644
--- a/drivers/platform/mellanox/mlxbf-pmc.h
+++ b/drivers/platform/mellanox/mlxbf-pmc.h
@@ -186,6 +186,7 @@ struct mlxbf_pmc_events mlxbf_smgen_events[] = {
 };
 
 struct mlxbf_pmc_events mlxbf1_trio_events[] = {
+{0x00, "DISABLE"},
 {0xa0, "TPIO_DATA_BEAT"},
 {0xa1, "TDMA_DATA_BEAT"},
 {0xa2, "MAP_DATA_BEAT"},
@@ -210,6 +211,7 @@ struct mlxbf_pmc_events mlxbf1_trio_events[] = {
 };
 
 struct mlxbf_pmc_events mlxbf2_trio_events[] = {
+{0x00, "DISABLE"},
 {0xa0, "TPIO_DATA_BEAT"},
 {0xa1, "TDMA_DATA_BEAT"},
 {0xa2, "MAP_DATA_BEAT"},
@@ -243,6 +245,7 @@ struct mlxbf_pmc_events mlxbf2_trio_events[] = {
 };
 
 struct mlxbf_pmc_events mlxbf_ecc_events[] = {
+{0x00, "DISABLE"},
 {0x100, "ECC_SINGLE_ERROR_CNT"},
 {0x104, "ECC_DOUBLE_ERROR_CNT"},
 {0x114, "SERR_INJ"},
@@ -256,6 +259,7 @@ struct mlxbf_pmc_events mlxbf_ecc_events[] = {
 };
 
 struct mlxbf_pmc_events mlxbf_mss_events[] = {
+{0x00, "DISABLE"},
 {0xc0, "RXREQ_MSS"},
 {0xc1, "RXDAT_MSS"},
 {0xc2, "TXRSP_MSS"},
@@ -264,6 +268,7 @@ struct mlxbf_pmc_events mlxbf_mss_events[] = {
 };
 
 struct mlxbf_pmc_events mlxbf_hnf_events[] = {
+{0x00, "DISABLE"},
 {0x45, "HNF_REQUESTS"},
 {0x46, "HNF_REJECTS"},
 {0x47, "ALL_BUSY"},
@@ -323,6 +328,7 @@ struct mlxbf_pmc_events mlxbf_hnf_events[] = {
 };
 
 struct mlxbf_pmc_events mlxbf2_hnfnet_events[] = {
+{0x00, "DISABLE"},
 {0x12, "CDN_REQ"},
 {0x13, "DDN_REQ"},
 {0x14, "NDN_REQ"},
-- 
2.30.1




More information about the kernel-team mailing list