From patchwork Tue Aug 28 09:48:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10578129 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 A751814E1 for ; Tue, 28 Aug 2018 09:55:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9374525D9E for ; Tue, 28 Aug 2018 09:55:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87C1A28F47; Tue, 28 Aug 2018 09:55:25 +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=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 26A7625D9E for ; Tue, 28 Aug 2018 09:55:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VNQ+r66uFskGK+JuwSKJMI+tmvhKIm6+O3g16TdUVMw=; b=OFZr8TstSy7DJy PT6SukqrdFXjpuNzD4rB2BGb+ocw7V2SOrHJdyfv08vVLEAIeKZA3UFxJPqvqRw1f+xMK3hJubKNn irDn0x1BY3byIv9+xXuPuZ+aWHj76KI05UiMIrmr1rGjDG33pfFbKJFREvZwhEIMDRtzqDwSGpyBx Rj43cS7dzTjOwZQrbgseIeEpWgpwBZu2ScuRsnnTYL01Ib5kNukAsL4LKrAlVXRKv3XZiQEPp9h7g +EFBbnQ+kcZW4GIalwX+YCNQzNvNig+qcV+qPsJHAp77WIjIM3OyH5WYKk+PdDTe3g9uS6WE04i4a N/p/q0vsqgr0WctHOCuQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuaiN-0005hp-7M; Tue, 28 Aug 2018 09:55:11 +0000 Received: from mail-eopbgr700087.outbound.protection.outlook.com ([40.107.70.87] helo=NAM04-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuaeo-00040q-Lt for linux-arm-kernel@lists.infradead.org; Tue, 28 Aug 2018 09:51:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector1-synaptics-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4vaoEQz1IWgRSirqSCG2jo2WQ2A8ou5Ebi6qEcnTlmU=; b=uJA+TuLi/7PRsa/t6vjEpXQL/LaIUI0LnoYSVXUA7L9ACVyKJuMKDS/C7Qq7avcAKshsOsgip1Dnw7fGYGMAquotSPamH5DqVq6F5O8AxTVEUNkgTj5774RuJSOU+QTdlTpUhowdTgZ68KOCGs2v68qH8fZXDEiFOdVvX/HaLMk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; Received: from xhacker.debian (124.74.246.114) by BY2PR0301MB1574.namprd03.prod.outlook.com (2a01:111:e400:526e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Tue, 28 Aug 2018 09:51:14 +0000 Date: Tue, 28 Aug 2018 17:48:14 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH v6 3/3] mmc: sdhci-of-dwcmshc: solve 128MB DMA boundary limitation Message-ID: <20180828174814.40dfa48f@xhacker.debian> In-Reply-To: <20180828174534.00fb5e24@xhacker.debian> References: <20180828174534.00fb5e24@xhacker.debian> X-Mailer: Claws Mail 3.17.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: TYAPR01CA0018.jpnprd01.prod.outlook.com (2603:1096:404::30) To BY2PR0301MB1574.namprd03.prod.outlook.com (2a01:111:e400:526e::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d283c4ca-d006-48d4-f874-08d60ccbcbf6 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:BY2PR0301MB1574; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1574; 3:Dt3GKAF0Vm19dsz+NkFK3JWNCCaUQEpMUdCZwA0eKmzmAO/88Kaesdi+pnt4lFpD1GjU3kDt+ejoIlPgH3BBq6SeU5DaR3xJ/AaM81UmkE9//PTpKFn9tfgrAFOdEAr2cbJOhcM9s+5e5V/cbVmyK07rW2NPpDmUEXU30uTbeGRFSLleOD0/QhkoeipnVkJI+2XvdDzOr2M725KMsNy0RpjDDQKxlo10l9Qf2LsFhApRHAhmmepz+9rGw6/tS2K9; 25:9lxI9ehjlBmSVPoffC0+eLDkRrufB1pPshl6jec+64cKkFuUnGttOUVLfWU3KzArPyU0HC4jSx+QoZhoLidlBfFI1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sHy8QGcIwKIHCumu; 4:r3d7kzKRoJb4Z85Qd+sg0Rfg8npHm2xQt/mYB6jFGQU6KSJWmheFmLhIhcTyxecTXvh8Eck1q9d6fbAoohLDwQpjjeEl4SUdFwEJwudB9PArFqxR2X3GQD08Wt6C/s2STUkQgDSAGcYitOtmSUKL78B09sF4zlcNTzbYuaJIYRF7ewxTNC1idTH4RNhDus883hsgTP8wzY7UksH8ydOvBS/i6ZJHBh677D61I2bSm32V8C4nDksI67jI24lPtiyl63apIJxqtbs00sI5NojFpg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231311)(944501410)(52105095)(10201501046)(149027)(150027)(6041310)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(201708071742011)(7699016); SRVR:BY2PR0301MB1574; BCL:0; PCL:0; RULEID:; SRVR:BY2PR0301MB1574; X-Forefront-PRVS: 077884B8B5 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(346002)(39860400002)(396003)(376002)(366004)(189003)(199004)(54906003)(25786009)(4326008)(16526019)(186003)(66066001)(72206003)(476003)(14444005)(86362001)(26005)(11346002)(6506007)(446003)(386003)(478600001)(956004)(5660300001)(81166006)(8676002)(97736004)(50226002)(8936002)(81156014)(486006)(47776003)(316002)(230700001)(1076002)(3846002)(105586002)(23726003)(7736002)(50466002)(68736007)(52116002)(106356001)(53936002)(33896004)(2906002)(76176011)(305945005)(7696005)(9686003)(110136005)(55016002)(6116002)(133343001)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB1574; H:xhacker.debian; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts)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uMeZrGkMtQ+0pnjo8y7C5iN/nL/89Pthx4HZeCdDgL+LiUKZ0H/AgvSv0qL3Tl/cr28agt60Sw==; 5:o2kUE8YeCPv15/L8srQWMkV7DkVVu6X26E4tEU/fgn66u1fi8t7SXr6wgDCFXPbdeM6S9KHGf5wNvjjE62Iu8PzG60+xp+hEwYgZpkgPa8GiMiQVtgsjZPUfMVL4ve7uq6c1Yo/SBVIY8uK1LRtzPhhhm58jzkn4gbIiUteW/uo=; 7:PG7uOMx4BPcBK7yNL1a3vMIQZNarf3ekfdUzkeeGxpSlmz40R1yPkRO66OQB3305pP1t+LCSJc0aWS5uoyOLhFTAkKKyNKBRepdJ2SzkQs6+5+XzQagnEj8P1ZX7kuHqDEdaRGMwosoAEdUkWuuLi6JBXIxiGOThQOIp4nm+V4HLr5mN0UHYSx0Vkd23cRDQRz3y1eekz+7EQ9g+XYvu7sza9uqcVz+vKnn9JEGj4pWjdy7OuwR3u2ZTZbMB7LRo SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Aug 2018 09:51:14.5947 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d283c4ca-d006-48d4-f874-08d60ccbcbf6 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB1574 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180828_025130_809232_A7C0BFB1 X-CRM114-Status: GOOD ( 10.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When using DMA, if the DMA addr spans 128MB boundary, we have to split the DMA transfer into two so that each one doesn't exceed the boundary. Signed-off-by: Jisheng Zhang Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-of-dwcmshc.c | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c index 1b7cd144fb01..a5137845a1c7 100644 --- a/drivers/mmc/host/sdhci-of-dwcmshc.c +++ b/drivers/mmc/host/sdhci-of-dwcmshc.c @@ -8,21 +8,51 @@ */ #include +#include +#include #include #include +#include #include "sdhci-pltfm.h" +#define BOUNDARY_OK(addr, len) \ + ((addr | (SZ_128M - 1)) == ((addr + len - 1) | (SZ_128M - 1))) + struct dwcmshc_priv { struct clk *bus_clk; }; +/* + * If DMA addr spans 128MB boundary, we split the DMA transfer into two + * so that each DMA transfer doesn't exceed the boundary. + */ +static void dwcmshc_adma_write_desc(struct sdhci_host *host, void **desc, + dma_addr_t addr, int len, unsigned int cmd) +{ + int tmplen, offset; + + if (likely(!len || BOUNDARY_OK(addr, len))) { + sdhci_adma_write_desc(host, desc, addr, len, cmd); + return; + } + + offset = addr & (SZ_128M - 1); + tmplen = SZ_128M - offset; + sdhci_adma_write_desc(host, desc, addr, tmplen, cmd); + + addr += tmplen; + len -= tmplen; + sdhci_adma_write_desc(host, desc, addr, len, cmd); +} + static const struct sdhci_ops sdhci_dwcmshc_ops = { .set_clock = sdhci_set_clock, .set_bus_width = sdhci_set_bus_width, .set_uhs_signaling = sdhci_set_uhs_signaling, .get_max_clock = sdhci_pltfm_clk_get_max_clock, .reset = sdhci_reset, + .adma_write_desc = dwcmshc_adma_write_desc, }; static const struct sdhci_pltfm_data sdhci_dwcmshc_pdata = { @@ -36,12 +66,21 @@ static int dwcmshc_probe(struct platform_device *pdev) struct sdhci_host *host; struct dwcmshc_priv *priv; int err; + u32 extra; host = sdhci_pltfm_init(pdev, &sdhci_dwcmshc_pdata, sizeof(struct dwcmshc_priv)); if (IS_ERR(host)) return PTR_ERR(host); + /* + * extra adma table cnt for cross 128M boundary handling. + */ + extra = DIV_ROUND_UP_ULL(dma_get_required_mask(&pdev->dev), SZ_128M); + if (extra > SDHCI_MAX_SEGS) + extra = SDHCI_MAX_SEGS; + host->adma_table_cnt += extra; + pltfm_host = sdhci_priv(host); priv = sdhci_pltfm_priv(pltfm_host);