[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1360496352-29482-9-git-send-email-sjur.brandeland@stericsson.com>
Date: Sun, 10 Feb 2013 12:39:11 +0100
From: sjur.brandeland@...ricsson.com
To: Ido Yariv <ido@...ery.com>, Ohad Ben-Cohen <ohad@...ery.com>
Cc: linux-kernel@...r.kernel.org,
Dmitry Tarnyagin <dmitry.tarnyagin@...ricsson.com>,
Linus Walleij <linus.walleij@...aro.org>,
Erwan Yvin <erwan.yvin@...ricsson.com>, sjur@...ndeland.net,
Sjur Brændeland <sjur.brandeland@...ricsson.com>
Subject: [PATCH 8/9] remoteproc: Calculate max_notifyid by counting vrings
From: Sjur Brændeland <sjur.brandeland@...ricsson.com>
Simplify handling of max_notifyid by simply counting the
number of vrings.
Signed-off-by: Sjur Brændeland <sjur.brandeland@...ricsson.com>
---
drivers/remoteproc/remoteproc_core.c | 34 +++++++++++++++++++---------------
1 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index ec9f81e..14f40eb 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -226,9 +226,6 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)
return ret;
}
- /* Store largest notifyid */
- rproc->max_notifyid = max(rproc->max_notifyid, notifyid);
-
dev_dbg(dev, "vring%d: va %p dma %llx size %x idr %d\n", i, va,
(unsigned long long)dma, size, notifyid);
@@ -278,25 +275,13 @@ rproc_parse_vring(struct rproc_vdev *rvdev, struct fw_rsc_vdev *rsc, int i)
return 0;
}
-static int rproc_max_notifyid(int id, void *p, void *data)
-{
- int *maxid = data;
- *maxid = max(*maxid, id);
- return 0;
-}
-
void rproc_free_vring(struct rproc_vring *rvring)
{
int size = PAGE_ALIGN(vring_size(rvring->len, rvring->align));
struct rproc *rproc = rvring->rvdev->rproc;
- int maxid = 0;
dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma);
idr_remove(&rproc->notifyids, rvring->notifyid);
-
- /* Find the largest remaining notifyid */
- idr_for_each(&rproc->notifyids, rproc_max_notifyid, &maxid);
- rproc->max_notifyid = maxid;
}
/**
@@ -679,6 +664,15 @@ free_carv:
return ret;
}
+static int rproc_handle_notifyid(struct rproc *rproc, struct fw_rsc_vdev *rsc,
+ int avail)
+{
+ /* Summerize the number of notification IDs */
+ rproc->max_notifyid += rsc->num_of_vrings;
+
+ return 0;
+}
+
/*
* A lookup table for resource handlers. The indices are defined in
* enum fw_resource_type.
@@ -694,6 +688,10 @@ static rproc_handle_resource_t rproc_handle_vdev_rsc[RSC_LAST] = {
[RSC_VDEV] = (rproc_handle_resource_t)rproc_handle_vdev,
};
+static rproc_handle_resource_t rproc_handle_notifyid_rsc[RSC_LAST] = {
+ [RSC_VDEV] = (rproc_handle_resource_t)rproc_handle_notifyid,
+};
+
/* handle firmware resource entries before booting the remote processor */
static int
rproc_handle_resource(struct rproc *rproc, struct resource_table *table,
@@ -868,6 +866,12 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context)
if (!table)
goto out;
+ rproc->max_notifyid = 0;
+
+ /* count the numbe of notify-ids */
+ ret = rproc_handle_resource(rproc, table, tablesz,
+ rproc_handle_notifyid_rsc);
+
/* look for virtio devices and register them */
ret = rproc_handle_resource(rproc, table, tablesz,
rproc_handle_vdev_rsc);
--
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists