Skip to contentSkip to conversation

remoteproc: core: Auto select rproc-virtio device id

PATCH In review Shengjiu Wang 2 participants 2 messages Oct 18, 2022 Remote processor (remoteproc)

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 remoteproc: core: Auto select rproc-virtio device id

With multiple remoteproc device, there will below error:

sysfs: cannot create duplicate filename '/bus/platform/devices/rproc-virtio.0'

The rvdev_data.index is duplicate, that cause issue, so need to use the PLATFORM_DEVID_AUTO instead. After fixing device name it becomes something like:
/bus/platform/devices/rproc-virtio.2.auto

Fixes 1d7b61c06dc3 ("remoteproc: virtio: Create platform device for the remoteproc_virtio")

---
changes in v3:
- add comment in codec

changes in v2:
- update commit message

 drivers/remoteproc/remoteproc_core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +7 -1
index 8768cb64f560..f9187e35b090 100644
@@ -509,7 +509,13 @@ static int rproc_handle_vdev(struct rproc *rproc, void *ptr,
 	rvdev_data.rsc_offset = offset;
 	rvdev_data.rsc = rsc;
 
-	pdev = platform_device_register_data(dev, "rproc-virtio", rvdev_data.index, &rvdev_data,
+	/*
+	 * When there is more than one remote processor, rproc->nb_vdev number is
+	 * same for each separate instances of "rproc". If rvdev_data.index is used
+	 * as device id, then we get dupliation in sysfs, so need to use
+	 * PLATFORM_DEVID_AUTO to auto select device id.
+	 */
+	pdev = platform_device_register_data(dev, "rproc-virtio", PLATFORM_DEVID_AUTO, &rvdev_data,
 					     sizeof(rvdev_data));
 	if (IS_ERR(pdev)) {
 		dev_err(dev, "failed to create rproc-virtio device\n");
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 10 lines · Shengjiu Wang

With multiple remoteproc device, there will below error:

sysfs: cannot create duplicate filename '/bus/platform/devices/rproc-virtio.0'

The rvdev_data.index is duplicate, that cause issue, so need to use the PLATFORM_DEVID_AUTO instead. After fixing device name it becomes something like:
/bus/platform/devices/rproc-virtio.2.auto

Quoted 5 lines
Fixes 1d7b61c06dc3 ("remoteproc: virtio: Create platform device for the remoteproc_virtio")

I will queue this on Monday when rc2 comes out.

Thanks,
Mathieu

Quoted 32 lines

---
changes in v3:
- add comment in codec

changes in v2:
- update commit message

 drivers/remoteproc/remoteproc_core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +7 -2
index 8768cb64f560..f9187e35b090 100644
@@ -509,7 +509,13 @@ static int rproc_handle_vdev(struct rproc *rproc, void *ptr,
        rvdev_data.rsc_offset = offset;
        rvdev_data.rsc = rsc;
 
-       pdev = platform_device_register_data(dev, "rproc-virtio", rvdev_data.index, &rvdev_data,
+       /*
+        * When there is more than one remote processor, rproc->nb_vdev number is
+        * same for each separate instances of "rproc". If rvdev_data.index is used
+        * as device id, then we get dupliation in sysfs, so need to use
+        * PLATFORM_DEVID_AUTO to auto select device id.
+        */
+       pdev = platform_device_register_data(dev, "rproc-virtio", PLATFORM_DEVID_AUTO, &rvdev_data,
                                             sizeof(rvdev_data));
        if (IS_ERR(pdev)) {
                dev_err(dev, "failed to create rproc-virtio device\n");
--

2.34.1