From patchwork Wed Jul 25 09:44:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10543775 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 40B881805 for ; Wed, 25 Jul 2018 09:47:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EA4129AD6 for ; Wed, 25 Jul 2018 09:47:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22F3F29B0F; Wed, 25 Jul 2018 09:47:22 +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 BC34629AD6 for ; Wed, 25 Jul 2018 09:47:21 +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=GeqyRhVwuogORtdJzo/d/mfH/iGi9TNNIQ3hOphGqJY=; b=UD1MG4YPdef6/H yRZI1n2ZYbTTGyhYBDBZgDoYyCxv2sevri/A05IES+ZY8CMRI0pO0Tpl/j0Co4C6Qy5SetWJ90/bu yhv7gIiVvuTkbjZvPfDk81/Iet84LxeAUOLny85poZSw4khWPXH5gUIdr2KyiXmSX7KQ9uAntQ24y CiWCQTH/oAa/Ou6x3LLyoXQ0z5e4hPd2zkK6uPVg9l+yaSGw8U1EpFPebZmLu2S2me0azzg2WnWaK RDD3xD/uml4chALvEX154ByjqNNR9zLLC2ZQpCdA3B4FA4IIAzlO3ff7GTgLx2HZb6s1ElkiM3DQ7 UKn9setopewJZ09tW6KA==; 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 1fiGO0-0001yj-CB; Wed, 25 Jul 2018 09:47:12 +0000 Received: from mail-bn3nam04on061d.outbound.protection.outlook.com ([2a01:111:f400:fe4e::61d] helo=NAM04-BN3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fiGNw-0001xD-Nv for linux-arm-kernel@lists.infradead.org; Wed, 25 Jul 2018 09:47: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=oBNdgngxV6F5slvk6l8KUn4Gw+nIUof/U1bct/+gEzA=; b=p2XdC4YrqSl5GmLZFxLH/x2LWmQjEQtxHtviB0BsPaM7hd/DXlI+r7C+rLlQlvbRJPJY6wImJsgDhZDo2Fm8Nao2iUP14up50xBFQzsInoZ29v2GQs44SgOiSbZ4coXwSnOJ5NRoihATqs1iFo0KyLQVCMsZ8YTPjxiIAbVLL1k= 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.973.21; Wed, 25 Jul 2018 09:46:52 +0000 Date: Wed, 25 Jul 2018 17:44:37 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH mmc-next 1/3] mmc: sdhci: add adma_table_num member to struct sdhci_host Message-ID: <20180725174437.64e888a9@xhacker.debian> In-Reply-To: <20180725174235.1ca764cf@xhacker.debian> References: <20180725174235.1ca764cf@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: TY2PR06CA0015.apcprd06.prod.outlook.com (2603:1096:404:42::27) To BY2PR0301MB1574.namprd03.prod.outlook.com (2a01:111:e400:526e::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 994cd71e-74a4-4993-6478-08d5f2138d70 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600073)(711020)(2017052603328)(7153060)(7193020); SRVR:BY2PR0301MB1574; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1574; 3:DZaNYVBpuwHWmj1qyggoofzvY3LFUPW38YQ0C3uA+9AsYTQGtfJURLqjPCKJ/BnfkOahKctmoJsLXNNGHENswDJAHH2hwpYDkaU0Sb/U0+UgR0KZLG/H0DtQP0Rt+og59wuCO8TRqz57hJR/tJLb8AQlcvzPpd0Q7Rw7x6cHKVWUGD5AoeWePq4nmQbxf6JfyuVwYjldCHvRCQMI3crBfxyYEyEsYMrgmxd9clYn4B1oMqIA0rv79Bihf3b+aPId; 25:c7gIskuMkW8CFsRWJPUUOjvAxGOuGJs0u6l2vgofYqqIekHqf75i9XGmZdMjk2EFMMRRLXfxkgmfP8rz1/B0xUiS/H5L+9FhfDgmrwPrOgY6hQo/eA6MaZfi1XBvH1oCMhJrPTPKWvnM9Em04oNcXRy6QtTmUKRBep8cX22X7NTa6WxuJ4PXROFNeljQimqhYW91ee/6rUe/Q7aaJy3CozXmcnmPUilvHZpTnSPURdizkZgxGzxxxLLyNdO7dCw3hi9Guy+O0aN1QRFKbXQh60HVOfVihvs4Z1aylK0gRtdk3/0HziLPXQl9RJMtx56HmIfbZ5cgzLkjXyvcOSr5cQ==; 31:uyLJ4KNw4BnLESKlIMKExF9AwsR5biTAEiUHB2fW31StAYXwR0Pemgszl92kuoCN+tHIwDX0OOBsNwGYGZariiq+ZxojFH/KFgRf9KaBGDH2Sa9lAG1r7k15cRltvAf2tdV4ay4DG4jOW+nHI7wPOtZ2YVBd+0sZwsLtrxWlFMqFaDMHPqVAkdANxsevk+/McBMFGnj/s/DplEdwPiS+rVRjB0chgksYILzcu323WEA= X-MS-TrafficTypeDiagnostic: BY2PR0301MB1574: X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1574; 20:vfdYzV0/XD59UY2lS3DExAo02Ygo7fDZNt8wANwbVKAtn3cOsh3mrG/4hYQymzJHql0fg1HxiVNNrng6WxgsxzoYirDPBlyfnF794dj2zUkdPcuN90tCw7j70RQT1b+ypO/pkoqswlvzrJ5NycBh1W8ER27xwVO15AGp5BS0DpGIPMBm7POgQ4aeCMv1KPdprzZ+YgmAdTBSGWYXFLWr10z7OmfooOGgzxVqgkZtrktIbYlyrkewv0EzN83UHkfcvEw/6jTylcXRCaRRzMFpd6tsLwoVPXPe7VIfgIi7entjA1Y23jcar4z7X/mr6yLz0m87McfocDoW+tLx0c3iKIqUmSssdSaJNAwd2dQ0dJaSUjO10bRE4kOK4jmeFYzOAa5poEcY3fzDsSCnDOzQS103Pj5VCWLkfvnCohcn6I7/zyozL0mrzObIbkv7HDmFP5cpfHACGWmISh0Tjxt4379Dy/JkrnVY74IBpSVJMMhADood17jIj2iI8wRrHEOr; 4:eZw3Fh7vi65xbFoW7+HEu42tGmfzJBCSIBE/85ga+HaEzZbF4PYoKS9n9w8FukSJKUbvv6t0jhKWNqv6Pn1yHbbi94gilcEG2P86WUcXC8r6qbfh1FDW1Uef7CmWeH1O+q/aZvQ+fqCqTijkT5W635yqeTvHThOq0qo3RTERfNNu8mYsHWTbKD7fOw9xpUV/pVQAegm8fpxXvz6f+cuSyyCXHcbemP0CaQVsDA7rgjvhM8a5oQrHzn+Yo+v4RitOqs1JXxWgkiEIzsNQjYvJ6Q== 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)(8121501046)(5005006)(3231311)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:BY2PR0301MB1574; BCL:0; PCL:0; RULEID:; SRVR:BY2PR0301MB1574; X-Forefront-PRVS: 0744CFB5E8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(346002)(136003)(39860400002)(376002)(396003)(199004)(189003)(6116002)(52116002)(72206003)(230700001)(25786009)(106356001)(5660300001)(478600001)(53936002)(4326008)(68736007)(305945005)(6666003)(105586002)(7736002)(76176011)(7696005)(66066001)(6506007)(47776003)(55016002)(26005)(186003)(16526019)(2906002)(33896004)(81166006)(8676002)(8936002)(81156014)(86362001)(3846002)(486006)(446003)(97736004)(50226002)(50466002)(956004)(11346002)(9686003)(1076002)(23726003)(476003)(386003)(110136005)(316002)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB1574; 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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xBq5EmbDdfmMiFAtSgdippbcNn2cKq0ePq4+6QZB/QihwPrfDYew4txSzx1ELQlKWAeqgjBR+azMTe6WOYaeuZMAAIBMdeJb2fJPgJQuDzyfdMuLH7zDX6mwDejo4IVqoZTVlcwliWJt18IyBWss/jJlii5BE+6OLc=; 7:Uj8laCsjevaqlSgqUShUt338JSx8XkC5CrzCdO6S15OZqV8MU6F+dPgs/Oc3f67i3RNXHfDHhhXQLyQvmvOPoCqvdXwlOxEqjQySzwiPDy7C0CRpIdzk2Tr3dZpqF1DbnyAWg2ZBEPcLuS+ZJUFbdp5jxr4QjkaQ8Ey/77eS7DQGSWiFJZRVflfHkwHeq8YsoBWUX2RVuH7Q+sEVbixZUGx8Jemyrd8IBt48282qFHEhuwoAoWnTF7OmKZPmmuKl SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2018 09:46:52.0555 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 994cd71e-74a4-4993-6478-08d5f2138d70 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-20180725_024708_926731_EDC3083D X-CRM114-Status: GOOD ( 10.90 ) 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 Wed Jul 25 09:46:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10543779 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 7756D112E for ; Wed, 25 Jul 2018 09:48:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6650029B4D for ; Wed, 25 Jul 2018 09:48:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A19B29B50; Wed, 25 Jul 2018 09:48:55 +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 D987729B4D for ; Wed, 25 Jul 2018 09:48:54 +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=EAD23ddrA2cy4Q GD0zxajRlg4G/7TgoWQA7EavVaT9s8D2coRDZRUbu026om4Z47LhDNAd0YuSU4qPCU8/vwbNG2guk 3F3/Qv/4tN4yOATvuanTTuUEJEjMdYMPvnbNrBHAf+8QPILNfhzRhW7cOAaoq9N75cC7Szmt64DFX 9yrE+1HgR1qRoDBqa+6BuIfSi78Fi4ywEthgUb41/o4duHH+AqCyGSonzy9ysSTm8Wqm/WbC/9+K2 qSnZSrRC/S+i3FHxiTmJoTpZKGx3VwokqfwPu0yYzMGSVP8VF5XY0XMRIDFxQjEwjSscZWjKyKT0W SiOkYyIZ3gkd0xK1NuJQ==; 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 1fiGPb-0002cO-Ug; Wed, 25 Jul 2018 09:48:51 +0000 Received: from mail-dm3nam03on0627.outbound.protection.outlook.com ([2a01:111:f400:fe49::627] helo=NAM03-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fiGPY-0002Zd-Gd for linux-arm-kernel@lists.infradead.org; Wed, 25 Jul 2018 09:48:50 +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=OhZfZ27qlc4FLzHpyhujBdRxmBGk5LyJxqkO/wng55WubtmMxjtt/Jrn1EHwrDJdTg2oqQkxyaF73KSFNGEKHK2bE+XmdzKbiGYXNB+K06gNRN4hu/PEgT5HjKHckhEyXD3N5QrdSeX1WDXcC4emBXmrW2sXvjh7wGKqp071OdA= 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.973.22; Wed, 25 Jul 2018 09:48:33 +0000 Date: Wed, 25 Jul 2018 17:46:18 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH mmc-next 2/3] mmc: sdhci: introduce adma_write_desc() hook to struct sdhci_ops Message-ID: <20180725174618.1dc9bdd4@xhacker.debian> In-Reply-To: <20180725174235.1ca764cf@xhacker.debian> References: <20180725174235.1ca764cf@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: TY1PR01CA0142.jpnprd01.prod.outlook.com (2603:1096:402:1::18) To CY1PR0301MB1580.namprd03.prod.outlook.com (2a01:111:e400:529c::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aad1736a-dfa7-4e70-90ad-08d5f213ca04 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600073)(711020)(2017052603328)(7153060)(7193020); SRVR:CY1PR0301MB1580; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1580; 3:2aHqziea3vj9+tx/Rv89Et6ZPC9hchjvPladp/OzLh1O2wtwWK/UE9Jtn+nRimvmys+RYvfgvQSZ32aHOf0OFwjNC7H+tuseyEsJvF9c9k6HA1xhY4rO9g8XkDoDhX7cBNLPBAmBY46xrZZ4bB+U3RKbWVdR1H+fCCI2vjlLjSHaD9svbkKsiUt5yvWrsyn5KNLkju1aSPzrSSc1PypFD4c5fpZWqgRstynykM9zJUbAWe+QBfIQN5iz9NgjQ5Yc; 25:Bv6ydgWCncNsExtm0u+eOD34XPAZF/B1ZKDVwaSJKzdbGTxODKM9bgNCLvSSkQfm/FlKd3w9gnG/vpn3EdWwlGwfDMiDJP6JYRI+wTSi0kMrKVtzV/XHLHilOuEFRVaRNCWdsjFzLAdmJUKSbzGntx0AFdjugPPbr0lvgNVnItK50DZOnB2OMQi8NpH+l2EfUTSt1WYLJV0osDauejJaTFJL0yn4Tf3lmbJww3Amb/QA4dBwfxJ5AWty8eHQzlj76kL++DerDSGO637s6lqq5DVo/nhbvi31gqX0D15FPyIn9g3JCugLWYdFgGPlThbCdEUnIZryRXFW7dvcvAc72Q==; 31:CB6jQUU20hMk5pby2k3PmLDUijK/NllCqfAxRN+4xElfpEEbygL+QBTUPek46Pd99QnwInz91OgfoAa2LDQawuFzLNgo6/HJaDWBB/G0umnqx35SzYOlzjJww1dVDbXbawH6MTpOd6UQ4dPQ5bbMKHNJRGr9/jXFjvmp1BOjaCF0XBVEZC6rnMTwRaMZQSVcyjln143YZUGeKJ4Tivqsifck5/QTM10INdWHRfCr8XI= X-MS-TrafficTypeDiagnostic: CY1PR0301MB1580: X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1580; 20:mXuQfZel/mN+d1BRlrXMc2m45iAlzzt3N1o1lqDmAT+FiVXLK8XQXmDaW/snQJXX+U/J0gWnAsom9pwK5ddEHj30s2TBMvXaT3bnF+Zywq3WvafTF9VRMznMgNgj5Hg16ZqiYPVEiqzW/w9jb17ya5k+FFrPtSb/jIyk+JYCsICoLehI3oyKAqlFuKJgocPZu/fxJpYmqzlqo1+zDJYr/5yF/lDEEAVFy298lj0qCaqMR945xbzYZwJ0WOgqfWMhymRVGc2mqP6afQOyYswEk2SK+Kj8jtCCchmEIWuIVhyJLPQbyVS+NrJ2MapcVxG2xkAXeipTwZ85fE9wiqyQ7NwTilxg96QD36Zrz6xUnklszS/hRoyl+I17lc6qoGXVMITC+SVObuu5khgdbq9zOSfhITpESxpv89SOO2oygbf+z0f4dsqWoIDs9CDasEzwIuoyxRLM+Wsa4aUxHGVawn/MnYKBZSlyBlLg5PIxV9u94FvEAWKokUljnur44P3S; 4:MI3rC+eTMJ/b6gh3vk7SA+NrZiXx2RQfEvGdShaH3AzUDgS9SctpiQzKlxB4zs9juvsgFiij8m5XYcWeOvN7fnSmQ++Vrw1s2Pm/BBcLIf1p0z8vk9ir6OwIACOfn7B0u6+N5B5lDQdBfmufdfJmXcUoR3Z46Q/KdHLq++z4bj8SXnvSsN/CcNcstL8dsrKoJPK/69WduwiAyD5TTkzN36yRETI1Sg2q0jxgOJfBedk8R7XeyenYHFAZoOtolpE773fdzRIsz4mLSNeLsGXvrA== 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)(8121501046)(5005006)(3231311)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:CY1PR0301MB1580; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB1580; X-Forefront-PRVS: 0744CFB5E8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(366004)(39860400002)(396003)(346002)(136003)(199004)(189003)(105586002)(14444005)(7696005)(486006)(9686003)(476003)(956004)(55016002)(47776003)(66066001)(1076002)(106356001)(3846002)(50226002)(86362001)(68736007)(25786009)(6116002)(5660300001)(575784001)(23726003)(2906002)(50466002)(305945005)(7736002)(97736004)(53936002)(8936002)(81166006)(8676002)(230700001)(386003)(6666003)(6506007)(76176011)(81156014)(33896004)(16526019)(186003)(4326008)(446003)(26005)(11346002)(110136005)(52116002)(316002)(478600001)(72206003)(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-Micros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jjyDxE1/Uk5PhNlKFkoa7lnbH1EJ+a3iLi6ioLt+FYBvBf++HmDPZTZMAhXA==; 5:gs4DFSSPDu1308hYxlgV8xGBaCZ2ubRMRvolf5zRGXYawJV/r3jbWv9ShEm6GNGHGT+6uv5Fb7XaiXtzUyEggO0hS87XzMXqb/P1xz5yrxmM1YFdPuGwhIth9aoHSHr55d3BkerDm+uWR2tn+4dS3iNZcog5xj4WCClczvY3XHA=; 7:LAbuh/LaEvBf+a/N8pmMMPkEE0hAQ2KVPToh3A+pKdx1DMYhyOtEhqZYELKDx/NcH2P1g7nCxFeyRwiuYw+HD7x3dVCLqLn24F2MiZ0RigVdTQ4vrciY6QNF/i+Qox/3o+ZBsKNks9FlrUjY0himPPmJ2gXarl9WkTVOBsJg5XK0xngclR8inZOLLvq/FHosvPxUo2bQfInAXN2LWe7mDmaBjYTJoCcetCqx0mJrgh8m+kAc2YSF86RX0AlGX6Kg SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2018 09:48:33.6171 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: aad1736a-dfa7-4e70-90ad-08d5f213ca04 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-20180725_024848_710692_A18FAC86 X-CRM114-Status: GOOD ( 10.55 ) 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 Wed Jul 25 09:47:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10543783 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 C0CDE112E for ; Wed, 25 Jul 2018 09:50:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AE62D29BEA for ; Wed, 25 Jul 2018 09:50:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACA2E29BFA; Wed, 25 Jul 2018 09:50:30 +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 3B1C829B8E for ; Wed, 25 Jul 2018 09:50:30 +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=3MCBrEDQHBpfuaEwEb6bcmjuOqjaPic3NrtaykzYx1M=; b=JhFAj5zcb6h66K v0W8fqZD6yRGuAkWzBrflecdwd5NZ3GomnU4ExxBeATGeUwgjK4ygTy/eMCUu0g8WL4vfyhiK+7Ep L7CFlaaBWYmoCinHxq9UCgqVPk+Ng98slncAvjQk+QHGyNKpW4l6Z7jWXp6AX382a+b5MFDVlaFLL NI3Ci4SeBR3F1RaS3jhpjIXrInk/eqQozVSi6CdZTYpfigMA3SLi2W8y8OjGmgG3HEtcP7F38uk6z ryc2hDBUGhwZohX/ynnI8EgHNEhRWn/swJA1+S4ci1cm6rtMmM9K7r3vrwGo4//2oRd5XkhGNyoo7 12OiYxlhHuBL359fDZTg==; 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 1fiGR4-0004WS-LB; Wed, 25 Jul 2018 09:50:22 +0000 Received: from mail-eopbgr720062.outbound.protection.outlook.com ([40.107.72.62] helo=NAM05-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fiGR0-00041d-KZ for linux-arm-kernel@lists.infradead.org; Wed, 25 Jul 2018 09:50:20 +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=R7iafxf17daJnbA03X1L1fF6SeMmbt272IvF7POJpYc=; b=eoFchRg3NzYIQ0WdNO6Mth4v3mxjG355cc6nHWTlybcR74xKrhddawP5dBBoaMI/FMAls4Rc98aIeTSPI7jj0SQ5j5G1dGZIQlF3J1Fmz3w0kWYEsSqEqzL/aQap7NMYqclWehtKz3N/D/mgW/xTbLvG/47uu5XPtZkFCmczDJs= 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.973.21; Wed, 25 Jul 2018 09:50:04 +0000 Date: Wed, 25 Jul 2018 17:47:49 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH mmc-next 3/3] mmc: sdhci-of-dwcmshc: solve 128MB DMA boundary limitation Message-ID: <20180725174749.6fc97d4d@xhacker.debian> In-Reply-To: <20180725174235.1ca764cf@xhacker.debian> References: <20180725174235.1ca764cf@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: TY1PR01CA0146.jpnprd01.prod.outlook.com (2603:1096:402:1::22) To BY2PR0301MB1576.namprd03.prod.outlook.com (2a01:111:e400:526e::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 80c3348e-8b89-463c-0266-08d5f2140001 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600073)(711020)(2017052603328)(7153060)(7193020); SRVR:BY2PR0301MB1576; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1576; 3:WRSryKkG1M0L89vwWwXE9v2biSVpRGyuLhyM46cvAyNfXrmisO6CNEPJ1QEQHhdfAiFqXxNFNBnGXrhoZLxnAf9IRS13qQ2jjWkWla1f0xDY3D9lLggxVJuYF3a/kxDWtlp+otnGO75KWGPoMIooujpaCiFaxdntU66xLPvCM+GYUiM60Sho0ysSSCd7KgrSRkq2zIpk56B96lfCPeEQL/oEkRxagfgF/tBZvNIF8HEPCGSea4MwTFZ9vVyGXAM5; 25:bNGXlC5K5zjGbNCwoPp33i/nFoneW5lS2KtGrawuXDsO9x7FsA2LrVcc2Yj2I9GfjDA72LfuTxlNHY2VheqlwEZvVSBNmJqOLLOp/tenc0o0Zguv0M3+weAs5nOqzAkNZxVWm6NtkD8yFqoZJRGTCaNIxKPvXlJKmprLmISssSTJA81D/9Yqa+Hj5MdZFi8afz/fLP5DgdUYeCRZ+tR9RgjSIQmE8JNS3oyFOisMXKNlAa9COuSDTK5Z+rACi+jTvoTTFKK5UDltEp81EcJf+RAOkX8e3I2ikx4NBbZXe0W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9bGTC5NSE5nEWZcjTqXTKGi3tYCbXgbmYlSiHZgWALabzAgN/IhCUSW/Y8NejnjiWwRliA== 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)(8121501046)(5005006)(3231311)(944501410)(52105095)(93006095)(93001095)(10201501046)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:BY2PR0301MB1576; BCL:0; PCL:0; RULEID:; SRVR:BY2PR0301MB1576; X-Forefront-PRVS: 0744CFB5E8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(136003)(376002)(346002)(366004)(189003)(199004)(97736004)(50466002)(2906002)(53936002)(105586002)(8936002)(86362001)(956004)(110136005)(106356001)(47776003)(305945005)(8676002)(81156014)(81166006)(6666003)(7736002)(5660300001)(66066001)(76176011)(1076002)(68736007)(230700001)(26005)(25786009)(55016002)(4326008)(23726003)(9686003)(6116002)(72206003)(33896004)(446003)(3846002)(50226002)(14444005)(6506007)(386003)(16526019)(316002)(11346002)(478600001)(476003)(486006)(186003)(7696005)(52116002)(133343001)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB1576; 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; BY2PR0301MB1576; 23:SLhR+/xNf3FAHvshbwJXYjcFQkMXExORfVUXTu1?= L9Jq4iiB1crLU7ZFDk1Y3M4gnzAVClnxbJ+ZeqPS5cjAogh8gpD9L4OBkWOj/lhPqC+PtbwCi48aAiUohYiez6FdYyk34CGyIXVcMdyPQuAph1MbETtMZL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zmuqtofOYKUpBTp2blboA8PZmMMAmpe8/fAJEtHrImSyHzOnIU X-Microsoft-Antispam-Message-Info: tLz8LufCV3K96UDWribDRvV53OhtbhBGNS0nHkXFojgfpfLp4rYq6M+NpeOSIsnK+lFjgu86NIqv8RVU19MynDi/bHhvV1A9+tHd2X9VQb7BG2/F6qXdrc40HR7mFItcx90R2YDo/xj24gi9VnIqkKhOB6Tcs5wP3QZjKUjbgbqowbBlgsrKUXYWdJnrueqbxK2GM2ZMIDQ/7Jst/5rdLGWvpR9IwY8NFJLRutaq2Voxd2mV9vlRg3UtLsK/gfy/l7hyHfHtJ+LoO/kzfAwaLR47FIyN8DgJ26ZjjQrNURckwof+X1noe9xg+iMFfPw6gjEE9bzSkonla/ru4HHhevwKo7V4PEXixZEYuxrepTo= X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB1576; 6:wRju6PgNedl79V1f5emJalLEcAsxopu2ymWasYkecoLHsMju7peHqj/J8LZ76zMrUpnuSlwhNGirCMHpgjrHIo/58yrGonsvpT04tkCQMaofPGlK0jWXP7UAD4RKcV2ZUMEezVj/gam3+jR3fG31SIOcWbijBRKa3SP6nCMx4ySBR75RN+A5X/NSGl/PJgDA2uCoo0M4rE14v45OtjNcpKyz8upa8s/vQ/eXG/VSsIyXRAferF8bE2/ty2e4L7WuRInPP6R8BKoIrqp+8QsWztbxwmB22kc362eVJKrQgJGLk9kxX+OnQc6IfdzKgguDelJegAM40/aQ2ds5KEnM07KoZELsuoHRLYHEuaCzpNS7WRMfb7nC2Tse1XrDDVyEpFMbZFAwhQFAb/cXVgFiG/rGpZsVX0NHkYuqazLxUBGdQzd3KyrFSBpjfN4BQxlevm72kZvyqJUK0HsrjfnYSw==; 5:S5NVXIpkSKatvnh1vlnY0hT3SGoGaadUFoCDo2v0z1rJGXCAgHp6S+KIEFqvphv3nmYzCyIHuoPbd8PvfKb6ivwYk3msoz2aUg7zNpq8YUiHWH+wbVoR+4bB3vhBw9IP8cS7HfXX2cl/7imd0Aqd7JqUYeRubFXTr20s8zDqbis=; 7:xSR/da4Wit3C6C0dXpr+5hoZ3X6zv60ArFwQIu3sKaSsYZEjaMQkyk5PSwQKd+d/ZxgWRFvnNjVWzKvtkrQDz+hYs+5NlpLWyBhuMNWnWNoYBDTHjD/5EkOFpV+qHe9ebUwI7Vj+GHN2ws5Eacq424XZCn9sAp3HTYEmIJFkYPyXl2FoDLSTVRSVJipcr/ZTWDqhrjgvJBRtxUfbG+MaEjYeummvXkxuZ00Rr0OyxVgmJB6vknjVUYDdGGId98AJ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2018 09:50:04.2532 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80c3348e-8b89-463c-0266-08d5f2140001 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-20180725_025018_706003_78477333 X-CRM114-Status: GOOD ( 11.65 ) 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..01b5cb772554 100644 --- a/drivers/mmc/host/sdhci-of-dwcmshc.c +++ b/drivers/mmc/host/sdhci-of-dwcmshc.c @@ -13,16 +13,45 @@ #include "sdhci-pltfm.h" +#define BOUNDARY_OK(addr, len) \ + ((addr | (SZ_128M - 1)) == ((addr + len) | (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 (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 +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 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 = totalram_pages / (SZ_128M / PAGE_SIZE) + 1; + 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);