mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Ping-Pong Compatible DMA buffer chaining
@ 2005-12-26  6:05 Deven Balani
  2006-01-03  1:08 ` Alan Cox
  0 siblings, 1 reply; 4+ messages in thread
From: Deven Balani @ 2005-12-26  6:05 UTC (permalink / raw)
  To: linux-kernel

Hi All!

I am developing a SATA Driver which is libata-complaint for ARM
platform for linux-2.4 kernels.

But I am facing these issues:
1) The SATA Host Controller supports a DMA Logic which has Ping Pong Buffers.
How Can I allocate a linear contiguous buffer and give it to the
Buffer Descriptors of the Host Controller. I believe consistent alloc
would help me in this regard. But How could I do a chaining of Buffers
in a Ping Pong Scenario which has Buffer Descriptors.
2) The libata is using Scatter-Gather List to send Device Identify
Command. Is it necessary to have a Scatter-Gather List for non-PCI ARM
platforms. Can I bypass this mechanism.

Thanks,
Deven

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

* Re: Ping-Pong Compatible DMA buffer chaining
  2005-12-26  6:05 Ping-Pong Compatible DMA buffer chaining Deven Balani
@ 2006-01-03  1:08 ` Alan Cox
  2006-01-04  5:28   ` Deven Balani
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Cox @ 2006-01-03  1:08 UTC (permalink / raw)
  To: Deven Balani; +Cc: linux-kernel

On Llu, 2005-12-26 at 11:35 +0530, Deven Balani wrote:
> 1) The SATA Host Controller supports a DMA Logic which has Ping Pong Buffers.
> How Can I allocate a linear contiguous buffer and give it to the
> Buffer Descriptors of the Host Controller. I believe consistent alloc
> would help me in this regard. But How could I do a chaining of Buffers
> in a Ping Pong Scenario which has Buffer Descriptors.

Depends entirely on your hardware.

> 2) The libata is using Scatter-Gather List to send Device Identify
> Command. Is it necessary to have a Scatter-Gather List for non-PCI ARM
> platforms. Can I bypass this mechanism.

It is neccessary as the user space virtual memory will be fragmented in
physical space (unless you are using MMUless Linux when it will be far
less fragmented).

If the platform is an MMUless one then you can fill in the host
structure and indicate that you support a maximum scatter gather list
size of one. This will break up I/O's when neccessary to keep within
that limit but this will hurt your performance by causing a lot more
requests on a non MMUless system.

Alan


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

* Re: Ping-Pong Compatible DMA buffer chaining
  2006-01-03  1:08 ` Alan Cox
@ 2006-01-04  5:28   ` Deven Balani
  2006-01-04  8:43     ` Alan Cox
  0 siblings, 1 reply; 4+ messages in thread
From: Deven Balani @ 2006-01-04  5:28 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel

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

Hi Sir,

Basically My hardware is not allowing to do a scatter-gather list.
Might be my next version of Hardware _could_ allow me. So I decided to
come out with a _Work Around_.

please find attached sg_pingpong.txt.

My hardware has two Buffers B0 and B1 for both Tx and Rx path.
I had to fill the first buffer initially and then _continue_ a walk
through the sg list with help of buffer completion interrupts of B0 &
B1.

Can you suggest any inputs for this scenario.

Regards,
Deven

On 1/3/06, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> On Llu, 2005-12-26 at 11:35 +0530, Deven Balani wrote:
> > 1) The SATA Host Controller supports a DMA Logic which has Ping Pong Buffers.
> > How Can I allocate a linear contiguous buffer and give it to the
> > Buffer Descriptors of the Host Controller. I believe consistent alloc
> > would help me in this regard. But How could I do a chaining of Buffers
> > in a Ping Pong Scenario which has Buffer Descriptors.
>
> Depends entirely on your hardware.
>
> > 2) The libata is using Scatter-Gather List to send Device Identify
> > Command. Is it necessary to have a Scatter-Gather List for non-PCI ARM
> > platforms. Can I bypass this mechanism.
>
> It is neccessary as the user space virtual memory will be fragmented in
> physical space (unless you are using MMUless Linux when it will be far
> less fragmented).
>
> If the platform is an MMUless one then you can fill in the host
> structure and indicate that you support a maximum scatter gather list
> size of one. This will break up I/O's when neccessary to keep within
> that limit but this will hurt your performance by causing a lot more
> requests on a non MMUless system.
>
> Alan
>
>



--
"A smile confuses an approaching frown..."

[-- Attachment #2: sg_pingpong.txt --]
[-- Type: text/plain, Size: 1382 bytes --]

For conversion from SG list to ping pong:

Generate new sglist based on original sglist but taking into account MAX_DMA_BUF_SIZE bytes as the maximum per buffer.  This will simplify your continuance logic significantly.

For each entry in Sgentries
   set entry in progress to true
   while entry in progress
      if entry.buffersize larger than MAX_DMA_BUF_SIZE
         Add a new entry to SGentries1 a buffer of MAX_DMA_BUF_SIZE
         Decrement entry.buffersize by MAX_DMA_BUF_SIZE
         Increment entry.pointer by MAX_DMA_BUF_SIZE
      else
         Add a new entry to SGentries1 with a copy of current entry
         set entry in progress to false
   endwhile
endwhile

while more SGentries1 and at least one buffer free
      populate first active buffer with entry
        Remove entry from SGentries1
        toggle active buffer
endwhile

if SGentries1 is not empty
   enable DMA buffer complete interrupt
endif

Start DMA.

In your DMA buffer complete interrupt:

if SGentries1 is not empty
   populate the completed buffer
   activate newly populated buffer
endif
check the active buffer (the other one) to see if it just completed
if this other one just completed
   if Sgentries is not empty
      populate this buffer
   endif
endif
if SGentries1 is STILL not empty at this point
   enable DMA buffer interrupt
else
   disable DMA buffer interrupt
endif 







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

* Re: Ping-Pong Compatible DMA buffer chaining
  2006-01-04  5:28   ` Deven Balani
@ 2006-01-04  8:43     ` Alan Cox
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Cox @ 2006-01-04  8:43 UTC (permalink / raw)
  To: Deven Balani; +Cc: linux-kernel

On Mer, 2006-01-04 at 10:58 +0530, Deven Balani wrote:
> My hardware has two Buffers B0 and B1 for both Tx and Rx path.
> I had to fill the first buffer initially and then _continue_ a walk
> through the sg list with help of buffer completion interrupts of B0 &
> B1.

This looks workable to me. You can possibly also use the max_Sectors
field in the sht to simplify the logic by letting the kernel split the
sg entries before they become too large for your hardware.

Alan


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

end of thread, other threads:[~2006-01-04  8:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-26  6:05 Ping-Pong Compatible DMA buffer chaining Deven Balani
2006-01-03  1:08 ` Alan Cox
2006-01-04  5:28   ` Deven Balani
2006-01-04  8:43     ` Alan Cox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome