From patchwork Wed May 10 08:24:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 98967 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp105528qge; Wed, 10 May 2017 01:24:57 -0700 (PDT) X-Received: by 10.99.126.20 with SMTP id z20mr4895413pgc.158.1494404697616; Wed, 10 May 2017 01:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1494404697; cv=none; d=google.com; s=arc-20160816; b=PpcaItl4OH5VynCsw6f1+W27V/yN+8EBeaLrDolCHMiQH0Dnxb87JZfuJsFRwmDhEt GGuez+Kph9NNhfDKrEIer7PXD0j1WfsaMMxTStgiN8Ju3wQnADqHos+YyHqfNpP7yHIQ DD5AQcV2SwH3ZYvi7qzkxiN9AfnvmuH2Gx3fEWEGXE4+HxDVNLlnqgtq3uw4VcS/FgKA NyBhz6YspRlITvVxj6X2q3kwLI1pPAsLML/N8lBmH8IAAcySMFMcWcx4LfzN1J8SqCeW 1IsdVW7+EFK6XJZBzZxNX19alA5p8AvXnlDV+T/vepmWVhV/CKWFgBTlzh7SmyasNUvP 447A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=h6NWiOXaEFL/3ROx3EmKxlJRszvYTfJ0vItljEnJrT4=; b=AWQ/ZU6snsBhDYmPE+ITHSzJgR2LosZB050rYMXR90I6992K0wPI9kQGJKH/i2NeQ7 cYbXAlXqtCMannfNWrpaAT2MyR3bctEu/ivIJbbqhpO6HM4TPOc9Hqp/3+PE17k4ryM4 bvWZgWHDMOBioOTy6VVYgDFiIlrpTHVVu4ZFz3BEGxsOFaUp0iXT2ijZKQD8yoeKEOW4 aNjpQjmPm7nxO00GBdYyo01eSPtgRHK+4SdwKUPLTrUz1uLZkkppax96m4Q6YvVClTbp T7SgOL7UYadmhz1vBQDFJu2aGnAm949NKEh654YSqlw7+5o5w9ji8os5sH+smRGpbzEQ 3IDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f132si2315878pgc.250.2017.05.10.01.24.57; Wed, 10 May 2017 01:24:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752606AbdEJIYy (ORCPT + 6 others); Wed, 10 May 2017 04:24:54 -0400 Received: from mail-qt0-f180.google.com ([209.85.216.180]:35703 "EHLO mail-qt0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752605AbdEJIYt (ORCPT ); Wed, 10 May 2017 04:24:49 -0400 Received: by mail-qt0-f180.google.com with SMTP id n4so20271883qte.2 for ; Wed, 10 May 2017 01:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WMv7MfKvantDzjgomr8MQN6gLjbIb278YoCOIeSV36Y=; b=JqIVsPHsaifq8oJTGOaoQTugEDeSC6f/tXA/VPKIOlRTOQYIjJKvX/+jK0jLeOhvhv JyOzGEodBR3oAQlU+aai/lS/q7eYB6sgO/Ll6KLkro3hjwgJEvsxZqx0MZirqUz4XXlF M3ZOtfz93dGKFKSCqK56JjI4UAl5T15LM0vhk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WMv7MfKvantDzjgomr8MQN6gLjbIb278YoCOIeSV36Y=; b=Wk3KtRHnTE99ri0p6UrwgDMxU7nJlkWHaP/BsE62UzF3zHZntLfNx4FiNRMMBpiHar k+cNXuAURkBlCbKb3Ak1bTzGaH7XaycEYtkEaCifrN7ZUEfVfi/U2XEFBv3sKOjkdoB/ prJNGzDUlCO59Z2sOYSBuDb07i5dajIiJTFfNGOUQENbTOUgQFrCQqVKQUzCf4bCE2vd ETcPjG/IYo2LvS+6niqDuczS6U/VCiGIFJkW2em2RIBkp4uDWIno47aJtuaSIxaYLeDg vS62bG3AYBscWHzkhkRVUSr0S+BCgf6XVShclqMWwlMERorncqvhwC58ss1OzNDbfi0s WxdQ== X-Gm-Message-State: AODbwcAcUo3jcVeQC1LTxNakGMun259uz2AAvQhEaAZ0+o78Q2OWF3+p 5eFz99XBdBfIEjkO X-Received: by 10.25.16.96 with SMTP id f93mr2114982lfi.37.1494404687916; Wed, 10 May 2017 01:24:47 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id 17sm401500ljo.56.2017.05.10.01.24.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 May 2017 01:24:46 -0700 (PDT) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter Cc: linux-block@vger.kernel.org, Jens Axboe , Christoph Hellwig , Arnd Bergmann , Bartlomiej Zolnierkiewicz , Paolo Valente , Linus Walleij Subject: [PATCH 1/5] mmc: core: Delete bounce buffer Kconfig option Date: Wed, 10 May 2017 10:24:14 +0200 Message-Id: <20170510082418.10513-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170510082418.10513-1-linus.walleij@linaro.org> References: <20170510082418.10513-1-linus.walleij@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org This option is activated by all multiplatform configs and what not so we almost always have it turned on, and the memory it saves is negligible, even more so moving forward. The actual bounce buffer only gets allocated only when used, the only thing the ifdefs are saving is a little bit of code. It is highly improper to have this as a Kconfig option that get turned on by Kconfig, make this a pure runtime-thing and let the host decide whether we use bounce buffers. We add a new property "disable_bounce" to the host struct. Notice that mmc_queue_calc_bouncesz() already disables the bounce buffers if host->max_segs != 1, so any arch that has a maximum number of segments higher than 1 will have bounce buffers disabled. The option CONFIG_MMC_BLOCK_BOUNCE is default y so the majority of platforms in the kernel already have it on, and it then gets turned off at runtime since most of these have a host->max_segs > 1. The few exceptions that have host->max_segs == 1 and still turn off the bounce buffering are those that disable it in their defconfig. Those are the following: arch/arm/configs/colibri_pxa300_defconfig arch/arm/configs/zeus_defconfig - Uses MMC_PXA, drivers/mmc/host/pxamci.c - Sets host->max_segs = NR_SG, which is 1 - This needs its bounce buffer deactivated so we set host->disable_bounce to true in the host driver arch/arm/configs/davinci_all_defconfig - Uses MMC_DAVINCI, drivers/mmc/host/davinci_mmc.c - This driver sets host->max_segs to MAX_NR_SG, which is 16 - That means this driver anyways disabled bounce buffers - No special action needed for this platform arch/arm/configs/lpc32xx_defconfig arch/arm/configs/nhk8815_defconfig arch/arm/configs/u300_defconfig - Uses MMC_ARMMMCI, drivers/mmc/host/mmci.[c|h] - This driver by default sets host->max_segs to NR_SG, which is 128, unless a DMA engine is used, and in that case the number of segments are also > 1 - That means this driver already disables bounce buffers - No special action needed for these platforms arch/arm/configs/sama5_defconfig - Uses MMC_SDHCI, MMC_SDHCI_PLTFM, MMC_SDHCI_OF_AT91, MMC_ATMELMCI - Uses drivers/mmc/host/sdhci.c - Normally sets host->max_segs to SDHCI_MAX_SEGS which is 128 and thus disables bounce buffers - Sets host->max_segs to 1 if SDHCI_USE_SDMA is set - SDHCI_USE_SDMA is only set by SDHCI on PCI adapers - That means that for this platform bounce buffers are already disabled at runtime - No special action needed for this platform arch/blackfin/configs/CM-BF533_defconfig arch/blackfin/configs/CM-BF537E_defconfig - Uses MMC_SPI (a simple MMC card connected on SPI pins) - Uses drivers/mmc/host/mmc_spi.c - Sets host->max_segs to MMC_SPI_BLOCKSATONCE which is 128 - That means this platform already disables bounce buffers at runtime - No special action needed for these platforms arch/mips/configs/cavium_octeon_defconfig - Uses MMC_CAVIUM_OCTEON, drivers/mmc/host/cavium.c - Sets host->max_segs to 16 or 1 - Setting host->disable_bounce to be sure for the 1 case arch/mips/configs/qi_lb60_defconfig - Uses MMC_JZ4740, drivers/mmc/host/jz4740_mmc.c - This sets host->max_segs to 128 so bounce buffers are already runtime disabled - No action needed for this platform It would be interesting to come up with a list of the platforms that actually end up using bounce buffers. I have not been able to infer such a list, but it occurs when host->max_segs == 1 and the bounce buffering is not explicitly disabled. Signed-off-by: Linus Walleij --- drivers/mmc/core/Kconfig | 18 ------------------ drivers/mmc/core/queue.c | 15 +-------------- drivers/mmc/host/cavium.c | 3 +++ drivers/mmc/host/pxamci.c | 6 ++++++ include/linux/mmc/host.h | 1 + 5 files changed, 11 insertions(+), 32 deletions(-) -- 2.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/core/Kconfig b/drivers/mmc/core/Kconfig index fc1ecdaaa9ca..42e89060cd41 100644 --- a/drivers/mmc/core/Kconfig +++ b/drivers/mmc/core/Kconfig @@ -61,24 +61,6 @@ config MMC_BLOCK_MINORS If unsure, say 8 here. -config MMC_BLOCK_BOUNCE - bool "Use bounce buffer for simple hosts" - depends on MMC_BLOCK - default y - help - SD/MMC is a high latency protocol where it is crucial to - send large requests in order to get high performance. Many - controllers, however, are restricted to continuous memory - (i.e. they can't do scatter-gather), something the kernel - rarely can provide. - - Say Y here to help these restricted hosts by bouncing - requests back and forth from a large buffer. You will get - a big performance gain at the cost of up to 64 KiB of - physical memory. - - If unsure, say Y here. - config SDIO_UART tristate "SDIO UART/GPS class support" depends on TTY diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c index 5c37b6be3e7b..545466342fb1 100644 --- a/drivers/mmc/core/queue.c +++ b/drivers/mmc/core/queue.c @@ -219,7 +219,6 @@ static struct mmc_queue_req *mmc_queue_alloc_mqrqs(int qdepth) return mqrq; } -#ifdef CONFIG_MMC_BLOCK_BOUNCE static int mmc_queue_alloc_bounce_bufs(struct mmc_queue_req *mqrq, int qdepth, unsigned int bouncesz) { @@ -258,7 +257,7 @@ static unsigned int mmc_queue_calc_bouncesz(struct mmc_host *host) { unsigned int bouncesz = MMC_QUEUE_BOUNCESZ; - if (host->max_segs != 1) + if (host->max_segs != 1 || host->disable_bounce) return 0; if (bouncesz > host->max_req_size) @@ -273,18 +272,6 @@ static unsigned int mmc_queue_calc_bouncesz(struct mmc_host *host) return bouncesz; } -#else -static inline bool mmc_queue_alloc_bounce(struct mmc_queue_req *mqrq, - int qdepth, unsigned int bouncesz) -{ - return false; -} - -static unsigned int mmc_queue_calc_bouncesz(struct mmc_host *host) -{ - return 0; -} -#endif static int mmc_queue_alloc_sgs(struct mmc_queue_req *mqrq, int qdepth, int max_segs) diff --git a/drivers/mmc/host/cavium.c b/drivers/mmc/host/cavium.c index 58b51ba6aabd..66066f73e477 100644 --- a/drivers/mmc/host/cavium.c +++ b/drivers/mmc/host/cavium.c @@ -1050,6 +1050,9 @@ int cvm_mmc_of_slot_probe(struct device *dev, struct cvm_mmc_host *host) else mmc->max_segs = 1; + /* Disable bounce buffers for max_segs = 1 */ + mmc->disable_bounce = true; + /* DMA size field can address up to 8 MB */ mmc->max_seg_size = 8 * 1024 * 1024; mmc->max_req_size = mmc->max_seg_size; diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index c763b404510f..d3b5e6376504 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c @@ -666,6 +666,12 @@ static int pxamci_probe(struct platform_device *pdev) mmc->max_segs = NR_SG; /* + * This architecture used to disable bounce buffers through its + * defconfig, now it is done at runtime as a host property. + */ + mmc->disable_bounce = true; + + /* * Our hardware DMA can handle a maximum of one page per SG entry. */ mmc->max_seg_size = PAGE_SIZE; diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 21385ac0c9b1..b53c0e18a33b 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -310,6 +310,7 @@ struct mmc_host { /* host specific block data */ unsigned int max_seg_size; /* see blk_queue_max_segment_size */ unsigned short max_segs; /* see blk_queue_max_segments */ + bool disable_bounce; /* disable bounce buffers */ unsigned short unused; unsigned int max_req_size; /* maximum number of bytes in one req */ unsigned int max_blk_size; /* maximum size of one mmc block */