[PATCH v2 4/6] perf/imx_ddr: Add support for PMU in DB (system interconnects)

Will Deacon will at kernel.org
Mon Nov 3 06:31:05 PST 2025


On Fri, Oct 24, 2025 at 02:17:14PM -0400, Frank Li wrote:
> From: Joakim Zhang <qiangqing.zhang at nxp.com>
> 
> There is a PMU in DB, which has the same function with PMU in DDR
> subsystem, the difference is PMU in DB only supports cycles, axid-read,
> axid-write events.
> 
> e.g.
> perf stat -a -e imx8_db0/axid-read,axi_mask=0xMMMM,axi_id=0xDDDD,axi_port=0xPP,axi_channel=0xH/ cmd
> perf stat -a -e imx8_db0/axid-write,axi_mask=0xMMMM,axi_id=0xDDDD,axi_port=0xPP,axi_channel=0xH/ cmd
> 
> Signed-off-by: Joakim Zhang <qiangqing.zhang at nxp.com>
> Signed-off-by: Frank Li <Frank.Li at nxp.com>
> ---
>  drivers/perf/fsl_imx8_ddr_perf.c | 65 ++++++++++++++++++++++++++++++++++------
>  1 file changed, 56 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/perf/fsl_imx8_ddr_perf.c b/drivers/perf/fsl_imx8_ddr_perf.c
> index 2a8426a74af98cf46725c2c70534829e198746f3..328287ab6326e3832aed85633957196548435d67 100644
> --- a/drivers/perf/fsl_imx8_ddr_perf.c
> +++ b/drivers/perf/fsl_imx8_ddr_perf.c
> @@ -53,18 +53,27 @@
>  #define to_ddr_pmu(p)		container_of(p, struct ddr_pmu, pmu)
>  
>  #define DDR_PERF_DEV_NAME	"imx8_ddr"
> +#define DB_PERF_DEV_NAME	"imx8_db"
>  #define DDR_CPUHP_CB_NAME	DDR_PERF_DEV_NAME "_perf_pmu"
>  
>  static DEFINE_IDA(ddr_ida);
> +static DEFINE_IDA(db_ida);
>  
>  /* DDR Perf hardware feature */
>  #define DDR_CAP_AXI_ID_FILTER			0x1     /* support AXI ID filter */
>  #define DDR_CAP_AXI_ID_FILTER_ENHANCED		0x3     /* support enhanced AXI ID filter */
>  #define DDR_CAP_AXI_ID_PORT_CHANNEL_FILTER	0x4	/* support AXI ID PORT CHANNEL filter */
>  
> +/* Perf type */
> +enum fsl_ddr_type {
> +	DDR_PERF_TYPE = 0,	/* ddr Perf (default) */
> +	DB_PERF_TYPE,		/* db Perf */
> +};
> +
>  struct fsl_ddr_devtype_data {
>  	unsigned int quirks;    /* quirks needed for different DDR Perf core */
>  	const char *identifier;	/* system PMU identifier for userspace */
> +	enum fsl_ddr_type type;	/* types of Perf, ddr or db */
>  };
>  
>  static const struct fsl_ddr_devtype_data imx8_devtype_data;
> @@ -98,6 +107,12 @@ static const struct fsl_ddr_devtype_data imx8dxl_devtype_data = {
>  	.identifier = "i.MX8DXL",
>  };
>  
> +static const struct fsl_ddr_devtype_data imx8dxl_db_devtype_data = {
> +	.quirks = DDR_CAP_AXI_ID_PORT_CHANNEL_FILTER,
> +	.identifier = "i.MX8DXL",

Is this identifier useful given that you don't add
'ddr_perf_identifier_attrs' here:

> +static const struct attribute_group *db_attr_groups[] = {
> +	&db_perf_events_attr_group,
> +	&ddr_perf_format_attr_group,
> +	&ddr_perf_cpumask_attr_group,
> +	&ddr_perf_filter_cap_attr_group,
> +	NULL,
> +};

?

Perhaps it would be better if you avoided adding a new array of attribute
groups and instead implemented the '.is_visible' callback for
'ddr_perf_events_attr_group'? That way, you avoid the duplication and
you can hide everything except for the three events you want in the DB
PMU.

Will



More information about the linux-arm-kernel mailing list