From: Konrad Rzeszutek Wilk <konrad@kernel.org>
To: Alexander Duyck <alexander.h.duyck@intel.com>
Cc: 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,
linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
x86@kernel.org
Subject: Re: [RFC PATCH 1/7] swiotlb: Instead of tracking the end of the swiotlb region just calculate it
Date: Thu, 4 Oct 2012 09:01:08 -0400 [thread overview]
Message-ID: <20121004130107.GB9158@phenom.dumpdata.com> (raw)
In-Reply-To: <20121004003847.5016.50978.stgit@gitlad.jf.intel.com>
On Wed, Oct 03, 2012 at 05:38:47PM -0700, Alexander Duyck wrote:
> In the case of swiotlb we already have the start of the region and the number
> of slabs that give us the region size. Instead of having to call
> virt_to_phys on two pointers we can just take advantage of the fact that the
> region is linear and just compute the end based on the start plus the size.
Why not take advantage of 'the fact that the region is linear' and just
pre-compute the end in swiotlb_init_with_tbl?
That way the logic in is_swiotlb_buffer is even simpler?
>
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
> ---
>
> lib/swiotlb.c | 25 ++++++++++++-------------
> 1 files changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/lib/swiotlb.c b/lib/swiotlb.c
> index f114bf6..5cc4d4e 100644
> --- a/lib/swiotlb.c
> +++ b/lib/swiotlb.c
> @@ -57,11 +57,11 @@ 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;
>
> /*
> - * The number of IO TLB blocks (in groups of 64) between io_tlb_start and
> - * io_tlb_end. This is command line adjustable via setup_io_tlb_npages.
> + * The number of IO TLB blocks (in groups of 64).
> + * This is command line adjustable via setup_io_tlb_npages.
> */
> static unsigned long io_tlb_nslabs;
>
> @@ -128,11 +128,11 @@ void swiotlb_print_info(void)
> phys_addr_t pstart, pend;
>
> pstart = virt_to_phys(io_tlb_start);
> - pend = virt_to_phys(io_tlb_end);
> + pend = pstart + bytes;
>
> 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);
> + bytes >> 20, io_tlb_start, io_tlb_start + bytes - 1);
> }
>
> void __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
> @@ -143,12 +143,10 @@ 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;
>
> /*
> * Allocate and initialize the free list array. This array is used
> * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE
> - * between io_tlb_start and io_tlb_end.
> */
> io_tlb_list = alloc_bootmem_pages(PAGE_ALIGN(io_tlb_nslabs * sizeof(int)));
> for (i = 0; i < io_tlb_nslabs; i++)
> @@ -254,14 +252,12 @@ 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;
>
> memset(io_tlb_start, 0, bytes);
>
> /*
> * Allocate and initialize the free list array. This array is used
> * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE
> - * between io_tlb_start and io_tlb_end.
> */
> io_tlb_list = (unsigned int *)__get_free_pages(GFP_KERNEL,
> get_order(io_tlb_nslabs * sizeof(int)));
> @@ -304,7 +300,6 @@ cleanup3:
> sizeof(int)));
> io_tlb_list = NULL;
> cleanup2:
> - io_tlb_end = NULL;
> io_tlb_start = NULL;
> io_tlb_nslabs = 0;
> return -ENOMEM;
> @@ -339,8 +334,10 @@ 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);
> + phys_addr_t swiotlb_start = virt_to_phys(io_tlb_start);
> +
> + return paddr >= swiotlb_start &&
> + paddr < (swiotlb_start + (io_tlb_nslabs << IO_TLB_SHIFT));
> }
>
> /*
> @@ -938,6 +935,8 @@ 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;
> + unsigned long bytes = io_tlb_nslabs << IO_TLB_SHIFT;
> +
> + return swiotlb_virt_to_bus(hwdev, io_tlb_start + bytes - 1) <= mask;
> }
> EXPORT_SYMBOL(swiotlb_dma_supported);
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
next prev parent reply other threads:[~2012-10-04 13:12 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-04 0:38 [RFC PATCH 0/7] Improve swiotlb performance by using physical addresses Alexander Duyck
2012-10-04 0:38 ` [RFC PATCH 1/7] swiotlb: Instead of tracking the end of the swiotlb region just calculate it Alexander Duyck
2012-10-04 13:01 ` Konrad Rzeszutek Wilk [this message]
2012-10-04 15:54 ` Alexander Duyck
2012-10-04 16:31 ` Konrad Rzeszutek Wilk
2012-10-04 0:38 ` [RFC PATCH 2/7] swiotlb: Make io_tlb_start a physical address instead of a virtual address Alexander Duyck
2012-10-04 13:18 ` Konrad Rzeszutek Wilk
2012-10-04 17:11 ` Alexander Duyck
2012-10-04 17:19 ` Konrad Rzeszutek Wilk
2012-10-04 20:22 ` Alexander Duyck
2012-10-09 16:43 ` Konrad Rzeszutek Wilk
2012-10-09 19:11 ` Alexander Duyck
2012-10-04 0:38 ` [RFC PATCH 3/7] swiotlb: Make io_tlb_overflow_buffer a physical address Alexander Duyck
2012-10-04 0:39 ` [RFC PATCH 4/7] swiotlb: Return physical addresses when calling swiotlb_tbl_map_single Alexander Duyck
2012-10-04 0:39 ` [RFC PATCH 5/7] swiotlb: Use physical addresses for swiotlb_tbl_unmap_single Alexander Duyck
2012-10-04 0:39 ` [RFC PATCH 6/7] swiotlb: Use physical addresses instead of virtual in swiotlb_tbl_sync_single Alexander Duyck
2012-10-04 0:39 ` [RFC PATCH 7/7] swiotlb: Do not export swiotlb_bounce since there are no external consumers Alexander Duyck
2012-10-04 12:55 ` [RFC PATCH 0/7] Improve swiotlb performance by using physical addresses Konrad Rzeszutek Wilk
2012-10-04 15:50 ` Alexander Duyck
2012-10-04 13:33 ` Konrad Rzeszutek Wilk
2012-10-04 17:57 ` Alexander Duyck
2012-10-05 16:55 ` Andi Kleen
2012-10-05 19:35 ` Alexander Duyck
2012-10-05 20:02 ` Andi Kleen
2012-10-05 23:23 ` Alexander Duyck
2012-10-06 17:57 ` Andi Kleen
2012-10-06 18:56 ` H. Peter Anvin
2012-10-08 15:43 ` Alexander Duyck
2012-10-09 19:05 ` 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=20121004130107.GB9158@phenom.dumpdata.com \
--to=konrad@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alexander.h.duyck@intel.com \
--cc=bhelgaas@google.com \
--cc=devel@linuxdriverproject.org \
--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
Powered by JetHome