From: Christoph Hellwig <hch@lst.de>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Russell King <linux@armlinux.org.uk>,
Nicolas Pitre <nico@fluxnic.net>,
Aaro Koskinen <aaro.koskinen@iki.fi>,
Ben Dooks <ben-linux@fluff.org>,
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 [thread overview]
Message-ID: <20190114095804.27978-8-hch@lst.de> (raw)
In-Reply-To: <20190114095804.27978-1-hch@lst.de>
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 <hch@lst.de>
---
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 <linux/module.h>
#include <linux/init.h>
#include <linux/io.h>
+#include <linux/highmem.h>
#include <linux/platform_device.h>
#include <linux/mbus.h>
#include <linux/delay.h>
@@ -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;
}
--
2.20.1
next prev parent reply other threads:[~2019-01-14 9:58 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-14 9:57 remove block layer bounce buffering for MMC Christoph Hellwig
2019-01-14 9:57 ` [PATCH 01/11] mmc: davinci: handle highmem pages Christoph Hellwig
2019-01-14 9:57 ` [PATCH 02/11] mmc: moxart: " Christoph Hellwig
2019-01-14 9:57 ` [PATCH 03/11] mmc: omap: " Christoph Hellwig
2019-01-14 9:57 ` [PATCH 04/11] mmc: omap: handle chained sglists Christoph Hellwig
2019-01-14 9:57 ` [PATCH 05/11] mmc: s3cmci: handle highmem pages Christoph Hellwig
2019-01-30 7:57 ` Ulf Hansson
2019-01-30 8:04 ` Christoph Hellwig
2019-01-30 8:16 ` Ulf Hansson
2019-01-14 9:57 ` [PATCH 06/11] mmc: s3cmci: handle chained sglists Christoph Hellwig
2019-01-14 9:58 ` Christoph Hellwig [this message]
2019-01-14 16:29 ` [PATCH 07/11] mmc: mvsdio: handle highmem pages Nicolas Pitre
2019-01-30 7:55 ` Ulf Hansson
2019-01-14 9:58 ` [PATCH 08/11] mmc: sh_mmcif: " Christoph Hellwig
2019-01-14 9:58 ` [PATCH 09/11] mmc: sh_mmcif: handle chained sglists Christoph Hellwig
2019-01-14 9:58 ` [PATCH 10/11] mmc: core: don't use block layer bounce buffers Christoph Hellwig
2019-01-14 9:58 ` [PATCH 11/11] dma-mapping: remove dma_max_pfn Christoph Hellwig
2019-01-14 10:26 ` remove block layer bounce buffering for MMC Ulf Hansson
2019-01-16 10:24 ` Arnd Bergmann
2019-01-16 13:51 ` Linus Walleij
2019-01-16 13:54 ` Arnd Bergmann
2019-01-14 16:52 ` Robin Murphy
2019-01-14 16:57 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190114095804.27978-8-hch@lst.de \
--to=hch@lst.de \
--cc=aaro.koskinen@iki.fi \
--cc=ben-linux@fluff.org \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=nico@fluxnic.net \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).