From: Xu Yang <xu.yang_2@nxp.com>
To: frank.li@nxp.com, will@kernel.org, mark.rutland@arm.com,
robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de,
kernel@pengutronix.de, festevam@gmail.com,
john.g.garry@oracle.com, jolsa@kernel.org, namhyung@kernel.org,
irogers@google.com
Cc: mike.leach@linaro.org, peterz@infradead.org, mingo@redhat.com,
acme@kernel.org, alexander.shishkin@linux.intel.com,
adrian.hunter@intel.com, linux-arm-kernel@lists.infradead.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org, imx@lists.linux.dev
Subject: [PATCH v11 2/8] perf: imx_perf: add macro definitions for parsing config attr
Date: Wed, 29 May 2024 00:05:17 +0800 [thread overview]
Message-ID: <20240528160523.1695953-2-xu.yang_2@nxp.com> (raw)
In-Reply-To: <20240528160523.1695953-1-xu.yang_2@nxp.com>
The user can set event and counter in cmdline and the driver need to parse
it using 'config' attr value. This will add macro definitions to avoid
hard-code in driver.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
---
Changes in v4:
- new patch
Changes in v5:
- move this patch earlier
Changes in v6:
- no changes
Changes in v7:
- use FIELD_*
Changes in v8:
- add Rb tag
Changes in v9:
- add Rb tag
Changes in v10:
- no changes
Changes in v11:
- no changes
---
drivers/perf/fsl_imx9_ddr_perf.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c
index 72c2d3074cde..0017f2c9ef91 100644
--- a/drivers/perf/fsl_imx9_ddr_perf.c
+++ b/drivers/perf/fsl_imx9_ddr_perf.c
@@ -42,6 +42,9 @@
#define NUM_COUNTERS 11
#define CYCLES_COUNTER 0
+#define CONFIG_EVENT GENMASK(7, 0)
+#define CONFIG_COUNTER GENMASK(15, 8)
+
#define to_ddr_pmu(p) container_of(p, struct ddr_pmu, pmu)
#define DDR_PERF_DEV_NAME "imx9_ddr"
@@ -339,8 +342,10 @@ static void ddr_perf_counter_local_config(struct ddr_pmu *pmu, int config,
int counter, bool enable)
{
u32 ctrl_a;
+ int event;
ctrl_a = readl_relaxed(pmu->base + PMLCA(counter));
+ event = FIELD_GET(CONFIG_EVENT, config);
if (enable) {
ctrl_a |= PMLCA_FC;
@@ -352,7 +357,7 @@ static void ddr_perf_counter_local_config(struct ddr_pmu *pmu, int config,
ctrl_a &= ~PMLCA_FC;
ctrl_a |= PMLCA_CE;
ctrl_a &= ~FIELD_PREP(PMLCA_EVENT, 0x7F);
- ctrl_a |= FIELD_PREP(PMLCA_EVENT, (config & 0x000000FF));
+ ctrl_a |= FIELD_PREP(PMLCA_EVENT, event);
writel(ctrl_a, pmu->base + PMLCA(counter));
} else {
/* Freeze counter. */
@@ -366,8 +371,8 @@ static void ddr_perf_monitor_config(struct ddr_pmu *pmu, int cfg, int cfg1, int
u32 pmcfg1, pmcfg2;
int event, counter;
- event = cfg & 0x000000FF;
- counter = (cfg & 0x0000FF00) >> 8;
+ event = FIELD_GET(CONFIG_EVENT, cfg);
+ counter = FIELD_GET(CONFIG_COUNTER, cfg);
pmcfg1 = readl_relaxed(pmu->base + PMCFG1);
@@ -469,7 +474,7 @@ static int ddr_perf_event_add(struct perf_event *event, int flags)
int cfg2 = event->attr.config2;
int counter;
- counter = (cfg & 0x0000FF00) >> 8;
+ counter = FIELD_GET(CONFIG_COUNTER, cfg);
pmu->events[counter] = event;
pmu->active_events++;
--
2.34.1
next prev parent reply other threads:[~2024-05-28 7:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 16:05 [PATCH v11 1/8] dt-bindings: perf: fsl-imx-ddr: Add i.MX95 compatible Xu Yang
2024-05-28 16:05 ` Xu Yang [this message]
2024-05-28 13:15 ` [PATCH v11 2/8] perf: imx_perf: add macro definitions for parsing config attr kernel test robot
2024-05-28 13:15 ` kernel test robot
2024-05-28 16:05 ` [PATCH v11 3/8] perf: imx_perf: let the driver manage the counter usage rather the user Xu Yang
2024-05-28 16:05 ` [PATCH v11 4/8] perf: imx_perf: refactor driver for imx93 Xu Yang
2024-05-28 16:05 ` [PATCH v11 5/8] perf: imx_perf: fix counter start and config sequence Xu Yang
2024-05-28 16:05 ` [PATCH v11 6/8] perf: imx_perf: add support for i.MX95 platform Xu Yang
2024-05-28 16:05 ` [PATCH v11 7/8] perf vendor events arm64:: Add i.MX93 DDR Performance Monitor metrics Xu Yang
2024-05-28 16:05 ` [PATCH v11 8/8] perf vendor events arm64:: Add i.MX95 " Xu Yang
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=20240528160523.1695953-2-xu.yang_2@nxp.com \
--to=xu.yang_2@nxp.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=festevam@gmail.com \
--cc=frank.li@nxp.com \
--cc=imx@lists.linux.dev \
--cc=irogers@google.com \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=kernel@pengutronix.de \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=robh+dt@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=will@kernel.org \
/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).