hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/arch/sparc/kernel/iommu.c
....@@ -10,7 +10,7 @@
1010 #include <linux/slab.h>
1111 #include <linux/delay.h>
1212 #include <linux/device.h>
13
-#include <linux/dma-mapping.h>
13
+#include <linux/dma-map-ops.h>
1414 #include <linux/errno.h>
1515 #include <linux/iommu-helper.h>
1616 #include <linux/bitmap.h>
....@@ -108,10 +108,9 @@
108108 /* Allocate and initialize the free area map. */
109109 sz = num_tsb_entries / 8;
110110 sz = (sz + 7UL) & ~7UL;
111
- iommu->tbl.map = kmalloc_node(sz, GFP_KERNEL, numa_node);
111
+ iommu->tbl.map = kzalloc_node(sz, GFP_KERNEL, numa_node);
112112 if (!iommu->tbl.map)
113113 return -ENOMEM;
114
- memset(iommu->tbl.map, 0, sz);
115114
116115 iommu_tbl_pool_init(&iommu->tbl, num_tsb_entries, IO_PAGE_SHIFT,
117116 (tlb_type != hypervisor ? iommu_flushall : NULL),
....@@ -315,7 +314,7 @@
315314 bad_no_ctx:
316315 if (printk_ratelimit())
317316 WARN_ON(1);
318
- return SPARC_MAPPING_ERROR;
317
+ return DMA_MAPPING_ERROR;
319318 }
320319
321320 static void strbuf_flush(struct strbuf *strbuf, struct iommu *iommu,
....@@ -473,8 +472,7 @@
473472 outs->dma_length = 0;
474473
475474 max_seg_size = dma_get_max_seg_size(dev);
476
- seg_boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1,
477
- IO_PAGE_SIZE) >> IO_PAGE_SHIFT;
475
+ seg_boundary_size = dma_get_seg_boundary_nr_pages(dev, IO_PAGE_SHIFT);
478476 base_shift = iommu->tbl.table_map_base >> IO_PAGE_SHIFT;
479477 for_each_sg(sglist, s, nelems, i) {
480478 unsigned long paddr, npages, entry, out_entry = 0, slen;
....@@ -548,7 +546,7 @@
548546
549547 if (outcount < incount) {
550548 outs = sg_next(outs);
551
- outs->dma_address = SPARC_MAPPING_ERROR;
549
+ outs->dma_address = DMA_MAPPING_ERROR;
552550 outs->dma_length = 0;
553551 }
554552
....@@ -574,7 +572,7 @@
574572 iommu_tbl_range_free(&iommu->tbl, vaddr, npages,
575573 IOMMU_ERROR_CODE);
576574
577
- s->dma_address = SPARC_MAPPING_ERROR;
575
+ s->dma_address = DMA_MAPPING_ERROR;
578576 s->dma_length = 0;
579577 }
580578 if (s == outs)
....@@ -742,24 +740,16 @@
742740 spin_unlock_irqrestore(&iommu->lock, flags);
743741 }
744742
745
-static int dma_4u_mapping_error(struct device *dev, dma_addr_t dma_addr)
746
-{
747
- return dma_addr == SPARC_MAPPING_ERROR;
748
-}
749
-
750743 static int dma_4u_supported(struct device *dev, u64 device_mask)
751744 {
752745 struct iommu *iommu = dev->archdata.iommu;
753746
754
- if (device_mask > DMA_BIT_MASK(32))
755
- return 0;
756
- if ((device_mask & iommu->dma_addr_mask) == iommu->dma_addr_mask)
747
+ if (ali_sound_dma_hack(dev, device_mask))
757748 return 1;
758
-#ifdef CONFIG_PCI
759
- if (dev_is_pci(dev))
760
- return pci64_dma_supported(to_pci_dev(dev), device_mask);
761
-#endif
762
- return 0;
749
+
750
+ if (device_mask < iommu->dma_addr_mask)
751
+ return 0;
752
+ return 1;
763753 }
764754
765755 static const struct dma_map_ops sun4u_dma_ops = {
....@@ -772,7 +762,6 @@
772762 .sync_single_for_cpu = dma_4u_sync_single_for_cpu,
773763 .sync_sg_for_cpu = dma_4u_sync_sg_for_cpu,
774764 .dma_supported = dma_4u_supported,
775
- .mapping_error = dma_4u_mapping_error,
776765 };
777766
778767 const struct dma_map_ops *dma_ops = &sun4u_dma_ops;