From patchwork Fri Jan 26 22:12:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilkka Koskinen X-Patchwork-Id: 13533407 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 13DDDC47DDF for ; Fri, 26 Jan 2024 22:13:27 +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=U+VVlVLPqMDwMKtjtr/MPbpoUhaAvgY0nHL5NVlUb4Y=; b=bHQJqROk6Hu920 z62+IGkoG1ptoGpCRKjox3b3coB78QVVsU2addCyMmeEJdvZinUvzMVP20dZ2yRfH8dmj1aGB7+Og ThPXwks22q7aXRkQK3mXed8Vqulh1UGKgwgvs4zSyrvHnGLTlwqgU/YcKLFdC4TEAd4jfktPkr+w/ 6XSMFtphpWp17EmQrrnD/Gd8K2+KkbkmXBRyay5W2wVPdBtf8sXLjf9eXcBdccPSv2fm6Wf0+drrL aEDNAkZ8a5G4JuM6MHOhle5M5G43QRUloOnp9x78uOpwI7Dm7/460JCvUCxt7JrLRO0xb+QYzzGl1 cy+sg3a3588B/AXmoWVQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTURo-00000005ZrQ-0XIc; Fri, 26 Jan 2024 22:13:16 +0000 Received: from mail-dm3nam02on20700.outbound.protection.outlook.com ([2a01:111:f403:2405::700] helo=NAM02-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTURf-00000005Zmp-3Jyw for linux-arm-kernel@lists.infradead.org; Fri, 26 Jan 2024 22:13:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DIO3PtgSwwXWCVrgcK7s5IYh0QWhQNNEmEEWAqsqgzqPI4t3bHA5hjj6ETVDhOYj45QqH/h/VSIWiXDrcAHjXuODSfu7h/H9tKMkNbUvgjMRL7a62y7aW7jyLoHpTeVZv4ikPzusZ4t8K0OIRfd2C+3lS3c2iUPvKAYHORdfZH4E2buuEv6B7f1ikiCbF1MFMKa2xJhK849MqRULBaDWBh029jBdn/GbUzGvswMO3EFZ4yseeSP1WPb5HUF+3qoAcA3pW5wCtaK32Pc6ZZWom/vZqhvpeC1nofjSESKTZemykGGQi5ID2NeuCYSQ8zodJDXprBvOosVW8DYcCA1r4A== 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=8SyuaePltjpI1YeJZX+fVap44lXG1cZP+l26fxKRQn0=; b=KpE8u631j2wDgCJpKVpRT6C7hI4Bnd7ImArAfLE7djRE77xPyk+HY7XjsoDbd0al90Aqz8vyEO85H/hiHt6KrSe2On//048JJhRrd2/rhI5WNAkDpxXVssOcLlqAQxgfCqZ9zUEa/sRekqJPtm/v8f6LEDELD5PUP1Ch7ddwPINzyq1kd/DKY1WOtmUER2PGS7vu1uK6vz32sAz+zBYYHV8wictZunYeq/q7FHAjg7Gg6jBMdJXU9q5cEj2lcdH5FmHuzE14caIeLSuuTtnRzpJL4xuRxLHa6tnFqe6+j3Htv6OQB48VHHaHX2+CWhVN9B+BE1SHQfBkPL2ZPn3CLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8SyuaePltjpI1YeJZX+fVap44lXG1cZP+l26fxKRQn0=; b=kywbhpak0oaB3IOsP1il2stRtO1ehJpdelNZ6vwIHijHX7mrE22xSq7rggbZn0W7LNliNSymu5a70pRG+loRzclStBIprQWOLDE2EBPXb283U90hLY0rVZVnsySDvIY9s5U4Z5vhegkfVFvZ8U4GeSZAx2sXj3sGAHvHanFud/Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from PH0PR01MB8166.prod.exchangelabs.com (2603:10b6:510:293::17) by PH0PR01MB7491.prod.exchangelabs.com (2603:10b6:510:f2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7228.24; Fri, 26 Jan 2024 22:13:04 +0000 Received: from PH0PR01MB8166.prod.exchangelabs.com ([fe80::67b9:4671:4fdb:2dbf]) by PH0PR01MB8166.prod.exchangelabs.com ([fe80::67b9:4671:4fdb:2dbf%5]) with mapi id 15.20.7228.023; Fri, 26 Jan 2024 22:13:04 +0000 From: Ilkka Koskinen To: Robin Murphy , Will Deacon , Mark Rutland Cc: Ilkka Koskinen , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] perf/arm-cmn: Add support for model specific parameters Date: Fri, 26 Jan 2024 14:12:14 -0800 Message-Id: <20240126221215.1537377-3-ilkka@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240126221215.1537377-1-ilkka@os.amperecomputing.com> References: <20240126221215.1537377-1-ilkka@os.amperecomputing.com> X-ClientProxiedBy: CH5P221CA0002.NAMP221.PROD.OUTLOOK.COM (2603:10b6:610:1f2::27) To PH0PR01MB8166.prod.exchangelabs.com (2603:10b6:510:293::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR01MB8166:EE_|PH0PR01MB7491:EE_ X-MS-Office365-Filtering-Correlation-Id: c3e8295d-2dee-4007-8b7c-08dc1ebbf7f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GQu1H+QLKjaePYiLXy/JiLMngyQSg3j8V/2kBheXWBgrFFie1bB/TNWDXWuhTFHcQyb6lUdwqwWeVcXbu6vCQCqEOV2ZDCpMAWVOYMvOPkfbTpg67HFX5jeRmSmq+8rh3GLSNOLniJMluhqCfu4Nx5C09uQyfUbnzzGn+8aggiSnTb5yS6/7xUONSQW595/9gBG/yu0MMEY8dKoVab/Qdx4+FfUljUj6BaB80mbwMHV2/l8Uud7hmrAdEZTxRs55BRPy3IAKbif1JV/um6DidoAto17pp8wbHN0Qw61X7+0rvNk/o7TO65S+CrjKFEUSx5Elb2DCpAuy4u/bcwQJ2+0a0Zo4u2BenGpiRNElEJKmQcDbGis9JPXMnPyH92itWxVIbfAs0g29mMW4+37bg0CWJ6xgFNfICaKMTU77Eq7WdW4CUJ7GxkPcLAvWLpTsLimfE0eL2XMtLevmWECrBzjP+D7gwBBowaqilfTaaLpa1ewd2ZIDpcUjR0n4J4rwdhY2ps2ci065F1YbZeKbCP+4RNA6cc9aMj9glHk/FNlb6UST8elu242MpmSzBc7MfKb13kZYMunhSfwKwa36eOkeQuySKeos3EDk7xhu746w8It5cTApxUApLZFvrHyW X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR01MB8166.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(39850400004)(136003)(366004)(396003)(346002)(230922051799003)(64100799003)(186009)(1800799012)(451199024)(5660300002)(66476007)(8936002)(2906002)(66946007)(8676002)(316002)(4326008)(66556008)(86362001)(110136005)(41300700001)(478600001)(6486002)(1076003)(83380400001)(6512007)(52116002)(38100700002)(38350700005)(6666004)(2616005)(6506007)(26005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 73KY32I00eutJRMNLFgCyJfD7DrzICzOnkKsXnkMzklt5RNY8o9ke5WFuC+4jWsxVq07rtcxWNW6fXfD+Tu6JQZ7wkGaYGbo2yVxtx997sTrw2QAUi5994512tMCSgg7rm1vhNFOCPzXSjvHQa0djKiUrkYj2k+tFUd4Tt68LPujIO2OaGSofOYjQDWLE89oOC+lwHPX8rSxdh84goO1woRvV+lAOsbzfGCwDd8rtBqlW/JMsKnXwtPVjNkypgf6GqaoDSQ1w8UskJpyitVqq2Hq8/Cfdx4o9HdD3EmHqzbHj0bS6yU1y65gF7KpDGO4jkNophI9ZUqk0EewV3SsxKiZrNxkvYvOLsp5UV5yFTWAAVlpzye5KZD9ourCRwHctIL4ujHe9t+qn5N9tTrG5p/BdMpOlKzzTjaGaxqBb2CtRdGk8b9kqyQgv45PVNbYGCywsrEdHQdHcReM+aOnCHoGsiAUbykid7GIlBGE2uioEVy9LFzIOZGwk1/Ny84gxKJsS9QkY80JCNnEr6+2GY5hO2G9mOEy0GgK5eS853sDwXRLMoOz226FDQZDEnd/eJufaN2P3U34XSkWH+vsmIa13Racf8gc+zJMcU8WcsfyS43WFTWT/3qoZ1REvjcv7aSySja26lo9aec8dS3/tprM3KrH2OEbsn46hAMH+VcTp0ysCJeW8WPgcgPBR9+qaoU506tdl2t99AujH6VcYrJDSVi+C3k5o+Y+MoiAMEajI14BHn8odRNcKIj+1IFg96jAVtdIi7B3DdGNp4elwcXo5Dug7ERtS6XAyTlM6f4t+IcJVhIjP4IizyKwU0sJOIdoBOlg43Pq3O93RUyflKx0N3ReDwuHobPc8T4lwUgfU1daowtHyfq8eB8F7pLFCRk/qzZXKPD7tXQpnZ5JOV/XKHZ2A3K82rBZmmbwqZyKlzp0OrCwxTKtdIWOGnqk4Ji1XKC7ODcgA6tN51wiX+CN2aJIAy5Qy24X+bqd8AxJYM8QMXNzhQo8JdgZExdOFKdHwF39VzyvdXk/xvrCAUEE2A4DZJdsLV7yVOQGs3PZU4EpiexBD7L7tpinPlMH7L/llJZdOkDZke3a6Exb/84Z9lXYLUaSV8Rr/SsNFG+t7YkoO51lmjZ1eqNgQFaus/T0E+S8+zn3tvA2/iyMw+04tCroF1N1O87IYjZ35pEFZ5aWPhmQwzyOkM0X8tzaW9LAxExhpUaDBk3MybzJ9fv6I1tAlXt1Y2X2hEL2gNe2mdUUF3ahibibTN8XSstvS8BkjFludz4x8SSyub5u2X1pcz1P/McPjqFEb5gOzM3oy9TPlrlCqz5BP1HxJDfTuQjmv3qZEhsncIAifIPb2ZEwogVKfKt9Det7xjO+IOK4fzZmBsStGzyAity7EJZYiMbvAJ0XDxA+Ly31U75kB1CruMWjN7OQduxJqOE1hoONfbsVIxbeSThfSzJcqThOKcXJgAs6rN5jP0W7EjgjNj09kjJfX1ZINMwFk/ZPRCT5hs2KDUPbN7b2tPlBuHo5f1/eQCuw+p6S0JLxX0NcyNi8k/Th9p7/18Quf8EbtqybFaOQssQPCiR8XnRtv/oKr81SwI7ujfGXnGroXv/3yvCA1RIovXznLQ9ijaTSEJ4= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: c3e8295d-2dee-4007-8b7c-08dc1ebbf7f5 X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB8166.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2024 22:13:04.8755 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hmNH0vP+KJ2mU4oGUtuiUAGVIu8EUwAsiH8v+jDhJZtCIObQgrRhuoN+83gx1b45+CUTwEeOJxS0/QFa2pcUFH6cN1MyGOQT/9QRLb824d0iIsUxZ9q4iPVno4YRoy6+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR01MB7491 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240126_141307_875433_BB6798BC X-CRM114-Status: GOOD ( 13.54 ) 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 Newer models have slightly different parameter fields or may introduce completely new ones. Thus, prepare for it by making also the parameters model specific. Signed-off-by: Ilkka Koskinen --- drivers/perf/arm-cmn.c | 45 +++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/drivers/perf/arm-cmn.c b/drivers/perf/arm-cmn.c index 93eb47ea7e25..dc6370396ad0 100644 --- a/drivers/perf/arm-cmn.c +++ b/drivers/perf/arm-cmn.c @@ -628,6 +628,7 @@ struct arm_cmn_event_attr { struct arm_cmn_format_attr { struct device_attribute attr; + enum cmn_model model; u64 field; int config; }; @@ -1265,29 +1266,44 @@ static ssize_t arm_cmn_format_show(struct device *dev, return sysfs_emit(buf, "config%d:%d-%d\n", fmt->config, lo, hi); } -#define _CMN_FORMAT_ATTR(_name, _cfg, _fld) \ +static umode_t arm_cmn_format_attr_is_visible(struct kobject *kobj, + struct attribute *attr, + int unused) +{ + struct device *dev = kobj_to_dev(kobj); + struct arm_cmn *cmn = to_cmn(dev_get_drvdata(dev)); + struct arm_cmn_format_attr *fmt = container_of(attr, typeof(*fmt), attr.attr); + + if (!(fmt->model & arm_cmn_model(cmn))) + return 0; + + return attr->mode; +} + +#define _CMN_FORMAT_ATTR(_model, _name, _cfg, _fld) \ (&((struct arm_cmn_format_attr[]) {{ \ .attr = __ATTR(_name, 0444, arm_cmn_format_show, NULL), \ + .model = _model, \ .config = _cfg, \ .field = _fld, \ }})[0].attr.attr) -#define CMN_FORMAT_ATTR(_name, _fld) _CMN_FORMAT_ATTR(_name, 0, _fld) +#define CMN_FORMAT_ATTR(_model, _name, _fld) _CMN_FORMAT_ATTR(_model, _name, 0, _fld) static struct attribute *arm_cmn_format_attrs[] = { - CMN_FORMAT_ATTR(type, CMN_CONFIG_TYPE), - CMN_FORMAT_ATTR(eventid, CMN_CONFIG_EVENTID), - CMN_FORMAT_ATTR(occupid, CMN_CONFIG_OCCUPID), - CMN_FORMAT_ATTR(bynodeid, CMN_CONFIG_BYNODEID), - CMN_FORMAT_ATTR(nodeid, CMN_CONFIG_NODEID), + CMN_FORMAT_ATTR(CMN_ANY, type, CMN_CONFIG_TYPE), + CMN_FORMAT_ATTR(CMN_ANY, eventid, CMN_CONFIG_EVENTID), + CMN_FORMAT_ATTR(CMN_ANY, occupid, CMN_CONFIG_OCCUPID), + CMN_FORMAT_ATTR(CMN_ANY, bynodeid, CMN_CONFIG_BYNODEID), + CMN_FORMAT_ATTR(CMN_ANY, nodeid, CMN_CONFIG_NODEID), - CMN_FORMAT_ATTR(wp_dev_sel, CMN_CONFIG_WP_DEV_SEL), - CMN_FORMAT_ATTR(wp_chn_sel, CMN_CONFIG_WP_CHN_SEL), - CMN_FORMAT_ATTR(wp_grp, CMN_CONFIG_WP_GRP), - CMN_FORMAT_ATTR(wp_exclusive, CMN_CONFIG_WP_EXCLUSIVE), - CMN_FORMAT_ATTR(wp_combine, CMN_CONFIG_WP_COMBINE), + CMN_FORMAT_ATTR(CMN_ANY, wp_dev_sel, CMN_CONFIG_WP_DEV_SEL), + CMN_FORMAT_ATTR(CMN_ANY, wp_chn_sel, CMN_CONFIG_WP_CHN_SEL), + CMN_FORMAT_ATTR(CMN_ANY, wp_grp, CMN_CONFIG_WP_GRP), + CMN_FORMAT_ATTR(CMN_ANY, wp_exclusive, CMN_CONFIG_WP_EXCLUSIVE), + CMN_FORMAT_ATTR(CMN_ANY, wp_combine, CMN_CONFIG_WP_COMBINE), - _CMN_FORMAT_ATTR(wp_val, 1, CMN_CONFIG1_WP_VAL), - _CMN_FORMAT_ATTR(wp_mask, 2, CMN_CONFIG2_WP_MASK), + _CMN_FORMAT_ATTR(CMN_ANY, wp_val, 1, CMN_CONFIG1_WP_VAL), + _CMN_FORMAT_ATTR(CMN_ANY, wp_mask, 2, CMN_CONFIG2_WP_MASK), NULL }; @@ -1295,6 +1311,7 @@ static struct attribute *arm_cmn_format_attrs[] = { static const struct attribute_group arm_cmn_format_attrs_group = { .name = "format", .attrs = arm_cmn_format_attrs, + .is_visible = arm_cmn_format_attr_is_visible, }; static ssize_t arm_cmn_cpumask_show(struct device *dev,