From patchwork Mon Aug 27 08:22:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 10576625 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5320317DB for ; Mon, 27 Aug 2018 08:26:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36335288B8 for ; Mon, 27 Aug 2018 08:26:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 268F6297FE; Mon, 27 Aug 2018 08:26:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 140F9288B8 for ; Mon, 27 Aug 2018 08:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RuCoym4FVi+RE5Tbz9XAEvmji4k9RYpgad8fyZEfDEc=; b=q8V89u+4lZLtlS w97gjKe3khqczRCtgFbatBo2lqgx3TYFYwr9iMYPbp59kgL2VnZxDFRgp3/9/DtTcd/gW4gIjJG+D 70+8Skhf8fVg0XZqzPUs1WVnOcMcMuDZ3uGFJt/Xyzp9s9D/awQBhvw27vG1//eBsNMHI/bYntWvn c2YVqOTvzzDu2TpPZq8Kt6HUOI8ROOFpwed4mYltHB42tA6gQZhxoofP+mgo/Zx5zS+jj203MMFHS 24c+DPp1D6Uol6cnoJuWza8iKi0Wc9Sdx+hNgYFc+0M2M8brPgupcW+R4UKyBhh3alvD+cL1V3GBg qUGbzuiS79cWxqIrDUzg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuCqi-0001yU-76; Mon, 27 Aug 2018 08:26:12 +0000 Received: from mail-co1nam05on0628.outbound.protection.outlook.com ([2a01:111:f400:fe50::628] helo=NAM05-CO1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fuCqR-0001sb-Vm for linux-arm-kernel@lists.infradead.org; Mon, 27 Aug 2018 08:26:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Synaptics.onmicrosoft.com; s=selector1-synaptics-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t34Jq3WRCfdlEWi8ntOQHsyGNkAU8Rm7d/6CzQM9b18=; b=VfNm+M5sf+2QB1l8kBWsoVbkmqnTFhdHKCJoOGUYSmazpXBoL8H9alPLhHTjObQJ3aiZABg2kJt90qY1rJVrfvkt/UNxp9BYoEzmcQXT4hcMIkIGORRiDpVsx9hFiWKAzKMQHZllxQ9CBE/zR8sD3gN92HzweA3p6A/FAt+yEtA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jisheng.Zhang@synaptics.com; Received: from xhacker.debian (124.74.246.114) by CY1PR0301MB1578.namprd03.prod.outlook.com (2a01:111:e400:529c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.14; Mon, 27 Aug 2018 08:25:41 +0000 Date: Mon, 27 Aug 2018 16:22:42 +0800 From: Jisheng Zhang To: Adrian Hunter , Ulf Hansson Subject: [PATCH v5 2/3] mmc: sdhci: introduce adma_write_desc() hook to struct sdhci_ops Message-ID: <20180827162242.0fc59e00@xhacker.debian> In-Reply-To: <20180827162026.3901de27@xhacker.debian> References: <20180827162026.3901de27@xhacker.debian> X-Mailer: Claws Mail 3.17.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Originating-IP: [124.74.246.114] X-ClientProxiedBy: TY1PR01CA0193.jpnprd01.prod.outlook.com (2603:1096:403::23) To CY1PR0301MB1578.namprd03.prod.outlook.com (2a01:111:e400:529c::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1fddc7e4-caf1-4060-19c4-08d60bf6adc6 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:CY1PR0301MB1578; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1578; 3:7tbD/BihYe0ssK7GQWsdDD4abLoy+/6jmkk6MiiWQK9U3qKys6xtTeCFnGVo2HHRHKNydK0BtuvujNKTWYBfuVBLQiiJZRaqShVY6v/O5ltQYS/WtMbYIjQcc4deeQIuyn82q6/zu/zIyH3YHl04xin1bW0gmy3mUTgLds6DrUTHoBqkid/ixf7TwWs8M3rY5Mu4RJlqMXXO694e7qUQS/HvwkWO+CkPec/BH16XZVxLDnSyJbzgEn+149fEqWqs; 25:8bqzlSa+BE4X12J4w080RBjGpOGTuuSlB/R6BYDunCDB6ow1dQsG0BEKeARl7HybWBrNhz/PNzSldFVDcCJFMekYKGcpq8zTjdxgis9989j6O3ggBagJgImo46OF3WhoefK6c1HR9/uxX+VGvnEa57PcKUPikRIPEhsxpOuopBRyZo0z5oBoHiYK/h9aPCHZM1YPkdUc9H5rawtJFW/bj9fxn5bMdck7km+rjq8756mcHr99R5x9iKRE2yH9GvYt8OA8PoOjOeFd9682E2svdUafu8iEbB2xRJs+OlgT7BI4YwaKfq/xFLzo16TsDHYwYBbLlVUAfk7fbbq/SjEt/A==; 31:X9Bcg7HK/T6phUz/6LC/DoDLEBeYnhZoKRa5Ri3ga/qLuDs+jHeIiZDXsil4E7KcsfDo24IgmFiXhlUxgTZ4mCaLEUJcUMDlaoXhMLacHHP6Hk3035NW1f8+n6AavsBQi2FMbm1UCdAp1f48d2OjCdSDq7liZ66ilP3dlyXAdakqv1I8fzVavvFL5IhYRexpEjmyTOrBYVj8Fe9vvjqpmju1aiu1km6z+eALwtix5vA= X-MS-TrafficTypeDiagnostic: CY1PR0301MB1578: X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1578; 20:JwkvusBj384BkY9KexcacW/igD6eWLb532uQHzpJje/yh9klznlFO56N/H9X2LOlloZCvvsdQvAZADR1XYtW5MUHq+FTOmfyeJN9rxZBz6Xf+jAh1XYsanO2oXo/b5AP73DLUA0d0q03cVzHwxa3XknmPb3mlsD1ogg32tOrBSMbMrvsOi5Av26kTgHi29Va3YV2b8FialSS5PxofcXDadGstRcjyJ5QtLus4RfS6DCm8HmfuW74r13TqSNfuSI7hQoKsO6YX9G0QuxfFuhUs+5+kAZCzNkb4MAvBQxEmk9jjQOXoIUh8jeyt1kiQUkJ6lDwDwx7cGmQiiigb0hBHODoijpkiwBkyADkuqXSSvuGuORMSWXm0jhjYekiUAcZkU3Urx+QFg0BElhIWVR1197f1GMGghUaBlTlwvB38HKuEp+T/nfp+r+jmj/uQONDfXpcjplfKbrzMN0yfBgmHJBXmHgutXecepxNU6rR/WvBQwOpEipHB1L8RYc9ZuIw; 4:ZkxR94yds9GLfVdG/OuW4vSgwqu5/Vpv4FA5JROp4w5i5AVe6QGo80CBW/pSg8J/f1wYWFAmjwCMHitGQF79uAoXXO0jbRwXghXx0/1sWjnJtlmXUC6Jy31BX3TGLs+Onu9aur99rana/Sl6OuCxM5v8WQ3/DgRxHnEfioRKApXHv3Mq7PYVj4EQcJM3cpXNkhpbkY/K6BTDLWqyFTFJxyRvP89Gk5rJ/8v/0cVlsnC15PE2klcf2Vzg81hlCmVHfTxoyTtoFKVoG0GhXmbP8KjrIgR7m2IRCYXxs0uYH+NBCh48r4E8qYGMbeScgt1X X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699016); SRVR:CY1PR0301MB1578; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB1578; X-Forefront-PRVS: 07778E4001 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39850400004)(346002)(366004)(136003)(396003)(376002)(199004)(189003)(23726003)(6116002)(3846002)(478600001)(230700001)(4326008)(47776003)(72206003)(956004)(476003)(11346002)(54906003)(316002)(53936002)(446003)(110136005)(50226002)(9686003)(8676002)(5660300001)(66066001)(81156014)(81166006)(105586002)(76176011)(186003)(16526019)(25786009)(2906002)(97736004)(7736002)(106356001)(8936002)(33896004)(55016002)(50466002)(26005)(68736007)(6506007)(305945005)(86362001)(1076002)(7696005)(52116002)(486006)(386003)(14444005)(39210200001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1578; H:xhacker.debian; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: synaptics.com does not design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8gOSE/tnGiEMCMGMGAyE/NlzSGdqLBDVSytkzMqfamvHxvGE1C9jVRu2oiaePSYS7Ixr6GyyLzSe9Xx+g==; 5:SN47ULbc2d880ukblMv3IhNjYplQZo3jKil4qFivHcN0Qg2AzgfdVe4xhmJdXwXyCUNQ+Rb6KNWNnbzHTx1XqpBZC+geifnZk8+hlgM1zq6dpfHoIVE530xO3j0HbzdmmohuYaLUvC0P7BmYYWXAwg3bu+PljMHCE7JuRDhz96o=; 7:PErXM+V6OpBaC8lAcg1vWH3tE6DO7228aSCH+IsIyPLXkB8W4GQmbvquksKhu8uCTGA+CLvsZtZNcr8bBhAIPB0qlG/LUMLPutxYbRqkEjQLFR1bj5DHDFOKOguQ+5EGLbp0Y+W+FyT9unC9My3BMI3Ica30C1iz1+B+6MTxBd/XtZy4+rRYStxIw2mNNdD/E74srG5ak60n2CWLbp7sS0t2YvLqODBvTzJKgsFyz1rU2mjUX3nYuk/fztkNP9h8 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: synaptics.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Aug 2018 08:25:41.0273 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1fddc7e4-caf1-4060-19c4-08d60bf6adc6 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 335d1fbc-2124-4173-9863-17e7051a2a0e X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1578 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180827_012556_200356_0DE87269 X-CRM114-Status: GOOD ( 10.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add this hook so that it can be overridden with driver specific implementations. We also let the original sdhci_adma_write_desc() accept &desc so that the function can set its new value. Then export the function so that it could be reused by driver's specific implementations. Signed-off-by: Jisheng Zhang Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci.c | 37 +++++++++++++++++++++++-------------- drivers/mmc/host/sdhci.h | 4 ++++ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 52ccf4644384..eb21d2db7f05 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -554,10 +554,10 @@ static void sdhci_kunmap_atomic(void *buffer, unsigned long *flags) local_irq_restore(*flags); } -static void sdhci_adma_write_desc(struct sdhci_host *host, void *desc, - dma_addr_t addr, int len, unsigned cmd) +void sdhci_adma_write_desc(struct sdhci_host *host, void **desc, + dma_addr_t addr, int len, unsigned int cmd) { - struct sdhci_adma2_64_desc *dma_desc = desc; + struct sdhci_adma2_64_desc *dma_desc = *desc; /* 32-bit and 64-bit descriptors have these members in same position */ dma_desc->cmd = cpu_to_le16(cmd); @@ -566,6 +566,19 @@ static void sdhci_adma_write_desc(struct sdhci_host *host, void *desc, if (host->flags & SDHCI_USE_64_BIT_DMA) dma_desc->addr_hi = cpu_to_le32((u64)addr >> 32); + + *desc += host->desc_sz; +} +EXPORT_SYMBOL_GPL(sdhci_adma_write_desc); + +static inline void __sdhci_adma_write_desc(struct sdhci_host *host, + void **desc, dma_addr_t addr, + int len, unsigned int cmd) +{ + if (host->ops->adma_write_desc) + host->ops->adma_write_desc(host, desc, addr, len, cmd); + + sdhci_adma_write_desc(host, desc, addr, len, cmd); } static void sdhci_adma_mark_end(void *desc) @@ -618,28 +631,24 @@ static void sdhci_adma_table_pre(struct sdhci_host *host, } /* tran, valid */ - sdhci_adma_write_desc(host, desc, align_addr, offset, - ADMA2_TRAN_VALID); + __sdhci_adma_write_desc(host, &desc, align_addr, + offset, ADMA2_TRAN_VALID); BUG_ON(offset > 65536); align += SDHCI_ADMA2_ALIGN; align_addr += SDHCI_ADMA2_ALIGN; - desc += host->desc_sz; - addr += offset; len -= offset; } BUG_ON(len > 65536); - if (len) { - /* tran, valid */ - sdhci_adma_write_desc(host, desc, addr, len, - ADMA2_TRAN_VALID); - desc += host->desc_sz; - } + /* tran, valid */ + if (len) + __sdhci_adma_write_desc(host, &desc, addr, len, + ADMA2_TRAN_VALID); /* * If this triggers then we have a calculation bug @@ -656,7 +665,7 @@ static void sdhci_adma_table_pre(struct sdhci_host *host, } } else { /* Add a terminating entry - nop, end, valid */ - sdhci_adma_write_desc(host, desc, 0, 0, ADMA2_NOP_END_VALID); + __sdhci_adma_write_desc(host, &desc, 0, 0, ADMA2_NOP_END_VALID); } } diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 25bddd21de31..2115416f973a 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -606,6 +606,8 @@ struct sdhci_ops { void (*adma_workaround)(struct sdhci_host *host, u32 intmask); void (*card_event)(struct sdhci_host *host); void (*voltage_switch)(struct sdhci_host *host); + void (*adma_write_desc)(struct sdhci_host *host, void **desc, + dma_addr_t addr, int len, unsigned int cmd); }; #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS @@ -736,6 +738,8 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios); int sdhci_start_signal_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios); void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable); +void sdhci_adma_write_desc(struct sdhci_host *host, void **desc, + dma_addr_t addr, int len, unsigned int cmd); #ifdef CONFIG_PM int sdhci_suspend_host(struct sdhci_host *host);