Skip to contentSkip to conversation

remoteproc: core: Auto select rproc-virtio device id

PATCH Superseded Shengjiu Wang 4 participants 4 messages Oct 13, 2022 Remote processor (remoteproc)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

Fixes 1d7b61c06dc3 ("remoteproc: virtio: Create platform device for the remoteproc_virtio")
---
 drivers/remoteproc/remoteproc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +1 -1
index 8768cb64f560..03a26498e879 100644
@@ -509,7 +509,7 @@ 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,
+	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
Reviewed-by on v1 1/1
#1 lore raw

Hi Shengju,

Quoted 3 lines · Shengjiu Wang

With multiple remoteproc device, there will below error:

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

Good catch!
Previously the device created was /sys/class/remoteproc/remoteproc0/remoteproc0#vdev0buffer/

So with your fix it become something like
/bus/platform/devices/rproc-virtio.2.auto

This works fine on my platform, also when creating two virtio devices for one remoteproc device.

Just a remark, could be nice to indicate in the commit message the result of your patch, means the name of the files created.

With that:

Thanks,
Arnaud

Quoted 23 lines

The rvdev_data.index is duplicate, that cause issue, so need to use the PLATFORM_DEVID_AUTO instead.

Fixes 1d7b61c06dc3 ("remoteproc: virtio: Create platform device for the remoteproc_virtio")
---
 drivers/remoteproc/remoteproc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +1 -1
index 8768cb64f560..03a26498e879 100644
@@ -509,7 +509,7 @@ 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,
+	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");
Reviewed-by
#2 lore raw

Hi,

Quoted 15 lines · Arnaud POULIQUEN

Hi Shengju,

Quoted 3 lines · Shengjiu Wang

With multiple remoteproc device, there will below error:

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

Good catch!
Previously the device created was /sys/class/remoteproc/remoteproc0/remoteproc0#vdev0buffer/

So with your fix it become something like
/bus/platform/devices/rproc-virtio.2.auto

Quoted 5 lines

This works fine on my platform, also when creating two virtio devices for one remoteproc device.

Just a remark, could be nice to indicate in the commit message the result of your patch, means the name of the files created.

Agree with the suggestion of putting the output in commit message.

LGTM.

-Mukesh

Quoted 31 lines

With that:

Thanks,
Arnaud

Quoted 23 lines

The rvdev_data.index is duplicate, that cause issue, so need to use the PLATFORM_DEVID_AUTO instead.

Fixes 1d7b61c06dc3 ("remoteproc: virtio: Create platform device for the remoteproc_virtio")
---
  drivers/remoteproc/remoteproc_core.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +1 -1
index 8768cb64f560..03a26498e879 100644
@@ -509,7 +509,7 @@ 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,
+	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");
Tested-by on v1 1/1
#3 lore raw
In reply to Shengjiu Wang
Quoted 7 lines

Subject: [PATCH] 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'

Quoted 6 lines

The rvdev_data.index is duplicate, that cause issue, so need to use the PLATFORM_DEVID_AUTO instead.

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

remoteproc_virtio")

Met same issue with on i.MX8QM-MEK dual CM4 case, and I tested same approach as you did.

Quoted 23 lines
---
 drivers/remoteproc/remoteproc_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +2 -2
index 8768cb64f560..03a26498e879 100644
@@ -509,7 +509,7 @@ 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,
+	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