diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2009-05-18 09:32:48 -0400 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2009-05-28 12:14:26 -0400 |
commit | 803b8cb4d9a93b90c67aba2aab7f2c54d595b5b9 (patch) | |
tree | 385fa4952c9014d04501b69a2b4410072f4dd361 /arch | |
parent | 384de72910a7bf96a02a6d8023fe9e16d872beb2 (diff) |
amd-iommu: change dma_dom->next_bit to dma_dom->next_address
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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/include/asm/amd_iommu_types.h | 2 | ||||
-rw-r--r-- | arch/x86/kernel/amd_iommu.c | 17 |
2 files changed, 10 insertions, 9 deletions
diff --git a/arch/x86/include/asm/amd_iommu_types.h b/arch/x86/include/asm/amd_iommu_types.h index eca912931a85..4ff4cf1f0809 100644 --- a/arch/x86/include/asm/amd_iommu_types.h +++ b/arch/x86/include/asm/amd_iommu_types.h | |||
@@ -249,7 +249,7 @@ struct dma_ops_domain { | |||
249 | unsigned long aperture_size; | 249 | unsigned long aperture_size; |
250 | 250 | ||
251 | /* address we start to search for free addresses */ | 251 | /* address we start to search for free addresses */ |
252 | unsigned long next_bit; | 252 | unsigned long next_address; |
253 | 253 | ||
254 | /* address space relevant data */ | 254 | /* address space relevant data */ |
255 | struct aperture_range *aperture[APERTURE_MAX_RANGES]; | 255 | struct aperture_range *aperture[APERTURE_MAX_RANGES]; |
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c index 794163ae97b4..c1a08b9119c9 100644 --- a/arch/x86/kernel/amd_iommu.c +++ b/arch/x86/kernel/amd_iommu.c | |||
@@ -627,13 +627,15 @@ static unsigned long dma_ops_area_alloc(struct device *dev, | |||
627 | u64 dma_mask, | 627 | u64 dma_mask, |
628 | unsigned long start) | 628 | unsigned long start) |
629 | { | 629 | { |
630 | unsigned long next_bit = dom->next_bit % APERTURE_RANGE_PAGES; | 630 | unsigned long next_bit = dom->next_address % APERTURE_RANGE_SIZE; |
631 | int max_index = dom->aperture_size >> APERTURE_RANGE_SHIFT; | 631 | int max_index = dom->aperture_size >> APERTURE_RANGE_SHIFT; |
632 | int i = start >> APERTURE_RANGE_SHIFT; | 632 | int i = start >> APERTURE_RANGE_SHIFT; |
633 | unsigned long boundary_size; | 633 | unsigned long boundary_size; |
634 | unsigned long address = -1; | 634 | unsigned long address = -1; |
635 | unsigned long limit; | 635 | unsigned long limit; |
636 | 636 | ||
637 | next_bit >>= PAGE_SHIFT; | ||
638 | |||
637 | boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1, | 639 | boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1, |
638 | PAGE_SIZE) >> PAGE_SHIFT; | 640 | PAGE_SIZE) >> PAGE_SHIFT; |
639 | 641 | ||
@@ -652,7 +654,7 @@ static unsigned long dma_ops_area_alloc(struct device *dev, | |||
652 | if (address != -1) { | 654 | if (address != -1) { |
653 | address = dom->aperture[i]->offset + | 655 | address = dom->aperture[i]->offset + |
654 | (address << PAGE_SHIFT); | 656 | (address << PAGE_SHIFT); |
655 | dom->next_bit = (address >> PAGE_SHIFT) + pages; | 657 | dom->next_address = address + (pages << PAGE_SHIFT); |
656 | break; | 658 | break; |
657 | } | 659 | } |
658 | 660 | ||
@@ -669,14 +671,12 @@ static unsigned long dma_ops_alloc_addresses(struct device *dev, | |||
669 | u64 dma_mask) | 671 | u64 dma_mask) |
670 | { | 672 | { |
671 | unsigned long address; | 673 | unsigned long address; |
672 | unsigned long start = dom->next_bit << PAGE_SHIFT; | ||
673 | |||
674 | 674 | ||
675 | address = dma_ops_area_alloc(dev, dom, pages, align_mask, | 675 | address = dma_ops_area_alloc(dev, dom, pages, align_mask, |
676 | dma_mask, start); | 676 | dma_mask, dom->next_address); |
677 | 677 | ||
678 | if (address == -1) { | 678 | if (address == -1) { |
679 | dom->next_bit = 0; | 679 | dom->next_address = 0; |
680 | address = dma_ops_area_alloc(dev, dom, pages, align_mask, | 680 | address = dma_ops_area_alloc(dev, dom, pages, align_mask, |
681 | dma_mask, 0); | 681 | dma_mask, 0); |
682 | dom->need_flush = true; | 682 | dom->need_flush = true; |
@@ -704,10 +704,11 @@ static void dma_ops_free_addresses(struct dma_ops_domain *dom, | |||
704 | 704 | ||
705 | BUG_ON(i >= APERTURE_MAX_RANGES || range == NULL); | 705 | BUG_ON(i >= APERTURE_MAX_RANGES || range == NULL); |
706 | 706 | ||
707 | if ((address >> PAGE_SHIFT) >= dom->next_bit) | 707 | if (address >= dom->next_address) |
708 | dom->need_flush = true; | 708 | dom->need_flush = true; |
709 | 709 | ||
710 | address = (address % APERTURE_RANGE_SIZE) >> PAGE_SHIFT; | 710 | address = (address % APERTURE_RANGE_SIZE) >> PAGE_SHIFT; |
711 | |||
711 | iommu_area_free(range->bitmap, address, pages); | 712 | iommu_area_free(range->bitmap, address, pages); |
712 | 713 | ||
713 | } | 714 | } |
@@ -870,7 +871,7 @@ static struct dma_ops_domain *dma_ops_domain_alloc(struct amd_iommu *iommu, | |||
870 | * a valid dma-address. So we can use 0 as error value | 871 | * a valid dma-address. So we can use 0 as error value |
871 | */ | 872 | */ |
872 | dma_dom->aperture[0]->bitmap[0] = 1; | 873 | dma_dom->aperture[0]->bitmap[0] = 1; |
873 | dma_dom->next_bit = 0; | 874 | dma_dom->next_address = 0; |
874 | 875 | ||
875 | dma_dom->need_flush = false; | 876 | dma_dom->need_flush = false; |
876 | dma_dom->target_dev = 0xffff; | 877 | dma_dom->target_dev = 0xffff; |