From 86d803e69e559ca67335b16c976296ee10fcdff8 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Wed, 24 Oct 2018 08:00:04 -0400 Subject: [PATCH] ocxl: Convert pe_tree to XArray Straightforward conversion. Signed-off-by: Matthew Wilcox --- drivers/misc/ocxl/link.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/misc/ocxl/link.c b/drivers/misc/ocxl/link.c index 58d111afd9f6..4d572176e1b6 100644 --- a/drivers/misc/ocxl/link.c +++ b/drivers/misc/ocxl/link.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -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 { -- 2.50.1