hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/arch/powerpc/platforms/pseries/iommu.c
....@@ -24,7 +24,6 @@
2424 #include <linux/of.h>
2525 #include <linux/iommu.h>
2626 #include <linux/rculist.h>
27
-#include <linux/local_lock.h>
2827 #include <asm/io.h>
2928 #include <asm/prom.h>
3029 #include <asm/rtas.h>
....@@ -191,13 +190,7 @@
191190 return ret;
192191 }
193192
194
-struct tce_page {
195
- __be64 * page;
196
- local_lock_t lock;
197
-};
198
-static DEFINE_PER_CPU(struct tce_page, tce_page) = {
199
- .lock = INIT_LOCAL_LOCK(lock),
200
-};
193
+static DEFINE_PER_CPU(__be64 *, tce_page);
201194
202195 static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
203196 long npages, unsigned long uaddr,
....@@ -219,10 +212,9 @@
219212 direction, attrs);
220213 }
221214
222
- /* to protect tcep and the page behind it */
223
- local_lock_irqsave(&tce_page.lock, flags);
215
+ local_irq_save(flags); /* to protect tcep and the page behind it */
224216
225
- tcep = __this_cpu_read(tce_page.page);
217
+ tcep = __this_cpu_read(tce_page);
226218
227219 /* This is safe to do since interrupts are off when we're called
228220 * from iommu_alloc{,_sg}()
....@@ -231,12 +223,12 @@
231223 tcep = (__be64 *)__get_free_page(GFP_ATOMIC);
232224 /* If allocation fails, fall back to the loop implementation */
233225 if (!tcep) {
234
- local_unlock_irqrestore(&tce_page.lock, flags);
226
+ local_irq_restore(flags);
235227 return tce_build_pSeriesLP(tbl->it_index, tcenum,
236228 tbl->it_page_shift,
237229 npages, uaddr, direction, attrs);
238230 }
239
- __this_cpu_write(tce_page.page, tcep);
231
+ __this_cpu_write(tce_page, tcep);
240232 }
241233
242234 rpn = __pa(uaddr) >> TCE_SHIFT;
....@@ -266,7 +258,7 @@
266258 tcenum += limit;
267259 } while (npages > 0 && !rc);
268260
269
- local_unlock_irqrestore(&tce_page.lock, flags);
261
+ local_irq_restore(flags);
270262
271263 if (unlikely(rc == H_NOT_ENOUGH_RESOURCES)) {
272264 ret = (int)rc;
....@@ -437,17 +429,16 @@
437429 DMA_BIDIRECTIONAL, 0);
438430 }
439431
440
- /* to protect tcep and the page behind it */
441
- local_lock_irq(&tce_page.lock);
442
- tcep = __this_cpu_read(tce_page.page);
432
+ local_irq_disable(); /* to protect tcep and the page behind it */
433
+ tcep = __this_cpu_read(tce_page);
443434
444435 if (!tcep) {
445436 tcep = (__be64 *)__get_free_page(GFP_ATOMIC);
446437 if (!tcep) {
447
- local_unlock_irq(&tce_page.lock);
438
+ local_irq_enable();
448439 return -ENOMEM;
449440 }
450
- __this_cpu_write(tce_page.page, tcep);
441
+ __this_cpu_write(tce_page, tcep);
451442 }
452443
453444 proto_tce = TCE_PCI_READ | TCE_PCI_WRITE;
....@@ -490,7 +481,7 @@
490481
491482 /* error cleanup: caller will clear whole range */
492483
493
- local_unlock_irq(&tce_page.lock);
484
+ local_irq_enable();
494485 return rc;
495486 }
496487