aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/remoteproc
diff options
context:
space:
mode:
authorSjur Brændeland <sjur.brandeland@stericsson.com>2013-02-21 12:15:37 -0500
committerOhad Ben-Cohen <ohad@wizery.com>2013-04-07 07:04:25 -0400
commitba7290e01663787fcfc2bedaff6232359d4ff248 (patch)
treef95914f654f498088b0fdb331904593c3a519bc7 /drivers/remoteproc
parent232fcdbb450000850bef8ff7e022cde2b4053f67 (diff)
remoteproc: calculate max_notifyid by counting vrings
Simplify handling of max_notifyid by simply counting the number of vrings. Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com> Acked-by: Ido Yariv <ido@wizery.com> [small terminology changes] Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Diffstat (limited to 'drivers/remoteproc')
-rw-r--r--drivers/remoteproc/remoteproc_core.c33
-rw-r--r--drivers/remoteproc/ste_modem_rproc.c2
2 files changed, 19 insertions, 16 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index b8228c628b0c..9d2a4ac6c706 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -224,9 +224,6 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)
224 } 224 }
225 notifyid = ret; 225 notifyid = ret;
226 226
227 /* Store largest notifyid */
228 rproc->max_notifyid = max(rproc->max_notifyid, notifyid);
229
230 dev_dbg(dev, "vring%d: va %p dma %llx size %x idr %d\n", i, va, 227 dev_dbg(dev, "vring%d: va %p dma %llx size %x idr %d\n", i, va,
231 (unsigned long long)dma, size, notifyid); 228 (unsigned long long)dma, size, notifyid);
232 229
@@ -268,25 +265,13 @@ rproc_parse_vring(struct rproc_vdev *rvdev, struct fw_rsc_vdev *rsc, int i)
268 return 0; 265 return 0;
269} 266}
270 267
271static int rproc_max_notifyid(int id, void *p, void *data)
272{
273 int *maxid = data;
274 *maxid = max(*maxid, id);
275 return 0;
276}
277
278void rproc_free_vring(struct rproc_vring *rvring) 268void rproc_free_vring(struct rproc_vring *rvring)
279{ 269{
280 int size = PAGE_ALIGN(vring_size(rvring->len, rvring->align)); 270 int size = PAGE_ALIGN(vring_size(rvring->len, rvring->align));
281 struct rproc *rproc = rvring->rvdev->rproc; 271 struct rproc *rproc = rvring->rvdev->rproc;
282 int maxid = 0;
283 272
284 dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma); 273 dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma);
285 idr_remove(&rproc->notifyids, rvring->notifyid); 274 idr_remove(&rproc->notifyids, rvring->notifyid);
286
287 /* Find the largest remaining notifyid */
288 idr_for_each(&rproc->notifyids, rproc_max_notifyid, &maxid);
289 rproc->max_notifyid = maxid;
290} 275}
291 276
292/** 277/**
@@ -669,6 +654,15 @@ free_carv:
669 return ret; 654 return ret;
670} 655}
671 656
657static int rproc_count_vrings(struct rproc *rproc, struct fw_rsc_vdev *rsc,
658 int avail)
659{
660 /* Summarize the number of notification IDs */
661 rproc->max_notifyid += rsc->num_of_vrings;
662
663 return 0;
664}
665
672/* 666/*
673 * A lookup table for resource handlers. The indices are defined in 667 * A lookup table for resource handlers. The indices are defined in
674 * enum fw_resource_type. 668 * enum fw_resource_type.
@@ -684,6 +678,10 @@ static rproc_handle_resource_t rproc_vdev_handler[RSC_LAST] = {
684 [RSC_VDEV] = (rproc_handle_resource_t)rproc_handle_vdev, 678 [RSC_VDEV] = (rproc_handle_resource_t)rproc_handle_vdev,
685}; 679};
686 680
681static rproc_handle_resource_t rproc_count_vrings_handler[RSC_LAST] = {
682 [RSC_VDEV] = (rproc_handle_resource_t)rproc_count_vrings,
683};
684
687/* handle firmware resource entries before booting the remote processor */ 685/* handle firmware resource entries before booting the remote processor */
688static int rproc_handle_resources(struct rproc *rproc, 686static int rproc_handle_resources(struct rproc *rproc,
689 struct resource_table *table, int len, 687 struct resource_table *table, int len,
@@ -858,6 +856,11 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context)
858 if (!table) 856 if (!table)
859 goto out; 857 goto out;
860 858
859 /* count the number of notify-ids */
860 rproc->max_notifyid = -1;
861 ret = rproc_handle_resources(rproc, table, tablesz,
862 rproc_count_vrings_handler);
863
861 /* look for virtio devices and register them */ 864 /* look for virtio devices and register them */
862 ret = rproc_handle_resources(rproc, table, tablesz, rproc_vdev_handler); 865 ret = rproc_handle_resources(rproc, table, tablesz, rproc_vdev_handler);
863 if (ret) 866 if (ret)
diff --git a/drivers/remoteproc/ste_modem_rproc.c b/drivers/remoteproc/ste_modem_rproc.c
index 8cc588f38cd2..6fc213948146 100644
--- a/drivers/remoteproc/ste_modem_rproc.c
+++ b/drivers/remoteproc/ste_modem_rproc.c
@@ -213,7 +213,7 @@ static int sproc_start(struct rproc *rproc)
213 } 213 }
214 214
215 /* Subscribe to notifications */ 215 /* Subscribe to notifications */
216 for (i = 0; i < rproc->max_notifyid; i++) { 216 for (i = 0; i <= rproc->max_notifyid; i++) {
217 err = sproc->mdev->ops.kick_subscribe(sproc->mdev, i); 217 err = sproc->mdev->ops.kick_subscribe(sproc->mdev, i);
218 if (err) { 218 if (err) {
219 sproc_err(sproc, 219 sproc_err(sproc,