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 08/11] mmc: sh_mmcif: handle highmem pages
Date: Mon, 14 Jan 2019 10:58:01 +0100 [thread overview]
Message-ID: <20190114095804.27978-9-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/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);
--
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 ` [PATCH 07/11] mmc: mvsdio: handle highmem pages Christoph Hellwig
2019-01-14 16:29 ` Nicolas Pitre
2019-01-30 7:55 ` Ulf Hansson
2019-01-14 9:58 ` Christoph Hellwig [this message]
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-9-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).