All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gupta, Pekon" <pekon-l0cyMroinI0@public.gmane.org>
To: "Poddar, Sourav" <sourav.poddar-l0cyMroinI0@public.gmane.org>,
	Trent Piepho <tpiepho-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Peter Korsgaard <peter-+2lRwdCCLRT2eFz/2MeuCQ@public.gmane.org>,
	Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	"dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org"
	<dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
	"computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
	<computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: "spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org"
	<spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
	"linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
	<linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	"Balbi, Felipe" <balbi-l0cyMroinI0@public.gmane.org>
Subject: RE: [PATCH 1/3] spi/qspi: Add memory mapped read support.
Date: Fri, 11 Oct 2013 09:30:48 +0000	[thread overview]
Message-ID: <20980858CB6D3A4BAE95CA194937D5E73EA211D8@DBDE04.ent.ti.com> (raw)
In-Reply-To: <52566ACC.1080100-l0cyMroinI0@public.gmane.org>

Hi,

> From: Poddar, Sourav
> > On Thursday 10 October 2013 07:57 AM, Trent Piepho wrote:
> > I've found that the SPI layer adds rather a lot of overhead to SPI
> > transactions.  It appears to come mostly from using another thread to
> > run the queue.  A fast SPI message of a few dozen bytes ends up having
> > more overhead from the SPI layer than the time it takes the driver to
> > do the actual transfer.
> >
> > So memory mapped mode via some kind of SPI hack seems like a bad
> > design.  All the SPI layer overhead and you don't get DMA.  Memory
> > mapped SPI could be a win, but I think you'd need to do it at the MTD
> > layer with a mapping driver that could read the mmapped SPI flash
> > directly.
> Yes, you are correct in all your comments above. I also feel that SPI
> framework
> should be bypassed. But the subject patch is derived based on the
> following points/limitation:
> 
> 1. There is a setup register in QSPI, that need to be filled, as of now
> I am filling it
>      in my driver as a MACRO.
> 
Based on you previous information of set_up_register..
> > What is "set_up_register"?
> > set_up_register is a memory mapped specific register with the
> > following fields:
> > - RCMD (Read command, which is actually the flash read command)
> > - NUmber of Address bytes
> > - Number of dummy bytes
> > - Read type(Single, dual and quad read).
> > - Write command.

set_up_register should be filled from DT not from Macros, as these
value change from NAND device to device, and based on that
populate 'struct m25p' in m25p_probe().Otherwise it might end-up
in similar situation as in fsl_spinor driver.
Refer below as an example.
http://lists.infradead.org/pipermail/linux-mtd/2013-September/048552.html



> 2. Controller repsonds to memory mapped read for read opcodes,
>  so during the read path we should tell the controller to switch to
>  memory mapped port.
> 
As you would be know from DT when to enable MMODE, so you  can
actually make MM_MODE as your *default mode*. And only when
SPI framework is used you selectively switch to SPI_MODE and
revert back to MM_MODE while returning.

This way you can use memcpy() or dma_copy() directly in flash driver
like m25p80.c, and avoid getting SPI generic framework delays.
So, it should be like this..

/* Make MM_MODE your default mode in controller driver */
qspi_driver.c: configure_qspi_controller(mode) {
if (mode == MM_MODE)
	- do all your controller configurations for MM_MODE
	- do all OPCODE selections for MM_MODE
}

qspi_controller_probe()
	if (of_mode_property("spi-flash-memory-map") {
		spi->mode |= MM_MODE;
		/* configure_qspi_controller (MM_MODE) */
	} else {
		/* configure_qspi_controller(SPI_MODE) */
	}


/* Case 1: MM_MODE=enabled: Flash driver calls memcpy() */
m25p80.c: m25p80_quad_read() {
	if (flash->mmap_read)
		/* controller is already in MM_MODE by default */
		memcpy(*from, *to, length);
	else
		/* usual call to spi_framework */
}


/* Case 2: SPI_MODE=enabled: Flash driver follows spi framework */
m25p80.c: m25p80_quad_read() {
	if (flash->mmap_read)
		/* ignored */
	else
		spi_add_message_to_tail();
}	

qspi_driver.c: prepare_transfer_hardware()
	if (spi->mode & MM_MODE) {
		/* controller is in MM_MODE by default, so switch
		  * to controller to SPI_MODE */
		configure_qspi_controller (SPI_MODE);
	} else {
		/* controller is already in SPI_MODE always */
	}

qspi_driver.c: transfer_one_message ()
	if (spi->mode & MM_MODE) {
		/* controller was switched to SPI_MODE in
		* prepare_transfer_hardware(),so revert back
		  * back to MM_MODE */
		configure_qspi_controller (MM_MODE);
	} else {
		/* controller is already in SPI_MODE always*/
	}
}

*Important*
But you need to be careful, because  you need to synchronize
with kthread_worker running inside SPI generic framework.
So, lock your spi_controller while doing MMODE accesses.
else you might end up in situation where a starving kthead_worker
suddenly woke-up  and changed your configurations from MMODE to
SPI_MODE in between ongoing memcpy() or dma_cpy().

(Request David W, and Mark B to please review this proposal
 based on m25p80.c and SPI generic framework, as I may be
 missing some understanding here).


with regards, pekon

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk

WARNING: multiple messages have this Message-ID (diff)
From: "Gupta, Pekon" <pekon@ti.com>
To: "Poddar, Sourav" <sourav.poddar@ti.com>,
	Trent Piepho <tpiepho@gmail.com>,
	Peter Korsgaard <peter@korsgaard.com>,
	Mark Brown <broonie@kernel.org>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>,
	"computersforpeace@gmail.com" <computersforpeace@gmail.com>
Cc: "spi-devel-general@lists.sourceforge.net"
	<spi-devel-general@lists.sourceforge.net>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"Balbi, Felipe" <balbi@ti.com>
Subject: RE: [PATCH 1/3] spi/qspi: Add memory mapped read support.
Date: Fri, 11 Oct 2013 09:30:48 +0000	[thread overview]
Message-ID: <20980858CB6D3A4BAE95CA194937D5E73EA211D8@DBDE04.ent.ti.com> (raw)
In-Reply-To: <52566ACC.1080100@ti.com>

Hi,

> From: Poddar, Sourav
> > On Thursday 10 October 2013 07:57 AM, Trent Piepho wrote:
> > I've found that the SPI layer adds rather a lot of overhead to SPI
> > transactions.  It appears to come mostly from using another thread to
> > run the queue.  A fast SPI message of a few dozen bytes ends up having
> > more overhead from the SPI layer than the time it takes the driver to
> > do the actual transfer.
> >
> > So memory mapped mode via some kind of SPI hack seems like a bad
> > design.  All the SPI layer overhead and you don't get DMA.  Memory
> > mapped SPI could be a win, but I think you'd need to do it at the MTD
> > layer with a mapping driver that could read the mmapped SPI flash
> > directly.
> Yes, you are correct in all your comments above. I also feel that SPI
> framework
> should be bypassed. But the subject patch is derived based on the
> following points/limitation:
> 
> 1. There is a setup register in QSPI, that need to be filled, as of now
> I am filling it
>      in my driver as a MACRO.
> 
Based on you previous information of set_up_register..
> > What is "set_up_register"?
> > set_up_register is a memory mapped specific register with the
> > following fields:
> > - RCMD (Read command, which is actually the flash read command)
> > - NUmber of Address bytes
> > - Number of dummy bytes
> > - Read type(Single, dual and quad read).
> > - Write command.

set_up_register should be filled from DT not from Macros, as these
value change from NAND device to device, and based on that
populate 'struct m25p' in m25p_probe().Otherwise it might end-up
in similar situation as in fsl_spinor driver.
Refer below as an example.
http://lists.infradead.org/pipermail/linux-mtd/2013-September/048552.html



> 2. Controller repsonds to memory mapped read for read opcodes,
>  so during the read path we should tell the controller to switch to
>  memory mapped port.
> 
As you would be know from DT when to enable MMODE, so you  can
actually make MM_MODE as your *default mode*. And only when
SPI framework is used you selectively switch to SPI_MODE and
revert back to MM_MODE while returning.

This way you can use memcpy() or dma_copy() directly in flash driver
like m25p80.c, and avoid getting SPI generic framework delays.
So, it should be like this..

/* Make MM_MODE your default mode in controller driver */
qspi_driver.c: configure_qspi_controller(mode) {
if (mode == MM_MODE)
	- do all your controller configurations for MM_MODE
	- do all OPCODE selections for MM_MODE
}

qspi_controller_probe()
	if (of_mode_property("spi-flash-memory-map") {
		spi->mode |= MM_MODE;
		/* configure_qspi_controller (MM_MODE) */
	} else {
		/* configure_qspi_controller(SPI_MODE) */
	}


/* Case 1: MM_MODE=enabled: Flash driver calls memcpy() */
m25p80.c: m25p80_quad_read() {
	if (flash->mmap_read)
		/* controller is already in MM_MODE by default */
		memcpy(*from, *to, length);
	else
		/* usual call to spi_framework */
}


/* Case 2: SPI_MODE=enabled: Flash driver follows spi framework */
m25p80.c: m25p80_quad_read() {
	if (flash->mmap_read)
		/* ignored */
	else
		spi_add_message_to_tail();
}	

qspi_driver.c: prepare_transfer_hardware()
	if (spi->mode & MM_MODE) {
		/* controller is in MM_MODE by default, so switch
		  * to controller to SPI_MODE */
		configure_qspi_controller (SPI_MODE);
	} else {
		/* controller is already in SPI_MODE always */
	}

qspi_driver.c: transfer_one_message ()
	if (spi->mode & MM_MODE) {
		/* controller was switched to SPI_MODE in
		* prepare_transfer_hardware(),so revert back
		  * back to MM_MODE */
		configure_qspi_controller (MM_MODE);
	} else {
		/* controller is already in SPI_MODE always*/
	}
}

*Important*
But you need to be careful, because  you need to synchronize
with kthread_worker running inside SPI generic framework.
So, lock your spi_controller while doing MMODE accesses.
else you might end up in situation where a starving kthead_worker
suddenly woke-up  and changed your configurations from MMODE to
SPI_MODE in between ongoing memcpy() or dma_cpy().

(Request David W, and Mark B to please review this proposal
 based on m25p80.c and SPI generic framework, as I may be
 missing some understanding here).


with regards, pekon

  parent reply	other threads:[~2013-10-11  9:30 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
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 [this message]
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=20980858CB6D3A4BAE95CA194937D5E73EA211D8@DBDE04.ent.ti.com \
    --to=pekon-l0cymroini0@public.gmane.org \
    --cc=balbi-l0cyMroinI0@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=dwmw2-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
    --cc=linux-mtd-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=peter-+2lRwdCCLRT2eFz/2MeuCQ@public.gmane.org \
    --cc=sourav.poddar-l0cyMroinI0@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=tpiepho-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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.