All of lore.kernel.org
 help / color / mirror / Atom feed
From: keita kobayashi <keita.kobayashi.ym@renesas.com>
To: linux-mmc@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Subject: [RFC/PATCH] mmc: tmio: Fix PIO mode with CONFIG_HIGHMEM
Date: Fri, 13 Feb 2015 14:55:47 +0900	[thread overview]
Message-ID: <54DD91E3.3070903@renesas.com> (raw)

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

WARNING: multiple messages have this Message-ID (diff)
From: keita kobayashi <keita.kobayashi.ym@renesas.com>
To: linux-mmc@vger.kernel.org
Cc: linux-sh@vger.kernel.org
Subject: [RFC/PATCH] mmc: tmio: Fix PIO mode with CONFIG_HIGHMEM
Date: Fri, 13 Feb 2015 05:55:47 +0000	[thread overview]
Message-ID: <54DD91E3.3070903@renesas.com> (raw)

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

             reply	other threads:[~2015-02-13  5:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-13  5:55 keita kobayashi [this message]
2015-02-13  5:55 ` [RFC/PATCH] mmc: tmio: Fix PIO mode with CONFIG_HIGHMEM keita kobayashi
2015-03-05 14:57 ` Ulf Hansson
2015-03-05 14:57   ` Ulf Hansson

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=54DD91E3.3070903@renesas.com \
    --to=keita.kobayashi.ym@renesas.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-sh@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.