From patchwork Tue Sep 20 11:41:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shravan Kumar Ramani X-Patchwork-Id: 1680004 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MX05L6R0hz1yqC for ; Tue, 20 Sep 2022 21:42:14 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1oabde-00087P-B9; Tue, 20 Sep 2022 11:42:06 +0000 Received: from mail-il-dmz.mellanox.com ([193.47.165.129] helo=mellanox.co.il) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1oabdc-00087G-Tu for kernel-team@lists.ubuntu.com; Tue, 20 Sep 2022 11:42:05 +0000 Received: from Internal Mail-Server by MTLPINE1 (envelope-from shravankr@mellanox.com) with SMTP; 20 Sep 2022 14:42:01 +0300 Received: from bu-vnc02.mtbu.labs.mlnx (bu-vnc02.mtbu.labs.mlnx [10.15.2.65]) by mtbu-labmailer.labs.mlnx (8.14.4/8.14.4) with ESMTP id 28KBg0mK007937; Tue, 20 Sep 2022 07:42:00 -0400 Received: (from shravankr@localhost) by bu-vnc02.mtbu.labs.mlnx (8.14.7/8.13.8/Submit) id 28KBg05r027718; Tue, 20 Sep 2022 07:42:00 -0400 From: Shravan Kumar Ramani To: kernel-team@lists.ubuntu.com Subject: [SRU][F:linux-bluefield][PATCH v2 1/1] UBUNTU: SAUCE: mlxbf-pmc: Fix error when reading unprogrammed events Date: Tue, 20 Sep 2022 07:41:54 -0400 Message-Id: <71c5f57ef9badcc271c46bbd06f2a2a0c5fd3c34.1663673280.git.shravankr@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Shravan Kumar Ramani Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" 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 --- 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"},