From patchwork Mon Aug 27 08:21:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10576621 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 E5D011390 for ; Mon, 27 Aug 2018 08:25:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF15329798 for ; Mon, 27 Aug 2018 08:25:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C270B29807; Mon, 27 Aug 2018 08:25:09 +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 6014D29798 for ; Mon, 27 Aug 2018 08:25:09 +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=vCp2rg0rn1cKW2pLYGnI0dhOFo9NchA7h5RJ/s9Ut0g=; b=fN0LiRmAXkZ2Fz ZphlGEveVSXXLcgMTaD908SakdNhjI+54mFwPlvQ6xx7/o/1sgfrFjiuZFjoFT+AbAYVoXhtYB+nW /hDrd4H9kLOwmiGG2muTQDD5RYfpII3yqK2Pg7b7UQo901L+x+LoBvwwJgOoSr7sm3lYLTufdpWHh qAXNThDCmUX78QJ29VjJFOzrI1s2MlUN4skDbOLuHTM+X8Zdcv2SJge7v13jfw4pilB8TtyxMPIi8 6vBr/RJS+R11i4x3Nmc67zQiyq96kU3obKpKTbg8VFIraXNKxGmKhM1gU3Wct/p0xWQZ7eBG2eWLj BqFHub/UAnmmGjFHyi+Q==; 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 1fuCpW-0000HG-TV; Mon, 27 Aug 2018 08:24:58 +0000 Received: from mail-sn1nam02on0042.outbound.protection.outlook.com ([104.47.36.42] helo=NAM02-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuCpT-0000FO-E5 for linux-arm-kernel@lists.infradead.org; Mon, 27 Aug 2018 08:24:57 +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=Yvprez3azRSi1qUZTkuWZTzIjc29OUayx4JB5SrF0mI=; b=qsSTXArLzFiEQMs8TXi6Be+X3lm6XVc+9b49vWK7o91k9JXjg94w1qbDOYRFx2fW+14havvtz0t+zWj6E5dLhJKg0DCw3/Ywcp7AgyItVXaOeefLHpTHBa6dKYYYUtJbTvShXCm1rAKenvnHhuwzvvfkTtbwuXt70eSPNtP1CSA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; Received: from xhacker.debian (124.74.246.114) by BY2PR0301MB1576.namprd03.prod.outlook.com (2a01:111:e400:526e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Mon, 27 Aug 2018 08:24:38 +0000 Date: Mon, 27 Aug 2018 16:21:35 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH v5 1/3] mmc: sdhci: add adma_table_cnt member to struct sdhci_host Message-ID: <20180827162135.46285a72@xhacker.debian> In-Reply-To: <20180827162026.3901de27@xhacker.debian> References: <20180827162026.3901de27@xhacker.debian> X-Mailer: Claws Mail 3.17.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: TY2PR0101CA0012.apcprd01.prod.exchangelabs.com (2603:1096:404:92::24) To BY2PR0301MB1576.namprd03.prod.outlook.com (2a01:111:e400:526e::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7e0d59fb-6936-4f9b-7aa3-08d60bf6886d X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BY2PR0301MB1576; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1576; 3:vbQn9cG/t1Ibfkup3B+bLEK7XvWPA0uHATLw7BlYtfs8JUnx66g2aGkg4SkLANG6zaIjU26/NR2GOSwUt2iN0ALNUm6gojP8tCE+Ti6cYpImRggfQcZJp/PDnC72AnFDg6tG+D3heHkw6nO7qZ3CbD79yf/wN7TRZ0yn9StnfH3BRUNQsq1Ll+pAaK3p2NuqDcSWo72xpJ3dcWBBtFxYM4BfSXrwTE/f27qvkaQvbvnoBLepbW9Lul+u1X/hN3nk; 25:eRihxTRPRoF/F4/x+e53O1j+EuO+BroIFZgfddD+auTz1s8A6uG+wGMzVpkRd4XzMdN0c6VTZVRJqJzMirHLtYW/n9tfnTt2h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PJIxkS; 4:HCQl7JCpaVYYG28pppDrtrrm/1Vz4SbFP+FbaYU3ZfpQU3GU22Zw3a6J2aiExM9x2sVX0+ppCgEWpZlTH6kqQK+0LsDLhQ5xb/8kToj2c10G1ObMb6SA5/MOnhaEvPYow8HSy/E8epZ0PfcK0sd3sbKjlQLajI58HcJG3TBsBNGEVhd6v1GTK04uxjuMb5IxQ4Ee/TM+WqghTVNvrZ0YNGr7FPZAEdr0R66vk5Iai5RxB6x9O847XAjjvWxjJF5DYn/ppBsbuDUbTCESUPFLSnRlJ+khBG0+lHR84FA3itzCNs1EkksQDs5zP5kom9fx X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231311)(944501410)(52105095)(10201501046)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016); SRVR:BY2PR0301MB1576; BCL:0; PCL:0; RULEID:; SRVR:BY2PR0301MB1576; X-Forefront-PRVS: 07778E4001 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(39860400002)(376002)(396003)(366004)(136003)(199004)(189003)(956004)(50226002)(8936002)(66066001)(476003)(11346002)(446003)(76176011)(5660300001)(6506007)(386003)(33896004)(7736002)(305945005)(81166006)(81156014)(8676002)(575784001)(26005)(7696005)(52116002)(2906002)(68736007)(16526019)(186003)(86362001)(23726003)(1076002)(230700001)(3846002)(6116002)(4326008)(25786009)(6666003)(110136005)(72206003)(54906003)(55016002)(50466002)(53936002)(486006)(47776003)(9686003)(478600001)(97736004)(105586002)(106356001)(316002)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB1576; H:xhacker.debian; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0301MB1576; 23:6bZFRffa1HNdiz+Bt6VXBtmM11MaE+7HvJfnMAk?= 3H6jlfDMxUIRsSRmXCITz1jHEg9YubRY4wuzwR6QzAcCuKLjfZixgXVBa1wMYFJ6CLKBMv6IHWrz8Eyn7laV6QYAhgifUMEha6xroTEH/UJx2zB+x6mIa8uQTif/nsV5zWXHnxq+/JXxvP7ydHEqWELb/Px53BmMdktQ+0g3iYCRZxwFM4pA/z9Ghg8uWHx5ae8NUv5PBh1Oo9RnAEoSMebN2OQjwpLyilGdctMC/yFEiwleHZPRtgfLMRbVBCVLSj2/AvjGBmKAswWNkjbPod4SgfbYokwWNdL+0Ah1lOIndG2hQBelynfLTg0Z25xLpInCBb8uVqVdXYJbW26Ro3Kft2Ks01xNDJIbW+e2k5W+rYNmMaNX72ReSXpByHnjSoYBgw3EJA0gBFBxmvax5RXEzp9XqRuo71jdpiMUMtFUaR/W24hEhnoETZ8/T7VrsHjcwPKeeXd629SJZ/6e/ZtDN6IsBNceiFZqFCyqh3iQ0+86JUzqW7VaYYJ2g3fQPX582KLXtIteWs6S/Xs4KoYz+77ggN57G4+qHxgEW/hJq62CxXUgLn1eY4DvmWexoFgJR3ol1c7D/jvlohT64baU03f30X5colNla0OFGgqw2cqXFjZqu2wgo8NPvrIAUUjIvD5fafdcox6zewpkaEJOhiTPj7RfNg8nM+grvKx0k2PL6V3SM6DnD9inx/rJvJCsQjqIIudzDG3gim7bba1EQNmEdhgpYzNoFma0umdxh5lID3uAu12ITA6ltjhMudOLhJb4WRVetut+HYznWTHv57Pvhn1C8XQqqYVXAYF9h7dWbSHVTykWbCS/eZ5EOAeZkIhqgfS+asrVAIdqUU+aqEOUMtThMvODVc2rrnxSk0fFdYHx4idh0nd3HZ5XB5IONweLzat3qrwkUxVOE7/GbOBfjGX0tWILXMXe/1pCew/qyya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8PziL60b3gdxdWdTQzRuJFZyxgpmlo7SUu6SnJEEvGygSznQYd+pDBP3LNyRW9yhWv4uX0KNqe+YOQPCDV1nMJtxm9rhQ2WYJhR8qmKveKCy/ZAIYx8Ew==; 5:wRfAOp9Hj88L+Ixi+sqf2HGkHfih/gKoSmfLg1eNgFIqG2yr/XS2QMVdw+mdKjB+yZ537++zVivIZz//ZEjoUSoQj1MF5ZfWy34DHuRvzQkS8hngIWuLXgcuydmij2hvyON3CqIauZctmmGM5GnOsmeF+jTuytHgjM3Uti/dalc=; 7:QvkPqZecM4koT3ouTbPjgngJdVdhOWsMPJIJ9++y+Kn2v8XycRX/WUCMdPxSx7SVMeWJvl2rbXy77P2otQx55kynFY5DjyGpwZXqxVPeg8+9yzM1ygluRO1Eg3UP5fw8Y7Ax11fOMnz6k4wWeaiF4ztmYQM5rcG+KopBFIpi7E8LcSKYFqbvxcrDr64R96mKlODk/LRDjB/1Tkc0wpeQUracYutxZfz+YVaJzh0AUEgn47CsB7cEWglkaCqmiVeU SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2018 08:24:38.1347 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e0d59fb-6936-4f9b-7aa3-08d60bf6886d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB1576 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180827_012455_543558_3196CEF8 X-CRM114-Status: GOOD ( 10.69 ) 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 This patch adds adma_table_cnt member to struct sdhci_host to give more flexibility to drivers to control the ADMA table count. Default value of adma_table_cnt is set to (SDHCI_MAX_SEGS * 2 + 1). Signed-off-by: Jisheng Zhang Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci.c | 17 +++++++++-------- drivers/mmc/host/sdhci.h | 3 +++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 1b3fbd9bd5c5..52ccf4644384 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -3322,6 +3322,13 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev, host->sdma_boundary = SDHCI_DEFAULT_BOUNDARY_ARG; + /* + * The DMA table descriptor count is calculated as the maximum + * number of segments times 2, to allow for an alignment + * descriptor for each segment, plus 1 for a nop end descriptor. + */ + host->adma_table_cnt = SDHCI_MAX_SEGS * 2 + 1; + return host; } @@ -3567,18 +3574,12 @@ int sdhci_setup_host(struct sdhci_host *host) dma_addr_t dma; void *buf; - /* - * The DMA descriptor table size is calculated as the maximum - * number of segments times 2, to allow for an alignment - * descriptor for each segment, plus 1 for a nop end descriptor, - * all multipled by the descriptor size. - */ if (host->flags & SDHCI_USE_64_BIT_DMA) { - host->adma_table_sz = (SDHCI_MAX_SEGS * 2 + 1) * + host->adma_table_sz = host->adma_table_cnt * SDHCI_ADMA2_64_DESC_SZ; host->desc_sz = SDHCI_ADMA2_64_DESC_SZ; } else { - host->adma_table_sz = (SDHCI_MAX_SEGS * 2 + 1) * + host->adma_table_sz = host->adma_table_cnt * SDHCI_ADMA2_32_DESC_SZ; host->desc_sz = SDHCI_ADMA2_32_DESC_SZ; } diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index f0bd36ce3817..25bddd21de31 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -563,6 +563,9 @@ struct sdhci_host { /* Host SDMA buffer boundary. */ u32 sdma_boundary; + /* Host ADMA table count */ + u32 adma_table_cnt; + u64 data_timeout; unsigned long private[0] ____cacheline_aligned; From patchwork Mon Aug 27 08:22:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10576625 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 5320317DB for ; Mon, 27 Aug 2018 08:26:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36335288B8 for ; Mon, 27 Aug 2018 08:26:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 268F6297FE; Mon, 27 Aug 2018 08:26:18 +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 140F9288B8 for ; Mon, 27 Aug 2018 08:26:16 +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=RuCoym4FVi+RE5Tbz9XAEvmji4k9RYpgad8fyZEfDEc=; b=q8V89u+4lZLtlS w97gjKe3khqczRCtgFbatBo2lqgx3TYFYwr9iMYPbp59kgL2VnZxDFRgp3/9/DtTcd/gW4gIjJG+D 70+8Skhf8fVg0XZqzPUs1WVnOcMcMuDZ3uGFJt/Xyzp9s9D/awQBhvw27vG1//eBsNMHI/bYntWvn c2YVqOTvzzDu2TpPZq8Kt6HUOI8ROOFpwed4mYltHB42tA6gQZhxoofP+mgo/Zx5zS+jj203MMFHS 24c+DPp1D6Uol6cnoJuWza8iKi0Wc9Sdx+hNgYFc+0M2M8brPgupcW+R4UKyBhh3alvD+cL1V3GBg qUGbzuiS79cWxqIrDUzg==; 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 1fuCqi-0001yU-76; Mon, 27 Aug 2018 08:26:12 +0000 Received: from mail-co1nam05on0628.outbound.protection.outlook.com ([2a01:111:f400:fe50::628] helo=NAM05-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuCqR-0001sb-Vm for linux-arm-kernel@lists.infradead.org; Mon, 27 Aug 2018 08:26:10 +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=t34Jq3WRCfdlEWi8ntOQHsyGNkAU8Rm7d/6CzQM9b18=; b=VfNm+M5sf+2QB1l8kBWsoVbkmqnTFhdHKCJoOGUYSmazpXBoL8H9alPLhHTjObQJ3aiZABg2kJt90qY1rJVrfvkt/UNxp9BYoEzmcQXT4hcMIkIGORRiDpVsx9hFiWKAzKMQHZllxQ9CBE/zR8sD3gN92HzweA3p6A/FAt+yEtA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; Received: from xhacker.debian (124.74.246.114) by CY1PR0301MB1578.namprd03.prod.outlook.com (2a01:111:e400:529c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.14; Mon, 27 Aug 2018 08:25:41 +0000 Date: Mon, 27 Aug 2018 16:22:42 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH v5 2/3] mmc: sdhci: introduce adma_write_desc() hook to struct sdhci_ops Message-ID: <20180827162242.0fc59e00@xhacker.debian> In-Reply-To: <20180827162026.3901de27@xhacker.debian> References: <20180827162026.3901de27@xhacker.debian> X-Mailer: Claws Mail 3.17.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: TY1PR01CA0193.jpnprd01.prod.outlook.com (2603:1096:403::23) To CY1PR0301MB1578.namprd03.prod.outlook.com (2a01:111:e400:529c::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1fddc7e4-caf1-4060-19c4-08d60bf6adc6 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:CY1PR0301MB1578; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1578; 3:7tbD/BihYe0ssK7GQWsdDD4abLoy+/6jmkk6MiiWQK9U3qKys6xtTeCFnGVo2HHRHKNydK0BtuvujNKTWYBfuVBLQiiJZRaqShVY6v/O5ltQYS/WtMbYIjQcc4deeQIuyn82q6/zu/zIyH3YHl04xin1bW0gmy3mUTgLds6DrUTHoBqkid/ixf7TwWs8M3rY5Mu4RJlqMXXO694e7qUQS/HvwkWO+CkPec/BH16XZVxLDnSyJbzgEn+149fEqWqs; 25:8bqzlSa+BE4X12J4w080RBjGpOGTuuSlB/R6BYDunCDB6ow1dQsG0BEKeARl7HybWBrNhz/PNzSldFVDcCJFMekYKGcpq8zTjdxgis9989j6O3ggBagJgImo46OF3WhoefK6c1HR9/uxX+VGvnEa57PcKUPikRIPEhsxpOuopBRyZo0z5oBoHiYK/h9aPCHZM1YPkdUc9H5rawtJFW/bj9fxn5bMdck7km+rjq8756mcHr99R5x9iKRE2yH9GvYt8OA8PoOjOeFd9682E2svdUafu8iEbB2xRJs+OlgT7BI4YwaKfq/xFLzo16TsDHYwYBbLlVUAfk7fbbq/SjEt/A==; 31:X9Bcg7HK/T6phUz/6LC/DoDLEBeYnhZoKRa5Ri3ga/qLuDs+jHeIiZDXsil4E7KcsfDo24IgmFiXhlUxgTZ4mCaLEUJcUMDlaoXhMLacHHP6Hk3035NW1f8+n6AavsBQi2FMbm1UCdAp1f48d2OjCdSDq7liZ66ilP3dlyXAdakqv1I8fzVavvFL5IhYRexpEjmyTOrBYVj8Fe9vvjqpmju1aiu1km6z+eALwtix5vA= X-MS-TrafficTypeDiagnostic: CY1PR0301MB1578: X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1578; 20:JwkvusBj384BkY9KexcacW/igD6eWLb532uQHzpJje/yh9klznlFO56N/H9X2LOlloZCvvsdQvAZADR1XYtW5MUHq+FTOmfyeJN9rxZBz6Xf+jAh1XYsanO2oXo/b5AP73DLUA0d0q03cVzHwxa3XknmPb3mlsD1ogg32tOrBSMbMrvsOi5Av26kTgHi29Va3YV2b8FialSS5PxofcXDadGstRcjyJ5QtLus4RfS6DCm8HmfuW74r13TqSNfuSI7hQoKsO6YX9G0QuxfFuhUs+5+kAZCzNkb4MAvBQxEmk9jjQOXoIUh8jeyt1kiQUkJ6lDwDwx7cGmQiiigb0hBHODoijpkiwBkyADkuqXSSvuGuORMSWXm0jhjYekiUAcZkU3Urx+QFg0BElhIWVR1197f1GMGghUaBlTlwvB38HKuEp+T/nfp+r+jmj/uQONDfXpcjplfKbrzMN0yfBgmHJBXmHgutXecepxNU6rR/WvBQwOpEipHB1L8RYc9ZuIw; 4:ZkxR94yds9GLfVdG/OuW4vSgwqu5/Vpv4FA5JROp4w5i5AVe6QGo80CBW/pSg8J/f1wYWFAmjwCMHitGQF79uAoXXO0jbRwXghXx0/1sWjnJtlmXUC6Jy31BX3TGLs+Onu9aur99rana/Sl6OuCxM5v8WQ3/DgRxHnEfioRKApXHv3Mq7PYVj4EQcJM3cpXNkhpbkY/K6BTDLWqyFTFJxyRvP89Gk5rJ/8v/0cVlsnC15PE2klcf2Vzg81hlCmVHfTxoyTtoFKVoG0GhXmbP8KjrIgR7m2IRCYXxs0uYH+NBCh48r4E8qYGMbeScgt1X X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016); SRVR:CY1PR0301MB1578; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB1578; X-Forefront-PRVS: 07778E4001 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39850400004)(346002)(366004)(136003)(396003)(376002)(199004)(189003)(23726003)(6116002)(3846002)(478600001)(230700001)(4326008)(47776003)(72206003)(956004)(476003)(11346002)(54906003)(316002)(53936002)(446003)(110136005)(50226002)(9686003)(8676002)(5660300001)(66066001)(81156014)(81166006)(105586002)(76176011)(186003)(16526019)(25786009)(2906002)(97736004)(7736002)(106356001)(8936002)(33896004)(55016002)(50466002)(26005)(68736007)(6506007)(305945005)(86362001)(1076002)(7696005)(52116002)(486006)(386003)(14444005)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1578; H:xhacker.debian; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1578; 23:bzsBDuueZTYAcEEtmfWKQ/seUugu9hI3SVZbGsT?= zxXHTvij3SVp5THF6YX01BPWLk6+hyq/KXtyRE2hIzS92N+Gk3OaT0uG4RDMwfWrDl3Ad9y6ZP7DCIUbgxza7t28i01ulNzJbd4t4wPzl1n2m7dnp/xf8oQk39yqLGuwIRD03CAe0DaVh2CG1COOSXKc1uJCm1djgwVteFRLFcCv8WNdtQ4mHFPmDszXySc0VgmnVrgcgulFNY6phTuO57DVXLa+knokzqm5zMPzYixJdfI8A9m9m+RIODfF4FvVrnY5w7C5OJ3pF58nToJ2D9iSHTdd9U2d6uX97HcVlPjMEtZGKSPJNG0yfl2TUgStc8pQamL9jPtCo8ExctXaK0a8gla7AmjcnsuqkraA9ILeIfetdwAWFQvfOtBqi1mfNZUtLzMibXAZS0XUXzfVWSFNOJZSLSgujLyGLB+4a7igvcb5P/etDJa4lGsJO+znJrWS0UXed3ihpjBqCL8RiRBnoHQM2xzRf4fIuwxc1R0ZWt/jwkyAm8a92BpF/x88feMk1oGDLUJVWAgSYRpyMbWdv+VatTrpUwpCoTIKPgAfbEqW5lm18ldQtBb1kfXYddC7a1Rg01VIEKFRnzxPuUhY9Vb9OJBABZei+sX8ZKwh/XvO3jLn6i/kfB4xQAk9fjTdxKmi+nlXnoRMQ5Jvhj16MRdy3jrgqakMp1BfdPlaEN0ELCT/smg3pmqORfr0Kaqxm+OqngtSFvp3wXa3qYXX+EICrokL7Al4Wkb+v1Xt1nquBkVyCuv6Iw1+EKHg0GsOLyVardZaXiN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J37lyF1DTxYUB7lo48gEzsWjdWrkm5+0y2bMrd5U0HTJH8oUfqj2cUajSVgChx2kQjDmOY8ILVNIcC522f9DqyV1OSeQdnrJsw3uTvNJ6T6/HWn76tzrsw4yFAubUpYFhbIu16zWziuBN9kDm4Rkaardjvj/pdc8fxWG6f6IhDhNjPS0QOUdDL4eeikpY+kBN8gOSE/tnGiEMCMGMGAyE/NlzSGdqLBDVSytkzMqfamvHxvGE1C9jVRu2oiaePSYS7Ixr6GyyLzSe9Xx+g==; 5:SN47ULbc2d880ukblMv3IhNjYplQZo3jKil4qFivHcN0Qg2AzgfdVe4xhmJdXwXyCUNQ+Rb6KNWNnbzHTx1XqpBZC+geifnZk8+hlgM1zq6dpfHoIVE530xO3j0HbzdmmohuYaLUvC0P7BmYYWXAwg3bu+PljMHCE7JuRDhz96o=; 7:PErXM+V6OpBaC8lAcg1vWH3tE6DO7228aSCH+IsIyPLXkB8W4GQmbvquksKhu8uCTGA+CLvsZtZNcr8bBhAIPB0qlG/LUMLPutxYbRqkEjQLFR1bj5DHDFOKOguQ+5EGLbp0Y+W+FyT9unC9My3BMI3Ica30C1iz1+B+6MTxBd/XtZy4+rRYStxIw2mNNdD/E74srG5ak60n2CWLbp7sS0t2YvLqODBvTzJKgsFyz1rU2mjUX3nYuk/fztkNP9h8 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2018 08:25:41.0273 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1fddc7e4-caf1-4060-19c4-08d60bf6adc6 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1578 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180827_012556_200356_0DE87269 X-CRM114-Status: GOOD ( 10.42 ) 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 Add this hook so that it can be overridden with driver specific implementations. We also let the original sdhci_adma_write_desc() accept &desc so that the function can set its new value. Then export the function so that it could be reused by driver's specific implementations. Signed-off-by: Jisheng Zhang Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci.c | 37 +++++++++++++++++++++++-------------- drivers/mmc/host/sdhci.h | 4 ++++ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 52ccf4644384..eb21d2db7f05 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -554,10 +554,10 @@ static void sdhci_kunmap_atomic(void *buffer, unsigned long *flags) local_irq_restore(*flags); } -static void sdhci_adma_write_desc(struct sdhci_host *host, void *desc, - dma_addr_t addr, int len, unsigned cmd) +void sdhci_adma_write_desc(struct sdhci_host *host, void **desc, + dma_addr_t addr, int len, unsigned int cmd) { - struct sdhci_adma2_64_desc *dma_desc = desc; + struct sdhci_adma2_64_desc *dma_desc = *desc; /* 32-bit and 64-bit descriptors have these members in same position */ dma_desc->cmd = cpu_to_le16(cmd); @@ -566,6 +566,19 @@ static void sdhci_adma_write_desc(struct sdhci_host *host, void *desc, if (host->flags & SDHCI_USE_64_BIT_DMA) dma_desc->addr_hi = cpu_to_le32((u64)addr >> 32); + + *desc += host->desc_sz; +} +EXPORT_SYMBOL_GPL(sdhci_adma_write_desc); + +static inline void __sdhci_adma_write_desc(struct sdhci_host *host, + void **desc, dma_addr_t addr, + int len, unsigned int cmd) +{ + if (host->ops->adma_write_desc) + host->ops->adma_write_desc(host, desc, addr, len, cmd); + + sdhci_adma_write_desc(host, desc, addr, len, cmd); } static void sdhci_adma_mark_end(void *desc) @@ -618,28 +631,24 @@ static void sdhci_adma_table_pre(struct sdhci_host *host, } /* tran, valid */ - sdhci_adma_write_desc(host, desc, align_addr, offset, - ADMA2_TRAN_VALID); + __sdhci_adma_write_desc(host, &desc, align_addr, + offset, ADMA2_TRAN_VALID); BUG_ON(offset > 65536); align += SDHCI_ADMA2_ALIGN; align_addr += SDHCI_ADMA2_ALIGN; - desc += host->desc_sz; - addr += offset; len -= offset; } BUG_ON(len > 65536); - if (len) { - /* tran, valid */ - sdhci_adma_write_desc(host, desc, addr, len, - ADMA2_TRAN_VALID); - desc += host->desc_sz; - } + /* tran, valid */ + if (len) + __sdhci_adma_write_desc(host, &desc, addr, len, + ADMA2_TRAN_VALID); /* * If this triggers then we have a calculation bug @@ -656,7 +665,7 @@ static void sdhci_adma_table_pre(struct sdhci_host *host, } } else { /* Add a terminating entry - nop, end, valid */ - sdhci_adma_write_desc(host, desc, 0, 0, ADMA2_NOP_END_VALID); + __sdhci_adma_write_desc(host, &desc, 0, 0, ADMA2_NOP_END_VALID); } } diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 25bddd21de31..2115416f973a 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -606,6 +606,8 @@ struct sdhci_ops { void (*adma_workaround)(struct sdhci_host *host, u32 intmask); void (*card_event)(struct sdhci_host *host); void (*voltage_switch)(struct sdhci_host *host); + void (*adma_write_desc)(struct sdhci_host *host, void **desc, + dma_addr_t addr, int len, unsigned int cmd); }; #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS @@ -736,6 +738,8 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios); int sdhci_start_signal_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios); void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable); +void sdhci_adma_write_desc(struct sdhci_host *host, void **desc, + dma_addr_t addr, int len, unsigned int cmd); #ifdef CONFIG_PM int sdhci_suspend_host(struct sdhci_host *host); From patchwork Mon Aug 27 08:24:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10576629 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 A40A317DB for ; Mon, 27 Aug 2018 08:28:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AF342968D for ; Mon, 27 Aug 2018 08:28:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BE7E29692; Mon, 27 Aug 2018 08:28: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=-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 BF2E22968D for ; Mon, 27 Aug 2018 08:27:59 +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=4m9lmisb40zOKaHt8dYaT8oGeSeVwZliyztnExzOkXg=; b=rTRXgzVCV6Q/CG FLVwK6+H7BySUMZQOM/SKqs0ituphjyPuaLSe40mmc2W4hYpQ6F5iFUT9e5DLr7BwegWbIeYefS5W CEBu6cfGD1dvP2+5MiPXKl2/37jmm506Hwe5HCmLQhwWFqC5DrJ39+5CsAmOadUbX9mTJXmra5F1p yrDC5RLe+YMbDyxYOqfwY0+0y5/YuDeT8ExpltuhkGxoEuGdUa606R5NTsMb50iVPAaFTsS1VVQMy udDy3AWVbrqISooM6Hc7ikpGpV9/NkHb5E+EBO1KvaMl3lj/oROWH18zXRxKUJ2CJOl5uK1mapRsI JYZtgO+8SOhcZFJ0tR8Q==; 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 1fuCsJ-0002fm-0W; Mon, 27 Aug 2018 08:27:51 +0000 Received: from mail-by2nam03on0067.outbound.protection.outlook.com ([104.47.42.67] helo=NAM03-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuCs0-0002Uo-Ir for linux-arm-kernel@lists.infradead.org; Mon, 27 Aug 2018 08:27:34 +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=N9RRjbOvBHjb8Mm5unulNA3GXdei0drLuVJUXzZw4R4=; b=p7+2+IIjN/xaJIbEyB7/s5fEDFCBQMPY9DfDobiODs1bEcXwfGaOAAuMHW/pIzh+xP6Kpv5x4MQWxcqMCd+yTkdp2qXHnsqj02kqVoTTV0JpAX4I+qw7dpdy80Sw1phjw67/qsHR4eLOsciH45Y9rmY+0WledEPRAuML/V5AcWE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; Received: from xhacker.debian (124.74.246.114) by CY1PR0301MB1580.namprd03.prod.outlook.com (2a01:111:e400:529c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.14; Mon, 27 Aug 2018 08:27:18 +0000 Date: Mon, 27 Aug 2018 16:24:19 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH v5 3/3] mmc: sdhci-of-dwcmshc: solve 128MB DMA boundary limitation Message-ID: <20180827162419.61afe238@xhacker.debian> In-Reply-To: <20180827162026.3901de27@xhacker.debian> References: <20180827162026.3901de27@xhacker.debian> X-Mailer: Claws Mail 3.17.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: TY1PR01CA0185.jpnprd01.prod.outlook.com (2603:1096:403::15) To CY1PR0301MB1580.namprd03.prod.outlook.com (2a01:111:e400:529c::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2da08f8f-342c-4e77-ac78-08d60bf6e7c1 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:CY1PR0301MB1580; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1580; 3:OQLlM4zE4bsPMkNCHJSlksYe0nPAl2tm4O0N3nAluJeRqkHTTD984FGYLQR5Xpht3cSa0+yy8YVw+PjPQnGV8Zzww4Iz5jMs15QLuRXAVGdKQMl5vBo3Wcbn0O5EdrUMGH6dTS8tT3/uLg9o5FKzG4a8G025l5QJIowh8rVXFAUMHnaemsLHXqT57s8vLJ5V7HFPOUhwG4973cEHaM2miJQS6YlaTRunkQW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nlGfVFzDWpAO4ycffnQ16pyD0F1+p/oAkvPkx1WyKN404n0kPrZOFKxLFKN+ojDsVTsYq/A+VVl/WIWXIp9fx72o2bGgLDSXWP9+8NqdSwXjBwuf0IH/QXBxEb; 4:2YfO3l9s6U/gql6+rNcdoEHo1SOjt0luz8NSL75psTMKmHDpGyuKDZm23qT2IMvUOiaObNNaFsgI3YRfF9v9HgUtLn/MtYUYJFVbOAs53LNEuI5OHwlquEAmwppwS7E6Ji4Z6Y6tCc7Rni0yW88m34uPgFhgqNwkGBRYn5UdiXC5ECTMkz7C/VUuU5Afgn/HwkrTQhZz4oWXPgbqhFPE8+mwjj4MSFTCEr7jIRhfptPUzTqalcTtbk9iGK5JdEVlTFAPlg3ev+ccWjqvh75/qg== 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)(3231311)(944501410)(52105095)(10201501046)(3002001)(93006095)(93001095)(149027)(150027)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016); SRVR:CY1PR0301MB1580; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB1580; X-Forefront-PRVS: 07778E4001 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(376002)(346002)(136003)(39850400004)(396003)(199004)(189003)(2906002)(6506007)(446003)(14444005)(66066001)(50226002)(8676002)(8936002)(86362001)(11346002)(72206003)(478600001)(68736007)(386003)(47776003)(26005)(476003)(316002)(54906003)(110136005)(53936002)(186003)(76176011)(1076002)(81166006)(81156014)(55016002)(9686003)(486006)(16526019)(97736004)(106356001)(5660300001)(230700001)(105586002)(3846002)(7736002)(33896004)(6116002)(25786009)(50466002)(4326008)(305945005)(23726003)(7696005)(956004)(52116002)(133343001)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1580; H:xhacker.debian; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: synaptics.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1580; 23:cKU/3ACjFHLdOqzFLY1c0xXQK9STfYvt5gk1VKt?= uzXJUfZxVqIaXR0q03GDo3b/vWY5XAytHFZkRMN3H2s9Jx3Cu8I5auWhvXi2tS2p1fyu9I0HKT3VglK7UcNou+/baSY778xkIyP9fLT40lcga8WaJK0OSgW5Ln1abIgaoGXUZ3CNMW+Om3UtDLwmvU31cr+er2vgHJwkPBh9g4m62+c1q01WHgtsWNSAmXvpFWmuBj0RWC+UGyKC3S/iM1iKO8jMMg5lRI9t+Vme+L7m4IMhuMj4qIdCNpSjzZilaqvqkhYBkC3vhFHZCJejw0wB3VnClppli86HNfqQEZFpXXo+ZewHr37IVYA3TXVSUT6cHwO7uglpF+ic7Vwx6+/3FcJWOFNM4yNgaoVpJAMYqOgfxO2hbhugs3Yxo6uolTnJrMV3l5ZmAZ4O4QfhSUjynnh+I3VHOdzSghbtXUMHZ1p1fPqoAURWIU+Vi+SXf1PZ/NJiHoE5FdJGg+deGl9EW5stX8UME2+C2L/lPmybGMkCQ+wX6mLhcIaJEu8QvB91ElaNa5vhzX+O4g+If1Pn7ol9XG7D+OiVcvtqgmy9dUZ+dct9jwnYcCmdTAN54WEt4ApEdTXlQDY7+ZZA851ogOWvjdX00tAohF8DSxNIooWJNqo+LAekTaB0nqSuj30ndY1z+a0+RO1AzjF3DaS/1TY+uGxWN+WYN3gzwJHXKH2midz28ePP+WQzx+3gRlzKMdMGhpCzW2MpGYfTZizpm6+4ijHs+vh/UTqZxJN43OWyZVFWKmqvsYqf+Q0Y2PNkA/Ip24jxc/7wyUzm5F9xZxHxC10jP7YdHsVX3ydY+2kVjhGkQakWAlpfXCGoTEPAPaK2u3pyPPPNA5n4XLq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/RppfVIxcXwlOlMKiTn/xcCUE8jVaUDUlEtgaauAf8CpP4tQR7MB+nqk2zqrN5a/myuuVDpBS+N4GB7wvC8E98UOM53Z1FQqIDwB0SvKrsx+rcJbVuDG7EMbWZJHZ34wzJXJzAmCVC3uWJvOm9214fGwGEha2jCH5sTH9n+jbraMwrQ2Yp2RHoGGlKDoDp+JxxccBiwzqE4TW30YA==; 5:Ew8p1sRQa+ak9mJAo3Lz3vuA2sd5xKZvbxbQrJMetsf8VRzWkCZUx7lxrXgHF5DpxrkedUlNrq4bjg8uQKrGoQvxjq18MOHlrB4dG3JskUae8DpaA9vSOy3Ihnar4bCFMWC2zu+orMRh0H5e+liFJ/lWq1mvLcywXWpwvOZJd/Q=; 7:ISH74r7aQBqIgmdjxydA00BP0GWXRM+yIODyqIBpQlsUNGI5twdq9mzd+UVr+escejvg/jvsjacEo97eQlWBw51sxBOyQAOqcqUgIOXRjMI/aq/4XYiAjdNbkO6MSdaBSUCg8yQQH5tKurKNxhM8spyYrrzuPd70sY6NEL/3odQDgs76OoahWpNQptoTYaIkEvkp6VSEfGGrgr0L8NxvcznSWebE6EBUPKF/nGU5JO7wXpjmBucd4SpbIOQ5rprA SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2018 08:27:18.3242 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2da08f8f-342c-4e77-ac78-08d60bf6e7c1 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1580 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180827_012732_666630_C553DC12 X-CRM114-Status: GOOD ( 11.07 ) 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 --- drivers/mmc/host/sdhci-of-dwcmshc.c | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c index 1b7cd144fb01..cfbdae8703a1 100644 --- a/drivers/mmc/host/sdhci-of-dwcmshc.c +++ b/drivers/mmc/host/sdhci-of-dwcmshc.c @@ -8,21 +8,50 @@ */ #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 +65,24 @@ 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); + /* + * The DMA table descriptor count is calculated as the maximum + * number of segments times 2, to allow for an alignment + * descriptor for each segment, plus 1 for a nop end descriptor, + * plus extra number for cross 128M boundary handling. + */ + extra = DIV_ROUND_UP(totalram_pages, SZ_128M / PAGE_SIZE); + 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);