Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp936805lqp; Thu, 21 Mar 2024 23:39:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+oLx3tm4jREg2owwl+74QnwP9VW7/K92VRJef7RqNfUKptAwvpVxMuZRrmLW6KueoE+LwyHVcTvCmunoIyC+M7VX2RkqKJwkKdygcfA== X-Google-Smtp-Source: AGHT+IFP2io4EQTGC+1+N7wo76wOO/AX6EYdBOyVdQAuQNFrKEW3B+1LAJbz339692VJLcBZBXZi X-Received: by 2002:a17:906:c09a:b0:a46:9f21:6545 with SMTP id f26-20020a170906c09a00b00a469f216545mr949839ejz.22.1711089587796; Thu, 21 Mar 2024 23:39:47 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id m25-20020a1709066d1900b00a462fa148ddsi607042ejr.544.2024.03.21.23.39.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 23:39:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111001-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=NnZhO5eN; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-111001-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111001-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 259AF1F24B54 for ; Fri, 22 Mar 2024 06:39:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F85810A28; Fri, 22 Mar 2024 06:39:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="NnZhO5eN" Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2080.outbound.protection.outlook.com [40.107.20.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88FAB10A13; Fri, 22 Mar 2024 06:39:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.20.80 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711089564; cv=fail; b=KehnfCooY/rQKv3UT54CcTbzDZ6x8/LsYavFdOjCDdsDHaR42ufmqx05TRQyo4QGpakXUDcFLoa+4nzH1/2FutPVEQYwa+a92EQH9JzCgEfr5NMJxD1gL7s9x4ihyo1rmHSHd5VwsgNxW7gKllxviALXg28/zv6bdctqmu3YjT0= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711089564; c=relaxed/simple; bh=zo2Jt1vz073eexaX5mA/e0MhHsAFjoMq+xefP9LyxIQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=aIYWsYWX53cZBPYVDlxV6oOl1nXOZEaaR84PgFXh1sOfy4oCHOkCH8U5jNSuMkOumR7Pao13Kcx023zyjbBq9d/qLMM1QTjvXhCy+LRt5bhPiLefezR8V1QVzKzwAZ3GjjUfmQcZlFiStw8Cc87O4W1WsWl4VxuW/TRK0axbhcs= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=NnZhO5eN; arc=fail smtp.client-ip=40.107.20.80 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f9NbG0XVRgVi8aoQHqjj9l/0VtcIWH7jiMHaarvHzgdQXC8hJGTVaRa3QFwsER9bE75DRHvmcYBI6K6LIeD0fNw6piybj2Ba/OldIYskut0i4Gxo1Dd9A4AfIq/7JDhcxcJyAXMcuu3VaYRJWeVTegm3PHT9iEd+OnZuLfp9S+0xuwSilwjMFpUwcWyjqrhsBMRnpb6PdQYIxRjcIarMWXMc/zIQBpPgJUOa7VBPsMdeSYNoZAm0A8aSOVqr+FltTKRPR9GtY/dvITkQEZzZrdeUwxK0mb9+bUXw53423w3dVEfFgoj9GC45BfLa4gQJcSG/NBhRSLIyqIyDDfhbHA== 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=Eh/24dzJXeksENJfGrTAVYplEbCO/6KdVTixG12Zko8=; b=i5bTzS7Uv8B6OdcrOriKG250LUGV4bXUae8pagjX8sVS4jxaXJjOSLqU86SLctESJKbrF8LzeOWTs+q97lxYdBmmw1YL/j7dgPMdEDjElkslPf577uNduw4T6bJOqLZpQKQdqIpONc8TsmkNv+FVUpViXPmzLY7/7F5YPx9jgYc9xVllukZHxFWHeFQPANYWfQT7zPU/BR84ObnP0uP5zFFaVVencFRz0GKXBD3M1QWRQt0YqziTiBLR2KSQqar5m+e/MDM7Dck6v9chBvPA30X2otQjJdKcbHprE2Ok1Lv+QmnIZBK7tn1saRkUTEO5JyDJcVZMPlNvPgKK9I8RHQ== 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=Eh/24dzJXeksENJfGrTAVYplEbCO/6KdVTixG12Zko8=; b=NnZhO5eN95ogikvzrG3mSb8tAkydQZZLyN2xe4umDw4Q9udb82czKFiSs7IQy1x6EtjybkFhtehp0S9+gHm9pWvrUBixgWEPnXxms2o1yOctIK7mbwtEetQNaLWY/OxW2mqtGqVa1YhRlDq9gRE3gpzdpPbt8f+6JL/OysDDOl8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB8829.eurprd04.prod.outlook.com (2603:10a6:102:20c::17) by DB9PR04MB8091.eurprd04.prod.outlook.com (2603:10a6:10:245::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.15; Fri, 22 Mar 2024 06:39:20 +0000 Received: from PAXPR04MB8829.eurprd04.prod.outlook.com ([fe80::1b13:505:8d50:f4e3]) by PAXPR04MB8829.eurprd04.prod.outlook.com ([fe80::1b13:505:8d50:f4e3%4]) with mapi id 15.20.7386.023; Fri, 22 Mar 2024 06:39:20 +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 v8 2/8] perf: imx_perf: add macro definitions for parsing config attr Date: Fri, 22 Mar 2024 14:39:24 +0800 Message-Id: <20240322063930.749126-2-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240322063930.749126-1-xu.yang_2@nxp.com> References: <20240322063930.749126-1-xu.yang_2@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR02CA0121.apcprd02.prod.outlook.com (2603:1096:4:188::21) To PAXPR04MB8829.eurprd04.prod.outlook.com (2603:10a6:102:20c::17) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8829:EE_|DB9PR04MB8091:EE_ X-MS-Office365-Filtering-Correlation-Id: d1b1523b-065e-4dc2-02d8-08dc4a3acdb9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2e657mhBG6kClTCzA2yCIr1A+ef53k96pIb0b9ds/5kDQm5yl1cXfcsaKiR0n5P5iISh0WSRoPVrlqqYIuASRjYyTxQtVMwJsPXoMNd6RcX3nwhvbIKHB7fdfwRJsnq6OR1VUwlI63UHWjNIEWFW4fB1QNuIwURKThuFq6vQPZeVz2LR0Es47v/YDdG4JsNrqSn7NEarQHwiWCaUjur5/oc1kci46sXQ/fV9PuGsspHC8HjTbylafNDOLNsDGOE4St3IXv/aHwPyTwZZw4NTDU06FeuKgiPKfPy/DJaM3XMU2ZEoJQENm79xmjWWouC2QmG2xd92UtGn2S/U2e6kCC/gFcCOGVtNpjegsPfr+RyDiSN3tEsg8trtW3moHA2FGR1S3r0LV78wxexy2akuw3Prv48AEOEj5l0Rap38NwvNIi3grf6WyVNgbtR1EJDLiYD9QvMu+fu0tYwrIiMk9g1F/onG2QQ6F1aScDQa4Arwsg4r4nJQyXyq3ghRkzs4QF40IJuh3X4As2j96h7sHrs6tYMf/ACM27AZRBWhbMEf8oxIUQPYgZxEsRb9p7Apz8E+qsPZIQUjY0l3C6Cj/SIB7Bt3s1gKwglGorJowJTScOOLG7/P1qTyJY4wNSa7Y6sMmrWjGGnu7OqTlBIgc6fl8ckbULzGl3TzdMch5EQicZ4u7evM+dDUdyIIa6p6CqNkafxBzjPC9YplK4S7r7aydwnBTxqmRkM8eDE0slQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8829.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(366007)(7416005)(52116005)(376005)(921011)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?TYOHe1uXIqkosnjq0qduxw+dF1Gi+RiO78W6S0P4ntQvK7Cfkk8hDrh2kyU3?= =?us-ascii?Q?dPJpjhko5O0jT0EpZ0S8CuuJW1QQlMBXUkQqpXW/mhESdi5c34YUpmcJ75Y4?= =?us-ascii?Q?7i7p/eneWVLfw1TK2yIlvUGrb2w0jwUhKY9rd+fWjsbTb1lZwewStzkpTxSk?= =?us-ascii?Q?oIq09pcs21mt/tLq1rFFZOgeUTctZ30KbgYh8iCtLD1w7al+3ndEIE4rxF3y?= =?us-ascii?Q?XsgoRRYmVt20x6smVTRQVZZjmtzzqaq4i2rKFoQwFUWjY11bm4dl19iZLU/u?= =?us-ascii?Q?UTQas1SFeAQcKZBsacX+nUPdZjmiUH+zzjjgZt+yQgcTuij7Vw+BsbY1Igvz?= =?us-ascii?Q?vZTZfgDdZffZ6bLxXqkQlmt/R+q0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mD8nbktEvd8ySRW7KpXhJ/kRJpvaMsZlJFoGhcVECrpuCBZRxT?= =?us-ascii?Q?AE5fkrXa8htW9GTGqljFp+VC/IXaUsKPF+xNvreoJDZXMqqMMRxkufnrOMb2?= =?us-ascii?Q?qICG87Mx1kQTKXfp568937NR+BMVw9/f9x77URKxTbCWeRW9GdqaowYCrk4u?= =?us-ascii?Q?zn7Qc8zB4JtFL7ltFA3hDXVJVt5OJBT3TK+cTJ71Y1Xv2NGKG0GU1Zv3tfWE?= =?us-ascii?Q?zNmWu8+4ER7XZCgYYpxn1XrE1EHYQBGESZQ7vb+Dso9JAagLk15XUDrV5ka3?= =?us-ascii?Q?ssrhj4Ydv9GmJEiWPKe4DO6anAlt+HEXc+t9caD+?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d1b1523b-065e-4dc2-02d8-08dc4a3acdb9 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8829.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2024 06:39:20.1660 (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: 010S2OVnLjJR032Zgc61Ojld3m1EFj6yYgOMLHNGS2Bqt/A9XXfIJ0Xm1+E7JWWQo9V6yF/9CN8BZRTgnwkODA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8091 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 --- 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++; -- 2.34.1