diff options
author | Ohad Ben-Cohen <ohad@wizery.com> | 2012-02-29 07:42:13 -0500 |
---|---|---|
committer | Ohad Ben-Cohen <ohad@wizery.com> | 2012-03-06 12:14:37 -0500 |
commit | 63140e0ed2e69bdafe62bc19fd6551d9213f80a7 (patch) | |
tree | a885f08832b5479721898b3dbef17edc17958d2c | |
parent | 55f34080d99be0ac75122a27e7b151c76a5b070d (diff) |
remoteproc: remove the hardcoded vring alignment
Remove the hardcoded vring alignment of 4096 bytes,
and instead utilize tha vring alignment as specified in
the resource table.
This is needed for remote processors that have rigid
memory requirement, and which have found the alignment of
4096 bytes to be excessively big.
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Cc: Brian Swetland <swetland@google.com>
Cc: Iliyan Malchev <malchev@google.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Mark Grosen <mgrosen@ti.com>
Cc: John Williams <john.williams@petalogix.com>
Cc: Michal Simek <monstr@monstr.eu>
Cc: Loic PALLARDY <loic.pallardy@stericsson.com>
Cc: Ludovic BARRE <ludovic.barre@stericsson.com>
Cc: Omar Ramirez Luna <omar.luna@linaro.org>
Cc: Guzman Lugo Fernando <fernando.lugo@ti.com>
Cc: Anna Suman <s-anna@ti.com>
Cc: Clark Rob <rob@ti.com>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Saravana Kannan <skannan@codeaurora.org>
Cc: David Brown <davidb@codeaurora.org>
Cc: Kieran Bingham <kieranbingham@gmail.com>
Cc: Tony Lindgren <tony@atomide.com>
-rw-r--r-- | drivers/remoteproc/remoteproc_core.c | 12 | ||||
-rw-r--r-- | drivers/remoteproc/remoteproc_virtio.c | 2 | ||||
-rw-r--r-- | include/linux/remoteproc.h | 9 |
3 files changed, 10 insertions, 13 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index ca02f128b435..9be5dadaa3a3 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c | |||
@@ -298,14 +298,15 @@ __rproc_handle_vring(struct rproc_vdev *rvdev, struct fw_rsc_vdev *rsc, int i) | |||
298 | return -EINVAL; | 298 | return -EINVAL; |
299 | } | 299 | } |
300 | 300 | ||
301 | /* the firmware must provide the expected queue size */ | 301 | /* verify queue size and vring alignment are sane */ |
302 | if (!vring->num) { | 302 | if (!vring->num || !vring->align) { |
303 | dev_err(dev, "invalid qsz (%d)\n", vring->num); | 303 | dev_err(dev, "invalid qsz (%d) or alignment (%d)\n", |
304 | vring->num, vring->align); | ||
304 | return -EINVAL; | 305 | return -EINVAL; |
305 | } | 306 | } |
306 | 307 | ||
307 | /* actual size of vring (in bytes) */ | 308 | /* actual size of vring (in bytes) */ |
308 | size = PAGE_ALIGN(vring_size(vring->num, AMP_VRING_ALIGN)); | 309 | size = PAGE_ALIGN(vring_size(vring->num, vring->align)); |
309 | 310 | ||
310 | if (!idr_pre_get(&rproc->notifyids, GFP_KERNEL)) { | 311 | if (!idr_pre_get(&rproc->notifyids, GFP_KERNEL)) { |
311 | dev_err(dev, "idr_pre_get failed\n"); | 312 | dev_err(dev, "idr_pre_get failed\n"); |
@@ -340,6 +341,7 @@ __rproc_handle_vring(struct rproc_vdev *rvdev, struct fw_rsc_vdev *rsc, int i) | |||
340 | dma, size, notifyid); | 341 | dma, size, notifyid); |
341 | 342 | ||
342 | rvdev->vring[i].len = vring->num; | 343 | rvdev->vring[i].len = vring->num; |
344 | rvdev->vring[i].align = vring->align; | ||
343 | rvdev->vring[i].va = va; | 345 | rvdev->vring[i].va = va; |
344 | rvdev->vring[i].dma = dma; | 346 | rvdev->vring[i].dma = dma; |
345 | rvdev->vring[i].notifyid = notifyid; | 347 | rvdev->vring[i].notifyid = notifyid; |
@@ -354,7 +356,7 @@ static void __rproc_free_vrings(struct rproc_vdev *rvdev, int i) | |||
354 | 356 | ||
355 | for (i--; i > 0; i--) { | 357 | for (i--; i > 0; i--) { |
356 | struct rproc_vring *rvring = &rvdev->vring[i]; | 358 | struct rproc_vring *rvring = &rvdev->vring[i]; |
357 | int size = PAGE_ALIGN(vring_size(rvring->len, AMP_VRING_ALIGN)); | 359 | int size = PAGE_ALIGN(vring_size(rvring->len, rvring->align)); |
358 | 360 | ||
359 | dma_free_coherent(rproc->dev, size, rvring->va, rvring->dma); | 361 | dma_free_coherent(rproc->dev, size, rvring->va, rvring->dma); |
360 | idr_remove(&rproc->notifyids, rvring->notifyid); | 362 | idr_remove(&rproc->notifyids, rvring->notifyid); |
diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index 07004106c954..ecf612130750 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c | |||
@@ -99,7 +99,7 @@ static struct virtqueue *rp_find_vq(struct virtio_device *vdev, | |||
99 | * Create the new vq, and tell virtio we're not interested in | 99 | * Create the new vq, and tell virtio we're not interested in |
100 | * the 'weak' smp barriers, since we're talking with a real device. | 100 | * the 'weak' smp barriers, since we're talking with a real device. |
101 | */ | 101 | */ |
102 | vq = vring_new_virtqueue(len, AMP_VRING_ALIGN, vdev, false, addr, | 102 | vq = vring_new_virtqueue(len, rvring->align, vdev, false, addr, |
103 | rproc_virtio_notify, callback, name); | 103 | rproc_virtio_notify, callback, name); |
104 | if (!vq) { | 104 | if (!vq) { |
105 | dev_err(rproc->dev, "vring_new_virtqueue %s failed\n", name); | 105 | dev_err(rproc->dev, "vring_new_virtqueue %s failed\n", name); |
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 7750d8a30933..f1ffabb978d3 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h | |||
@@ -43,13 +43,6 @@ | |||
43 | #include <linux/completion.h> | 43 | #include <linux/completion.h> |
44 | #include <linux/idr.h> | 44 | #include <linux/idr.h> |
45 | 45 | ||
46 | /* | ||
47 | * The alignment between the consumer and producer parts of the vring. | ||
48 | * Note: this is part of the "wire" protocol. If you change this, you need | ||
49 | * to update your peers too. | ||
50 | */ | ||
51 | #define AMP_VRING_ALIGN (4096) | ||
52 | |||
53 | /** | 46 | /** |
54 | * struct resource_table - firmware resource table header | 47 | * struct resource_table - firmware resource table header |
55 | * @ver: version number | 48 | * @ver: version number |
@@ -423,6 +416,7 @@ struct rproc { | |||
423 | * @dma: dma address | 416 | * @dma: dma address |
424 | * @len: length, in bytes | 417 | * @len: length, in bytes |
425 | * @da: device address | 418 | * @da: device address |
419 | * @align: vring alignment | ||
426 | * @notifyid: rproc-specific unique vring index | 420 | * @notifyid: rproc-specific unique vring index |
427 | * @rvdev: remote vdev | 421 | * @rvdev: remote vdev |
428 | * @vq: the virtqueue of this vring | 422 | * @vq: the virtqueue of this vring |
@@ -432,6 +426,7 @@ struct rproc_vring { | |||
432 | dma_addr_t dma; | 426 | dma_addr_t dma; |
433 | int len; | 427 | int len; |
434 | u32 da; | 428 | u32 da; |
429 | u32 align; | ||
435 | int notifyid; | 430 | int notifyid; |
436 | struct rproc_vdev *rvdev; | 431 | struct rproc_vdev *rvdev; |
437 | struct virtqueue *vq; | 432 | struct virtqueue *vq; |