* [RFC/PATCH] mmc: tmio: Fix PIO mode with CONFIG_HIGHMEM
@ 2015-02-13 5:55 keita kobayashi
2015-03-05 14:57 ` Ulf Hansson
0 siblings, 1 reply; 2+ messages in thread
From: keita kobayashi @ 2015-02-13 5:55 UTC (permalink / raw)
To: linux-mmc; +Cc: linux-sh
Current PIO mode occurred kernel panic with CONFIG_HIGHMEM.
This patch fixes the kernel panic by converting the driver
to the sg_miter API.
Reported-by: Cao Minh Hiep <cm-hiep@jinso.co.jp>
Signed-off-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
---
This patch is based on renesas.git / renesas-devel-20150211-v3.19 tag.
drivers/mmc/host/tmio_mmc.h | 1 +
drivers/mmc/host/tmio_mmc_pio.c | 35 ++++++++++++++++-------------------
2 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
index a34ecbe..3092219 100644
--- a/drivers/mmc/host/tmio_mmc.h
+++ b/drivers/mmc/host/tmio_mmc.h
@@ -56,6 +56,7 @@ struct tmio_mmc_host {
struct scatterlist *sg_orig;
unsigned int sg_len;
unsigned int sg_off;
+ struct sg_mapping_iter sg_miter;
struct platform_device *pdev;
struct tmio_mmc_data *pdata;
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index 250bf8c..6d8f363 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -70,17 +70,14 @@ static void tmio_mmc_ack_mmc_irqs(struct tmio_mmc_host *host, u32 i)
static void tmio_mmc_init_sg(struct tmio_mmc_host *host, struct mmc_data *data)
{
- host->sg_len = data->sg_len;
- host->sg_ptr = data->sg;
- host->sg_orig = data->sg;
- host->sg_off = 0;
-}
+ unsigned int flags = SG_MITER_ATOMIC;
-static int tmio_mmc_next_sg(struct tmio_mmc_host *host)
-{
- host->sg_ptr = sg_next(host->sg_ptr);
- host->sg_off = 0;
- return --host->sg_len;
+ if (data->flags & MMC_DATA_READ)
+ flags |= SG_MITER_TO_SG;
+ else
+ flags |= SG_MITER_FROM_SG;
+
+ sg_miter_start(&host->sg_miter, data->sg, data->sg_len, flags);
}
#ifdef CONFIG_MMC_DEBUG
@@ -418,7 +415,7 @@ static void tmio_mmc_transfer_data(struct tmio_mmc_host *host,
static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
{
struct mmc_data *data = host->data;
- void *sg_virt;
+ struct sg_mapping_iter *sg_miter = &host->sg_miter;
unsigned short *buf;
unsigned int count;
unsigned long flags;
@@ -431,10 +428,12 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
return;
}
- sg_virt = tmio_mmc_kmap_atomic(host->sg_ptr, &flags);
- buf = (unsigned short *)(sg_virt + host->sg_off);
+ local_irq_save(flags);
- count = host->sg_ptr->length - host->sg_off;
+ if (!sg_miter_next(sg_miter))
+ return;
+ buf = sg_miter->addr;
+ count = sg_miter->length;
if (count > data->blksz)
count = data->blksz;
@@ -444,12 +443,10 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
/* Transfer the data */
tmio_mmc_transfer_data(host, buf, count);
- host->sg_off += count;
-
- tmio_mmc_kunmap_atomic(host->sg_ptr, &flags, sg_virt);
+ sg_miter->consumed = count;
+ sg_miter_stop(sg_miter);
- if (host->sg_off = host->sg_ptr->length)
- tmio_mmc_next_sg(host);
+ local_irq_restore(flags);
return;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [RFC/PATCH] mmc: tmio: Fix PIO mode with CONFIG_HIGHMEM
2015-02-13 5:55 [RFC/PATCH] mmc: tmio: Fix PIO mode with CONFIG_HIGHMEM keita kobayashi
@ 2015-03-05 14:57 ` Ulf Hansson
0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2015-03-05 14:57 UTC (permalink / raw)
To: keita kobayashi; +Cc: linux-mmc, Linux-sh list
On 13 February 2015 at 06:55, keita kobayashi
<keita.kobayashi.ym@renesas.com> wrote:
> Current PIO mode occurred kernel panic with CONFIG_HIGHMEM.
> This patch fixes the kernel panic by converting the driver
> to the sg_miter API.
>
> Reported-by: Cao Minh Hiep <cm-hiep@jinso.co.jp>
> Signed-off-by: Keita Kobayashi <keita.kobayashi.ym@renesas.com>
Applied, thanks!
Kind regards
Uffe
> ---
> This patch is based on renesas.git / renesas-devel-20150211-v3.19 tag.
>
> drivers/mmc/host/tmio_mmc.h | 1 +
> drivers/mmc/host/tmio_mmc_pio.c | 35 ++++++++++++++++-------------------
> 2 files changed, 17 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h
> index a34ecbe..3092219 100644
> --- a/drivers/mmc/host/tmio_mmc.h
> +++ b/drivers/mmc/host/tmio_mmc.h
> @@ -56,6 +56,7 @@ struct tmio_mmc_host {
> struct scatterlist *sg_orig;
> unsigned int sg_len;
> unsigned int sg_off;
> + struct sg_mapping_iter sg_miter;
>
> struct platform_device *pdev;
> struct tmio_mmc_data *pdata;
> diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
> index 250bf8c..6d8f363 100644
> --- a/drivers/mmc/host/tmio_mmc_pio.c
> +++ b/drivers/mmc/host/tmio_mmc_pio.c
> @@ -70,17 +70,14 @@ static void tmio_mmc_ack_mmc_irqs(struct tmio_mmc_host *host, u32 i)
>
> static void tmio_mmc_init_sg(struct tmio_mmc_host *host, struct mmc_data *data)
> {
> - host->sg_len = data->sg_len;
> - host->sg_ptr = data->sg;
> - host->sg_orig = data->sg;
> - host->sg_off = 0;
> -}
> + unsigned int flags = SG_MITER_ATOMIC;
>
> -static int tmio_mmc_next_sg(struct tmio_mmc_host *host)
> -{
> - host->sg_ptr = sg_next(host->sg_ptr);
> - host->sg_off = 0;
> - return --host->sg_len;
> + if (data->flags & MMC_DATA_READ)
> + flags |= SG_MITER_TO_SG;
> + else
> + flags |= SG_MITER_FROM_SG;
> +
> + sg_miter_start(&host->sg_miter, data->sg, data->sg_len, flags);
> }
>
> #ifdef CONFIG_MMC_DEBUG
> @@ -418,7 +415,7 @@ static void tmio_mmc_transfer_data(struct tmio_mmc_host *host,
> static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
> {
> struct mmc_data *data = host->data;
> - void *sg_virt;
> + struct sg_mapping_iter *sg_miter = &host->sg_miter;
> unsigned short *buf;
> unsigned int count;
> unsigned long flags;
> @@ -431,10 +428,12 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
> return;
> }
>
> - sg_virt = tmio_mmc_kmap_atomic(host->sg_ptr, &flags);
> - buf = (unsigned short *)(sg_virt + host->sg_off);
> + local_irq_save(flags);
>
> - count = host->sg_ptr->length - host->sg_off;
> + if (!sg_miter_next(sg_miter))
> + return;
> + buf = sg_miter->addr;
> + count = sg_miter->length;
> if (count > data->blksz)
> count = data->blksz;
>
> @@ -444,12 +443,10 @@ static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
> /* Transfer the data */
> tmio_mmc_transfer_data(host, buf, count);
>
> - host->sg_off += count;
> -
> - tmio_mmc_kunmap_atomic(host->sg_ptr, &flags, sg_virt);
> + sg_miter->consumed = count;
> + sg_miter_stop(sg_miter);
>
> - if (host->sg_off = host->sg_ptr->length)
> - tmio_mmc_next_sg(host);
> + local_irq_restore(flags);
>
> return;
> }
> --
> 1.7.9.5
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-05 14:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-13 5:55 [RFC/PATCH] mmc: tmio: Fix PIO mode with CONFIG_HIGHMEM keita kobayashi
2015-03-05 14:57 ` Ulf Hansson
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).