From patchwork Thu Jul 26 07:12:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10545333 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 3EAB2112B for ; Thu, 26 Jul 2018 07:14:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25DB72AD78 for ; Thu, 26 Jul 2018 07:14:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19DC22AD9A; Thu, 26 Jul 2018 07:14:51 +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 8C11A2AD78 for ; Thu, 26 Jul 2018 07:14:50 +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=YcX3C4J+R6tXRW RJ2MGOpNh0O4R+OBv73MTes+b099e1Wv/dvFlfOPPsz6+eAaVya5taB/wA5H6MoW7EBXAsnrNLNs2 I+3iOUcQlUu0Tbk5gpEo3jezEY/szYUuBEn3judF+ONYqjx2iON20JqINx+E3KWvVdrguMLtWQsHe /XjyfbWoq6EWxMx1AumfEopZjPbtLsWhA7MYgcyeMRVE/npVGFn9HKAdVsRHACda7jB5GBOt3xwyN ky6/+ad8zmZkuOOwvOrMYQMU8x8XdBaelVjhDin0GaiRRuFVQtGjXFj41YWtH9hOgcoO1vfOphqIZ DEQNiSjVVGrE7FLtD33A==; 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 1fiaU1-00008v-BS; Thu, 26 Jul 2018 07:14:45 +0000 Received: from mail-bn3nam01on0084.outbound.protection.outlook.com ([104.47.33.84] helo=NAM01-BN3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fiaTx-0008R3-Ty for linux-arm-kernel@lists.infradead.org; Thu, 26 Jul 2018 07:14:43 +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=fXmEopCX4mABPyVvk9vh4L+fVKlq3mWoef2IGthBeJ2kUKECQizKDyi5ykeH/pMJ3X3OsdnQR43+2uJGO25elChiwj4mGABOJ8k/TvippHoNVi3H8Q5TT7+Gz/SnqBsTGtwI5VTIB+y/wd9Mg2aATHwr5Wv6BBpF1qx0JY8VGUA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; Received: from xhacker.debian (124.74.246.114) by SN1PR0301MB1583.namprd03.prod.outlook.com (2a01:111:e400:5232::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.973.21; Thu, 26 Jul 2018 07:14:23 +0000 Date: Thu, 26 Jul 2018 15:12:07 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH mmc-next v2 1/3] mmc: sdhci: add adma_table_num member to struct sdhci_host Message-ID: <20180726151207.6d8898f4@xhacker.debian> In-Reply-To: <20180726151017.4da1e336@xhacker.debian> References: <20180726151017.4da1e336@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: TYAPR01CA0129.jpnprd01.prod.outlook.com (2603:1096:404:2d::21) To SN1PR0301MB1583.namprd03.prod.outlook.com (2a01:111:e400:5232::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8042e27c-022a-4c7c-3830-08d5f2c76b31 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600073)(711020)(2017052603328)(7153060)(7193020); SRVR:SN1PR0301MB1583; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1583; 3:EEt/8wOGbKDPia+zkKto4BD+4JP/sEz7o9io3eTe9rU0AYfu9CDoYh0iNr5VaRXCHwtU20VPLBAG8K/oSsTyzAPuWcxFo7eMtpAeLQMg3IO8EmQDPpca9dOTyrVWevjXXfaHY/G/6NXr9oPEKGg//kwxSa+fNxmMJPWAH5OVUuQyrdDSVQcFRIEj227TYFbRjVaPczr+wyv8UgER4tUhZQjqalfpSlUsyNhNc0l19wAKM90PfJIyB2f0G4tRlcmQ; 25:v5SEdIGJoKh8dhK8Yx655FusTCceTHc5k8CvBjATTft9GsKeDlzDgKAobc7kEPh3A1Iq02jGgmReuhdS1jsxZdmvUAK0J2eYnB1fnyUtEJK6N4x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2Hg9QOFfcymY/gBjxexFDLg2xrWY3HSbA0GPFmMj8vlZXsJA0v2E2jzFXGXkYRX3ypA6517nrp9NmzEmLjMsFb3Ipc/k4K3FkO0SVeQ+2tSx6wU0IRIKGPDE0wRO7FK/xzTILzivz0hG2uJwTPfN4wFJJqKYAERlQiJ0Rr338y/fgFfolxZAw7HFgrfU7svZeU447xPeOhBeuF3hXgtdjqXVJOi1ARv+YHLhyGgitYZDU/VMncz6px9/LecaUxGptpwuVJGFH/e0Ong== 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)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:SN1PR0301MB1583; BCL:0; PCL:0; RULEID:; SRVR:SN1PR0301MB1583; X-Forefront-PRVS: 07459438AA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(376002)(346002)(136003)(366004)(396003)(199004)(189003)(16526019)(26005)(5660300001)(186003)(68736007)(486006)(2906002)(97736004)(50466002)(7736002)(316002)(476003)(72206003)(86362001)(478600001)(11346002)(305945005)(6666003)(110136005)(956004)(106356001)(6506007)(3846002)(6116002)(9686003)(50226002)(23726003)(446003)(4326008)(1076002)(55016002)(33896004)(105586002)(76176011)(230700001)(53936002)(47776003)(8936002)(66066001)(7696005)(52116002)(81156014)(25786009)(81166006)(8676002)(386003)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0301MB1583; 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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KowWk5Qgw==; 5:N4m6Ba+ZLAYHgzV9+8YcAU/qJk0mKsYKodIAzLUiG48q8p2/Aau4IR2ziVuddjaKbBMzBpDd5nkAzpMOTT9vitEUQmwrGoBmQ9mpqi5oK+1oU7frTFn+DZKHVY1T8UZpDuoHyAYi9PRlW45J4vbzxwV0XBDyuV1a/uw+yzLFezs=; 7:VmBrdlJVs2AgPPlx3r672CDd/GdKjlRz7+O1qRcx+7fxM5wk5ghwWELj9ktWmWf2CkngsmfRIdDTu1WAoznvHGXVchLiqwZFGjyGglogMAGqFkJ/TmaTaiJS6NUu581tJdxv2U1nRKYQUw7qO9KQeRO8Rs+qoDa9jqiWj5ycLkefHKGzTO5iQV7m0CWQVg+VThAPJHyuoN7k56sfU2Aj97Ag/5MHDiAzmFs2uCjk2fCVcClU1IhVr8tTgDUJA35+ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jul 2018 07:14:23.9183 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8042e27c-022a-4c7c-3830-08d5f2c76b31 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0301MB1583 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180726_001442_032863_514886B1 X-CRM114-Status: GOOD ( 10.72 ) 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 Thu Jul 26 07:12:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10545337 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 5483B112B for ; Thu, 26 Jul 2018 07:15:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C4C12AD98 for ; Thu, 26 Jul 2018 07:15:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 305D32AD9E; Thu, 26 Jul 2018 07:15:42 +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 C39662AD98 for ; Thu, 26 Jul 2018 07:15:41 +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=UIfCezBEZ7IR7t BaB3SmQw8Uexuugu/7SaJw/PY94yHEaONh08eNYS1gNu1ErJrh3wY2nYlnPWS6SFH3Lw46q3w7FnP WiARVpWjcxAXqGMFaE8qpn47JNa3eYXCtaUNDpzCjOAnt6pjEoyhaPf1oQLJVpeZU5uVir/cuqJbk 31cRUPVUpf1kAkG8s80JTIjFuzYesu60vucbkNdoDQ11Em1HVFoaAPMXSkaFPHVPwV+DUMvWFPvkS PoIzdKjJOX2jWCccUQ8M+AVPpfLs3ex+Daj8X3SJa1nG7kM/ssjpLLl27kEssijGy9jJdbgJulB7L 7SzgbAqi9A1MNLgypXpg==; 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 1fiaUq-0001se-EO; Thu, 26 Jul 2018 07:15:36 +0000 Received: from mail-eopbgr680056.outbound.protection.outlook.com ([40.107.68.56] helo=NAM04-BN3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fiaUk-00019q-Br for linux-arm-kernel@lists.infradead.org; Thu, 26 Jul 2018 07:15: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=J4u5uB4pyMz2QMMCboV1G5cEG2ARP2isXycosXVGyGw=; b=KbADhssaK5tlwR6x5LIhoHCyDZd5JfwQkWkAYEQ7cZmzZa2m5SMubhjmYUKcbkOkco+5XCt6U2SKuowb/NTo0W0A0Ef2GdWQoWndkgrnm3BErDHRSZ9NpLXf1wgX7Qy8tfk5D6B+3MtYv6ghYH0zy1YUYamSETbDHwPErQMQh5U= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; Received: from xhacker.debian (124.74.246.114) by BLUPR0301MB1570.namprd03.prod.outlook.com (2a01:111:e400:52a9::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.995.16; Thu, 26 Jul 2018 07:15:15 +0000 Date: Thu, 26 Jul 2018 15:12:55 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH mmc-next v2 2/3] mmc: sdhci: introduce adma_write_desc() hook to struct sdhci_ops Message-ID: <20180726151255.764aedb7@xhacker.debian> In-Reply-To: <20180726151017.4da1e336@xhacker.debian> References: <20180726151017.4da1e336@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: TY1PR01CA0140.jpnprd01.prod.outlook.com (2603:1096:402:1::16) To BLUPR0301MB1570.namprd03.prod.outlook.com (2a01:111:e400:52a9::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7d5ce5c7-19ea-41a8-ce05-08d5f2c78a09 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600073)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:BLUPR0301MB1570; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1570; 3:4mmWX5WdUnz++FpxK+ckNplyTPLIXCcpIjxNsTEHeOtmwtEG/g2/wRRl1ao+4lb6Lx0yRMTWMTdqxmc9odg8TqpOsemLwP7Iyn4nIpY/Sp+qN2LpM0DXzuIUtnRvoJQohCH28SqBQK63Wxkw4ylzONbmHJBIJiwpggLfK2rRANnDEyePBmbnYQbgpAhlZ3KXAwq2wQFj2GAvEs2Q2whU5DGiIKhBO6hJj9Uu1aGs3cmJD+WOmrZsHGO3mQ7X4D1Q; 25:pbyk/WlQEZt7EGs902XGMLv+ebUnL0JrMcsIGcdHm9QHrONqdQREvW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8aOWxQ4axBMWV3cZLJ/X0t7VvU5hZYK1Z5/p15moN4+5eykCnd/8PY9Bnq8JRjE; 4:En8HrnjrK5W36c1B0/XwHizZO39OvFvxGvVYwGa5sHp5zhq3J0H9AXBU/+dmOGfkl1ndgVHMNSGbVufu2uAq8gmIoUquYN8ma142TeuAC/YtVww3Yba0C5CeZ9eg/HTcJgc50t9zphzXG/uE+x92Xjiimlak8ud2FefQjdYqpQOon4CuHAhd2gPpUN6/PcWMRE7U8v2XTQx6HyGEYw4SaUxKxEkeng4dvZgOh/kFtqWD0hnDjCvBeocuyj7dtaMgh2rEHjCWBfWXaxAlC8ibNA== 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)(93006095)(93001095)(10201501046)(3002001)(149027)(150027)(6041310)(20161123560045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:BLUPR0301MB1570; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0301MB1570; X-Forefront-PRVS: 07459438AA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(346002)(39860400002)(396003)(376002)(136003)(199004)(189003)(53936002)(4326008)(50466002)(25786009)(50226002)(9686003)(486006)(446003)(26005)(956004)(476003)(14444005)(8936002)(55016002)(16526019)(68736007)(186003)(97736004)(305945005)(11346002)(7736002)(3846002)(6116002)(33896004)(2906002)(5660300001)(575784001)(86362001)(230700001)(6666003)(478600001)(81156014)(81166006)(23726003)(76176011)(6506007)(7696005)(386003)(52116002)(105586002)(106356001)(72206003)(1076002)(8676002)(110136005)(316002)(47776003)(66066001)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR0301MB1570; 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; BLUPR0301MB1570; 23:VSgUW2dahq7NcCLIXLzVEjWmbEcPxVtioMlTwi3?= CbfqO2u4FzX+U100xN2lSWS8kSB4rAfws4aYqagVeoUbfr23TsLO2JRW0wOWuskr41g2aipr+WgDU9vNGEtIzPAUIGpiau5wnthWw3J26kQSQXxUfERwOSKdqoplf7w+PMtbjmnexWO2VQlYn3b/cesP+kYjoY59j6DcFv2qzIgvWChr9gPUGmmJqSIjVWMpn7L3w5LbQE/G95ltOe+BRVDe693SIxecYmMUgCf3DwXrczuUi63J0O03vR2nbiO2W9rV0s9j634wShqxR87UVNHp6xQ+GCYclszJP+SP8zRWExA1znloSZrJKrWT5+RGoMp6yW2xxDu4L0Dh1ca058i6xBFyQcEerIIpkhNpOt9OOzphHyKn86ALWVLHKitVswMT8QuUoMNIMP5ygRYvaefZTFsjSEK44eKjtp6zDtmDqPelq3ZWyiaQTwqAt/IJlLS+xvlA0VZgvgetwvi/0K5Cwkm1Rq/0yE0qSL5fsC4t6TCJeCcOA2URvUItg6suQ3/DYgNPhJROSzGYzid2903dpHQsDuP1ouhC8pnOPcxOd44oAmHPId5KOGLJ/wQBttalaxnNiwR+scu6PH7EoMPOFpv05IrD/fBwWK1ajxNkVwaaXLso5xV+qRqyPYCGWJciSCRZUMrxt9wZXlEc1ytt7RT/DfGQGUNsPR1KoQlOqli/3ItPajQQFx00lmae/Dn6BdDQmpuZjnHLMhcqrPD2PODEh8xZJu4VC1qV+/NSF2XhwVzzTykDxTISzEic/KPNIyl+EHG1t0RcuKuSx5d/FJMhR8WjYsrPFSGIpnE5PD3GkLmIW4bnRErUiBKLZvXrxNHxLI77b7qNnErS2XhRRacJy6lOjqxCETGBWYfFlpDDjdh7J26dl2A3cyYmWCcjU08yE1k8fOJtQiNMT/V62/gtD3m6toehVrowkcmYvreM+8q8ctFnKJhqqXCwXCVXVg2GZueYNGP3OyrhTR8/UDP+6xgNCZsSnB8SeNANYRz7xoYxhLy6ss88jRpmlwRov/oaO90AV2ejsuKwxUH6LE33X6qEGho1/5PJmAeNXD/tv5/J6l3tL50g3HcLUdveINpjZg69vU54JzziYbuxWKZIqYbIDy9rq36U/EoWQKNsqRZ+kd05L0prwbvpiSMA1I1KCauPKXVOJLP6gqnRDPmo5DdQUx3qoRinlqDARZXKzb0SRxkp6ILO1vK9TUZI1MqwXfd3MTGyb+/ys5eZw X-Microsoft-Antispam-Message-Info: kCrTuZkePOyQIEx8uCMwngL4bNF7CPbItTiLYz6w/VBns3GVPZnIdYqaR0RF2Tu+YwI07DEI8BDoBiAxISyhFOrh1tyZ5YaKQY6nAqRixiKXELOKXwrlkT6cD8uOvkrC5cof/538nhd7amF68/5PHxcIHdTYZWhBGZKLX/vzot+SlaHyK872LvBNQrR/p09r6qKbpI3afqLTfSqrhMT+61hIQhpQ9w6T66cUVnIhXNQlmof3+7alaIyRk60jQzIZjyUxi7Ig04P44BeZxDm3jd27hrf8UUcxkMQM/AMVZcP9Dfoucxj5tdvXiMJf7GPe3t8MSFCst/RVhHuDubch/LW51FJEewgIUY7czU/ASm4= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0301MB1570; 6:IkDnlTs9wVFcPeGDLBi2IsmGNoIk45iSMwwu5JKVwX3rFvRmuFf45ZhhV5rjUtmqsXiFym7I3fsRNzdsVOF0h4HFKM9jV0pJ3kAOWAq64YPtSq0OzQVPtuJTXiLZJvhRtPhQkRkPXiW26OpSL6RBnGOhamLUJawEH/r89iuqANXCU/q4EtruhRxVUOXKro58Y8Z//wKKG+TU/aclIJZ0hVt7h9QVbMrraRc5ZL/kKnKArpzUkRNQikUGqOLviypgVauRslXo534omR8gkXrfC3sAxx/kow2Oi+ctoXXZS1FBf4Ll8FWmmhINfN6L7GQSKqfHhduPdFAuVyttFCbsWKWABQLyGO3Te0ie4YCgFG5gwtUAmQv3l61cDQAiQ45/05onFv30qvYS66w+avsWLXxqDYQmZ3UCBwErdawLruOjbwROuSg9K1P1/hun4yIV8D9pvfkffT6xOUK+YKBAzg==; 5:Gr1Sfr/xGm1mT5MHNvln0RBuGz6l7MXiEGQNo32Q1G4z9ANPjFE8Q7Ul8OsrV3S57Bes85E5y3e3AKh7moeRi8V9ZvvMBNHsEoiq0eMOPdtKjWOFzyBUxDnOLgTQSMAwxlWnMDJKZLGegOKbylMmvyR9DPK8HB0mzMzqp1mfM/Y=; 7:rPYUzcOHBX5zEp1q+V2XDb4elZmTjSDp7sU8EXvK+FxL1346JDFmUowYvJrnQULPFoqVfk2J4888pd42FToow69N5t40OFAy+oDRRVRgVpPtPK7kB0And6GBpsExuzKQIfi7BGaQ4FCZuyo4Ncry5SCIDAmECIDHhy1XaPHoHcclVaSijue9jTtQgcU0hPIB+PB9yWqWIXDcoglqAyneETeuuwb44hL4voGJfWF+ExcVNWiYyorr1CsRUVYX8ITH SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jul 2018 07:15:15.4855 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7d5ce5c7-19ea-41a8-ce05-08d5f2c78a09 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0301MB1570 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180726_001530_591753_3CB0C0AF X-CRM114-Status: GOOD ( 10.27 ) 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 Thu Jul 26 07:14: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: 10545353 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 0E316112B for ; Thu, 26 Jul 2018 07:17:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E92D32AD78 for ; Thu, 26 Jul 2018 07:17:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD8AA2AD9A; Thu, 26 Jul 2018 07:17:12 +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 7D1182AD78 for ; Thu, 26 Jul 2018 07:17:12 +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=66/dVDUKmUwFcWOypYQcZ0/rih7SYyrywrIvX3PPwr8=; b=oGa9Q6A5DSIEQc rb02GphXjThLFhgnvKOAlZFplU/QjbvJ1QdjIqRszOw4XDtd2cuvvnBpJBseQcKanOdAgfivBJVEG 3DtlJpWEdaId9kNTQ2e59VU2WoJr91Z5IcwcKWJvS7xPGAcLNlMJAtAfHDAgD1t83SgWxM1rkfimW lkBf/tAGmTwgjZF2iuZffluhzLLU/ys0Y4EMScpMhzb4nEWvpbkmRklAfrRGP1idRopAFxsgXwCRW +mTylUUfD68s9VU0rRreeockRrKhWPKGcWwV/50Ce/VcuB4tyOq3FnD28Ce/oxJZ0jhTMAA996+za CkxwgPhSxzS1ZN+91l8g==; 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 1fiaWI-0002MJ-6u; Thu, 26 Jul 2018 07:17:06 +0000 Received: from mail-eopbgr680074.outbound.protection.outlook.com ([40.107.68.74] helo=NAM04-BN3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fiaW6-0002Bq-IM for linux-arm-kernel@lists.infradead.org; Thu, 26 Jul 2018 07:16:56 +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=HlRP5G2TG801QspAVoCKXLH6MnxPvuZHUwgGBnLxYX4=; b=XVnEikeiFVfziyuCWPtXtwESNiTYjGexCI56KxZPT/zXp9e+cBPe2Up1eHuBM2Bnb8Hci9ZPvCGRh9dzVCfjS6mqL6knQw1asDSOMxtI217XSX+q2NqkTHTTg7yFOr7jKv0a95IfaI8ZA2EYEoI/smeQfHZb+CEI5WMV/wB/RlI= 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; Thu, 26 Jul 2018 07:16:39 +0000 Date: Thu, 26 Jul 2018 15:14:24 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH mmc-next v2 3/3] mmc: sdhci-of-dwcmshc: solve 128MB DMA boundary limitation Message-ID: <20180726151424.4bcecf41@xhacker.debian> In-Reply-To: <20180726151017.4da1e336@xhacker.debian> References: <20180726151017.4da1e336@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: TYAPR01CA0070.jpnprd01.prod.outlook.com (2603:1096:404:2b::34) To BY2PR0301MB1574.namprd03.prod.outlook.com (2a01:111:e400:526e::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c619941a-95fb-4468-01f4-08d5f2c7bbf0 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:uR8qndBRM+bi+i2EJyzGifOhGY6koOzxZ/tHarlaJ1LPtj/2JShl2S451c1O3OdkzYymO4YQPK6btNZwr5UxxWOAqF2IiFmjUJ07DJ4HGCFIkstK43WsZx6YIrCSjRuQB1IdNRG2TQa8t/+C2+a249HoqO5PQGLnPyFXMG2A/HCdx4xAQEyALKCbJ4JmOF43etEq7fP9YtyIZH9gZRKXB52TA/LRNkgOvHpceTlAyKf4Mx9bYpEl9VCAucxwam97; 25:2nvV1opx0VXHihR5Arl+3ZvJi69TJkuryw17CNY1ltU/7YDjHwGtCU18HKvd0yHzwhWmHq2B70J8VB5hyAOhRB5w8qCOIGAzTwVfweUMzi52NrGf+7pI2FY8Sak3fgeCv9/yqySr03NNlkwR70e3m7sAJYyVQbwropDHkTYUPPoe8m2h9OzpfrwspGOfy1z9fIRUDCD0XhxKx29wlH0PgbWE8zIP0gGFhQza8zDjmpsWfenO0KTx74rbqLnDRCYXlJxduXhdnxZpFuS/KYCzt6RZnks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z7UuCJsWOjuWUhVxlvM3RMVHHIM1sUvwBQEGyVKRnZ9FL43DZVM3FiaaJMa6euSfmwy89UBGZ3J5aacgQi62l3JI5U4jWeDae+w== 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)(3002001)(10201501046)(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: 07459438AA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(366004)(396003)(376002)(136003)(39860400002)(199004)(189003)(25786009)(52116002)(6116002)(66066001)(72206003)(230700001)(106356001)(5660300001)(68736007)(4326008)(305945005)(53936002)(478600001)(105586002)(6666003)(7736002)(7696005)(76176011)(6506007)(47776003)(55016002)(33896004)(8676002)(2906002)(16526019)(26005)(81166006)(8936002)(14444005)(81156014)(186003)(86362001)(97736004)(3846002)(446003)(486006)(50226002)(11346002)(9686003)(1076002)(50466002)(956004)(23726003)(476003)(316002)(110136005)(386003)(133343001)(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?1; BY2PR0301MB1574; 23:3J4QlBVxEyq5I9GzVUDZOUZv4R3ly4dgeSooYOV?= wH2gxeqUeLQUeWnA32k+XxmNtZPm4lvo9F3+gqLatvYyUmMr/asa7UCZ4iO7JxyrnziDN5qAvL8437cKfByDznCooDJaboRi5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oZ6eBanK9R2XEyq7kWRELmgbWpIcsaeFK3zRpNPRnpCd7oH8zW/WC4Q3FSC6Qo87bZJ6zfRDG56c=; 7:MYnh/ASPRsEmkNY4KRl+sHPF3opbknqOB6MVqRNOn3IvSMOBHfXsgYOjg69dQw2L17x0n7gcdaQ+RZdbmzKBApChKhneL55H43CTJ4Kgh37UwLa5wxJmfw9Fm5tV/z0cd53gI/af0/ZN8HbT+z1kdNl2lkX07kr9+mt2sONlwtxCc5eFHgPxSmUknjzf2HB3hyTSOQJ7yIidb9qg0vX95NYqFaCwLTbsqahY3in4/xvaG7icFcK2grco8QtsvpLo SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jul 2018 07:16:39.4814 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c619941a-95fb-4468-01f4-08d5f2c7bbf0 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-20180726_001654_669767_A2DF4E68 X-CRM114-Status: GOOD ( 11.95 ) 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 | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c index 1b7cd144fb01..7e189514bc83 100644 --- a/drivers/mmc/host/sdhci-of-dwcmshc.c +++ b/drivers/mmc/host/sdhci-of-dwcmshc.c @@ -8,21 +8,51 @@ */ #include +#include #include #include #include "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 (BOUNDARY_OK(addr, len) || !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 +66,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);