diff options
author | Ohad Ben-Cohen <ohad@wizery.com> | 2012-05-30 15:01:25 -0400 |
---|---|---|
committer | Ohad Ben-Cohen <ohad@wizery.com> | 2012-07-05 17:53:03 -0400 |
commit | b5ab5e24e960b9f780a4cc96815cfd4b0d412720 (patch) | |
tree | d07fbf490e03e9e2706c14a9bc24ae4f47b05111 /drivers/remoteproc/remoteproc_virtio.c | |
parent | 6db20ea8d85064175c7ef594c433c6c2e6bbab83 (diff) |
remoteproc: maintain a generic child device for each rproc
For each registered rproc, maintain a generic remoteproc device whose
parent is the low level platform-specific device (commonly a pdev, but
it may certainly be any other type of device too).
With this in hand, the resulting device hierarchy might then look like:
omap-rproc.0
|
- remoteproc0 <---- new !
|
- virtio0
|
- virtio1
|
- rpmsg0
|
- rpmsg1
|
- rpmsg2
Where:
- omap-rproc.0 is the low level device that's bound to the
driver which invokes rproc_register()
- remoteproc0 is the result of this patch, and will be added by the
remoteproc framework when rproc_register() is invoked
- virtio0 and virtio1 are vdevs that are registered by remoteproc
when it realizes that they are supported by the firmware
of the physical remote processor represented by omap-rproc.0
- rpmsg0, rpmsg1 and rpmsg2 are rpmsg devices that represent rpmsg
channels, and are registerd by the rpmsg bus when it gets notified
about their existence
Technically, this patch:
- changes 'struct rproc' to contain this generic remoteproc.x device
- creates a new "remoteproc" type, to which this new generic remoteproc.x
device belong to.
- adds a super simple enumeration method for the indices of the
remoteproc.x devices
- updates all dev_* messaging to use the generic remoteproc.x device
instead of the low level platform-specific device
- updates all dma_* allocations to use the parent of remoteproc.x (where
the platform-specific memory pools, most commonly CMA, are to be found)
Adding this generic device has several merits:
- we can now add remoteproc runtime PM support simply by hooking onto the
new "remoteproc" type
- all remoteproc log messages will now carry a common name prefix
instead of having a platform-specific one
- having a device as part of the rproc struct makes it possible to simplify
refcounting (see subsequent patch)
Thanks to Stephen Boyd <sboyd@codeaurora.org> for suggesting and
discussing these ideas in one of the remoteproc review threads and
to Fernando Guzman Lugo <fernando.lugo@ti.com> for trying them out
with the (upcoming) runtime PM support for remoteproc.
Cc: Fernando Guzman Lugo <fernando.lugo@ti.com>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Diffstat (limited to 'drivers/remoteproc/remoteproc_virtio.c')
-rw-r--r-- | drivers/remoteproc/remoteproc_virtio.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index 26a7144e7f3b..b6621831a58a 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c | |||
@@ -36,7 +36,7 @@ static void rproc_virtio_notify(struct virtqueue *vq) | |||
36 | struct rproc *rproc = rvring->rvdev->rproc; | 36 | struct rproc *rproc = rvring->rvdev->rproc; |
37 | int notifyid = rvring->notifyid; | 37 | int notifyid = rvring->notifyid; |
38 | 38 | ||
39 | dev_dbg(rproc->dev, "kicking vq index: %d\n", notifyid); | 39 | dev_dbg(&rproc->dev, "kicking vq index: %d\n", notifyid); |
40 | 40 | ||
41 | rproc->ops->kick(rproc, notifyid); | 41 | rproc->ops->kick(rproc, notifyid); |
42 | } | 42 | } |
@@ -57,7 +57,7 @@ irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int notifyid) | |||
57 | { | 57 | { |
58 | struct rproc_vring *rvring; | 58 | struct rproc_vring *rvring; |
59 | 59 | ||
60 | dev_dbg(rproc->dev, "vq index %d is interrupted\n", notifyid); | 60 | dev_dbg(&rproc->dev, "vq index %d is interrupted\n", notifyid); |
61 | 61 | ||
62 | rvring = idr_find(&rproc->notifyids, notifyid); | 62 | rvring = idr_find(&rproc->notifyids, notifyid); |
63 | if (!rvring || !rvring->vq) | 63 | if (!rvring || !rvring->vq) |
@@ -74,6 +74,7 @@ static struct virtqueue *rp_find_vq(struct virtio_device *vdev, | |||
74 | { | 74 | { |
75 | struct rproc_vdev *rvdev = vdev_to_rvdev(vdev); | 75 | struct rproc_vdev *rvdev = vdev_to_rvdev(vdev); |
76 | struct rproc *rproc = vdev_to_rproc(vdev); | 76 | struct rproc *rproc = vdev_to_rproc(vdev); |
77 | struct device *dev = &rproc->dev; | ||
77 | struct rproc_vring *rvring; | 78 | struct rproc_vring *rvring; |
78 | struct virtqueue *vq; | 79 | struct virtqueue *vq; |
79 | void *addr; | 80 | void *addr; |
@@ -95,7 +96,7 @@ static struct virtqueue *rp_find_vq(struct virtio_device *vdev, | |||
95 | size = vring_size(len, rvring->align); | 96 | size = vring_size(len, rvring->align); |
96 | memset(addr, 0, size); | 97 | memset(addr, 0, size); |
97 | 98 | ||
98 | dev_dbg(rproc->dev, "vring%d: va %p qsz %d notifyid %d\n", | 99 | dev_dbg(dev, "vring%d: va %p qsz %d notifyid %d\n", |
99 | id, addr, len, rvring->notifyid); | 100 | id, addr, len, rvring->notifyid); |
100 | 101 | ||
101 | /* | 102 | /* |
@@ -105,7 +106,7 @@ static struct virtqueue *rp_find_vq(struct virtio_device *vdev, | |||
105 | vq = vring_new_virtqueue(len, rvring->align, vdev, false, addr, | 106 | vq = vring_new_virtqueue(len, rvring->align, vdev, false, addr, |
106 | rproc_virtio_notify, callback, name); | 107 | rproc_virtio_notify, callback, name); |
107 | if (!vq) { | 108 | if (!vq) { |
108 | dev_err(rproc->dev, "vring_new_virtqueue %s failed\n", name); | 109 | dev_err(dev, "vring_new_virtqueue %s failed\n", name); |
109 | rproc_free_vring(rvring); | 110 | rproc_free_vring(rvring); |
110 | return ERR_PTR(-ENOMEM); | 111 | return ERR_PTR(-ENOMEM); |
111 | } | 112 | } |
@@ -152,7 +153,7 @@ static int rproc_virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs, | |||
152 | /* now that the vqs are all set, boot the remote processor */ | 153 | /* now that the vqs are all set, boot the remote processor */ |
153 | ret = rproc_boot(rproc); | 154 | ret = rproc_boot(rproc); |
154 | if (ret) { | 155 | if (ret) { |
155 | dev_err(rproc->dev, "rproc_boot() failed %d\n", ret); | 156 | dev_err(&rproc->dev, "rproc_boot() failed %d\n", ret); |
156 | goto error; | 157 | goto error; |
157 | } | 158 | } |
158 | 159 | ||
@@ -254,7 +255,7 @@ static void rproc_vdev_release(struct device *dev) | |||
254 | int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) | 255 | int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) |
255 | { | 256 | { |
256 | struct rproc *rproc = rvdev->rproc; | 257 | struct rproc *rproc = rvdev->rproc; |
257 | struct device *dev = rproc->dev; | 258 | struct device *dev = &rproc->dev; |
258 | struct virtio_device *vdev = &rvdev->vdev; | 259 | struct virtio_device *vdev = &rvdev->vdev; |
259 | int ret; | 260 | int ret; |
260 | 261 | ||