Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp823388pxf; Thu, 18 Mar 2021 12:23:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhsRHvup7vphDpQWCFvg1IZz8uiQ8TVDNI3lXTIesJP5tpABcjus6xw/SAVYZwGsrpD5+9 X-Received: by 2002:a17:906:934c:: with SMTP id p12mr137118ejw.131.1616095438309; Thu, 18 Mar 2021 12:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616095438; cv=none; d=google.com; s=arc-20160816; b=OpM9PvCRbSRl9k4p+EPthXFE06m4SM3deSkOUfskr3h6IbMUHqaKbZUXDQPVxHbzmp G95pwpailbpchWYB36NhbH12sP3tiEdez2w/NyMRY+OHv5qXn20j50jRyvuJZ1djQfqB xgoeEx49gQvqTjjPxbhC6lPAMvqqqKSIQJbzw8/M/0LIyU7M3YXeRniX73iQIxQ/eabY YOr0jVJNUPmdf8ExM10wA+6lvoYLhYHO4X6p+mVA245H07tHyF1RWrN8mS4IwtbTYFW/ Msiku5Zp6XeKkl9oQ1OUdLQfOArjr+klaKV3nqb2KT4aWc++SSnA6HObD+qQdnmxAIWk JQqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=TM+vEBqjvzmGZFh854VHWSVx/dlysQ2NuONxv+B86HU=; b=CNzntcBGX1r+WOhM3ZuiDlcpsP4Lzvb9YGFmLZ8pTcE3Pe/TGZn6A90w6NyvvNiBS9 SiRh5ZwhLjRS+aNsm9FBmgbaXfpVOYJoBWCvK0tpBAdEKom8GDqOWDQiTBZtqKpG89Fo HQbx3MKz22YdYdNKdwPrpcejWCWuInGp0CUlL3WQ8Rwzc2BGek09In3RlUrFWk07Vdja uK9SSnz2QC2qRNtrUumbnJn0SeqRNZthh84DlEdGcuA0VtpyaQl+jRxGVvvTCQpSRMOc mAaxUn11aFHsPKesAznjPpuQ0/Da/PNrN16pGmwzlc4iziuH9pbe3BEe+FLy55KVA/Po S+1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LBxnTBlH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n3si2248725edo.368.2021.03.18.12.23.35; Thu, 18 Mar 2021 12:23:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LBxnTBlH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232802AbhCRTW1 (ORCPT + 99 others); Thu, 18 Mar 2021 15:22:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232851AbhCRTWT (ORCPT ); Thu, 18 Mar 2021 15:22:19 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FBCFC06174A; Thu, 18 Mar 2021 12:22:19 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id bt4so3432976pjb.5; Thu, 18 Mar 2021 12:22:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=TM+vEBqjvzmGZFh854VHWSVx/dlysQ2NuONxv+B86HU=; b=LBxnTBlH06B0fQtsE0BvxU3j7rlfq3katQi7WoUGretXjpngZM5x897LI0NpbDoopk hX9iBFP1dRVeJ5lS7Yl+9a5OIDATku9d98R1Rx/4FFArP6hpBi0J3iDd+Rsz0PQwTw5c R7rsUuPuCQGPFsFO98LjnZNtEuIuaNEt1RD0TCsr7vxGZBm7MRs0f+S9DO/WW5b2H9f9 M/2bQqXtzMxL2aZnVTEeR0mnDwnH90eSyMZ2Z4GwX2+Hh3LbpAfBUZGEU5vhgSpsP3L5 eo9J50pKpEeagWcG3ytdINWi0vle6C8TvUyy2NJly5kyWfI6GqZVMYO9r7Ww35jE4yJA f74g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=TM+vEBqjvzmGZFh854VHWSVx/dlysQ2NuONxv+B86HU=; b=TM4SdMPlnb0irTOEDTVdi2REHFJdr4DCgAs9Tpr4wWXCFgwaNfCRenhpT8ks458HaB 61hQCW8GdGSWWoP/kKW26lAJTDGpW64VT2qK6wAy/8qts23Sc9B5q2JdKLcHZ6JsEkOz IIxFFZdTQsh3R8zQGgTscOoQHZnUwfDWwy/vz4hLTD+MfXkdqmpMdujxO0wgWOdFt4T1 ZWfE8KW/5HZMv9qEh9ySvRgTxonZCztCBeVBNT1u+X2bxQ2IvdgX9XiJWLTlEyRtaCka eTcq+bT49qatsQMKJtb7SH6bme/9eoIGql6WbeTTYj81mnNVFIdoxJGqAgNFzMnIIIRl b/tg== X-Gm-Message-State: AOAM533iJQPDPpT4n85GTKyKK24K6ut4awlsIeSUFmgnzZudFCH+aMzH XPNLkOIZfG6aWHzPFl6WUfI= X-Received: by 2002:a17:90a:e556:: with SMTP id ei22mr5793082pjb.214.1616095338892; Thu, 18 Mar 2021 12:22:18 -0700 (PDT) Received: from [10.230.29.202] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id h19sm3290393pfc.172.2021.03.18.12.22.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Mar 2021 12:22:18 -0700 (PDT) Subject: Re: [PATCH] swiotlb: Add swiotlb=off to disable SWIOTLB To: linux-kernel@vger.kernel.org, Christoph Hellwig Cc: opendmb@gmail.com, Jonathan Corbet , Konrad Rzeszutek Wilk , Marek Szyprowski , Robin Murphy , "Paul E. McKenney" , Randy Dunlap , Andrew Morton , Thomas Gleixner , Mauro Carvalho Chehab , Viresh Kumar , Mike Kravetz , Peter Zijlstra , "open list:DOCUMENTATION" , "open list:SWIOTLB SUBSYSTEM" References: <20210318191816.4185226-1-f.fainelli@gmail.com> From: Florian Fainelli Message-ID: Date: Thu, 18 Mar 2021 12:22:13 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210318191816.4185226-1-f.fainelli@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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