All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch] Add spi full duplex mode transfer support
@ 2006-08-30  4:40 Luke Yang
  2006-08-30  4:52 ` [spi-devel-general] " David Brownell
  0 siblings, 1 reply; 5+ messages in thread
From: Luke Yang @ 2006-08-30  4:40 UTC (permalink / raw)
  To: linux-kernel, dbrownell, spi-devel-general

[-- Attachment #1: Type: text/plain, Size: 723 bytes --]

Hi all,

   To enable full duplex mode spi transfer in Blackfin spi master
driver, I need an extra field in spi_transfer structure. Attached the
right format patch.

Signed-off-by: Luke Yang <luke.adi@gmail.com>

 spi.h |    1 +
 1 files changed, 1 insertion(+)

diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index c8bb680..99816eb 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -331,6 +331,7 @@ struct spi_transfer {
        dma_addr_t      rx_dma;

        unsigned        cs_change:1;
+       unsigned        is_duplex:1;
        u8              bits_per_word;
        u16             delay_usecs;
        u32             speed_hz;

-- 
Best regards,
Luke Yang
luke.adi@gmail.com

[-- Attachment #2: spi_full_duplex.patch --]
[-- Type: text/x-patch, Size: 331 bytes --]

diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index c8bb680..99816eb 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -331,6 +331,7 @@ struct spi_transfer {
 	dma_addr_t	rx_dma;
 
 	unsigned	cs_change:1;
+	unsigned        is_duplex:1;
 	u8		bits_per_word;
 	u16		delay_usecs;
 	u32		speed_hz;

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

* Re: [spi-devel-general] [Patch] Add spi full duplex mode transfer support
  2006-08-30  4:40 [Patch] Add spi full duplex mode transfer support Luke Yang
@ 2006-08-30  4:52 ` David Brownell
       [not found]   ` <2e2add590608300337h3e7e806bs69b63b24d73a104c@mail.gmail.com>
  0 siblings, 1 reply; 5+ messages in thread
From: David Brownell @ 2006-08-30  4:52 UTC (permalink / raw)
  To: spi-devel-general; +Cc: Luke Yang, linux-kernel, dbrownell

On Tuesday 29 August 2006 9:40 pm, Luke Yang wrote:
> Hi all,
> 
>    To enable full duplex mode spi transfer in Blackfin spi master
> driver, I need an extra field in spi_transfer structure. Attached the
> right format patch.

I don't understand.  ** ALL ** SPI transfers are full duplex.
If you want half duplex, just don't provide the buffer for the
transfer going in that direction (RX or TX).

Rejected ...


> Signed-off-by: Luke Yang <luke.adi@gmail.com>
> 
>  spi.h |    1 +
>  1 files changed, 1 insertion(+)
> 
> diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
> index c8bb680..99816eb 100644
> --- a/include/linux/spi/spi.h
> +++ b/include/linux/spi/spi.h
> @@ -331,6 +331,7 @@ struct spi_transfer {
>         dma_addr_t      rx_dma;
> 
>         unsigned        cs_change:1;
> +       unsigned        is_duplex:1;
>         u8              bits_per_word;
>         u16             delay_usecs;
>         u32             speed_hz;
> 
> -- 
> Best regards,
> Luke Yang
> luke.adi@gmail.com
> 

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

* Re: [spi-devel-general] [Patch] Add spi full duplex mode transfer support
       [not found]   ` <2e2add590608300337h3e7e806bs69b63b24d73a104c@mail.gmail.com>
@ 2006-08-30 15:35     ` David Brownell
  2006-08-30 15:56     ` Stephen Street
  1 sibling, 0 replies; 5+ messages in thread
From: David Brownell @ 2006-08-30 15:35 UTC (permalink / raw)
  To: spi-devel-general; +Cc: Manish Jaggi, Luke Yang, linux-kernel

On Wednesday 30 August 2006 3:37 am, Manish Jaggi wrote:
> 
> On the same lines can we have a member in spi_transfer structure
> like bUseDMA.

LinuxStronglyAvoidsMixedCaseSymbols, see Documentation/CodingStyle.


> In spi PIO mode for short writes of 2 to 8 words is better.
> And we use DMA for larger writes/reads
> 
> What do u think?

I think that such tradeoffs are best hidden from the upper layer
(protocol) drivers, since they're specific to the hardware and
to how the driver is implemented.  So the lower level (controller)
driver should make such tradeoffs.

It's also a change of $SUBJECT but that's a different issue.  :)

- Dave



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

* Re: [spi-devel-general] [Patch] Add spi full duplex mode transfer support
       [not found]   ` <2e2add590608300337h3e7e806bs69b63b24d73a104c@mail.gmail.com>
  2006-08-30 15:35     ` David Brownell
@ 2006-08-30 15:56     ` Stephen Street
  2006-08-30 16:26       ` David Brownell
  1 sibling, 1 reply; 5+ messages in thread
From: Stephen Street @ 2006-08-30 15:56 UTC (permalink / raw)
  To: Manish Jaggi
  Cc: David Brownell, spi-devel-general, Luke Yang, dbrownell, linux-kernel

On Wed, 2006-08-30 at 16:07 +0530, Manish Jaggi wrote:
> On the same lines can we have a member in spi_transfer structure
> like bUseDMA.
> 
> In spi PIO mode for short writes of 2 to 8 words is better.
> And we use DMA for larger writes/reads
> 
This capability is built into the pxa2xx_spi driver.  

Excerpt from linux/Documentation/spi/pxa2xx:

The pxa2xx_spi driver support both DMA and interrupt driven PIO message
transfers.  The driver defaults to PIO mode and DMA transfers must
enabled by setting the "enable_dma" flag in the "pxa2xx_spi_master"
structure and and ensuring that the "pxa2xx_spi_chip.dma_burst_size"
field is non-zero.  The DMA mode support both coherent and stream based
DMA mappings.

The following logic is used to determine the type of I/O to be used on
a per "spi_transfer" basis:

if !enable_dma or dma_burst_size == 0 then
        always use PIO transfers

if spi_message.is_dma_mapped 
   and rx_dma_buf != 0 and tx_dma_buf != 0 then
        use coherent DMA mode

if rx_buf and tx_buf are aligned on 8 byte boundary then
        use streaming DMA mode

otherwise
        use PIO transfer

By enabling DMA tranfers, clearing the spi_message.is_dma_mapped and
providing transfer buffer NOT aligned on 8 byte boundary forced PIO mode
will transfer buffers aligned on 8 byte boundary forces a DMA mode.

My experiance has shown the most stack allocated transfer buffers are
not 8 byte aligned and thus use PIO mode.

Stephen


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

* Re: [spi-devel-general] [Patch] Add spi full duplex mode transfer support
  2006-08-30 15:56     ` Stephen Street
@ 2006-08-30 16:26       ` David Brownell
  0 siblings, 0 replies; 5+ messages in thread
From: David Brownell @ 2006-08-30 16:26 UTC (permalink / raw)
  To: stephen; +Cc: Manish Jaggi, spi-devel-general, Luke Yang, linux-kernel

On Wednesday 30 August 2006 8:56 am, Stephen Street wrote:

> My experiance has shown the most stack allocated transfer buffers are
> not 8 byte aligned and thus use PIO mode.

Of course, providing a transfer buffer on the stack is nonportable;
it's not DMA-safe (especially on systems with dma-incoherent caches!),
while transfer buffers are required to be DMA-safe so that controller
buffers can choose to use DMA for _all_ transfers if they want.

- Dave



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

end of thread, other threads:[~2006-08-30 16:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-30  4:40 [Patch] Add spi full duplex mode transfer support Luke Yang
2006-08-30  4:52 ` [spi-devel-general] " David Brownell
     [not found]   ` <2e2add590608300337h3e7e806bs69b63b24d73a104c@mail.gmail.com>
2006-08-30 15:35     ` David Brownell
2006-08-30 15:56     ` Stephen Street
2006-08-30 16:26       ` David Brownell

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.