From patchwork Tue Feb 12 07:25:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10807419 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 2925214E1 for ; Tue, 12 Feb 2019 07:25:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02B142915C for ; Tue, 12 Feb 2019 07:25:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E84D52A3CA; Tue, 12 Feb 2019 07:25:39 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 7AEAA2915C for ; Tue, 12 Feb 2019 07:25:39 +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:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=46h17l3MuyYGD+SO/v9Te+uPPHFqxBzhXM9Kz28bYhI=; b=Dvzp4DbXVsdZd6 dxbUThlLhasd6eOtLkQ4MghzL3p+w3lCwK3z3kCPXN/L0GObMi4d1wAozza7AA5tE4PHKSUexfx3H iM8aPSFDfAP4PA1G18TUrZp4O912W9qDRBCwNfI/JXLQlG1DrsdDi7vJFikt11wx1DwEMqgRpqhmz eIWbCWNIHerRScEZs55I0S45XXo2vLwAsYuHkUOW5uf37RpLsRggd2aSXAB6b9313o9WW/5GvH8lm 7byUaVtNYPuViLm5i+F3aoN24kFpKKH78RIicQ5oPvPUAizwBo8gneZdMcE2cdiceDyu1vV1nsp3T XPceLLRwJuGOJzY/IjCw==; 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 1gtSRk-0002OV-8b; Tue, 12 Feb 2019 07:25:36 +0000 Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtSRh-0002OC-IA; Tue, 12 Feb 2019 07:25:33 +0000 From: Christoph Hellwig To: Ulf Hansson Subject: [PATCH 01/14] scatterlist: add sg_kmap_atomic / sg_kunmap_atomic helpers Date: Tue, 12 Feb 2019 08:25:15 +0100 Message-Id: <20190212072528.13167-2-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212072528.13167-1-hch@lst.de> References: <20190212072528.13167-1-hch@lst.de> MIME-Version: 1.0 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: Aaro Koskinen , Nicolas Pitre , linux-mmc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Ben Dooks , linux-omap@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 avoids bug prone open coding of the sg offset handling and also helps to document the limitations of mapping scatterlist entries. Signed-off-by: Christoph Hellwig --- include/linux/scatterlist.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index b96f0d0b5b8f..524cd8448a48 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -2,6 +2,7 @@ #ifndef _LINUX_SCATTERLIST_H #define _LINUX_SCATTERLIST_H +#include #include #include #include @@ -239,6 +240,31 @@ static inline void *sg_virt(struct scatterlist *sg) return page_address(sg_page(sg)) + sg->offset; } +/** + * sg_kmap_atomic - map a S/G list entry to a kernel address + * @sg: scatterlist entry + * + * Return a kernel address for scatterlist entry by kmapping it. Note that + * this function must only be called on scatterlist entries that do not span + * multiple pages. + */ +static inline void *sg_kmap_atomic(struct scatterlist *sg) +{ + if (WARN_ON_ONCE(sg->offset + sg->length > PAGE_SIZE)) + return NULL; + return kmap_atomic(sg_page(sg)) + sg->offset; +} + +/** + * sg_kunmap_atomic - unmap a S/G list entry to a kernel address + * @sg: scatterlist entry + * @ptr: address returned from sg_kmap_atomic + */ +static inline void sg_kunmap_atomic(struct scatterlist *sg, void *ptr) +{ + kunmap_atomic(ptr - sg->offset); +} + /** * sg_init_marker - Initialize markers in sg table * @sgl: The SG table From patchwork Tue Feb 12 07:25:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10807483 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 6496913A4 for ; Tue, 12 Feb 2019 07:27:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 498342915C for ; Tue, 12 Feb 2019 07:27:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D59E2A3D3; Tue, 12 Feb 2019 07:27: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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 EF2A82915C for ; Tue, 12 Feb 2019 07:27:11 +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:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ShB00Q9XqlFjzdt7N17YZDGrvV62q+3KN5eLEZas3Us=; b=Jf+KNFFL3FBOI2 IpX3rCrFww1iLQ47o5eBVAX1HgmaR5LYfEz+rmUtZlCYbjT7DvGn4WRkFPF80PwfjN3qlDjE6668H sXhyDmtcZhslgIyYZ+MKtuQPBLnc7gxdwaqA5nfuE88DXqUbq2Wd02YHPmwVUyt58zGwKLof8PCS/ Nz09qWQY2GqjfQ/XwlVqP66UsYhWdJPW0dW7yXB65B5cc0flP62+wjcPWbRtP96QKOn9LPrOiH5yh sF63sK51hPNZ+93k1EEt4IDY4bi1sZYpktkuz3iNJ8BOBTIicGreNRVh5H0WWVz25aGT00l8qwHPx mE66JpjPJgn2w9xhXqOw==; 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 1gtSTA-0003sS-52; Tue, 12 Feb 2019 07:27:04 +0000 Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtSRj-0002OR-VH; Tue, 12 Feb 2019 07:25:36 +0000 From: Christoph Hellwig To: Ulf Hansson Subject: [PATCH 02/14] mmc: remove the unused use_blk_mq field from struct mmc_host Date: Tue, 12 Feb 2019 08:25:16 +0100 Message-Id: <20190212072528.13167-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212072528.13167-1-hch@lst.de> References: <20190212072528.13167-1-hch@lst.de> MIME-Version: 1.0 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: Aaro Koskinen , Nicolas Pitre , linux-mmc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Ben Dooks , linux-omap@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 Signed-off-by: Christoph Hellwig --- include/linux/mmc/host.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 4d35ff36ceff..4eadf01b4a93 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -397,7 +397,6 @@ struct mmc_host { unsigned int doing_retune:1; /* re-tuning in progress */ unsigned int retune_now:1; /* do re-tuning at next req */ unsigned int retune_paused:1; /* re-tuning is temporarily disabled */ - unsigned int use_blk_mq:1; /* use blk-mq */ int rescan_disable; /* disable card detection */ int rescan_entered; /* used with nonremovable devices */ From patchwork Tue Feb 12 07:25:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10807429 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 A491414E1 for ; Tue, 12 Feb 2019 07:26:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89C4D2915C for ; Tue, 12 Feb 2019 07:26:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D48D2A3CA; Tue, 12 Feb 2019 07:26:14 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 2CC292915C for ; Tue, 12 Feb 2019 07:26:14 +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:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=h2v1N9mU1RwRTY1eByLo8vfCXpGzzoZpMFPMYVo49CY=; b=mdJd0Te3op66Z3 OG76j2KgOZ37+DCJ4M22YXMNR/XaouYSJEPtdpMTSpzY+mZnQ7nMM+6mUtmUNdVynX2fQQvdCe+mT Aa9zQBxQmzxJyA+pnHEpweGBBB2PIIAmDif0qA1vEHv90C8/N8s43RmXvq79PkbEYeMPlOwuVyv9g 1A3Q1wwyYdurIta1P1WSXbcKugEt+VhPFRT4xX9Z9ywu8oVSdc8A8qVBeG6c/UWVt8iodia/1Ht44 8d8bQNgKnZcyA8S8NUY13ce43KXTvg7+BTTQDXFZSgG5Ho3eSW/YsGuodW8vd8RIisA2Ntn65gHkJ qITVqkA29GQsLMpHZ1iw==; 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 1gtSSI-0002y1-FB; Tue, 12 Feb 2019 07:26:10 +0000 Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtSRm-0002P6-HK; Tue, 12 Feb 2019 07:25:38 +0000 From: Christoph Hellwig To: Ulf Hansson Subject: [PATCH 03/14] mmc: add a need_kmap flag to struct mmc_host Date: Tue, 12 Feb 2019 08:25:17 +0100 Message-Id: <20190212072528.13167-4-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212072528.13167-1-hch@lst.de> References: <20190212072528.13167-1-hch@lst.de> MIME-Version: 1.0 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: Aaro Koskinen , Nicolas Pitre , linux-mmc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Ben Dooks , linux-omap@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 If we want to get rid of the block layer bounce buffering for highmem we need to ensure no segment spans multiple pages so that we can kmap it. Add a flag to struct mmc_host so that we can handle the block and DMA layer interactions in common code. Signed-off-by: Christoph Hellwig --- drivers/mmc/core/queue.c | 13 +++++++++++++ include/linux/mmc/host.h | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c index 35cc138b096d..71cd2411329e 100644 --- a/drivers/mmc/core/queue.c +++ b/drivers/mmc/core/queue.c @@ -370,6 +370,19 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card) blk_queue_max_segments(mq->queue, host->max_segs); blk_queue_max_segment_size(mq->queue, host->max_seg_size); + /* + * If the host requires kmapping for PIO we need to ensure + * that no segment spans a page boundary. + */ + if (host->need_kmap) { + unsigned int dma_boundary = host->max_seg_size - 1; + + if (dma_boundary >= PAGE_SIZE) + dma_boundary = PAGE_SIZE - 1; + blk_queue_segment_boundary(mq->queue, dma_boundary); + dma_set_seg_boundary(mmc_dev(host), dma_boundary); + } + INIT_WORK(&mq->recovery_work, mmc_mq_recovery_handler); INIT_WORK(&mq->complete_work, mmc_blk_mq_complete_work); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 4eadf01b4a93..87f8a89d2f70 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -397,6 +397,7 @@ struct mmc_host { unsigned int doing_retune:1; /* re-tuning in progress */ unsigned int retune_now:1; /* do re-tuning at next req */ unsigned int retune_paused:1; /* re-tuning is temporarily disabled */ + unsigned int need_kmap:1; /* only allow single page segments */ int rescan_disable; /* disable card detection */ int rescan_entered; /* used with nonremovable devices */ From patchwork Tue Feb 12 07:25:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10807435 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 924A814E1 for ; Tue, 12 Feb 2019 07:26:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 776BF2915C for ; Tue, 12 Feb 2019 07:26:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6865F2A3CA; Tue, 12 Feb 2019 07:26: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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 142CA2915C for ; Tue, 12 Feb 2019 07:26: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:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YX1Rgr+q6tXNOZr+FyE6I7mhULmcXtz4ms/X+etCru4=; b=RjHv1DVw7eypdF u855HWEmvm4N0ok5kDqPD6RRQ478CdfxfhV9Mx9bVP13Rgm1AvV+5xrWLPGLj+BI8bwLH3bhYyRGX NQ36HyRhUhXYpQSIqtIFzM6EBODPLfS4Msj49pcFSIfLnQIsCCXFL67PVGPV/37mvAjy9UatqzgtF smvmcQCN+Uwc8PHi5AnXNsG1eslUm81Ptl3cRP/CTwWtBNorC8v3CJ1CHCbVL5mD0bmu2WaHzRo3g 3roBJXgwzyelrRcvazWinXTh9zoe0jdwo0TXkL46NIOIJGQT6G3rTst9C/2HyVYt4dJ6+3raVmfqW KUc1eUEatHierQz3BEZg==; 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 1gtSSU-0003Ak-ST; Tue, 12 Feb 2019 07:26:22 +0000 Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtSRp-0002RZ-8Y; Tue, 12 Feb 2019 07:25:41 +0000 From: Christoph Hellwig To: Ulf Hansson Subject: [PATCH 04/14] mmc: davinci: handle highmem pages Date: Tue, 12 Feb 2019 08:25:18 +0100 Message-Id: <20190212072528.13167-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212072528.13167-1-hch@lst.de> References: <20190212072528.13167-1-hch@lst.de> MIME-Version: 1.0 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: Aaro Koskinen , Nicolas Pitre , linux-mmc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Ben Dooks , linux-omap@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 Instead of setting up a kernel pointer to track the current PIO address, track the offset in the current page, and do an atomic kmap for the page while doing the actual PIO operations. Signed-off-by: Christoph Hellwig --- drivers/mmc/host/davinci_mmc.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c index 9e68c3645e22..6a16d7a1d5bc 100644 --- a/drivers/mmc/host/davinci_mmc.c +++ b/drivers/mmc/host/davinci_mmc.c @@ -194,11 +194,12 @@ struct mmc_davinci_host { #define DAVINCI_MMC_DATADIR_WRITE 2 unsigned char data_dir; - /* buffer is used during PIO of one scatterlist segment, and - * is updated along with buffer_bytes_left. bytes_left applies - * to all N blocks of the PIO transfer. + /* + * buffer_offset is used during PIO of one scatterlist segment, and is + * updated along with buffer_bytes_left. bytes_left applies to all N + * blocks of the PIO transfer. */ - u8 *buffer; + u32 buffer_offset; u32 buffer_bytes_left; u32 bytes_left; @@ -229,8 +230,8 @@ static irqreturn_t mmc_davinci_irq(int irq, void *dev_id); /* PIO only */ static void mmc_davinci_sg_to_buf(struct mmc_davinci_host *host) { + host->buffer_offset = host->sg->offset; host->buffer_bytes_left = sg_dma_len(host->sg); - host->buffer = sg_virt(host->sg); if (host->buffer_bytes_left > host->bytes_left) host->buffer_bytes_left = host->bytes_left; } @@ -238,7 +239,7 @@ static void mmc_davinci_sg_to_buf(struct mmc_davinci_host *host) static void davinci_fifo_data_trans(struct mmc_davinci_host *host, unsigned int n) { - u8 *p; + u8 *p, *base; unsigned int i; if (host->buffer_bytes_left == 0) { @@ -246,7 +247,8 @@ static void davinci_fifo_data_trans(struct mmc_davinci_host *host, mmc_davinci_sg_to_buf(host); } - p = host->buffer; + base = sg_kmap_atomic(host->sg); + p = base + host->buffer_offset; if (n > host->buffer_bytes_left) n = host->buffer_bytes_left; host->buffer_bytes_left -= n; @@ -275,7 +277,8 @@ static void davinci_fifo_data_trans(struct mmc_davinci_host *host, p = p + (n & 3); } } - host->buffer = p; + host->buffer_offset = p - base; + sg_kunmap_atomic(host->sg, base); } static void mmc_davinci_start_command(struct mmc_davinci_host *host, @@ -572,7 +575,7 @@ mmc_davinci_prepare_data(struct mmc_davinci_host *host, struct mmc_request *req) host->base + DAVINCI_MMCFIFOCTL); } - host->buffer = NULL; + host->buffer_offset = 0; host->bytes_left = data->blocks * data->blksz; /* For now we try to use DMA whenever we won't need partial FIFO @@ -1291,6 +1294,7 @@ static int davinci_mmcsd_probe(struct platform_device *pdev) mmc->ops = &mmc_davinci_ops; mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; + mmc->need_kmap = 1; /* With no iommu coalescing pages, each phys_seg is a hw_seg. * Each hw_seg uses one EDMA parameter RAM slot, always one From patchwork Tue Feb 12 07:25:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10807447 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 611FC13A4 for ; Tue, 12 Feb 2019 07:26:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44DF32915C for ; Tue, 12 Feb 2019 07:26:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 371862A3CA; Tue, 12 Feb 2019 07:26:39 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 CEBEE2915C for ; Tue, 12 Feb 2019 07:26: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:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hi3vs9aSZbbYVpTVI1sCgZU5wVUh/fE9Gyi7CT3BisY=; b=g7KEwFLkjXlzkM QTQ2Mc3XYva7HizgLL58zWlI5JcuI4j+OFNk9jZdg+EcUwINZ1VemlrekiRln+8kq6ky+dZHdly31 +KzAd+P7nBVM5gHRgrsx+0DSWQCFzKM4xC70BD8JaJUEjgvEpGiGq+REHFMDd6WorD25czcawY1IV Qn5bkEySuk4TuzK+GxGcVRRnARwo/bT3ZjkAIQBteF+C7QUKSb6fCFWVFmo9NZLDoeCsgdyIE6vNQ hutE3G749dfnXkIAx6DF7aqwDdqf5SW+o4cqwSv94KRfNSzqQpccMyFcx57KLF3OfSFWov0FA5klC 4dF8V9BfHbmyPQxWAfWQ==; 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 1gtSSi-0003Rl-7m; Tue, 12 Feb 2019 07:26:36 +0000 Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtSRr-0002US-VE; Tue, 12 Feb 2019 07:25:44 +0000 From: Christoph Hellwig To: Ulf Hansson Subject: [PATCH 05/14] mmc: moxart: handle highmem pages Date: Tue, 12 Feb 2019 08:25:19 +0100 Message-Id: <20190212072528.13167-6-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212072528.13167-1-hch@lst.de> References: <20190212072528.13167-1-hch@lst.de> MIME-Version: 1.0 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: Aaro Koskinen , Nicolas Pitre , linux-mmc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Ben Dooks , linux-omap@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 Instead of setting up a kernel pointer to track the current PIO address, track the offset in the current page, and do a kmap for the page while doing the actual PIO operations. Signed-off-by: Christoph Hellwig --- drivers/mmc/host/moxart-mmc.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c index a0670e9cd012..116964e6506d 100644 --- a/drivers/mmc/host/moxart-mmc.c +++ b/drivers/mmc/host/moxart-mmc.c @@ -311,7 +311,7 @@ static void moxart_transfer_pio(struct moxart_host *host) if (host->data_len == data->bytes_xfered) return; - sgp = sg_virt(host->cur_sg); + sgp = kmap(sg_page(host->cur_sg)) + host->cur_sg->offset; remain = host->data_remain; if (data->flags & MMC_DATA_WRITE) { @@ -319,8 +319,7 @@ static void moxart_transfer_pio(struct moxart_host *host) if (moxart_wait_for_status(host, FIFO_URUN, &status) == -ETIMEDOUT) { data->error = -ETIMEDOUT; - complete(&host->pio_complete); - return; + goto done; } for (len = 0; len < remain && len < host->fifo_width;) { iowrite32(*sgp, host->base + REG_DATA_WINDOW); @@ -335,8 +334,7 @@ static void moxart_transfer_pio(struct moxart_host *host) if (moxart_wait_for_status(host, FIFO_ORUN, &status) == -ETIMEDOUT) { data->error = -ETIMEDOUT; - complete(&host->pio_complete); - return; + goto done; } for (len = 0; len < remain && len < host->fifo_width;) { /* SCR data must be read in big endian. */ @@ -356,10 +354,15 @@ static void moxart_transfer_pio(struct moxart_host *host) data->bytes_xfered += host->data_remain - remain; host->data_remain = remain; - if (host->data_len != data->bytes_xfered) + if (host->data_len != data->bytes_xfered) { + kunmap(sg_page(host->cur_sg)); moxart_next_sg(host); - else - complete(&host->pio_complete); + return; + } + +done: + kunmap(sg_page(host->cur_sg)); + complete(&host->pio_complete); } static void moxart_prepare_data(struct moxart_host *host) @@ -614,6 +617,7 @@ static int moxart_probe(struct platform_device *pdev) spin_lock_init(&host->lock); mmc->ops = &moxart_ops; + mmc->need_kmap = 1; mmc->f_max = DIV_ROUND_CLOSEST(host->sysclk, 2); mmc->f_min = DIV_ROUND_CLOSEST(host->sysclk, CLK_DIV_MASK * 2); mmc->ocr_avail = 0xffff00; /* Support 2.0v - 3.6v power. */ From patchwork Tue Feb 12 07:25:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10807485 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 5EB2113A4 for ; Tue, 12 Feb 2019 07:27:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 461512A4EB for ; Tue, 12 Feb 2019 07:27:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39D6E2A65B; Tue, 12 Feb 2019 07:27:21 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 E85EF2A4EB for ; Tue, 12 Feb 2019 07:27:20 +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:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=h38AlOTBcv2KFvA+E4OPaUL8Q5WetanaRSq0+Uqekyw=; b=lYN6ih8PLduQ47 oVwm1Yeuhhpe1vK1GJqv+pYqQaK3bPhTUiCXLp9UMDmOGxaTYe7VWinATJr2UW3Wf2WFq+yTC2QZp hBL66Fb8wgEPqHi4yUtSaT235NMDK6xWSKTDQRWPXG8lO9JV72NgdOTq0ZeOClcHlJfoR14meXy8p BSCXbXCcOONvMQ4uRY73y3M4NIgjC+usfTHqbe6CvqyriFcIsGAST016ubkCs9zp8+R4PF2YRD/CB SKWaaNObVy3CLWg0wKXUdwMRPf3FgNonNafRWaIcGtqs7cn96Q7E+EtG4n+Zmiyh6m+KDHUT3Kzm2 rQLCAJFhhMAaxNF51iAw==; 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 1gtSTP-00045g-AM; Tue, 12 Feb 2019 07:27:19 +0000 Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtSRu-0002XO-Kx; Tue, 12 Feb 2019 07:25:47 +0000 From: Christoph Hellwig To: Ulf Hansson Subject: [PATCH 06/14] mmc: omap: handle highmem pages Date: Tue, 12 Feb 2019 08:25:20 +0100 Message-Id: <20190212072528.13167-7-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212072528.13167-1-hch@lst.de> References: <20190212072528.13167-1-hch@lst.de> MIME-Version: 1.0 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: Aaro Koskinen , Nicolas Pitre , linux-mmc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Ben Dooks , linux-omap@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 Instead of setting up a kernel pointer to track the current PIO address, track the offset in the current page, and do an atomic kmap for the page while doing the actual PIO operations. Signed-off-by: Christoph Hellwig --- drivers/mmc/host/omap.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c index c60a7625b1fa..6741c95f2281 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c @@ -148,7 +148,7 @@ struct mmc_omap_host { unsigned int sg_len; int sg_idx; - u16 * buffer; + u32 buffer_offset; u32 buffer_bytes_left; u32 total_bytes_left; @@ -649,7 +649,7 @@ mmc_omap_sg_to_buf(struct mmc_omap_host *host) sg = host->data->sg + host->sg_idx; host->buffer_bytes_left = sg->length; - host->buffer = sg_virt(sg); + host->buffer_offset = sg->offset; if (host->buffer_bytes_left > host->total_bytes_left) host->buffer_bytes_left = host->total_bytes_left; } @@ -666,7 +666,9 @@ mmc_omap_clk_timer(struct timer_list *t) static void mmc_omap_xfer_data(struct mmc_omap_host *host, int write) { + struct scatterlist *sg = host->data->sg + host->sg_idx; int n, nwords; + void *p; if (host->buffer_bytes_left == 0) { host->sg_idx++; @@ -684,15 +686,17 @@ mmc_omap_xfer_data(struct mmc_omap_host *host, int write) host->total_bytes_left -= n; host->data->bytes_xfered += n; + p = sg_kmap_atomic(sg); if (write) { __raw_writesw(host->virt_base + OMAP_MMC_REG(host, DATA), - host->buffer, nwords); + p + host->buffer_offset, nwords); } else { __raw_readsw(host->virt_base + OMAP_MMC_REG(host, DATA), - host->buffer, nwords); + p + host->buffer_offset, nwords); } + sg_kunmap_atomic(sg, p); - host->buffer += nwords; + host->buffer_offset += nwords; } #ifdef CONFIG_MMC_DEBUG @@ -1250,6 +1254,7 @@ static int mmc_omap_new_slot(struct mmc_omap_host *host, int id) mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_ERASE; mmc->ops = &mmc_omap_ops; + mmc->need_kmap = 1; mmc->f_min = 400000; if (mmc_omap2()) From patchwork Tue Feb 12 07:25:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10807487 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 6443E13A4 for ; Tue, 12 Feb 2019 07:27:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A2C62A3D3 for ; Tue, 12 Feb 2019 07:27:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E8592A66E; Tue, 12 Feb 2019 07:27:45 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 1F1EB2A3D3 for ; Tue, 12 Feb 2019 07:27:43 +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:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=THZeMqkDXNRYpGN6cafB8xz8xCOBJhRqwy9u8kGv5Nw=; b=cu4CcNNuhFyX7e Qpu0iQccRH3EO1aTHUSvvE43tJTgooz86AKan+IL+VBiYAgPnkA9rfARbJny5qWx2L/nW3ZTKuRf4 ovQaEojUyLQq+7jYvgcnOcfvtkw8rOU+Mw4zePND2Murtn428tnXcObbW7lBMmdka5q3/h6buQlYr fbkk60YGkorlh6UhMa0SiUVCdpZK3reEpkCySN2sMesVyJwmz4LeszJV1Cx1bgIgTXR/PZoSGmywb Gg1L9Ft0ftO2VCyrDF7i7HyV1DBAk7WIW9AaIKbnANz2eDxkt7Inrn8SKsvQnwRqnCFeNtKTZDm56 CkSJ1IqE0lFLs4CMrJ/A==; 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 1gtSTe-0004Kx-Ei; Tue, 12 Feb 2019 07:27:34 +0000 Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtSRx-0002b4-DI; Tue, 12 Feb 2019 07:25:49 +0000 From: Christoph Hellwig To: Ulf Hansson Subject: [PATCH 07/14] mmc: omap: handle chained sglists Date: Tue, 12 Feb 2019 08:25:21 +0100 Message-Id: <20190212072528.13167-8-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212072528.13167-1-hch@lst.de> References: <20190212072528.13167-1-hch@lst.de> MIME-Version: 1.0 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: Aaro Koskinen , Nicolas Pitre , linux-mmc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Ben Dooks , linux-omap@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 Use the proper sg_next() helper to move to the next scatterlist element to support chained scatterlists. Signed-off-by: Christoph Hellwig --- drivers/mmc/host/omap.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c index 6741c95f2281..8cd39bc087fa 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c @@ -147,7 +147,7 @@ struct mmc_omap_host { struct mmc_data *stop_data; unsigned int sg_len; - int sg_idx; + struct scatterlist *cur_sg; u32 buffer_offset; u32 buffer_bytes_left; u32 total_bytes_left; @@ -645,11 +645,8 @@ mmc_omap_cmd_timer(struct timer_list *t) static void mmc_omap_sg_to_buf(struct mmc_omap_host *host) { - struct scatterlist *sg; - - sg = host->data->sg + host->sg_idx; - host->buffer_bytes_left = sg->length; - host->buffer_offset = sg->offset; + host->buffer_bytes_left = host->cur_sg->length; + host->buffer_offset = host->cur_sg->offset; if (host->buffer_bytes_left > host->total_bytes_left) host->buffer_bytes_left = host->total_bytes_left; } @@ -666,13 +663,12 @@ mmc_omap_clk_timer(struct timer_list *t) static void mmc_omap_xfer_data(struct mmc_omap_host *host, int write) { - struct scatterlist *sg = host->data->sg + host->sg_idx; + struct scatterlist *sg = host->cur_sg; int n, nwords; void *p; if (host->buffer_bytes_left == 0) { - host->sg_idx++; - BUG_ON(host->sg_idx == host->sg_len); + host->cur_sg = sg_next(host->cur_sg); mmc_omap_sg_to_buf(host); } n = 64; @@ -984,7 +980,7 @@ mmc_omap_prepare_data(struct mmc_omap_host *host, struct mmc_request *req) } } - host->sg_idx = 0; + host->cur_sg = host->data->sg; if (use_dma) { enum dma_data_direction dma_data_dir; struct dma_async_tx_descriptor *tx; From patchwork Tue Feb 12 07:25:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10807489 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 5BA2B14E1 for ; Tue, 12 Feb 2019 07:27:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 413602A66E for ; Tue, 12 Feb 2019 07:27:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34E2F2A6AA; Tue, 12 Feb 2019 07:27:57 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 A6C3A2A66E for ; Tue, 12 Feb 2019 07:27:56 +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:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sEuGaHytdyxa46G4syeUdMNLCHQjwecyLwvoGBTAYH0=; b=PDV+EifCDwbhh1 nsujTCGpDej4Uqihm2P0yxO0IN1205eCKMmb6PvlO090juu36OuwRxzJH6cAleqRTg9ypn/25UCGd 09x5D7WrlfXw2puIk4+TQ30z3Zph9mabdUXcpuCtdFfs9xIv/Ty4yoD1rbeczTATYNOnqNifcm/1w FYjJJN4CAM3oRro/sZlGfZBHYtNzvGui1z1wlZ1euqT3QMpnGKbcA3eswm8z0TcZDHD1hh6JgdSuC asjzRLFQ6CQYIO36YYIo7nRjdU/gZogvNvJ4sz3O/NgufPvyOSUJICwJ2A9ooBfhe2AfhAlH3lNVM 4xbKItKv6KLAx/u2tDYQ==; 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 1gtSTr-0004aR-6f; Tue, 12 Feb 2019 07:27:47 +0000 Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtSS0-0002eI-5Q; Tue, 12 Feb 2019 07:25:53 +0000 From: Christoph Hellwig To: Ulf Hansson Subject: [PATCH 08/14] mmc: s3cmci: handle highmem pages Date: Tue, 12 Feb 2019 08:25:22 +0100 Message-Id: <20190212072528.13167-9-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212072528.13167-1-hch@lst.de> References: <20190212072528.13167-1-hch@lst.de> MIME-Version: 1.0 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: Aaro Koskinen , Nicolas Pitre , linux-mmc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Ben Dooks , linux-omap@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 Instead of setting up a kernel pointer to track the current PIO address, track the offset in the current page, and do an atomic kmap for the page while doing the actual PIO operations. Signed-off-by: Christoph Hellwig --- drivers/mmc/host/s3cmci.c | 107 +++++++++++++++++++------------------- drivers/mmc/host/s3cmci.h | 3 +- 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c index 10f5219b3b40..989fefea19f1 100644 --- a/drivers/mmc/host/s3cmci.c +++ b/drivers/mmc/host/s3cmci.c @@ -317,26 +317,17 @@ static void s3cmci_check_sdio_irq(struct s3cmci_host *host) } } -static inline int get_data_buffer(struct s3cmci_host *host, - u32 *bytes, u32 **pointer) +static inline int get_data_buffer(struct s3cmci_host *host) { - struct scatterlist *sg; - - if (host->pio_active == XFER_NONE) - return -EINVAL; - - if ((!host->mrq) || (!host->mrq->data)) - return -EINVAL; - if (host->pio_sgptr >= host->mrq->data->sg_len) { dbg(host, dbg_debug, "no more buffers (%i/%i)\n", host->pio_sgptr, host->mrq->data->sg_len); return -EBUSY; } - sg = &host->mrq->data->sg[host->pio_sgptr]; + host->cur_sg = &host->mrq->data->sg[host->pio_sgptr]; - *bytes = sg->length; - *pointer = sg_virt(sg); + host->pio_bytes = host->cur_sg->length; + host->pio_offset = host->cur_sg->offset; host->pio_sgptr++; @@ -422,11 +413,16 @@ static void s3cmci_disable_irq(struct s3cmci_host *host, bool transfer) static void do_pio_read(struct s3cmci_host *host) { - int res; u32 fifo; u32 *ptr; u32 fifo_words; void __iomem *from_ptr; + void *buf; + + if (host->pio_active == XFER_NONE) + goto done; + if (!host->mrq || !host->mrq->data) + goto done; /* write real prescaler to host, it might be set slow to fix */ writel(host->prescaler, host->base + S3C2410_SDIPRE); @@ -435,20 +431,12 @@ static void do_pio_read(struct s3cmci_host *host) while ((fifo = fifo_count(host))) { if (!host->pio_bytes) { - res = get_data_buffer(host, &host->pio_bytes, - &host->pio_ptr); - if (res) { - host->pio_active = XFER_NONE; - host->complete_what = COMPLETION_FINALIZE; - - dbg(host, dbg_pio, "pio_read(): " - "complete (no more data).\n"); - return; - } + if (get_data_buffer(host) < 0) + goto done; dbg(host, dbg_pio, - "pio_read(): new target: [%i]@[%p]\n", - host->pio_bytes, host->pio_ptr); + "pio_read(): new target: [%i]@[%zu]\n", + host->pio_bytes, host->pio_offset); } dbg(host, dbg_pio, @@ -470,63 +458,65 @@ static void do_pio_read(struct s3cmci_host *host) host->pio_count += fifo; fifo_words = fifo >> 2; - ptr = host->pio_ptr; - while (fifo_words--) + + buf = (sg_kmap_atomic(host->cur_sg) + host->pio_offset); + ptr = buf; + while (fifo_words--) { *ptr++ = readl(from_ptr); - host->pio_ptr = ptr; + host->pio_offset += 4; + } if (fifo & 3) { u32 n = fifo & 3; u32 data = readl(from_ptr); - u8 *p = (u8 *)host->pio_ptr; + u8 *p = (u8 *)ptr; while (n--) { *p++ = data; data >>= 8; + host->pio_offset++; } } + sg_kunmap_atomic(host->cur_sg, buf); } if (!host->pio_bytes) { - res = get_data_buffer(host, &host->pio_bytes, &host->pio_ptr); - if (res) { - dbg(host, dbg_pio, - "pio_read(): complete (no more buffers).\n"); - host->pio_active = XFER_NONE; - host->complete_what = COMPLETION_FINALIZE; - - return; - } + if (get_data_buffer(host) < 0) + goto done; } enable_imask(host, S3C2410_SDIIMSK_RXFIFOHALF | S3C2410_SDIIMSK_RXFIFOLAST); + return; + +done: + host->pio_active = XFER_NONE; + host->complete_what = COMPLETION_FINALIZE; + dbg(host, dbg_pio, "pio_read(): complete (no more data).\n"); } static void do_pio_write(struct s3cmci_host *host) { void __iomem *to_ptr; - int res; + void *buf; u32 fifo; u32 *ptr; + if (host->pio_active == XFER_NONE) + goto done; + if (!host->mrq || !host->mrq->data) + goto done; + to_ptr = host->base + host->sdidata; while ((fifo = fifo_free(host)) > 3) { if (!host->pio_bytes) { - res = get_data_buffer(host, &host->pio_bytes, - &host->pio_ptr); - if (res) { - dbg(host, dbg_pio, - "pio_write(): complete (no more data).\n"); - host->pio_active = XFER_NONE; - - return; - } + if (get_data_buffer(host) < 0) + goto done; dbg(host, dbg_pio, - "pio_write(): new source: [%i]@[%p]\n", - host->pio_bytes, host->pio_ptr); + "pio_write(): new source: [%i]@[%zd]\n", + host->pio_bytes, host->pio_offset); } @@ -543,13 +533,20 @@ static void do_pio_write(struct s3cmci_host *host) host->pio_count += fifo; fifo = (fifo + 3) >> 2; - ptr = host->pio_ptr; - while (fifo--) + buf = (sg_kmap_atomic(host->cur_sg) + host->pio_offset); + ptr = buf; + while (fifo--) { writel(*ptr++, to_ptr); - host->pio_ptr = ptr; + host->pio_offset += 4; + } + sg_kunmap_atomic(host->cur_sg, buf); } enable_imask(host, S3C2410_SDIIMSK_TXFIFOHALF); + return; +done: + dbg(host, dbg_pio, "pio_write(): complete (no more data).\n"); + host->pio_active = XFER_NONE; } static void pio_tasklet(unsigned long data) @@ -1055,6 +1052,7 @@ static int s3cmci_prepare_pio(struct s3cmci_host *host, struct mmc_data *data) BUG_ON((data->flags & BOTH_DIR) == BOTH_DIR); host->pio_sgptr = 0; + host->cur_sg = &host->mrq->data->sg[host->pio_sgptr]; host->pio_bytes = 0; host->pio_count = 0; host->pio_active = rw ? XFER_WRITE : XFER_READ; @@ -1678,6 +1676,7 @@ static int s3cmci_probe(struct platform_device *pdev) host->clk_rate = clk_get_rate(host->clk); mmc->ops = &s3cmci_ops; + mmc->need_kmap = 1; mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; #ifdef CONFIG_MMC_S3C_HW_SDIO_IRQ mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ; diff --git a/drivers/mmc/host/s3cmci.h b/drivers/mmc/host/s3cmci.h index 30c2c0dd1bc8..4320f7d832dc 100644 --- a/drivers/mmc/host/s3cmci.h +++ b/drivers/mmc/host/s3cmci.h @@ -50,10 +50,11 @@ struct s3cmci_host { int dma_complete; + struct scatterlist *cur_sg; u32 pio_sgptr; u32 pio_bytes; u32 pio_count; - u32 *pio_ptr; + u32 pio_offset; #define XFER_NONE 0 #define XFER_READ 1 #define XFER_WRITE 2 From patchwork Tue Feb 12 07:25:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10807491 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 7550114E1 for ; Tue, 12 Feb 2019 07:28:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 599BC2A69E for ; Tue, 12 Feb 2019 07:28:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35EFA2A6AB; Tue, 12 Feb 2019 07:28:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 BF0712A69E for ; Tue, 12 Feb 2019 07:28:05 +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:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=21uxw8wzoS0IpgwF/L2aD2cCRN2EJ7zj9wcQMZ8yRGA=; b=nFIRdZx9LUQu4D P41ES5+irSREvDjO3p2niCYJgNUfCpR7v9rD+TwIRTxEcNtuaHLhm1+O6371zWgCn6r2p/H3pDmLh CEp5tb+aJ0kHz5dE9uSWRI08U1FzKoGdQD6QzHAQc5yRJ77HiFy0lhqJnE4I71j4bxJYf3qVPYDda q7Q2lwOK95q3gEMz9S+ionZk3oZiHGa4gNwXpt9VJPVFOcKluqog5dmbIKENlX5pMDvpd24fPYPcS khm/cqXnqt+xMzyyxjhuuql0pPwqdVKVYxpgX13THhisEJ529qK+585bpdZmUmcFru2Mc4QPvccfr cUiaDWcyBk1lhdz9R9Qw==; 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 1gtSU5-0004qa-2g; Tue, 12 Feb 2019 07:28:01 +0000 Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtSS3-0002iH-Gu; Tue, 12 Feb 2019 07:25:55 +0000 From: Christoph Hellwig To: Ulf Hansson Subject: [PATCH 09/14] mmc: s3cmci: handle chained sglists Date: Tue, 12 Feb 2019 08:25:23 +0100 Message-Id: <20190212072528.13167-10-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212072528.13167-1-hch@lst.de> References: <20190212072528.13167-1-hch@lst.de> MIME-Version: 1.0 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: Aaro Koskinen , Nicolas Pitre , linux-mmc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Ben Dooks , linux-omap@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 Use the proper sg_next() helper to move to the next scatterlist element to support chained scatterlists. Signed-off-by: Christoph Hellwig --- drivers/mmc/host/s3cmci.c | 19 +++++++++---------- drivers/mmc/host/s3cmci.h | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c index 989fefea19f1..df7c27f78abf 100644 --- a/drivers/mmc/host/s3cmci.c +++ b/drivers/mmc/host/s3cmci.c @@ -319,20 +319,19 @@ static void s3cmci_check_sdio_irq(struct s3cmci_host *host) static inline int get_data_buffer(struct s3cmci_host *host) { - if (host->pio_sgptr >= host->mrq->data->sg_len) { - dbg(host, dbg_debug, "no more buffers (%i/%i)\n", - host->pio_sgptr, host->mrq->data->sg_len); + if (!host->next_sg) { + dbg(host, dbg_debug, "no more buffers (%i)\n", + host->mrq->data->sg_len); return -EBUSY; } - host->cur_sg = &host->mrq->data->sg[host->pio_sgptr]; + host->cur_sg = host->next_sg; + host->next_sg = sg_next(host->next_sg); host->pio_bytes = host->cur_sg->length; host->pio_offset = host->cur_sg->offset; - host->pio_sgptr++; - - dbg(host, dbg_sg, "new buffer (%i/%i)\n", - host->pio_sgptr, host->mrq->data->sg_len); + dbg(host, dbg_sg, "new buffer (%i)\n", + host->mrq->data->sg_len); return 0; } @@ -1051,8 +1050,8 @@ static int s3cmci_prepare_pio(struct s3cmci_host *host, struct mmc_data *data) BUG_ON((data->flags & BOTH_DIR) == BOTH_DIR); - host->pio_sgptr = 0; - host->cur_sg = &host->mrq->data->sg[host->pio_sgptr]; + host->cur_sg = host->mrq->data->sg; + host->next_sg = sg_next(host->cur_sg); host->pio_bytes = 0; host->pio_count = 0; host->pio_active = rw ? XFER_WRITE : XFER_READ; diff --git a/drivers/mmc/host/s3cmci.h b/drivers/mmc/host/s3cmci.h index 4320f7d832dc..caf1078d07d1 100644 --- a/drivers/mmc/host/s3cmci.h +++ b/drivers/mmc/host/s3cmci.h @@ -51,7 +51,7 @@ struct s3cmci_host { int dma_complete; struct scatterlist *cur_sg; - u32 pio_sgptr; + struct scatterlist *next_sg; u32 pio_bytes; u32 pio_count; u32 pio_offset; From patchwork Tue Feb 12 07:25:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10807493 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 8BE9713A4 for ; Tue, 12 Feb 2019 07:28:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71CB62A69E for ; Tue, 12 Feb 2019 07:28:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6621C2A6AB; Tue, 12 Feb 2019 07:28:26 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 D9C322A69E for ; Tue, 12 Feb 2019 07:28:25 +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:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PbmgsyhLy8s2QyIHgNvsHOOKrzERyshrvWe5H6msqfw=; b=BwohJYzvFeVFBb QaQ4boRqEP8HlyLzLxbJDuaY6y7rhT4K8MmNWzkE8f8k03ddj32IexOAjQ37tqQbg2D2/YolhEEOF nM21rhNIDonlcEbrl6vNUg1VoKUjKA/RBctUrUHxt0g7iSWz9nNPn/V4oAwXuzerEeLScJAdJIV9t aDNfGcKP5lGCH6lsQWa4pL0eEqdX8oHiCPbTh7tHCbGzAJtigrwtxs0h4wsHMIIUIXdR52fwbitxW jwOgphCM0CFSynOv675CcAxxIKFdd5WWn41E8c/MTZkkcmjGfzJ3bTYnz47QcTIKPg6Uf3wJHgy8O G67dln3E+TiS27PGMwZA==; 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 1gtSUN-0005Cp-Vc; Tue, 12 Feb 2019 07:28:19 +0000 Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtSS6-0002lW-2f; Tue, 12 Feb 2019 07:25:58 +0000 From: Christoph Hellwig To: Ulf Hansson Subject: [PATCH 10/14] mmc: mvsdio: handle highmem pages Date: Tue, 12 Feb 2019 08:25:24 +0100 Message-Id: <20190212072528.13167-11-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212072528.13167-1-hch@lst.de> References: <20190212072528.13167-1-hch@lst.de> MIME-Version: 1.0 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: Aaro Koskinen , Nicolas Pitre , linux-mmc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Ben Dooks , linux-omap@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 Instead of setting up a kernel pointer to track the current PIO address, track the offset in the current page, and do an atomic kmap for the page while doing the actual PIO operations. Signed-off-by: Christoph Hellwig --- drivers/mmc/host/mvsdio.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c index e22bbff89c8d..d04c78125a4d 100644 --- a/drivers/mmc/host/mvsdio.c +++ b/drivers/mmc/host/mvsdio.c @@ -42,7 +42,8 @@ struct mvsd_host { unsigned int intr_en; unsigned int ctrl; unsigned int pio_size; - void *pio_ptr; + struct scatterlist *pio_sg; + unsigned int pio_offset; /* offset in words into the segment */ unsigned int sg_frags; unsigned int ns_per_clk; unsigned int clock; @@ -96,9 +97,9 @@ static int mvsd_setup_data(struct mvsd_host *host, struct mmc_data *data) if (tmout_index > MVSD_HOST_CTRL_TMOUT_MAX) tmout_index = MVSD_HOST_CTRL_TMOUT_MAX; - dev_dbg(host->dev, "data %s at 0x%08x: blocks=%d blksz=%d tmout=%u (%d)\n", + dev_dbg(host->dev, "data %s at 0x%08llx: blocks=%d blksz=%d tmout=%u (%d)\n", (data->flags & MMC_DATA_READ) ? "read" : "write", - (u32)sg_virt(data->sg), data->blocks, data->blksz, + (u64)sg_phys(data->sg), data->blocks, data->blksz, tmout, tmout_index); host->ctrl &= ~MVSD_HOST_CTRL_TMOUT_MASK; @@ -118,10 +119,11 @@ static int mvsd_setup_data(struct mvsd_host *host, struct mmc_data *data) * boundary. */ host->pio_size = data->blocks * data->blksz; - host->pio_ptr = sg_virt(data->sg); + host->pio_sg = data->sg; + host->pio_offset = data->sg->offset / 2; if (!nodma) - dev_dbg(host->dev, "fallback to PIO for data at 0x%p size %d\n", - host->pio_ptr, host->pio_size); + dev_dbg(host->dev, "fallback to PIO for data at 0x%x size %d\n", + host->pio_offset, host->pio_size); return 1; } else { dma_addr_t phys_addr; @@ -291,8 +293,9 @@ static u32 mvsd_finish_data(struct mvsd_host *host, struct mmc_data *data, { void __iomem *iobase = host->base; - if (host->pio_ptr) { - host->pio_ptr = NULL; + if (host->pio_sg) { + host->pio_sg = NULL; + host->pio_offset = 0; host->pio_size = 0; } else { dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->sg_frags, @@ -376,8 +379,10 @@ static irqreturn_t mvsd_irq(int irq, void *dev) if (host->pio_size && (intr_status & host->intr_en & (MVSD_NOR_RX_READY | MVSD_NOR_RX_FIFO_8W))) { - u16 *p = host->pio_ptr; + u16 *base = sg_kmap_atomic(host->pio_sg); + u16 *p = base + host->pio_offset; int s = host->pio_size; + while (s >= 32 && (intr_status & MVSD_NOR_RX_FIFO_8W)) { readsw(iobase + MVSD_FIFO, p, 16); p += 16; @@ -416,13 +421,15 @@ static irqreturn_t mvsd_irq(int irq, void *dev) } dev_dbg(host->dev, "pio %d intr 0x%04x hw_state 0x%04x\n", s, intr_status, mvsd_read(MVSD_HW_STATE)); - host->pio_ptr = p; + host->pio_offset = p - base; host->pio_size = s; + sg_kunmap_atomic(host->pio_sg, base); irq_handled = 1; } else if (host->pio_size && (intr_status & host->intr_en & (MVSD_NOR_TX_AVAIL | MVSD_NOR_TX_FIFO_8W))) { - u16 *p = host->pio_ptr; + u16 *base = sg_kmap_atomic(host->pio_sg); + u16 *p = base + host->pio_offset; int s = host->pio_size; /* * The TX_FIFO_8W bit is unreliable. When set, bursting @@ -453,8 +460,9 @@ static irqreturn_t mvsd_irq(int irq, void *dev) } dev_dbg(host->dev, "pio %d intr 0x%04x hw_state 0x%04x\n", s, intr_status, mvsd_read(MVSD_HW_STATE)); - host->pio_ptr = p; + host->pio_offset = p - base; host->pio_size = s; + sg_kunmap_atomic(host->pio_sg, base); irq_handled = 1; } @@ -737,6 +745,7 @@ static int mvsd_probe(struct platform_device *pdev) clk_prepare_enable(host->clk); mmc->ops = &mvsd_ops; + mmc->need_kmap = 1; mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; From patchwork Tue Feb 12 07:25:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10807495 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 1D49414E1 for ; Tue, 12 Feb 2019 07:28:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01FF42A69E for ; Tue, 12 Feb 2019 07:28:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6EB12A6AB; Tue, 12 Feb 2019 07:28:39 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 7AD352A69E for ; Tue, 12 Feb 2019 07:28:39 +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:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TBl3+7/j0aPbPiU8UvtO9w3GrkgjfAfD/JbLuyaGSRw=; b=WHk6gwkT37m8Hi wesXlKrBVsplNjBPKmwCgBcoHPheA7v16dnIPZCkzRTEXMWceVyvU+nDeJbXCB0rJsLXMp7UBMM6N TnGFsBQ5Z621QYo+Sg68eVYyR/CRiCwH71Ha6QliaQgG2wojiK+qGnp4aBqwm1wanSNXZ3HolwUzh d24ABJ3wyn3BYq6dy69zcP8tJiIREYPGZlYXN7MGFel11cYs8C4ljM3sd5vG96Ld3qtw2ELkJDEtR IYj9KtZvaNF9cpJ2+jIk9Rx7ZLKUI0+T1IX17cGQsdVY6mJ2H/sRYMSB8xnYzvXPFM9MaSqH1dLEX rLsiEDM2O0u6Ymvdxv9A==; 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 1gtSUc-0005RP-RP; Tue, 12 Feb 2019 07:28:34 +0000 Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtSS8-0002oX-QN; Tue, 12 Feb 2019 07:26:01 +0000 From: Christoph Hellwig To: Ulf Hansson Subject: [PATCH 11/14] mmc: sh_mmcif: handle highmem pages Date: Tue, 12 Feb 2019 08:25:25 +0100 Message-Id: <20190212072528.13167-12-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212072528.13167-1-hch@lst.de> References: <20190212072528.13167-1-hch@lst.de> MIME-Version: 1.0 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: Aaro Koskinen , Nicolas Pitre , linux-mmc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Ben Dooks , linux-omap@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 Instead of setting up a kernel pointer to track the current PIO address, track the offset in the current page, and do an atomic kmap for the page while doing the actual PIO operations. Signed-off-by: Christoph Hellwig --- drivers/mmc/host/sh_mmcif.c | 59 +++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index 81bd9afb0980..24c3f13bafdb 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c @@ -228,7 +228,7 @@ struct sh_mmcif_host { bool dying; long timeout; void __iomem *addr; - u32 *pio_ptr; + u32 pio_offset; spinlock_t lock; /* protect sh_mmcif_host::state */ enum sh_mmcif_state state; enum sh_mmcif_wait_for wait_for; @@ -595,7 +595,7 @@ static int sh_mmcif_error_manage(struct sh_mmcif_host *host) return ret; } -static bool sh_mmcif_next_block(struct sh_mmcif_host *host, u32 *p) +static bool sh_mmcif_next_block(struct sh_mmcif_host *host) { struct mmc_data *data = host->mrq->data; @@ -606,10 +606,10 @@ static bool sh_mmcif_next_block(struct sh_mmcif_host *host, u32 *p) if (host->sg_blkidx == data->sg->length) { host->sg_blkidx = 0; - if (++host->sg_idx < data->sg_len) - host->pio_ptr = sg_virt(++data->sg); - } else { - host->pio_ptr = p; + if (++host->sg_idx < data->sg_len) { + data->sg++; + host->pio_offset = data->sg->offset / 4; + } } return host->sg_idx != data->sg_len; @@ -631,8 +631,8 @@ static bool sh_mmcif_read_block(struct sh_mmcif_host *host) { struct device *dev = sh_mmcif_host_to_dev(host); struct mmc_data *data = host->mrq->data; - u32 *p = sg_virt(data->sg); - int i; + u32 *p; + int off, i; if (host->sd_error) { data->error = sh_mmcif_error_manage(host); @@ -640,8 +640,11 @@ static bool sh_mmcif_read_block(struct sh_mmcif_host *host) return false; } + p = sg_kmap_atomic(data->sg); + off = data->sg->offset / 4; for (i = 0; i < host->blocksize / 4; i++) - *p++ = sh_mmcif_readl(host->addr, MMCIF_CE_DATA); + p[off++] = sh_mmcif_readl(host->addr, MMCIF_CE_DATA); + sg_kunmap_atomic(data->sg, p); /* buffer read end */ sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFRE); @@ -664,7 +667,7 @@ static void sh_mmcif_multi_read(struct sh_mmcif_host *host, host->wait_for = MMCIF_WAIT_FOR_MREAD; host->sg_idx = 0; host->sg_blkidx = 0; - host->pio_ptr = sg_virt(data->sg); + host->pio_offset = data->sg->offset / 4; sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFREN); } @@ -673,7 +676,7 @@ static bool sh_mmcif_mread_block(struct sh_mmcif_host *host) { struct device *dev = sh_mmcif_host_to_dev(host); struct mmc_data *data = host->mrq->data; - u32 *p = host->pio_ptr; + u32 *p; int i; if (host->sd_error) { @@ -684,10 +687,14 @@ static bool sh_mmcif_mread_block(struct sh_mmcif_host *host) BUG_ON(!data->sg->length); - for (i = 0; i < host->blocksize / 4; i++) - *p++ = sh_mmcif_readl(host->addr, MMCIF_CE_DATA); + p = sg_kmap_atomic(data->sg); + for (i = 0; i < host->blocksize / 4; i++) { + p[host->pio_offset++] = + sh_mmcif_readl(host->addr, MMCIF_CE_DATA); + } + sg_kunmap_atomic(data->sg, p); - if (!sh_mmcif_next_block(host, p)) + if (!sh_mmcif_next_block(host)) return false; sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFREN); @@ -711,8 +718,8 @@ static bool sh_mmcif_write_block(struct sh_mmcif_host *host) { struct device *dev = sh_mmcif_host_to_dev(host); struct mmc_data *data = host->mrq->data; - u32 *p = sg_virt(data->sg); - int i; + u32 *p; + int off, i; if (host->sd_error) { data->error = sh_mmcif_error_manage(host); @@ -720,8 +727,11 @@ static bool sh_mmcif_write_block(struct sh_mmcif_host *host) return false; } + p = sg_kmap_atomic(data->sg); + off = data->sg->offset / 4; for (i = 0; i < host->blocksize / 4; i++) - sh_mmcif_writel(host->addr, MMCIF_CE_DATA, *p++); + sh_mmcif_writel(host->addr, MMCIF_CE_DATA, p[off++]); + sg_kunmap_atomic(data->sg, p); /* buffer write end */ sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MDTRANE); @@ -744,7 +754,7 @@ static void sh_mmcif_multi_write(struct sh_mmcif_host *host, host->wait_for = MMCIF_WAIT_FOR_MWRITE; host->sg_idx = 0; host->sg_blkidx = 0; - host->pio_ptr = sg_virt(data->sg); + host->pio_offset = data->sg->offset / 4; sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFWEN); } @@ -753,7 +763,7 @@ static bool sh_mmcif_mwrite_block(struct sh_mmcif_host *host) { struct device *dev = sh_mmcif_host_to_dev(host); struct mmc_data *data = host->mrq->data; - u32 *p = host->pio_ptr; + u32 *p; int i; if (host->sd_error) { @@ -764,10 +774,14 @@ static bool sh_mmcif_mwrite_block(struct sh_mmcif_host *host) BUG_ON(!data->sg->length); - for (i = 0; i < host->blocksize / 4; i++) - sh_mmcif_writel(host->addr, MMCIF_CE_DATA, *p++); + p = sg_kmap_atomic(data->sg); + for (i = 0; i < host->blocksize / 4; i++) { + sh_mmcif_writel(host->addr, MMCIF_CE_DATA, + p[host->pio_offset++]); + } + sg_kunmap_atomic(data->sg, p); - if (!sh_mmcif_next_block(host, p)) + if (!sh_mmcif_next_block(host)) return false; sh_mmcif_bitset(host, MMCIF_CE_INT_MASK, MASK_MBUFWEN); @@ -1424,6 +1438,7 @@ static int sh_mmcif_probe(struct platform_device *pdev) spin_lock_init(&host->lock); mmc->ops = &sh_mmcif_ops; + mmc->need_kmap = 1; sh_mmcif_init_ocr(host); mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_WAIT_WHILE_BUSY; From patchwork Tue Feb 12 07:25:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10807497 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 BBD7713A4 for ; Tue, 12 Feb 2019 07:29:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1B562A7E4 for ; Tue, 12 Feb 2019 07:29:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F9C82A812; Tue, 12 Feb 2019 07:29:01 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 364AA2A7E4 for ; Tue, 12 Feb 2019 07:29:01 +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:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IjNYlB4Uuoswm8AI3x2ZvVyZRgr20DVtKzRcyy1u/u8=; b=Bv1R/8DMxLvz7N 2Asw3NDQfv1vPjd/WCX2shOx4CHF7azrMNqVzfbLcwDCqQiFp+NcJTY+4kvXq2Xu1KKLY65WfPXEy RpZIOuHpdLWPPecWsf4sdWfTuLLkeM5fmQBUyDlucZhwbDCwt2ey041t1ijrVCJlU9Unx4BT44jSg sp4AliaFG6hWD6zzugztrzHYdEgScgm2YOQQD7OsvCkGyndvLwXwQCQe199IXWpRZ7e7LiQ4RcAQ8 BiSqk2Mzvk1LS2AdG6RTKVB+WnxLm/6KeaOrNkuUXg6SScglX1+6uXzxpwapZsPMNf7htIqp0xF8n DZ3wzLEKl2yrligMplEw==; 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 1gtSUv-0005kD-9O; Tue, 12 Feb 2019 07:28:53 +0000 Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtSSB-0002rI-FU; Tue, 12 Feb 2019 07:26:03 +0000 From: Christoph Hellwig To: Ulf Hansson Subject: [PATCH 12/14] mmc: sh_mmcif: handle chained sglists Date: Tue, 12 Feb 2019 08:25:26 +0100 Message-Id: <20190212072528.13167-13-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212072528.13167-1-hch@lst.de> References: <20190212072528.13167-1-hch@lst.de> MIME-Version: 1.0 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: Aaro Koskinen , Nicolas Pitre , linux-mmc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Ben Dooks , linux-omap@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 Use the proper sg_next() helper to move to the next scatterlist element to support chained scatterlists. Signed-off-by: Christoph Hellwig --- drivers/mmc/host/sh_mmcif.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index 24c3f13bafdb..9e59dbe6ef30 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c @@ -234,7 +234,6 @@ struct sh_mmcif_host { enum sh_mmcif_wait_for wait_for; struct delayed_work timeout_work; size_t blocksize; - int sg_idx; int sg_blkidx; bool power; bool ccs_enable; /* Command Completion Signal support */ @@ -606,13 +605,13 @@ static bool sh_mmcif_next_block(struct sh_mmcif_host *host) if (host->sg_blkidx == data->sg->length) { host->sg_blkidx = 0; - if (++host->sg_idx < data->sg_len) { - data->sg++; - host->pio_offset = data->sg->offset / 4; - } + data->sg = sg_next(data->sg); + if (!data->sg) + return false; + host->pio_offset = data->sg->offset / 4; } - return host->sg_idx != data->sg_len; + return true; } static void sh_mmcif_single_read(struct sh_mmcif_host *host, @@ -665,7 +664,6 @@ static void sh_mmcif_multi_read(struct sh_mmcif_host *host, BLOCK_SIZE_MASK; host->wait_for = MMCIF_WAIT_FOR_MREAD; - host->sg_idx = 0; host->sg_blkidx = 0; host->pio_offset = data->sg->offset / 4; @@ -752,7 +750,6 @@ static void sh_mmcif_multi_write(struct sh_mmcif_host *host, BLOCK_SIZE_MASK; host->wait_for = MMCIF_WAIT_FOR_MWRITE; - host->sg_idx = 0; host->sg_blkidx = 0; host->pio_offset = data->sg->offset / 4; From patchwork Tue Feb 12 07:25:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10807499 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 7CB2E13A4 for ; Tue, 12 Feb 2019 07:29:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 632212A808 for ; Tue, 12 Feb 2019 07:29:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56EA52A81A; Tue, 12 Feb 2019 07:29:14 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 058682A808 for ; Tue, 12 Feb 2019 07:29:14 +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:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XKCtz8uUERmhmFRekXR4PXm1Hc3GLCI9za5x4sRTNSA=; b=fPF4ib10U17oP2 6HnDutS5iWb2Pk/DKJis88X8mam6AlIbqD+xbmyB6P2CqBUww96lS8eihnjj0DWRRIO+l6MwXtTI6 ofEQwX4l0vJ5WQGf69vIFjkT4Wfk3VBoFUVKyPNRUfH/0dtxEBNln/f5ipCNSHZ6tl+PGtAr5TKCb PkI66m3lRPLSJMcUK7zJ0Zbmp9X2PDgCJC2JNe2ftMhPcL19qxcMqyXv8i2yuKDbYXQAiIJCwlPt+ c2ArEGDLCCIlLrvTbgcmm7UDlVsHQAwo+4AxHdUNSSzsvV90MBuGow+Hax4rxB4DVO7E4glblwEq8 n/0o7NXCmrWGGdQ8xnCg==; 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 1gtSVB-00065O-IB; Tue, 12 Feb 2019 07:29:09 +0000 Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtSSE-0002ty-4k; Tue, 12 Feb 2019 07:26:06 +0000 From: Christoph Hellwig To: Ulf Hansson Subject: [PATCH 13/14] mmc: core: don't use block layer bounce buffers Date: Tue, 12 Feb 2019 08:25:27 +0100 Message-Id: <20190212072528.13167-14-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212072528.13167-1-hch@lst.de> References: <20190212072528.13167-1-hch@lst.de> MIME-Version: 1.0 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: Aaro Koskinen , Nicolas Pitre , linux-mmc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Ben Dooks , linux-omap@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 All MMC and SD host drivers are highmem safe now, and bounce buffering for addressing limitations is handled in the DMA layer now. Signed-off-by: Christoph Hellwig --- drivers/mmc/core/queue.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c index 71cd2411329e..1c92a2a4d641 100644 --- a/drivers/mmc/core/queue.c +++ b/drivers/mmc/core/queue.c @@ -354,17 +354,12 @@ static const struct blk_mq_ops mmc_mq_ops = { static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card) { struct mmc_host *host = card->host; - u64 limit = BLK_BOUNCE_HIGH; - - if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask) - limit = (u64)dma_max_pfn(mmc_dev(host)) << PAGE_SHIFT; blk_queue_flag_set(QUEUE_FLAG_NONROT, mq->queue); blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, mq->queue); if (mmc_can_erase(card)) mmc_queue_setup_discard(mq->queue, card); - blk_queue_bounce_limit(mq->queue, limit); blk_queue_max_hw_sectors(mq->queue, min(host->max_blk_count, host->max_req_size / 512)); blk_queue_max_segments(mq->queue, host->max_segs); From patchwork Tue Feb 12 07:25:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10807501 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 3864213A4 for ; Tue, 12 Feb 2019 07:29:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F0602A8F1 for ; Tue, 12 Feb 2019 07:29:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 131762A8FA; Tue, 12 Feb 2019 07:29:32 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 9373D2A8F1 for ; Tue, 12 Feb 2019 07:29:31 +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:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2LDfREH2O+ncRJ/RjpT3OvJhL4Gqi8z2n1l/85C4yqI=; b=MaoI9dgf/sfVWv ewmVxMlXYArHgEQW3s31MikdesoAsRxc6rryiRJHsH/NtfDghwko9L210ksfkYdHO61kHCkONiyqx Rq9ynfubN8F4UCua3SBKtVvVPacQQXFyk3JLtD1srE+Fo7CNZ5eX8cx5u0ZZmmD6urnC4qvHAClLh PIxEPdj/BHqL49k053Oi1oDMekE+mvkekxf7PBfgZlOB+a/mGLHASfYRtsEZLF32PChqkcE2Ir3Vz T6+x3QtweWW2c3IyK3734ynvxdA73jHQRyGwXTBhk6XzCBq7TZ8G7POuG+4V3/+85XVQ4A35nnvqD 8oaZ+3pAZA349lh9eExg==; 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 1gtSVP-0006O0-9v; Tue, 12 Feb 2019 07:29:23 +0000 Received: from 089144210182.atnat0019.highway.a1.net ([89.144.210.182] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gtSSG-0002vw-RH; Tue, 12 Feb 2019 07:26:09 +0000 From: Christoph Hellwig To: Ulf Hansson Subject: [PATCH 14/14] dma-mapping: remove dma_max_pfn Date: Tue, 12 Feb 2019 08:25:28 +0100 Message-Id: <20190212072528.13167-15-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190212072528.13167-1-hch@lst.de> References: <20190212072528.13167-1-hch@lst.de> MIME-Version: 1.0 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: Aaro Koskinen , Nicolas Pitre , linux-mmc@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Ben Dooks , linux-omap@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 These days the DMA mapping code must bounce buffer for any not supported address, and if they driver needs to optimize for natively supported ranged it should use dma_get_required_mask. Signed-off-by: Christoph Hellwig --- arch/arm/include/asm/dma-mapping.h | 7 ------- include/linux/dma-mapping.h | 7 ------- 2 files changed, 14 deletions(-) diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index 31d3b96f0f4b..496b36b9a7ff 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h @@ -89,13 +89,6 @@ static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) } #endif -/* The ARM override for dma_max_pfn() */ -static inline unsigned long dma_max_pfn(struct device *dev) -{ - return dma_to_pfn(dev, *dev->dma_mask); -} -#define dma_max_pfn(dev) dma_max_pfn(dev) - #define arch_setup_dma_ops arch_setup_dma_ops extern void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, const struct iommu_ops *iommu, bool coherent); diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index f6ded992c183..c6dbc287e466 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -710,13 +710,6 @@ static inline int dma_set_seg_boundary(struct device *dev, unsigned long mask) return -EIO; } -#ifndef dma_max_pfn -static inline unsigned long dma_max_pfn(struct device *dev) -{ - return (*dev->dma_mask >> PAGE_SHIFT) + dev->dma_pfn_offset; -} -#endif - static inline int dma_get_cache_alignment(void) { #ifdef ARCH_DMA_MINALIGN