From patchwork Mon Jul 30 02:44:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10548389 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 982B2112E for ; Mon, 30 Jul 2018 02:47:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 861152948E for ; Mon, 30 Jul 2018 02:47:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79D1E294D3; Mon, 30 Jul 2018 02:47:06 +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 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 1CC9629494 for ; Mon, 30 Jul 2018 02:47:06 +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: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:In-Reply-To:References: List-Owner; bh=GeqyRhVwuogORtdJzo/d/mfH/iGi9TNNIQ3hOphGqJY=; b=nuAiXWJKKfYm6T dHDKyyEdcJ0dSb+2J8XB09sjPqwOBEPh+7duQ8LkiPshCKRURMTmbPVRQu5/TGmD53JPYb5kyscOn +UjnHkrwSDcMe2dSogU8Spv8sf/diPGUhBNEBESd9GWmPUzaE5Ykfm6oyav7GVd7C8kUYWyT8Yi2n rxS8BkbpCWKXWOQ0dHvq7LpXSqZFWLl+NPwGF1V2GzBDH0Blc+HAAhvryE2dcsXRMZfrtqHgX7LTs vZhLiUNXktqNGdPGAaSbnvMjZivRlI6xc8Non5tVaLWoQTr+9hDk22HC67H/u5dvTeClIfG7Qpa3o GRCJAAY5lFRr2DN5FMMg==; 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 1fjyD8-0004Ht-CG; Mon, 30 Jul 2018 02:47:02 +0000 Received: from mail-dm3nam03on0043.outbound.protection.outlook.com ([104.47.41.43] helo=NAM03-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fjyD5-0004Gp-Fw for linux-arm-kernel@lists.infradead.org; Mon, 30 Jul 2018 02:47:00 +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=oBNdgngxV6F5slvk6l8KUn4Gw+nIUof/U1bct/+gEzA=; b=JbhazQj0nd4YnydvveFbfmGLeJfDTOrfCfwdlAKDwr79361dFwpbXj9/ua+N3B5+NK0kUe7zdMREjzW+GOd3Ql6Xu+Hn7XzUHF4SUfbNSkho6Y3fmWo/GDRcRXjR+KHoV74Fe7FEPKK8dRkagUbgkbXpapLRojZVoicWxe26XRs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; Received: from xhacker.debian (124.74.246.114) by BLUPR0301MB1572.namprd03.prod.outlook.com (2a01:111:e400:52a9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.16; Mon, 30 Jul 2018 02:46:44 +0000 Date: Mon, 30 Jul 2018 10:44:24 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH mmc-next v3 1/3] mmc: sdhci: add adma_table_num member to struct sdhci_host Message-ID: <20180730104424.44fa39a5@xhacker.debian> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: TY2PR01CA0002.jpnprd01.prod.outlook.com (2603:1096:404:a::14) To BLUPR0301MB1572.namprd03.prod.outlook.com (2a01:111:e400:52a9::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f242d97e-a87a-4ade-b273-08d5f5c6b09d X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:BLUPR0301MB1572; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1572; 3:WWzQ5dKtb7gT+6UR2m7hAaTl88NCGzOSNt2Uh8z3tLVlFBnpql5GW3JyUvELv7FI8ifZ5aE7crYapt3O/TuwvsUtp431Qh3xQ+Ih7gQbGAZ1j24odbq6ROBgrCeXl9hWBlaFsavq+re3pI5g465xZbzD/XSYexmB4gPDeoRPFCdNPPKVcTEcTneadz17d/vO1dQPW2oCjRuNgS8O9xHLx2lrGmgCEG+laZX7aYLEa/yX0UI9QN8rIZlZG/y67fFD; 25:EEVsb2wH5yzTJq4EsAnWt5JEhDUnqDiSoos03RFPvRsNILkcwRKYDz1ZlJo069tAqD6i3q3+rcxddk4vR0L9rDzW9BEV8EduwWDQM54RIaxB3U8niiEvf97/pGbLO6HOS+7fG0sG8RvxH0v25t1cGCuGZrEDAS66qmKfMn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ENinJNOjBS2D385MkluI09bP0F8XMncD/DS2x6y9HG/u5MIqbVwG4RWydQCGUIzfsqAzqV2DDyh3cMwJsURFrwoVD5LAHhcmqmU+N8dd8JTEdX8IbtGt7Z3LGnnKSENDsfosyW5q9Fu8zm13BSLOTj5QK/N2Mro101ZqtnHwYYV2rN5IKycN5PRzrBBmw4aGE8VIH7rUPg== 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)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:BLUPR0301MB1572; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0301MB1572; X-Forefront-PRVS: 0749DC2CE6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39850400004)(346002)(136003)(396003)(366004)(189003)(199004)(386003)(305945005)(6506007)(33896004)(7736002)(476003)(486006)(956004)(50466002)(16526019)(26005)(186003)(68736007)(6666003)(110136005)(55016002)(9686003)(52116002)(316002)(81166006)(2906002)(81156014)(8676002)(8936002)(7696005)(230700001)(106356001)(50226002)(5660300001)(1076002)(23726003)(6116002)(3846002)(53936002)(4326008)(25786009)(105586002)(97736004)(72206003)(47776003)(478600001)(66066001)(86362001)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0301MB1572; 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) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0301MB1572; 23:UaL0yamRr6PduuYY/XDdcCFJ+t5noXxEh7ELCvM?= UUGYsVorRD2YyTi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v0FvLEEn4uC22gzeZObzo2LnmqIE8VlD6hg4gfY=; 7:wieIFn95WGoUG5g4dPnYO5GS5mLrul0rbEuXbs+nQ/bCVW9HC9Z+Gqn04ZTnyeY2ibNhSlewgIz1FQdoTqqfP3tDQoxsren+/NKvukGmkoEozX6WoABpUmrEWJJbaVvSbxexgrakrJrTS+2GKXXd0gJvuthwqZcPGPq+xvoC16cZkxLbih/7yO7Qva0j3xTiHTHRe6GUVm7k0AKTJwNoJqQEoMc+Lh39Qa7xOrH7MnNHHVAneS6icidV7Yorc2UJ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2018 02:46:44.1983 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f242d97e-a87a-4ade-b273-08d5f5c6b09d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0301MB1572 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180729_194659_576999_E01D835F X-CRM114-Status: GOOD ( 10.36 ) 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_num member to struct sdhci_host to give more flexibility to drivers to control the ADMA table number. Default value of adma_table_num is set to (SDHCI_MAX_SEGS * 2 + 1). Signed-off-by: Jisheng Zhang --- drivers/mmc/host/sdhci.c | 17 +++++++++-------- drivers/mmc/host/sdhci.h | 2 ++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index a7b5602ef6f7..14dd4a49e03b 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -3316,6 +3316,13 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev, host->sdma_boundary = SDHCI_DEFAULT_BOUNDARY_ARG; + /* + * The DMA descriptor table number 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_num = SDHCI_MAX_SEGS * 2 + 1; + return host; } @@ -3561,18 +3568,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_num * 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_num * 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 23966f887da6..d55fd7033e93 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -563,6 +563,8 @@ struct sdhci_host { /* Host SDMA buffer boundary. */ u32 sdma_boundary; + u32 adma_table_num; + u64 data_timeout; unsigned long private[0] ____cacheline_aligned; From patchwork Mon Jul 30 02:45:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10548393 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 4AFF914BC for ; Mon, 30 Jul 2018 02:48:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39BAD2997E for ; Mon, 30 Jul 2018 02:48:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DAFB29985; Mon, 30 Jul 2018 02:48:17 +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 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 B7BEF2997E for ; Mon, 30 Jul 2018 02:48: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=baoEhWivsb6/2yF6VdWItofzFrDylYr4XmkBHpSDQO0=; b=bvSM2Y/cCpBWb5 iQAuhgs5DWjhjeoDLKndEc1VcTmEtnid/bRx19woKlbeNzLOEGnz6y4R57MXMtKg/IoLR5PFUyChY 3oXsKAPdCBY462AMbopKU3iEAYKoetZf/yx71gVC7vVYX6QjJD5m2AlTWpHuONSSqwQq4uB3etzwn 0TzOjwJN37Al5vg6+kTnZ47ED/NfmbRVR8DZHuXH/47yAT7Cl7+Z/3TNm9n26ATpi5XOkFLelIYGL oxkSvdsKCoH8z/MRNi7HHaXHAwufpkr0RiGlEL1WEjhlF2PzOThJgO+tcB9560i0pDSK7X57vmH/k m5vZf4bZhCWPbPC/36ww==; 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 1fjyEF-0004dj-HH; Mon, 30 Jul 2018 02:48:11 +0000 Received: from mail-eopbgr720078.outbound.protection.outlook.com ([40.107.72.78] helo=NAM05-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fjyEB-0004bH-RY for linux-arm-kernel@lists.infradead.org; Mon, 30 Jul 2018 02:48:09 +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=J4u5uB4pyMz2QMMCboV1G5cEG2ARP2isXycosXVGyGw=; b=vV0ZaRvbHgOc+E9iBu2TRDBFO74dkH+zWJmhC3aqZERNabASl0iAmCFRbTOtBOVFZ26/XKWg1hDgT6hijk+GePpr4R9Srbzn55MaSlmgvcl6gyT8R8iJvhkivhb6P9lQO7K3U/+sVDEYfmH9ecAP1VhG3mpxr5P7+HJnqy4MPdg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; Received: from xhacker.debian (124.74.246.114) by SN1PR0301MB1584.namprd03.prod.outlook.com (2a01:111:e400:5232::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.19; Mon, 30 Jul 2018 02:47:53 +0000 Date: Mon, 30 Jul 2018 10:45:31 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH mmc-next v3 2/3] mmc: sdhci: introduce adma_write_desc() hook to struct sdhci_ops Message-ID: <20180730104531.388b4f39@xhacker.debian> In-Reply-To: <20180730104228.28b58bd0@xhacker.debian> References: <20180730104228.28b58bd0@xhacker.debian> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: TY1PR01CA0160.jpnprd01.prod.outlook.com (2603:1096:402::12) To SN1PR0301MB1584.namprd03.prod.outlook.com (2a01:111:e400:5232::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: da222d22-5b65-4da5-e54c-08d5f5c6d9c4 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:SN1PR0301MB1584; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1584; 3:9+hB5XNZX/exSi6Hf88QDLdSPrJqYG5+cdNf7od1G9rqjdAfGeECsUiNJyfejD1c2Qzn9BzlGvpyz0D5CPwDvzRusOy8OnH4ktGPV7hNqTx48my3rnPnGdQmT/gL+QFTAaMBJNYGOFAW2yd0zdMvQUzu/fMR8pKous69NyAItdJet1ts2XMafQ9KQiA+RNozaJ9ZlCcEtuZ0D0qCo/l5jjI4sXhvo0hCONF2wsuSjh+CZd0pgQDP2WjFK8LgZ4H4; 25:q5fg8FQcUkpTTNpeZGPxxsjPsV0uNAW2GL4GaLsx2TLPimib7C6/62J/NjRtmRZXU28kepvsgay2VsrSaAB/ZceGmuTXb++3+jQCTt8OpnqK4K3rm9EQQSDBBw1anZQsZt5kAuM+LgW3+SnHLOoL3t092G8fkFFuhUi7xUD2ilfk/YupJGLkVxpoZJtogFaQNzBCq+OKLScEqhXoKuhYR9/Y9Z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TzRw/Ht1GCXCKaYkrjG7lQsKVUNdOPjwHROajfPsV59c1pCHWg0RChU6R1OWwQFBhF5ZYO/4V2cRpcB1/ixTBOZnckm8NK4RlNb71Gfg2/S+4L7OW3wt1sNG1R9W8eByqnfrzDMlLADepl1+2q1BVcYYTNHNBU4w9txed0w== 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)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:SN1PR0301MB1584; BCL:0; PCL:0; RULEID:; SRVR:SN1PR0301MB1584; X-Forefront-PRVS: 0749DC2CE6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(136003)(346002)(366004)(396003)(39850400004)(376002)(189003)(199004)(105586002)(6116002)(3846002)(106356001)(23726003)(8936002)(230700001)(6666003)(50226002)(7736002)(6506007)(386003)(68736007)(186003)(16526019)(7696005)(2906002)(26005)(8676002)(81156014)(81166006)(52116002)(53936002)(76176011)(478600001)(4326008)(72206003)(1076002)(47776003)(25786009)(33896004)(97736004)(476003)(5660300001)(110136005)(316002)(305945005)(956004)(50466002)(486006)(575784001)(66066001)(446003)(11346002)(86362001)(55016002)(14444005)(9686003)(39210200001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0301MB1584; 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) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN1PR0301MB1584; 23:l9m0jEctKXTQezuVPtFSSE/1chWEhPLnq3bCY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vkSSgZP0BMSJO9gdjnfPNq3yqaLSs/zrL+grbwwuRmvJlk4bOZixoN6vFmAY99S8x2+gkXSiyOoKjhlUwg04oMg==; 5:dB8iLLo+7hG7vtQm8pDLQbvWXRxXQQhVjZWRzRy0tLfzPoL1i9IMrCK7NFaGCwZ9eFENbmCsbAxcji8UrWn+zKXV8xl2QHa7RL7jVjiwS1UaPmca0XKfI9QrW2Prl/wcBLWO6UqmP6Y11Nvvta3h9E4nxIPkONL9BFWy3nQETuM=; 7:3SDQ16PZPIaXuwapRydO+UakRCjcPYV42f1/zTlPtti+zDf3PyqDJElgBDSMixkZGBZT4b1NdbwDizDp9ffCODhNf+/1FW1HqceijLKf4VRdDzG6u7aq2pMnRCZHyrRJHw6rf7dQvc+OySquUgoU22npnbR4wvFfIjYebp5koMs+RV/Vdfxu0fSsMbQ6tbq4IHm73qlZompTvSV1C4+CJ0O+QKWMdn61MyjFE5g+HRiufhROL9Pm4liTIr0NS/ZY SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2018 02:47:53.4380 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: da222d22-5b65-4da5-e54c-08d5f5c6d9c4 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0301MB1584 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180729_194807_922275_B4109B2C X-CRM114-Status: GOOD ( 10.05 ) 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 rename the original sdhci_adma_write_desc() to _sdhci_adma_write_desc() and export it, so that it could be reused by driver's specific implementations. Signed-off-by: Jisheng Zhang --- drivers/mmc/host/sdhci.c | 31 +++++++++++++++++++++++-------- drivers/mmc/host/sdhci.h | 6 ++++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 14dd4a49e03b..50c846d99182 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -554,8 +554,8 @@ 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) +unsigned int _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; @@ -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); + + return host->desc_sz; +} +EXPORT_SYMBOL_GPL(_sdhci_adma_write_desc); + +static unsigned int 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) + return host->ops->adma_write_desc(host, desc, addr, len, cmd); + + return _sdhci_adma_write_desc(host, desc, addr, len, cmd); } static void sdhci_adma_mark_end(void *desc) @@ -585,6 +598,7 @@ static void sdhci_adma_table_pre(struct sdhci_host *host, void *desc, *align; char *buffer; int len, offset, i; + unsigned int desc_sz; /* * The spec does not specify endianness of descriptor table. @@ -618,15 +632,16 @@ static void sdhci_adma_table_pre(struct sdhci_host *host, } /* tran, valid */ - sdhci_adma_write_desc(host, desc, align_addr, offset, - ADMA2_TRAN_VALID); + desc_sz = 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; + desc += desc_sz; addr += offset; len -= offset; @@ -636,9 +651,9 @@ static void sdhci_adma_table_pre(struct sdhci_host *host, if (len) { /* tran, valid */ - sdhci_adma_write_desc(host, desc, addr, len, - ADMA2_TRAN_VALID); - desc += host->desc_sz; + desc_sz = sdhci_adma_write_desc(host, desc, addr, len, + ADMA2_TRAN_VALID); + desc += desc_sz; } /* diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index d55fd7033e93..0aad0ee8f63b 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -605,6 +605,9 @@ 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); + unsigned int (*adma_write_desc)(struct sdhci_host *host, void *desc, + dma_addr_t addr, int len, + unsigned int cmd); }; #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS @@ -735,6 +738,9 @@ 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); +unsigned int _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 Jul 30 02:46:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10548399 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 674E6112E for ; Mon, 30 Jul 2018 02:49:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 563302997E for ; Mon, 30 Jul 2018 02:49:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A53F29985; Mon, 30 Jul 2018 02:49:17 +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 autolearn=ham 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 C744B2997E for ; Mon, 30 Jul 2018 02:49: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=GXCkSoTnR8uQHZM35OsM9N98LLWHESnbzExiHMYQFOU=; b=lBJD8IQZkaoWar Ovs3RliH3xan8dZqE2EHE0TMLlq12w8BqkFskKSPNTOsVYW15TWI4Np83hQmR9QHKwJ3owLWgLq/7 llDsfqwgfCHsv43qFQxNjc74fONLp4cjz9DP1WlVxqZx6Nz7IMXknwgBfJKi+3daaX2CovGrJThFh qxIttnBpE/CGjFmyyBkjA1rw4FRqpJkYSYn5JRaDWpMjdNM7j0xOaf6WJy0XD8NEk2cO4y7exW9zM dXoFrwUBMJq1D+gkTtIQ6sFVnEARB5U2uwokFU0cEedr0plmW9YCYfhbWKtdKM7PVk7N8/gOLL3Mk u6RjhL/Ttx2S8Vwmk9aQ==; 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 1fjyFF-0005BV-Kt; Mon, 30 Jul 2018 02:49:13 +0000 Received: from mail-eopbgr690081.outbound.protection.outlook.com ([40.107.69.81] helo=NAM04-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fjyFC-00059O-BL for linux-arm-kernel@lists.infradead.org; Mon, 30 Jul 2018 02:49:11 +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=2DMtqpOMbuFhQoQgeJJlG3FGQoKSeAMNNyY9oeGv2F8=; b=d3oIT/Zib5MHs9s0fjzPOFVJmLGzLzjEcIKsXPWQRF6t6BXa1gu9PlOFS31IoPp0pu70esJ56rmi1SpgATyY80aUwoVK86OSDeq1rFbBtprd7Pc9Rawm+SRRMtXJJ0pFTg9gc5EHRajgGcD6qltbYhZQr45gYGJZQ2HFLRIvXok= 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.995.19; Mon, 30 Jul 2018 02:48:56 +0000 Date: Mon, 30 Jul 2018 10:46:36 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH mmc-next v3 3/3] mmc: sdhci-of-dwcmshc: solve 128MB DMA boundary limitation Message-ID: <20180730104636.1a3e6c81@xhacker.debian> In-Reply-To: <20180730104228.28b58bd0@xhacker.debian> References: <20180730104228.28b58bd0@xhacker.debian> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: TY2PR06CA0027.apcprd06.prod.outlook.com (2603:1096:404:2e::15) To CY1PR0301MB1578.namprd03.prod.outlook.com (2a01:111:e400:529c::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc42ea34-c5ef-4b9c-8695-08d5f5c6ff46 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:CY1PR0301MB1578; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1578; 3:WXBvdwL/s6ZYQSpsN6y7zCfLoEKcB+9jx8MccKvGx/qYoHFhhCm/fQqv0YYUCfWKxKWPnkFtLP4Zywizg3oKD1PqQhsvZd7Biy/HOTOUYG1Hook5CjYIDJYbJs/llmEbVg0IncmuWMZ+9uqgXdH4nur0zNYnuq37bkxHJaQQtJqW9vliTdFdW32KLLsXnx9CGcof9lY/8+6E2ebgMADLxNzCGO7O5uwm4E0a+T4/Pcp71DwBdvxotvSW0qkV33mg; 25:7Fk1vARo2e9kZXemo6zdcpnuMuJnXnK3WLJr9+gIryxKfZEeyQ7WV2CKqTZ7s3is0iz5gLZ6o5PRdOgIHdupKXNbOwwRIqqCygAO28Nbf34jzGNdcOC1Ba1vnUl5v4YxpOJTgtxuM6yVs3GeVIwZowpih4ewyKbs6KeABgBctH4mJwEw6BSQ7flRHXwmPQrM3aGANjpQT6Yp79OwDVHBK7WswgGyKDpqpdZFfknzZSbSlNtkpXP20HTqz/of9jDj4kFXhIcRyncBM5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gzZ7cn8EOOC+mVckbDPpYDD/qg9ToZDzCP7g+MmqG4lLMCZenxa/A/6pCdcSJvOIgrYwWGlm/1JsSnkGzAceSg== 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)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123562045)(20161123558120)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:CY1PR0301MB1578; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB1578; X-Forefront-PRVS: 0749DC2CE6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(376002)(39850400004)(366004)(346002)(136003)(199004)(189003)(386003)(6506007)(8676002)(50466002)(14444005)(76176011)(81166006)(305945005)(7736002)(81156014)(33896004)(52116002)(7696005)(6116002)(3846002)(97736004)(956004)(476003)(23726003)(11346002)(105586002)(446003)(26005)(106356001)(230700001)(47776003)(1076002)(486006)(6666003)(9686003)(8936002)(53936002)(50226002)(66066001)(68736007)(5660300001)(86362001)(55016002)(4326008)(316002)(186003)(16526019)(110136005)(2906002)(25786009)(72206003)(478600001)(133343001)(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:uPixWRCW1QTZ/X+1Hr6G2Gr9FZ+nvLxdY4HbQa5?= OurWGjrtO8b5fz9J9KFowhphE5Bfz6m86AB96jq8qLQnyF6mBBn57QLxXLYumt2FmuQbv2++/ir4IMMipRnBs1SKOrJuKQBXXaD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93gNPdgmErhBR80MA/zx1UbBLL14dLBO6E9Pza2XmQMLiW0TQItMoyFWO8=; 7:tyvTEVTpoX7KuwqKfq64XoliSa5wcrrF/Y9U3AUsm7/1fdI6joWJJQtXLrOjBuc8XZREWUdP2sVyZPUuwFdAm2yGfB6JlG/RtY+a3pOmpGUY4RVS7B9waOpcqubEordmNCZf6sIs4+4EatjzsK7anQVW1VVkf81//iLo7ffRna3OPsnWCYVBfT/ZJ8k086pS+ykCysPqYynvP2sDMRa3FNYqPQGG+TU7rgQVMbC80yCAzSSJQNf7M2qxAh5ob//9 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jul 2018 02:48:56.3403 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc42ea34-c5ef-4b9c-8695-08d5f5c6ff46 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-20180729_194910_416472_221F4A9D X-CRM114-Status: GOOD ( 11.63 ) 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 | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c index 1b7cd144fb01..e890fc8f5284 100644 --- a/drivers/mmc/host/sdhci-of-dwcmshc.c +++ b/drivers/mmc/host/sdhci-of-dwcmshc.c @@ -8,21 +8,52 @@ */ #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 the DMA transfer doesn't exceed the boundary. + */ +static unsigned int 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))) + return _sdhci_adma_write_desc(host, desc, addr, len, cmd); + + offset = addr & (SZ_128M - 1); + tmplen = SZ_128M - offset; + _sdhci_adma_write_desc(host, desc, addr, tmplen, cmd); + + addr += tmplen; + len -= tmplen; + desc += host->desc_sz; + _sdhci_adma_write_desc(host, desc, addr, len, cmd); + + return host->desc_sz * 2; +} + 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 +67,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 descriptor table number 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_num = SDHCI_MAX_SEGS * 2 + 1 + extra; + pltfm_host = sdhci_priv(host); priv = sdhci_pltfm_priv(pltfm_host);