Message ID | 20250131-ffa_updates-v2-6-544ba4e35387@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | firmware: arm_ffa: Framework notification support + other updates and fixes | expand |
On 31-01-25, 11:24, Sudeep Holla wrote: > @@ -1461,39 +1480,18 @@ static int ffa_setup_partitions(void) > !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)) > ffa_mode_32bit_set(ffa_dev); > > - info = kzalloc(sizeof(*info), GFP_KERNEL); > - if (!info) { > + if (ffa_xa_add_partition_info(ffa_dev->vm_id)) { > ffa_device_unregister(ffa_dev); > continue; > } > - rwlock_init(&info->rw_lock); > - ret = xa_insert(&drv_info->partition_info, tpbuf->id, > - info, GFP_KERNEL); > - if (ret) { > - pr_err("%s: failed to save partition ID 0x%x - ret:%d\n", > - __func__, tpbuf->id, ret); > - ffa_device_unregister(ffa_dev); > - kfree(info); > - } > + Why extra blank line here ? > }
On Fri, Feb 14, 2025 at 10:20:30AM +0530, Viresh Kumar wrote: > On 31-01-25, 11:24, Sudeep Holla wrote: > > @@ -1461,39 +1480,18 @@ static int ffa_setup_partitions(void) > > !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)) > > ffa_mode_32bit_set(ffa_dev); > > > > - info = kzalloc(sizeof(*info), GFP_KERNEL); > > - if (!info) { > > + if (ffa_xa_add_partition_info(ffa_dev->vm_id)) { > > ffa_device_unregister(ffa_dev); > > continue; > > } > > - rwlock_init(&info->rw_lock); > > - ret = xa_insert(&drv_info->partition_info, tpbuf->id, > > - info, GFP_KERNEL); > > - if (ret) { > > - pr_err("%s: failed to save partition ID 0x%x - ret:%d\n", > > - __func__, tpbuf->id, ret); > > - ffa_device_unregister(ffa_dev); > > - kfree(info); > > - } > > + > > Why extra blank line here ? > Spurious for sure, no idea how I managed that though. Dropped it now.
diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 87e106c728b89f3ce7c11219cf7cad9cc166dda2..67d5be261d83633805c81dd84fdfc2b5c702f3ca 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1423,11 +1423,30 @@ static struct notifier_block ffa_bus_nb = { .notifier_call = ffa_bus_notifier, }; +static int ffa_xa_add_partition_info(int vm_id) +{ + struct ffa_dev_part_info *info; + int ret; + + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + rwlock_init(&info->rw_lock); + ret = xa_insert(&drv_info->partition_info, vm_id, info, GFP_KERNEL); + if (ret) { + pr_err("%s: failed to save partition ID 0x%x - ret:%d. Abort.\n", + __func__, vm_id, ret); + kfree(info); + } + + return ret; +} + static int ffa_setup_partitions(void) { int count, idx, ret; struct ffa_device *ffa_dev; - struct ffa_dev_part_info *info; struct ffa_partition_info *pbuf, *tpbuf; if (drv_info->version == FFA_VERSION_1_0) { @@ -1461,39 +1480,18 @@ static int ffa_setup_partitions(void) !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)) ffa_mode_32bit_set(ffa_dev); - info = kzalloc(sizeof(*info), GFP_KERNEL); - if (!info) { + if (ffa_xa_add_partition_info(ffa_dev->vm_id)) { ffa_device_unregister(ffa_dev); continue; } - rwlock_init(&info->rw_lock); - ret = xa_insert(&drv_info->partition_info, tpbuf->id, - info, GFP_KERNEL); - if (ret) { - pr_err("%s: failed to save partition ID 0x%x - ret:%d\n", - __func__, tpbuf->id, ret); - ffa_device_unregister(ffa_dev); - kfree(info); - } + } kfree(pbuf); /* Allocate for the host */ - info = kzalloc(sizeof(*info), GFP_KERNEL); - if (!info) { - /* Already registered devices are freed on bus_exit */ - ffa_partitions_cleanup(); - return -ENOMEM; - } - - rwlock_init(&info->rw_lock); - ret = xa_insert(&drv_info->partition_info, drv_info->vm_id, - info, GFP_KERNEL); + ret = ffa_xa_add_partition_info(drv_info->vm_id); if (ret) { - pr_err("%s: failed to save Host partition ID 0x%x - ret:%d. Abort.\n", - __func__, drv_info->vm_id, ret); - kfree(info); /* Already registered devices are freed on bus_exit */ ffa_partitions_cleanup(); }