From patchwork Tue May 28 16:05:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13676250 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 54279C25B7E for ; Tue, 28 May 2024 07:57:55 +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=vz5+2PO8wGEyxM/QVli86A886m0w0ZwTqUbaH4/fCQY=; b=jt9N7eekfiCJ5Q FpEoaLEm4/qx6PcqDFq+LR8iD7UhmoSq1rN17m2YPrcyHNm6C2mzSA1U8i83z8iqEMb2y5k8EI8bf PSMAClb9xbhJ3vNHZqNbTIIpSbbMWC7WqnuhPoRLLi8btSIaSSWY9PtSqYYyvA9z2j9SyUuUY7LZ0 bFmVZBgrV5OHp1601jm6BZgi9fH1wlvaCJdxQB/5vpCoUZGr05jlFfyPX6w3yDM6X9S7ylkYhISnJ QK9S2WMWMwCHlQsk4nZK3PGaIKKmhzWTadCgRJcG9hxbE8oWtmnne5ZyzN4b1xMBb4ae2QQTy5dFZ BmwCiT0wvAqdfilOr4JQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBriH-0000000HNRY-29pd; Tue, 28 May 2024 07:57:41 +0000 Received: from mail-db3eur04on062e.outbound.protection.outlook.com ([2a01:111:f400:fe0c::62e] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBriB-0000000HNOT-3Acs for linux-arm-kernel@lists.infradead.org; Tue, 28 May 2024 07:57:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZO9/f+zCpxxvCxG5rj8LMhV3M7LGRoJDOQtairBo8VoiATCcqGIM+YpDoHstA36uEXcjZl9vFGnDWBSibrpu+fRgBVRoQO+1otNgKckTWHOIV+pJxwZiKpgD4FATKRhZikMQHz75v5aV3nPyxPNzn7ypxtj1KMndEWBG6VvNLvI58NX8NEUydvO8/2z5pSzk+t7NNCGrX2l+4xe3HKLTgVwjhExJfoKSvyIRD/E0BNJdECI57zZFLOsWMro72L69atbd9u8SAxSIXG1HN2abH/zW/PxACJ/z8cpPKOGetnBy7LBZrubZ1QYTExVKtfSGPid9mSWBIpLl6HHM0dQ2Rg== 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=a+g7qzMjIuB1QHMtgpqdQ5Ue8boQ3mKkVhHve+pHFwA=; b=aamc72Tl5oTrr8lPUlK8qbnpdPuS/ZDPSbscQ/a6Z4/iCwz7lYm3acaO3jvPJDZ6vDzRatMFvlvAeGcw4CnIhCNPpTAoiyMA0liyXxGtIO0QSwCDUYss9JnCdP2Ft5GEmiCJKX64WANmy928x4+0ipZxh5Rpnvh/a6MWxLdM/2PMx6ONmfn/3ci7/nrDwt6sLpqN9SbO1STHBydZybQE//pnkYfgbwKWdK/bYhD2VWrNK8mhXpg+R2MU18GtV0v1my9ZJlH8/tNFn25P7qdoJu/6kk/5kAZwST5Wmi+XKjSpaBoiVXQOaWejieGncUc0l3VUiGEP91MFgUFA3lQbqA== 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=a+g7qzMjIuB1QHMtgpqdQ5Ue8boQ3mKkVhHve+pHFwA=; b=ZfCytQtrwXT2ZfArEnCn01bRrfX9SEuhDYdnibzf8zO0c2qI60MD3puGtNbpnA33fWtxDkC9FQ6jQpaniD7QFzFuKGNYIn4cP26MexRI4VMckL32BZUqRZcgEZYr+V6bCmdKxKw1IV9ftrTNMkpBU/yWE0bG8U0+sJ+7zGBVfHs= 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 AS5PR04MB10019.eurprd04.prod.outlook.com (2603:10a6:20b:67f::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30; Tue, 28 May 2024 07:57:31 +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; Tue, 28 May 2024 07:57:31 +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 v11 2/8] perf: imx_perf: add macro definitions for parsing config attr Date: Wed, 29 May 2024 00:05:17 +0800 Message-Id: <20240528160523.1695953-2-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240528160523.1695953-1-xu.yang_2@nxp.com> References: <20240528160523.1695953-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SI1PR02CA0027.apcprd02.prod.outlook.com (2603:1096:4:1f4::18) To DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8822:EE_|AS5PR04MB10019:EE_ X-MS-Office365-Filtering-Correlation-Id: 2a20b8b7-22ee-4c5a-dbaf-08dc7eebd3a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|1800799015|52116005|7416005|376005|38350700005|921011; X-Microsoft-Antispam-Message-Info: 9dEtRMMrlr2QU+1EuNsQDGvuM4a7QCq6mZ1Q2tGZJvMVKd75WlOIlaJXPVhgmzTs9OdUtGlxoydtzTGwkqjR8lsYkZ6LYYEpsMFDrCcu2KGyc3QNZe9r9iI9vDuOGt98nMOG+dPDvrgNuwye6dLnpgPPkOL4KbYidU4gp65LiKD/TUw1sZd83MVDNsTXFewQ/6oHT/wAbPOscnPicBYh+RGm6MYCRXMI9raYpMuE8gvNFCYRr6E/OPmrlc0r5PMZnT8TxOrgRDVrrmHg42GLwZ1frI2w9wGDLWrSM58Jct7nN1jBh+yftWJQhUiqVIY87bmB8/f59IVIxtkVvRH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LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8822.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(1800799015)(52116005)(7416005)(376005)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bx6s5Btxxn0dCzFrfIgSLeFM4BZyVfbyVk4BvaK0JVXjLXvXa0/00MFwXhEc0vyUuDfe46VDX/aErzydtEMpjKJ+QPERDiaFkhJx1zIrd2KBUAKK37iB2cboXsL4aMrIOrDX43muN4jBa+aU0AQUMcaogl78a+e+CboUHyKNaxYhcGhxQ9o7kZXkCTX8haDOfLn4jTwLQpThdaE6uP0zXvZJ+MVA2o8DT017uaEdtFjxLJh9gPEctBpSsOKIVVo4t3KTWLp1K1VF6SVeEASTrw6rtSQMUbf+G1/xu/DZgIHpzqgTGnlvn4YRgqnHhvmZaVGFO+1u3TPvYu3u5AWVhBrLng9elmfjFcaeXojVHucwmgX9fn7/iIxdMkYKHf7gQ19bybVbzvb/xbS7luEE/HxksRzlsu2MTpylerDuQvWGElXBWJrtG1a41q+OhdyXxxy4d+xmKkimAe6bcwc4LZBva8GbwjWQQK6AerSXvqDH/DszXBcmLK60I4O09nXx6sdUnCppL9tZYAxgxNirUnEJGPOsr+gpW+HBO6XwmKbCW6ph9Nik0XmCDxbzYE7CNVqKlX20kT6DJprokLQuSTP+zxmTUdhmwGLb1uSP+buIOooYTPoBlZTBlMfNhGJQq7+ZOkXRvb5NsorXeVGvQVtlePE1BKvm1WylYp1zy+upPA0/1hJfUudVgujFz5r71VSDdD5vmy3/1mhrdw9BExqU6I/QTYYxNkOGaiLymF8DdDZhtgcA7T47EqkhLThUo6SqWoW02Z6Nqme0rxCnHqPoKx2ng8mqN+KxHdhXo6LnXS9Adon1L/RXBjMfv9vPLjaFuKVfJvZrwPgkPi6TmIHKs9m9AONn45p8/Dr6ctTKUYTBrUCzPMhcRnDEgorx2O/5Ny8qRDLX915/n4E579koOXNtoLVRSQb55upGCQ0rCTAi/xtyqfUs9ubNLpv5Hluem2NEWVRCEoTH4Oq/3hhU9SiR6oCfsU5vVCavR/H7xPHy/0oTfRIuXXa0cT/jMM9vyWisIZHXDqYau0cs4Lrmfoh/uSHijsCKrH1LXOPKW+i4ZE5o7kGOjnSgRsEMJ9qA3bGpEirgG/zUSuC3+JuTbDWvDJ8Spr92VnPS/2maCAdKliDpSxh/KrQPjKEVo7FfG6LhZMJjzAuTcX1pLGtUzbnn1N9p7DNzXLX8cMr/WExxKc3/YV1Y3gc4aZ2l/Oj5eDpIU+sZvXEjeRj+KrqxpemMpGR0DX9Lua2tLrrWx9a1VjFZhtmlf/IDEfBysgtmVSj/a7odqfGU02EqFLQKlCX7qab5Zx0+gDGCRtm2dqs/sQyjQ71zwOoi6rdBekEpVektqWHSEtACt+DdqsA5SZi00g/Fu2+5ybW2j3/A3vlBplmB7lW/tPMkeELBvOljcgyO9BiQVZG6Q8lOyCC5U5VTDGdHa9Of55VyJr8UjGQYi8YpJHZ85FAhSms6QrhLQBQaonavCbqlUdgPwFNeiWJ7H3eZl3EkCQD2SrK+JNUK1mDzWZDD4NqPeboP69Ado0yuIsCpvIz3cPxeS279U4uIZjOVn3CKyxnYgW+r7xt6v5KAXysk9YrwS9jx X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2a20b8b7-22ee-4c5a-dbaf-08dc7eebd3a6 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8822.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2024 07:57:31.6035 (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: ImBzFV7p/fH4L5iBAVNU1ZSLIlpPY0H9My7aWf1ENXGM6BYbXlC4eeCLwWskwDcUl9CzkjaS48yXPuQRxAb8JA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS5PR04MB10019 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240528_005735_837983_1CF3FD1B X-CRM114-Status: GOOD ( 15.17 ) 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 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 Signed-off-by: Xu Yang --- 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++;