From patchwork Mon Jan 14 09:57:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10761917 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 1A8D914E5 for ; Mon, 14 Jan 2019 09:59:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CAB528B0B for ; Mon, 14 Jan 2019 09:59:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 00FC028B10; Mon, 14 Jan 2019 09:59:52 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 931ED28B0F for ; Mon, 14 Jan 2019 09:59:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726618AbfANJ6Q (ORCPT ); Mon, 14 Jan 2019 04:58:16 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:57524 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbfANJ6Q (ORCPT ); Mon, 14 Jan 2019 04:58:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ukM87FMgfgS9ur3gUuVOhxDqT0YWODMmGAJNvyFPMYc=; b=LcEZ/Ndcc3jGQx2CZ13af/Imy3 0BE2RCQHOyWrgw5kXPCcuAW3vQohRGaY6UUxcn064R9/3bFXvLl3XtoTRvuVzEMnn98BxNEJgSHf8 lNx2syU97p1WGDIZpg4/ermCt7wQRTYGhB7Y18onqHQLpbKv52khQtxcrhWPtMHNWruAa3iNz5MMt zRVoIusxp/OeIRjeMlJm9Ny5MU0UvsRVntcsEWDJM+AySGww90PWFDnXXl9dQVNy6ZFb5IF0/a8Om fVAiIzV15SEH/dlRKt5TnCo5g/8MclfzlHTzpxWn8VJUFAhw77jcr33ryzWp1lbsVlH+bydIOqbfg 7wxtrB4A==; Received: from 089144213167.atnat0022.highway.a1.net ([89.144.213.167] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1giz0T-0001qz-HZ; Mon, 14 Jan 2019 09:58:09 +0000 From: Christoph Hellwig To: Ulf Hansson Cc: Russell King , Nicolas Pitre , Aaro Koskinen , Ben Dooks , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/11] mmc: davinci: handle highmem pages Date: Mon, 14 Jan 2019 10:57:54 +0100 Message-Id: <20190114095804.27978-2-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114095804.27978-1-hch@lst.de> References: <20190114095804.27978-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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 | 43 ++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c index 9e68c3645e22..9c500c52b63d 100644 --- a/drivers/mmc/host/davinci_mmc.c +++ b/drivers/mmc/host/davinci_mmc.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -194,11 +195,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 +231,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 +240,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; + void *p; unsigned int i; if (host->buffer_bytes_left == 0) { @@ -246,7 +248,7 @@ static void davinci_fifo_data_trans(struct mmc_davinci_host *host, mmc_davinci_sg_to_buf(host); } - p = host->buffer; + p = kmap_atomic(sg_page(host->sg)); if (n > host->buffer_bytes_left) n = host->buffer_bytes_left; host->buffer_bytes_left -= n; @@ -258,24 +260,31 @@ static void davinci_fifo_data_trans(struct mmc_davinci_host *host, */ if (host->data_dir == DAVINCI_MMC_DATADIR_WRITE) { for (i = 0; i < (n >> 2); i++) { - writel(*((u32 *)p), host->base + DAVINCI_MMCDXR); - p = p + 4; + u32 *val = p + host->buffer_offset; + + writel(*val, host->base + DAVINCI_MMCDXR); + host->buffer_offset += 4; } if (n & 3) { - iowrite8_rep(host->base + DAVINCI_MMCDXR, p, (n & 3)); - p = p + (n & 3); + iowrite8_rep(host->base + DAVINCI_MMCDXR, + p + host->buffer_offset, n & 3); + host->buffer_offset += (n & 3); } } else { for (i = 0; i < (n >> 2); i++) { - *((u32 *)p) = readl(host->base + DAVINCI_MMCDRR); - p = p + 4; + u32 *val = p + host->buffer_offset; + + *val = readl(host->base + DAVINCI_MMCDRR); + host->buffer_offset += 4; } if (n & 3) { - ioread8_rep(host->base + DAVINCI_MMCDRR, p, (n & 3)); - p = p + (n & 3); + ioread8_rep(host->base + DAVINCI_MMCDRR, + p + host->buffer_offset, n & 3); + host->buffer_offset += (n & 3); } } - host->buffer = p; + + kunmap_atomic(p); } static void mmc_davinci_start_command(struct mmc_davinci_host *host, @@ -572,7 +581,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 From patchwork Mon Jan 14 09:57:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10761867 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 14A3014E5 for ; Mon, 14 Jan 2019 09:58:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 059B028ABB for ; Mon, 14 Jan 2019 09:58:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDDAB28AE7; Mon, 14 Jan 2019 09:58: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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FB4928ABB for ; Mon, 14 Jan 2019 09:58:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726541AbfANJ6U (ORCPT ); Mon, 14 Jan 2019 04:58:20 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:57828 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbfANJ6U (ORCPT ); Mon, 14 Jan 2019 04:58:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PC7MWnyri7Tw5JfDSYFG9mz/W8WDf8AUZ+PFyenukAs=; b=fEqALaB/1lhpdMtqfvSHCfhuqZ WOYrESC5tkiLF3DkA01tU904RKHV4Sw/rd2P+rsuK7Hzw07zCKqdd1+iFLUbjX6cadLnawPcQY40g 2dEOaAca0/9YbTH6vnnqQUgYDKbp7WphIhE7fbM0id2OJQopns3IC6pgPlCzUsKTrYBuPoEPyP5S9 5VCQW0DwasKYlB02xcu5Z5ld6y8li7ofxIvOuvMe42SAg+o7UO36KU31CAHnKyhzC3vciOZsh+vjV WHSTGKW3O/RYitrtb03pgm78f2IId8g4D5VjKUyBYd36GQzFVC4g4iS5zmG/KB1Wajq9hbnMnLp0m gMPiiQJQ==; Received: from 089144213167.atnat0022.highway.a1.net ([89.144.213.167] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1giz0W-0001rf-L4; Mon, 14 Jan 2019 09:58:13 +0000 From: Christoph Hellwig To: Ulf Hansson Cc: Russell King , Nicolas Pitre , Aaro Koskinen , Ben Dooks , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/11] mmc: moxart: handle highmem pages Date: Mon, 14 Jan 2019 10:57:55 +0100 Message-Id: <20190114095804.27978-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114095804.27978-1-hch@lst.de> References: <20190114095804.27978-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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 | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c index a0670e9cd012..7142bca425c8 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) From patchwork Mon Jan 14 09:57:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10761909 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 B4FC314E5 for ; Mon, 14 Jan 2019 09:59:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A727828B0B for ; Mon, 14 Jan 2019 09:59:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 989EA28B10; Mon, 14 Jan 2019 09:59:41 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A73E28B0B for ; Mon, 14 Jan 2019 09:59:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726704AbfANJ6X (ORCPT ); Mon, 14 Jan 2019 04:58:23 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:58116 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbfANJ6X (ORCPT ); Mon, 14 Jan 2019 04:58:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1w9jZZTi3DvzoUA7QUurE84hYRAcJKNs5P1tn9D6S9o=; b=ZlPJoyxuVASkVw7JGj+0RxA7PZ C6spsELtfM+69XVM45tT3E767DfiUnoOuqRUnfWTu6M4JXfFotcNMNaMrpOnO8E0oHHDqC3WA7RwI o6nTuQ7s8RpGTEwgR2JJ5+Bl9/lo6m8Achv9IggGcIowotrXWvrCNVjQqeyqnKXDvjVtXG96mLYr9 6DggEdbbLwQf0QjfqR6sUZJs0eX8RZhYy4darvTzBTJIyQ2M5+0PuOh1g5GIUmFOSJQwT34EMGW5l dnVVIq974WqmeOBnyAAlFllQ5W1wtRGFSIpUTyXEaYeiyRHaI6zsgxfKTIR8J2ihmpQrAqzsL7e3d JTzfiZ8Q==; Received: from 089144213167.atnat0022.highway.a1.net ([89.144.213.167] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1giz0Z-0001uJ-UF; Mon, 14 Jan 2019 09:58:16 +0000 From: Christoph Hellwig To: Ulf Hansson Cc: Russell King , Nicolas Pitre , Aaro Koskinen , Ben Dooks , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/11] mmc: omap: handle highmem pages Date: Mon, 14 Jan 2019 10:57:56 +0100 Message-Id: <20190114095804.27978-4-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114095804.27978-1-hch@lst.de> References: <20190114095804.27978-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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..0377ac6194a0 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -148,7 +149,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 +650,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 +667,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 +687,17 @@ mmc_omap_xfer_data(struct mmc_omap_host *host, int write) host->total_bytes_left -= n; host->data->bytes_xfered += n; + p = kmap_atomic(sg_page(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); } + kunmap_atomic(p); - host->buffer += nwords; + host->buffer_offset += nwords; } #ifdef CONFIG_MMC_DEBUG From patchwork Mon Jan 14 09:57:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10761905 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 5277414E5 for ; Mon, 14 Jan 2019 09:59:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 421FB28B0B for ; Mon, 14 Jan 2019 09:59:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36B4A28B10; Mon, 14 Jan 2019 09:59: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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0DD328B0B for ; Mon, 14 Jan 2019 09:59:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726771AbfANJ61 (ORCPT ); Mon, 14 Jan 2019 04:58:27 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:58390 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726761AbfANJ60 (ORCPT ); Mon, 14 Jan 2019 04:58:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=OJytBFiMFV7AJYQkXOx0ilRvBkQf1Wlcn0Y5tk8Zi5s=; b=lJiWOH+0I1p3CnkZREUHJdGp2w 5Wop3vXBMkCICUUVPd4nIax85kVaYWHKVxPNMg1MPRTDo7ft3mZ4PAs7gruw8J4f6FJSP7GPMnBt6 RS1NweP8DchGW6RP9fV02BtHu3sk/aIH77XAbdXjxKiJgbi5kY+t4HLDuZq6iKhqngahSxetYi6o1 kTydsvq8bG7PO8oEfELl+voJoPJId1aP7xAw6kmQAT2CJ2xoctZFKFvHbALQ/HpZF77kbBVbLJiXz mzpXg8KWndNsclDN++ytzNhC8ztZ5SrMRhBU8PFDpD8DXUQehjsORPqHN7/5Ht/WBs7LE9l/5UwrX xYTvL21A==; Received: from 089144213167.atnat0022.highway.a1.net ([89.144.213.167] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1giz0d-0001xy-DN; Mon, 14 Jan 2019 09:58:20 +0000 From: Christoph Hellwig To: Ulf Hansson Cc: Russell King , Nicolas Pitre , Aaro Koskinen , Ben Dooks , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/11] mmc: omap: handle chained sglists Date: Mon, 14 Jan 2019 10:57:57 +0100 Message-Id: <20190114095804.27978-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114095804.27978-1-hch@lst.de> References: <20190114095804.27978-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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 0377ac6194a0..248707aba2df 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c @@ -148,7 +148,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; @@ -646,11 +646,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; } @@ -667,13 +664,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; @@ -985,7 +981,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 Mon Jan 14 09:57:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10761871 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 8891313B5 for ; Mon, 14 Jan 2019 09:58:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 779DA28ABB for ; Mon, 14 Jan 2019 09:58:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C05228AE7; Mon, 14 Jan 2019 09:58:38 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE5A628ABB for ; Mon, 14 Jan 2019 09:58:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726816AbfANJ6b (ORCPT ); Mon, 14 Jan 2019 04:58:31 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:58764 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726811AbfANJ6b (ORCPT ); Mon, 14 Jan 2019 04:58:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/s++KaySvR6D7mjFJB7ah1oNqG5vMse2K9rQmUXPq24=; b=ry3vZ+UwWbCPrLNsQH04P3GtCr UxzzopGXuf4S/v937V4B1tmp6v25zNN+juuQxoSeRjkhmPkbLUuayiRea0uPS8JXVh4e0L5sIE92h 6oVMYinALLdAniIfpXfAunS4dOAZp7RlCxJwuHvXDmHSYOk5hsu0E6hmCpoxgrrRrPCnPqylPzCkH TBae4GLCecXMu0hXqni5Vipy6UEldy97NkAUeWqXN9dXkgO8GFX/DYULLwTvBkOkxqqAIqn89wez5 Ln17bBpnBVEyKcOyBnO19NIQT0T4KJA4lz+vYK8zinjbQW025So8qmpDJ5EROrb6NAFdJjgMCUrjg KDcFoVWQ==; Received: from 089144213167.atnat0022.highway.a1.net ([89.144.213.167] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1giz0g-00021E-SG; Mon, 14 Jan 2019 09:58:23 +0000 From: Christoph Hellwig To: Ulf Hansson Cc: Russell King , Nicolas Pitre , Aaro Koskinen , Ben Dooks , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/11] mmc: s3cmci: handle highmem pages Date: Mon, 14 Jan 2019 10:57:58 +0100 Message-Id: <20190114095804.27978-6-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114095804.27978-1-hch@lst.de> References: <20190114095804.27978-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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..1be84426c817 100644 --- a/drivers/mmc/host/s3cmci.c +++ b/drivers/mmc/host/s3cmci.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -317,26 +318,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 +414,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 +432,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 +459,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 = (kmap_atomic(sg_page(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++; } } + kunmap_atomic(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 +534,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 = (kmap_atomic(sg_page(host->cur_sg)) + host->pio_offset); + ptr = buf; + while (fifo--) { writel(*ptr++, to_ptr); - host->pio_ptr = ptr; + host->pio_offset += 4; + } + kunmap_atomic(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 +1053,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; 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 Mon Jan 14 09:57:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10761901 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 E8E5513B5 for ; Mon, 14 Jan 2019 09:59:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB67828B0B for ; Mon, 14 Jan 2019 09:59:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CFB1628B0F; Mon, 14 Jan 2019 09:59:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21CAD28B0A for ; Mon, 14 Jan 2019 09:59:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726785AbfANJ7Y (ORCPT ); Mon, 14 Jan 2019 04:59:24 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:60210 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726857AbfANJ6v (ORCPT ); Mon, 14 Jan 2019 04:58:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=WZ9aJEBC7EdGRYOFoux4r/SaAviNsLiJM7mr7nUt+xw=; b=nvuGuEGrA6lXHBJRocmbjOMDkC rjtYKqaMNZD89cnBBBEc9TaCCIY4SJmclUvcYTq6q0KxAVQo27rv6SZYzsw0cBdyntMggVaO/M/pO QMyTS+ZENRDdGQizbQv0uMijvWGGXw1FpdxaQlc4Jyqh9ppgLpo+lhFeM+C164s7T/TeaG9wPjRbG 9OcCwqD4tRdSb8x1zrSMGSjc5jyFtchgsYLpGFwr4xh65JFiOJ2IBwqh4Zt8eGOZEwAsYWz52B3GP JndHaGVbDdogHR+FpV5Eck9L4IGymJFtCzF4U2FIaaBr1cYPtYsQG4yeEkgUNzBWk6KNxvPmA4yrz UAfnTcwA==; Received: from 089144213167.atnat0022.highway.a1.net ([89.144.213.167] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1giz0k-000250-Ag; Mon, 14 Jan 2019 09:58:26 +0000 From: Christoph Hellwig To: Ulf Hansson Cc: Russell King , Nicolas Pitre , Aaro Koskinen , Ben Dooks , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/11] mmc: s3cmci: handle chained sglists Date: Mon, 14 Jan 2019 10:57:59 +0100 Message-Id: <20190114095804.27978-7-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114095804.27978-1-hch@lst.de> References: <20190114095804.27978-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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 1be84426c817..2660fb61d1d0 100644 --- a/drivers/mmc/host/s3cmci.c +++ b/drivers/mmc/host/s3cmci.c @@ -320,20 +320,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; } @@ -1052,8 +1051,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 Mon Jan 14 09:58:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10761877 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 A54E214E5 for ; Mon, 14 Jan 2019 09:58:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96E9528ABB for ; Mon, 14 Jan 2019 09:58:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B4A728AE7; Mon, 14 Jan 2019 09:58:46 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02AA728ADD for ; Mon, 14 Jan 2019 09:58:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726755AbfANJ6j (ORCPT ); Mon, 14 Jan 2019 04:58:39 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:59308 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726717AbfANJ6i (ORCPT ); Mon, 14 Jan 2019 04:58:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=RtgWLmRaQa8Vtp2WR0jaqmktdlYG16bsRVyK1TK9/tw=; b=JvpY1zkCyh99fpfRANl3nAXYCv 0l+F4ZtYUHCMbspkFJQJT+Zv7oLBD2CyAAM8h6B9Qo6QdoBinDKwm3ZsoGxh3Uace5FxYFHLzLbKH lgbxhdvia3xTtXuFRXpFaocWkWwqZrwiXUWqwYvZ31zdTfercbn8FkWAFLHr0IUpxeBR8UusMbK5D z6fwN46Cs5WO0FfJvx/Ed/oVwbSaUj2jN3tIl4JQW9ifDOLbbf2ZfPa5t1xZ5h1U733bOpAumv8I3 JeTkUULPMcR9HWo4nuH8Y8J+g9TTC2ZnGHdP338fw0VUyNzkz27YAiK/yjTSJ9L8VqqxQOgdB5eiF 5RsrFASA==; Received: from 089144213167.atnat0022.highway.a1.net ([89.144.213.167] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1giz0o-00028p-5p; Mon, 14 Jan 2019 09:58:30 +0000 From: Christoph Hellwig To: Ulf Hansson Cc: Russell King , Nicolas Pitre , Aaro Koskinen , Ben Dooks , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/11] mmc: mvsdio: handle highmem pages Date: Mon, 14 Jan 2019 10:58:00 +0100 Message-Id: <20190114095804.27978-8-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114095804.27978-1-hch@lst.de> References: <20190114095804.27978-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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 | 48 +++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/drivers/mmc/host/mvsdio.c b/drivers/mmc/host/mvsdio.c index e22bbff89c8d..545e370d6dae 100644 --- a/drivers/mmc/host/mvsdio.c +++ b/drivers/mmc/host/mvsdio.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -42,7 +43,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 +98,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 +120,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 +294,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,11 +380,12 @@ 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 *p = kmap_atomic(sg_page(host->pio_sg)); + unsigned int o = 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; + readsw(iobase + MVSD_FIFO, p + o, 16); + o += 16; s -= 32; intr_status = mvsd_read(MVSD_NOR_INTR_STATUS); } @@ -391,8 +396,10 @@ static irqreturn_t mvsd_irq(int irq, void *dev) */ if (s <= 32) { while (s >= 4 && (intr_status & MVSD_NOR_RX_READY)) { - put_unaligned(mvsd_read(MVSD_FIFO), p++); - put_unaligned(mvsd_read(MVSD_FIFO), p++); + put_unaligned(mvsd_read(MVSD_FIFO), p + o); + o++; + put_unaligned(mvsd_read(MVSD_FIFO), p + o); + o++; s -= 4; intr_status = mvsd_read(MVSD_NOR_INTR_STATUS); } @@ -400,7 +407,7 @@ static irqreturn_t mvsd_irq(int irq, void *dev) u16 val[2] = {0, 0}; val[0] = mvsd_read(MVSD_FIFO); val[1] = mvsd_read(MVSD_FIFO); - memcpy(p, ((void *)&val) + 4 - s, s); + memcpy(p + o, ((void *)&val) + 4 - s, s); s = 0; intr_status = mvsd_read(MVSD_NOR_INTR_STATUS); } @@ -416,13 +423,14 @@ 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 = o; host->pio_size = s; 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 *p = kmap_atomic(sg_page(host->pio_sg)); + unsigned int o = host->pio_offset; int s = host->pio_size; /* * The TX_FIFO_8W bit is unreliable. When set, bursting @@ -431,8 +439,10 @@ static irqreturn_t mvsd_irq(int irq, void *dev) * TX_FIFO_8W remains set. */ while (s >= 4 && (intr_status & MVSD_NOR_TX_AVAIL)) { - mvsd_write(MVSD_FIFO, get_unaligned(p++)); - mvsd_write(MVSD_FIFO, get_unaligned(p++)); + mvsd_write(MVSD_FIFO, get_unaligned(p + o)); + o++; + mvsd_write(MVSD_FIFO, get_unaligned(p + o)); + o++; s -= 4; intr_status = mvsd_read(MVSD_NOR_INTR_STATUS); } @@ -453,7 +463,7 @@ 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 = o; host->pio_size = s; irq_handled = 1; } From patchwork Mon Jan 14 09:58:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10761883 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 12C9813B5 for ; Mon, 14 Jan 2019 09:58:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0310A286F7 for ; Mon, 14 Jan 2019 09:58:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E904B286FE; Mon, 14 Jan 2019 09:58:52 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6197F286F7 for ; Mon, 14 Jan 2019 09:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726881AbfANJ6v (ORCPT ); Mon, 14 Jan 2019 04:58:51 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:60212 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbfANJ6v (ORCPT ); Mon, 14 Jan 2019 04:58:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=fun2sOWR4Sa93NP+haaBCSxtEybL6195fdEis776Vs0=; b=uLkpzwcWDCx1qxs0Ei+gt6KFhh nnN/hgm2x8VHnZYkSwzwIPyZfubn11qtQii1qxHGwxtS5cX1x4+Fn84B0MJize8IH3+GEVy6pQ/V0 uZea6cnYZSICglOk9VAdSaCqCmziY+u0UbVCWdyJRw0TfmS9lIUdlLbScJuGKVSYEQowr1CNZjEdx rTpsS31EV12/oKS3Ey1xNSMLV5NBWZWMsNqBmrutbiyLonis85BoDptDYpFPYa7R2mxCqgANugMmr EsfqKI1pyw+2XjUvuqTPAZW78Rk/rB6f9X3rE9GXRQCXuIMF4yWbkdITVojuVxxH94tDs2kLKyfbY Eu5DUd8g==; Received: from 089144213167.atnat0022.highway.a1.net ([89.144.213.167] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1giz0r-0002Cb-Nh; Mon, 14 Jan 2019 09:58:34 +0000 From: Christoph Hellwig To: Ulf Hansson Cc: Russell King , Nicolas Pitre , Aaro Koskinen , Ben Dooks , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/11] mmc: sh_mmcif: handle highmem pages Date: Mon, 14 Jan 2019 10:58:01 +0100 Message-Id: <20190114095804.27978-9-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114095804.27978-1-hch@lst.de> References: <20190114095804.27978-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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 | 58 +++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index 81bd9afb0980..0d2bbb8943f5 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 = kmap_atomic(sg_page(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); + kunmap_atomic(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 = kmap_atomic(sg_page(data->sg)); + for (i = 0; i < host->blocksize / 4; i++) { + p[host->pio_offset++] = + sh_mmcif_readl(host->addr, MMCIF_CE_DATA); + } + kunmap_atomic(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 = kmap_atomic(sg_page(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++]); + kunmap_atomic(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 = kmap_atomic(sg_page(data->sg)); + for (i = 0; i < host->blocksize / 4; i++) { + sh_mmcif_writel(host->addr, MMCIF_CE_DATA, + p[host->pio_offset++]); + } + kunmap_atomic(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); From patchwork Mon Jan 14 09:58:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10761903 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 A73B714E5 for ; Mon, 14 Jan 2019 09:59:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9996B28B0A for ; Mon, 14 Jan 2019 09:59:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D67C28B0F; Mon, 14 Jan 2019 09:59:36 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FFFE28B0A for ; Mon, 14 Jan 2019 09:59:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726803AbfANJ6s (ORCPT ); Mon, 14 Jan 2019 04:58:48 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:59932 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726857AbfANJ6q (ORCPT ); Mon, 14 Jan 2019 04:58:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=T4OCbupN7r9XzFe0NMLIX5QDout51/50IpzPj/iVSVU=; b=EnB6rFYvBStp+HzKG0KpV7/ZQF 9LALqZfaJGKhkdrZ/sio/2G9AOMAYji1BJfIcwaiRDYO4pSTiDlw1pGsFLO0YeVxbBcOaOMxTCQGM PcrR6Rvn7aeg50pBWBDxVX3WjPhzoXSdIWU84LnUY8FnvqUKi+RgGYQr2gKeKU3gZLqKzxCvbyHH0 kwjMd88/WxRUZbyRyp7xvUf02OL3TO4+6ocV84/gXdwz/lGfh4+xUfy/Rub+SX8UmdsHllM09lTvS h42FfN/Q5VaRacGxer8wIqMu6ntWEoWnwUpVs5RyoBooAOQGxaGWM3XqHcOSFnHd5sAqbUISdPcMh REPDbtTw==; Received: from 089144213167.atnat0022.highway.a1.net ([89.144.213.167] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1giz0v-0002Is-AA; Mon, 14 Jan 2019 09:58:38 +0000 From: Christoph Hellwig To: Ulf Hansson Cc: Russell King , Nicolas Pitre , Aaro Koskinen , Ben Dooks , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/11] mmc: sh_mmcif: handle chained sglists Date: Mon, 14 Jan 2019 10:58:02 +0100 Message-Id: <20190114095804.27978-10-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114095804.27978-1-hch@lst.de> References: <20190114095804.27978-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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 0d2bbb8943f5..a4116be5ebc7 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 Mon Jan 14 09:58:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10761891 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 96A591515 for ; Mon, 14 Jan 2019 09:59:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8877F28703 for ; Mon, 14 Jan 2019 09:59:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CC7028706; Mon, 14 Jan 2019 09:59:16 +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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CF1428712 for ; Mon, 14 Jan 2019 09:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726936AbfANJ7C (ORCPT ); Mon, 14 Jan 2019 04:59:02 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:32802 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726934AbfANJ7B (ORCPT ); Mon, 14 Jan 2019 04:59:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+xou8RMEFy2bcsKgoqdXLDip0asPY/iH85oHbiBXhd0=; b=oZjOdfDbcaXIe01UZRZTHtVAgG Uzx2SyiLhyKpTtg9OWt/1Oz6lTNzvF6VYKN0J3AaGkjd8dz8Xi1Yy33zcDG2EH7E8LTMtF5dbYvfL zmjfJUirIO/B7ZEqpKAJoEdSHdG4t+mdiZlSf+xuXTkvDCWVsa9fJSXz64F1GbnE90cR/M/bSx0uh 6Dh/jAu14XAFSohCZpYaun+GogH7hdXTYnVy36iNoHz2ocxJwu//HpjI35Hrh9m/REiZHqlWKI+Vg 4BUwT+YTRvACmsMxmrYW0HC6hWd1nwicftXZzkAyFnLaL0ZeyqroxSvT8bmAehAFZxPlZPkvEU3Vc oxbXoUKg==; Received: from 089144213167.atnat0022.highway.a1.net ([89.144.213.167] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1giz0y-0002PT-RF; Mon, 14 Jan 2019 09:58:41 +0000 From: Christoph Hellwig To: Ulf Hansson Cc: Russell King , Nicolas Pitre , Aaro Koskinen , Ben Dooks , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/11] mmc: core: don't use block layer bounce buffers Date: Mon, 14 Jan 2019 10:58:03 +0100 Message-Id: <20190114095804.27978-11-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114095804.27978-1-hch@lst.de> References: <20190114095804.27978-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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 35cc138b096d..26a18b851397 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 Mon Jan 14 09:58:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10761885 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 2C50313B5 for ; Mon, 14 Jan 2019 09:58:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D32D286F7 for ; Mon, 14 Jan 2019 09:58:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FF66286FE; Mon, 14 Jan 2019 09:58: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=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC3D5286F7 for ; Mon, 14 Jan 2019 09:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726899AbfANJ6z (ORCPT ); Mon, 14 Jan 2019 04:58:55 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:60484 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbfANJ6y (ORCPT ); Mon, 14 Jan 2019 04:58:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CIKvEsqambALdGutoiZPpIA5EvIUo191MZXIgS3IRFo=; b=RuUJggtwRqEsqKAnpt5MuTXjKA m5NcC3xAcfuNhjQ19kbCa4w0c9HEf0IVHW5bI+cR0jCSzvBqAn+9jWSObxVGpIqvQMsThj97SdQEB Gq8N8xoYniyiaP1qbbvwl4yuL4BvU1L3MDl2Gdm4g2qPy5ziJKF8xhLGPQts0EAYnITh+3xD/fdqc lD7v9fjjr567xQ9WuJ/VPPecTLKJT4a+VsUrQ1AT3iMkjzYmFy+HDq4VENIV7tLZHq95CaTSiGHpN pNLBVdJZEmqYeoxKLsFZZINfZg1ZNqyopjc0cf2+wUYuwtby2WyRx3QWvd7RQCnP55nDrFobc8yI9 YLhe/bqQ==; Received: from 089144213167.atnat0022.highway.a1.net ([89.144.213.167] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1giz12-0002VI-Iv; Mon, 14 Jan 2019 09:58:45 +0000 From: Christoph Hellwig To: Ulf Hansson Cc: Russell King , Nicolas Pitre , Aaro Koskinen , Ben Dooks , linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/11] dma-mapping: remove dma_max_pfn Date: Mon, 14 Jan 2019 10:58:04 +0100 Message-Id: <20190114095804.27978-12-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190114095804.27978-1-hch@lst.de> References: <20190114095804.27978-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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