]> www.infradead.org Git - users/willy/xarray.git/commitdiff
ocxl: Convert pe_tree to XArray
authorMatthew Wilcox <willy@infradead.org>
Wed, 24 Oct 2018 12:00:04 +0000 (08:00 -0400)
committerMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 8 Aug 2019 18:01:05 +0000 (14:01 -0400)
Straightforward conversion.

Signed-off-by: Matthew Wilcox <willy@infradead.org>
drivers/misc/ocxl/link.c

index 58d111afd9f6ab5217812334ae2da26c4dc01b16..4d572176e1b65b9ff2c7cf448dad9fbe338d5f43 100644 (file)
@@ -4,6 +4,7 @@
 #include <linux/mutex.h>
 #include <linux/mm_types.h>
 #include <linux/mmu_context.h>
+#include <linux/xarray.h>
 #include <asm/copro.h>
 #include <asm/pnv-ocxl.h>
 #include <misc/ocxl.h>
@@ -46,7 +47,7 @@ struct spa {
        struct ocxl_process_element *spa_mem;
        int spa_order;
        struct mutex spa_lock;
-       struct radix_tree_root pe_tree; /* Maps PE handles to pe_data */
+       struct xarray pe_array; /* Maps PE handles to pe_data */
        char *irq_name;
        int virq;
        void __iomem *reg_dsisr;
@@ -207,7 +208,7 @@ static irqreturn_t xsl_fault_handler(int irq, void *data)
        }
 
        rcu_read_lock();
-       pe_data = radix_tree_lookup(&spa->pe_tree, pe_handle);
+       pe_data = xa_load(&spa->pe_array, pe_handle);
        if (!pe_data) {
                /*
                 * Could only happen if the driver didn't notify the
@@ -341,7 +342,7 @@ static int alloc_spa(struct pci_dev *dev, struct ocxl_link *link)
                return -ENOMEM;
 
        mutex_init(&spa->spa_lock);
-       INIT_RADIX_TREE(&spa->pe_tree, GFP_KERNEL);
+       xa_init(&spa->pe_array);
        INIT_WORK(&spa->xsl_fault.fault_work, xsl_fault_handler_bh);
 
        spa->spa_order = SPA_SPA_SIZE_LOG - PAGE_SHIFT;
@@ -547,7 +548,7 @@ int ocxl_link_add_pe(void *link_handle, int pasid, u32 pidr, u32 tidr,
         * invalidation
         */
        mb();
-       radix_tree_insert(&spa->pe_tree, pe_handle, pe_data);
+       xa_store(&spa->pe_array, pe_handle, pe_data, GFP_KERNEL);
 
        /*
         * The mm must stay valid for as long as the device uses it. We
@@ -627,15 +628,15 @@ int ocxl_link_remove_pe(void *link_handle, int pasid)
         * sure the PASID is no longer in use, including pending
         * interrupts. However, there's no way to be sure...
         *
-        * We clear the PE and remove the context from our radix
-        * tree. From that point on, any new interrupt for that
+        * We clear the PE and remove the context from our array.
+        * From that point on, any new interrupt for that
         * context will fail silently, which is ok. As mentioned
         * above, that's not expected, but it could happen if the
         * driver or AFU didn't do the right thing.
         *
         * There could still be a bottom half running, but we don't
         * need to wait/flush, as it is managing a reference count on
-        * the mm it reads from the radix tree.
+        * the mm it reads from the array.
         */
        pe_handle = pasid & SPA_PE_MASK;
        pe = spa->spa_mem + pe_handle;
@@ -666,7 +667,7 @@ int ocxl_link_remove_pe(void *link_handle, int pasid)
        rc = pnv_ocxl_spa_remove_pe_from_cache(link->platform_data, pe_handle);
        WARN_ON(rc);
 
-       pe_data = radix_tree_delete(&spa->pe_tree, pe_handle);
+       pe_data = xa_erase(&spa->pe_array, pe_handle);
        if (!pe_data) {
                WARN(1, "Couldn't find pe data when removing PE\n");
        } else {