From nobody Sat Sep 26 09:23:33 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 86B4A387596 for ; Wed, 2 Sep 2026 18:08:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788372536; cv=none; b=CaZwb3k0Rn97IiWH6QH7z6JlfH3hsaQJ/cI4ZbXdi6jlueSGk3Z6iEQXnM/ubPMxmGJxD52sR2foeJqS2+nykeZzuQe+REZXYQHyXD80pIbnKTUIWhA4rwP7lm+VyEnZSRSFEzkDxLJT8jB5PFtmAdWf4yzx2zC7Pc+QerAK5n0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788372536; c=relaxed/simple; bh=vSYj1Ys/owwCN8sFbLJ/5CPpCU7lY6/j6/iPP19TXz4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NHsl6fzcLVjdcl+m41osIKXUuWBJWAlWHhjDaSZhyYk6c9fJyTXF/APAnWYIgn5WS6R9sYQ2z325pfFgTqDBjdSBc/VjR6QCNuesL4+1MTNmQxmFhWo6VB9nfKy0ar/jn8NgOMR7/BjQ0jhlp0e4CbKUiKhQBN/30AoUemOAPus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=hpqrlfx+; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=T4W3JI7Y; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="hpqrlfx+"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="T4W3JI7Y" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 682Hr6hn1714507 for ; Wed, 2 Sep 2026 18:08:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=pEM9jPOOZuj CwjK6sG3Tm845ZU4s2wO25Iym0LKZjIU=; b=hpqrlfx+gQ1EcVXy+xrSZw1dsVb Q725rQ66WGtSyBbq5rk5Wzi7WSRUtw9a7jODQwpOLfP9GNt5rgZPlH0hPe97FII3 2MmJvOjRwkeu1Km7soacLVTKU2eQ9AU78oyIaZpDzrEQrnJaHXSBQsPnkTMSydWG 2x9wrcXNL+H2YPCykjbGuVQOS3gZzyTx4RP1XywdTLpDMvT79sSwiU9TMfJg9P9A gB9O83wrEyGfedkpUwgAfzUdfXvZg466RYtkB9tWBkJUwEnzmwSNeFKzLDVlPPLS mz6diLZVexhK3ZdaxUjlftQ3EELeskhHhtLtTmZJwde6vukEcOBlJOj6x1Q== Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gemce9d5v-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 02 Sep 2026 18:08:52 +0000 (GMT) Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-936708f129aso229543985a.0 for ; Wed, 02 Sep 2026 11:08:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1788372532; x=1788977332; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=pEM9jPOOZujCwjK6sG3Tm845ZU4s2wO25Iym0LKZjIU=; b=T4W3JI7YJKGBsw2htWuTpJK980XWSajU63e1T+C4Xv0T708lK1a2f8/czfJmvnYgy8 a/ZH/hmrq/glePBbcB2GKR7k1z6yl/RAlI+nLmRL93lKS3rSvpBMG9AjQk9/t8e8WQ/J 0umxsVquI5YqLXLoIY3Qje3+A+9yXxvULPvz+Cp2IymYP1SirYMqZGulSpszIUC8jkk5 aAazlNQZMfZs9CxSACBL9jgOGKC+kbXqowLIfdM3dxhWXNf+/gsaYYAbOKuC0tzDDU9F NFm39Wg8d2GR8ij4pWp9gRmv9Lv0o2HJwMuG+Y2GgqkerwyGtrAkBXYH5bgSvMtLNY46 ZTfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788372532; x=1788977332; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=pEM9jPOOZujCwjK6sG3Tm845ZU4s2wO25Iym0LKZjIU=; b=gb64FhXt3gBgplntn3YvGFfslmEfKcYt/DNESta48wYk41xoB5JXVS1o+mBZhRZi4S t3y354YS/0zMr4Cj/OlfovUs9oCJJEZYvgtPD48ElU+lFzMKv+IS+T6lCZMnPk7yhfe+ rnHH4E0yf4Li0pa81EZD949Q66h4AQNf8v5fxUjxNK1Tx2fGYjXreNlUyFj98vMwVmpw BlrWC9WYgWg7eVaG2hutjmbltyBSiTR6ZzvabyrFhSZ+RN2LjBAeXsYYOgBKf0BhUaap hsGa5IcdW6IVCkaufKRD6XQGGPO8XTswuHyz3EGujvBoqWRuuz3fINVZKJfYIuvnSWz8 Y73w== X-Forwarded-Encrypted: i=1; AKwUvByBniBbKkE8ptMc5AjBgwzRUx+MTC6x56i8CdqFxz3lp6goAD1KW4h1TnQXHYsFkRs9H6A8hzqp6IHFAZ4=@vger.kernel.org X-Gm-Message-State: AFuF++k54sVarsWZkIg0YP8b4uunMStzu7p3VHDOl+Cly9ZmfmXhpMwk OE42RG/qqCrQ1E1B+gmHmf/Rq9EchgfJL1oTMQ3fKtFxI8qsRGreo6oqNJTB2aMj13wHKZm/J5C Crrm0FEXpGzM6mVlAGvcHZ7ZOOdryCX/DFCg6KeCmc2g9iA77hLIaK8gP1nxzLI2o5PA= X-Gm-Gg: AYBFou2nM8x/rz7jCs5idp1sl7O9GVR++2GLFSLTaAd4eUEGUor7BN01Kr8G1UyLF+x t36IicPT0X6WNDy+WANrBmMRWlZqlFR5rZWnMDMenVrXitRh8UF5qoMzfwjhpovwRngvp2+RpNX C3eg+METoCtAC7LUYKSfoYmrhVol3YiFyPhcL2Hd4G+re6ZC9w8lhSRVqkYRZZfgRC9svlYCZLZ VhKfEqPbk31CloJAjMrQZvSO343qQORmcpg9ePErvplA4Zz7mKjCP6LurT51zCSjKXIX8rIbCS7 jZ9WaNDNGX3WF4OaK2PODk0+LM8sTw+OEIiZF4ZfvOhSbtGgxguuBH7Vt+L0O0b1Ct7wDmAnLL/ T+exuGAlIjXhTqWA0NGjw20khY9rqZ7fG7Xc7fhZuauXLhZA5L7D1qxLprhFPELOZbcL01stEOp TnFfufMnkxIWUkCRc= X-Received: by 2002:a05:620a:f13:b0:937:2ac8:bbda with SMTP id af79cd13be357-93960f52da3mr746017185a.35.1788372531337; Wed, 02 Sep 2026 11:08:51 -0700 (PDT) X-Received: by 2002:a05:620a:f13:b0:937:2ac8:bbda with SMTP id af79cd13be357-93960f52da3mr746011785a.35.1788372530865; Wed, 02 Sep 2026 11:08:50 -0700 (PDT) Received: from shalem (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a67f895d68sm1444041a12.4.2026.09.02.11.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Sep 2026 11:08:49 -0700 (PDT) From: Hans de Goede To: Bjorn Andersson , Cristian Marussi , Sudeep Holla Cc: Hans de Goede , Daniel Lezcano , Bjorn Andersson , Frank.Li@kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/3] module: add SCMI device table alias support Date: Wed, 2 Sep 2026 20:08:42 +0200 Message-ID: <20260902180844.41230-2-johannes.goede@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260902180844.41230-1-johannes.goede@oss.qualcomm.com> References: <20260902180844.41230-1-johannes.goede@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTAyMDE2MCBTYWx0ZWRfX7i1Qwo4QsQza 71owRmy8fgx0vjWnfnPj+8SxcPH5bISvF9q0UR3vvTo2WVK2ywPQQGNpUWV+4zoFqGayozQPqes QtDvr2Aj0ob5GGeyXUr7blFNLaDW6DoNPg05vMEncobHRruUNXlv9Qf9Lgb/FmSdws+168oswOa /CWfieRZ5/EPWto97XAX2nJivCPAFpQ+n4v0WrbpuOkuwo6BO4S6L20ChtKsmdIbSMI3aDgigmF M6Ng0VyPHrxxjkuyKGUcUr06PWGD/NHzoxcGweD1G5OIOU4H9Om8eKEERz0n6Zfg3ZvzYHzOSsI gtH/N6Aqua/v3QnBSIBw4RSoa3SveDOwrK9HjAymU5rSExhDvuEpg4l2Jrtcdd8j/EfqljKHa8I 5LREHFoyr6K/gQ00eJ3K3y5l/Pb6Yfxu+rY+C1rD0GdqRayjSEkKSWQsUuUksizzto6arpOJqX0 HhTac28sETYR4evXnYg== X-Proofpoint-ORIG-GUID: 4dCObOW6EOlSVtYVcTmzyxIMjA87obBv X-Authority-Analysis: v=2.4 cv=QfpWeMbv c=1 sm=1 tr=0 ts=6a986634 cx=c_pps a=HLyN3IcIa5EE8TELMZ618Q==:117 a=xqWC_Br6kY4A:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=bC-a23v3AAAA:8 a=EUspDBNiAAAA:8 a=NbjprmzQH6tOvfj-_-IA:9 a=bTQJ7kPSJx9SKPbeHEYW:22 a=FO4_E8m0qiDe52t0p3_H:22 X-Proofpoint-GUID: 4dCObOW6EOlSVtYVcTmzyxIMjA87obBv X-Proofpoint-Spam-Info: AW1haW4tMjYwOTAyMDE2MCBTYWx0ZWRfX5pIBCTe6AjGy 6aki+lyRRzRIDkKUBAMx7PdHZBoZ4xNqsya9GmmqFByP8tgjfPu9PWDW/PeSHhvrx0h5XX79Ger PTliY7YamS571FptJhXOBMZ3Cu+CyLg= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-02_04,2026-09-02_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 bulkscore=0 phishscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 clxscore=1015 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2609020160 Content-Type: text/plain; charset="utf-8" From: Bjorn Andersson SCMI client drivers already describe their bus match data with MODULE_DEVICE_TABLE(scmi, ...), but modpost does not know how to consume SCMI device tables. As a result, SCMI modules do not get generated module aliases from their id tables. Move struct scmi_device_id to mod_devicetable.h so it has a fixed layout visible to modpost, add the corresponding generated offsets and teach file2alias to emit scmi:: aliases. Use the same stable alias format for SCMI device uevents and sysfs modaliases. The previous string included the instance-specific device name, which is not useful for matching modules. Assisted-by: Codex:GPT-5.5 Reviewed-by: Hans de Goede Tested-by: Hans de Goede Signed-off-by: Bjorn Andersson Signed-off-by: Hans de Goede --- Changes in v4: - Drop unused driver_data member from struct scmi_device_id (Uwe) - Drop device-id/scmi.h include from mod_devicetable.h (Uwe) - Add device-id/scmi.h to devicetable-offsets.c and file2alias.c (Uwe) Changes in v3: - Adjust for ad428f5811bd ("mod_devicetable.h: Split into per subsystem headers") - Add '\n' to modalias_show() output, matching other subsystems' modalias Changes in v2: - Drop #include from scmi_protocol.h - Link to v1: https://patch.msgid.link/20260616-scmi-modalias-v1-0-662b8dd5= 2ab2@oss.qualcomm.com --- MAINTAINERS | 1 + drivers/firmware/arm_scmi/bus.c | 21 ++++++++++----------- include/linux/device-id/scmi.h | 17 +++++++++++++++++ include/linux/scmi_protocol.h | 6 +----- scripts/mod/devicetable-offsets.c | 5 +++++ scripts/mod/file2alias.c | 12 ++++++++++++ 6 files changed, 46 insertions(+), 16 deletions(-) create mode 100644 include/linux/device-id/scmi.h diff --git a/MAINTAINERS b/MAINTAINERS index fc6ca082106f..ee5beee606fc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -26334,6 +26334,7 @@ F: drivers/pmdomain/arm/ F: drivers/powercap/arm_scmi_powercap.c F: drivers/regulator/scmi-regulator.c F: drivers/reset/reset-scmi.c +F: include/linux/device-id/scmi.h F: include/linux/sc[mp]i_protocol.h F: include/trace/events/scmi.h F: include/uapi/linux/virtio_scmi.h diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bu= s.c index 793be9eabaed..d12d5de15a1a 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -13,11 +13,12 @@ #include #include #include +#include #include =20 #include "common.h" =20 -#define SCMI_UEVENT_MODALIAS_FMT "%s:%02x:%s" +#define SCMI_UEVENT_MODALIAS_FMT SCMI_MODULE_PREFIX "%02x:%s" =20 BLOCKING_NOTIFIER_HEAD(scmi_requested_devices_nh); EXPORT_SYMBOL_GPL(scmi_requested_devices_nh); @@ -141,7 +142,7 @@ static int scmi_protocol_table_register(const struct sc= mi_device_id *id_table) int ret =3D 0; const struct scmi_device_id *entry; =20 - for (entry =3D id_table; entry->name && ret =3D=3D 0; entry++) + for (entry =3D id_table; entry->name[0] && ret =3D=3D 0; entry++) ret =3D scmi_protocol_device_request(entry); =20 return ret; @@ -197,18 +198,18 @@ scmi_protocol_table_unregister(const struct scmi_devi= ce_id *id_table) { const struct scmi_device_id *entry; =20 - for (entry =3D id_table; entry->name; entry++) + for (entry =3D id_table; entry->name[0]; entry++) scmi_protocol_device_unrequest(entry); } =20 static int scmi_dev_match_by_id_table(struct scmi_device *scmi_dev, const struct scmi_device_id *id_table) { - if (!id_table || !id_table->name) + if (!id_table || !id_table->name[0]) return 0; =20 /* Always skip transport devices from matching */ - for (; id_table->protocol_id && id_table->name; id_table++) + for (; id_table->protocol_id && id_table->name[0]; id_table++) if (id_table->protocol_id =3D=3D scmi_dev->protocol_id && strncmp(scmi_dev->name, "__scmi_transport_device", 23) && !strcmp(id_table->name, scmi_dev->name)) @@ -245,7 +246,7 @@ static struct scmi_device *scmi_child_dev_find(struct d= evice *parent, struct device *dev; =20 id_table[0].protocol_id =3D prot_id; - id_table[0].name =3D name; + strscpy(id_table[0].name, name, sizeof(id_table[0].name)); =20 dev =3D device_find_child(parent, &id_table, scmi_match_by_id_table); if (!dev) @@ -282,8 +283,7 @@ static int scmi_device_uevent(const struct device *dev,= struct kobj_uevent_env * const struct scmi_device *scmi_dev =3D to_scmi_dev(dev); =20 return add_uevent_var(env, "MODALIAS=3D" SCMI_UEVENT_MODALIAS_FMT, - dev_name(&scmi_dev->dev), scmi_dev->protocol_id, - scmi_dev->name); + scmi_dev->protocol_id, scmi_dev->name); } =20 static ssize_t modalias_show(struct device *dev, @@ -291,9 +291,8 @@ static ssize_t modalias_show(struct device *dev, { struct scmi_device *scmi_dev =3D to_scmi_dev(dev); =20 - return sysfs_emit(buf, SCMI_UEVENT_MODALIAS_FMT, - dev_name(&scmi_dev->dev), scmi_dev->protocol_id, - scmi_dev->name); + return sysfs_emit(buf, SCMI_UEVENT_MODALIAS_FMT "\n", + scmi_dev->protocol_id, scmi_dev->name); } static DEVICE_ATTR_RO(modalias); =20 diff --git a/include/linux/device-id/scmi.h b/include/linux/device-id/scmi.h new file mode 100644 index 000000000000..1b4ccfa9dcc5 --- /dev/null +++ b/include/linux/device-id/scmi.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef LINUX_DEVICE_ID_SCMI_H +#define LINUX_DEVICE_ID_SCMI_H + +#ifdef __KERNEL__ +#include +#endif + +#define SCMI_NAME_SIZE 32 +#define SCMI_MODULE_PREFIX "scmi:" + +struct scmi_device_id { + __u8 protocol_id; + char name[SCMI_NAME_SIZE]; +}; + +#endif /* ifndef LINUX_DEVICE_ID_SCMI_H */ diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 5ab73b1ab9aa..ba53302d95f5 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -9,6 +9,7 @@ #define _LINUX_SCMI_PROTOCOL_H =20 #include +#include #include #include #include @@ -951,11 +952,6 @@ struct scmi_device { =20 #define to_scmi_dev(d) container_of_const(d, struct scmi_device, dev) =20 -struct scmi_device_id { - u8 protocol_id; - const char *name; -}; - struct scmi_driver { const char *name; int (*probe)(struct scmi_device *sdev); diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-of= fsets.c index b4178c42d08f..91ec3704ee2b 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 #define COMPILE_OFFSETS +#include #include #include =20 @@ -144,6 +145,10 @@ int main(void) DEVID(rpmsg_device_id); DEVID_FIELD(rpmsg_device_id, name); =20 + DEVID(scmi_device_id); + DEVID_FIELD(scmi_device_id, protocol_id); + DEVID_FIELD(scmi_device_id, name); + DEVID(i2c_device_id); DEVID_FIELD(i2c_device_id, name); =20 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 8d36c74dec2d..5379b1def07b 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -121,6 +121,7 @@ typedef struct { /* Big exception to the "don't include kernel headers into userspace, which * even potentially has different endianness and word sizes, since * we handle those differences explicitly below */ +#include "../../include/linux/device-id/scmi.h" #include "../../include/linux/mod_devicetable.h" =20 struct devtable { @@ -852,6 +853,16 @@ static void do_rpmsg_entry(struct module *mod, void *s= ymval) module_alias_printf(mod, false, RPMSG_DEVICE_MODALIAS_FMT, *name); } =20 +/* Looks like: scmi:NN:S */ +static void do_scmi_entry(struct module *mod, void *symval) +{ + DEF_FIELD(symval, scmi_device_id, protocol_id); + DEF_FIELD_ADDR(symval, scmi_device_id, name); + + module_alias_printf(mod, false, SCMI_MODULE_PREFIX "%02x:%s", + protocol_id, *name); +} + /* Looks like: i2c:S */ static void do_i2c_entry(struct module *mod, void *symval) { @@ -1491,6 +1502,7 @@ static const struct devtable devtable[] =3D { {"virtio", SIZE_virtio_device_id, do_virtio_entry}, {"vmbus", SIZE_hv_vmbus_device_id, do_vmbus_entry}, {"rpmsg", SIZE_rpmsg_device_id, do_rpmsg_entry}, + {"scmi", SIZE_scmi_device_id, do_scmi_entry}, {"i2c", SIZE_i2c_device_id, do_i2c_entry}, {"i3c", SIZE_i3c_device_id, do_i3c_entry}, {"slim", SIZE_slim_device_id, do_slim_entry}, --=20 2.55.0 From nobody Sat Sep 26 09:23:33 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 623422472B8 for ; Wed, 2 Sep 2026 18:08:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788372537; cv=none; b=M5CofSRBiJI7Uvv31GWpLCKLNuX3c/9SZKwJJ+cJ3h8idHYTD0EoqrBsM2hgNLXQSonglS2elJoJ2cQlIWMIejpfyz+QR5dUsW4bp9VDzuLx8a7EEWmKki0VK/F/gKXY+rNe2xgElCO+Q7OsX7Gm6Y52RAz6xVbnHPNPr7eEFpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788372537; c=relaxed/simple; bh=qqYzxrvaW33GugN1wfMmttWK+is/52VK42xgNKdCyJI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z5XUab6xLZMKZhjDo53ffGrUyYdJUO+dFPZ2talEnnqujvuWxTrlbgKYCXjCG8IqPDPsjK8/j72PFo4ynhaFIlJC25U4+2DZ5aiDHwMrIiV9T8yQ2zMzfAEN2u8WbfV6FL+eB31UzgrlhvlvBbvL2kZsmBDie4xzk+j4DaE8UI8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=llUct4c5; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=NPyvYJBk; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="llUct4c5"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="NPyvYJBk" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 682Hr22g2270814 for ; Wed, 2 Sep 2026 18:08:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=8/6R5LUyWsU dJmgkPC8R28H+x4JiDbGyxUBi1wvYWmg=; b=llUct4c580shIcDg73MLmvRVJL3 rYZ5pZ9DZzYgOKGXpvVH51WqQKdKZGK0PGjK9aV8Hr1J3M2iqjaQLjf2LDMvlBPL hGv4+zlqEgaLeoNRQZNR7JIwSs9oQY5MuTyqhkp/X4yGCaDWUxWBssoBt9vrMFl2 oqayeEXnypFPbNivWamumxlt7OdkxXSXtATWmzYewVhTVTXHt+A25SKtlpDQbpcf Ym7HOMI6Hyyef9p04dBmlKhMLPacd8l6gHKILQZWe4yWuE9Mai44qxXUUg1A4UYG 7YqV04PHb9ztuflJhayzP1qtYP19J4Lyx9oGNlqz4sapzGCUBxi2DPgp+Gw== Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gej2ca07b-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 02 Sep 2026 18:08:55 +0000 (GMT) Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-939665a1ae6so206725085a.0 for ; Wed, 02 Sep 2026 11:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1788372535; x=1788977335; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=8/6R5LUyWsUdJmgkPC8R28H+x4JiDbGyxUBi1wvYWmg=; b=NPyvYJBkGL5OuFDA35gSYGzmpj4bP9u0QwejJ561++FChQber7HDGvHZU2KGSX9AAH j3Kx4Q/4GZGL4PpBvTdZ9GyzP66cRMooRjKJMqPctkpXBMhIMW/TiTE2+852yyhh0mAE RYASD5XyawjPtrLD4Suxp6sBY7lhwEhGpJjIPsjcxpKzOiffPS2J6yjR0eKyTS0tBPCj 8bcTGIm5GcgPdSpftj12fRDZtYxRPLGCTO4fDFAKs4N4z3gOhctLVOqVAzvFwI7nOojA 3q1GOkXDbFUFSCXdKswKwbvWhGa/oFUtioIRMF3SGs9Oc0TCHEPe+oBGrAEAzxBAuo+Q bM6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788372535; x=1788977335; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=8/6R5LUyWsUdJmgkPC8R28H+x4JiDbGyxUBi1wvYWmg=; b=C8/2aveVnW7UTFGLgZqExQmacJH3wmrLaaERw4bVyDEfIxk6zFKs6sRI2S02iaHZ/H CKxmGdk9hzMLDvoQLIy5K413WjEpJZWuGbt7vagKOvQOAEVPhwMw6woWudV8b6rS+arV qone4TZXksc30c7MRIfPxScnWLi8j70B5mBttuTCRnoKNzkEbe6ggy2XYAzI/onAc9GV X+Q5qaMOBpZBg07EpYfWdeWUYYL8w/OZgomyP61Dc1guCckWGfeWFX50/fH+2PSydFNb j1X84/r/O5HK0HMNZuxR3UwFNNLezp51Qb92hIxd47K3plh/v01yn2lg1+FPnvilTFHl Ok8A== X-Forwarded-Encrypted: i=1; AKwUvBxdNEEHjGdQUdhtaj+ainWWd57HosCwDqNIGkx7ungW0J9cfLTDTpECsx8l4R0sorAtoa5Du9bnbe3omqc=@vger.kernel.org X-Gm-Message-State: AFuF++mqy6At9UWYyMQMFFfCKcX6JPMp3aukpDFFP42aL26zzHt0xj7A 9dTg+V0RBOAodd2YgJ+YhZhIjzDM7L1cWWG9lZyQhI7Bk4eZjeg344ddvlQpsFUVwNjqdNQamO5 4vgQMICfxeiuEPPrWVBDeTk+v5OD9QYWL+O32apf7pVk9p9ASuUqEiEkTlEemSilj7js= X-Gm-Gg: AYBFou1wE+535dbpecEck20TxOWRdH2vR1HP13ecUASCOO1Mq+IiF7ZaRCeGy1YkIk2 EgmYGPErJ3xfNZngfouliDAORikj3CgeNOLvaxiaiMXbmGxp8npdM/CYvSmJHNugYMpT20isl+S I7WRA4Zr2BD8eItRwE65/m0j2zAGGIU10P9BoB9JPzS1WN8X3yx8R3gAHpcYD9JtXysVJV0BuCB crhADjVGMUEzWfDIqoO1Br+guVyzgN3X33dZnEUbC8/jGYqb2IjgvxsZCOOk1HWlCr2zSZVKQaP R3HvBIc1o736+eIiu2eM4zUKC7X0RW6YH4hIEcA/TmG+ouF/MDrsexLD8/iMx1lQ7J+FCYL0T28 Lu6slrLZk7R9JYy8+dWyBquNMkWnT50hXfyO0fA+zFkMNHqhy1+znmpKBJ5sLlKsxtek92s9Jp6 CjoWlYE9e65E662yE= X-Received: by 2002:a05:620a:711b:b0:937:27fb:96f8 with SMTP id af79cd13be357-93960fe4a2bmr717702585a.41.1788372534518; Wed, 02 Sep 2026 11:08:54 -0700 (PDT) X-Received: by 2002:a05:620a:711b:b0:937:27fb:96f8 with SMTP id af79cd13be357-93960fe4a2bmr717694085a.41.1788372533835; Wed, 02 Sep 2026 11:08:53 -0700 (PDT) Received: from shalem (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a67f895d68sm1444041a12.4.2026.09.02.11.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Sep 2026 11:08:52 -0700 (PDT) From: Hans de Goede To: Bjorn Andersson , Cristian Marussi , Sudeep Holla Cc: Hans de Goede , Daniel Lezcano , Bjorn Andersson , Frank.Li@kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v5 2/3] firmware: arm_scmi: Fix scmi_protocol_table_register() error handling Date: Wed, 2 Sep 2026 20:08:43 +0200 Message-ID: <20260902180844.41230-3-johannes.goede@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260902180844.41230-1-johannes.goede@oss.qualcomm.com> References: <20260902180844.41230-1-johannes.goede@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Info: AW1haW4tMjYwOTAyMDE2MCBTYWx0ZWRfX/bLoDsLZVlg7 KkQnBs5IhR2xmOtOm5E2OTUgcPpEitSlM/Lbc/jKLvWwnOvKDp2TLBQxtKWT6srY+66bd7Z5RUD ft9gf6BhIrpFKYQn9zK+4QmYKF/CgYY= X-Authority-Analysis: v=2.4 cv=G+ss1dk5 c=1 sm=1 tr=0 ts=6a986637 cx=c_pps a=50t2pK5VMbmlHzFWWp8p/g==:117 a=xqWC_Br6kY4A:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=mtY6ubt43vOedHXxatAA:9 a=IoWCM6iH3mJn3m4BftBB:22 X-Proofpoint-GUID: xvznUG7l3_Hy4tRVRls7O48qlPr4s7qF X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTAyMDE2MCBTYWx0ZWRfX9UgMAN8e9GU9 HnKcPGYFUKufj0qrukm6DvMtO9jIYTFejez4qYSi1X+aJBxEfpTDlFU6YBxyqfnQJEQrYP46sTq 1dozjVc2/HDwBiB30YSX5d5nN4wJAvxWbQtzOcdk+ZI0BEPaSGtamYxiMKVmKxuKSlzI/XOY/Ho pCsB/HBB6f3Az2g+qvW748nmBAawcFdT2Ac9wgTzpy7v4EHv2O+cM3A/L5MW3875nm2h9bWY244 l/PeOmx6zEgtqAgGkS8p2aTDDDjMcqviNGrVaWtob4GQ6nD4cvkA8N9l+Wr9DI5hfqhu7l4OJRN CzFDRrtIInA4zeIsgF2Bm+EOAWROwU+T8rTAnSXzBaQlPD45o9KV4IU1GEej6X9r4HKtYH75L2B PMIs6LIxiMucHhI6jqMyhjjKj/6Tv8w+TIwE7nSBKaJARtTot3eVxBZ0o7sJOeQJ5rYWH+KgABW hjOdTf0Hq61l68q/ZBg== X-Proofpoint-ORIG-GUID: xvznUG7l3_Hy4tRVRls7O48qlPr4s7qF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-02_04,2026-09-02_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 adultscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2609020160 Content-Type: text/plain; charset="utf-8" scmi_protocol_table_register() stops at the first failure to request one of the scmi_device_id-s into scmi_requested_devices, but it leaves any previously successfully requested device-ids in place. Unrequest any successfully requested device-ids on error to fix this. The code manually unrequests these rather then calling scmi_protocol_table_unregister() because one way this can fail is because of duplicate device-ids and in that case the original device-id must not be unrequested. This also moves scmi_protocol_table_register() to below scmi_protocol_device_unrequest() since it now calls that local function. Signed-off-by: Hans de Goede --- Changes in v5: - New patch in v5 of this series --- drivers/firmware/arm_scmi/bus.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bu= s.c index d12d5de15a1a..6f667e4ffeed 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -137,17 +137,6 @@ static int scmi_protocol_device_request(const struct s= cmi_device_id *id_table) return ret; } =20 -static int scmi_protocol_table_register(const struct scmi_device_id *id_ta= ble) -{ - int ret =3D 0; - const struct scmi_device_id *entry; - - for (entry =3D id_table; entry->name[0] && ret =3D=3D 0; entry++) - ret =3D scmi_protocol_device_request(entry); - - return ret; -} - /** * scmi_protocol_device_unrequest - Helper to unrequest a device * @@ -193,6 +182,25 @@ static void scmi_protocol_device_unrequest(const struc= t scmi_device_id *id_table mutex_unlock(&scmi_requested_devices_mtx); } =20 +static int scmi_protocol_table_register(const struct scmi_device_id *id_ta= ble) +{ + int i, ret; + + for (i =3D 0; id_table[i].name[0]; i++) { + ret =3D scmi_protocol_device_request(&id_table[i]); + if (ret) + goto error; + } + + return 0; + +error: + while (--i >=3D 0) + scmi_protocol_device_unrequest(&id_table[i]); + + return ret; +} + static void scmi_protocol_table_unregister(const struct scmi_device_id *id_table) { --=20 2.55.0 From nobody Sat Sep 26 09:23:33 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 94D9338757C for ; Wed, 2 Sep 2026 18:08:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788372540; cv=none; b=D0r2cZaNEmphVWFJhX0dry4CgCxtBtqKRxQYYiNvKVqFXw6MR3mlp83umFtEI7GNxQi5BVSxop5EZHxEbfHh0KqVNIhrxigVcYRXrnKOiCcvUD7LSYkmMU9jsJhN2rJxr7c6Zx/vYSi0mAQ2zdlD7XK04B/hF8KZ6CxCtxFiRLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788372540; c=relaxed/simple; bh=vs/zkZkBqDGWIJOv/e2m5e2aVz+VFWJKG1MOOWJTS0k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Jhwai5tFRgdSFbbsvSqm4f55P1t4wHI5hIoPNHX+Z642wKn0/nz8tdZWmlS6s+v3utrqoIUtobA+Cf2tZknFIAjuigMG0mzgfkvz9yJifb0Du7/dflsOyk/X4I6K9JCkLgvfxhirpWijzxrsPOYHkFtDt6+cqEvmDsMslVyUUxM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=DxS6P7SL; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Md8bIJIy; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="DxS6P7SL"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Md8bIJIy" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 682HqvMq2104770 for ; Wed, 2 Sep 2026 18:08:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=bbORKfBAEcY HO2qsqE2iCDgdtjeThGNyWZmtJvMyYf4=; b=DxS6P7SLUnmuzeNOqzF+4g/zJxu Ce2GUi0lzlVVbLVCYigkJKHMuQZCRp411lPCy3f8HAp4JJ7J74PFJfi5NjXp9peI Ryus9hn6rdlRnFw+PdD7Rj7AhOFxeXKLxxpExLLzmdjzoWjz9XHQ66UNquuTn6H/ 1TrFa94LmcwyCA6MDaT9uHssmcMH1IUYYOQk4zU8ZLLmAOe/PpUS8l1UciAcNcer I0nMGjUHGfkbk4hxBgKikY2O2uXoRezFF1Iyxpd/3iAEnFAiSICxf0rlswxNkquT 84rUO5n6Awh4naqesajSsDeG0EpfCHZYzIDCqG1IaIevEX8GGxNNnb/9VUw== Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4genrdrxu4-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 02 Sep 2026 18:08:57 +0000 (GMT) Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-939665a1ae6so206735985a.0 for ; Wed, 02 Sep 2026 11:08:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1788372537; x=1788977337; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=bbORKfBAEcYHO2qsqE2iCDgdtjeThGNyWZmtJvMyYf4=; b=Md8bIJIyTQuh7aNdFiIvfKXCnZrLtop7r0kkLMY23/EtXlER/8EYMSb+8amEm4IYhA kW5AhXx5LH7yKdLbkbjQZrn7r7z1QjS8szMthDFRJ1Z/MJxRVmLeDjEHM47GFigWQ/o6 AewZjc+4Okv8KD5u7XMtwxJj31rxgO0o/L15GqJfLSDdfPWtuQ1BNH9vmOZMYgNIeSqg 0RhUhbD53bAQhY0IBJ/YDxts+5x9gduV37iSQabBBCKVPvnqv4WSCydMnf6i/w98O9md a7ljYGpVKeruo0ABK4pT5MqeBFqZcENGpTvpBMuRANXw05aKLysJDYAd5hiNLT4gmVjI Duww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788372537; x=1788977337; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=bbORKfBAEcYHO2qsqE2iCDgdtjeThGNyWZmtJvMyYf4=; b=pPcb7MbY8G8deg1rresQMaZmuYys9fpifbpd9ztt9Jf7CIRK9PHoOl5Cgdlv52poTs KjM6KVw5DHcNbrwCrE7ypcfRhAJrQBde/Nm5GgysDq+2Dk46xyynZn5bUGCdSrafDXzA 20OnIkiS7lW+3x/beRk4tGHT9lZSpQoYyOqfa7wBYqKR5O2xEHSldBnNN5crKbwfCwJG 9pfONWLqzbYo6nlWefoN+Xnl2pnPpXN0wTxL2l/cwRpRpQwBPRLw+mWsG8K3dyPmlUKi zNJSjc0B88G9hID9nTvQO0G2lM5Si+775jt58Gk6Ezy53ny2lVa4euCaXHiBgOVUIHaD mr8A== X-Forwarded-Encrypted: i=1; AKwUvBx4oJTavZJ4tMAps32EMdEGX+xmblQlfAkCjlSitPPXyOh8GlUxhEYZfJu9dlda9zLlC/ds/TN7BMhDr/Y=@vger.kernel.org X-Gm-Message-State: AFuF++nDDCcufQdvLZKo3lEic5q1HpcotD4HR2ryV8FhMdAf8514FgVP cKEmqz2QjioXE78r4vHYXA13elE0bXTC5IXF7WNg9Rb9n3jsjeCWhiDhUoQQJIpV7rePiCA3FEx eI5iRCfB3TGG60seuGp9I0wokeYMvX9KX6sbDYBnCWXTO/PwbXPe/dbqBFOYChS+3Vjg= X-Gm-Gg: AYBFou2xNlj3JE86HoPtwm5hBBocsv3uj3d9BLplMmmfVjsxeuMnuKX6xa1JjiZbnkM Nsrwt05i/pOyA0RhHA6Hvasr1HHhKLaxaaT0eB1uIdl+f2us9c4Mcgtun7tb+vjtUmt/kyeLTql fk3b/7tM88dvteG02O+4hnuL4l84g0bc+KaDlwlHSDpIUzPBs9G+4tp/KxbQQWJOu1x4tFLPnpp 3bZV8XZ53gpiyViBjHrocdbhDBzjw2vZC8+lDu+z6JBJZL4o9aYjh6e0owKW42PbAmlXiECKmCi URdiQj7XP3H6v9UGIEwAM4FIXvJoj7Pat9boj5sMQ09YEm8RNFPdb/TFPC38h9yBs9zaOCfplnS 1qFRYp1WfgnzSBzUsAiJIZZu1jIMaFUTroo89CrYbYJcXUjtAxvWI+O0fkotxaC2YiKAttUuveE a/mosoOoRFHU4TgzA= X-Received: by 2002:a05:620a:28c7:b0:932:ddff:1241 with SMTP id af79cd13be357-93960efc6d7mr820782185a.26.1788372536497; Wed, 02 Sep 2026 11:08:56 -0700 (PDT) X-Received: by 2002:a05:620a:28c7:b0:932:ddff:1241 with SMTP id af79cd13be357-93960efc6d7mr820774185a.26.1788372535857; Wed, 02 Sep 2026 11:08:55 -0700 (PDT) Received: from shalem (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a67f895d68sm1444041a12.4.2026.09.02.11.08.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Sep 2026 11:08:54 -0700 (PDT) From: Hans de Goede To: Bjorn Andersson , Cristian Marussi , Sudeep Holla Cc: Hans de Goede , Daniel Lezcano , Bjorn Andersson , Frank.Li@kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, imx@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v5 3/3] firmware: arm_scmi: Always create devices for standard protocols Date: Wed, 2 Sep 2026 20:08:44 +0200 Message-ID: <20260902180844.41230-4-johannes.goede@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260902180844.41230-1-johannes.goede@oss.qualcomm.com> References: <20260902180844.41230-1-johannes.goede@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=H4/rBeYi c=1 sm=1 tr=0 ts=6a986639 cx=c_pps a=qKBjSQ1v91RyAK45QCPf5w==:117 a=xqWC_Br6kY4A:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=9VS019lR99HtUmLVNGAA:9 a=NFOGd7dJGGMPyQGDc5-O:22 X-Proofpoint-GUID: 6ij0Tir41dt9EEaMni2E1mhJWiFQ9e91 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTAyMDE2MCBTYWx0ZWRfX5U2dXgiscEjj hSsoxiZWpboytOh/ShN0JWnQTkMvpf61tgED9WezJs7yh9pMZ8wcfKBtFZTBjz7kDFgPiarfAwX aCg7g5CYGCRMWU8b/z137yqVtUBkNuCKcwMm7V5SU9kK9C/6UoqmbWBg61XtUInbvYt1b1xJByu Yo+MM7rsKH60AiML3yXhCpoZxyF9mubiKj9T+XWiUGfKDPSSsR83jLsMH44P7gxgETXbeVVnzV5 vsM6mh71Md9M32tQUYeuWbJ4nMtQLrHnmmDjZeeS/GP29jJh6PvPBPHdyLWeKyvTDeeyfW487JN ICwFnRxKUIs4yDJO4ohz4VAYbcvnJhHwBFXKKoOjcx0vcy7c5UzJPGmhyhvNGr4oTZ3cOKU5Pop 0Ce9OnVa2DKyhnT9ir85eH2W5UoAG9BN9JRbTFPtdVm0iqr594JmmhSJHu6Oy/8uEUDCzn/qeef fkNuCh93W9+SS37JcFA== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTAyMDE2MCBTYWx0ZWRfXy6Unm9jRbsnn a3Alqiz1gik4MOmaCqnPhTiuyksP6XSBCGLuPNUfE9x7EDaZpjglJCkFpvSrGh6BwI1Z8k2MGiG QunOhdXrgMphLNZhMD/ZyLUmgxm6qPc= X-Proofpoint-ORIG-GUID: 6ij0Tir41dt9EEaMni2E1mhJWiFQ9e91 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-02_04,2026-09-02_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 bulkscore=0 clxscore=1015 malwarescore=0 spamscore=0 phishscore=0 impostorscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2609020160 Content-Type: text/plain; charset="utf-8" Protocol driver module auto-loading requires the devices to already be created for udev to get the necessary uevents based on which udev loads modules. But SCMI devices are only created after their { protocol, name } device-id has been added to the requested-devices list which is done from scmi_driver_register(). This creates a circular dependency where device creation is waiting for the driver to register and loading the module with the driver is waiting for the device to be created. Add a list of standard protocol device-ids and always create devices for these without relying on these being added to the requested-devices list. This removes the circular dependency, fixing module auto-loading. Signed-off-by: Hans de Goede --- Changes in v5: - This is a new patch in v5 replacing "Pre-register protocol, name tupples for standard protocol". Pre-registering requires scmi_protocol_device_request() to allow duplicate device-ids, but then if the first driver of two with duplicate devce-ids gets unloaded device creation for the second driver will fail. Allowing duplicates causes all kinds of problems, so this new approach avoids this. --- drivers/firmware/arm_scmi/bus.c | 48 +++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bu= s.c index 6f667e4ffeed..10d15da76f19 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -505,6 +505,34 @@ _scmi_device_create(struct device_node *np, struct dev= ice *parent, return sdev; } =20 +/* Standard protocols table */ +static const struct scmi_device_id scmi_std_id_table[] =3D { + { SCMI_PROTOCOL_POWER, "genpd" }, + { SCMI_PROTOCOL_SYSTEM, "syspower" }, + { SCMI_PROTOCOL_PERF, "perf" }, + { SCMI_PROTOCOL_PERF, "cpufreq" }, + { SCMI_PROTOCOL_CLOCK, "clocks" }, + { SCMI_PROTOCOL_SENSOR, "hwmon" }, + { SCMI_PROTOCOL_SENSOR, "iiodev" }, + { SCMI_PROTOCOL_RESET, "reset" }, + { SCMI_PROTOCOL_VOLTAGE, "regulator" }, + { SCMI_PROTOCOL_POWERCAP, "powercap" }, + { SCMI_PROTOCOL_PINCTRL, "pinctrl" }, + { SCMI_PROTOCOL_PINCTRL, "pinctrl-imx" }, + { }, +}; + +static bool scmi_device_id_in_std_id_table(const struct scmi_device_id *id) +{ + for (int i =3D 0; scmi_std_id_table[i].name[0]; i++) { + if (scmi_std_id_table[i].protocol_id =3D=3D id->protocol_id && + !strcmp(scmi_std_id_table[i].name, id->name)) + return true; + } + + return false; +} + /** * scmi_device_create - A method to create one or more SCMI devices * @@ -534,11 +562,25 @@ struct scmi_device *scmi_device_create(struct device_= node *np, { struct list_head *phead; struct scmi_requested_dev *rdev; - struct scmi_device *scmi_dev =3D NULL; + struct scmi_device *sdev, *scmi_dev =3D NULL; =20 if (name) return _scmi_device_create(np, parent, protocol, name); =20 + /* + * Always create devices for standard protocols, even if the device-ids + * have not been registered into scmi_requested_devices yet. This allows + * auto-loading of SCMI protocol driver modules for standard protocols. + */ + for (int i =3D 0; scmi_std_id_table[i].name[0]; i++) { + if (scmi_std_id_table[i].protocol_id !=3D protocol) + continue; + + sdev =3D _scmi_device_create(np, parent, protocol, scmi_std_id_table[i].= name); + if (sdev) + scmi_dev =3D sdev; + } + mutex_lock(&scmi_requested_devices_mtx); phead =3D idr_find(&scmi_requested_devices, protocol); /* Nothing to do. */ @@ -549,7 +591,9 @@ struct scmi_device *scmi_device_create(struct device_no= de *np, =20 /* Walk the list of requested devices for protocol and create them */ list_for_each_entry(rdev, phead, node) { - struct scmi_device *sdev; + /* Standard proto matches already have their dev created above */ + if (scmi_device_id_in_std_id_table(rdev->id_table)) + continue; =20 sdev =3D _scmi_device_create(np, parent, rdev->id_table->protocol_id, --=20 2.55.0