History

Merge tag 'arm-swiotlb-5.3' of git://git.infradead.org/users/hch/dma-mapping

Pull arm swiotlb support from Christoph Hellwig: "This fixes a cascade of regressions that originally started with the addition of the ia64 port, but only got fatal once we removed most uses of block layer bounce buffering in Linux 4.18. The reason is that while the original i386/PAE code that was the first architecture that supported > 4GB of memory without an iommu decided to leave bounce buffering to the subsystems, which in those days just mean block and networking as no one else consumed arbitrary userspace memory. Later with ia64, x86_64 and other ports we assumed that either an iommu or something that fakes it up ("software IOTLB" in beautiful Intel speak) is present and that subsystems can rely on that for dealing with addressing limitations in devices. Except that the ARM LPAE scheme that added larger physical address to 32-bit ARM did not follow that scheme and thus only worked by chance and only for block and networking I/O directly to highmem. Long story, short fix - add swiotlb support to arm when build for LPAE platforms, which actuallys turns out to be pretty trivial with the modern dma-direct / swiotlb code to fix the Linux 4.18-ish regression" * tag 'arm-swiotlb-5.3' of git://git.infradead.org/users/hch/dma-mapping: arm: use swiotlb for bounce buffering on LPAE configs dma-mapping: check pfn validity in dma_common_{mmap,get_sgtable}

Linus Torvalds committed 7 years ago

Commit 234172f2 parents 35fca9f ad3c7b15 files · +85 −3Browse files

Showing the changes to kernel (1 of 5 files). Show all

Unified · Split

kernel/dma/mapping.c+11−2
@@ -116,11 +116,16 @@ int dma_common_get_sgtable(struct device *dev, struct sg_table *sgt, · 115 unmodified lines
116116 int ret;
117117
118118 if (!dev_is_dma_coherent(dev)) {
119+ unsigned long pfn;
120+
119121 if (!IS_ENABLED(CONFIG_ARCH_HAS_DMA_COHERENT_TO_PFN))
120122 return -ENXIO;
121123
122− page = pfn_to_page(arch_dma_coherent_to_pfn(dev, cpu_addr,
123− dma_addr));
124+ /* If the PFN is not valid, we do not have a struct page */
125+ pfn = arch_dma_coherent_to_pfn(dev, cpu_addr, dma_addr);
126+ if (!pfn_valid(pfn))
127+ return -ENXIO;
128+ page = pfn_to_page(pfn);
124129 } else {
125130 page = virt_to_page(cpu_addr);
126131 }
@@ -170,7 +175,11 @@ int dma_common_mmap(struct device *dev, struct vm_area_struct *vma, · 43 unmodified lines
170175 if (!dev_is_dma_coherent(dev)) {
171176 if (!IS_ENABLED(CONFIG_ARCH_HAS_DMA_COHERENT_TO_PFN))
172177 return -ENXIO;
178+
179+ /* If the PFN is not valid, we do not have a struct page */
173180 pfn = arch_dma_coherent_to_pfn(dev, cpu_addr, dma_addr);
181+ if (!pfn_valid(pfn))
182+ return -ENXIO;
174183 } else {
175184 pfn = page_to_pfn(virt_to_page(cpu_addr));
176185 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t