From: Hans de Goede <hdegoede@redhat.com>
To: Shravan Kumar Ramani <shravankr@nvidia.com>,
Mark Gross <markgross@kernel.org>,
Vadim Pasternak <vadimp@nvidia.com>,
David Thompson <davthompson@nvidia.com>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/3] platform/mellanox: mlxbf-pmc: Fix reading of unprogrammed events
Date: Mon, 11 Sep 2023 13:14:45 +0200 [thread overview]
Message-ID: <a685b317-8b35-ffad-8f7f-2da9a5f6a491@redhat.com> (raw)
In-Reply-To: <04d0213932d32681de1c716b54320ed894e52425.1693917738.git.shravankr@nvidia.com>
Hi,
On 9/5/23 14:49, Shravan Kumar Ramani wrote:
> 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: 1a218d312e65 ("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>
Thank you for your patch, I've applied this patch to my fixes
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=fixes
Note it will show up in my fixes branch once I've pushed my
local branch there, which might take a while.
I will include this patch in my next fixes pull-req to Linus
for the current kernel development cycle.
Regards,
Hans
> ---
> drivers/platform/mellanox/mlxbf-pmc.c | 27 +++++++--------------------
> 1 file changed, 7 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/platform/mellanox/mlxbf-pmc.c b/drivers/platform/mellanox/mlxbf-pmc.c
> index 95afcae7b9fa..2d4bbe99959e 100644
> --- a/drivers/platform/mellanox/mlxbf-pmc.c
> +++ b/drivers/platform/mellanox/mlxbf-pmc.c
> @@ -191,6 +191,7 @@ static const struct mlxbf_pmc_events mlxbf_pmc_smgen_events[] = {
> };
>
> static const struct mlxbf_pmc_events mlxbf_pmc_trio_events_1[] = {
> + { 0x0, "DISABLE" },
> { 0xa0, "TPIO_DATA_BEAT" },
> { 0xa1, "TDMA_DATA_BEAT" },
> { 0xa2, "MAP_DATA_BEAT" },
> @@ -214,6 +215,7 @@ static const struct mlxbf_pmc_events mlxbf_pmc_trio_events_1[] = {
> };
>
> static const struct mlxbf_pmc_events mlxbf_pmc_trio_events_2[] = {
> + { 0x0, "DISABLE" },
> { 0xa0, "TPIO_DATA_BEAT" },
> { 0xa1, "TDMA_DATA_BEAT" },
> { 0xa2, "MAP_DATA_BEAT" },
> @@ -246,6 +248,7 @@ static const struct mlxbf_pmc_events mlxbf_pmc_trio_events_2[] = {
> };
>
> static const struct mlxbf_pmc_events mlxbf_pmc_ecc_events[] = {
> + { 0x0, "DISABLE" },
> { 0x100, "ECC_SINGLE_ERROR_CNT" },
> { 0x104, "ECC_DOUBLE_ERROR_CNT" },
> { 0x114, "SERR_INJ" },
> @@ -258,6 +261,7 @@ static const struct mlxbf_pmc_events mlxbf_pmc_ecc_events[] = {
> };
>
> static const struct mlxbf_pmc_events mlxbf_pmc_mss_events[] = {
> + { 0x0, "DISABLE" },
> { 0xc0, "RXREQ_MSS" },
> { 0xc1, "RXDAT_MSS" },
> { 0xc2, "TXRSP_MSS" },
> @@ -265,6 +269,7 @@ static const struct mlxbf_pmc_events mlxbf_pmc_mss_events[] = {
> };
>
> static const struct mlxbf_pmc_events mlxbf_pmc_hnf_events[] = {
> + { 0x0, "DISABLE" },
> { 0x45, "HNF_REQUESTS" },
> { 0x46, "HNF_REJECTS" },
> { 0x47, "ALL_BUSY" },
> @@ -323,6 +328,7 @@ static const struct mlxbf_pmc_events mlxbf_pmc_hnf_events[] = {
> };
>
> static const struct mlxbf_pmc_events mlxbf_pmc_hnfnet_events[] = {
> + { 0x0, "DISABLE" },
> { 0x12, "CDN_REQ" },
> { 0x13, "DDN_REQ" },
> { 0x14, "NDN_REQ" },
> @@ -892,7 +898,7 @@ static int mlxbf_pmc_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;
> @@ -904,25 +910,6 @@ static int mlxbf_pmc_read_event(int blk_num, uint32_t cnt_num, bool is_l3,
> perfval_offset = perfcfg_offset +
> pmc->block[blk_num].counters * MLXBF_PMC_REG_SIZE;
>
> - /* Set counter in "read" mode */
> - perfmon_cfg = FIELD_PREP(MLXBF_PMC_PERFMON_CONFIG_ADDR,
> - MLXBF_PMC_PERFCTL);
> - perfmon_cfg |= FIELD_PREP(MLXBF_PMC_PERFMON_CONFIG_STROBE, 1);
> - perfmon_cfg |= FIELD_PREP(MLXBF_PMC_PERFMON_CONFIG_WR_R_B, 0);
> -
> - if (mlxbf_pmc_write(pmc->block[blk_num].mmio_base + perfcfg_offset,
> - MLXBF_PMC_WRITE_REG_64, perfmon_cfg))
> - return -EFAULT;
> -
> - /* Check if the counter is enabled */
> -
> - if (mlxbf_pmc_read(pmc->block[blk_num].mmio_base + perfval_offset,
> - MLXBF_PMC_READ_REG_64, &perfctl))
> - return -EFAULT;
> -
> - if (!FIELD_GET(MLXBF_PMC_PERFCTL_EN0, perfctl))
> - return -EINVAL;
> -
> /* Set counter in "read" mode */
> perfmon_cfg = FIELD_PREP(MLXBF_PMC_PERFMON_CONFIG_ADDR,
> MLXBF_PMC_PERFEVT);
next prev parent reply other threads:[~2023-09-11 22:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-05 12:49 [PATCH v4 0/3] Updates to Mellanox PMC driver Shravan Kumar Ramani
2023-09-05 12:49 ` [PATCH v4 1/3] platform/mellanox: mlxbf-pmc: Fix potential buffer overflows Shravan Kumar Ramani
2023-09-11 11:14 ` Hans de Goede
2023-09-05 12:49 ` [PATCH v4 2/3] platform/mellanox: mlxbf-pmc: Fix reading of unprogrammed events Shravan Kumar Ramani
2023-09-11 11:14 ` Hans de Goede [this message]
2023-09-05 12:49 ` [PATCH v4 3/3] platform/mellanox: mlxbf-pmc: Add support for BlueField-3 Shravan Kumar Ramani
2023-09-13 14:54 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a685b317-8b35-ffad-8f7f-2da9a5f6a491@redhat.com \
--to=hdegoede@redhat.com \
--cc=davthompson@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=shravankr@nvidia.com \
--cc=vadimp@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).