From: Cristian Marussi <cristian.marussi@arm.com>
To: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, arm-scmi@vger.kernel.org
Cc: sudeep.holla@kernel.org, philip.radford@arm.com,
james.quinlan@broadcom.com, f.fainelli@gmail.com,
vincent.guittot@linaro.org, etienne.carriere@foss.st.com,
peng.fan@oss.nxp.com, michal.simek@amd.com,
gatien.chevallier@foss.st.com, u.kleine-koenig@baylibre.com,
dakr@kernel.org, Cristian Marussi <cristian.marussi@arm.com>
Subject: [PATCH v2 1/4] firmware: arm_scmi: Add transport instance handles
Date: Sun, 10 May 2026 17:05:24 +0100 [thread overview]
Message-ID: <20260510160527.3537474-2-cristian.marussi@arm.com> (raw)
In-Reply-To: <20260510160527.3537474-1-cristian.marussi@arm.com>
SCMI transport drivers are initialized first and then the control is passed
to the SCMI core stack: some of these transports are dependent also on some
external subsytem which will have to be initialized upfront, before the
transport driver itself can be deemed operational.
Transport drivers like virtio or optee need a way to defer the core SCMI
probing till they are fully initialized and operational and also a way to
pass back the device reference to be used as a supplier while building the
devlink relations.
SCMI transport drivers can be probed multiple times when used in a multiple
instance configuration but the capability to carry-on with multiple probes
depends on the support provided by the underlying transport driver.
This change will also allow for the removal of the frowned-upon trick of
registering a platform driver only after the end of the transport drivers
porbe to avoid explicit probe deferrals.
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
v1 -> v2
- saving *th handle into scmi_transport to simplify freeing path
- add a return value to supplier_put
---
drivers/firmware/arm_scmi/common.h | 52 +++++++++++++++++++++++++++---
1 file changed, 48 insertions(+), 4 deletions(-)
diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
index 7c9617d080a0..af6f9f498e14 100644
--- a/drivers/firmware/arm_scmi/common.h
+++ b/drivers/firmware/arm_scmi/common.h
@@ -17,6 +17,7 @@
#include <linux/hashtable.h>
#include <linux/list.h>
#include <linux/module.h>
+#include <linux/property.h>
#include <linux/refcount.h>
#include <linux/scmi_protocol.h>
#include <linux/spinlock.h>
@@ -462,6 +463,28 @@ struct scmi_transport_core_operations {
const struct scmi_message_operations *msg;
};
+/**
+ * struct scmi_transport_handle - Transport instance handle
+ * @supplier_get: A helper to retrieve the device descriptor, identifying the
+ * transport driver serving this SCMI instance, which will be
+ * used as a supplier for the core SCMI driver: returning an
+ * error here causes the probe sequence to be interrupted and
+ * return that same error code, so that each transport can decide
+ * which policy to implement by choosing an appropriate error.
+ * @supplier_put: A helper to signal that the specified transport supplier is
+ * no more being used and it is made available again.
+ *
+ * Note that these helpers are needed and provided only by those transports
+ * whose initialization relies on some other subsystem and whose relations to
+ * the core SCMI driver is not tracked by firmware descriptions.
+ */
+struct scmi_transport_handle {
+ struct device __must_check *(*supplier_get)
+ (const struct scmi_transport_handle *th);
+ int (*supplier_put)(const struct scmi_transport_handle *th,
+ struct device *dev);
+};
+
/**
* struct scmi_transport - A structure representing a configured transport
*
@@ -470,35 +493,52 @@ struct scmi_transport_core_operations {
* @desc: Transport descriptor
* @core_ops: A pointer to a pointer used by the core SCMI stack to make the
* core transport operations accessible to the transports.
+ * @th: An optional pointer to the transport handle
*/
struct scmi_transport {
struct device *supplier;
struct scmi_desc desc;
struct scmi_transport_core_operations **core_ops;
+ const struct scmi_transport_handle *th;
};
#define DEFINE_SCMI_TRANSPORT_DRIVER(__tag, __drv, __desc, __match, __core_ops)\
static void __tag##_dev_free(void *data) \
{ \
struct platform_device *spdev = data; \
+ struct scmi_transport *strans; \
+ \
+ strans = dev_get_platdata(&spdev->dev); \
+ if (strans && strans->th) \
+ strans->th->supplier_put(strans->th, strans->supplier); \
\
platform_device_unregister(spdev); \
} \
\
static int __tag##_probe(struct platform_device *pdev) \
{ \
- struct device *dev = &pdev->dev; \
+ struct device *dev = &pdev->dev, *supplier; \
struct platform_device *spdev; \
struct scmi_transport strans; \
int ret; \
\
+ supplier = dev; \
+ strans.th = device_get_match_data(dev); \
+ if (strans.th) { \
+ supplier = strans.th->supplier_get(strans.th); \
+ if (IS_ERR(supplier)) \
+ return PTR_ERR(supplier); \
+ } \
+ \
spdev = platform_device_alloc("arm-scmi", PLATFORM_DEVID_AUTO); \
- if (!spdev) \
- return -ENOMEM; \
+ if (!spdev) { \
+ ret = -ENOMEM; \
+ goto err_mem; \
+ } \
\
device_set_of_node_from_dev(&spdev->dev, dev); \
\
- strans.supplier = dev; \
+ strans.supplier = supplier; \
memcpy(&strans.desc, &(__desc), sizeof(strans.desc)); \
strans.core_ops = &(__core_ops); \
\
@@ -515,6 +555,10 @@ static int __tag##_probe(struct platform_device *pdev) \
\
err: \
platform_device_put(spdev); \
+err_mem: \
+ if (strans.th) \
+ strans.th->supplier_put(strans.th, supplier); \
+ \
return ret; \
} \
\
--
2.53.0
next prev parent reply other threads:[~2026-05-10 16:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-10 16:05 [PATCH v2 0/4] Rework SCMI transport drivers probing sequence Cristian Marussi
2026-05-10 16:05 ` Cristian Marussi [this message]
2026-05-10 16:05 ` [PATCH v2 2/4] firmware: arm_scmi: Add a generic transport supplier Cristian Marussi
2026-05-10 16:05 ` [PATCH v2 3/4] firmware: arm_scmi: virtio: Rework transport probe sequence Cristian Marussi
2026-05-10 16:05 ` [PATCH v2 4/4] firmware: arm_scmi: optee: " Cristian Marussi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260510160527.3537474-2-cristian.marussi@arm.com \
--to=cristian.marussi@arm.com \
--cc=arm-scmi@vger.kernel.org \
--cc=dakr@kernel.org \
--cc=etienne.carriere@foss.st.com \
--cc=f.fainelli@gmail.com \
--cc=gatien.chevallier@foss.st.com \
--cc=james.quinlan@broadcom.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=peng.fan@oss.nxp.com \
--cc=philip.radford@arm.com \
--cc=sudeep.holla@kernel.org \
--cc=u.kleine-koenig@baylibre.com \
--cc=vincent.guittot@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox