From: Alexander Duyck <alexander.h.duyck@intel.com>
To: konrad.wilk@oracle.com, tglx@linutronix.de, mingo@redhat.com,
hpa@zytor.com, rob@landley.net, akpm@linux-foundation.org,
joerg.roedel@amd.com, bhelgaas@google.com, shuahkhan@gmail.com,
fujita.tomonori@lab.ntt.co.jp
Cc: linux-kernel@vger.kernel.org, x86@kernel.org
Subject: [PATCH v2 1/7] swiotlb: Make io_tlb_end a physical address instead of a virtual one
Date: Thu, 11 Oct 2012 13:34:21 -0700 [thread overview]
Message-ID: <20121011203421.12444.32871.stgit@gitlad.jf.intel.com> (raw)
In-Reply-To: <20121011203010.12444.15503.stgit@gitlad.jf.intel.com>
This change replaces all references to the virtual address for io_tlb_end
with references to the physical address io_tlb_end. The main advantage of
replacing the virtual address with a physical address is that we can avoid
having to do multiple translations from the virtual address to the physical
one needed for testing an existing DMA address.
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
---
lib/swiotlb.c | 24 +++++++++++++-----------
1 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index f114bf6..19aac9f 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -57,7 +57,8 @@ int swiotlb_force;
* swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this
* API.
*/
-static char *io_tlb_start, *io_tlb_end;
+static char *io_tlb_start;
+phys_addr_t io_tlb_end;
/*
* The number of IO TLB blocks (in groups of 64) between io_tlb_start and
@@ -125,14 +126,16 @@ static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev,
void swiotlb_print_info(void)
{
unsigned long bytes = io_tlb_nslabs << IO_TLB_SHIFT;
- phys_addr_t pstart, pend;
+ phys_addr_t pstart;
+ unsigned char *vend;
pstart = virt_to_phys(io_tlb_start);
- pend = virt_to_phys(io_tlb_end);
+ vend = phys_to_virt(io_tlb_end);
printk(KERN_INFO "software IO TLB [mem %#010llx-%#010llx] (%luMB) mapped at [%p-%p]\n",
- (unsigned long long)pstart, (unsigned long long)pend - 1,
- bytes >> 20, io_tlb_start, io_tlb_end - 1);
+ (unsigned long long)pstart,
+ (unsigned long long)io_tlb_end,
+ bytes >> 20, io_tlb_start, vend - 1);
}
void __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
@@ -143,7 +146,7 @@ void __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
io_tlb_nslabs = nslabs;
io_tlb_start = tlb;
- io_tlb_end = io_tlb_start + bytes;
+ io_tlb_end = __pa(io_tlb_start) + bytes;
/*
* Allocate and initialize the free list array. This array is used
@@ -254,7 +257,7 @@ swiotlb_late_init_with_tbl(char *tlb, unsigned long nslabs)
io_tlb_nslabs = nslabs;
io_tlb_start = tlb;
- io_tlb_end = io_tlb_start + bytes;
+ io_tlb_end = virt_to_phys(io_tlb_start) + bytes;
memset(io_tlb_start, 0, bytes);
@@ -304,7 +307,7 @@ cleanup3:
sizeof(int)));
io_tlb_list = NULL;
cleanup2:
- io_tlb_end = NULL;
+ io_tlb_end = 0;
io_tlb_start = NULL;
io_tlb_nslabs = 0;
return -ENOMEM;
@@ -339,8 +342,7 @@ void __init swiotlb_free(void)
static int is_swiotlb_buffer(phys_addr_t paddr)
{
- return paddr >= virt_to_phys(io_tlb_start) &&
- paddr < virt_to_phys(io_tlb_end);
+ return paddr >= virt_to_phys(io_tlb_start) && paddr < io_tlb_end;
}
/*
@@ -938,6 +940,6 @@ EXPORT_SYMBOL(swiotlb_dma_mapping_error);
int
swiotlb_dma_supported(struct device *hwdev, u64 mask)
{
- return swiotlb_virt_to_bus(hwdev, io_tlb_end - 1) <= mask;
+ return phys_to_dma(hwdev, io_tlb_end - 1) <= mask;
}
EXPORT_SYMBOL(swiotlb_dma_supported);
next prev parent reply other threads:[~2012-10-11 20:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-11 20:34 [PATCH v2 0/7] Improve swiotlb performance by using physical addresses Alexander Duyck
2012-10-11 20:34 ` Alexander Duyck [this message]
2012-10-13 12:52 ` [PATCH v2 1/7] swiotlb: Make io_tlb_end a physical address instead of a virtual one Hillf Danton
2012-10-15 15:43 ` Alexander Duyck
2012-10-18 12:41 ` Konrad Rzeszutek Wilk
2012-10-18 15:53 ` Alexander Duyck
2012-10-19 14:18 ` Konrad Rzeszutek Wilk
2012-10-19 16:21 ` Alexander Duyck
2012-10-11 20:34 ` [PATCH v2 2/7] swiotlb: Make io_tlb_start " Alexander Duyck
2012-10-11 20:34 ` [PATCH v2 3/7] swiotlb: Make io_tlb_overflow_buffer a physical address Alexander Duyck
2012-10-11 20:34 ` [PATCH v2 4/7] swiotlb: Return physical addresses when calling swiotlb_tbl_map_single Alexander Duyck
2012-10-11 20:34 ` [PATCH v2 5/7] swiotlb: Use physical addresses for swiotlb_tbl_unmap_single Alexander Duyck
2012-10-11 20:34 ` [PATCH v2 6/7] swiotlb: Use physical addresses instead of virtual in swiotlb_tbl_sync_single Alexander Duyck
2012-10-11 20:34 ` [PATCH v2 7/7] swiotlb: Do not export swiotlb_bounce since there are no external consumers Alexander Duyck
2012-10-12 16:05 ` [PATCH v2 0/7] Improve swiotlb performance by using physical addresses Alexander Duyck
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=20121011203421.12444.32871.stgit@gitlad.jf.intel.com \
--to=alexander.h.duyck@intel.com \
--cc=akpm@linux-foundation.org \
--cc=bhelgaas@google.com \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=hpa@zytor.com \
--cc=joerg.roedel@amd.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rob@landley.net \
--cc=shuahkhan@gmail.com \
--cc=tglx@linutronix.de \
--cc=x86@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