From patchwork Wed May 29 08:03:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13678179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F009C25B7E for ; Wed, 29 May 2024 08:05:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GZ6EkG7n2UI2AbbAFFUPRmUvsPEQYvO6RQHwKjuq26I=; b=GJ1xBO1YCEuytM gBt9VPSmzW1aLe7gixg7LO6dQZmIZhW7rFrnkmThRAw/sN8dlpC46CcSYLgANqp3g1NIn3Ue0yKx5 QElUod3UALhbxsQrEZ7cwI3knj2Zd+MuBOxXTFvzMuSmjGY+hwboHpmQY6J1YZrZZKYV2FFMpO+ix 20uqwAemhAwnIB5J4MOJpN7BAR3ETOLwpWmUyXGCMkvXTSgLFmhGx42EZ9aV7V5HP9cbiNXIeYMyc oiZapgoo0z4+iTQaidzu9O1pZ9PbPmWs50QSzws6mKESIJJ/Ge7g6ReIIEyHiY3KbkaxZ2tkWUfUY Sh4y18PGZZxvU20d1PMQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCEJH-00000003Gps-1T63; Wed, 29 May 2024 08:05:23 +0000 Received: from mail-db3eur04on0600.outbound.protection.outlook.com ([2a01:111:f400:fe0c::600] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCEJ8-00000003GhW-3PnT for linux-arm-kernel@lists.infradead.org; Wed, 29 May 2024 08:05:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AjISoPEzzOCRF3h6gHG04e46IWjFsR93L2MeeL7YKkDJ8VC30uZ8jXthqwp5XttOhQOJ4Lyw3nXiuVbMD950zmcNXUxcUFdk0INkpxQVx024PTwSiI99TDW8hDiviimduMEQHpG/juy1Ek4Q50xLx0tAyfWCU4+gMsEyqnqkr/3xswbYyXFzp9t4RwsWn9T1u+sDMKPkCSUDdllITPHeEHCOY+SMRVwr5kKL2UMS+kRTzOp1bhvQsJVBVtrB4W4VYNZa7MJDlBJ0TEGh+Fjng2uxol0VFRXrRnytoOUAIuU9NgHQsKx/NxrmXfLfYmDKLrYT6Q1OSbIHbyaYJL8V6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UIVC9q49Y15Eo1eTfe07H/cIjOoYuuo1u61ZEqfwFT8=; b=dKidtkHTIGBzHdiRUf/4m8KkssRhTMle0/ALh8blB6Nvaq0Tw5pisjTJfbwlSOgfN73HiyHacSnX5hDiF0mhIhp0WTP7E5K9P6By6JAqolW86BbZLgfz2ixvQGoMEWyb+JrVFQTJS7d7VzuG0QvGIioG+Tjyx6AM/gWAEG++9JTnElRD4s86CemQYJ4tEzln2ZGfTd3E0o8TTLLB9y6zX/t5bIMsBaL6xBZp+3jl2GchQ7hIgTHA9aNGbhpy2EJYmyOxfGTHQPO21qBmf7B6vYLo3bbDBmbj8q64zQ6O6wCFxU14+hSQWEBqtm2h1b7ffjvLr5vdiWLcFrcYN+Pa4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UIVC9q49Y15Eo1eTfe07H/cIjOoYuuo1u61ZEqfwFT8=; b=bDV48EZzVQNyBexxVb/BBO1O1hg/VV9C+HJHOg2QJCE0Nwc+MN6hgxhe+NcwsthIACoAkD//q59fLOw0KX/6cDrQ59aXjtZ6jifPe0DBb1NwZHBH35Awl6ArhLm6K4Xa/xjiwK3w/tTNHi2FnSSto+MW1o2AigrYzQqNTaJnU0w= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) by AS1PR04MB9384.eurprd04.prod.outlook.com (2603:10a6:20b:4d8::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.19; Wed, 29 May 2024 08:05:11 +0000 Received: from DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::4e24:c2c7:bd58:c5c7]) by DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::4e24:c2c7:bd58:c5c7%4]) with mapi id 15.20.7611.025; Wed, 29 May 2024 08:05:11 +0000 From: Xu Yang 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 v12 6/8] perf: imx_perf: add support for i.MX95 platform Date: Wed, 29 May 2024 16:03:56 +0800 Message-Id: <20240529080358.703784-6-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529080358.703784-1-xu.yang_2@nxp.com> References: <20240529080358.703784-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SI2PR01CA0016.apcprd01.prod.exchangelabs.com (2603:1096:4:191::20) To DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8822:EE_|AS1PR04MB9384:EE_ X-MS-Office365-Filtering-Correlation-Id: 74614e21-2cb5-4cb9-0d07-08dc7fb61018 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|1800799015|52116005|376005|7416005|38350700005|921011; X-Microsoft-Antispam-Message-Info: rdGtisgGDsH61WQ0nEnKEIbkGzatdMzAqMN7QT1cYEFTpJaC3/G9+XWLNYXZNTx4a8cjfU+hMbYKMshfqIUbSy1yCgi9p5md3IneQ+EDxUcstB8DZDh1MRIwsc3z3zXV+s6yUGPIzfmEAV/9dxwuN/lKpGmGeONWPHBPZ+k0LcBakVtLdIGVgfwn8GsyM7ugij7hvwbQOnjMx5aD0h7Hvj2tV06TWJjA+RyR9jRiKOnkPPhKsSm7R2gwHeNrDu3EXi+lLD6+ELKU6psKmU8zV+B0p6uvIrZSW3vcCDZzjPm3EFMHjMu+3mNhPxb5EM8ZE6eXLye+IcJXN0ntxtAjljeMP8NG8qs6L8SuAqcP5aZKZkcl7I/R5ykWiImDT8ivoDpdBEuE3QA5TtLW6Hw0ccY9IUaMOovwCoKOp8GoPMnROij01tj+IlmtFc+ypOxKH/NCsanJ8pLV3/++WaoqnfXstM+l/lNcHCNWtF0uMSNEOmKG/edBo2mx4gdW3JGq1wYvzxeCaV5/GprNYf3iOv6R9+MpzTFJ0NK0XeJTN8oYCl4R63+eduSO7DZ0JeusXo/jfzweaB/5DZtcXu6M/FVtGf9jJbYbLpqbQfOC2FYVRRz9yo1yAzvw1AZJybo/pVNdg3wgiO+Mtf3p4YpO6MLFHJ0zvGYNnktf1a6tIPZi9v0KBwQoDt96vp9fqMJZca5/O+HPTacO0YTkwpoIBa//DF1gVhMhFDfxPGNzwfnSghNKt9HOoyX3cworFcqQ/+dfw0ma9NYFcdTuqnIfNfoMHgPVlhT88t+NYAKfn0evrtxEkk4Re257V1i7V/GvzmKMkFSTiDUyr15xxASVmeGkxDKOYdyFG/B7dwRgIV6k9jYMk8yzoE8ZrvAf8NTNG38gzB1I/feyIAg88kTEHwXgbemovvpPcNLn2+RIRmpx5Z4MvDgeQAKRjQbLGHgb9iA0hmdpNL5bkCsoOVKE+aD/JdkK4wl+4M5dk4EmPR+HSlJTWJgUW7dbnoOmkN0X8NLoMIeFFotBjZKZTNJfXBmLlUyhlEb/bwgA1ZN42iddQJvM73Hl2OnkbVkxFxfJX8y1iBqAA6TZMlz6b69vFb/sp6kT05HBcP7QBONrEmKt8H70C8N/U1E1JVSqf5DU2CMBmS2tPxoOnao5DBAMJXb18S2wQ7Z7S8EogQ9r86MCi2KbuByOmclbi1JqrQwsJBSdtb2YblduUAjgBuuaAgAZApqUvulICEfxzdMrjMt3iC0/sZp/tBCumwMgPvISUIkoLW/djg4V2j83a6mslhCng0npruQbfCtc1QdH4QP3+x7/cgBcqi7KbKRlM0JgfwQABDdj/gduTa1nbdv2qg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8822.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(1800799015)(52116005)(376005)(7416005)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: buCoGAu+G1tUuG2j5mCeV/+9uJOUvKyAmF0GL7VbHuUv0bywSXKSLiZqlq8cHW46UBwGBfOa4T2+WokfYAUUhpPmdck22TqDQol+UKM80Wfs+i2sjCQ+bdeiLKjsAepg1LSNml8WMoWfVRXjVw65f4A4Aged2wSgzzzdCxZ3QDUB+9pUNBl1MVVn1Mk/RWhCpY137I8nLyeIs1ogOaDkGJRFORmrDXtDM+MSc5p6NyGqce7XR2kXKPhaxmgD1y/6PP1LX8MLq3e81hd/M9PynN54sEipbQQ8bB5fvq1sG+EjlhkjnJI52BCoGeg1HkF93GgA/eRBDXL2pqQu+SRSf6qgxd7Jm2hmBAs/k1jmDpTu7U0dDzlAbI1UbvaIdupAMhx7ETuFy2h0COpRN4a7HrL8cETB39Vna2lyHhJJ1cSK7Bsv6p/7VwHA1QcHIYSEp/k4XfB9KT490LGU1Kzz6VdF+dEn/BrJCXGRqjG5skES/e7E2cpnENNHmEUtNKzM87+ma8Yv2PCDrVEVEnaZow+QsUh8FLpNBnECacyU860IUJ+w0a3JXyjcWbmNiqZ8ezZ2kfj4A7nnCMzf2Z6/IbnOjwhGrZRsRoJeuySgtYfB23t+dodc7TP15veQ3MGajvEM72Fso5iS+q1aBHQ/d+IbI6Gd526u1GTkeF/5c0sKuk+qNn5R1tkrhSjV8YWk/2Syr4TloCb25yQReXrJuS3V1r5d1y1dPy08wPi69Z3roi1Itq4Eb1jK3jV3XJO1IhVF6AupZVHYScj7V3qtRxGzDDiYEYEb9g/nByaKpXiA+wmREN3tz+fDTQyTuS1vdCbx0T8cDeKAqOE/hyghy7OWDRB1RPZQkitaHnzipehv6tW5zBhtj32gDyNcKB/v8RhBYxYlY3srrfA/j3wlyjarddwXv5hIlM5F6ViGpcEtM2rpqQNabqHzDq6QqlTvYCi4K9DWVkYXRiLa3bo4cXInChZM5gtXHfQYvVl2uiQRm7WME5jopr2fCTR6JppnmTnO0n4slUrRPhnLbNkq10vlnoJO31ikI2ljK8Emsnj+FEjJ2LQxg/B479KX6GTPOwx5ARP2IgGTrl81iqUwgEtG45LZ2JiVWRmgSsDHcnDXGZf2QXcHo6Z6V/2Ntqojp/YgOprlL4VVw8vv5VQTq2yLuYqFv51NCgi6odWu+mCjQ3vGIYp2mb9/mdKlmhm30OF1eUQdvwl/tK0ipMZw0VE02j0N12N2oaWdaT6YEbiANAMCBviroKS0wACK6lLzxKwvw3OemAOuUS7FocXtj93TEq1yeXU4mTWmWObN5l9f3bR7Qjl5fx5ZUL+IGFeYwiSrrcppHgVRhL1+ug0uZh7LJMWtEX0LiZSQhWnDtCYQwpMtfDthGD6GcNgB2fjYwaACF3oHe2j96kzDXpZkM9sj9b3dkxNxedQyX1jJMUZDCQl1PZ7S/EodgYwNY16JDxLqwWoL+v2mrm5iP2/OLws4TB9Ug2lTZaoCtAkOUFpXY6gDCJgcxYM2iMrb5F7n3ncAj8weEgIzuV4hQQuoVhG9KjE5DMXd3Q3bD247fhBKa9a/JhTlnJhPb7yuW2cS X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 74614e21-2cb5-4cb9-0d07-08dc7fb61018 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8822.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2024 08:05:11.2409 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XyfBI3c0fo3NH5e+w865YGg0AXG787diEsIvaYOzx/BoK+gJHLz6LzopmOx4AQTIAtSXmVFJAUKRTyOMuGv7bg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9384 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240529_010515_163143_18FA26BF X-CRM114-Status: GOOD ( 20.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org i.MX95 has a DDR PMU which is almostly same as i.MX93, it now supports read beat and write beat filter capabilities. This will add support for i.MX95 and enhance the driver to support specific filter handling for it. Usage: For read beat: ~# perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_rd_beat_filt2,axi_mask=ID_MASK,axi_id=ID/ ~# perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_rd_beat_filt1,axi_mask=ID_MASK,axi_id=ID/ ~# perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_rd_beat_filt0,axi_mask=ID_MASK,axi_id=ID/ eg: For edma2: perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_rd_beat_filt0,axi_mask=0x00f,axi_id=0x00c/ For write beat: ~# perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_wr_beat_filt,axi_mask=ID_MASK,axi_id=ID/ eg: For edma2: perf stat -a -I 1000 -e imx9_ddr0/eddrtq_pm_wr_beat_filt,axi_mask=0x00f,axi_id=0x00c/ Reviewed-by: Frank Li Signed-off-by: Xu Yang --- Changes in v2: - put soc spefific axi filter events to drvdata according to Frank's suggestions. - adjust pmcfg axi_id and axi_mask config Changes in v3: - no changes Changes in v4: - only contain imx95 parts Changes in v5: - improve imx95_ddr_perf_monitor_config() - use write_relaxed to pair read_relaxed Changes in v6: - no changes Changes in v7: - no changes Changes in v8: - add definition IMX95_DDR_PMU_EVENT_ATTR Changes in v9: - add Rb tag Changes in v10: - no changes Changes in v11: - no changes Changes in v12: - no changes --- drivers/perf/fsl_imx9_ddr_perf.c | 89 ++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 3 deletions(-) diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c index 7b43b54920da..69f920b1caf2 100644 --- a/drivers/perf/fsl_imx9_ddr_perf.c +++ b/drivers/perf/fsl_imx9_ddr_perf.c @@ -17,9 +17,19 @@ #define MX93_PMCFG1_RD_BT_FILT_EN BIT(29) #define MX93_PMCFG1_ID_MASK GENMASK(17, 0) +#define MX95_PMCFG1_WR_BEAT_FILT_EN BIT(31) +#define MX95_PMCFG1_RD_BEAT_FILT_EN BIT(30) + #define PMCFG2 0x04 #define MX93_PMCFG2_ID GENMASK(17, 0) +#define PMCFG3 0x08 +#define PMCFG4 0x0C +#define PMCFG5 0x10 +#define PMCFG6 0x14 +#define MX95_PMCFG_ID_MASK GENMASK(9, 0) +#define MX95_PMCFG_ID GENMASK(25, 16) + /* Global control register affects all counters and takes priority over local control registers */ #define PMGC0 0x40 /* Global control register bits */ @@ -75,13 +85,23 @@ static const struct imx_ddr_devtype_data imx93_devtype_data = { .identifier = "imx93", }; +static const struct imx_ddr_devtype_data imx95_devtype_data = { + .identifier = "imx95", +}; + static inline bool is_imx93(struct ddr_pmu *pmu) { return pmu->devtype_data == &imx93_devtype_data; } +static inline bool is_imx95(struct ddr_pmu *pmu) +{ + return pmu->devtype_data == &imx95_devtype_data; +} + static const struct of_device_id imx_ddr_pmu_dt_ids[] = { - {.compatible = "fsl,imx93-ddr-pmu", .data = &imx93_devtype_data}, + { .compatible = "fsl,imx93-ddr-pmu", .data = &imx93_devtype_data }, + { .compatible = "fsl,imx95-ddr-pmu", .data = &imx95_devtype_data }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, imx_ddr_pmu_dt_ids); @@ -158,6 +178,9 @@ static ssize_t ddr_pmu_event_show(struct device *dev, #define IMX93_DDR_PMU_EVENT_ATTR(_name, _id) \ DDR_PMU_EVENT_ATTR_COMM(_name, _id, &imx93_devtype_data) +#define IMX95_DDR_PMU_EVENT_ATTR(_name, _id) \ + DDR_PMU_EVENT_ATTR_COMM(_name, _id, &imx95_devtype_data) + static struct attribute *ddr_perf_events_attrs[] = { /* counter0 cycles event */ IMX9_DDR_PMU_EVENT_ATTR(cycles, 0), @@ -204,6 +227,7 @@ static struct attribute *ddr_perf_events_attrs[] = { IMX9_DDR_PMU_EVENT_ATTR(ddrc_ld_wiq_7, ID(2, 71)), IMX9_DDR_PMU_EVENT_ATTR(eddrtq_pmon_empty, ID(2, 72)), IMX93_DDR_PMU_EVENT_ATTR(eddrtq_pm_rd_trans_filt, ID(2, 73)), /* imx93 specific*/ + IMX95_DDR_PMU_EVENT_ATTR(eddrtq_pm_wr_beat_filt, ID(2, 73)), /* imx95 specific*/ /* counter3 specific events */ IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_row_collision_0, ID(3, 64)), @@ -216,6 +240,7 @@ static struct attribute *ddr_perf_events_attrs[] = { IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_row_collision_7, ID(3, 71)), IMX9_DDR_PMU_EVENT_ATTR(eddrtq_pmon_full, ID(3, 72)), IMX93_DDR_PMU_EVENT_ATTR(eddrtq_pm_wr_trans_filt, ID(3, 73)), /* imx93 specific*/ + IMX95_DDR_PMU_EVENT_ATTR(eddrtq_pm_rd_beat_filt2, ID(3, 73)), /* imx95 specific*/ /* counter4 specific events */ IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_row_open_0, ID(4, 64)), @@ -228,6 +253,7 @@ static struct attribute *ddr_perf_events_attrs[] = { IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_row_open_7, ID(4, 71)), IMX9_DDR_PMU_EVENT_ATTR(eddrtq_pmon_ld_rdq2_rmw, ID(4, 72)), IMX93_DDR_PMU_EVENT_ATTR(eddrtq_pm_rd_beat_filt, ID(4, 73)), /* imx93 specific*/ + IMX95_DDR_PMU_EVENT_ATTR(eddrtq_pm_rd_beat_filt1, ID(4, 73)), /* imx95 specific*/ /* counter5 specific events */ IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_valid_start_0, ID(5, 64)), @@ -239,6 +265,7 @@ static struct attribute *ddr_perf_events_attrs[] = { IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_valid_start_6, ID(5, 70)), IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_valid_start_7, ID(5, 71)), IMX9_DDR_PMU_EVENT_ATTR(eddrtq_pmon_ld_rdq1, ID(5, 72)), + IMX95_DDR_PMU_EVENT_ATTR(eddrtq_pm_rd_beat_filt0, ID(5, 73)), /* imx95 specific*/ /* counter6 specific events */ IMX9_DDR_PMU_EVENT_ATTR(ddrc_qx_valid_end_0, ID(6, 64)), @@ -432,6 +459,57 @@ static void imx93_ddr_perf_monitor_config(struct ddr_pmu *pmu, int event, writel_relaxed(pmcfg2, pmu->base + PMCFG2); } +static void imx95_ddr_perf_monitor_config(struct ddr_pmu *pmu, int event, + int counter, int axi_id, int axi_mask) +{ + u32 pmcfg1, pmcfg, offset = 0; + + pmcfg1 = readl_relaxed(pmu->base + PMCFG1); + + if (event == 73) { + switch (counter) { + case 2: + pmcfg1 |= MX95_PMCFG1_WR_BEAT_FILT_EN; + offset = PMCFG3; + break; + case 3: + pmcfg1 |= MX95_PMCFG1_RD_BEAT_FILT_EN; + offset = PMCFG4; + break; + case 4: + pmcfg1 |= MX95_PMCFG1_RD_BEAT_FILT_EN; + offset = PMCFG5; + break; + case 5: + pmcfg1 |= MX95_PMCFG1_RD_BEAT_FILT_EN; + offset = PMCFG6; + break; + } + } else { + switch (counter) { + case 2: + pmcfg1 &= ~MX95_PMCFG1_WR_BEAT_FILT_EN; + break; + case 3: + case 4: + case 5: + pmcfg1 &= ~MX95_PMCFG1_RD_BEAT_FILT_EN; + break; + } + } + + writel_relaxed(pmcfg1, pmu->base + PMCFG1); + + if (offset) { + pmcfg = readl_relaxed(pmu->base + offset); + pmcfg &= ~(FIELD_PREP(MX95_PMCFG_ID_MASK, 0x3FF) | + FIELD_PREP(MX95_PMCFG_ID, 0x3FF)); + pmcfg |= (FIELD_PREP(MX95_PMCFG_ID_MASK, axi_mask) | + FIELD_PREP(MX95_PMCFG_ID, axi_id)); + writel_relaxed(pmcfg, pmu->base + offset); + } +} + static void ddr_perf_event_update(struct perf_event *event) { struct ddr_pmu *pmu = to_ddr_pmu(event->pmu); @@ -541,8 +619,13 @@ static int ddr_perf_event_add(struct perf_event *event, int flags) hwc->idx = counter; hwc->state |= PERF_HES_STOPPED; - /* read trans, write trans, read beat */ - imx93_ddr_perf_monitor_config(pmu, event_id, counter, cfg1, cfg2); + if (is_imx93(pmu)) + /* read trans, write trans, read beat */ + imx93_ddr_perf_monitor_config(pmu, event_id, counter, cfg1, cfg2); + + if (is_imx95(pmu)) + /* write beat, read beat2, read beat1, read beat */ + imx95_ddr_perf_monitor_config(pmu, event_id, counter, cfg1, cfg2); if (flags & PERF_EF_START) ddr_perf_event_start(event, flags);