Skip to contentSkip to conversation

firmware: arm_ffa: Assign the missing IDR allocation ID to the FFA device

PATCH Applied Sudeep Holla 1 participant 3 messages Oct 3, 2023 – Oct 6, 2023 Firmware framework for ARMV8-a

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 firmware: arm_ffa: Assign the missing IDR allocation ID to the FFA device

Commit 19b8766459c4 ("firmware: arm_ffa: Fix FFA device names for logical partitions") added an ID to the FFA device using ida_alloc() and append the same to "arm-ffa" to make up a unique device name. However it missed to stash the id value in ffa_dev to help freeing the ID later when the device is destroyed.

Due to the missing/unassigned ID in FFA device, we get the following warning when the FF-A device is unregistered. Fix the same by actually assigning the ID in the FFA device this time for real.

Fixes 19b8766459c4 ("firmware: arm_ffa: Fix FFA device names for logical partitions")
---
 drivers/firmware/arm_ffa/bus.c | 1 +
 1 file changed, 1 insertion(+)
drivers/firmware/arm_ffa/bus.c +1 -0
index 2b8bfcd010f5..7865438b3696 100644
@@ -193,6 +193,7 @@ struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
 	dev->release = ffa_release_device;
 	dev_set_name(&ffa_dev->dev, "arm-ffa-%d", id);
 
+	ffa_dev->id = id;
 	ffa_dev->vm_id = vm_id;
 	ffa_dev->ops = ops;
 	uuid_copy(&ffa_dev->uuid, uuid);
Signature · 1 line
2.42.0
#1 lore raw
Quoted 10 lines · Sudeep Holla

Commit 19b8766459c4 ("firmware: arm_ffa: Fix FFA device names for logical partitions") added an ID to the FFA device using ida_alloc() and append the same to "arm-ffa" to make up a unique device name. However it missed to stash the id value in ffa_dev to help freeing the ID later when the device is destroyed.

Due to the missing/unassigned ID in FFA device, we get the following warning when the FF-A device is unregistered. Fix the same by actually assigning the ID in the FFA device this time for real.

Missed the below warning:

  |   ida_free called for id=0 which is not allocated.
  |   WARNING: CPU: 7 PID: 1 at lib/idr.c:525 ida_free+0x114/0x164
  |   CPU: 7 PID: 1 Comm: swapper/0 Not tainted 6.6.0-rc4 #209
  |   pstate: 61400009 (nZCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--)
  |   pc : ida_free+0x114/0x164
  |   lr : ida_free+0x114/0x164
  |   Call trace:
  |    ida_free+0x114/0x164
  |    ffa_release_device+0x24/0x3c
  |    device_release+0x34/0x8c
  |    kobject_put+0x94/0xf8
  |    put_device+0x18/0x24
  |    klist_devices_put+0x14/0x20
  |    klist_next+0xc8/0x114
  |    bus_for_each_dev+0xd8/0x144
  |    arm_ffa_bus_exit+0x30/0x54
  |    ffa_init+0x68/0x330
  |    do_one_initcall+0xdc/0x250
  |    do_initcall_level+0x8c/0xac
  |    do_initcalls+0x54/0x94
  |    do_basic_setup+0x1c/0x28
  |    kernel_init_freeable+0x104/0x170
  |    kernel_init+0x20/0x1a0
  |    ret_from_fork+0x10/0x20
Quoted 21 lines
Fixes 19b8766459c4 ("firmware: arm_ffa: Fix FFA device names for logical partitions")
---
 drivers/firmware/arm_ffa/bus.c | 1 +
 1 file changed, 1 insertion(+)
drivers/firmware/arm_ffa/bus.c +1 -0
index 2b8bfcd010f5..7865438b3696 100644
@@ -193,6 +193,7 @@ struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id,
 	dev->release = ffa_release_device;
 	dev_set_name(&ffa_dev->dev, "arm-ffa-%d", id);
 
+	ffa_dev->id = id;
 	ffa_dev->vm_id = vm_id;
 	ffa_dev->ops = ops;
 	uuid_copy(&ffa_dev->uuid, uuid);
Signature · 1 line
2.42.0
Signature · 2 lines
Regards,
Sudeep
author Applied
#2 lore raw
In reply to Sudeep Holla
Quoted 11 lines · Sudeep Holla

Commit 19b8766459c4 ("firmware: arm_ffa: Fix FFA device names for logical partitions") added an ID to the FFA device using ida_alloc() and append the same to "arm-ffa" to make up a unique device name. However it missed to stash the id value in ffa_dev to help freeing the ID later when the device is destroyed.

Due to the missing/unassigned ID in FFA device, we get the following warning when the FF-A device is unregistered. Fix the same by actually assigning the ID in the FFA device this time for real.

[...]

Applied to sudeep.holla/linux (for-next/ffa/updates), thanks!

[1/1] firmware: arm_ffa: Assign the missing IDR allocation ID to the FFA device

      https://git.kernel.org/sudeep.holla/c/7d0bc6360f17

--
Regards,
Sudeep