From patchwork Wed Mar 20 06:36:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 10860911 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CD8C713B5 for ; Wed, 20 Mar 2019 06:37:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA1BF289F8 for ; Wed, 20 Mar 2019 06:37:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98764299F4; Wed, 20 Mar 2019 06:37:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02A72289F8 for ; Wed, 20 Mar 2019 06:36:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727180AbfCTGg6 (ORCPT ); Wed, 20 Mar 2019 02:36:58 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:37276 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727151AbfCTGg6 (ORCPT ); Wed, 20 Mar 2019 02:36:58 -0400 Received: by mail-pg1-f195.google.com with SMTP id q206so1035983pgq.4 for ; Tue, 19 Mar 2019 23:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=endlessm-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5Luj8qedFJhE73u4LFJM9ibs9W+XCAN6Zm8/UJfMARw=; b=sjdVRewsYNdnIJFXBwYiPfGfK/2acPZ5w0t4U4m3p2JAuvGgMZYhkO3YC/hr0sXacs eUnp5VdVj8ohqRHfVMK3N7hVUVZXt6VdgFT80e9kyoUpTVRszy6Y3AoMCmI5H0Ar9M26 5G6cHggTDyY/1OOFY/RfrM+xHf1Y+jWGVruaqkLf254pbPZAGkKmemuFXiceQTSchGrc L+dAPNPKa+j73jmCcDu+J+pWMUMNzADuD6weNQEP3J7Rfi+xb3FzI7JArC9yQc0TQ6Nk wN4EnGWyUUpIEjYmzD1M33cfMQNzPDMBK6QlJer3LM7K8ZKez5pRcV8kXnr60hyf9qpT yFrA== 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:mime-version :content-transfer-encoding; bh=5Luj8qedFJhE73u4LFJM9ibs9W+XCAN6Zm8/UJfMARw=; b=ocoEuEeyjY7XNo87AqPckHr98Y6sc8idhgGl0jK1gH+Yka/xQtdDqApp2WFnQ/sCSN 6ha5YXhMbNHt+JskFuYbMhrK/E0ONF2v4X9axWaazT9jHMu1f59o64lYhbwZrAykhDf4 lGczu5UdfbeYjG4vbJR3NwYSf/qnNe8ZZ2SvBq9e7U8Iqw+GpRN/FVGpO5xxmZjkDwu1 MBJYhQlmiCZl7ezebqOJJiNOK07Ulk6gQf62I4Eum/GEvLDAJSTLOQpbPmLWyfqY3OvC jSE5nbK9R1Jy1ucQNlL1Udb0/z4zhoSTW2UgbroYNqbuUxC4uQqv+4g6LJFQNJ0wWT/m Dhxw== X-Gm-Message-State: APjAAAV/NcmBn5SysUWIdyXFZDv8HjyOJItJa1YqqnikGuJHXtdDIyBq 8CbiIG7t/q55qv8Gzl5SySLgHDq+GFw= X-Google-Smtp-Source: APXvYqwWxddqxi2IZ5Dy0t5XTSt7XFMJNtsaiRRxnpLqMfnfZfcV6mwbuNwOZV7KMr/AFcMfMN/0aQ== X-Received: by 2002:a63:cc0e:: with SMTP id x14mr5838762pgf.159.1553063817582; Tue, 19 Mar 2019 23:36:57 -0700 (PDT) Received: from limbo.local (123-204-46-122.static.seed.net.tw. [123.204.46.122]) by smtp.gmail.com with ESMTPSA id 23sm1292840pfn.2.2019.03.19.23.36.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Mar 2019 23:36:56 -0700 (PDT) From: Daniel Drake To: ulf.hansson@linaro.org, linux@rempel-privat.de Cc: linux-mmc@vger.kernel.org Subject: [PATCH] mmc: alcor: fix DMA reads Date: Wed, 20 Mar 2019 14:36:53 +0800 Message-Id: <20190320063653.22638-1-drake@endlessm.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Setting max_blk_count to 1 here was causing the mmc block layer to always use the MMC_READ_SINGLE_BLOCK command here, which the driver does not DMA-accelerate. Drop the max_blk_ settings here. The mmc host defaults suffice, along with the max_segs and max_seg_size settings, which I have now documented in more detail. Now each MMC command reads 4 512-byte blocks, using DMA instead of PIO. On my SD card, this increases read performance (measured with dd) from 167kb/sec to 4.6mb/sec. Link: http://lkml.kernel.org/r/CAD8Lp47L5T3jnAjBiPs1cQ+yFA3L6LJtgFvMETnBrY63-Zdi2g@mail.gmail.com Signed-off-by: Daniel Drake Reviewed-by: Oleksij Rempel --- drivers/mmc/host/alcor.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/host/alcor.c b/drivers/mmc/host/alcor.c index c712b7deb3a9d..82a97866e0cf4 100644 --- a/drivers/mmc/host/alcor.c +++ b/drivers/mmc/host/alcor.c @@ -1044,14 +1044,27 @@ static void alcor_init_mmc(struct alcor_sdmmc_host *host) mmc->caps2 = MMC_CAP2_NO_SDIO; mmc->ops = &alcor_sdc_ops; - /* Hardware cannot do scatter lists */ + /* The hardware does DMA data transfer of 4096 bytes to/from a single + * buffer address. Scatterlists are not supported, but upon DMA + * completion (signalled via IRQ), the original vendor driver does + * then immediately set up another DMA transfer of the next 4096 + * bytes. + * + * This means that we need to handle the I/O in 4096 byte chunks. + * Lacking a way to limit the sglist entries to 4096 bytes, we instead + * impose that only one segment is provided, with maximum size 4096, + * which also happens to be the minimum size. This means that the + * single-entry sglist handled by this driver can be handed directly + * to the hardware, nice and simple. + * + * Unfortunately though, that means we only do 4096 bytes I/O per + * MMC command. A future improvement would be to make the driver + * accept sg lists and entries of any size, and simply iterate + * through them 4096 bytes at a time. + */ mmc->max_segs = AU6601_MAX_DMA_SEGMENTS; mmc->max_seg_size = AU6601_MAX_DMA_BLOCK_SIZE; - - mmc->max_blk_size = mmc->max_seg_size; - mmc->max_blk_count = mmc->max_segs; - - mmc->max_req_size = mmc->max_seg_size * mmc->max_segs; + mmc->max_req_size = mmc->max_seg_size; } static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)