From patchwork Thu Mar 7 02:47:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13584991 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 94EB4C5475B for ; Thu, 7 Mar 2024 02:48:47 +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=/tylMf+9vjjKYBGOlHLzqGkorXcAJsDU8JkrJOkysxo=; b=wsiv8+LeU25DmI OlV3TQSH4KpRi8SspWCOgKTptvG+CPCqnnR1Shho47h8h4E4ddXuyJJZsXCVNKoNedzlm2HlVHeXv gCvJvkjeqG88nyeBhIPoG60yfPZ8kgp4BqgOkxEAQFQKS4n7rWRtN5c524vJiuBtYGpCjLLgYJne0 BNnVLSyEUul7Q/2wPf5Xjy3uBli4Gn8dGT1Ux8vK6Si0HAorVE34YHDL5OU+kjlrgifbtOvqHoYH9 l6yheXgaKBdyDqq+okErE8f5HMi71qh5gYQpu9cSS2HMyyoZuzHEriBwXqb5Tr1moEwL+xlUgvO+z 8t7TtbZTpC5gjMFQ87og==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ri3o8-00000002iDB-0AMj; Thu, 07 Mar 2024 02:48:32 +0000 Received: from mail-he1eur04on20600.outbound.protection.outlook.com ([2a01:111:f403:260f::600] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ri3o4-00000002i9H-1lA9 for linux-arm-kernel@lists.infradead.org; Thu, 07 Mar 2024 02:48:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QPMpXHNrF9OO+jkWmt0ZroBfnr8q19adrL9YGuDRClh0mj+gBqdCNalfz5sDXouiFRe1WPy+ZSGjBTckFLom9jItIHVdpM7mW7JERL7cm+eGLz6HYQPKfkx28O//QsxKBWyJR7vI9TwU0asU2J2UV2bV9AWZgLALMuO8g+Yol2ilTjEzmRUPgPkkhOxBacWOvnFVgF1dEwYYLwpqbn0827kGEhu0R9oux4X138o50xWL2swT0H19joevJyv70zGOi/CTbgwJmtJNOQZLJWgVW5ZleM8JQfQW15CuRWr8P0KVDEUtxIHpc1izkdD8LDgij9HiWM1eeUHh+3GC1hjI4g== 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=txgi/SKif4pZzkn1YRbgXWmvam50+iuqmwjxPf4LUUo=; b=jRpCL8vpjzYXG3UjwoJjCTyuQ/A2SXD3RuJfu+llbleZ4Vd8J2+x3JLGE2YW/Jg6N2eQGlTCG0OYivIV6+1T0d0FE3p6g/fV1lY4Savk4NeDjaX8JT0WK419Wy514H5HtyyCx2KUnTXMDebbn/yGvzUi5xl8xHIQbTGcVthKYY+QwyOIUEj2UyuDEH59EtrjwMB2PevYuWFFVlS4DnUJd+eAzVtKg+qjFZAjaO2Wj2ocec3YcOZ3EOjTeaMsCZT3U+yYHz/on1fdSAP0WGQ2ocVcSU7afBukovBjDev4R4R4cnE3Kc2IiQIkFyba5SYxjfQLu/iyWV2OAd72OkeYkQ== 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=txgi/SKif4pZzkn1YRbgXWmvam50+iuqmwjxPf4LUUo=; b=QbJ363xc1zKSb90C36aRQIzXjGob3bSkGzFGj9uHJvUBzgZ32FGVbl/VOn8P4HCPSlqzqNtVabyF609kClRhyCevtib7mMjpp3epTYrxK9XlluPvirUSCdO8ruGV6mBnc11QLas+2piucLjQjzXQ2bEhNe90e4hqvkOMfFgw44w= 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 AS8PR04MB8022.eurprd04.prod.outlook.com (2603:10a6:20b:28a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7339.39; Thu, 7 Mar 2024 02:48:21 +0000 Received: from DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::d45f:4483:c11:68b0]) by DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::d45f:4483:c11:68b0%7]) with mapi id 15.20.7339.035; Thu, 7 Mar 2024 02:48:21 +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 v5 4/7] perf: imx_perf: add macro definitions for parsing config attr Date: Thu, 7 Mar 2024 10:47:51 +0800 Message-Id: <20240307024754.3469810-4-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240307024754.3469810-1-xu.yang_2@nxp.com> References: <20240307024754.3469810-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SI2PR02CA0037.apcprd02.prod.outlook.com (2603:1096:4:196::8) To DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8822:EE_|AS8PR04MB8022:EE_ X-MS-Office365-Filtering-Correlation-Id: 91765e0e-5db4-41e6-6210-08dc3e510d4e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uO/+d7HP3zHt/r4cuvLJSVEBmcDk03FlodA/m5e6XKYwna8iTcFBZZKhYlEKhMdlilHopa8WURUY2fUClyuDsFAFV5/W16S9AkGS6g5MvgNbXdOvJ6YKM6k1IbGkdH26AFEax9JgJWfab2bj0zC2gKqm4+mwM3yCtkdlYGZepDT4AZay6hedRnjSzGkdZXScgII/ef0GG6j7vV09Z9MrieUquCEB++5EjJHXLCbFs8PwUqWMDEXQU219LSKVKosTfAZfArSOF7qmnScSAXt8toOm3njeGZjZt+GrXND4O82WjJx9EcYoS+3fdhC1yZK7p9GLRQDdRuSqxjTzqlcMy7OiMmR26ZwzJLXaBrWCl/Tc0XOns5dLHuEq0+QJugs4Sr6bPSC8AFN4F/5fyY/nCS92Quv5e+yLcneg6UoFzVQpK42H5kJpdwaFUAQqWhfD2m3Pk6uuV+WKODgHLwgfWCn78a6Q9TvCCRS3OyskCjVbBYQZb8oIIdA+l3lVfVhMq59oy/rR2kHQimx2DNiOLw/d5xDkd75y+hVXc2CwTd3hap9mELzpArnL1CUnqgF8zwkmiRahKeCFzbNiYWcGsURLOjOqbTXIBsw4minFelH/J+i76hWdM5JwbGcIcWCtDY9Uyxs8b3/wU9bMyZr691jmDvAkKk1EE/u7eC+WFE4oEmcAgX+RoFjOB/yporFHYVRg0+d+x6CVcjaqk0z16HRyKV2uPahJfFJltRf/Rfg= 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)(376005)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PeUQMOf7FCvU1vslfYQvsXfYFH80ART8AUt5jgfSzsQk+ANQb9ZijB+lerphrKIEU9QpDqky/s15pgZOtxMi0PDLGfDeQJAenUM9+9wxhG7JjPz7THH3cZVVc9A13ZW//0Hh8/pJu/e2Ae5+YHkMcyH8zFWrE0iPV5/9vDb9O9G0KjlZxMKimxeYB6fYlTBPlCmvmD15GdlTki7mW7cy1k1wz2GZ+Qu0Wdx3kqV5F3h7WDt7c1TW9bqvuVxXCN+hr3YePqt4xohtEmwI4Eqi64s906TjW+I6cei23Y6F//lLrzqbo3KBqAGpyzHeJG2l0jnv5K3lvt7x3adZ7EnIdUeqdR+jqUDUnqW2ESPpMipCQN9FueGY2g72TbstXmrXaDGEbrV4MvJupWq8JAm4bIxzx2buBg7Qzfy7w97wVzKoRvQRt76Rx7AhoIIm36RuB8Kd60AvPgJg5k254Ao/U6S7jCGr7DsFTLbS1Wkn/09MHBnsuAVCFNKd60qKm1+Nmkkz1odoGICTTnhlpJ6YsSY7BvgZjM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-Exchange-CrossTenant-Network-Message-Id: 91765e0e-5db4-41e6-6210-08dc3e510d4e X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8822.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2024 02:48:21.7912 (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: Dz2L0gi2kRbIpCJqmF/vED9x3D56+lsbSvqcjv9DfVGMNNc8ArQsYZAhq0IwdG7SA7puw8ApxiKPRqHdHT81qg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8022 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240306_184829_370902_D11483AE X-CRM114-Status: GOOD ( 14.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 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. Signed-off-by: Xu Yang --- Changes in v4: - new patch Changes in v5: - move this patch earlier --- drivers/perf/fsl_imx9_ddr_perf.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/perf/fsl_imx9_ddr_perf.c b/drivers/perf/fsl_imx9_ddr_perf.c index 2cd5bcf1d3d1..35e422083948 100644 --- a/drivers/perf/fsl_imx9_ddr_perf.c +++ b/drivers/perf/fsl_imx9_ddr_perf.c @@ -42,6 +42,11 @@ #define NUM_COUNTERS 11 #define CYCLES_COUNTER 0 +#define CONFIG_EVENT_MASK 0x00FF +#define CONFIG_EVENT_OFFSET 0 +#define CONFIG_COUNTER_MASK 0xFF00 +#define CONFIG_COUNTER_OFFSET 8 + #define to_ddr_pmu(p) container_of(p, struct ddr_pmu, pmu) #define DDR_PERF_DEV_NAME "imx9_ddr" @@ -361,8 +366,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 = (config & CONFIG_EVENT_MASK) >> CONFIG_EVENT_OFFSET; if (enable) { ctrl_a |= PMLCA_FC; @@ -374,7 +381,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. */ @@ -388,8 +395,8 @@ static void imx93_ddr_perf_monitor_config(struct ddr_pmu *pmu, int cfg, int cfg1 u32 pmcfg1, pmcfg2; int event, counter; - event = cfg & 0x000000FF; - counter = (cfg & 0x0000FF00) >> 8; + event = (cfg & CONFIG_EVENT_MASK) >> CONFIG_EVENT_OFFSET; + counter = (cfg & CONFIG_COUNTER_MASK) >> CONFIG_COUNTER_OFFSET; pmcfg1 = readl_relaxed(pmu->base + PMCFG1); @@ -491,7 +498,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 = (cfg & CONFIG_COUNTER_MASK) >> CONFIG_COUNTER_OFFSET; pmu->events[counter] = event; pmu->active_events++;