hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/s390/pci/pci_dma.c
....@@ -10,12 +10,10 @@
1010 #include <linux/slab.h>
1111 #include <linux/export.h>
1212 #include <linux/iommu-helper.h>
13
-#include <linux/dma-mapping.h>
13
+#include <linux/dma-map-ops.h>
1414 #include <linux/vmalloc.h>
1515 #include <linux/pci.h>
1616 #include <asm/pci_dma.h>
17
-
18
-#define S390_MAPPING_ERROR (~(dma_addr_t) 0x0)
1917
2018 static struct kmem_cache *dma_region_table_cache;
2119 static struct kmem_cache *dma_page_table_cache;
....@@ -263,13 +261,11 @@
263261 unsigned long start, int size)
264262 {
265263 struct zpci_dev *zdev = to_zpci(to_pci_dev(dev));
266
- unsigned long boundary_size;
267264
268
- boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1,
269
- PAGE_SIZE) >> PAGE_SHIFT;
270265 return iommu_area_alloc(zdev->iommu_bitmap, zdev->iommu_pages,
271266 start, size, zdev->start_dma >> PAGE_SHIFT,
272
- boundary_size, 0);
267
+ dma_get_seg_boundary_nr_pages(dev, PAGE_SHIFT),
268
+ 0);
273269 }
274270
275271 static dma_addr_t dma_alloc_address(struct device *dev, int size)
....@@ -301,7 +297,7 @@
301297
302298 out_error:
303299 spin_unlock_irqrestore(&zdev->iommu_bitmap_lock, flags);
304
- return S390_MAPPING_ERROR;
300
+ return DMA_MAPPING_ERROR;
305301 }
306302
307303 static void dma_free_address(struct device *dev, dma_addr_t dma_addr, int size)
....@@ -349,7 +345,7 @@
349345 /* This rounds up number of pages based on size and offset */
350346 nr_pages = iommu_num_pages(pa, size, PAGE_SIZE);
351347 dma_addr = dma_alloc_address(dev, nr_pages);
352
- if (dma_addr == S390_MAPPING_ERROR) {
348
+ if (dma_addr == DMA_MAPPING_ERROR) {
353349 ret = -ENOSPC;
354350 goto out_err;
355351 }
....@@ -372,7 +368,7 @@
372368 out_err:
373369 zpci_err("map error:\n");
374370 zpci_err_dma(ret, pa);
375
- return S390_MAPPING_ERROR;
371
+ return DMA_MAPPING_ERROR;
376372 }
377373
378374 static void s390_dma_unmap_pages(struct device *dev, dma_addr_t dma_addr,
....@@ -406,7 +402,7 @@
406402 dma_addr_t map;
407403
408404 size = PAGE_ALIGN(size);
409
- page = alloc_pages(flag, get_order(size));
405
+ page = alloc_pages(flag | __GFP_ZERO, get_order(size));
410406 if (!page)
411407 return NULL;
412408
....@@ -449,7 +445,7 @@
449445 int ret;
450446
451447 dma_addr_base = dma_alloc_address(dev, nr_pages);
452
- if (dma_addr_base == S390_MAPPING_ERROR)
448
+ if (dma_addr_base == DMA_MAPPING_ERROR)
453449 return -ENOMEM;
454450
455451 dma_addr = dma_addr_base;
....@@ -496,7 +492,7 @@
496492 for (i = 1; i < nr_elements; i++) {
497493 s = sg_next(s);
498494
499
- s->dma_address = S390_MAPPING_ERROR;
495
+ s->dma_address = DMA_MAPPING_ERROR;
500496 s->dma_length = 0;
501497
502498 if (s->offset || (size & ~PAGE_MASK) ||
....@@ -546,11 +542,6 @@
546542 }
547543 }
548544
549
-static int s390_mapping_error(struct device *dev, dma_addr_t dma_addr)
550
-{
551
- return dma_addr == S390_MAPPING_ERROR;
552
-}
553
-
554545 int zpci_dma_init_device(struct zpci_dev *zdev)
555546 {
556547 int rc;
....@@ -675,16 +666,19 @@
675666 .unmap_sg = s390_dma_unmap_sg,
676667 .map_page = s390_dma_map_pages,
677668 .unmap_page = s390_dma_unmap_pages,
678
- .mapping_error = s390_mapping_error,
669
+ .mmap = dma_common_mmap,
670
+ .get_sgtable = dma_common_get_sgtable,
671
+ .alloc_pages = dma_common_alloc_pages,
672
+ .free_pages = dma_common_free_pages,
679673 /* dma_supported is unconditionally true without a callback */
680674 };
681675 EXPORT_SYMBOL_GPL(s390_pci_dma_ops);
682676
683677 static int __init s390_iommu_setup(char *str)
684678 {
685
- if (!strncmp(str, "strict", 6))
679
+ if (!strcmp(str, "strict"))
686680 s390_iommu_strict = 1;
687
- return 0;
681
+ return 1;
688682 }
689683
690684 __setup("s390_iommu=", s390_iommu_setup);