diff options
author | Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> | 2022-09-21 15:50:44 +0200 |
---|---|---|
committer | Mathieu Poirier <mathieu.poirier@linaro.org> | 2022-09-21 19:15:04 +0200 |
commit | 1d7b61c06dc310421911dac7c5d2d15b754c8b63 (patch) | |
tree | ea210bfff5a65b7df6fde3bd807b34f6bc0e193e /drivers/remoteproc/remoteproc_core.c | |
parent | remoteproc: Move rproc_vdev management to remoteproc_virtio.c (diff) | |
download | linux-1d7b61c06dc310421911dac7c5d2d15b754c8b63.tar.xz linux-1d7b61c06dc310421911dac7c5d2d15b754c8b63.zip |
remoteproc: virtio: Create platform device for the remoteproc_virtio
Define a platform driver to manage the remoteproc virtio device as
a platform devices.
The platform device allows to pass rproc_vdev_data platform data to
specify properties that are stored in the rproc_vdev structure.
Such approach will allow to preserve legacy remoteproc virtio device
creation but also to probe the device using device tree mechanism.
remoteproc_virtio.c update:
- Add rproc_virtio_driver platform driver. The probe ops replaces
the rproc_rvdev_add_device function.
- All reference to the rvdev->dev has been updated to rvdev-pdev->dev.
- rproc_rvdev_release is removed as associated to the rvdev device.
- The use of rvdev->kref counter is replaced by get/put_device on the
remoteproc virtio platform device.
- The vdev device no longer increments rproc device counter.
increment/decrement is done in rproc_virtio_probe/rproc_virtio_remove
function in charge of the vrings allocation/free.
remoteproc_core.c update:
Migrate from the rvdev device to the rvdev platform device.
From this patch, when a vdev resource is found in the resource table
the remoteproc core register a platform device.
Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Link: https://lore.kernel.org/r/20220921135044.917140-5-arnaud.pouliquen@foss.st.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Diffstat (limited to 'drivers/remoteproc/remoteproc_core.c')
-rw-r--r-- | drivers/remoteproc/remoteproc_core.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 2e88f933a4eb..e7c25477b0af 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -480,6 +480,7 @@ static int rproc_handle_vdev(struct rproc *rproc, void *ptr, struct rproc_vdev *rvdev; size_t rsc_size; struct rproc_vdev_data rvdev_data; + struct platform_device *pdev; /* make sure resource isn't truncated */ rsc_size = struct_size(rsc, vring, rsc->num_of_vrings); @@ -508,9 +509,12 @@ static int rproc_handle_vdev(struct rproc *rproc, void *ptr, rvdev_data.rsc_offset = offset; rvdev_data.rsc = rsc; - rvdev = rproc_rvdev_add_device(rproc, &rvdev_data); - if (IS_ERR(rvdev)) - return PTR_ERR(rvdev); + pdev = platform_device_register_data(dev, "rproc-virtio", rvdev_data.index, &rvdev_data, + sizeof(rvdev_data)); + if (IS_ERR(pdev)) { + dev_err(dev, "failed to create rproc-virtio device\n"); + return PTR_ERR(pdev); + } return 0; } @@ -1246,7 +1250,7 @@ void rproc_resource_cleanup(struct rproc *rproc) /* clean up remote vdev entries */ list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node) - kref_put(&rvdev->refcount, rproc_vdev_release); + platform_device_unregister(rvdev->pdev); rproc_coredump_cleanup(rproc); } |