From: Konrad Rzeszutek Wilk Subject: [PATCH 02/11] [swiotlb] Make 'setup_io_tlb_npages' accept new 'swiotlb=' syntax. Date: Wed, 3 Feb 2010 12:08:03 -0500 Message-ID: <1265216892-14230-3-git-send-email-konrad.wilk@oracle.com> References: <20100203110407H.fujita.tomonori@lab.ntt.co.jp> <1265216892-14230-1-git-send-email-konrad.wilk@oracle.com> <1265216892-14230-2-git-send-email-konrad.wilk@oracle.com> Return-path: In-Reply-To: <1265216892-14230-2-git-send-email-konrad.wilk@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: chrisw@sous-sol.org, fujita.tomonori@lab.ntt.co.jp, iommu@lists.linux-foundation.org, dwmw2@infradead.org Cc: Ian.Campbell@eu.citrix.com, jeremy@goop.org, xen-devel@lists.xensource.com, alex.williamson@hp.com, Konrad Rzeszutek Wilk List-Id: xen-devel@lists.xenproject.org The old syntax for 'swiotlb' is still in effect, and we extend it now to include the overflow buffer size. The syntax is now: swiotlb=[force,][nslabs=,][overflow=] or more commonly know as: swiotlb=[force] swiotlb=[nslabs=] swiotlb=[overflow=] Signed-off-by: Konrad Rzeszutek Wilk --- Documentation/x86/x86_64/boot-options.txt | 6 ++++- lib/swiotlb.c | 36 +++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Documentation/x86/x86_64/boot-options.txt b/Documentation/x86/x86_64/boot-options.txt index 29a6ff8..81f9b94 100644 --- a/Documentation/x86/x86_64/boot-options.txt +++ b/Documentation/x86/x86_64/boot-options.txt @@ -267,10 +267,14 @@ IOMMU (input/output memory management unit) iommu options only relevant to the software bounce buffering (SWIOTLB) IOMMU implementation: - swiotlb=[,force] + swiotlb=[npages=] + swiotlb=[force] + swiotlb=[overflow=] + Prereserve that many 128K pages for the software IO bounce buffering. force Force all IO through the software TLB. + Size in bytes of the overflow buffer. Settings for the IBM Calgary hardware IOMMU currently found in IBM pSeries and xSeries machines: diff --git a/lib/swiotlb.c b/lib/swiotlb.c index e6d9e32..0663879 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c @@ -102,7 +102,27 @@ static int late_alloc; static int __init setup_io_tlb_npages(char *str) { + int get_value(const char *token, char *str, char **endp) + { + ssize_t len; + int val = 0; + + len = strlen(token); + if (!strncmp(str, token, len)) { + str += len; + if (*str == '=') + ++str; + if (*str != '\0') + val = simple_strtoul(str, endp, 0); + } + *endp = str; + return val; + } + + int val; + while (*str) { + /* The old syntax */ if (isdigit(*str)) { io_tlb_nslabs = simple_strtoul(str, &str, 0); /* avoid tail segment of size < IO_TLB_SEGSIZE */ @@ -110,14 +130,22 @@ setup_io_tlb_npages(char *str) } if (!strncmp(str, "force", 5)) swiotlb_force = 1; - str += strcspn(str, ","); - if (*str == ',') - ++str; + /* The new syntax: swiotlb=nslabs=16384,overflow=32768,force */ + val = get_value("nslabs", str, &str); + if (val) + io_tlb_nslabs = ALIGN(val, IO_TLB_SEGSIZE); + + val = get_value("overflow", str, &str); + if (val) + io_tlb_overflow = val; + str = strpbrk(str, ","); + if (!str) + break; + str++; /* skip ',' */ } return 1; } __setup("swiotlb=", setup_io_tlb_npages); -/* make io_tlb_overflow tunable too? */ /* Note that this doesn't work with highmem page */ static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev, -- 1.6.2.5