Message ID | 20231005175640.379631-1-sudeep.holla@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | firmware: arm_ffa: Emit modalias for FF-A devices | expand |
Hi Sudeep, > In order to enable libkmod lookups for FF-A device objects to their > corresponding module, add 'modalias' to the base attribute of FF-A > devices. > > Cc: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> > Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> > --- Tested-by: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> More details: We used this patch to autoload Arm FF-A TEE kernel module [1]. Please have a look at the tests logs [2]. The logs show: - The aliases exported in sysfs by the FF-A bus for each FF-A device - modinfo output for arm-ffa-tee.ko which uses an alias pattern matching the alias exported by the bus driver - mdev (the device manager) command autorun at boot time, searches for the modalias entries in sysfs and passes them to modprobe - modprobe matches between the sysfs alias and the kernel module - lsmod shows that the module was loaded automatically at boot time Cheers, Abdellatif [1]: arm-ffa-tee.ko: https://gitlab.arm.com/linux-arm/linux-trusted-services [2]: logs for the tests made root@corstone1000-fvp:~# uname -r 6.4.14-yocto-standard root@corstone1000-fvp:~# root@corstone1000-fvp:~# cat /sys/devices/arm-ffa-1/modalias arm_ffa:8001:486178e0-e7f8-11e3-bc5e-0002a5d5c51broot@corstone1000-fvp:~# root@corstone1000-fvp:~# cat /sys/devices/arm-ffa-2/modalias arm_ffa:8002:46bb39d1-b4d9-45b5-88ff-040027dab249root@corstone1000-fvp:~# root@corstone1000-fvp:~# cat /sys/devices/arm-ffa-3/modalias arm_ffa:8003:00000000-0000-0000-0000-000000000000root@corstone1000-fvp:~# root@corstone1000-fvp:~# root@corstone1000-fvp:~# modinfo /lib/modules/6.4.14-yocto-standard/updates/arm-ffa-tee.ko filename: /lib/modules/6.4.14-yocto-standard/updates/arm-ffa-tee.ko version: 1.1.2 license: GPL v2 description: Arm FF-A TEE driver author: Balint Dobszay <balint.dobszay@arm.com> alias: arm_ffa:*:* srcversion: 693E15C4E73D08A57E02B1E depends: name: arm_ffa_tee vermagic: 6.4.14-yocto-standard SMP preempt aarch64 root@corstone1000-fvp:~# root@corstone1000-fvp:~# root@corstone1000-fvp:~# grep modalias /etc/init.d/mdev -A 4 find /sys/ -name modalias -print0 | \ xargs -0 sort -u | \ tr '\n' '\0' | \ xargs -0 modprobe -abq } root@corstone1000-fvp:~# root@corstone1000-fvp:~# lsmod Module Size Used by arm_ffa_tee 12288 -2 root@corstone1000-fvp:~#
On Thu, 05 Oct 2023 18:56:40 +0100, Sudeep Holla wrote: > In order to enable libkmod lookups for FF-A device objects to their > corresponding module, add 'modalias' to the base attribute of FF-A > devices. > Applied to sudeep.holla/linux (for-next/ffa/updates), thanks! [1/1] firmware: arm_ffa: Emit modalias for FF-A devices https://git.kernel.org/sudeep.holla/c/22779149e93d -- Regards, Sudeep
diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c index 7865438b3696..1c7940ba5539 100644 --- a/drivers/firmware/arm_ffa/bus.c +++ b/drivers/firmware/arm_ffa/bus.c @@ -15,6 +15,8 @@ #include "common.h" +#define SCMI_UEVENT_MODALIAS_FMT "arm_ffa:%04x:%pUb" + static DEFINE_IDA(ffa_bus_id); static int ffa_device_match(struct device *dev, struct device_driver *drv) @@ -63,10 +65,20 @@ static int ffa_device_uevent(const struct device *dev, struct kobj_uevent_env *e { const struct ffa_device *ffa_dev = to_ffa_dev(dev); - return add_uevent_var(env, "MODALIAS=arm_ffa:%04x:%pUb", + return add_uevent_var(env, "MODALIAS=" SCMI_UEVENT_MODALIAS_FMT, ffa_dev->vm_id, &ffa_dev->uuid); } +static ssize_t modalias_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct ffa_device *ffa_dev = to_ffa_dev(dev); + + return sysfs_emit(buf, SCMI_UEVENT_MODALIAS_FMT, ffa_dev->vm_id, + &ffa_dev->uuid); +} +static DEVICE_ATTR_RO(modalias); + static ssize_t partition_id_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -88,6 +100,7 @@ static DEVICE_ATTR_RO(uuid); static struct attribute *ffa_device_attributes_attrs[] = { &dev_attr_partition_id.attr, &dev_attr_uuid.attr, + &dev_attr_modalias.attr, NULL, }; ATTRIBUTE_GROUPS(ffa_device_attributes);
In order to enable libkmod lookups for FF-A device objects to their corresponding module, add 'modalias' to the base attribute of FF-A devices. Cc: Abdellatif El Khlifi <abdellatif.elkhlifi@arm.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> --- drivers/firmware/arm_ffa/bus.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)