]> git.karo-electronics.de Git - linux-beck.git/commitdiff
amd-iommu: change dma_dom->next_bit to dma_dom->next_address
authorJoerg Roedel <joerg.roedel@amd.com>
Mon, 18 May 2009 13:32:48 +0000 (15:32 +0200)
committerJoerg Roedel <joerg.roedel@amd.com>
Thu, 28 May 2009 16:14:26 +0000 (18:14 +0200)
Simplify the code a little bit by using the same unit for all address
space related state in the dma_ops domain structure.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
arch/x86/include/asm/amd_iommu_types.h
arch/x86/kernel/amd_iommu.c

index eca912931a85ac1c7f1d09fe1eec22952b67f87f..4ff4cf1f08098b3b4d68c03d3cc4b1eeeed5d1cf 100644 (file)
@@ -249,7 +249,7 @@ struct dma_ops_domain {
        unsigned long aperture_size;
 
        /* address we start to search for free addresses */
-       unsigned long next_bit;
+       unsigned long next_address;
 
        /* address space relevant data */
        struct aperture_range *aperture[APERTURE_MAX_RANGES];
index 794163ae97b49e2c93a7e2f785bf2ebf7e8fa306..c1a08b9119c9d67249befe9cd9a7abfbb8b36480 100644 (file)
@@ -627,13 +627,15 @@ static unsigned long dma_ops_area_alloc(struct device *dev,
                                        u64 dma_mask,
                                        unsigned long start)
 {
-       unsigned long next_bit = dom->next_bit % APERTURE_RANGE_PAGES;
+       unsigned long next_bit = dom->next_address % APERTURE_RANGE_SIZE;
        int max_index = dom->aperture_size >> APERTURE_RANGE_SHIFT;
        int i = start >> APERTURE_RANGE_SHIFT;
        unsigned long boundary_size;
        unsigned long address = -1;
        unsigned long limit;
 
+       next_bit >>= PAGE_SHIFT;
+
        boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1,
                        PAGE_SIZE) >> PAGE_SHIFT;
 
@@ -652,7 +654,7 @@ static unsigned long dma_ops_area_alloc(struct device *dev,
                if (address != -1) {
                        address = dom->aperture[i]->offset +
                                  (address << PAGE_SHIFT);
-                       dom->next_bit = (address >> PAGE_SHIFT) + pages;
+                       dom->next_address = address + (pages << PAGE_SHIFT);
                        break;
                }
 
@@ -669,14 +671,12 @@ static unsigned long dma_ops_alloc_addresses(struct device *dev,
                                             u64 dma_mask)
 {
        unsigned long address;
-       unsigned long start = dom->next_bit << PAGE_SHIFT;
-
 
        address = dma_ops_area_alloc(dev, dom, pages, align_mask,
-                                    dma_mask, start);
+                                    dma_mask, dom->next_address);
 
        if (address == -1) {
-               dom->next_bit = 0;
+               dom->next_address = 0;
                address = dma_ops_area_alloc(dev, dom, pages, align_mask,
                                             dma_mask, 0);
                dom->need_flush = true;
@@ -704,10 +704,11 @@ static void dma_ops_free_addresses(struct dma_ops_domain *dom,
 
        BUG_ON(i >= APERTURE_MAX_RANGES || range == NULL);
 
-       if ((address >> PAGE_SHIFT) >= dom->next_bit)
+       if (address >= dom->next_address)
                dom->need_flush = true;
 
        address = (address % APERTURE_RANGE_SIZE) >> PAGE_SHIFT;
+
        iommu_area_free(range->bitmap, address, pages);
 
 }
@@ -870,7 +871,7 @@ static struct dma_ops_domain *dma_ops_domain_alloc(struct amd_iommu *iommu,
         * a valid dma-address. So we can use 0 as error value
         */
        dma_dom->aperture[0]->bitmap[0] = 1;
-       dma_dom->next_bit = 0;
+       dma_dom->next_address = 0;
 
        dma_dom->need_flush = false;
        dma_dom->target_dev = 0xffff;