From: Joerg Roedel <joerg.roedel@amd.com>
To: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Cc: Joerg Roedel <joerg.roedel@amd.com>
Subject: [PATCH 05/12] amd-iommu: change dma_dom->next_bit to dma_dom->next_address
Date: Fri, 22 May 2009 14:21:26 +0200 [thread overview]
Message-ID: <1242994893-28902-6-git-send-email-joerg.roedel@amd.com> (raw)
In-Reply-To: <1242994893-28902-1-git-send-email-joerg.roedel@amd.com>
[ impact: code simplification ]
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 | 2 +-
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 eca9129..4ff4cf1 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 {
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];
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 794163a..c1a08b9 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,
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;
--
1.6.3.1
next prev parent reply other threads:[~2009-05-22 12:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-22 12:21 [PATCH 0/12] extended allocator for amd iommu Joerg Roedel
2009-05-22 12:21 ` [PATCH 01/12] amd-iommu: introduce aperture_range structure Joerg Roedel
2009-05-22 12:21 ` [PATCH 02/12] amd-iommu: move page table allocation code to seperate function Joerg Roedel
2009-05-22 12:21 ` [PATCH 03/12] amd-iommu: handle page table allocation failures in dma_ops code Joerg Roedel
2009-05-22 12:21 ` [PATCH 04/12] amd-iommu: make address allocator aware of multiple aperture ranges Joerg Roedel
2009-05-22 12:21 ` Joerg Roedel [this message]
2009-05-22 12:21 ` [PATCH 06/12] amd-iommu: move aperture_range allocation code to seperate function Joerg Roedel
2009-05-22 12:21 ` [PATCH 07/12] amd-iommu: handle exlusion ranges and unity mappings in alloc_new_range Joerg Roedel
2009-05-22 12:21 ` [PATCH 08/12] amd-iommu: enlarge the aperture dynamically Joerg Roedel
2009-05-22 12:21 ` [PATCH 09/12] amd-iommu: remove amd_iommu_size kernel parameter Joerg Roedel
2009-05-22 12:21 ` [PATCH 10/12] amd-iommu: disable round-robin allocator for CONFIG_IOMMU_STRESS Joerg Roedel
2009-05-22 12:21 ` [PATCH 11/12] amd-iommu: don't preallocate page tables with CONFIG_IOMMU_STRESS Joerg Roedel
2009-05-22 12:21 ` [PATCH 12/12] amd-iommu: don't free dma adresses below 512MB " Joerg Roedel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1242994893-28902-6-git-send-email-joerg.roedel@amd.com \
--to=joerg.roedel@amd.com \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®