diff options
author | Sjur Brændeland <sjur.brandeland@stericsson.com> | 2013-02-21 12:15:40 -0500 |
---|---|---|
committer | Ohad Ben-Cohen <ohad@wizery.com> | 2013-04-07 07:06:17 -0400 |
commit | c0d631570ad54a8561f5fc7023e96b5316c7fdb9 (patch) | |
tree | 0d10e2d1022267540868402e90bc08f336bd229a /drivers/remoteproc | |
parent | 92b38f851470f8d8ea7ed638d546f83b5268bc12 (diff) |
remoteproc: set vring addresses in resource table
Set the vring addresses in the resource table so that
the remote device can read the actual addresses used.
Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
Acked-by: Ido Yariv <ido@wizery.com>
[rebase]
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Diffstat (limited to 'drivers/remoteproc')
-rw-r--r-- | drivers/remoteproc/remoteproc_core.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index d0251fe9e119..7c357370083a 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c | |||
@@ -194,6 +194,7 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) | |||
194 | struct rproc *rproc = rvdev->rproc; | 194 | struct rproc *rproc = rvdev->rproc; |
195 | struct device *dev = &rproc->dev; | 195 | struct device *dev = &rproc->dev; |
196 | struct rproc_vring *rvring = &rvdev->vring[i]; | 196 | struct rproc_vring *rvring = &rvdev->vring[i]; |
197 | struct fw_rsc_vdev *rsc; | ||
197 | dma_addr_t dma; | 198 | dma_addr_t dma; |
198 | void *va; | 199 | void *va; |
199 | int ret, size, notifyid; | 200 | int ret, size, notifyid; |
@@ -204,7 +205,6 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) | |||
204 | /* | 205 | /* |
205 | * Allocate non-cacheable memory for the vring. In the future | 206 | * Allocate non-cacheable memory for the vring. In the future |
206 | * this call will also configure the IOMMU for us | 207 | * this call will also configure the IOMMU for us |
207 | * TODO: let the rproc know the da of this vring | ||
208 | */ | 208 | */ |
209 | va = dma_alloc_coherent(dev->parent, size, &dma, GFP_KERNEL); | 209 | va = dma_alloc_coherent(dev->parent, size, &dma, GFP_KERNEL); |
210 | if (!va) { | 210 | if (!va) { |
@@ -215,7 +215,6 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) | |||
215 | /* | 215 | /* |
216 | * Assign an rproc-wide unique index for this vring | 216 | * Assign an rproc-wide unique index for this vring |
217 | * TODO: assign a notifyid for rvdev updates as well | 217 | * TODO: assign a notifyid for rvdev updates as well |
218 | * TODO: let the rproc know the notifyid of this vring | ||
219 | * TODO: support predefined notifyids (via resource table) | 218 | * TODO: support predefined notifyids (via resource table) |
220 | */ | 219 | */ |
221 | ret = idr_alloc(&rproc->notifyids, rvring, 0, 0, GFP_KERNEL); | 220 | ret = idr_alloc(&rproc->notifyids, rvring, 0, 0, GFP_KERNEL); |
@@ -233,6 +232,15 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) | |||
233 | rvring->dma = dma; | 232 | rvring->dma = dma; |
234 | rvring->notifyid = notifyid; | 233 | rvring->notifyid = notifyid; |
235 | 234 | ||
235 | /* | ||
236 | * Let the rproc know the notifyid and da of this vring. | ||
237 | * Not all platforms use dma_alloc_coherent to automatically | ||
238 | * set up the iommu. In this case the device address (da) will | ||
239 | * hold the physical address and not the device address. | ||
240 | */ | ||
241 | rsc = (void *)rproc->table_ptr + rvdev->rsc_offset; | ||
242 | rsc->vring[i].da = dma; | ||
243 | rsc->vring[i].notifyid = notifyid; | ||
236 | return 0; | 244 | return 0; |
237 | } | 245 | } |
238 | 246 | ||
@@ -271,9 +279,16 @@ void rproc_free_vring(struct rproc_vring *rvring) | |||
271 | { | 279 | { |
272 | int size = PAGE_ALIGN(vring_size(rvring->len, rvring->align)); | 280 | int size = PAGE_ALIGN(vring_size(rvring->len, rvring->align)); |
273 | struct rproc *rproc = rvring->rvdev->rproc; | 281 | struct rproc *rproc = rvring->rvdev->rproc; |
282 | int idx = rvring->rvdev->vring - rvring; | ||
283 | struct fw_rsc_vdev *rsc; | ||
274 | 284 | ||
275 | dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma); | 285 | dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma); |
276 | idr_remove(&rproc->notifyids, rvring->notifyid); | 286 | idr_remove(&rproc->notifyids, rvring->notifyid); |
287 | |||
288 | /* reset resource entry info */ | ||
289 | rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset; | ||
290 | rsc->vring[idx].da = 0; | ||
291 | rsc->vring[idx].notifyid = -1; | ||
277 | } | 292 | } |
278 | 293 | ||
279 | /** | 294 | /** |