linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/2] spi: Add DMA support for ti-qspi
@ 2016-06-08  6:48 Vignesh R
  2016-06-08  6:48 ` [PATCH v4 1/2] spi: Add DMA support for spi_flash_read() Vignesh R
  2016-06-08  6:48 ` [PATCH v4 2/2] spi: spi-ti-qspi: Add DMA support for QSPI mmap read Vignesh R
  0 siblings, 2 replies; 6+ messages in thread
From: Vignesh R @ 2016-06-08  6:48 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, linux-kernel, linux-omap, Vignesh R


This series adds support for DMA during QSPI flash read using memory
mapped mode.

Tested on DRA74 EVM, DRA72 EVM and AM437x SK on linux-next.

v3: https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1160792.html
v2: https://lkml.org/lkml/2016/4/25/187
v1: https://lkml.org/lkml/2016/4/4/855


Vignesh R (2):
  spi: Add DMA support for spi_flash_read()
  spi: spi-ti-qspi: Add DMA support for QSPI mmap read

 drivers/spi/spi-ti-qspi.c | 188 ++++++++++++++++++++++++++++++++++++++++++----
 drivers/spi/spi.c         |  28 +++++++
 include/linux/spi/spi.h   |   4 +
 3 files changed, 207 insertions(+), 13 deletions(-)

-- 
2.8.3

^ permalink raw reply	[flat|nested] 6+ messages in thread
* [PATCH v2 2/3] spi: Add DMA support for spi_flash_read()
@ 2016-04-25  9:44 Vignesh R
  2016-06-08  9:25 ` Applied "spi: Add DMA support for spi_flash_read()" to the spi tree Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Vignesh R @ 2016-04-25  9:44 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi, linux-omap, linux-kernel, Vignesh R

Few SPI devices provide accelerated read interfaces to read from
SPI-NOR flash devices. These hardwares also support DMA to transfer data
from flash to memory either via mem-to-mem DMA or dedicated slave DMA
channels. Hence, add support for DMA in order to improve throughput and
reduce CPU load.
Use spi_map_buf() to get sg table for the buffer and pass it to SPI
driver.

Signed-off-by: Vignesh R <vigneshr@ti.com>
---

v2: use cur_msg_mapped flag to indicate success/failure of spi_map_buf()

 drivers/spi/spi.c       | 14 ++++++++++++++
 include/linux/spi/spi.h |  4 ++++
 2 files changed, 18 insertions(+)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 82126bbe69cf..f98c19addc07 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2725,6 +2725,7 @@ int spi_flash_read(struct spi_device *spi,
 
 {
 	struct spi_master *master = spi->master;
+	struct device *rx_dev = NULL;
 	int ret;
 
 	if ((msg->opcode_nbits == SPI_NBITS_DUAL ||
@@ -2750,9 +2751,22 @@ int spi_flash_read(struct spi_device *spi,
 			return ret;
 		}
 	}
+
 	mutex_lock(&master->bus_lock_mutex);
+	if (master->dma_rx) {
+		rx_dev = master->dma_rx->device->dev;
+		ret = spi_map_buf(master, rx_dev, &msg->rx_sg,
+				  msg->buf, msg->len,
+				  DMA_FROM_DEVICE);
+		if (!ret)
+			msg->cur_msg_mapped = true;
+	}
 	ret = master->spi_flash_read(spi, msg);
+	if (msg->cur_msg_mapped)
+		spi_unmap_buf(master, rx_dev, &msg->rx_sg,
+			      DMA_FROM_DEVICE);
 	mutex_unlock(&master->bus_lock_mutex);
+
 	if (master->auto_runtime_pm)
 		pm_runtime_put(master->dev.parent);
 
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index 857a9a1d82b5..b51ea761b5c8 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -1141,6 +1141,8 @@ static inline ssize_t spi_w8r16be(struct spi_device *spi, u8 cmd)
  * @opcode_nbits: number of lines to send opcode
  * @addr_nbits: number of lines to send address
  * @data_nbits: number of lines for data
+ * @rx_sg: Scatterlist for receive data read from flash
+ * @cur_msg_mapped: message has been mapped for DMA
  */
 struct spi_flash_read_message {
 	void *buf;
@@ -1153,6 +1155,8 @@ struct spi_flash_read_message {
 	u8 opcode_nbits;
 	u8 addr_nbits;
 	u8 data_nbits;
+	struct sg_table rx_sg;
+	bool cur_msg_mapped;
 };
 
 /* SPI core interface for flash read support */
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-06-08 10:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-08  6:48 [PATCH v4 0/2] spi: Add DMA support for ti-qspi Vignesh R
2016-06-08  6:48 ` [PATCH v4 1/2] spi: Add DMA support for spi_flash_read() Vignesh R
2016-06-08 10:00   ` Applied "spi: Add DMA support for spi_flash_read()" to the spi tree Mark Brown
2016-06-08  6:48 ` [PATCH v4 2/2] spi: spi-ti-qspi: Add DMA support for QSPI mmap read Vignesh R
  -- strict thread matches above, loose matches on Subject: below --
2016-04-25  9:44 [PATCH v2 2/3] spi: Add DMA support for spi_flash_read() Vignesh R
2016-06-08  9:25 ` Applied "spi: Add DMA support for spi_flash_read()" to the spi tree Mark Brown
2016-06-08  9:27   ` Vignesh R

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).