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: 10807461 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 1257D1575 for ; Tue, 12 Feb 2019 07:26:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF4102915C for ; Tue, 12 Feb 2019 07:26:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E38DB29933; Tue, 12 Feb 2019 07:26:48 +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 673A62A3CA for ; Tue, 12 Feb 2019 07:26:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728240AbfBLH0G (ORCPT ); Tue, 12 Feb 2019 02:26:06 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:59472 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728229AbfBLH0F (ORCPT ); Tue, 12 Feb 2019 02:26:05 -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=y15lbeGIutmHsSPBlrAfZlKazhuFzHUw19wvliWyyvQ=; b=VD2cWNP+hiFEs1beZcd6rcOZuC 1m6SpQjFm/MrG5c8uaFXbuDAy5SvbWsysQO84y9Z8iLti/HHHu6lQ7ZudNQwGTCwrZnC5rfC/xt10 7oduoOarimYgpg8Anh99bdyvR0wKZ5rhUbptmzkJOUGvlimf86WHe7Roe+anp+/GAnMcYbLtMIfKU VHKApHQFyHk2vYFuFCiVWabxf34g1XcRzDWqfaJDC5PwJ0a54VsTeV02iWW27yXVHXn0SeSoW1zSH pZABb5fg6BtiT8BX7SqgxWUxqRd6M+yPEONPplmPqJzbZJU7i4rxyYRl3uXUt0f3GvxfSFaOpPrpB yONXEI1g==; 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 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/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-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@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..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