From patchwork Mon Apr 15 06:13:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13629442 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 B07C8C04FF9 for ; Mon, 15 Apr 2024 06:13:25 +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=1nKz0cCJ2PFHutwFNRRW5CP/l6GTrXOJObHtFsaLM9k=; b=AruN2oT6GPNSyd Hrhln64LjlSMZSF8jdmw2/IhmG7yaM55fh5XbQ7So1xZmQWegZERsye6J0HkFUODybgRAJpkKKls9 0yFuq5sGoiQXkpyaf5YP1oYLhFV5t/C77l7pMmG0Ximn8vqJK0sL644kDAsGXnm3NxBoaX08qWR+B KGTTgG0hdhlIReEGMwrwgmdr/5N60tjQm/rECE23jJJua2i32P3nYWnhnoXT/g0sltNtDmyRWkqHf il1rTTRDa1ws9qZsYaaWfeogK+P0UG2/X4CFOVCmYMEu7WeTsuMZgDSnk58lwTLBmajqXFwkOBuSA MI5xYs5QOXK5lNQBbkKA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwFac-000000077BR-01qI; Mon, 15 Apr 2024 06:13:14 +0000 Received: from mail-he1eur04on20601.outbound.protection.outlook.com ([2a01:111:f403:260f::601] helo=EUR04-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwFaT-0000000774s-2hW5 for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2024 06:13:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AZHrocj1mZBSMidngHDT6W6Q8kgXUbYqfXdd5q/vwZTQ4ag80aFgvvQAbq6VukHjiiLgwikrKE2v/iUU6/D1vviB39kDBCVFZHlBYcLaUrgUAKXiKSdEmVzpTi7Vl0Znd1++vxclUK4tGTksVyrnLGQENDx99IBUSXfkiuKQ8X2X0Mm++9M8ss4nxTWWoxj0+T5J4BSorfJ9WsiUIdElHfbXqBPI6FRz6Bf3w5Acb6cz82Dy16yV+1Wrvy9mGPGGNEy7UipO2TfE/CUlBNDjRSqISIieUdIMaLKzoOuFm352lrfDhf8sA/sEQ8XC2oQZKCyTMXhD/KGfXVo9zHBZnw== 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=l0sQMBBuEKcx/Sd309ts8fBYek5hfFfQdxYIqFsmDtE=; b=C4v0nrjNt6Ze0kHYJY6N/4xpLnJ8sAM5onKli3iJz1DtqF59oPslcX3UUILPXxGXGeBD8HgzCzJ/zKUuYMriUB4RFtQ6UhDFEvEAi1FCzHvnxaqUTYH47KOHFKIHoyLvb2wOn6PMyhsMkm5SiH5ExkwFUYs8bUQiV+Dn3I6p35dasS3Wjj/ERLQqvNmcMrNDUaNuamkH8JCau3cwhju45Stl0KMprreVV4oqWR//xjGVpu0ZSUlrSEfMAmyFxlQu9DjdXg3SJLP34wCmciYa4z20h1Ix8Dg4ePMLdthvSE6TLQS5isHexeDdqVafUXaOmJF59MbHnni5f/cYhYcGfA== 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=l0sQMBBuEKcx/Sd309ts8fBYek5hfFfQdxYIqFsmDtE=; b=HZEqL4rdvIB5sUaSlLevr7Tp7L+GqWNTQqv8Goa1OraM64xgbqHnJ25rUuf6oEsfJLuPdbca7lgUUdGp+eUuJZLG7I6mKnnohdyrVD21aipsA2H7JrF62A1UIKieI0PApan9KoJfzvz4TFjROesu6fEaZSH0kTb5RIjyQIwzG80= 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 PA1PR04MB10117.eurprd04.prod.outlook.com (2603:10a6:102:454::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.43; Mon, 15 Apr 2024 06:12:52 +0000 Received: from DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::8d2f:ac7e:966a:2f5f]) by DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::8d2f:ac7e:966a:2f5f%6]) with mapi id 15.20.7452.046; Mon, 15 Apr 2024 06:12:52 +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 v10 2/8] perf: imx_perf: add macro definitions for parsing config attr Date: Mon, 15 Apr 2024 14:13:14 +0800 Message-Id: <20240415061320.3948707-2-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240415061320.3948707-1-xu.yang_2@nxp.com> References: <20240415061320.3948707-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SG2PR02CA0034.apcprd02.prod.outlook.com (2603:1096:3:18::22) To DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8822:EE_|PA1PR04MB10117:EE_ X-MS-Office365-Filtering-Correlation-Id: e7171888-a8ea-44a8-4fb7-08dc5d131517 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OC7c622b+lL8gWo0ozVqRVFFrO0l5Q1GdKe4hCJAYQoEFYzU1BKPPCGbIYlwRw8qaXhzKImGKtskHRVSrVVMe50MwJUqj6UbC8wwo6KCz62krYCQXEwjJuXo2DYhza4avZTD9Unyci2enSgBnYtSthnAszsHwVE0y4drtsCMDZ2gP75wAE0DbUZv0uKXpPWSIrIbR6mXuMehv9f7W50VFNUUx6imc6F4DQud/1Fls2VqsfvJiy6HkMxAIhgtrbmJoe1cbP/sOEYYkggqArMqNP+nQpcpLqilNBwjv4UP5hIAYUcLZDFp8y6/WYtNrztVwnyziF4T72QQkm6fZS81Ktw6QMiEzO3+uGw4d8DM6LyAh/jdK35Ovq+7hSVREP6AotumxtcZ6Ai7E3OEpTB+nOpSXtGYVOV1KRoZzF0+1jx4kP8n5OIIInpy1ODj+d3Lm3mRyWb/f53UV0ufJXz9niU8EQ20g4rJwP9EyCogEm0HgxN1oWLGhj8zmarkFYb1TAWpJkji9KVi/+koEloLm63rSSAe2hLhY6GSv7sBPsItsCbxFSkIsV0MW6Rs98iwSAOypxq89VypHQXPUjAUKyE7CdPHMBVCGeriohiVlOQCEwX4XSxWCYurhNulx9mknRf5jlkvnTiXnTO/6kE261/+b3ULrXVf6r5PIzri2UJfghHRvfDtu/bslOsXThIUDG4QxZvye4BYKqmPOtHH90HtPz5H1se9mLPpm37v2lY= 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)(52116005)(376005)(7416005)(1800799015)(366007)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fsIP6F84A7H9ylWITCzHLn6m5zV28GO3PWUlbvqw9a6sh6n9ozmwvmwBilB/KkqBZbKnnSYRclcwlv8mfmUSsT6wPVnW5aFzGzoXoaJ7L8gPuYktwT2jem62o80tw9vI631uIGV7bqljoZgCNOV0X5U5eEhaH9gPPEGYgCFOE7McJm9wQjphZX0pRUChGZh/kLWIJS0Cu4REkFWpjzpvPhnVMnPmR03/AQbypVllAxfL86BqTLm5JaWvzBDrn2tO8jiH1lHnyCr9iFjXGerqpAaeV/EHtEhSeItJt7wi/ckR26+jO3EWDsPYunhotb/2zO0acivTmW03pBWD4P7Jvt885CLSQlXI8gYTe5WepRhhodaPc9sfCM/D//IgRWj/Kp+6xiwOwzsRKqLLaH1eTNI7ljcImK5x9cZ1YezV2q3UySvMDqSrzaWGRtEl0r2ICd+/6L72uX6GHgnWPbGWN1CbUAbnAFkfvq4HFKi0rMWZqEryiuCmgJGji+Ayiool4DC3+ghe1LugERI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X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7171888-a8ea-44a8-4fb7-08dc5d131517 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8822.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2024 06:12:52.1420 (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: l372IqxOrdMejBN7y3BrLbOyB7xS2Jwuo6kGNEtClp36v9R0V4SgCRntvxaXBoOnc+RL/yvXFnm6RDj7yvB7rA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10117 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240414_231305_719495_A4703CDA X-CRM114-Status: GOOD ( 14.35 ) 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 --- 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++;