From: Sourav Poddar <sourav.poddar@ti.com>
To: Mark Brown <broonie@kernel.org>
Cc: Peter Korsgaard <peter@korsgaard.com>,
Trent Piepho <tpiepho@gmail.com>,
balbi@ti.com,
"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
"spi-devel-general@lists.sourceforge.net"
<spi-devel-general@lists.sourceforge.net>,
computersforpeace@gmail.com, dwmw2@infradead.org
Subject: Re: [PATCH 1/3] spi/qspi: Add memory mapped read support.
Date: Tue, 15 Oct 2013 17:19:07 +0530 [thread overview]
Message-ID: <525D2BB3.4020705@ti.com> (raw)
In-Reply-To: <20131015111647.GX2443@sirena.org.uk>
Hi Mark,
On Tuesday 15 October 2013 04:46 PM, Mark Brown wrote:
> On Tue, Oct 15, 2013 at 11:36:47AM +0530, Sourav Poddar wrote:
>
>> But there is one problem which I faced while trying to achieve the
>> above. Currently, spi
>> framework takes care of the runtime clock control part in
>> pump_message(spi.c). So, at the
>> beginning of each transfer, there is a "get_sync" while at the end
>> there is a "put_sync". Now, if
>> I try to do a memcpy in flash and bypass the SPI framework, there is
>> a data abort as the SPI
>> controller clocks are cut.
> Can you fix this by enabling the clock is enabled when you return the
> buffer to the MTD layer and then disabling the clock when the buffer is
> released?
Sorry, I did not get you here. With memory mapped read, there is no
buffer exchanged, everything takes place at the mtd layer only, what gets
exchanged is just the memory mapped address.
Here is the patch which I did on top of the subject patch series, wherein my
controller is in default memory mapped mode, while doing a read in mtd layer
its just does a memcopy and return.
This gives me a data abort as pm_runtime_get_sync is not called on the
qspi controller.
Index: linux/drivers/mtd/devices/m25p80.c
===================================================================
--- linux.orig/drivers/mtd/devices/m25p80.c 2013-10-15
17:08:15.000000000 +0530
+++ linux/drivers/mtd/devices/m25p80.c 2013-10-15 17:08:26.000000000
+0530
@@ -102,7 +102,7 @@
u8 *command;
bool fast_read;
bool quad_read;
- bool mmap_read;
+ void *mmap_read;
};
static inline struct m25p *mtd_to_m25p(struct mtd_info *mtd)
@@ -438,18 +438,21 @@
pr_debug("%s: %s from 0x%08x, len %zd\n", dev_name(&flash->spi->dev),
__func__, (u32)from, len);
printk("enter mtd quad..\n");
+
+ if (flash->mmap_read) {
+ printk("memory map=%x\n", flash->mmap_read);
+ memcpy(buf, flash->mmap_read + from, len);
+ *retlen = len;
+ return 0;
+ }
+
spi_message_init(&m);
memset(t, 0, (sizeof(t)));
- if (flash->mmap_read)
- t[0].memory_map = 1;
t[0].tx_buf = flash->command;
- t[0].len = flash->mmap_read ? from : (m25p_cmdsz(flash) +
(flash->quad_read ? 1 : 0));
- printk("t[0].len=%d\n", t[0].len);
+ t[0].len = (m25p_cmdsz(flash) + (flash->quad_read ? 1 : 0));
spi_message_add_tail(&t[0], &m);
- if (flash->mmap_read)
- t[1].memory_map = 1;
t[1].rx_buf = buf;
t[1].len = len;
t[1].rx_nbits = SPI_NBITS_QUAD;
@@ -476,7 +479,7 @@
spi_sync(flash->spi, &m);
- *retlen = flash->mmap_read ? len : (m.actual_length -
m25p_cmdsz(flash) -
+ *retlen = (m.actual_length - m25p_cmdsz(flash) -
(flash->quad_read ? 1 : 0));
mutex_unlock(&flash->lock);
@@ -1215,7 +1218,7 @@
if (spi->mode && SPI_RX_MMAP) {
printk("memory mapped mode set\n");
- flash->mmap_read = true;
+ flash->mmap_read = spi->memory_map;
}
flash->command = kmalloc(MAX_CMD_SIZE + (flash->fast_read ? 1 :
(flash->quad_read ? 1 : 0)), GFP_KERNEL);
Index: linux/drivers/spi/spi-ti-qspi.c
===================================================================
--- linux.orig/drivers/spi/spi-ti-qspi.c 2013-10-15
17:08:15.000000000 +0530
+++ linux/drivers/spi/spi-ti-qspi.c 2013-10-15 17:15:52.000000000 +0530
@@ -256,6 +256,8 @@
break;
}
ti_qspi_write(qspi, memval, QSPI_SPI_SETUP0_REG);
+ enable_qspi_memory_mapped(qspi);
+ spi->memory_map = qspi->mmap_base;
spi->mode |= SPI_RX_MMAP;
}
@@ -433,22 +435,13 @@
qspi->cmd |= QSPI_FLEN(frame_length);
qspi->cmd |= QSPI_WC_CMD_INT_EN;
+ disable_qspi_memory_mapped(qspi);
+
ti_qspi_write(qspi, QSPI_WC_INT_EN, QSPI_INTR_ENABLE_SET_REG);
mutex_lock(&qspi->list_lock);
list_for_each_entry(t, &m->transfers, transfer_list) {
- if (t->memory_map) {
- if (t->tx_buf) {
- from = t->len;
- continue;
- }
- enable_qspi_memory_mapped(qspi);
- memcpy(t->rx_buf, qspi->mmap_base + from, t->len);
- disable_qspi_memory_mapped(qspi);
- goto out;
- }
-
qspi->cmd |= QSPI_WLEN(t->bits_per_word);
ret = qspi_transfer_msg(qspi, t);
@@ -461,13 +454,13 @@
m->actual_length += t->len;
}
-out:
mutex_unlock(&qspi->list_lock);
m->status = status;
spi_finalize_current_message(master);
ti_qspi_write(qspi, qspi->cmd | QSPI_INVAL, QSPI_SPI_CMD_REG);
+ enable_qspi_memory_mapped(qspi);
return status;
}
@@ -599,6 +592,7 @@
if (res_mmap) {
printk("mmap_available\n");
qspi->mmap_base = devm_ioremap_resource(&pdev->dev, res_mmap);
+ printk("qspi->mmap_base=%x\n", qspi->mmap_base);
if (IS_ERR(qspi->mmap_base)) {
ret = PTR_ERR(qspi->mmap_base);
goto free_master;
Index: linux/include/linux/spi/spi.h
===================================================================
--- linux.orig/include/linux/spi/spi.h 2013-10-15 17:08:15.000000000
+0530
+++ linux/include/linux/spi/spi.h 2013-10-15 17:08:26.000000000 +0530
@@ -94,6 +94,7 @@
#define SPI_RX_MMAP 0x1000 /* Memory mapped read */
u8 bits_per_word;
int irq;
+ void __iomem *memory_map;
void *controller_state;
void *controller_data;
char modalias[SPI_NAME_SIZE];
@@ -556,7 +557,6 @@
u16 delay_usecs;
u32 speed_hz;
- bool memory_map;
struct list_head transfer_list;
};
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: Sourav Poddar <sourav.poddar@ti.com>
To: Mark Brown <broonie@kernel.org>
Cc: Peter Korsgaard <peter@korsgaard.com>,
Trent Piepho <tpiepho@gmail.com>,
balbi@ti.com,
"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
"spi-devel-general@lists.sourceforge.net"
<spi-devel-general@lists.sourceforge.net>,
computersforpeace@gmail.com, dwmw2@infradead.org
Subject: Re: [PATCH 1/3] spi/qspi: Add memory mapped read support.
Date: Tue, 15 Oct 2013 17:19:07 +0530 [thread overview]
Message-ID: <525D2BB3.4020705@ti.com> (raw)
In-Reply-To: <20131015111647.GX2443@sirena.org.uk>
Hi Mark,
On Tuesday 15 October 2013 04:46 PM, Mark Brown wrote:
> On Tue, Oct 15, 2013 at 11:36:47AM +0530, Sourav Poddar wrote:
>
>> But there is one problem which I faced while trying to achieve the
>> above. Currently, spi
>> framework takes care of the runtime clock control part in
>> pump_message(spi.c). So, at the
>> beginning of each transfer, there is a "get_sync" while at the end
>> there is a "put_sync". Now, if
>> I try to do a memcpy in flash and bypass the SPI framework, there is
>> a data abort as the SPI
>> controller clocks are cut.
> Can you fix this by enabling the clock is enabled when you return the
> buffer to the MTD layer and then disabling the clock when the buffer is
> released?
Sorry, I did not get you here. With memory mapped read, there is no
buffer exchanged, everything takes place at the mtd layer only, what gets
exchanged is just the memory mapped address.
Here is the patch which I did on top of the subject patch series, wherein my
controller is in default memory mapped mode, while doing a read in mtd layer
its just does a memcopy and return.
This gives me a data abort as pm_runtime_get_sync is not called on the
qspi controller.
Index: linux/drivers/mtd/devices/m25p80.c
===================================================================
--- linux.orig/drivers/mtd/devices/m25p80.c 2013-10-15
17:08:15.000000000 +0530
+++ linux/drivers/mtd/devices/m25p80.c 2013-10-15 17:08:26.000000000
+0530
@@ -102,7 +102,7 @@
u8 *command;
bool fast_read;
bool quad_read;
- bool mmap_read;
+ void *mmap_read;
};
static inline struct m25p *mtd_to_m25p(struct mtd_info *mtd)
@@ -438,18 +438,21 @@
pr_debug("%s: %s from 0x%08x, len %zd\n", dev_name(&flash->spi->dev),
__func__, (u32)from, len);
printk("enter mtd quad..\n");
+
+ if (flash->mmap_read) {
+ printk("memory map=%x\n", flash->mmap_read);
+ memcpy(buf, flash->mmap_read + from, len);
+ *retlen = len;
+ return 0;
+ }
+
spi_message_init(&m);
memset(t, 0, (sizeof(t)));
- if (flash->mmap_read)
- t[0].memory_map = 1;
t[0].tx_buf = flash->command;
- t[0].len = flash->mmap_read ? from : (m25p_cmdsz(flash) +
(flash->quad_read ? 1 : 0));
- printk("t[0].len=%d\n", t[0].len);
+ t[0].len = (m25p_cmdsz(flash) + (flash->quad_read ? 1 : 0));
spi_message_add_tail(&t[0], &m);
- if (flash->mmap_read)
- t[1].memory_map = 1;
t[1].rx_buf = buf;
t[1].len = len;
t[1].rx_nbits = SPI_NBITS_QUAD;
@@ -476,7 +479,7 @@
spi_sync(flash->spi, &m);
- *retlen = flash->mmap_read ? len : (m.actual_length -
m25p_cmdsz(flash) -
+ *retlen = (m.actual_length - m25p_cmdsz(flash) -
(flash->quad_read ? 1 : 0));
mutex_unlock(&flash->lock);
@@ -1215,7 +1218,7 @@
if (spi->mode && SPI_RX_MMAP) {
printk("memory mapped mode set\n");
- flash->mmap_read = true;
+ flash->mmap_read = spi->memory_map;
}
flash->command = kmalloc(MAX_CMD_SIZE + (flash->fast_read ? 1 :
(flash->quad_read ? 1 : 0)), GFP_KERNEL);
Index: linux/drivers/spi/spi-ti-qspi.c
===================================================================
--- linux.orig/drivers/spi/spi-ti-qspi.c 2013-10-15
17:08:15.000000000 +0530
+++ linux/drivers/spi/spi-ti-qspi.c 2013-10-15 17:15:52.000000000 +0530
@@ -256,6 +256,8 @@
break;
}
ti_qspi_write(qspi, memval, QSPI_SPI_SETUP0_REG);
+ enable_qspi_memory_mapped(qspi);
+ spi->memory_map = qspi->mmap_base;
spi->mode |= SPI_RX_MMAP;
}
@@ -433,22 +435,13 @@
qspi->cmd |= QSPI_FLEN(frame_length);
qspi->cmd |= QSPI_WC_CMD_INT_EN;
+ disable_qspi_memory_mapped(qspi);
+
ti_qspi_write(qspi, QSPI_WC_INT_EN, QSPI_INTR_ENABLE_SET_REG);
mutex_lock(&qspi->list_lock);
list_for_each_entry(t, &m->transfers, transfer_list) {
- if (t->memory_map) {
- if (t->tx_buf) {
- from = t->len;
- continue;
- }
- enable_qspi_memory_mapped(qspi);
- memcpy(t->rx_buf, qspi->mmap_base + from, t->len);
- disable_qspi_memory_mapped(qspi);
- goto out;
- }
-
qspi->cmd |= QSPI_WLEN(t->bits_per_word);
ret = qspi_transfer_msg(qspi, t);
@@ -461,13 +454,13 @@
m->actual_length += t->len;
}
-out:
mutex_unlock(&qspi->list_lock);
m->status = status;
spi_finalize_current_message(master);
ti_qspi_write(qspi, qspi->cmd | QSPI_INVAL, QSPI_SPI_CMD_REG);
+ enable_qspi_memory_mapped(qspi);
return status;
}
@@ -599,6 +592,7 @@
if (res_mmap) {
printk("mmap_available\n");
qspi->mmap_base = devm_ioremap_resource(&pdev->dev, res_mmap);
+ printk("qspi->mmap_base=%x\n", qspi->mmap_base);
if (IS_ERR(qspi->mmap_base)) {
ret = PTR_ERR(qspi->mmap_base);
goto free_master;
Index: linux/include/linux/spi/spi.h
===================================================================
--- linux.orig/include/linux/spi/spi.h 2013-10-15 17:08:15.000000000
+0530
+++ linux/include/linux/spi/spi.h 2013-10-15 17:08:26.000000000 +0530
@@ -94,6 +94,7 @@
#define SPI_RX_MMAP 0x1000 /* Memory mapped read */
u8 bits_per_word;
int irq;
+ void __iomem *memory_map;
void *controller_state;
void *controller_data;
char modalias[SPI_NAME_SIZE];
@@ -556,7 +557,6 @@
u16 delay_usecs;
u32 speed_hz;
- bool memory_map;
struct list_head transfer_list;
};
next prev parent reply other threads:[~2013-10-15 11:49 UTC|newest]
Thread overview: 104+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-09 15:24 [PATCH 0/3]Add quad/memory mapped support for SPI flash Sourav Poddar
2013-10-09 15:24 ` Sourav Poddar
2013-10-09 15:24 ` [PATCH 1/3] spi/qspi: Add memory mapped read support Sourav Poddar
2013-10-09 15:24 ` Sourav Poddar
2013-10-09 16:07 ` Mark Brown
2013-10-09 16:07 ` Mark Brown
[not found] ` <20131009160759.GQ21581-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-10-09 16:54 ` Sourav Poddar
2013-10-09 16:54 ` Sourav Poddar
2013-10-09 17:40 ` Mark Brown
2013-10-09 17:40 ` Mark Brown
2013-10-09 18:15 ` Sourav Poddar
2013-10-09 18:15 ` Sourav Poddar
2013-10-09 18:41 ` Mark Brown
2013-10-09 18:41 ` Mark Brown
[not found] ` <20131009174027.GS21581-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-10-09 19:01 ` Peter Korsgaard
2013-10-09 19:01 ` Peter Korsgaard
2013-10-09 19:36 ` Mark Brown
2013-10-09 19:36 ` Mark Brown
[not found] ` <87hacq1d5k.fsf-D6SC8u56vOOJDPpyT6T3/w@public.gmane.org>
2013-10-10 2:27 ` Trent Piepho
2013-10-10 2:27 ` Trent Piepho
2013-10-10 8:52 ` Sourav Poddar
2013-10-10 8:52 ` Sourav Poddar
2013-10-10 10:14 ` Mark Brown
2013-10-10 10:14 ` Mark Brown
2013-10-10 10:17 ` Sourav Poddar
2013-10-10 10:17 ` Sourav Poddar
2013-10-10 11:08 ` Sourav Poddar
2013-10-10 11:08 ` Sourav Poddar
2013-10-11 10:08 ` Mark Brown
2013-10-11 10:08 ` Mark Brown
2013-10-15 6:06 ` Sourav Poddar
2013-10-15 6:06 ` Sourav Poddar
2013-10-15 11:16 ` Mark Brown
2013-10-15 11:16 ` Mark Brown
2013-10-15 11:49 ` Sourav Poddar [this message]
2013-10-15 11:49 ` Sourav Poddar
2013-10-15 12:46 ` Mark Brown
2013-10-15 12:46 ` Mark Brown
[not found] ` <20131015124656.GM2443-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-10-15 13:23 ` Sourav Poddar
2013-10-15 13:23 ` Sourav Poddar
2013-10-15 15:53 ` Mark Brown
2013-10-15 15:53 ` Mark Brown
[not found] ` <525D41E2.30206-l0cyMroinI0@public.gmane.org>
2013-10-15 15:33 ` Gupta, Pekon
2013-10-15 15:33 ` Gupta, Pekon
2013-10-15 16:01 ` Mark Brown
2013-10-15 16:01 ` Mark Brown
2013-10-15 16:54 ` Gupta, Pekon
2013-10-15 16:54 ` Gupta, Pekon
2013-10-15 18:01 ` Brian Norris
2013-10-15 18:01 ` Brian Norris
2013-10-15 18:10 ` Sourav Poddar
2013-10-15 18:10 ` Sourav Poddar
[not found] ` <20131015180142.GS23337-bU/DPfM3abD4WzifrMjOTkcViWtcw2C0@public.gmane.org>
2013-10-15 18:13 ` Trent Piepho
2013-10-15 18:13 ` Trent Piepho
2013-10-15 18:33 ` Gupta, Pekon
2013-10-15 18:33 ` Gupta, Pekon
2013-10-15 20:52 ` Mark Brown
2013-10-15 20:52 ` Mark Brown
[not found] ` <20131015205254.GX2443-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-10-15 21:03 ` Trent Piepho
2013-10-15 21:03 ` Trent Piepho
2013-10-15 22:10 ` Mark Brown
2013-10-15 22:10 ` Mark Brown
[not found] ` <20980858CB6D3A4BAE95CA194937D5E73EA23640-yXqyApvAXouIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2013-10-17 12:24 ` Sourav Poddar
2013-10-17 12:24 ` Sourav Poddar
2013-10-17 12:38 ` Mark Brown
2013-10-17 12:38 ` Mark Brown
2013-10-17 13:03 ` Gupta, Pekon
2013-10-17 13:03 ` Gupta, Pekon
2013-10-17 23:42 ` Mark Brown
2013-10-18 4:06 ` Sourav Poddar
2013-10-18 5:56 ` Trent Piepho
2013-10-18 6:10 ` Sourav Poddar
2013-10-18 7:27 ` Sourav Poddar
2013-10-18 10:31 ` Mark Brown
2013-10-18 11:48 ` Sourav Poddar
2013-10-18 13:08 ` Mark Brown
2013-10-18 14:47 ` Sourav Poddar
2013-10-15 20:59 ` Mark Brown
2013-10-15 20:59 ` Mark Brown
[not found] ` <52566ACC.1080100-l0cyMroinI0@public.gmane.org>
2013-10-11 9:30 ` Gupta, Pekon
2013-10-11 9:30 ` Gupta, Pekon
2013-10-10 10:10 ` Mark Brown
2013-10-10 10:10 ` Mark Brown
[not found] ` <20131010101052.GF21581-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-10-10 23:53 ` Trent Piepho
2013-10-11 9:59 ` Mark Brown
2013-10-11 9:59 ` Mark Brown
2013-10-09 15:24 ` [PATCHv3 2/3] drivers: mtd: devices: Add quad " Sourav Poddar
2013-10-09 15:24 ` Sourav Poddar
[not found] ` <1381332284-21822-3-git-send-email-sourav.poddar-l0cyMroinI0@public.gmane.org>
2013-10-09 18:15 ` Jagan Teki
2013-10-09 18:15 ` Jagan Teki
[not found] ` <CAD6G_RShZMkSpVzvXWEE0+sDX=pcnf7ndChndgDG5_T4EVL2vQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-10-11 7:10 ` Gupta, Pekon
2013-10-11 7:10 ` Gupta, Pekon
2013-10-24 1:06 ` Brian Norris
2013-10-24 5:44 ` Sourav Poddar
2013-10-24 7:34 ` Brian Norris
2013-10-24 8:44 ` Sourav Poddar
2013-10-24 17:07 ` Brian Norris
2013-10-24 17:55 ` Sourav Poddar
2013-10-09 15:24 ` [RFC/PATCH 3/3] drivers: mtd: devices: Add memory mapped " Sourav Poddar
2013-10-09 15:24 ` Sourav Poddar
2013-10-09 15:45 ` Mark Brown
2013-10-09 15:45 ` Mark Brown
2013-10-24 0:22 ` [PATCH 0/3]Add quad/memory mapped support for SPI flash Brian Norris
2013-10-24 4:51 ` Sourav Poddar
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=525D2BB3.4020705@ti.com \
--to=sourav.poddar@ti.com \
--cc=balbi@ti.com \
--cc=broonie@kernel.org \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=peter@korsgaard.com \
--cc=spi-devel-general@lists.sourceforge.net \
--cc=tpiepho@gmail.com \
/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.