firmware: arm_ffa: Unregister the FF-A devices when cleaning up the partitions

Both the FF-A core and the bus were in a single module before the
commit 18c250bd7e ("firmware: arm_ffa: Split bus and driver into distinct modules").

The arm_ffa_bus_exit() takes care of unregistering all the FF-A devices.
Now that there are 2 distinct modules, if the core driver is unloaded and
reloaded, it will end up adding duplicate FF-A devices as the previously
registered devices weren't unregistered when we cleaned up the modules.

Fix the same by unregistering all the FF-A devices on the FF-A bus during
the cleaning up of the partitions and hence the cleanup of the module.

Fixes: 18c250bd7e ("firmware: arm_ffa: Split bus and driver into distinct modules")
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Message-Id: <20250217-ffa_updates-v3-8-bd1d9de615e7@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
This commit is contained in:
Sudeep Holla
2025-02-17 15:38:49 +00:00
parent 2f622a8b07
commit 46dcd68aac
3 changed files with 9 additions and 4 deletions

View File

@@ -1494,10 +1494,8 @@ static int ffa_setup_partitions(void)
/* Allocate for the host */
ret = ffa_xa_add_partition_info(drv_info->vm_id);
if (ret) {
/* Already registered devices are freed on bus_exit */
if (ret)
ffa_partitions_cleanup();
}
return ret;
}
@@ -1507,6 +1505,9 @@ static void ffa_partitions_cleanup(void)
struct ffa_dev_part_info *info;
unsigned long idx;
/* Clean up/free all registered devices */
ffa_devices_unregister();
xa_for_each(&drv_info->partition_info, idx, info) {
xa_erase(&drv_info->partition_info, idx);
kfree(info);