[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <bbd44c42-cedc-7bd6-a443-c991fd080298@gmail.com>
Date: Thu, 18 Mar 2021 12:22:13 -0700
From: Florian Fainelli <f.fainelli@...il.com>
To: linux-kernel@...r.kernel.org, Christoph Hellwig <hch@....de>
Cc: opendmb@...il.com, Jonathan Corbet <corbet@....net>,
Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Robin Murphy <robin.murphy@....com>,
"Paul E. McKenney" <paulmck@...nel.org>,
Randy Dunlap <rdunlap@...radead.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Thomas Gleixner <tglx@...utronix.de>,
Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
Viresh Kumar <viresh.kumar@...aro.org>,
Mike Kravetz <mike.kravetz@...cle.com>,
Peter Zijlstra <peterz@...radead.org>,
"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
"open list:SWIOTLB SUBSYSTEM" <iommu@...ts.linux-foundation.org>
Subject: Re: [PATCH] swiotlb: Add swiotlb=off to disable SWIOTLB
On 3/18/2021 12:18 PM, Florian Fainelli wrote:
> It may be useful to disable the SWIOTLB completely for testing or when a
> platform is known not to have any DRAM addressing limitations what so
> ever.
>
> Signed-off-by: Florian Fainelli <f.fainelli@...il.com>
Christoph, in addition to this change, how would you feel if we
qualified the swiotlb_init() in arch/arm/mm/init.c with a:
if (memblock_end_of_DRAM() >= SZ_4G)
swiotlb_init(1)
right now this is made unconditional whenever ARM_LPAE is enabled which
is the case for the platforms I maintain (ARCH_BRCMSTB) however we do
not really need a SWIOTLB so long as the largest DRAM physical address
does not exceed 4GB AFAICT.
Thanks!
> ---
> Documentation/admin-guide/kernel-parameters.txt | 1 +
> include/linux/swiotlb.h | 1 +
> kernel/dma/swiotlb.c | 9 +++++++++
> 3 files changed, 11 insertions(+)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 04545725f187..b0223e48921e 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -5278,6 +5278,7 @@
> force -- force using of bounce buffers even if they
> wouldn't be automatically used by the kernel
> noforce -- Never use bounce buffers (for debugging)
> + off -- Completely disable SWIOTLB
>
> switches= [HW,M68k]
>
> diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
> index 5857a937c637..23f86243defe 100644
> --- a/include/linux/swiotlb.h
> +++ b/include/linux/swiotlb.h
> @@ -15,6 +15,7 @@ enum swiotlb_force {
> SWIOTLB_NORMAL, /* Default - depending on HW DMA mask etc. */
> SWIOTLB_FORCE, /* swiotlb=force */
> SWIOTLB_NO_FORCE, /* swiotlb=noforce */
> + SWIOTLB_OFF, /* swiotlb=off */
> };
>
> /*
> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
> index c10e855a03bc..d7a4a789c7d3 100644
> --- a/kernel/dma/swiotlb.c
> +++ b/kernel/dma/swiotlb.c
> @@ -126,6 +126,8 @@ setup_io_tlb_npages(char *str)
> } else if (!strcmp(str, "noforce")) {
> swiotlb_force = SWIOTLB_NO_FORCE;
> io_tlb_nslabs = 1;
> + } else if (!strcmp(str, "off")) {
> + swiotlb_force = SWIOTLB_OFF;
> }
>
> return 0;
> @@ -229,6 +231,9 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
> unsigned long i, bytes;
> size_t alloc_size;
>
> + if (swiotlb_force == SWIOTLB_OFF)
> + return 0;
> +
> bytes = nslabs << IO_TLB_SHIFT;
>
> io_tlb_nslabs = nslabs;
> @@ -284,6 +289,9 @@ swiotlb_init(int verbose)
> unsigned char *vstart;
> unsigned long bytes;
>
> + if (swiotlb_force == SWIOTLB_OFF)
> + goto out;
> +
> if (!io_tlb_nslabs) {
> io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
> io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
> @@ -302,6 +310,7 @@ swiotlb_init(int verbose)
> io_tlb_start = 0;
> }
> pr_warn("Cannot allocate buffer");
> +out:
> no_iotlb_memory = true;
> }
>
>
--
Florian
Powered by blists - more mailing lists