]> www.infradead.org Git - users/willy/xarray.git/commitdiff
remoteproc: Convert notifyids to XArray
authorMatthew Wilcox <willy@infradead.org>
Mon, 18 Feb 2019 21:43:36 +0000 (16:43 -0500)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Fri, 9 Aug 2019 01:38:18 +0000 (21:38 -0400)
Signed-off-by: Matthew Wilcox <willy@infradead.org>
drivers/remoteproc/remoteproc_core.c
drivers/remoteproc/remoteproc_virtio.c
include/linux/remoteproc.h

index 3c5fbbbfb0f17c6104589a9fcace6aab00c88db7..50a3c344d54afe306f1b980cac205c6896a404be 100644 (file)
@@ -354,12 +354,12 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)
         * TODO: assign a notifyid for rvdev updates as well
         * TODO: support predefined notifyids (via resource table)
         */
-       ret = idr_alloc(&rproc->notifyids, rvring, 0, 0, GFP_KERNEL);
+       ret = xa_alloc(&rproc->notifyids, &notifyid, rvring, xa_limit_32b,
+                       GFP_KERNEL);
        if (ret < 0) {
-               dev_err(dev, "idr_alloc failed: %d\n", ret);
+               dev_err(dev, "id allocation failed: %d\n", ret);
                return ret;
        }
-       notifyid = ret;
 
        /* Potentially bump max_notifyid */
        if (notifyid > rproc->max_notifyid)
@@ -403,7 +403,7 @@ void rproc_free_vring(struct rproc_vring *rvring)
        int idx = rvring->rvdev->vring - rvring;
        struct fw_rsc_vdev *rsc;
 
-       idr_remove(&rproc->notifyids, rvring->notifyid);
+       xa_erase(&rproc->notifyids, rvring->notifyid);
 
        /* reset resource entry info */
        rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset;
@@ -1948,8 +1948,6 @@ static void rproc_type_release(struct device *dev)
 
        dev_info(&rproc->dev, "releasing %s\n", rproc->name);
 
-       idr_destroy(&rproc->notifyids);
-
        if (rproc->index >= 0)
                ida_simple_remove(&rproc_dev_index, rproc->index);
 
@@ -2060,7 +2058,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
 
        mutex_init(&rproc->lock);
 
-       idr_init(&rproc->notifyids);
+       xa_init_flags(&rproc->notifyids, XA_FLAGS_ALLOC);
 
        INIT_LIST_HEAD(&rproc->carveouts);
        INIT_LIST_HEAD(&rproc->mappings);
index 8c07cb2ca8bae575a697152dfa977fbd7b355e1b..969cbf9a2031db6f5591df2eb8ee3e50cda046bb 100644 (file)
@@ -54,7 +54,7 @@ irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int notifyid)
 
        dev_dbg(&rproc->dev, "vq index %d is interrupted\n", notifyid);
 
-       rvring = idr_find(&rproc->notifyids, notifyid);
+       rvring = xa_load(&rproc->notifyids, notifyid);
        if (!rvring || !rvring->vq)
                return IRQ_NONE;
 
index 16ad66683ad0a719b4ff91ae195eda82ee9fb7e2..9b1e2a41df4c5ae5057118f5eb87d4480d563b89 100644 (file)
@@ -468,7 +468,7 @@ struct rproc_dump_segment {
  * @bootaddr: address of first instruction to boot rproc with (optional)
  * @rvdevs: list of remote virtio devices
  * @subdevs: list of subdevices, to following the running state
- * @notifyids: idr for dynamically assigning rproc-wide unique notify ids
+ * @notifyids: used for dynamically assigning rproc-wide unique notify ids
  * @index: index of this rproc device
  * @crash_handler: workqueue for handling a crash
  * @crash_cnt: crash counter
@@ -501,7 +501,7 @@ struct rproc {
        u32 bootaddr;
        struct list_head rvdevs;
        struct list_head subdevs;
-       struct idr notifyids;
+       struct xarray notifyids;
        int index;
        struct work_struct crash_handler;
        unsigned int crash_cnt;