mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-30 22:50:54 -04:00
Merge tag 'ffa-updates-6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into soc/drivers
Arm FF-A driver updates for v6.11 The main addition is the split of bus and driver into distinct modules The FF-A bus module is initialized at subsys_initcall level when builtin. FF-A drivers initialization is now changed to module_init level so that pKVM ffa proxy is all setup and running in case pKVM hypervisor needs to trap and handle FF-A calls. One of the reason for not having this split from the beginning is the need to workaround the FF-A v1.0 NULL UUID. The FF-A bus layer called into FF-A driver and populated the device UUID if it matches with the driver attempting to match. Moving the workaround away from the FF-A bus layer to the FF-A core driver as a bus notifier will help to remove the dependency. * tag 'ffa-updates-6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux: firmware: arm_ffa: Split bus and driver into distinct modules firmware: arm_ffa: Move the FF-A v1.0 NULL UUID workaround to bus notifier Link: https://lore.kernel.org/r/20240624103451.2870146-1-sudeep.holla@arm.com Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
@@ -2,5 +2,7 @@
|
||||
ffa-bus-y = bus.o
|
||||
ffa-driver-y = driver.o
|
||||
ffa-transport-$(CONFIG_ARM_FFA_SMCCC) += smccc.o
|
||||
ffa-module-objs := $(ffa-bus-y) $(ffa-driver-y) $(ffa-transport-y)
|
||||
obj-$(CONFIG_ARM_FFA_TRANSPORT) = ffa-module.o
|
||||
ffa-core-objs := $(ffa-bus-y)
|
||||
ffa-module-objs := $(ffa-driver-y) $(ffa-transport-y)
|
||||
obj-$(CONFIG_ARM_FFA_TRANSPORT) = ffa-core.o
|
||||
obj-$(CONFIG_ARM_FFA_TRANSPORT) += ffa-module.o
|
||||
|
||||
@@ -30,12 +30,11 @@ static int ffa_device_match(struct device *dev, struct device_driver *drv)
|
||||
while (!uuid_is_null(&id_table->uuid)) {
|
||||
/*
|
||||
* FF-A v1.0 doesn't provide discovery of UUIDs, just the
|
||||
* partition IDs, so fetch the partitions IDs for this
|
||||
* id_table UUID and assign the UUID to the device if the
|
||||
* partition ID matches
|
||||
* partition IDs, so match it unconditionally here and handle
|
||||
* it via the installed bus notifier during driver binding.
|
||||
*/
|
||||
if (uuid_is_null(&ffa_dev->uuid))
|
||||
ffa_device_match_uuid(ffa_dev, &id_table->uuid);
|
||||
return 1;
|
||||
|
||||
if (uuid_equal(&ffa_dev->uuid, &id_table->uuid))
|
||||
return 1;
|
||||
@@ -50,6 +49,10 @@ static int ffa_device_probe(struct device *dev)
|
||||
struct ffa_driver *ffa_drv = to_ffa_driver(dev->driver);
|
||||
struct ffa_device *ffa_dev = to_ffa_dev(dev);
|
||||
|
||||
/* UUID can be still NULL with FF-A v1.0, so just skip probing them */
|
||||
if (uuid_is_null(&ffa_dev->uuid))
|
||||
return -ENODEV;
|
||||
|
||||
return ffa_drv->probe(ffa_dev);
|
||||
}
|
||||
|
||||
@@ -232,14 +235,21 @@ void ffa_device_unregister(struct ffa_device *ffa_dev)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(ffa_device_unregister);
|
||||
|
||||
int arm_ffa_bus_init(void)
|
||||
static int __init arm_ffa_bus_init(void)
|
||||
{
|
||||
return bus_register(&ffa_bus_type);
|
||||
}
|
||||
subsys_initcall(arm_ffa_bus_init);
|
||||
|
||||
void arm_ffa_bus_exit(void)
|
||||
static void __exit arm_ffa_bus_exit(void)
|
||||
{
|
||||
ffa_devices_unregister();
|
||||
bus_unregister(&ffa_bus_type);
|
||||
ida_destroy(&ffa_bus_id);
|
||||
}
|
||||
module_exit(arm_ffa_bus_exit);
|
||||
|
||||
MODULE_ALIAS("ffa-core");
|
||||
MODULE_AUTHOR("Sudeep Holla <sudeep.holla@arm.com>");
|
||||
MODULE_DESCRIPTION("ARM FF-A bus");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
@@ -14,8 +14,6 @@ typedef struct arm_smccc_1_2_regs ffa_value_t;
|
||||
|
||||
typedef void (ffa_fn)(ffa_value_t, ffa_value_t *);
|
||||
|
||||
int arm_ffa_bus_init(void);
|
||||
void arm_ffa_bus_exit(void);
|
||||
bool ffa_device_is_valid(struct ffa_device *ffa_dev);
|
||||
void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid);
|
||||
|
||||
|
||||
@@ -1224,14 +1224,6 @@ void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
|
||||
int count, idx;
|
||||
struct ffa_partition_info *pbuf, *tpbuf;
|
||||
|
||||
/*
|
||||
* FF-A v1.1 provides UUID for each partition as part of the discovery
|
||||
* API, the discovered UUID must be populated in the device's UUID and
|
||||
* there is no need to copy the same from the driver table.
|
||||
*/
|
||||
if (drv_info->version > FFA_VERSION_1_0)
|
||||
return;
|
||||
|
||||
count = ffa_partition_probe(uuid, &pbuf);
|
||||
if (count <= 0)
|
||||
return;
|
||||
@@ -1242,6 +1234,35 @@ void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
|
||||
kfree(pbuf);
|
||||
}
|
||||
|
||||
static int
|
||||
ffa_bus_notifier(struct notifier_block *nb, unsigned long action, void *data)
|
||||
{
|
||||
struct device *dev = data;
|
||||
struct ffa_device *fdev = to_ffa_dev(dev);
|
||||
|
||||
if (action == BUS_NOTIFY_BIND_DRIVER) {
|
||||
struct ffa_driver *ffa_drv = to_ffa_driver(dev->driver);
|
||||
const struct ffa_device_id *id_table= ffa_drv->id_table;
|
||||
|
||||
/*
|
||||
* FF-A v1.1 provides UUID for each partition as part of the
|
||||
* discovery API, the discovered UUID must be populated in the
|
||||
* device's UUID and there is no need to workaround by copying
|
||||
* the same from the driver table.
|
||||
*/
|
||||
if (uuid_is_null(&fdev->uuid))
|
||||
ffa_device_match_uuid(fdev, &id_table->uuid);
|
||||
|
||||
return NOTIFY_OK;
|
||||
}
|
||||
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static struct notifier_block ffa_bus_nb = {
|
||||
.notifier_call = ffa_bus_notifier,
|
||||
};
|
||||
|
||||
static int ffa_setup_partitions(void)
|
||||
{
|
||||
int count, idx, ret;
|
||||
@@ -1250,6 +1271,12 @@ static int ffa_setup_partitions(void)
|
||||
struct ffa_dev_part_info *info;
|
||||
struct ffa_partition_info *pbuf, *tpbuf;
|
||||
|
||||
if (drv_info->version == FFA_VERSION_1_0) {
|
||||
ret = bus_register_notifier(&ffa_bus_type, &ffa_bus_nb);
|
||||
if (ret)
|
||||
pr_err("Failed to register FF-A bus notifiers\n");
|
||||
}
|
||||
|
||||
count = ffa_partition_probe(&uuid_null, &pbuf);
|
||||
if (count <= 0) {
|
||||
pr_info("%s: No partitions found, error %d\n", __func__, count);
|
||||
@@ -1261,7 +1288,7 @@ static int ffa_setup_partitions(void)
|
||||
import_uuid(&uuid, (u8 *)tpbuf->uuid);
|
||||
|
||||
/* Note that if the UUID will be uuid_null, that will require
|
||||
* ffa_device_match() to find the UUID of this partition id
|
||||
* ffa_bus_notifier() to find the UUID of this partition id
|
||||
* with help of ffa_device_match_uuid(). FF-A v1.1 and above
|
||||
* provides UUID here for each partition as part of the
|
||||
* discovery API and the same is passed.
|
||||
@@ -1581,14 +1608,9 @@ static int __init ffa_init(void)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = arm_ffa_bus_init();
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
drv_info = kzalloc(sizeof(*drv_info), GFP_KERNEL);
|
||||
if (!drv_info) {
|
||||
ret = -ENOMEM;
|
||||
goto ffa_bus_exit;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ret = ffa_version_check(&drv_info->version);
|
||||
@@ -1649,11 +1671,9 @@ static int __init ffa_init(void)
|
||||
free_pages_exact(drv_info->rx_buffer, RXTX_BUFFER_SIZE);
|
||||
free_drv_info:
|
||||
kfree(drv_info);
|
||||
ffa_bus_exit:
|
||||
arm_ffa_bus_exit();
|
||||
return ret;
|
||||
}
|
||||
subsys_initcall(ffa_init);
|
||||
module_init(ffa_init);
|
||||
|
||||
static void __exit ffa_exit(void)
|
||||
{
|
||||
@@ -1663,7 +1683,6 @@ static void __exit ffa_exit(void)
|
||||
free_pages_exact(drv_info->tx_buffer, RXTX_BUFFER_SIZE);
|
||||
free_pages_exact(drv_info->rx_buffer, RXTX_BUFFER_SIZE);
|
||||
kfree(drv_info);
|
||||
arm_ffa_bus_exit();
|
||||
}
|
||||
module_exit(ffa_exit);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user