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;