From patchwork Wed Nov 20 03:21:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13880678 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 0F4A2D6E2A3 for ; Wed, 20 Nov 2024 03:22:49 +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=VGPmNe7c3/3/mfKwQHXXJtQb3HyCvcAMQP7Jcac/ctE=; b=poi1H0o0Z82giHB2yeV2ifaKYc d4I/9VTpRPWhqXp33QrwGojEgz1E7t7+Sm9rZ4OtirNLh2+MLt3awfZkQpKrqsAaffDYfBTL/GrT8 5WpOfm/NTV622HbK4PLzs73q09tTKNJZeDvg8oj192xgpsJZUVjGrOmA28Igxt709Lun3Ncjg5FzD qQzfZig6bPSnq2s32fxafHW1QafSdTxFdMkDl2U4z4QaxdF8mdX2sIa0SwbpzAP66iILs2cFGwDVe bWdvdP4IoQq+PkEInxQ5eQgBB2hfxrqyn5dbTck8xxzW4ulEqS6htVDCBeXOVJwL1QfaqZWaJ4MJw 7Usl8prQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tDbIV-0000000EHhc-1AqY; Wed, 20 Nov 2024 03:22:31 +0000 Received: from mail-vi1eur05on20607.outbound.protection.outlook.com ([2a01:111:f403:2613::607] helo=EUR05-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tDbHZ-0000000EHdt-3Luz for linux-arm-kernel@lists.infradead.org; Wed, 20 Nov 2024 03:21:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yV0RI+0v8lkXOAYtcd2rw0bQuFozjWmFzMQaYaYbKKQKWjnrruFPZ7h8Jdv49BpWT9gZta3BrA1OiCiAQKeH/BDyeQoFSXXvXgRHRO2WswO0j8yZSJS5/fI6j++31kbPaFQWATohqx1P+beULEBPy3w69S2hrB59rvY9bfP9fuRvD2zc1k5zSzheCr5OeRVsw1TSnEKdhaPv/oqewTu0rHP1bLnM0SPUMD0G36+eNlByeyuWJUWuZBj9whLvkOCy4+RrOq9iQMsckjZzcVIlZybj1G+VB2Z8g/QZxGyaWsJ396qaBUBkjRaN2KAV/FwvJCBEuCmfErvZ6WJ7TSOxtw== 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=VGPmNe7c3/3/mfKwQHXXJtQb3HyCvcAMQP7Jcac/ctE=; b=Qx31ODM6XLmRgESl2yC52+14bBSvICss+eZDngNvldU/1aCQe1iahZmPdKxjkEsH9g0MhUgT1jcLtfOmD4RMp7f6ghcmJJyqhNNKjfj3w2zEpTwBnEaWn+Xni/H9EdO/8VNKvGWYi3WIHH0+nBK1mQzB2H5qYtT/Q6e2pX37bkEd3D2PeExNHb6u3xfw3VucoWrJhIAQlS5LTdxqeLRRAmUgag0b1ygISZwt8q9rGX86VTCgsLsWJpsmSvs5TcCl1Va96fDCEZ5RL7v8xhq+BfDlxqeBESkMb54rG6H6sXzy00xttSSr4LSkSoxpa0wvOpbJVrLr7xyI2M1b0TD3QA== 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=VGPmNe7c3/3/mfKwQHXXJtQb3HyCvcAMQP7Jcac/ctE=; b=FAxdRoSO3+LMlSJAJky+Lntb75fmPe4qKIDPUsE5W+lOu6OTfXBSnjz6BIJ12qi5rh0RSyEnOOuQJef4sznbcRa5YYZh7YqEe9rqZtLhQrRlGuLlKLTzUkY9gU+aq/bVRI5T3EPIstjPFhlb+JDDP+E6D3MjIps/GTJWH4p3XVAgA9FV+5LqPDi4GtFay2DbL58g+ol99rNIJbLdCLweW8mtGvUpSARoK77ILhQ18U+sfA0KEWCg2siNsxLc+SBqPExzvhUbmfq5A8c6leRd6by1DwKxg26eGWIMbiyMbUr71+lX6mpqWHg6puqhRtyL1CbTwl6HN2LqD11XW4z7ew== 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 AS4PR04MB9361.eurprd04.prod.outlook.com (2603:10a6:20b:4e6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.14; Wed, 20 Nov 2024 03:21:22 +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.8158.023; Wed, 20 Nov 2024 03:21:21 +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] perf: imx9_perf: introduce axi filter version Date: Wed, 20 Nov 2024 11:21:09 +0800 Message-Id: <20241120032109.1163146-1-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SG2PR01CA0155.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::35) To DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8822:EE_|AS4PR04MB9361:EE_ X-MS-Office365-Filtering-Correlation-Id: 58af18d5-0431-4ebb-bfae-08dd091267e0 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: knafvlDVf5UxIs1kq+8XVMYnzShdw/PM7fSLqzab2ySemeP0ckJytdXDZzCv37Zgdn41t9dKwoxbJ3GmUH7c/k4OXusL53xG7MxK5f6dXopymFMxPYBDPu1QskT1Hk0kv7nEHeoJlTZQ2nsRKSP8SB5rUd9ss/71+QSaukVWYdB5BGU+HU4s6IvzNVK+Iss1HcNacTHqpvM5VRzXaFGLL9DwJGNlE/NKu0fWjZPCK14Tu6p6fVAWhfqzbXladbnUsNWnZJJOw8rNL+nj+IfMyI7R+pE8COrJDLbkJwChjtVc9jsOop3jb1SvjnjVSypYuDeEhFkwXSRguOICd7CYQhxK1QrPr5bK8Csz+pjTS/Oj/3adfzBfQ+UyNxqC5FyQTG1pvdGjHAzbBDgf3n6nES73HySVr5KUjuvfS2egGYrRCfd7pXmhRCKLUA1koHhlMWJm6LeL6Wu0CoWkFl4m1CXEWbhBCtjHCjk8xYKG2+hT8JGa5KNWhD1bGqbCsyYrNd/BVdB9q2ZE88WRVLqlYZH0GJPym8P4zHMmpgVBusT3S/qvQzV9HVAoMT/2dGnXCY/LJGv6TFRBT7ClAZmv4BjWsZeF1MFDa91bMOm0YESGuQB+88UyU+tzQyi1gM02POBJLHvY6gU8x6hUhd8SUdHz8+uY8zXfnlKfE6NfwLioWszhWe5zdGpi72DsheUT9+Lf17S0tK83Kvlo4/644VbcUe3U+Nrxu872Om7inv/V8qhTANqTUR2Q7s9i1jS5hshTfQnDGCfPcw+zuAn9I0wIeNevm32X8LZxnioSjx7mZJp7dIUY5M17ZwZqdXEKqqGYVSH26+V5/nMNVrU6PUpPoQyKOujwB281CkoAqx4sEBWP1u9N01VdAx9BKtjHexIDzk8qSRPCdK3nympBJnTuKShA49OjCtpyBTiWtVXKLbWoaQF2nOLNH4uIueD/16XG7VAznINyvpq1ZC5yjYFOaNLKuHf4/8XnEwSsYoSPxffQenYqT+K9KQ+ZpSOG/dGZJfQnaogzgxWWSWQUXSYonh08B71iKbVRd6m5rLICm3hCxNOCcFSHJJqd2jHzsfV+Mlg9CiumjpVPj8Q8/1ATF1isgdkZftn8VzZjzKXf9t3s25303kYNXqcNaHtmSOTrrlgMDSzPEEIhkK0/msiP1CehaqGcPHN0VbIlUEwfWUWsofMKKR2K6/sALsGwSkSe4LnseKEcqzCp539/4CisloJ4lDFmmVH2Zfvd89VoPLLDEKmnn3TIVGfvXq8x0rep8N4mnu/WSoM0pDkOW/udysI4C9d7wo+t9YHckWUehiyRQmIlmTlBxOF6QlCxL3rtk/sbQS8nwcXYxT/EByj4X1RRIUXyb3dL/rFZqIU= 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)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-Chun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/0o+KuRHN6r1HkyRzrmjFXDSp0H5Y7lZpUbPS9UX+Sv0Iotkr9kdFdiMiF4hHyNjmLBT+YvEDqNc7wtJ/GLcWDgrIB2lSIpEeOSTktpUNvTbogt8OYal3iJxRRQ+H4JckNWUQCuF00xLqZBtV7yzmGu9+23/Ol8YdmMo5tMiBVDVUuiBHBd3NGJdgeDzBJMxL9pOz6eHPZyAy3BeAYgWDBsZdTU9KJGW1XhPpFkBP/ZhPisSrl9Kx5xjLTN2EUkIUfpDFHOdG1JI4sg+6tA5AE36l9yLia+XwgDjrr86RZUSFc9jKxf6BlBsVGKbH6Ycdaca+pk2/MZu1BfdRXt4z4stYjgH8oW7VcUbocLdHifAl7qebSudXF+FBFDaB7kKicj3Ke6Weco8gr9v0e8QFt8tbW762udfWnnTi+Y3a9uXNdDZCZyV8kOyXeSIHcADujZrACPX/wzpy+Y1obFfKRd4J5eF5D6qzdorgXZTryBl71zcdI1orZNW7aUV76Zti+dLlhtlyP61xTsrxfA73R4ZPeETmgwXTwTaXKI7JvGI+y X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58af18d5-0431-4ebb-bfae-08dd091267e0 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8822.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2024 03:21:21.5555 (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: peHTNTlh3lKNrVK5c0P4qlvca8Z6X8QdJYSk6JAcj04tf2Hn7gNWYQAdfVRkh/6b9uD9nEzHrKv/z6CE1Islvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9361 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241119_192133_837677_56D2AD2A X-CRM114-Status: GOOD ( 16.47 ) 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 --- drivers/perf/fsl_imx9_ddr_perf.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c index 3c856d9a4e97..965345d78f7a 100644 --- a/drivers/perf/fsl_imx9_ddr_perf.c +++ b/drivers/perf/fsl_imx9_ddr_perf.c @@ -63,8 +63,12 @@ static DEFINE_IDA(ddr_ida); +#define DDR_PERF_AXI_FILTER_V1 0x1 +#define DDR_PERF_AXI_FILTER_V2 0x2 + struct imx_ddr_devtype_data { const char *identifier; /* system PMU identifier for userspace */ + unsigned int type; /* AXI filter version */ }; struct ddr_pmu { @@ -83,24 +87,27 @@ struct ddr_pmu { static const struct imx_ddr_devtype_data imx91_devtype_data = { .identifier = "imx91", + .type = DDR_PERF_AXI_FILTER_V1 }; static const struct imx_ddr_devtype_data imx93_devtype_data = { .identifier = "imx93", + .type = DDR_PERF_AXI_FILTER_V1 }; static const struct imx_ddr_devtype_data imx95_devtype_data = { .identifier = "imx95", + .type = 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->type == 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->type == DDR_PERF_AXI_FILTER_V2; } static const struct of_device_id imx_ddr_pmu_dt_ids[] = { @@ -155,7 +162,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 +314,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->type != ddr_pmu->devtype_data->type)) return 0; return attr->mode; @@ -624,11 +632,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);