remoteproc: core: Auto select rproc-virtio device id
authorShengjiu Wang <shengjiu.wang@nxp.com>
Tue, 18 Oct 2022 13:44:04 +0000 (21:44 +0800)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Mon, 24 Oct 2022 16:11:22 +0000 (10:11 -0600)
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")
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Reviewed-by: Mukesh Ojha <quic_mojha@quicinc.com>
Tested-by: Peng Fan <peng.fan@nxp.com>
Link: https://lore.kernel.org/r/1666100644-27010-1-git-send-email-shengjiu.wang@nxp.com
[Fixed typographical error in comment block]
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
drivers/remoteproc/remoteproc_core.c

index 8768cb64f560ce1cfc47bc87b33bf4541ea118d0..cb1d414a23896c0a55fab0d8077958296e44a50c 100644 (file)
@@ -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 duplication 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");