From patchwork Mon Nov 25 10:43:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13884804 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 ED2A9D3B7FF for ; Mon, 25 Nov 2024 10:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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:In-Reply-To:References:List-Owner; bh=T+PTzzcnP9siLZGzwp8bMcE8d7Ixq6pDTA7Zs0n5dJs=; b=X51c1J1QKXV7jSUGPx2g4TEVD4 Z4z1ytqDEIOauXgwgTpTCu8lLKgeAdBOr4YsJhByVtOO9yXydOICEFqb3pLPXUMHgjeYX8fTnxn66 jXTU830bMYtyuOssITbxIQRbuw+Whiz9G9kiR5WwWMZB1UerZn94anmgBuuwGQUyTDumu8kzWfz1I v25qPeznsCIUcAagw36DrywK/fHUSnTbWqFVG/d2PmyXgq8eOeNLgQCrt4GCAP/A5mkdvdPX+Ft3h vtMy8dfStcussJACT+e2GZ0cingow8t+G37JATEvvoH/UJKTFue2z2LD0e3xCvlVtVtqngbysPiht MFl3l+UA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tFWaA-00000007nlg-2cHJ; Mon, 25 Nov 2024 10:44:42 +0000 Received: from mail-am0eur02on20630.outbound.protection.outlook.com ([2a01:111:f403:2606::630] helo=EUR02-AM0-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tFWZD-00000007nZd-1Mzv for linux-arm-kernel@lists.infradead.org; Mon, 25 Nov 2024 10:43:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XoVzud7wfsm/Ec40sxeFEmExlCWF7ev3mIlnuIKFCxB8r0zp6zVXtiEs++S/26QOF02f4Liu+4L+X3hvd4SGrLcZDOFHWGF+7j/IICtY9nel3SEGkbS5Vh+CoTV5QnkjgQqNVkg9tiZH6eBxjWFgB1h2IOIBtu4ZDsEr1M+QM7X1ZfIZSjvZi/dF7gBLOGrZqJxMMC6mkYy1EMo59LgyZv5CHWGX6rYDaZXdH678btB+TkxhrpKHUreoYj0VcURM0SfFDORchH4CSFdbXNabKCoeG6Ofs+aZzj51s9L+OoFI/e9G7a2kVG2tFGU7oTgSbs5ZzU/QYX+NCF2GQ+6CXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=T+PTzzcnP9siLZGzwp8bMcE8d7Ixq6pDTA7Zs0n5dJs=; b=blDWy6i/KDlAoty6Wrid+Pl9bJA5iN++Te114st6/iZmwPMyguTrv/0o7cslcZ4nxG6A6WYxETKwzIPBh0OfKVNsJR4B95CZHyA3hPMIhW8CEXgn/TgcgNhh33dLihzW1Z7kTn1hGMXmS2AWVmq6KZrwGm7dFKNXGKAVOwsRAatkDUe3lWJTKPFw9F91BbTNG1/+gGAwPmLQZRXS44vK8E4unkfE6MtODSJnc2VSg5Y0FO3kTreIovB4G5xlZ8oT90DD4unoGsAFHbWz8QNzENX7CjalH5j9QYeP5MwlChkXRo1x6hcEiaOPzja335VnMOTXGg0Eex4hgDtJY4CgeA== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T+PTzzcnP9siLZGzwp8bMcE8d7Ixq6pDTA7Zs0n5dJs=; b=FJvsAF1w2SVw19LiyjqjFye0+8m/uQc6izDhDcQLDsa/Ew7D7DGVRLtKn77x8iRxw6I0faJm8Z8fiobEJaoM+iMyJMrSC7dt+caxtVXBJSUYS/EYpsaZIkTvtG8CXmSwziDtisq9NewjC+YH9/xeJjsAjHkQg9Qc66jyQOdnNtMAVVcSpxPVPIKADxCCFqUJlKnqAnYG9bFDbL59/NjGXuRz1Fv3etfhy3wl1l9D/gNW8ly1fJ/rcgHSxx0fA+ul+zMxlrRwce+t4DyBE+no7xpEkhPskRCOoonAs71QYs0duSZ2o3BmG0Rj4Qf9d0NVkWuZpm/0txEcng8x6tZKyQ== 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 AS1PR04MB9503.eurprd04.prod.outlook.com (2603:10a6:20b:4d1::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.18; Mon, 25 Nov 2024 10:43:37 +0000 Received: from DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::4e24:c2c7:bd58:c5c7]) by DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::4e24:c2c7:bd58:c5c7%6]) with mapi id 15.20.8182.019; Mon, 25 Nov 2024 10:43:37 +0000 From: Xu Yang To: Frank.li@nxp.com, will@kernel.org, mark.rutland@arm.com, shawnguo@kernel.org, kernel@pengutronix.de, festevam@gmail.com Cc: linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev Subject: [PATCH v2] perf: imx9_perf: Introduce AXI filter version to refactor the driver and better extension Date: Mon, 25 Nov 2024 18:43:38 +0800 Message-Id: <20241125104338.2433339-1-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SGXP274CA0012.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::24) To DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8822:EE_|AS1PR04MB9503:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a702f3f-f225-4fc5-7553-08dd0d3e04a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: gpRrOqy3jNZJnhoB8vtgcFkRANr7Vdj37BHvd8Pm6w/wvBRnRd7DL5BwuIEr23YyEdTf7dvVPWRISyNE3+HrbDhBY+NuBzO6hn5ot46SmHPz4INxR3vecSfoeBR5a/CNQM4HQRFwsapcgZU2cE5tW5zoUbFp2BuHZgDRYOth3oHgWUrptM0UaEsJBTotywTdZiaK93naFiUUpMWdPW/WF0uUyRem1nA2mbm9vKwYW9Wjgow2iLs1i5uA5Qf0cWEktg+YChnq1MSlErufBx/S4/W111sqGCx5DbWZJ+L4+G8liEnH2WVYgOxu+VkZXUl081heyPPduy1fy52qLzv9UNSSWRHkK0TY+VKJb6WF7YLhHb9l4U9KwGAyLWxJLXFrg4WA7E1vc7PeuhOfIk3OhxcV28jIERhFcpsd3012UGXy01P6Nn3IQp7iOBXyG7BdE+25522x4+x/aO6ZeaK8HSwr5Drr3FZ4Z240jgmf/5ZXoTSJH5X7m6iXV5f65ZZnkprtmsDjjHAxnZEXGCkKgV9LJ4DclGR3flbznWYnB28iONOzBy6con96mdwiy6VMcUW7PuptRJhbbS1WoXyUGyNOHgZUiS3HEjnxa8fj5L0Apdw13fqrpGztoqVRa0XvExwUpnLbebirikALeGVC4qGG13gWDpKl0Yfjyebo8h17U9bzMSABrarlIn3MPpVvppuL+Zk4nNS41DhVejzYpsaqBLR71c4F5xZ0XdQuA/Ej1FFqu0G+4HALCos94W1Vm3JT0AXujpwUsEOgAdP97kJ38OkEElb6FBVFVWWzkX6CTohzR7F4DO4D1qq6sKnyjJ6zshHcJqZJcquBQTb9QQQ42x+UQBJM1Vl++FRHKzNxtTGF1YQ+F2HN1rxWsYD9dH870s+7yj5XmYOyKw1BGw33cbadlFA8fkqW5Z1PaRS9K3m3liqbc+J0P/xp445cwFWZ8iGHS/nG0WUosG4pJNQYIVfzWXA03Y5YKlL7h6WlrNCAK66ueHAZMczgfgLna59u6VP4bIrnhA2ZasGOUht10QicbXwq2rPKkyJuE0Yd/etWVWB2YXhN87CPTl//8k9d4E4QNwJai104ZM0fR4yybze6cUSxANOfgTz/v83z00y2f/EFrCViUzzGJVjWVoy3iFzU79jnyZtuGLm+VUHi/kjHEFYQFymOHTLviNUcaWq5f2snzv3zwG6cW4E0dGwwleLr9kwkAO0aqehRX9MIsNTmddwP78/IjgfItLa9lEabwZXU6Tp+Xtk5KTayc+/yfp81+VXkMiiGOZ4qfjVTUyPEoDbEmYXnCgwFHJCqqzThMn+0sPRMRMhBMWkXg16OYebzCwD+G1HL+vLtd6vTxQKA/8M+4O8cbU7kv726l5AsVLTs7hJXWnRIOcEd57VxNxHUCrUFNiwxlj0tkw== 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:(13230040)(1800799024)(366016)(376014)(52116014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qOBJ2MrX2VCUvZ+Qzbd8nxZ65KjUt6qW/kuKdFa0QnWyHOYFItzmkm8F8PRnlF6NX44yOOiS/p6J5UVm7s+Fj6dfc8Py9Hq93Mp2ku2p2S6UAN6P0nXiOHe2DCgN7bdqi+CrpaBGXuREWi4/bk+kqvNViuaB0qJBdLnHb5Atti2MJGgTmJhz7vdSf3iEiE9BcI/y5Nhk/H/jZgct6f8UJC93RacOBq1q5t35el30naIGu1FL0q4EhhifpECH3ClPnblVzDXIep7mf808EFP8eK3wTXlitiqfQFT1u10Ija2001CMMxC+Yy+tD4SkZ0UMS81vIH1ooskqo3d7g//ywO+5uQH/0QDkeIJWWx6oXxJgvwYe82rInlFhebBBMr5sCuWVtbbIsENtLqBRZ0hcUN7gGeNi3WUtDAnMl+uUbTgycfgNbVPVrrAukSpQDzOYccVSJrJgc18LJaD2WD+8bdBGGhsDQ94iggo5LySP4yCm1aykKaIIc8z6+x7OARsKT4xcL5UDUtYuZ5x3TXfIJMemEwLwl7V9F5ErLXXg4ZXfnFs8YFBJAq2SIuXp/ARsCXn1cambAK5IR4Dsc/Gb0d0XP8zQRo X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6a702f3f-f225-4fc5-7553-08dd0d3e04a1 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8822.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Nov 2024 10:43:37.5288 (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: MKChXnpJ74LT0RIE9nQ0BM4uv47QPy6bupKbPVX4Pf3MAfNs3UuFKjFFJLfNFeF8wUo7RKYRmfBjDb66mz9uPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9503 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241125_024343_366471_39B41E7F X-CRM114-Status: GOOD ( 18.28 ) 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 The imx93 is the first supported DDR PMU that supports read transaction, write transaction and read beats events which corresponding respecitively to counter 2, 3 and 4. However, transaction-based AXI match has low accuracy when get total bits compared to beats-based. And imx93 doesn't assign AXI_ID to each master. So axi filter is not used widely on imx93. This could be regards as AXI filter version 1. To improve the AXI filter capability, imx95 supports 1 read beats and 3 write beats event which corresponding respecitively to counter 2-5. imx95 also detailed AXI_ID allocation so that most of the master could be count individually. This could be regards as AXI filter version 2. This will introduce AXI filter version to refactor the driver and support better extension, such as coming imx943. Signed-off-by: Xu Yang Reviewed-by: Frank Li --- Changes in v2: - modify subject - add comments for AXI_FILTER version - type -> filter_ver --- drivers/perf/fsl_imx9_ddr_perf.c | 33 ++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c index 3c856d9a4e97..e2c2c674b6d2 100644 --- a/drivers/perf/fsl_imx9_ddr_perf.c +++ b/drivers/perf/fsl_imx9_ddr_perf.c @@ -63,8 +63,21 @@ static DEFINE_IDA(ddr_ida); +/* + * V1 support 1 read transaction, 1 write transaction and 1 read beats + * event which corresponding respecitively to counter 2, 3 and 4. + */ +#define DDR_PERF_AXI_FILTER_V1 0x1 + +/* + * V2 support 1 read beats and 3 write beats events which corresponding + * respecitively to counter 2-5. + */ +#define DDR_PERF_AXI_FILTER_V2 0x2 + struct imx_ddr_devtype_data { const char *identifier; /* system PMU identifier for userspace */ + unsigned int filter_ver; /* AXI filter version */ }; struct ddr_pmu { @@ -83,24 +96,27 @@ struct ddr_pmu { static const struct imx_ddr_devtype_data imx91_devtype_data = { .identifier = "imx91", + .filter_ver = DDR_PERF_AXI_FILTER_V1 }; static const struct imx_ddr_devtype_data imx93_devtype_data = { .identifier = "imx93", + .filter_ver = DDR_PERF_AXI_FILTER_V1 }; static const struct imx_ddr_devtype_data imx95_devtype_data = { .identifier = "imx95", + .filter_ver = DDR_PERF_AXI_FILTER_V2 }; -static inline bool is_imx93(struct ddr_pmu *pmu) +static inline bool axi_filter_v1(struct ddr_pmu *pmu) { - return pmu->devtype_data == &imx93_devtype_data; + return pmu->devtype_data->filter_ver == DDR_PERF_AXI_FILTER_V1; } -static inline bool is_imx95(struct ddr_pmu *pmu) +static inline bool axi_filter_v2(struct ddr_pmu *pmu) { - return pmu->devtype_data == &imx95_devtype_data; + return pmu->devtype_data->filter_ver == DDR_PERF_AXI_FILTER_V2; } static const struct of_device_id imx_ddr_pmu_dt_ids[] = { @@ -155,7 +171,7 @@ static const struct attribute_group ddr_perf_cpumask_attr_group = { struct imx9_pmu_events_attr { struct device_attribute attr; u64 id; - const void *devtype_data; + const struct imx_ddr_devtype_data *devtype_data; }; static ssize_t ddr_pmu_event_show(struct device *dev, @@ -307,7 +323,8 @@ ddr_perf_events_attrs_is_visible(struct kobject *kobj, if (!eattr->devtype_data) return attr->mode; - if (eattr->devtype_data != ddr_pmu->devtype_data) + if ((eattr->devtype_data != ddr_pmu->devtype_data) && + (eattr->devtype_data->filter_ver != ddr_pmu->devtype_data->filter_ver)) return 0; return attr->mode; @@ -624,11 +641,11 @@ static int ddr_perf_event_add(struct perf_event *event, int flags) hwc->idx = counter; hwc->state |= PERF_HES_STOPPED; - if (is_imx93(pmu)) + if (axi_filter_v1(pmu)) /* read trans, write trans, read beat */ imx93_ddr_perf_monitor_config(pmu, event_id, counter, cfg1, cfg2); - if (is_imx95(pmu)) + if (axi_filter_v2(pmu)) /* write beat, read beat2, read beat1, read beat */ imx95_ddr_perf_monitor_config(pmu, event_id, counter, cfg1, cfg2);