From patchwork Thu Aug 23 10:07:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10573685 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 750681390 for ; Thu, 23 Aug 2018 10:10:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57EFE2B954 for ; Thu, 23 Aug 2018 10:10:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BCEC2B956; Thu, 23 Aug 2018 10:10:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=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 E10AA2B95C for ; Thu, 23 Aug 2018 10:10: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=QYl94OI2AGtzBcQtFxSkX8PsRvsb3xHQ91BL1EYDpBE=; b=KG4IuXyzJSJ4eG +v1vg2MzqlvUI6lfj4OnmqXqmFmcbr56FkkGS4rB5ummz4YQ1ZR/4QjUatQKQynMw4wgVw4jGEuJc LWhWQWfSnPFE8XeGcVqxPTbNgjBMOxIEo7ShGo43hRH8whrGTXxcbbUBCchCI8sqN47itFOqD1isI 4qQSYg2WyFC91bTCS72K4hmVMy5PWq48QdoIk3qcw6ciPmsRK0reeyMLtJQnupHLtZwUNBbG45IFe gy1vZ5lH8CrfZXH8Tg5TkLzEgvmxcorRVtCgG1+FGif1yXEesaQ461qCmSvS07puR0F7TO9NomrRp Sd/0myvirBy6A0oj2QDA==; 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 1fsmZA-0002aG-9S; Thu, 23 Aug 2018 10:10:12 +0000 Received: from mail-dm3nam05on0608.outbound.protection.outlook.com ([2a01:111:f400:fe51::608] helo=NAM05-DM3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsmZ6-0001H3-DN for linux-arm-kernel@lists.infradead.org; Thu, 23 Aug 2018 10:10: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=9Bon9+liMmvla43DwIjLyvZGi6jeqHc3DRek38ffmlY=; b=imyrJaoTZOlwV1YPuEhIe/PO/fFGhBIzhiwChQseFl5Z5R8db7Fu9rxHUnfJX7DpRn/OolRqjwAD7irn47iWNzDXneiCUbq5H5B9pC/5Mamdx/gTuMJIb58zb4d5KB91PVAM6GJNf3ySyvKfB8Yqn+kSy4EIGJANZlTpYNQ6icg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; Received: from xhacker.debian (124.74.246.114) by CY1PR0301MB1579.namprd03.prod.outlook.com (2a01:111:e400:529c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.14; Thu, 23 Aug 2018 10:09:53 +0000 Date: Thu, 23 Aug 2018 18:07:00 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH v4 1/3] mmc: sdhci: add adma_table_cnt member to struct sdhci_host Message-ID: <20180823180700.3432c4db@xhacker.debian> In-Reply-To: <20180823180549.78e508db@xhacker.debian> References: <20180823180549.78e508db@xhacker.debian> X-Mailer: Claws Mail 3.17.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: TYAPR01CA0067.jpnprd01.prod.outlook.com (2603:1096:404:2b::31) To CY1PR0301MB1579.namprd03.prod.outlook.com (2a01:111:e400:529c::17) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 71ac459e-c399-4fc1-9af9-08d608e092fa X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:CY1PR0301MB1579; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1579; 3:p9xsUimXJDeEgOzpcYBM/UAWDso3YHMAV6nJxUM1j2eczos+Q91j6BMQRdq56gn1gKYpYHVRu3AdJwWJGL74b16GgvNxY11SS4e/cv1B3Nh0hDubpGdlc7QlTQYS8y/lxhtuJXFbe7Tt+XO127E8pXRKYZV85p5Wh972amP8VWDNjE0xaORcJiGklbr8YMJ+Cg6qopsDuagTn3haU6Juxe17N+AwSJ/oc86CDZ6KT+ssIi6zn1zT4ZeJNnytNlVh; 25:dpaaLr0TsiZjSAHNpIu+tZww0ovs6NURUEctMQbRYNJadmy6aI/pOHqMlq3Xt4xaLJTqrXYKENbluIlTZNsX74pH06VtDLF6kEkgH3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w+7x4bY4eeL4jxirf6KCUmLyexZQq7vUMaNoc80KLf8+mmd9xERoTmKXI/9daQ0KyPSPlKjLLh7oeGYtDRw/UmxUagSkSW62Drch5FrR462Cb9zzwmpaGq8L3DvimkcUa87CVM61sRpRUB0Csug/xBxC/b5ipvWXLMelcisQyqVkLvLvwwirUIAlRDY7M4Xe54VwLzBfXVbzZCcOOVh98V+K3/XtIJ+NQ5SW2N3MifBWAN6zpYAT+C7NFzUwj3ufklh5dtFdEA== 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)(10201501046)(93006095)(93001095)(3002001)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201708071742011)(7699016); SRVR:CY1PR0301MB1579; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB1579; X-Forefront-PRVS: 0773BB46AC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(136003)(39860400002)(396003)(376002)(346002)(366004)(199004)(189003)(478600001)(47776003)(66066001)(72206003)(55016002)(9686003)(53936002)(26005)(3846002)(575784001)(486006)(1076002)(7696005)(52116002)(6116002)(86362001)(76176011)(50466002)(110136005)(6506007)(386003)(33896004)(54906003)(23726003)(186003)(16526019)(11346002)(476003)(956004)(446003)(316002)(2906002)(8676002)(7736002)(68736007)(230700001)(105586002)(106356001)(8936002)(81156014)(81166006)(50226002)(305945005)(5660300001)(6666003)(97736004)(25786009)(4326008)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1579; 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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mfqOIp7CJ7pljEqBuCP8QLRSSVVW034C3hc5lAzFw==; 5:3Qhk4sk2Cq+qWKk9a1xedehdDlYRP9rYYny4S1occNsiH98BmLWjC+vWJTYargDC8OzqA+ZQ4aNAVk7y/35TnE5I7qeVIlb6FM5RMo8l2J0OVCy6s8J3pQuvzuSMTNQlYxvN8cg1cusaukCu37ogumdHqk2LySybjjQZHYkKzlk=; 7:06vqGp5xbyEy+mRGIssBFhh9Hd8wXtQ852d4j0zS8idhnEqFx03/OHjRPWSPRSHPT+7gXPdDJ1+uk4BNmrXVhxY6GJJo+aCdzTA3m3t4DS0BKcvIDlviTO9zmrUmRupb+dnn9ExkAy/dxOlHhhvCuiKNiYF/SkA61qFDYmqh6Tu/d24KfCQJcjSKenRG3djd8BU1WMNJl7CiIiTvvD2oT1HBORLyqvZoNAJVW8iZTbaVSlNN2wNFnYEhfuIiZYP9 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2018 10:09:53.6798 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 71ac459e-c399-4fc1-9af9-08d608e092fa X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1579 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180823_031008_616230_C54C2F86 X-CRM114-Status: GOOD ( 10.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds adma_table_cnt member to struct sdhci_host to give more flexibility to drivers to control the ADMA table count. Default value of adma_table_cnt is set to (SDHCI_MAX_SEGS * 2 + 1). Signed-off-by: Jisheng Zhang Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci.c | 17 +++++++++-------- drivers/mmc/host/sdhci.h | 3 +++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 1b3fbd9bd5c5..52ccf4644384 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -3322,6 +3322,13 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev, host->sdma_boundary = SDHCI_DEFAULT_BOUNDARY_ARG; + /* + * The DMA table descriptor count is calculated as the maximum + * number of segments times 2, to allow for an alignment + * descriptor for each segment, plus 1 for a nop end descriptor. + */ + host->adma_table_cnt = SDHCI_MAX_SEGS * 2 + 1; + return host; } @@ -3567,18 +3574,12 @@ int sdhci_setup_host(struct sdhci_host *host) dma_addr_t dma; void *buf; - /* - * The DMA descriptor table size is calculated as the maximum - * number of segments times 2, to allow for an alignment - * descriptor for each segment, plus 1 for a nop end descriptor, - * all multipled by the descriptor size. - */ if (host->flags & SDHCI_USE_64_BIT_DMA) { - host->adma_table_sz = (SDHCI_MAX_SEGS * 2 + 1) * + host->adma_table_sz = host->adma_table_cnt * SDHCI_ADMA2_64_DESC_SZ; host->desc_sz = SDHCI_ADMA2_64_DESC_SZ; } else { - host->adma_table_sz = (SDHCI_MAX_SEGS * 2 + 1) * + host->adma_table_sz = host->adma_table_cnt * SDHCI_ADMA2_32_DESC_SZ; host->desc_sz = SDHCI_ADMA2_32_DESC_SZ; } diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index f0bd36ce3817..25bddd21de31 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -563,6 +563,9 @@ struct sdhci_host { /* Host SDMA buffer boundary. */ u32 sdma_boundary; + /* Host ADMA table count */ + u32 adma_table_cnt; + u64 data_timeout; unsigned long private[0] ____cacheline_aligned; From patchwork Thu Aug 23 10:08:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10573689 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 E86BA112E for ; Thu, 23 Aug 2018 10:11:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9C2E2B956 for ; Thu, 23 Aug 2018 10:11:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDE812B961; Thu, 23 Aug 2018 10:11:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 468592B956 for ; Thu, 23 Aug 2018 10:11:34 +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=AZ9zIe9UkHHrrQZL577V8ShesngLhq9Cc0adn1BjBcU=; b=uDq2sIQigwSq7Q q9iSCEuRVIGHhz1t6eQOw6358U2Iona4f9ySdksxKn+l03mLqdKWmG9LishTMyxz1/ljTLh84I+lW VqAnrACvHP1OMS4E43AhCEmLd4X4/1ziSV+W3ikqqPMmSIv+JxVdySbF4VkN2Zm5/1rVVKKUnudij S+NKTNpBHZ8SW+8oawT+8B4eW2FhfW1aScrjFIDkt6O85MO94PJSRFVj9ZECaboLJmPrjKSwtBJjR nTjjrYMQKpkkcJvN0PerTZ6ON+Hks1paely2RLVA4a44IP4nmU3SYlt7fTZuIupqxyCSrdedP/tI0 8S5W7LPWNgjJnvO/fWOQ==; 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 1fsmaT-0003Fb-9M; Thu, 23 Aug 2018 10:11:33 +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 1fsmaQ-0003E8-25 for linux-arm-kernel@lists.infradead.org; Thu, 23 Aug 2018 10:11:31 +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=XHSZSuyjNGrT+Sf76Mxn24jsh+NJ/0VMIqAwG89hV98=; b=II0i/UJnI8SEJBqwXhHSdNTAFkADBNO3hn8Itwe1NPXycnktJ19KJhQYJJhSqVVqPhYXpDRYvW6KoYRvXGgUx/yva4rEU8l3cJDCojXaPRPSLgmFaen/gAn7pO9v3i+Nw1Vt34kRA/B87hEmUTkkCupZXmEb2ikJE1tasD/nx6E= 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.1080.13; Thu, 23 Aug 2018 10:11:16 +0000 Date: Thu, 23 Aug 2018 18:08:22 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH v4 2/3] mmc: sdhci: introduce adma_write_desc() hook to struct sdhci_ops Message-ID: <20180823180822.7e904f73@xhacker.debian> In-Reply-To: <20180823180549.78e508db@xhacker.debian> References: <20180823180549.78e508db@xhacker.debian> X-Mailer: Claws Mail 3.17.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: TYAPR01CA0166.jpnprd01.prod.outlook.com (2603:1096:404:7e::34) To SN1PR0301MB1584.namprd03.prod.outlook.com (2a01:111:e400:5232::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6a759829-6b39-4e1a-d4e1-08d608e0c41a X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:SN1PR0301MB1584; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1584; 3:vtRkCvRmfvL/hYVEl9lJdTyq+HucFaH2UIMIkrQqrQ3r4v4sp1LpJ9VEyNbsTJ7XXpd3u9GAwoeRLXuPpwfRv4FxqX36C8bMKMKKWyWuUdBjpUuZkdqQiISMAf4zB59YQIFanWKCIaGYVT3SDgH2WBBOtCGL+Yx5UZoDnxOn/WidWZ+aZhgUBK9B1krztRTs7k5ER8432fAOtXYWILV2b+1KhF6px/pmp8WAtnG5t/hy1QiTg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huLSJzo0vufoDjTpGJRolhgwmGWNeU6I+DJf6S/PRmI3qQ2VYq+pEnM4AdtjUfauhZwQlxE82YDqfhxEsgeiH4Ls31jEIrveoBswRl9; 4:UisnWzMJfyp4aUnN6LI+I+dWPBLQ0REUKkBgxge4PQvGa1GFvNP2D5zY1Spbz5RMkZvRL4UZ7EEhM+6Eu+MXpK5vzyyCg4ZAI3BxIVxO2z+MUYOPMl/m5HJ8wIYWcFGRh263Cy9ZrhqdBRoHX5F/fM6BntsiEcq5N6qk1plFd06q/rdtuJMx1olwsEtX9SI225E55EzQYAkDjAZDCTRHyYXH1ERvbeiKSi7PWg1b+JjUTCho1aplrqL+P0JguMaYMKusgBNtEStHFEh3U6NX+Q== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3231311)(944501410)(52105095)(10201501046)(3002001)(93006095)(93001095)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016); SRVR:SN1PR0301MB1584; BCL:0; PCL:0; RULEID:; SRVR:SN1PR0301MB1584; X-Forefront-PRVS: 0773BB46AC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(39860400002)(346002)(136003)(376002)(396003)(199004)(189003)(6116002)(33896004)(76176011)(68736007)(3846002)(23726003)(50466002)(2906002)(1076002)(50226002)(14444005)(305945005)(8936002)(106356001)(86362001)(25786009)(7696005)(52116002)(7736002)(97736004)(230700001)(81166006)(16526019)(316002)(6666003)(186003)(5660300001)(81156014)(956004)(47776003)(11346002)(9686003)(26005)(4326008)(386003)(6506007)(54906003)(105586002)(110136005)(8676002)(72206003)(478600001)(486006)(446003)(476003)(55016002)(66066001)(53936002)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0301MB1584; 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; SN1PR0301MB1584; 23:q3shqjl0WNRsOm7UqLMxA6vHJs9TULO2xho0o28?= NSnMdJP4qOyDtABmfIFbELn+SxDOBI2wK8WT7TUJO7WUQWhtuBopVGR0pLccrY/hRoeO3vZ55yhA2Jnh2iuL4KU84z0mkENSf948cy0lvCFJLorM65eLA4txwLLM2aLWQYT9x9aRR6sTqJ20P+GKF3z0Web5cp//C2PJcDQSLX8I0mj9Nnc9OixaJ2Mx4iv2j5lDDwRQLTH0BJG2vJblioksnnBSKNiF72QjRI22Hi6YWfbnoOkVh5FZv5VBzPZ4P1AQSDlYfxucIbiE+GTaAqy7YODrDgUjWt9apvyyrbm0mYjVHqY0HV2coR0JIBm2QC+vwM/icPNH0a9xncBV8AK1ohREVQ9nyq0BbVsCVdAp+DZXFne+5DPE1ieT2KxcbFxcP4GuisrvENGS6Xj7bO3E4NvU96IOt6VYs7zYI2fVGFU2pXV+EzCdQc8d/pm8OocfwABw+sz4E5I7fnuWvIlwO0/UFiReSUlAvGe0ge1nLlwuKNLsNKd5LXUj0YAQ9JqFzn1pe91I54FaHW1CuQf5sBeytPMnsS4OFjsuqYEwKGimokGSatKx6YEeNf7hd0yxscdtWY/aDixVagnP0w2tpf8XODLVw1CIXEKmzPvvh6of3jQAWn34RnmOvonY34sXeTB20IF0IKuEAUas6n5rlWioxgWrgNxF+/IEcL6GHbafQsOA/o2fqWfXrCoyN+CR35uUNzdOtqDDmnahc1KlePLtC7PG6OxcuhrhU667UDTzGfvjy3nQdmI7mmH5NLvZ/UBBoFFyzjBPcG3F/lYVz11PnohwutNKMQy/yzadMCHZwKq0BMxbwdoY4CKk8kI0E+9GgxOCGRmXqqKX4pmAdNln3nYaZipwCPz3bECzQ8v8UzZcp5Um0Z0YM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F/fK7WGUZzK4/aiftn7HqTz8pmE2+qMxMLt4G0NwKa3X1jfqyD1Sn9ohZS/zMW4WrsqSaDffCBjEL1e4y8KkGWk4lePFyVX7sK2SxBT+3oS+updHuOJbb/Fd5CpkM7UYSaEDycuFMT0azRpp3G3NKFmAxPkresMQ==; 5:FMy+3tQpU0Sipuutc99Tj/ifjGuZ/zOxOim103okZUTOWLj4Xlvb06JuEousgsPCXku09Ha+/Td3L+s+wEwmdxB1gcD8brIb1pB6Kia+5Tc4QW0h952CjrThyUhI8lj3VX7KcAVeiESXtUbPyIVgbxPdBIMYS4EjGUm2iklkJAw=; 7:8G1vtTEqorXc2dTzve+uUlPXKO9kvfVvvvaXp13HxzjydqZwaubLbjk7IZZaMtuijDrrBDMxA9q2MpdE4mdn+2/vg/Ly1EOiS6C5odQfgX/LE6AzyC/eVv+U+G/cH5/m3gaCmdW1TDW2Rs0AWU1GelawwVim3lzOBohPQUESashOfnRjwag9nA+wjm1LEALsx71lr3noWsc97SuDgK6stNbfvfwyvS+APnkaYsydH9TJcSrwXahDBd0aiD73tYdw SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2018 10:11:16.1041 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a759829-6b39-4e1a-d4e1-08d608e0c41a 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-20180823_031130_170639_8B628AF6 X-CRM114-Status: GOOD ( 10.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add this hook so that it can be overridden with driver specific implementations. We also let the original sdhci_adma_write_desc() accept &desc so that the function can set its new value. Then export the function so that it could be reused by driver's specific implementations. Signed-off-by: Jisheng Zhang Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci.c | 37 +++++++++++++++++++++++-------------- drivers/mmc/host/sdhci.h | 4 ++++ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 52ccf4644384..eb21d2db7f05 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -554,10 +554,10 @@ static void sdhci_kunmap_atomic(void *buffer, unsigned long *flags) local_irq_restore(*flags); } -static void sdhci_adma_write_desc(struct sdhci_host *host, void *desc, - dma_addr_t addr, int len, unsigned cmd) +void sdhci_adma_write_desc(struct sdhci_host *host, void **desc, + dma_addr_t addr, int len, unsigned int cmd) { - struct sdhci_adma2_64_desc *dma_desc = desc; + struct sdhci_adma2_64_desc *dma_desc = *desc; /* 32-bit and 64-bit descriptors have these members in same position */ dma_desc->cmd = cpu_to_le16(cmd); @@ -566,6 +566,19 @@ static void sdhci_adma_write_desc(struct sdhci_host *host, void *desc, if (host->flags & SDHCI_USE_64_BIT_DMA) dma_desc->addr_hi = cpu_to_le32((u64)addr >> 32); + + *desc += host->desc_sz; +} +EXPORT_SYMBOL_GPL(sdhci_adma_write_desc); + +static inline void __sdhci_adma_write_desc(struct sdhci_host *host, + void **desc, dma_addr_t addr, + int len, unsigned int cmd) +{ + if (host->ops->adma_write_desc) + host->ops->adma_write_desc(host, desc, addr, len, cmd); + + sdhci_adma_write_desc(host, desc, addr, len, cmd); } static void sdhci_adma_mark_end(void *desc) @@ -618,28 +631,24 @@ static void sdhci_adma_table_pre(struct sdhci_host *host, } /* tran, valid */ - sdhci_adma_write_desc(host, desc, align_addr, offset, - ADMA2_TRAN_VALID); + __sdhci_adma_write_desc(host, &desc, align_addr, + offset, ADMA2_TRAN_VALID); BUG_ON(offset > 65536); align += SDHCI_ADMA2_ALIGN; align_addr += SDHCI_ADMA2_ALIGN; - desc += host->desc_sz; - addr += offset; len -= offset; } BUG_ON(len > 65536); - if (len) { - /* tran, valid */ - sdhci_adma_write_desc(host, desc, addr, len, - ADMA2_TRAN_VALID); - desc += host->desc_sz; - } + /* tran, valid */ + if (len) + __sdhci_adma_write_desc(host, &desc, addr, len, + ADMA2_TRAN_VALID); /* * If this triggers then we have a calculation bug @@ -656,7 +665,7 @@ static void sdhci_adma_table_pre(struct sdhci_host *host, } } else { /* Add a terminating entry - nop, end, valid */ - sdhci_adma_write_desc(host, desc, 0, 0, ADMA2_NOP_END_VALID); + __sdhci_adma_write_desc(host, &desc, 0, 0, ADMA2_NOP_END_VALID); } } diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 25bddd21de31..2115416f973a 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -606,6 +606,8 @@ struct sdhci_ops { void (*adma_workaround)(struct sdhci_host *host, u32 intmask); void (*card_event)(struct sdhci_host *host); void (*voltage_switch)(struct sdhci_host *host); + void (*adma_write_desc)(struct sdhci_host *host, void **desc, + dma_addr_t addr, int len, unsigned int cmd); }; #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS @@ -736,6 +738,8 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios); int sdhci_start_signal_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios); void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable); +void sdhci_adma_write_desc(struct sdhci_host *host, void **desc, + dma_addr_t addr, int len, unsigned int cmd); #ifdef CONFIG_PM int sdhci_suspend_host(struct sdhci_host *host); From patchwork Thu Aug 23 10:09:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10573691 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 3B868112E for ; Thu, 23 Aug 2018 10:12:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 216292B963 for ; Thu, 23 Aug 2018 10:12:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 159EA2B966; Thu, 23 Aug 2018 10:12:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=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 0A2902B963 for ; Thu, 23 Aug 2018 10:12:38 +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=kHHr0P81vxdOnt2pianYQNV84aMLIo+CYMjq6+VnRFI=; b=sp3gNW3XH8+5v3 w7NTvr+8I6A8Sj29WO7o+ZekCxdXmKlWW/OPNBks7eGaSfFyit63BjBOZOFsalXHsEbxh9toRy6SL BU/6SSAPMFyhLbxYCJE8QiJb7AVvqA0L9BhceRUsUFTasY/VnoZxrcq9+j8a8LuZgqrxm4GrI3Jxo Ix3AEHuCTpLfL/B3RwEma9fN/FpKB82p6jLS/mG8EOiFdeKvhCPzYq1sNkSjz0QIWtvin4Q2vykG3 jibxLLAo0BcK9N03ll6gLxvWTFV3Ed687TOou1Fy/ymW1XAI9/SiliwcsVu7KruamwgnrlTY5i3R5 1jM2CXA6D51g4dH013RQ==; 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 1fsmbV-0003kJ-AC; Thu, 23 Aug 2018 10:12:37 +0000 Received: from mail-bn3nam04on0601.outbound.protection.outlook.com ([2a01:111:f400:fe4e::601] helo=NAM04-BN3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fsmbS-0003jS-GL for linux-arm-kernel@lists.infradead.org; Thu, 23 Aug 2018 10:12:35 +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=mugOSjt0euDPb0idTRjybc3FDW6t0ZBTaqeUhCSK0Ms=; b=mhZXa8ENQWP8826/q0KfoND+rhjnYUtEE58zLk+gRpSAVkbE1CkW/eZ3CJSzQX0XGV48+WQnS0z1pq+XsCDRUBu6/iF/98A1jz8R5SkWFQaRbzd44XYzpzY/8YcC/45HXWPpG05YbYuG/REllrWT4ZqQvodyEKn7fL6S+eXlHXw= Received: from xhacker.debian (124.74.246.114) by SN1PR0301MB1582.namprd03.prod.outlook.com (2a01:111:e400:5232::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.13; Thu, 23 Aug 2018 10:12:19 +0000 Date: Thu, 23 Aug 2018 18:09:26 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH v4 3/3] mmc: sdhci-of-dwcmshc: solve 128MB DMA boundary limitation Message-ID: <20180823180926.444b34b5@xhacker.debian> In-Reply-To: <20180823180549.78e508db@xhacker.debian> References: <20180823180549.78e508db@xhacker.debian> X-Mailer: Claws Mail 3.17.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: TYAPR01CA0023.jpnprd01.prod.outlook.com (2603:1096:404::35) To SN1PR0301MB1582.namprd03.prod.outlook.com (2a01:111:e400:5232::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 55f33881-a792-406d-d868-08d608e0ea0a X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:SN1PR0301MB1582; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1582; 3:iO8a+gBzdYCZJcvdWPIz15z/01cPHFwk02BWYqm4ll45FCCi7RT7wSAjc14v+V4eJK01CvwOmRkIxribR3SF4I0IXNkYqSJC0RMx9JDGKOMZ5mxn0FzeK/r9hr8GFlYGSaonWNgHdW3n+HToq/FtWVA7dxIb3h7z2G61+UJypxDqoAHbjKexkWQlsaeihNu2cRfFRYD9S2+gvSRKKyzCjo8wA6iUw/uwCPxelufzrGfrQGCFfnQvcohWWh6YAEiS; 25:UDawk77UJCIl5VbCp04sJZkE3KJzIsT4RXLvBUYqguzKMlVQb5P+h3Y//h1A0Ak17ZJfwF4QmkYYqQoK17xuu755Epb04uqCnEE2CcZL/idDAEhACjZP7YuQpG7fC2AAR85un7vPJKlUh+9tyj5RudfHwCmX9aD0sj2mG7eRAPRV9ILkjHMgxqai0fOK2TchGG2bGcpwewSozg7oj3srP7rQXWTjX2RjeUVsU8/LIcAlfQ2C+sYcrdc0KwDdzDFP38cphIO/Y2VGwye3kDo3RO0pKEOdxUM6ji+EEtnkiiFFHV0/Q39Z2L0+SMA6k33dB/28tl8f1MI41XsSrAEYkg==; 31:/v87Y6PczlyEmLDBWjDq+1waZzxdmH23x2zpt2fQ2fulfeIhvhEnV58K6EH6j0ldflfFD2M+xx1LnaGpfbofk0R4BEsZbcdz4lU0hlHv8uC3115ahXYDCpRDQ3eJQNPS97hDjD+i3xttaIu+q0bpYUNyrm526GxmGuts8n8fWLDkqCyG6o7i4cEvzrjoRkxb+zkR2wHr0pbDHEyw5XEgGdchJlxKhIARAEvPzGBwgvU= X-MS-TrafficTypeDiagnostic: SN1PR0301MB1582: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; X-Microsoft-Exchange-Diagnostics: 1; SN1PR0301MB1582; 20:vplPV1squi5HcE+LY9ydZeB0ecMLnfob3uDuc6WJJ+iwpAphGwQlVBAKj7KTTNvewiBdlbVsrKhgCK0uie+TJUShrNz6r68805y+IMlIYL4rXZ68ci/RrH+PNQUPnBWLjImBp0lc8tYTByJkMX75I/er5ygupvPm1lz+1P/j69Fz5n+ViH5Zlf8UcQsCdAiCc1k7bS8E7To1MflSgXv8bJf0iL8q5Rr4Zhi46yx7bdg6vbSgERcX7TqmtNtxB7AECklXdOKpGV/VieljYCFi8U53VysGdz014nO5cX/mKYQLtUOdDRrtgGVKT0I59ZIce1igmTROPBrlTaAydKSSiBTDWNiHpFxNYmsFV7Lk9mJlcde2n6DbG4V1hUKJlEVXUQjl4gmouatrsS8FPio23bvypk2KqVn4uBqkvURjTGtO8pgY1Jsjvj5CulvfG2oHi7Xgqcf1dc6Ad12gi+lTT5WettQj9rqyXyINKughj38iXGpgNjX4429k896Nq/mG; 4:2opeqg4aw+aU8hgQatm9OIEswC8IQQK9du8P8CFsWyEXoFenDAcbKIwRn2oY+tbA7T9MNgO/kSzCdzsyur/nzmz0NOzwf/AZ92NETn0n0PUyZfMnsFDArHzh9vZwVb+AUytRDZCUm6dEWKXXHsqTsA5vp57z3LFv9ozp0+JYpW029lgnMo0ZLVkBza+1+mAqKp3btdtqTYa0jTNnGy2WEZTxKDoidPSwpAs42yrkfqaGHpnCqXT20WY0CnQVFq60u81C508VSxsJJ0pKKF5reA== 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)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(201708071742011)(7699016); SRVR:SN1PR0301MB1582; BCL:0; PCL:0; RULEID:; SRVR:SN1PR0301MB1582; X-Forefront-PRVS: 0773BB46AC X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(346002)(396003)(366004)(376002)(136003)(199004)(189003)(66066001)(25786009)(6116002)(52116002)(3846002)(5660300001)(110136005)(956004)(50466002)(446003)(54906003)(81166006)(81156014)(7696005)(575784001)(86362001)(33896004)(11346002)(76176011)(8936002)(47776003)(478600001)(106356001)(97736004)(186003)(6666003)(4326008)(486006)(16526019)(105586002)(386003)(6506007)(50226002)(26005)(2906002)(1076002)(72206003)(23726003)(53936002)(14444005)(7736002)(476003)(68736007)(305945005)(316002)(9686003)(55016002)(8676002)(230700001)(133343001)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR0301MB1582; 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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pj6tQV2i8Eus36UXjhqEPzA6cGGHIoExI4XTpx4dha6XuTwI3oQJ0uiXLqspV404t5lcpTQTmjxcEzjfkiiQ==; 5:EtQ79QAMxCM93xiHfa6PpexrXwV7KEq1/a0KBv9CzbDyTMZg9X38toBT21RfYiTvgXPU4D3Owg/FMPwke6CZkE57ANX/h3DK6CRCthLWr3Kl6DCDPgxk0uHJlbT6E5JwZWZyOP42eKNBJgIyRgdwyjAeEPOrA6eruoOQ2W+4AUU=; 7:f+5Ekk8ZFL6GrTY/T014aeOyriW38jUDvYZyXzsGs3CW/AONCczH6BSPj+8J016cJv0E3MfluPBOItgzgcpBu7/eXSHmjiS+VIPRzuBAcTfHSjge8TOICxcJ7hCGZFAko/BkkCSJiPxkkqS2Oqu4euCs/aQxzGM6gWL6McXNxtrNv4ecSXzno/yPKVxwleAOZRIC4dnOaiX4kzmG+4wq6NcxpO0ima8e8AlWW00JeFsw8cGTXnejYENrfGLGIlwy SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2018 10:12:19.7560 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55f33881-a792-406d-d868-08d608e0ea0a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR0301MB1582 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180823_031234_694181_7BE34707 X-CRM114-Status: GOOD ( 11.59 ) 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 | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c index 1b7cd144fb01..df0a3aeabe19 100644 --- a/drivers/mmc/host/sdhci-of-dwcmshc.c +++ b/drivers/mmc/host/sdhci-of-dwcmshc.c @@ -8,21 +8,48 @@ */ #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 void dwcmshc_adma_write_desc(struct sdhci_host *host, void **desc, + dma_addr_t addr, int len, unsigned int cmd) +{ + int tmplen, offset; + + if (likely(!len || BOUNDARY_OK(addr, len))) + sdhci_adma_write_desc(host, desc, addr, len, cmd); + + offset = addr & (SZ_128M - 1); + tmplen = SZ_128M - offset; + sdhci_adma_write_desc(host, desc, addr, tmplen, cmd); + + addr += tmplen; + len -= tmplen; + sdhci_adma_write_desc(host, desc, addr, len, cmd); +} + static const struct sdhci_ops sdhci_dwcmshc_ops = { .set_clock = sdhci_set_clock, .set_bus_width = sdhci_set_bus_width, .set_uhs_signaling = sdhci_set_uhs_signaling, .get_max_clock = sdhci_pltfm_clk_get_max_clock, .reset = sdhci_reset, + .adma_write_desc = dwcmshc_adma_write_desc, }; static const struct sdhci_pltfm_data sdhci_dwcmshc_pdata = { @@ -36,12 +63,24 @@ static int dwcmshc_probe(struct platform_device *pdev) struct sdhci_host *host; struct dwcmshc_priv *priv; int err; + u32 extra; host = sdhci_pltfm_init(pdev, &sdhci_dwcmshc_pdata, sizeof(struct dwcmshc_priv)); if (IS_ERR(host)) return PTR_ERR(host); + /* + * The DMA table descriptor count is calculated as the maximum + * number of segments times 2, to allow for an alignment + * descriptor for each segment, plus 1 for a nop end descriptor, + * plus extra number for cross 128M boundary handling. + */ + extra = DIV_ROUND_UP(totalram_pages, SZ_128M / PAGE_SIZE); + if (extra > SDHCI_MAX_SEGS) + extra = SDHCI_MAX_SEGS; + host->adma_table_cnt = SDHCI_MAX_SEGS * 2 + 1 + extra; + pltfm_host = sdhci_priv(host); priv = sdhci_pltfm_priv(pltfm_host);