Loading arch/arm/mm/dma-mapping.c +22 −3 Original line number Diff line number Diff line Loading @@ -1811,7 +1811,7 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, int ret = 0; unsigned int count; struct scatterlist *s; int prot; int prot = 0; size = PAGE_ALIGN(size); *handle = ARM_MAPPING_ERROR; Loading @@ -1820,6 +1820,11 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, if (iova == ARM_MAPPING_ERROR) return -ENOMEM; /* * Check for coherency. */ prot |= is_coherent ? IOMMU_CACHE : 0; for (count = 0, s = sg; count < (size >> PAGE_SHIFT); s = sg_next(s)) { phys_addr_t phys = page_to_phys(sg_page(s)); unsigned int len = PAGE_ALIGN(s->offset + s->length); Loading @@ -1827,7 +1832,7 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, if (!is_coherent && (attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0) __dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir); prot = __dma_info_to_prot(dir, attrs); prot |= __dma_info_to_prot(dir, attrs); ret = iommu_map(mapping->domain, iova, phys, len, prot); if (ret < 0) Loading Loading @@ -1931,9 +1936,23 @@ int arm_iommu_map_sg(struct device *dev, struct scatterlist *sg, dma_addr_t iova; int prot = __dma_info_to_prot(dir, attrs); bool coherent; /* * This is used to check if there are any unaligned offset/size * given in the scatter list. */ bool unaligned_offset_size = false; for_each_sg(sg, s, nents, i) for_each_sg(sg, s, nents, i) { total_length += s->length; if ((s->offset & ~PAGE_MASK) || (s->length & ~PAGE_MASK)) { unaligned_offset_size = true; break; } } if (unaligned_offset_size) return __iommu_map_sg(dev, sg, nents, dir, attrs, is_dma_coherent(dev, attrs, false)); iova = __alloc_iova(mapping, total_length); if (iova == ARM_MAPPING_ERROR) Loading Loading
arch/arm/mm/dma-mapping.c +22 −3 Original line number Diff line number Diff line Loading @@ -1811,7 +1811,7 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, int ret = 0; unsigned int count; struct scatterlist *s; int prot; int prot = 0; size = PAGE_ALIGN(size); *handle = ARM_MAPPING_ERROR; Loading @@ -1820,6 +1820,11 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, if (iova == ARM_MAPPING_ERROR) return -ENOMEM; /* * Check for coherency. */ prot |= is_coherent ? IOMMU_CACHE : 0; for (count = 0, s = sg; count < (size >> PAGE_SHIFT); s = sg_next(s)) { phys_addr_t phys = page_to_phys(sg_page(s)); unsigned int len = PAGE_ALIGN(s->offset + s->length); Loading @@ -1827,7 +1832,7 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, if (!is_coherent && (attrs & DMA_ATTR_SKIP_CPU_SYNC) == 0) __dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir); prot = __dma_info_to_prot(dir, attrs); prot |= __dma_info_to_prot(dir, attrs); ret = iommu_map(mapping->domain, iova, phys, len, prot); if (ret < 0) Loading Loading @@ -1931,9 +1936,23 @@ int arm_iommu_map_sg(struct device *dev, struct scatterlist *sg, dma_addr_t iova; int prot = __dma_info_to_prot(dir, attrs); bool coherent; /* * This is used to check if there are any unaligned offset/size * given in the scatter list. */ bool unaligned_offset_size = false; for_each_sg(sg, s, nents, i) for_each_sg(sg, s, nents, i) { total_length += s->length; if ((s->offset & ~PAGE_MASK) || (s->length & ~PAGE_MASK)) { unaligned_offset_size = true; break; } } if (unaligned_offset_size) return __iommu_map_sg(dev, sg, nents, dir, attrs, is_dma_coherent(dev, attrs, false)); iova = __alloc_iova(mapping, total_length); if (iova == ARM_MAPPING_ERROR) Loading