From patchwork Mon Jan 20 07:13:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 13944790 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010046.outbound.protection.outlook.com [52.101.69.46]) (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 B9C4D145A18 for ; Mon, 20 Jan 2025 07:14:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.46 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737357278; cv=fail; b=ad4BEnOkQxQ0ZDLAaZ6UIJsAh2DZ/T26aZpjKdyZrGhZdx3IpDh2nskiyrMKy45D/Y82ZGPcv/GzbH6fGXUxU6nTqACU15KMWDmITyxTYFXMkWn8rY9dG5iBwzvr5jyxlRRvJz0O3uLKNNQ8f5poGXgjOUOt3wqKgDkD3SuHaVA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737357278; c=relaxed/simple; bh=sp+OqPQfpWgE4cAJIx1oo5i1nCWvRdX06yZ4FCxSaNg=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=A4Q8LmDwNADj8LnJKwG4P0/gmpxXG03MYPioLlhin9DrHtntx1JAtEHdwWgJA2i2I/449vnEikbePN71Jj4LPGWVnkoBnxlb97jzs0vjUgkuwjZ4k93OjqMkCa5/nCLdeKVDay4ZKYWuVLyqZORkiAA1oniTO7B8wzYVi++ZPmg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=aJBKPw5s; arc=fail smtp.client-ip=52.101.69.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="aJBKPw5s" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=WcgalTFbfcpsV+yDz05D3jlw221QK8z3V+PSnbSRtNboZQJF4kHQ0CjqScOxR6VriiVz2awycFabd8NcFVwfO/+qRYpW7w18epEP6UETdbAqDQu+C0JdhXOJM5fgFUoSgbWXaAxIxyGz1crXWbju7eoZ9gPPkzXfZFgFjSQoC8f47g61rvc5vZdFH80+oqwLUlq2nvzSH7DEXqi3Kp4I1WJKRW5CcOPWlwUQlwrmN1IYLJihp8xSalRy2IB5j1MTEx0ZUaQ/eq2liOykOheVBZ2/u5BTRTxuNVimyt1qlO89Yewn5D3RtFcdUF+R59rfohw6KiHi/OwczEAUdpyQFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=5N4soaqVvGniFGVKXuIwxhaCY94c2fcgCzLF1RtnT2U=; b=gIGO/zI9f8xeblbFH9S5B1/DAMJYEmNrBmkOugjU5TjFbDGAD9oYyPdavFwBKzwFwWlOtD5dBjzme3bR6l7AaDKi3qoI7EPQd8MCLWyBdWpDYOoFIOo4eVQBo+bc9TDiPDYXCJxxxEhBsJn1ESzDsrSYQnFBoAcJJhulJ39xu+FApJKlJjXIpli7j5kLdoKHGRNeOk23fK6M+X0BnWCOEa0nO8PWxml14mISFFDGmxwl0jb6OFB2HVugWxOfDOjl+CE1W4d3GHHHKOLJXuA7qboJDld1Hu8BJe/97WLodxfPl5uxMhZ20G2isrwXtmK1ykcCzLi590YZXcDdnqRz6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5N4soaqVvGniFGVKXuIwxhaCY94c2fcgCzLF1RtnT2U=; b=aJBKPw5sUMahEG6vJrQn5QdseNQzNUu+PQmeyK8JNI4jwIOSXHkzsJn+6pBm7XZhtujpo8VAE2SWlfuNiKolFsMGHbMgPfDmNTBa461k1L8Dd3AuC/PTO111rWcTNgVcAbFz9kPRSiqQnm5UKwj9DE8+qnb0DV/4zmWjusu0tWvhfJcG+qt/YEmBLWaEIDJwYUm3ONaSCHGM0rJcroxBv+s5li114spN+4bdPsx2qXc6DxBEYz59MqfImTeoi72I+ytxVt5tYJheQPl6ztVHxHVnaciMqk+aTnhyhBa3fcA74zLXq26FQ1pp+ycrbIzgp5ShE1JXHnOoks722AcXzA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by AM8PR04MB7442.eurprd04.prod.outlook.com (2603:10a6:20b:1d8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.18; Mon, 20 Jan 2025 07:14:34 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%5]) with mapi id 15.20.8356.020; Mon, 20 Jan 2025 07:14:34 +0000 From: "Peng Fan (OSS)" Date: Mon, 20 Jan 2025 15:13:30 +0800 Subject: [PATCH v2 2/4] firmware: arm_scmi: Add machine_allowlist and machine_blocklist Message-Id: <20250120-scmi-fwdevlink-v2-2-3af2fa37dbac@nxp.com> References: <20250120-scmi-fwdevlink-v2-0-3af2fa37dbac@nxp.com> In-Reply-To: <20250120-scmi-fwdevlink-v2-0-3af2fa37dbac@nxp.com> To: Sudeep Holla , Cristian Marussi , Saravana Kannan , Linus Walleij , Dong Aisheng , Fabio Estevam , Shawn Guo , Jacky Bai , Pengutronix Kernel Team , Sascha Hauer Cc: arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, imx@lists.linux.dev, Peng Fan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1737357232; l=2685; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=aQkTl5KnV+Ghr5dkzA87eUlMVoRB+D46A6vU1kqaigQ=; b=2VL8YIT/05Gg64JAQiw/Y2bzpscQRRjXN/on6j2pFc5P5hM0/NihawvdpJmFbEJQQb+20Rg6M MfGAJ+yl1pdBV6ezgTlbGKzcXN+C9vgw3n8RcKHVIZ7a14O6HG9YCWc X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR01CA0129.apcprd01.prod.exchangelabs.com (2603:1096:4:40::33) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|AM8PR04MB7442:EE_ X-MS-Office365-Filtering-Correlation-Id: b7d68899-72c9-40d1-3a60-08dd392217d7 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016|7416014|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?33SSD9fpp8M+1STcCBONy63Hu+FhK3F?= =?utf-8?q?RAHJhbnCae+G8Wh9Ty5ErCyTqaDz+1l471+EB0keUASy/iutNc5fgQOnPVDMvwbUZ?= =?utf-8?q?M2XO47kiHC36roJ2dpuuFM1huvfP3vNwl62ZXBn6apc1Rm9DhdFz0n5kvbUMhHxef?= =?utf-8?q?DYLlCdk6gSttqvs3WlMSi3DfR0jz/H4TOql+4wQnwO9XiKVJ0DGs07NAmmFnHg1Cd?= =?utf-8?q?6JJB2mNBNi/Q0Cst2cDq73CK/3QpEPG08YkL7hrjCGOafCTwi6hxLdpLZdDTfsxFp?= =?utf-8?q?rCPzzkKf7v391knTfWonaJNu0zM3rFlQjtR09naa8vus9ccHh7Gc6B2zO4JCJdXeZ?= =?utf-8?q?TlyLNRnflEH35wEzfsJaVTFH/ZosHdi0EVvN6Po07HL8joQ7lY50FbUOVv095cCr0?= =?utf-8?q?v3nIr+4V06OaWCax7y300rMFfwaOG9OnRRaU2Tm80g0iWJDff1xeEEin1y3eywP7X?= =?utf-8?q?gDeeF+Aq7RQZMIRAG5S4sShNqPg56ArnbDaWW+sS6YLsB673a8MswaisidUGmJf8v?= =?utf-8?q?F05oayeYc5vdIGQah1Mw7ob3kCfF1IiGDrQa7Y11Q+1NmSd7edOUbBz7DJJazMgRJ?= =?utf-8?q?kZve3t9DUIetGjB241YfVwf0mw/3ujZHmuTJKU2ysuwM7zPsKwLWNxzulG34zKVrl?= =?utf-8?q?nfwbUbx0o3cuJxXHSPxoUK8M5fB6cVU8kuyE8LJkIbxKhanq+oifGOqh7WyDWHzJK?= =?utf-8?q?gIy57UbyMGNM1jsfdjmh18ojPyFBLwYLWWIjH5rMz/WnaHC1KFieAhGOnzNtJFuUR?= =?utf-8?q?rhes7Vwl3+NBWMEG7VOCFqLV4t9mS6+O1dddOojTaWhgB1MlFbuuOsf3TGev86CTx?= =?utf-8?q?QLX2fpbUa4Yfk77f6H57Jg0G3Q46ls0BIXNUtuabEQoie6ovtPVa8gcsR0jDmxLbM?= =?utf-8?q?92v30unvNezv94+i6xEqMFYUlWCa1qh1eS2EuKQytQpUl8jsglxiWTXsZ3qPUdcQb?= =?utf-8?q?b8riPpn/6lnWOoylpPaFNzlCbHHu6ktr6pYxOuj96QqGCPe6Gf01+7vHMcN0JAcPj?= =?utf-8?q?E8K4CIhttK2scHUjYP+afJh5s59sTwBkcXKYt2IeqoddtH5Zp3ib7ZSU6nL65Jmvu?= =?utf-8?q?KRtHVkpj35FLkM8lXFQZU9BhzcvWLPZlvf3mb4CkGr6lHw0Wm2oAAVATQhSWqJyEA?= =?utf-8?q?GnQXHFiH8fNmfLgIboVTdtcqo6u23e2UQVU1gI0YD8BhcffJ0lRQT+12FzbqgBMx6?= =?utf-8?q?F0ShVf1EVtlscxEBoFqmlBZQzpL7TvWgIgGlcN9RousF3EmMcw78s1ucvMHEDbC+M?= =?utf-8?q?aP+wmdtfxxeCKYUhxVAx9YJ9P+F85R1r5npYBkLfWaOlpMyo/QbpnOipzwrLu1qEq?= =?utf-8?q?2GUOPFuKYioeiSaTHOkkXbuqs55yqgABll8OFW2LkueGGjI23m+TGQjrWMbi7JfnB?= =?utf-8?q?/rWY4sIQDb3?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016)(7416014)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf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mEYwKv0w7bpsXV5Mk+dRsk1F6jCrgmbvt?= =?utf-8?q?zbMszm5gZJUs/UObNv5nbhf5Oco3AKphI5lhdxRBxPhWGZ1p3d/9aL8Z8pme7Bs41?= =?utf-8?q?+ciPNgWJwvdUL3l2vUPy+dNnTy4eV4/N7S8JNJ3iclNsjoSoKfl1/+3hPBLR3ia1I?= =?utf-8?q?FvGJBNgTTMZYLY5hS/P8EbaadcVrc6uGHVBdvTbcC5XGOU2PzUtiui1u3ocXRE12B?= =?utf-8?q?tG9+6QudzIBWsm7cUhkfW86mPic7WpjLz/LtM/gOABGpGzjRkjmDhjFYW1F4PlBwG?= =?utf-8?q?nQYMO3K9V3dL3vOUaSK9+kSW+YC43R3OQc3U75YXgWozHVpIPMQmFgRqtIUBQ68ga?= =?utf-8?q?zQ0YTzTHhqExuSqaUf+YVV7GXlrIxDaKV6Rygc5CYFdrNhUtWERh4VRtzVf9WnjNt?= =?utf-8?q?bTuynMPKFPFqs+ArBOYZmNxxm4HNoAdoJnTVuLAxRMrwDOXqGFF2zqtg0gRcJQniB?= =?utf-8?q?Jl8DLaRT5avnAq44xdiSXQcjnSz8uX3nnCuuHyqF/43YJjAlhXT5A6BsdeUGp0Goo?= =?utf-8?q?sS91U8BH0Eyw5iYJWIh7KW0RsnYHobluEr83rmjAeBNhbngMXXxu1ePeq3sNzIXiS?= =?utf-8?q?KkE0WE+za9NCUeDqsiLduW0Wn39Hua6gmez8WMMMOtib6h6wweIfWG9QMUv93O+3T?= =?utf-8?q?xtBFdtMKaX5x?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b7d68899-72c9-40d1-3a60-08dd392217d7 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2025 07:14:34.9012 (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: REi370fSPUW4AcLbqJ4vA4XwXQMrOWGlh+kw09ku3PJ47vzlyFEoB2eGWhY6g9Kwa9UC3rNm+MJAubKfxLb0Xw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7442 From: Peng Fan There are two cases: pinctrl-scmi.c and pinctrl-imx-scmi.c, both use SCMI_PROTOCOL_PINCTRL. If both drivers are built in, and the scmi device with name "pinctrl-imx" is created earlier, and the fwnode device points to the scmi device, non-i.MX platforms will never have the pinctrl supplier ready. Vendor A use 0x80 for feature X, Vendor B use 0x80 for feature Y. With both drivers built in, two scmi devices will be created, and both drivers will be probed. On A's patform, feature Y probe may fail, vice verus. Introduce machine_allowlist and machine_blocklist to allow or block the creation of scmi devices to address above issues. machine_blocklist is non-vendor protocols, but vendor has its own implementation. Saying need to block pinctrl-scmi.c on i.MX95. machine_allowlist is for vendor protocols. Saying vendor A drivers only allow vendor A machine, vendor B machines only allow vendor B machine. Signed-off-by: Peng Fan --- drivers/firmware/arm_scmi/bus.c | 14 ++++++++++++++ include/linux/scmi_protocol.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c index 7850eb7710f499888d32aebf5d99df63db8bfa26..76a5d946de7a8e16f5d940abc4f542aac5bb2b92 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -55,6 +55,20 @@ static int scmi_protocol_device_request(const struct scmi_device_id *id_table) unsigned int id = 0; struct list_head *head, *phead = NULL; struct scmi_requested_dev *rdev; + const char * const *allowlist = id_table->machine_allowlist; + const char * const *blocklist = id_table->machine_blocklist; + + if (blocklist && of_machine_compatible_match(blocklist)) { + pr_debug("block SCMI device (%s) for protocol %x\n", + id_table->name, id_table->protocol_id); + return 0; + } + + if (allowlist && !of_machine_compatible_match(allowlist)) { + pr_debug("block SCMI device (%s) for protocol %x\n", + id_table->name, id_table->protocol_id); + return 0; + } pr_debug("Requesting SCMI device (%s) for protocol %x\n", id_table->name, id_table->protocol_id); diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 688466a0e816247d24704f7ba109667a14226b67..e1b822d3522ff25168f895a4b1ed4c4e9a35bfff 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -950,6 +950,9 @@ struct scmi_device { struct scmi_device_id { u8 protocol_id; const char *name; + /* Optional */ + const char * const *machine_blocklist; + const char * const *machine_allowlist; }; struct scmi_driver {