Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'fixes-for-v3.12' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping

Pull DMA-mapping fix from Marek Szyprowski:
"A bugfix for the IOMMU-based implementation of dma-mapping subsystem
for ARM architecture"

* 'fixes-for-v3.12' of git://git.linaro.org/people/mszyprowski/linux-dma-mapping:
ARM: dma-mapping: Always pass proper prot flags to iommu_map()

+28 -15
+28 -15
arch/arm/mm/dma-mapping.c
··· 1232 1232 break; 1233 1233 1234 1234 len = (j - i) << PAGE_SHIFT; 1235 - ret = iommu_map(mapping->domain, iova, phys, len, 0); 1235 + ret = iommu_map(mapping->domain, iova, phys, len, 1236 + IOMMU_READ|IOMMU_WRITE); 1236 1237 if (ret < 0) 1237 1238 goto fail; 1238 1239 iova += len; ··· 1432 1431 GFP_KERNEL); 1433 1432 } 1434 1433 1434 + static int __dma_direction_to_prot(enum dma_data_direction dir) 1435 + { 1436 + int prot; 1437 + 1438 + switch (dir) { 1439 + case DMA_BIDIRECTIONAL: 1440 + prot = IOMMU_READ | IOMMU_WRITE; 1441 + break; 1442 + case DMA_TO_DEVICE: 1443 + prot = IOMMU_READ; 1444 + break; 1445 + case DMA_FROM_DEVICE: 1446 + prot = IOMMU_WRITE; 1447 + break; 1448 + default: 1449 + prot = 0; 1450 + } 1451 + 1452 + return prot; 1453 + } 1454 + 1435 1455 /* 1436 1456 * Map a part of the scatter-gather list into contiguous io address space 1437 1457 */ ··· 1466 1444 int ret = 0; 1467 1445 unsigned int count; 1468 1446 struct scatterlist *s; 1447 + int prot; 1469 1448 1470 1449 size = PAGE_ALIGN(size); 1471 1450 *handle = DMA_ERROR_CODE; ··· 1483 1460 !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs)) 1484 1461 __dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir); 1485 1462 1486 - ret = iommu_map(mapping->domain, iova, phys, len, 0); 1463 + prot = __dma_direction_to_prot(dir); 1464 + 1465 + ret = iommu_map(mapping->domain, iova, phys, len, prot); 1487 1466 if (ret < 0) 1488 1467 goto fail; 1489 1468 count += len >> PAGE_SHIFT; ··· 1690 1665 if (dma_addr == DMA_ERROR_CODE) 1691 1666 return dma_addr; 1692 1667 1693 - switch (dir) { 1694 - case DMA_BIDIRECTIONAL: 1695 - prot = IOMMU_READ | IOMMU_WRITE; 1696 - break; 1697 - case DMA_TO_DEVICE: 1698 - prot = IOMMU_READ; 1699 - break; 1700 - case DMA_FROM_DEVICE: 1701 - prot = IOMMU_WRITE; 1702 - break; 1703 - default: 1704 - prot = 0; 1705 - } 1668 + prot = __dma_direction_to_prot(dir); 1706 1669 1707 1670 ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, prot); 1708 1671 if (ret < 0)