From: Yeoreum Yun <yeoreum.yun@arm.com>
To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Suzuki Poulose <suzuki.poulose@arm.com>,
Steven Price <steven.price@arm.com>,
Sami Mujawar <sami.mujawar@arm.com>,
"Aneesh Kumar K.V" <aneesh.kumar@kernel.org>,
Jiri Pirko <jiri@resnulli.us>,
GONG Ruiqi <gongruiqi1@huawei.com>,
Jason Gunthorpe <jgg@ziepe.ca>, Mark Brown <broonie@kernel.org>,
Yeoreum Yun <yeoreum.yun@arm.com>
Subject: [PATCH RFC v2 1/6] firmware: arm-smccc: introduce match function
Date: Fri, 27 Nov 2026 15:28:31 +0000 [thread overview]
Message-ID: <20261127-firme_interface-v2-1-ab88b2d0b4e0@arm.com> (raw)
In-Reply-To: <20261127-firme_interface-v2-0-ab88b2d0b4e0@arm.com>
Somce of protocol based on the smc is not enough to match smccc-device
and smccc-driver with func_id only.
For example, firme interface will create smccc-device per service
and this requires to chech whether firme smccc-device is for each
service.
To resolve this, add match function and match parameter for device
which is set at the time of smccc-device creation so that smccc-driver
could match proper smccc-device with match parameter and driver specific
match function.
This match parameter is defined under smc func-id. IOW, devices which
share the func-id should have the same type for module parameter so
that each driver under the same func-id can check extra one with
match parameter type.
Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
---
drivers/firmware/smccc/bus.c | 24 ++++++++++++++++--------
drivers/firmware/smccc/smccc.c | 3 ++-
include/linux/arm-smccc-bus.h | 5 ++++-
3 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/drivers/firmware/smccc/bus.c b/drivers/firmware/smccc/bus.c
index 0357a7c48af0b..4a1182153bef8 100644
--- a/drivers/firmware/smccc/bus.c
+++ b/drivers/firmware/smccc/bus.c
@@ -11,15 +11,20 @@ static int arm_smccc_bus_match(struct device *dev,
{
const struct arm_smccc_device_id *id_table;
const struct arm_smccc_device *smccc_dev = to_arm_smccc_device(dev);
+ const struct arm_smccc_driver *smccc_drv = to_arm_smccc_driver(drv);
- id_table = to_arm_smccc_driver(drv)->id_table;
+ id_table = smccc_drv->id_table;
if (!id_table)
return 0;
- while (id_table->func_id) {
- if (smccc_dev->func_id == id_table->func_id)
- return 1;
- id_table++;
+ for (; id_table->func_id; id_table++) {
+ if (smccc_dev->func_id != id_table->func_id)
+ continue;
+ if (!!smccc_dev->match_params != !!smccc_drv->match)
+ continue;
+ if (smccc_drv->match && !smccc_drv->match(smccc_dev))
+ continue;
+ return 1;
}
return 0;
@@ -103,7 +108,7 @@ static void arm_smccc_release_device(struct device *dev)
kfree(smccc_dev);
}
-static struct device *arm_smccc_device_alloc(u32 func_id)
+static struct device *arm_smccc_device_alloc(u32 func_id, void *match_params)
{
struct arm_smccc_device *smccc_dev;
@@ -112,6 +117,7 @@ static struct device *arm_smccc_device_alloc(u32 func_id)
return NULL;
smccc_dev->func_id = func_id;
+ smccc_dev->match_params = match_params;
smccc_dev->dev.bus = &arm_smccc_bus_type;
smccc_dev->dev.release = arm_smccc_release_device;
device_initialize(&smccc_dev->dev);
@@ -119,14 +125,16 @@ static struct device *arm_smccc_device_alloc(u32 func_id)
return &smccc_dev->dev;
}
-struct arm_smccc_device *arm_smccc_device_register(const char *name, u32 func_id)
+struct arm_smccc_device *arm_smccc_device_register(const char *name, u32 func_id,
+ void *match_params)
{
int ret;
if (!name)
return ERR_PTR(-EINVAL);
- struct device *dev __free(put_device) = arm_smccc_device_alloc(func_id);
+ struct device *dev __free(put_device) = arm_smccc_device_alloc(func_id,
+ match_params);
if (!dev)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/firmware/smccc/smccc.c b/drivers/firmware/smccc/smccc.c
index 5dc768ac4143a..93658120114d3 100644
--- a/drivers/firmware/smccc/smccc.c
+++ b/drivers/firmware/smccc/smccc.c
@@ -136,7 +136,8 @@ static int __init smccc_devices_init(void)
if (!smccc_probe_smccc_device(smccc_dev))
continue;
- sdev = arm_smccc_device_register(smccc_dev->device_name, smccc_dev->func_id);
+ sdev = arm_smccc_device_register(smccc_dev->device_name,
+ smccc_dev->func_id, NULL);
if (IS_ERR(sdev))
pr_err("%s: could not register device: %pe\n",
smccc_dev->device_name, sdev);
diff --git a/include/linux/arm-smccc-bus.h b/include/linux/arm-smccc-bus.h
index 05c0c850510e0..b7b44c9b67ec3 100644
--- a/include/linux/arm-smccc-bus.h
+++ b/include/linux/arm-smccc-bus.h
@@ -12,6 +12,7 @@
struct arm_smccc_device {
struct device dev;
u32 func_id;
+ void *match_params;
};
#define to_arm_smccc_device(d) container_of_const(d, struct arm_smccc_device, dev)
@@ -22,6 +23,7 @@ struct arm_smccc_driver {
const char *name;
int (*probe)(struct arm_smccc_device *sdev);
void (*remove)(struct arm_smccc_device *sdev);
+ bool (*match)(const struct arm_smccc_device *sdev);
const struct arm_smccc_device_id *id_table;
};
@@ -31,7 +33,8 @@ struct arm_smccc_driver {
int arm_smccc_driver_register(struct arm_smccc_driver *driver,
struct module *owner, const char *mod_name);
void arm_smccc_driver_unregister(struct arm_smccc_driver *driver);
-struct arm_smccc_device *arm_smccc_device_register(const char *name, u32 func_id);
+struct arm_smccc_device *arm_smccc_device_register(const char *name, u32 func_id,
+ void *match_param);
void arm_smccc_device_unregister(struct arm_smccc_device *smcc_dev);
#define arm_smccc_register(driver) \
--
2.43.0
next prev parent reply other threads:[~2026-11-27 15:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 15:28 [PATCH RFC v2 0/6] firmware: arm_firme: introduce FIRME support for host attestation Yeoreum Yun
2026-11-27 15:28 ` Yeoreum Yun [this message]
2026-11-27 15:28 ` [PATCH RFC v2 2/6] firmware: arm_firme: introduce arm_firme Yeoreum Yun
2026-11-27 15:28 ` [PATCH RFC v2 3/6] Documentation/ctlv: introduce ctlv-attestation-firme family Yeoreum Yun
2026-11-27 15:28 ` [PATCH RFC v2 5/6] attestation: providers: introduce FIRME attestation provider Yeoreum Yun
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=20261127-firme_interface-v2-1-ab88b2d0b4e0@arm.com \
--to=yeoreum.yun@arm.com \
--cc=aneesh.kumar@kernel.org \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=gongruiqi1@huawei.com \
--cc=jgg@ziepe.ca \
--cc=jiri@resnulli.us \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=sami.mujawar@arm.com \
--cc=steven.price@arm.com \
--cc=suzuki.poulose@arm.com \
/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