public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Yicong Yang <yangyicong@huawei.com>
To: <will@kernel.org>, <mark.rutland@arm.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Cc: <jonathan.cameron@huawei.com>, <prime.zeng@hisilicon.com>,
	<linuxarm@huawei.com>, <yangyicong@hisilicon.com>,
	<wangyushan12@huawei.com>
Subject: [PATCH 6/9] drivers/perf: hisi: Relax the event number check of v2 PMUs
Date: Tue, 18 Feb 2025 17:19:57 +0800	[thread overview]
Message-ID: <20250218092000.41641-7-yangyicong@huawei.com> (raw)
In-Reply-To: <20250218092000.41641-1-yangyicong@huawei.com>

From: Junhao He <hejunhao3@huawei.com>

The supported event number range of each Uncore PMUs is provided by
each driver in hisi_pmu::check_event and out of range events
will be rejected. A later version with expanded event number range
needs to register the PMU with updated hisi_pmu::check_event
even if it's the only update, which means the expanded events
cannot be used unless the driver's updated. However the unsupported
events won't be counted by the hardware so we can relax the event
number check to allow the use the expanded events.

Signed-off-by: Junhao He <hejunhao3@huawei.com>
Signed-off-by: Yicong Yang <yangyicong@hisilicon.com>
---
 drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c | 2 +-
 drivers/perf/hisilicon/hisi_uncore_hha_pmu.c  | 7 +++----
 drivers/perf/hisilicon/hisi_uncore_pa_pmu.c   | 2 +-
 drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c | 3 +--
 4 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
index 26eaa6d20c00..21c494881ca0 100644
--- a/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_ddrc_pmu.c
@@ -53,7 +53,7 @@
 #define DDRC_V1_PERF_CTRL_EN	0x2
 #define DDRC_V2_PERF_CTRL_EN	0x1
 #define DDRC_V1_NR_EVENTS	0x7
-#define DDRC_V2_NR_EVENTS	0x90
+#define DDRC_V2_NR_EVENTS	0xFF
 
 #define DDRC_EVENT_CNTn(base, n)	((base) + (n) * 8)
 #define DDRC_EVENT_TYPEn(base, n)	((base) + (n) * 4)
diff --git a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
index ca609db86046..78cd6d67f209 100644
--- a/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_hha_pmu.c
@@ -47,9 +47,8 @@
 #define HHA_SRCID_CMD		GENMASK(16, 6)
 #define HHA_SRCID_MSK		GENMASK(30, 20)
 #define HHA_DATSRC_SKT_EN	BIT(23)
-#define HHA_EVTYPE_NONE		0xff
+#define HHA_EVTYPE_MASK		GENMASK(7, 0)
 #define HHA_V1_NR_EVENT		0x65
-#define HHA_V2_NR_EVENT		0xCE
 
 HISI_PMU_EVENT_ATTR_EXTRACTOR(srcid_cmd, config1, 10, 0);
 HISI_PMU_EVENT_ATTR_EXTRACTOR(srcid_msk, config1, 21, 11);
@@ -197,7 +196,7 @@ static void hisi_hha_pmu_write_evtype(struct hisi_pmu *hha_pmu, int idx,
 
 	/* Write event code to HHA_EVENT_TYPEx register */
 	val = readl(hha_pmu->base + reg);
-	val &= ~(HHA_EVTYPE_NONE << shift);
+	val &= ~(HHA_EVTYPE_MASK << shift);
 	val |= (type << shift);
 	writel(val, hha_pmu->base + reg);
 }
@@ -453,7 +452,7 @@ static int hisi_hha_pmu_dev_probe(struct platform_device *pdev,
 
 	if (hha_pmu->identifier >= HISI_PMU_V2) {
 		hha_pmu->counter_bits = 64;
-		hha_pmu->check_event = HHA_V2_NR_EVENT;
+		hha_pmu->check_event = HHA_EVTYPE_MASK;
 		hha_pmu->pmu_events.attr_groups = hisi_hha_pmu_v2_attr_groups;
 		hha_pmu->num_counters = HHA_V2_NR_COUNTERS;
 	} else {
diff --git a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
index a0142684e379..80108c63cb60 100644
--- a/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_pa_pmu.c
@@ -440,7 +440,7 @@ static int hisi_pa_pmu_dev_probe(struct platform_device *pdev,
 	pa_pmu->pmu_events.attr_groups = pa_pmu->dev_info->attr_groups;
 	pa_pmu->num_counters = PA_NR_COUNTERS;
 	pa_pmu->ops = &hisi_uncore_pa_ops;
-	pa_pmu->check_event = 0xB0;
+	pa_pmu->check_event = PA_EVTYPE_MASK;
 	pa_pmu->counter_bits = 64;
 	pa_pmu->dev = &pdev->dev;
 	pa_pmu->on_cpu = -1;
diff --git a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
index dce7195320f2..ea31b64e05e2 100644
--- a/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
+++ b/drivers/perf/hisilicon/hisi_uncore_sllc_pmu.c
@@ -58,7 +58,6 @@
 #define SLLC_V3_SRCID_CMD_MSK		GENMASK(9, 1)
 #define SLLC_V3_SRCID_MSK_MSK		GENMASK(18, 10)
 
-#define SLLC_NR_EVENTS			0x80
 #define SLLC_EVENT_CNTn(cnt0, n)	((cnt0) + (n) * 8)
 #define SLLC_FIRST_BIT(_mask)		(find_first_bit((const unsigned long *)&(_mask), 32))
 #define SLLC_FIELD_PREP(_mask, _val)	(_mask & (_val << SLLC_FIRST_BIT(_mask)))
@@ -476,7 +475,7 @@ static int hisi_sllc_pmu_dev_probe(struct platform_device *pdev,
 
 	sllc_pmu->pmu_events.attr_groups = hisi_sllc_pmu_v2_attr_groups;
 	sllc_pmu->ops = &hisi_uncore_sllc_ops;
-	sllc_pmu->check_event = SLLC_NR_EVENTS;
+	sllc_pmu->check_event = SLLC_EVTYPE_MASK;
 	sllc_pmu->counter_bits = 64;
 	sllc_pmu->num_counters = 8;
 	sllc_pmu->dev = &pdev->dev;
-- 
2.24.0


  parent reply	other threads:[~2025-02-18  9:19 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-18  9:19 [PATCH 0/9] General updates and two new drivers for HiSilicon Uncore PMU Yicong Yang
2025-02-18  9:19 ` [PATCH 1/9] drivers/perf: hisi: Extend struct hisi_pmu_dev_info Yicong Yang
2025-03-01  6:23   ` Will Deacon
2025-03-03 14:43     ` Yicong Yang
2025-03-04  9:21       ` Jonathan Cameron
2025-02-18  9:19 ` [PATCH 2/9] drivers/perf: hisi: Simplify the probe process for each DDRC version Yicong Yang
2025-03-04  9:26   ` Jonathan Cameron
2025-02-18  9:19 ` [PATCH 3/9] drivers/perf: hisi: Add support for HiSilicon DDRC v3 PMU driver Yicong Yang
2025-03-04  9:27   ` Jonathan Cameron
2025-02-18  9:19 ` [PATCH 4/9] drivers/perf: hisi: Use ACPI driver_data to retrieve SLLC PMU information Yicong Yang
2025-03-01  6:43   ` Will Deacon
2025-03-04  9:49     ` Jonathan Cameron
2025-03-04 10:00   ` Jonathan Cameron
2025-02-18  9:19 ` [PATCH 5/9] drivers/perf: hisi: Add support for HiSilicon SLLC v3 PMU driver Yicong Yang
2025-03-04 10:02   ` Jonathan Cameron
2025-02-18  9:19 ` Yicong Yang [this message]
2025-03-04 10:11   ` [PATCH 6/9] drivers/perf: hisi: Relax the event number check of v2 PMUs Jonathan Cameron
2025-02-18  9:19 ` [PATCH 7/9] drivers/perf: hisi: Support PMUs with no interrupt Yicong Yang
2025-03-04 10:16   ` Jonathan Cameron
2025-02-18  9:19 ` [PATCH 8/9] drivers/perf: hisi: Add support for HiSilicon NoC PMU Yicong Yang
2025-03-04 10:22   ` Jonathan Cameron
2025-02-18  9:20 ` [PATCH 9/9] drivers/perf: hisi: Add support for HiSilicon MN PMU driver Yicong Yang
2025-03-04 10:24   ` Jonathan Cameron

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=20250218092000.41641-7-yangyicong@huawei.com \
    --to=yangyicong@huawei.com \
    --cc=jonathan.cameron@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=mark.rutland@arm.com \
    --cc=prime.zeng@hisilicon.com \
    --cc=wangyushan12@huawei.com \
    --cc=will@kernel.org \
    --cc=yangyicong@hisilicon.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