[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1450822888-22590-8-git-send-email-joro@8bytes.org>
Date: Tue, 22 Dec 2015 23:21:12 +0100
From: Joerg Roedel <joro@...tes.org>
To: iommu@...ts.linux-foundation.org
Cc: linux-kernel@...r.kernel.org, joro@...tes.org, jroedel@...e.de
Subject: [PATCH 07/23] iommu/amd: Add dma_ops_aperture_alloc() function
From: Joerg Roedel <jroedel@...e.de>
Make this a wrapper around iommu_ops_area_alloc() for now
and add more logic to this function later on.
Signed-off-by: Joerg Roedel <jroedel@...e.de>
---
drivers/iommu/amd_iommu.c | 37 +++++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 1d1ef37..be0e81a 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -1518,6 +1518,28 @@ out_free:
return -ENOMEM;
}
+static dma_addr_t dma_ops_aperture_alloc(struct aperture_range *range,
+ unsigned long pages,
+ unsigned long next_bit,
+ unsigned long dma_mask,
+ unsigned long boundary_size,
+ unsigned long align_mask)
+{
+ unsigned long offset, limit, flags;
+ dma_addr_t address;
+
+ offset = range->offset >> PAGE_SHIFT;
+ limit = iommu_device_max_index(APERTURE_RANGE_PAGES, offset,
+ dma_mask >> PAGE_SHIFT);
+
+ spin_lock_irqsave(&range->bitmap_lock, flags);
+ address = iommu_area_alloc(range->bitmap, limit, next_bit, pages,
+ offset, boundary_size, align_mask);
+ spin_unlock_irqrestore(&range->bitmap_lock, flags);
+
+ return address;
+}
+
static unsigned long dma_ops_area_alloc(struct device *dev,
struct dma_ops_domain *dom,
unsigned int pages,
@@ -1530,8 +1552,6 @@ static unsigned long dma_ops_area_alloc(struct device *dev,
int i = start >> APERTURE_RANGE_SHIFT;
unsigned long boundary_size, mask;
unsigned long address = -1;
- unsigned long limit;
- unsigned long flags;
next_bit >>= PAGE_SHIFT;
@@ -1541,19 +1561,12 @@ static unsigned long dma_ops_area_alloc(struct device *dev,
1UL << (BITS_PER_LONG - PAGE_SHIFT);
for (;i < max_index; ++i) {
- unsigned long offset = dom->aperture[i]->offset >> PAGE_SHIFT;
-
if (dom->aperture[i]->offset >= dma_mask)
break;
- limit = iommu_device_max_index(APERTURE_RANGE_PAGES, offset,
- dma_mask >> PAGE_SHIFT);
-
- spin_lock_irqsave(&dom->aperture[i]->bitmap_lock, flags);
- address = iommu_area_alloc(dom->aperture[i]->bitmap,
- limit, next_bit, pages, offset,
- boundary_size, align_mask);
- spin_unlock_irqrestore(&dom->aperture[i]->bitmap_lock, flags);
+ address = dma_ops_aperture_alloc(dom->aperture[i], pages,
+ next_bit, dma_mask,
+ boundary_size, align_mask);
if (address != -1) {
address = dom->aperture[i]->offset +
(address << PAGE_SHIFT);
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists