From nobody Fri Sep 25 13:55:24 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 8E462377A90 for ; Fri, 11 Sep 2026 15:23:38 +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=1789140221; cv=none; b=onx2shmasUB7+p5u5XzMPpjUk7WBBjU8ZuDGfUVJit0roI0jJUhiPurAS6rjaXi8dzuWclsFdbaWKII6SiS7blYs/IT/uCbdpq6Mg+Xm4+O9ENHFYbWO2QJ/lA1Odf6JUMyLiaTU8i597ahmKVTklbDYHVwPBtPN4xSPZ7Kok98= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789140221; c=relaxed/simple; bh=vSYj1Ys/owwCN8sFbLJ/5CPpCU7lY6/j6/iPP19TXz4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AYTBaztlrMp4HY+HmK/jX1WlgQ/gK3DjlNPEYOYe6CYWCG60bqi6wJcca6tP4qJenI0+SBYXI8OGQdF1GV9/YdkjARKhfdfR7T5StENzaMymufnHmFOQRdX90MPILLQxa63nR4IlG8bw36T1SwUNmtwnYcMfalbQQoU9NWB6Czk= 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=ZiM8bxI4; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ZCYsYS2B; 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="ZiM8bxI4"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ZCYsYS2B" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEmADR222588 for ; Fri, 11 Sep 2026 15:23:37 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=ZiM8bxI4nMUEqrC442er4jrqbUH 15aqptBgNvibc3upEYfytmBbcsCHkD/ncccW1GvkaVBXzt/+oOtAruWnGH0SUQMN CmiFAHZVBtupYwcz7YbvUxg9XsAy3tcHzC6WOdDUIHEx29TsROsHHEa2f85v5BaO 79UwxKDJfUD2jRWWHxkTGZ2IwBjtntKf/Bi7+VCX157Psvk/Tw/e8TRaHcgQyGx0 AUC/W/aanHgMU0RsP7kRGDb46yI+hEk3CBNG6fCwgPU1jKtaGjMuvb8JP3DzSZwi GZOd5bvBSB82qQQV7uzR3xQk3e5t0uq0THESI8zhwjf/aZ6AsBCY5+fZrhg== Received: from mail-vs1-f69.google.com (mail-vs1-f69.google.com [209.85.217.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gmbdradyf-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 11 Sep 2026 15:23:37 +0000 (GMT) Received: by mail-vs1-f69.google.com with SMTP id ada2fe7eead31-785b66a7017so237351137.2 for ; Fri, 11 Sep 2026 08:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1789140217; x=1789745017; 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=ZCYsYS2Bd0Nen15tPFzu2IrbKRASBmkiPeTJLIBbQjb3JTszRchKphJx3R8e+Fllee XO6PUxwqTJ05lLcLhKNUBWsguf43Mt1i1+fo9ld5egY49mcvI1Kr9jydoYcdzgGgwr6G Qg4Hj2dRdz7R+IAfLrxuKjrPMVkNINtxt3UuW6DVieaBsKHxvFJx3N+GD8Tdb/++EFTH YwP0dxDxGwmndGYD0FcHHW7ddQfPMey3SlsNUkY/27+GjmM5g2CsRNpwVz3D7nWUrNxS 4ibhZGWGh8hDk1BVvDl9YNM6QaoQlPGUQUoCC1J/kC4NANcZEIV+rqbx9qhEOSZQP503 6l0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789140217; x=1789745017; 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=M6pYhDxroZGynxhAWDWL0qjsbRYoMDwivtlpTWXgRT7g+jxi6yYGV37xzAcDL6NuPg heCmJnUCqnOWXXhMzqmi8dKOJPez27N3SzhnbNWVFbbik2bsWW4pqi7co8PUrqt0Z3iA EvRF/azzcfaKrKvsyDrhM76LwXJ1HLO3ToDLDGusgkRTwkKHttxwSok/QmgVSgQj2VWP L1PcXAbxh4a1SdE0PQ1R1eYLJL/s/YAjivEPWjaGcayiPoQ3xg+1w++vgwSDjjPlya/f k/yQx5QbN5Q4cl5FOaTEb1hwk4tqI53AufhF3oYfWkRVCCd74/KBiSZStmQq/2kgUY7J yipA== X-Forwarded-Encrypted: i=1; AKwUvBwyrNgCdrTthWePLy6Q41tervY+AvxIZyjKYen3tdVpeGqR27qGcrsFwuoUtyREqRz8DLj6AXVvARYSbhg=@vger.kernel.org X-Gm-Message-State: AFuF++ma28oF3gHNhM3Rlx3PPzvkhvVwYDbpLHcmPzdZF+RYdFEoPj3g PPu0tfZRiCX9thLMRBvLovnDn/PLWSgylEyIJ5olRwi3OTD2374wnHsut9vsENyJB+JChtEUIhI ZW4zwPG1LLqq4+FkmnKlTlaNlEn6MxHJNCOT22aXh5Kfa3ypNGMOjCgEF3/+xqT6dPVs= X-Gm-Gg: AYBFou0f7j6GHHiL2Pt6dD9CNujMZlgK8B0d/nmwofk1m40gPeAHyp+KFm/n1gbUoDV 2lNg3mLGCtUgVp7h8q7mWX5mDHyWvFzeRgZbYBu40+wGE7JBgS1xy+sGFcBG8GzUmlCFi2NFM1t MzgKtzBUR8di79fzyN+uVvttXItLXlMgV9jihccQwexm8vetz4rBiS/rwdO0OxhhY1Ulu6x6wse mlJArcNRxsu3kfZ1e/zXCs61/r6UzBEEehvDDil04b7jw+XEHCwXhYyR+kiyernjrm0RHGkuQLs lpFYceZLAw72i2ZZVDYtnZwxSDocGR8+7XASSA71Du+jIvJprUhOfYR3/80e6sQy8uGXT87gcg6 /LY5EeGgTR6PkIcnTeDqfWv9W0Ti78UVVqaT2fV+LhgkvNJREhP4xLXvYEmJ3CLwRiaBexWNKaO pJKAj46EKZC9cG8ryQxXh8NqIA/9QXw5elwArU X-Received: by 2002:a05:6102:3970:b0:782:de7b:eead with SMTP id ada2fe7eead31-792a53b19a3mr5186274137.1.1789140216461; Fri, 11 Sep 2026 08:23:36 -0700 (PDT) X-Received: by 2002:a05:6102:3970:b0:782:de7b:eead with SMTP id ada2fe7eead31-792a53b19a3mr5186201137.1.1789140216013; Fri, 11 Sep 2026 08:23:36 -0700 (PDT) Received: from t14s.space.revspace.nl (2001-1c00-2a07-3a01-8e96-3679-0b9c-de47.cable.dynamic.v6.ziggo.nl. [2001:1c00:2a07:3a01:8e96:3679:b9c:de47]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c296614323csm94042566b.59.2026.09.11.08.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 08:23:33 -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 v6 1/4] module: add SCMI device table alias support Date: Fri, 11 Sep 2026 17:23:26 +0200 Message-ID: <20260911152329.5822-2-johannes.goede@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260911152329.5822-1-johannes.goede@oss.qualcomm.com> References: <20260911152329.5822-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-GUID: CBKMV7pSnpj1Bot32KyZ03SRj-zb3_ej X-Authority-Analysis: v=2.4 cv=PLmaavqC c=1 sm=1 tr=0 ts=6aa41cf9 cx=c_pps a=5HAIKLe1ejAbszaTRHs9Ug==:117 a=xqWC_Br6kY4A:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=bC-a23v3AAAA:8 a=EUspDBNiAAAA:8 a=NbjprmzQH6tOvfj-_-IA:9 a=gYDTvv6II1OnSo0itH1n:22 a=FO4_E8m0qiDe52t0p3_H:22 X-Proofpoint-ORIG-GUID: CBKMV7pSnpj1Bot32KyZ03SRj-zb3_ej X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxNCBTYWx0ZWRfX52kvN3/9dcqM RS4PmMX0r9R6+I1VyFWzvb40RFAkbMF0YsEOAcZkjXubz0hZjazawrKuZaYG/c12zBJUrf1ko4e u1ZzO8D00Sy75dLCXbGgWZohL9tdcg0= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxNCBTYWx0ZWRfX96+d36VDoE4m 6Er8i3JDC188RHC0yhAx6LYlT2BKYnuI0dhoQTBZoc3Orr/92eEKvcmaKne8YUcjjBvfFSR+AcJ KCdH4WNPuM1OzunMYv4nnHLQ8mZd83OWLmaJLxaF2Uqh0XpwPgI5CvCSn98cKhjT8yy3Zcjk8IC Jv1QysjfmnDoflpUd1T1kPt3W1nyl0qYuPqa4E9p/GjxukNRMn9L3WYiimTDxO7mzClI17qtcCC W6YiVk839awRSY6aeYJg11Ps9mM3L7q5pnk2CjTsgZdp/BUXRwWqEqunzWaU38oHXS0PsgEUK0x YX0fNXy1fCyG84BENJs1R7Toy9pmwmc35yAeKmhFqWegwPkoqsdMJnp3Wlvi4ZIKCXRvgec7oBo BH13g3QktT1IRDKCy6wMJg6Trhp8HmlzR9LTrUJa2pxChF6EaFd2n5mILR6s/uYASB3W8jj6AKl VjN+bqFxitFQy1sszfQ== 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-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 spamscore=0 phishscore=0 adultscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 impostorscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110214 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 Fri Sep 25 13:55:24 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 9D845352022 for ; Fri, 11 Sep 2026 15:23:42 +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=1789140224; cv=none; b=dV+aFJdxLyXKxAvBOVbFqwAWRjacxUt6+kXjRSq0vHNlkx4M8Rzhjl6xdCxIvmoaXsHS87FAmwhNbwazue3Dflz0y3S6pApFR9P5sVO3zEVHBlHQ4dp8BbN9Rr3hdJykd3eKbg0Y9Jr2QCWYU/QUpMYaMr+Cwi3mbP6p2m2Wr60= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789140224; c=relaxed/simple; bh=fOozqXRREZdVE1IpU1zeudvT0HR4HrTNyPKFTzqIpmk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A6+EUaTZNg5AkOanwRINkn0L83/grwvtEtdH4XGLVQDpKTk04tdeXoC9JZ2Ca1cnjL7ONlR4BD/nf0AXSVT5M6qkzV9MnC1xq4Fbg9Y4rT+sWAzlKBX19rdlllaG0r7mUO2khr7mt0ehsRjXmoPn0cAFyZlKFpXcYKlb3JT1J9w= 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=Dp4kRRQp; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=cbuXTZ+4; 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="Dp4kRRQp"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="cbuXTZ+4" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEmGnK222842 for ; Fri, 11 Sep 2026 15:23:41 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=g5ESSTcnZuT 5ralQyPBxo3SGry0UvUcfoIReYTVE9Ig=; b=Dp4kRRQpf311WuUvZyTt1GXXi8G mQYJJF0dlzq5DsvMj5qcT8+2XoHzzdBcsvCTXIZycX1tPeuDr4fJwTrinWI+XCIS RZr9KMknF8zabRu1Z99rhRnOTBmnz+oGP3KkyHZ/x/7Zkp/P/UnBfrcxzuo8rRxS AYpK2/Xy0wzFGf0g/R79AgTuzeqTejBhWQo53tpIEBFMzeeLvKLYRq+pN/aM+N/y Rh7oNoGRbqeQPF7851HTH+/1Hbt0SxLjaX2xCcry4jhnQpsiJR0/LIXHo9rO0VF0 5rigtLFxh9aHI/uR1xm1pDcI2KT+d9BFbPNeCGMghN2kgL8UZSAg7Qt34eQ== Received: from mail-vs1-f72.google.com (mail-vs1-f72.google.com [209.85.217.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gmbdradyq-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 11 Sep 2026 15:23:41 +0000 (GMT) Received: by mail-vs1-f72.google.com with SMTP id ada2fe7eead31-73858d44c8aso250190137.0 for ; Fri, 11 Sep 2026 08:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1789140221; x=1789745021; 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=g5ESSTcnZuT5ralQyPBxo3SGry0UvUcfoIReYTVE9Ig=; b=cbuXTZ+4WkyBb4ynOOSGwOfliiEZM/KTP26BW0R/sYoQJx1RBTdZe44NqKNuhDinR1 IohOxOvQG0Rn2IyNeC3U2rYsjCxE+r90+IChi/vseS0uyou3Z0IT4QHE51odPsPEw97/ w1ycaCv3o0RB1gftggrWFpAmZW6fUTlY6FSpXKWmTpAr47ZK1ECJJDSBzd7cNUULnlkE ukN1MF/Re/QAwYHJB/nYK5x0EOxj45ceeWFHy2kDNbT87v9Vo5mfYYh8RHJvXay0aPA2 3ZXua2SMV7heJEbX9RzQ2wzD2DuHWEgll8w0bOcOwF9oouYhDrPgTggkefGqv3zcp5rL QJLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789140221; x=1789745021; 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=g5ESSTcnZuT5ralQyPBxo3SGry0UvUcfoIReYTVE9Ig=; b=jM+1716qPcnmXcqi7vR7xZM87+G4OmHH0S69acwwKrdDv3vvaB1gGa4pSobsrBZ5qr Y4A+QReEJCdJnFVc+NqtzfCRM0+0QzH2aZgP+rs1fiQ7iRSjIE9y2B2A/NTEnr9NYclT UavhO+i7wV1slY2yXFw5W2GxLerVCasWWGFpmXElVAr4l5cBQXyhkqGG/SW0N72CLEm7 V2EuUt45Wz/D5NlqhdTPjmocWNl0razFWkHocZ/4/E9Rb5gghWBshkr3fHOF8SkIBbl0 eUZbkZnlaMQyzSl5pE4IrjX+tE6iSZU8KS9fu9tX/gND7gPQBTraJwx8BNbqWZf/prUg wyCg== X-Forwarded-Encrypted: i=1; AKwUvBwe7E7URymFgAMXs+lb7f4WWrZGRnRov/74vokTluAffjlYE+UCb29XjzjcB22tARbSCuGeWSpakPCqqvg=@vger.kernel.org X-Gm-Message-State: AFuF++lFXyYozTi+4vZyHhwCabB2E8voPLRJek6R9Yfu7pQloW9MuWD/ Y2Uf4hl27PGmldq+DvlDLbYOaExRpR1dCsxlc3K7jXseNj9p3WNVQFKlivjrKi3ZHLnWorDAS80 im1cW49WSpa24ONw/iWGYVU5ShwchBtJZEq2FCceJjWci9RJz8SxxeExzXkzpMPmKQS4= X-Gm-Gg: AYBFou2DsPUMKo2qWI4eQEQUef59h0McGiwmrQOGQIRsKPTwdNU1atFVlElUwUHzx/R QX+pPEdhBSUDB0W3oOgUzyI6JOdpPExrk7mBs3U/qyyWDBzYg+pHBh1yw0NnmGsQyPzRRg69cl7 UNHjMJkXODWGtbAy7kymWoewF4MXXzZ4EAKxYl8G23IfLsz2HkBLb6vOlvuNhsWpbuy4VZqj9ov KKWdyJDuCT+cRSCD6lAvg7cyUTK/OROd39wMaj14OANPEaLHmtXbii3cD3xvnDCVZH4NcVzjrqx BP07Tun8XN2tIWPmq22ZwDB5fZqMBZGkC6zD0uDDKNYMsUif6ymPpoQhVama0d09/HNQiFPOzbo wjyffpLsHXXRnXmZngpqBKpZ/i6nRKW9+JEEKgAc33BvDCGnSvyWbTfRKCnOUESYZD0xgGG4qNH +AJq/s7yxLpsJiOck+rDU7vtfr8wGmfpMLcmAE X-Received: by 2002:a05:6102:1953:b0:78f:7135:b4ff with SMTP id ada2fe7eead31-792a52b9d3fmr5324941137.2.1789140220664; Fri, 11 Sep 2026 08:23:40 -0700 (PDT) X-Received: by 2002:a05:6102:1953:b0:78f:7135:b4ff with SMTP id ada2fe7eead31-792a52b9d3fmr5324849137.2.1789140220237; Fri, 11 Sep 2026 08:23:40 -0700 (PDT) Received: from t14s.space.revspace.nl (2001-1c00-2a07-3a01-8e96-3679-0b9c-de47.cable.dynamic.v6.ziggo.nl. [2001:1c00:2a07:3a01:8e96:3679:b9c:de47]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c296614323csm94042566b.59.2026.09.11.08.23.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 08:23:36 -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 v6 2/4] firmware: arm_scmi: Fix scmi_protocol_table_register() error handling Date: Fri, 11 Sep 2026 17:23:27 +0200 Message-ID: <20260911152329.5822-3-johannes.goede@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260911152329.5822-1-johannes.goede@oss.qualcomm.com> References: <20260911152329.5822-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-GUID: VRaRF_ITP3Ya8r_JlueCQDXTNrGLPnfL X-Authority-Analysis: v=2.4 cv=PLmaavqC c=1 sm=1 tr=0 ts=6aa41cfd cx=c_pps a=DUEm7b3gzWu7BqY5nP7+9g==:117 a=xqWC_Br6kY4A:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=mtY6ubt43vOedHXxatAA:9 a=-aSRE8QhW-JAV6biHavz:22 X-Proofpoint-ORIG-GUID: VRaRF_ITP3Ya8r_JlueCQDXTNrGLPnfL X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxNCBTYWx0ZWRfX+JnmG6d5yuKf 6Eelk0mZQ6EtfcnoNCyEwyl27KI2x1n5O6XRPWIz6PZ+8DVNpmGZTWlIr+tu+jbmdLK5dZio+B4 useJ3oXJOGyGtD9QO27uU8W6Hs4Ir6Q= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxNCBTYWx0ZWRfX7tKjiCeHfuQn oH/5Ew/3ub2LvttuKkV07hfvY/JEOoHWeAflBpuAwqb5mo7KCQMaoKnE8MvPErYKy7qT5ruKJ2o cD+PZAaRAkW1YuMlZU7UGz/uEXmMxOSAHbyCRAneP7zmEDqN3tDVqR8PFCUocPw9WjicM9h2KU+ j94WhyCdCo3Yg/2buzWhAhxZtqXKXPV7OYFIi9sipaTFvALGDqCL7ovd+PIrc0zqyKKiB2Ile2U 3ssXAuKWYnxva4Q/PgHKtCkfo//1m1rnDTSXywT6sDx8rPjz3AIEQal/THv+Uv9QAvRzYEZdFjW 6OwcSpg3SNDNWQc+OpNWwNCVlNsBAP7x9biH2Mb9ue8awheUQTK/VXZKtbEU1nX3AHF02Adnk7P 0mhEdDhdCB8goOVcZ4qLV2LWCvxM1PgR7drkScBr4t9sfOZxDrt08Czl9MKqbWH3Fh/BEw6Dm+s Z2cf+NiEVeNoq02uCXg== 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-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 spamscore=0 phishscore=0 adultscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 impostorscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110214 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. Fixes: 2858f6e5f064 ("firmware: arm_scmi: Add multiple protocols registrati= on support") Signed-off-by: Hans de Goede --- Changes in v6: - Add Fixes tag 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 Fri Sep 25 13:55:24 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 ACBDA37B41F for ; Fri, 11 Sep 2026 15:23:46 +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=1789140228; cv=none; b=pxrpXpT8qhvvmt99WVTXuTvCuzz7GrpBYJOAa73WmQWnr7NwN1aeDIRRzWvzU4OIz1QeGk9J30DCRG/0deT5aS2Pnh1yamfOcqi6ZGrFba0ohqHC4tl93TxLhrxnTlnUN68blM+UGiP1PVlF3gldo46gIRclZwtIui7H6rXMqRs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789140228; c=relaxed/simple; bh=cHC+UHnFTXah7PYvHY5YC/sMeyCMkaCll5i3gjNsico=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p3Jtu3QRp8pxd712WRbiJbWXo+J1bCxj1h/5AR5WauadNi156BzrSaBO3Z0q69XgN4PNXuJbtYazESZ3bHYQmnejyS5r2wKQCLXi0eNsHH8eelTPWqqyVGe5FHJKu9+0y6o/+2buZT1Kt2f0+y2o7913V46AiXF1ZOGgeIWtYBA= 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=Suq9KY7z; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Rq1CnhYj; 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="Suq9KY7z"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Rq1CnhYj" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEmBj7222612 for ; Fri, 11 Sep 2026 15:23:45 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=Urk/tOiIEwK LzYvti+etTD7iBNYdIx2xH64rRVioykU=; b=Suq9KY7zVg/VebW6W63FMbrTuJj 7ap8NNkC4Lsuzv9kMMfAD/4qrM2tl8jxAe/P7CfqHEXFezJMEx93GLLUd4mYXgOP MYvLaM3AVLYi3qEn6EHYbpSAoKaKHoydQu5x1EQjM+5m8+FlnmjhShHvXbOb8CeP BCMP0JBc4ms6YpO4HoYFpZst5TSnmCXVv0LiCae61u4gTCfHoJo9FzmBcIU1hx6u F2hKMEQhv/553GpVDCLEvyMYAhZ6UUsHiQlc1fGGD3vZQQTzfgbaGXGGc/TkaTcO QLyW+Io1/xtaBj6k6Vf8sm7/jRYPc4YoowZijbeEXxnHdYIyBdGud2O3D3Q== Received: from mail-vs1-f72.google.com (mail-vs1-f72.google.com [209.85.217.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gmbdradyv-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 11 Sep 2026 15:23:45 +0000 (GMT) Received: by mail-vs1-f72.google.com with SMTP id ada2fe7eead31-78580a6b2fbso307394137.3 for ; Fri, 11 Sep 2026 08:23:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1789140224; x=1789745024; 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=Urk/tOiIEwKLzYvti+etTD7iBNYdIx2xH64rRVioykU=; b=Rq1CnhYj/sqKKtosAqiCDmjPSdu+izEnC53r4WfS04tGkNvu3r1y0TLAvQg6gSCllo iJK4tUVGMThkFI66Cz7pgafxtr0u3+K6dd1JnqAWNU6GgbIYsogxeizh9dx5N3e683hH LdjttzZGgjJa7uqwWjqOEWnwYIIq8avKClkzPC5V4MuOqv2nWXebAr+dP9RxjoW7M8sE 9YtI844sTPeO5rUoom/VnYSczsJoOYgNAYoJvoappjreuCsML1ss3ubR7X+1LuIVAjw0 ltVkq/EK+5P1CUQ2HWdMfgIyJFAPU2RK7ZLNSGiqSA9936v+cOJdKGggxtpxHBQycIbm X3XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789140224; x=1789745024; 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=Urk/tOiIEwKLzYvti+etTD7iBNYdIx2xH64rRVioykU=; b=nPxj2hMA6+nkkQDcW1orehEX5t+QCAp47Z9yAT+q9FzfaeJjH/uRJdCfFJFEWvhfis sqhJE8WeHNqkkaXmq/9vaMEvjSfo2yA5XdZe31aixbNWg6YHLy34xzwCu3aGC31CqFVl 8ALoa4A4p1+nEIw58F+0iy3o6DokdsF2R9H/INOhxUDIYbKNA5icr6f1JdvDgWFb7LTb AE2O/wg2B2qj3ggKK63ueyA11YmNIzA2gGYm3nJydmY0deZS4nRVqvUk3wPh+6esGc5C vY4nA3FoxGUjD7zPhECKhFVLqKWjHoyo+8aWzAP5JykzDFkij9bc0MLHBuluRigRbhOS LVsw== X-Forwarded-Encrypted: i=1; AKwUvBzzVGlH+zwqJMAOts08aLXXiCZa01dq0hXJe76dT/A7og2s5TER/l6tKD08EFJfiI3bHH2Ol2GqcHRdZb8=@vger.kernel.org X-Gm-Message-State: AFuF++lBIvVEqQ94DB4RbqfCIRzhhosvY8YI7hpNviTpoffIOrUi83cH ftvswFRrIurlZLvKKn52qbLDpuq4KMVhSvMQ5VH/rOP9Q5LbQhG8x063Dud0x0137+RlayYcXNk fK8ZBSTJmDQ2xCiB8quC+vsXVLPP/V4O+YtWpBfMQr+B2BwXu/BAsbP0hQX3/jIpDZbc= X-Gm-Gg: AYBFou1ruyvEgPC9T92Y5X1KXkr/h2nnCvmXPvjkNfKZjkrPmxE8yIL9ZUeNzs00jb4 nmjjzxU2SSymV71bx4fs5mDLVlUWtATpJmsIEMc+STyCFTUzSqZhqgJzbfqNYG6IMIBhzPDX6pX HBrLK5wO87NfFgji2buOrElZIl/xFGDKdZw4AE+IOY6j/e4rS/nvx+PXR/YU0zy0ThqiviEoXRy A4CuuXojjkiSfoVSxWZuTbxS6gl2LtYr6uUmZtC44ro8FXGT0WKDxrSj9OuQpsKbqlKmy+0MGsM jkpeTPItxk0a1eLVRrHb3pGvjBMylQCvMgzlswQhjADgCZtNpVzxOymhuKScuJmdgVQfcaEY1G6 jIKnuUStB9H2PGTQoSNEmAx/flBXlp01/q/7fqQkEv8ffRaUWRkzqSRv9M/RUa7IEXddzb2R0/K xMLq7DH1siTo6ALAsx9VxHinXk7acfdAjnekFL X-Received: by 2002:a05:6102:a191:20b0:786:724a:4e94 with SMTP id ada2fe7eead31-792aa571236mr4941232137.11.1789140224567; Fri, 11 Sep 2026 08:23:44 -0700 (PDT) X-Received: by 2002:a05:6102:a191:20b0:786:724a:4e94 with SMTP id ada2fe7eead31-792aa571236mr4941110137.11.1789140224027; Fri, 11 Sep 2026 08:23:44 -0700 (PDT) Received: from t14s.space.revspace.nl (2001-1c00-2a07-3a01-8e96-3679-0b9c-de47.cable.dynamic.v6.ziggo.nl. [2001:1c00:2a07:3a01:8e96:3679:b9c:de47]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c296614323csm94042566b.59.2026.09.11.08.23.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 08:23:40 -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 v6 3/4] firmware: arm_scmi: Fix scmi_protocol_device_unrequest() race Date: Fri, 11 Sep 2026 17:23:28 +0200 Message-ID: <20260911152329.5822-4-johannes.goede@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260911152329.5822-1-johannes.goede@oss.qualcomm.com> References: <20260911152329.5822-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-GUID: 2qV8uD_w6nXIanFVAkUnuex1_bBNtzih X-Authority-Analysis: v=2.4 cv=PLmaavqC c=1 sm=1 tr=0 ts=6aa41d01 cx=c_pps a=DUEm7b3gzWu7BqY5nP7+9g==:117 a=xqWC_Br6kY4A:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=EzzhlMzFHTv8R9URApkA:9 a=-aSRE8QhW-JAV6biHavz:22 X-Proofpoint-ORIG-GUID: 2qV8uD_w6nXIanFVAkUnuex1_bBNtzih X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxNCBTYWx0ZWRfX4m4O2MTe6WKM 16DfTQm7Pz5J1UkU5SFGttVud0Vq9eqMudC/t2PMS1Ld765YbOdiKh9BbdG+CHhmdAI80XUNPcR Xu6EEdo8sqT8mgmAlMjdECfCXCcOR30= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDIxNCBTYWx0ZWRfX1DyuQFRjHCPs dIKSrUeOvKfpefEtzwsBond+0fWQxIqvt546Ng6ezO+Br96HztiZ+y64vn0cr6iE4+hoNgkjbB9 PTm2vxrt6UPYXOAnYf8PeXjN4zv9VpAKBhE26SC93XvG5Rv2d0enjJ/tti9H3YApj0krPYskcjN 9Q1gGf2JkhTXJL/xM6WbU68Z/OvZxnvYlSfHX6lOAcle+cBA9x9/hwJ0UCjgJOiG/TGUr6HFRw5 cAwAE+IsawIzoplLGqc3l0PXrNvqLJlhlojsARg30CJ1Z5h84/+7aqvcuIiLUZoifU7Uf1E1P1l gibxoyeuKz7NSfHjJ/7hQsc7tEFvliIBDfpe82vkdysnf6CrWEBibx+UpAecs/QrpgLDYSS3Z42 979px624SgjxMba/5HIBPLU6isHcxE5qw7/s/W9e/A7aRBUT1ipbvSNxuwo9JyYrioakhkkGVQ3 DDqHESUZwpPgvLhEM/w== 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-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 spamscore=0 phishscore=0 adultscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 impostorscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110214 Content-Type: text/plain; charset="utf-8" scmi_protocol_device_unrequest() unlocks scmi_requested_devices_mtx during the notifier call. During this window phead might have been deleted by another racing scmi_protocol_device_unrequest(). Re-acquire phead before cleaning it up to avoid this potential double free problem. Fixes: d3cd7c525fd2 ("firmware: arm_scmi: Refactor protocol device creation= ") Signed-off-by: Hans de Goede --- Changes in v6: - New patch in v6 of this series (Suggested by local Shashiko run on v5) --- drivers/firmware/arm_scmi/bus.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bu= s.c index 6f667e4ffeed..651d4ba06574 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -173,7 +173,13 @@ static void scmi_protocol_device_unrequest(const struc= t scmi_device_id *id_table } } =20 - if (list_empty(phead)) { + /* + * Since scmi_requested_devices_mtx is unlocked during + * the notifier call phead might have been deleted by another + * racing scmi_protocol_device_unrequest(), re-acquire it here. + */ + phead =3D idr_find(&scmi_requested_devices, id_table->protocol_id); + if (phead && list_empty(phead)) { idr_remove(&scmi_requested_devices, id_table->protocol_id); kfree(phead); --=20 2.55.0 From nobody Fri Sep 25 13:55:24 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 A41E7376A12 for ; Fri, 11 Sep 2026 15:23:50 +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=1789140232; cv=none; b=aAhPqlij3gXWeD4nK3s61zBofhwqXURiit5hiu8tXNpupJcXmVRLs57E2ueGFyd/ffDaDzsTJcAPa0J62yJa5cVxk65ouXfaLmYvHcse+mCUa49USxCCkNP6gTEOso3q6M4klu6B5vsfWK0g32t03JSyDMmwRsoHfRAtii7cly8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789140232; c=relaxed/simple; bh=IuAWYhrq8iC+CikdHI/e1ECe/txOrhjj6EPDSmygtY8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cXSQMCHw/OY6lgkMHC4Sg3CQTGyfa/fzFNWXov8Z0YwcW+vRci1IzVyTy4yGdp+q1C7X8Yw+HoNArlXE04J06F5MpM//LPLXn6BTDYun4RGTf0MsgN+W3e8pwwsvUnqXrNo+tQBpl2+xiCvJzqs1hJCVRt3tbp9ew9Ok9+yw4Rs= 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=LhMHT+xB; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ebtl2uT9; 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="LhMHT+xB"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ebtl2uT9" Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68BEmEf93780643 for ; Fri, 11 Sep 2026 15:23:49 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=mZj8U1PD25c E+8ESg/8vDL8EK7ciOY34ML1dGtbAf+A=; b=LhMHT+xBhFwTdV7bkSdWxz4EoAC z7U/u39CJNv7+23UyJYMvjDYMEGHhjYtseSJJci9B0nWGAImnllxhTjT0EANdoKP O0D4JBPXRbsyNibsjRLB1PDsU7yNh/QaRMmRbqfRkzOZZ1O1flN8oloWTgobel/R IZXEaxIvwmnbmwUbO2FFAb44stsRh+9EwQdAiFTWW4r1lIJOfnYoBLXOcc5Jfz6t acExdXWI4GV1osNWm9kSyXrS9jbH72IQhj7vmOCHuTfn55h8fGXsH0rp8Fyf6AfX 9kEIFFa5/DRPc4fMAv7p4LQVQQ9KeWYmcZyeujF6e8i+L2GmhgV/24R4f1Q== Received: from mail-vs1-f72.google.com (mail-vs1-f72.google.com [209.85.217.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gmcgfj5ru-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 11 Sep 2026 15:23:49 +0000 (GMT) Received: by mail-vs1-f72.google.com with SMTP id ada2fe7eead31-78d25a8ff32so248411137.2 for ; Fri, 11 Sep 2026 08:23:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1789140229; x=1789745029; 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=mZj8U1PD25cE+8ESg/8vDL8EK7ciOY34ML1dGtbAf+A=; b=ebtl2uT9i7AnRFi/Xf5/Kg9p+ykM0SpbjfpGjK1TISQhSX8wqlXj2gWxo6o/T/MYZW 6i5n6iTYrbrzChUb1UM7Q0P4aS7l8SAH38gM+CoJIx3dltxqBQNbpZKTD0vgoSwk9Pqa PXLgsAShMJ10vajMY7hyYUT7KEoLy7yIWPrf7C12c2m1/Vmd99pnrdi2VxpOwrtcWYKz 8wFGz0/IooQDUSh5tXc9G6m6jRj3W2vMkIrB+yBCVNHwGVdwtsaf3BgzxWP2PpdMuz7q mdOxnVVFHReCoZfQJXcQpYiwjEuVu2tsuwTsmWztJI2meSsa5Q3wcfrvGkMH8hEABa+S 3tiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789140229; x=1789745029; 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=mZj8U1PD25cE+8ESg/8vDL8EK7ciOY34ML1dGtbAf+A=; b=LKUpQPoLUEfKnIO0ohE5EvWs4UVJYoM+hMM2dlXRtHmgT7kQmIKQVhR53m5Q8yPdUi Sc3f6DsFzPcVQn4DB+fbPaqLFZS6AvHRW8NQrlaje1qZqxW7QzV2gsuXBuX13Zu0JukF Q6O9KEElOxTXoqWe0nwM9nUtMqwQcNaC+8sKw09WjgUYd1BAngreEaqFQbpOl46Qkc7Q 5rT3mDwYphGfVKc76gy59K0K2UE9217rFNBjXCHgQoOzISh7Ni1Nhf7iGvDYsMD+iEWw KNkOcIM5akMqWTc6l7gqDIkBPh1vKL600fvhdev4NpyyGExM6XG5bEvYWCExfsYrKWEM uzUQ== X-Forwarded-Encrypted: i=1; AKwUvBxT9Kbw8gIVqHEgcm7y01gNGcafqtj9Rw2wuiObI1qceiXp0XB/7/BD+XvteilP6nFjiByjk0ajpQZDYrA=@vger.kernel.org X-Gm-Message-State: AFuF++lLolVaw6sijpi0W8Sw1ktm9dFD4KTzZsAf9uBBbzk00Zki+k/J me+yngsujPMUIQ2GcAmoc4V2feABontbYdznz90k8bYKch1yJeGob81tPoMqRrApBvPl3be4onz QIqDmVIKvyuPUHeSsT1FxRBmKEV7LeNoEIIblm+ODFPN7SpOJiXndZPJBmRiZ/d7Iows= X-Gm-Gg: AYBFou1b+i+dR0v+M1rsLX6p4dMMORFBJM/hDLAuYNv3J2YLi83NOvOS7PKEXz09qQU GfceYhqdED4k5JeAsUY3j2j0aRq4lpgK3UCygk4lLFdTjO2w9g5J9wJ30ECAG807NV0adzo+pp1 BHPYc0s5LyESY8sNe8o5I4KVh5YvkPjPiciGHmGV+BXUZ0X9cf03SoEJF5Aq2qzdUKbBV3R9m5/ GRpl/tEdnm+I83a5+RNvoMOQwNuuupOiH/oFwIcUzb/V7NqJ7h/ULozgfosiIrZeN2Mr5olSBc2 DSHIe/JNEC9ntAIVXnIlGQJx36W1B0DvBwxpNRfLQ+fKSYpcx1O8aPZQ7FEYsh3FoM6asUVv8yM nKxbFimDQ1FGn3eOjabH7jqZ/N8+k+KtmTL0+xW4rBVcnuYHE84wUtFBKip6kNnntv5A9fvT6RV yf9P2iVg4FPLeixI7JTzqEjnsQo1BO074VoKKC X-Received: by 2002:a05:6102:c8d:b0:793:980a:d1ff with SMTP id ada2fe7eead31-7939829b4d3mr3029889137.3.1789140228750; Fri, 11 Sep 2026 08:23:48 -0700 (PDT) X-Received: by 2002:a05:6102:c8d:b0:793:980a:d1ff with SMTP id ada2fe7eead31-7939829b4d3mr3029791137.3.1789140228322; Fri, 11 Sep 2026 08:23:48 -0700 (PDT) Received: from t14s.space.revspace.nl (2001-1c00-2a07-3a01-8e96-3679-0b9c-de47.cable.dynamic.v6.ziggo.nl. [2001:1c00:2a07:3a01:8e96:3679:b9c:de47]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c296614323csm94042566b.59.2026.09.11.08.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Sep 2026 08:23:44 -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 v6 4/4] firmware: arm_scmi: Always create devices for standard protocols Date: Fri, 11 Sep 2026 17:23:29 +0200 Message-ID: <20260911152329.5822-5-johannes.goede@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260911152329.5822-1-johannes.goede@oss.qualcomm.com> References: <20260911152329.5822-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: AW1haW4tMjYwOTExMDIxNCBTYWx0ZWRfX5UpbM1r6tH7g vIx/bRIklAfH4GsgMFjgxFTTqKs8B551dXeTluSUmTzv3odiMbC9Ld9Azm+Hxxhr35pGYw5p3pG m0KEg8VBA+Egd/kmsk1NPXds2l9YfixOSj/PKjHRWxcCDvIO1pU6uTHOGphel08RLF5q/MgOeQx L0rAwH1wJINP/+OOIU+OZtTserTPi9LJkm/gd9lSlpxD5bRGx1NnmAeMwhEmNSDVtf1Ji0xRdMu nDxr8lUIqvw5WTNmO07dsStkGrgmJ98Rhuqc0ZRBSp9fi7gFh9vz4LH/SxJomqG1oMBu46NZDJB Y03A+mevoUzj6CsiDWyIUbkeCFllK7DSQpLUTzjx1pSrGY55fiLrNYIp7leZCe+uvhyVkfGG/Y7 uYlzx97GAytVHLJm6M9/fDl97o3tr/kj6tp9ckHyt5CNAJmS8oE65izel2mn8HKemtziH7r7omB ypg2wfxco/tgWNm5ptQ== X-Proofpoint-GUID: D1RfpRnD4brnzijYIaoKpQJZx-t6YxFs X-Proofpoint-ORIG-GUID: D1RfpRnD4brnzijYIaoKpQJZx-t6YxFs X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDIxNCBTYWx0ZWRfX5U/Kdzpxwzv0 nNCllpmA9dtE/nY/lhbsEKwBTtIRCenpPCRNWYj1fODOEmdtFN+QVXwtvramoVpNg1h+kid9ACN X7Yh9S9bCnf0634ffUCMwINbG50z6G8= X-Authority-Analysis: v=2.4 cv=ULtIjyfy c=1 sm=1 tr=0 ts=6aa41d05 cx=c_pps a=DUEm7b3gzWu7BqY5nP7+9g==:117 a=xqWC_Br6kY4A:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=l971TreVHldC-rsvbM8A:9 a=-aSRE8QhW-JAV6biHavz:22 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-11_05,2026-09-11_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 phishscore=0 bulkscore=0 clxscore=1015 malwarescore=0 suspectscore=0 spamscore=0 lowpriorityscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110214 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 v6: - Replace the if (!phead) return NULL; early exit with return scmi_dev; Since a standard protocol device may have been created at this point. 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 | 50 +++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bu= s.c index 651d4ba06574..ea59dcd95b6a 100644 --- a/drivers/firmware/arm_scmi/bus.c +++ b/drivers/firmware/arm_scmi/bus.c @@ -511,6 +511,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 * @@ -540,22 +568,38 @@ 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. */ if (!phead) { mutex_unlock(&scmi_requested_devices_mtx); - return NULL; + return scmi_dev; } =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