Loading arch/arm64/include/asm/dma-iommu.h +1 −3 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ struct dma_iommu_mapping { void *bitmap; size_t bits; unsigned int order; dma_addr_t base; spinlock_t lock; Loading @@ -26,8 +25,7 @@ struct dma_iommu_mapping { #ifdef CONFIG_ARM64_DMA_USE_IOMMU struct dma_iommu_mapping * arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size, int order); arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size); void arm_iommu_release_mapping(struct dma_iommu_mapping *mapping); Loading arch/arm64/mm/dma-mapping.c +10 −18 Original line number Diff line number Diff line Loading @@ -1143,11 +1143,8 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping, if (order > CONFIG_ARM64_DMA_IOMMU_ALIGNMENT) order = CONFIG_ARM64_DMA_IOMMU_ALIGNMENT; count = ((PAGE_ALIGN(size) >> PAGE_SHIFT) + (1 << mapping->order) - 1) >> mapping->order; if (order > mapping->order) align = (1 << (order - mapping->order)) - 1; count = PAGE_ALIGN(size) >> PAGE_SHIFT; align = (1 << order) - 1; spin_lock_irqsave(&mapping->lock, flags); start = bitmap_find_next_zero_area(mapping->bitmap, mapping->bits, 0, Loading @@ -1160,16 +1157,14 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping, bitmap_set(mapping->bitmap, start, count); spin_unlock_irqrestore(&mapping->lock, flags); return mapping->base + (start << (mapping->order + PAGE_SHIFT)); return mapping->base + (start << PAGE_SHIFT); } static inline void __free_iova(struct dma_iommu_mapping *mapping, dma_addr_t addr, size_t size) { unsigned int start = (addr - mapping->base) >> (mapping->order + PAGE_SHIFT); unsigned int count = ((size >> PAGE_SHIFT) + (1 << mapping->order) - 1) >> mapping->order; unsigned int start = (addr - mapping->base) >> PAGE_SHIFT; unsigned int count = size >> PAGE_SHIFT; unsigned long flags; spin_lock_irqsave(&mapping->lock, flags); Loading Loading @@ -1984,8 +1979,7 @@ const struct dma_map_ops iommu_coherent_ops = { * arm_iommu_create_mapping * @bus: pointer to the bus holding the client device (for IOMMU calls) * @base: start address of the valid IO address space * @size: size of the valid IO address space * @order: accuracy of the IO addresses allocations * @size: maximum size of the valid IO address space * * Creates a mapping structure which holds information about used/unused * IO address ranges, which is required to perform memory allocation and Loading @@ -1995,15 +1989,14 @@ const struct dma_map_ops iommu_coherent_ops = { * arm_iommu_attach_device function. */ struct dma_iommu_mapping * arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size, int order) arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size) { unsigned int count = size >> (PAGE_SHIFT + order); unsigned int bitmap_size = BITS_TO_LONGS(count) * sizeof(long); unsigned int bits = size >> PAGE_SHIFT; unsigned int bitmap_size = BITS_TO_LONGS(bits) * sizeof(long); struct dma_iommu_mapping *mapping; int err = -ENOMEM; if (!count) if (!bitmap_size) return ERR_PTR(-EINVAL); mapping = kzalloc(sizeof(struct dma_iommu_mapping), GFP_KERNEL); Loading @@ -2016,7 +2009,6 @@ arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size, mapping->base = base; mapping->bits = BITS_PER_BYTE * bitmap_size; mapping->order = order; spin_lock_init(&mapping->lock); mapping->domain = iommu_domain_alloc(bus); Loading Loading
arch/arm64/include/asm/dma-iommu.h +1 −3 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ struct dma_iommu_mapping { void *bitmap; size_t bits; unsigned int order; dma_addr_t base; spinlock_t lock; Loading @@ -26,8 +25,7 @@ struct dma_iommu_mapping { #ifdef CONFIG_ARM64_DMA_USE_IOMMU struct dma_iommu_mapping * arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size, int order); arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size); void arm_iommu_release_mapping(struct dma_iommu_mapping *mapping); Loading
arch/arm64/mm/dma-mapping.c +10 −18 Original line number Diff line number Diff line Loading @@ -1143,11 +1143,8 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping, if (order > CONFIG_ARM64_DMA_IOMMU_ALIGNMENT) order = CONFIG_ARM64_DMA_IOMMU_ALIGNMENT; count = ((PAGE_ALIGN(size) >> PAGE_SHIFT) + (1 << mapping->order) - 1) >> mapping->order; if (order > mapping->order) align = (1 << (order - mapping->order)) - 1; count = PAGE_ALIGN(size) >> PAGE_SHIFT; align = (1 << order) - 1; spin_lock_irqsave(&mapping->lock, flags); start = bitmap_find_next_zero_area(mapping->bitmap, mapping->bits, 0, Loading @@ -1160,16 +1157,14 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping, bitmap_set(mapping->bitmap, start, count); spin_unlock_irqrestore(&mapping->lock, flags); return mapping->base + (start << (mapping->order + PAGE_SHIFT)); return mapping->base + (start << PAGE_SHIFT); } static inline void __free_iova(struct dma_iommu_mapping *mapping, dma_addr_t addr, size_t size) { unsigned int start = (addr - mapping->base) >> (mapping->order + PAGE_SHIFT); unsigned int count = ((size >> PAGE_SHIFT) + (1 << mapping->order) - 1) >> mapping->order; unsigned int start = (addr - mapping->base) >> PAGE_SHIFT; unsigned int count = size >> PAGE_SHIFT; unsigned long flags; spin_lock_irqsave(&mapping->lock, flags); Loading Loading @@ -1984,8 +1979,7 @@ const struct dma_map_ops iommu_coherent_ops = { * arm_iommu_create_mapping * @bus: pointer to the bus holding the client device (for IOMMU calls) * @base: start address of the valid IO address space * @size: size of the valid IO address space * @order: accuracy of the IO addresses allocations * @size: maximum size of the valid IO address space * * Creates a mapping structure which holds information about used/unused * IO address ranges, which is required to perform memory allocation and Loading @@ -1995,15 +1989,14 @@ const struct dma_map_ops iommu_coherent_ops = { * arm_iommu_attach_device function. */ struct dma_iommu_mapping * arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size, int order) arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size) { unsigned int count = size >> (PAGE_SHIFT + order); unsigned int bitmap_size = BITS_TO_LONGS(count) * sizeof(long); unsigned int bits = size >> PAGE_SHIFT; unsigned int bitmap_size = BITS_TO_LONGS(bits) * sizeof(long); struct dma_iommu_mapping *mapping; int err = -ENOMEM; if (!count) if (!bitmap_size) return ERR_PTR(-EINVAL); mapping = kzalloc(sizeof(struct dma_iommu_mapping), GFP_KERNEL); Loading @@ -2016,7 +2009,6 @@ arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size, mapping->base = base; mapping->bits = BITS_PER_BYTE * bitmap_size; mapping->order = order; spin_lock_init(&mapping->lock); mapping->domain = iommu_domain_alloc(bus); Loading