Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* RE: buffer producer/consumer sync
@ 2004-03-31  5:02 Gupta, Kshitij
  2004-03-31  7:31 ` Russell King
  0 siblings, 1 reply; 21+ messages in thread
From: Gupta, Kshitij @ 2004-03-31  5:02 UTC (permalink / raw)
  To: 'Russell King'; +Cc: alsa-devel

hi,
	I was just curious to know about by when will we be having a proper
reference driver for ARM .  We are ready to help out from here if there are
any issues.
warm regards
-kshitij

-----Original Message-----
From: Russell King [mailto:rmk@arm.linux.org.uk]On Behalf Of Russell
King
Sent: Tuesday, March 09, 2004 5:17 PM
To: Gupta, Kshitij
Cc: Jaroslav Kysela; alsa-devel@lists.sourceforge.net
Subject: Re: [Alsa-devel] buffer producer/consumer sync


On Tue, Mar 09, 2004 at 05:03:37PM +0530, Gupta, Kshitij wrote:
> 	I was referring to a ARM implementation in the ALSA tree for our
> ALSA driver development on OMAP 1610 (ARM 926)
> sound\arm\sa11xx-uda1341.c.  Just wanted to know if sa11xx-uda1341.c is
also
> affected by this problem.  

sa11xx-uda1341 isn't a good driver to look at - it's very specific to
the iPAQ as it stands.  I've been working on a properly modularised
driver which separates out the PCM DMA engine from the rest of the
code, which in turn makes it a lot easier to add support for different
platforms.  IOW, I've done the job properly.

However, just as the iPAQ people (didn't) work with the rest of the
ARM community when they created their supposed generic sa11xx-uda1341
implementation, the rest of the ARM community didn't work with them
when creating our driver.  And now various people are calling for
sa11xx-uda1341 to be deleted once my driver is merged.  It's good when
communities fragment, isn't it? 8(

However, the problem I've been describing is a problem with the core
ALSA implementation and affects all hardware drivers on ARM, whether
they be PCI, ISA or ARM specific.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 21+ messages in thread
* RE: buffer producer/consumer sync
@ 2004-03-09 11:33 Gupta, Kshitij
  2004-03-09 11:46 ` Russell King
  0 siblings, 1 reply; 21+ messages in thread
From: Gupta, Kshitij @ 2004-03-09 11:33 UTC (permalink / raw)
  To: Gupta, Kshitij, 'Russell King', Jaroslav Kysela; +Cc: alsa-devel

hi,
	I was referring to a ARM implementation in the ALSA tree for our
ALSA driver development on OMAP 1610 (ARM 926)
sound\arm\sa11xx-uda1341.c.  Just wanted to know if sa11xx-uda1341.c is also
affected by this problem.  
regards
-kshitij

-----Original Message-----
From: alsa-devel-admin@lists.sourceforge.net
[mailto:alsa-devel-admin@lists.sourceforge.net]On Behalf Of Gupta,
Kshitij
Sent: Tuesday, March 09, 2004 4:11 PM
To: 'Russell King'; Jaroslav Kysela
Cc: alsa-devel@lists.sourceforge.net
Subject: RE: [Alsa-devel] buffer producer/consumer sync


hi,
	Just for your information we are using OSS PCM emulation.  And let
me also first understand the problem :).  Which I am not able to figure out
yet :(. 
regards
-kshitij

-----Original Message-----
From: Russell King [mailto:rmk@arm.linux.org.uk]On Behalf Of Russell
King
Sent: Tuesday, March 09, 2004 3:48 PM
To: Jaroslav Kysela
Cc: Gupta, Kshitij; alsa-devel@lists.sourceforge.net
Subject: Re: [Alsa-devel] buffer producer/consumer sync


On Tue, Mar 09, 2004 at 10:53:57AM +0100, Jaroslav Kysela wrote:
> On Tue, 9 Mar 2004, Gupta, Kshitij wrote:
> > > Can someone comment on this and guide a little bit to solve this
problem.
> 
> Yes, on ARM platform you might have problem with MMU / cache coherency, 
> because appl_ptr and hw_ptr are mmaped to user space. I observed this 
> behaviour on SA11xx platform, too.
> 
> Russell King already notified us about this problem. See the mail archive 
> for the proper fix of the midlevel code.

There currently doesn't exist a public fix for this yet, so people using
ARM platforms will have to live without ALSA for the time being.
(Actually, you can still use ALSA but you must use OSS PCM emulation.)

As you say, appl_ptr and hw_ptr have cache coherency problems.  However,
a portable and acceptable solution does not exist today to solve this
problem which would be acceptable to ALSA.  The current preferred
solution is to call flush_dcache_page() on the page whenever the kernel
reads and writes such a page - obviously that is too expensive for ALSA.

Therefore, kernel architecture people need to trash this issue out, but
I'm only interested in doing that post-2.6.4, once we've managed to get
the DMA mapping stuff sorted properly.

Unfortunately I'm busy for the next three days with other stuff, so I
won't be able to look at any of this; I doubt 2.6.4 will be out before
Friday morning anyway.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 21+ messages in thread
* RE: buffer producer/consumer sync
@ 2004-03-09 10:40 Gupta, Kshitij
  0 siblings, 0 replies; 21+ messages in thread
From: Gupta, Kshitij @ 2004-03-09 10:40 UTC (permalink / raw)
  To: 'Russell King', Jaroslav Kysela; +Cc: alsa-devel

hi,
	Just for your information we are using OSS PCM emulation.  And let
me also first understand the problem :).  Which I am not able to figure out
yet :(. 
regards
-kshitij

-----Original Message-----
From: Russell King [mailto:rmk@arm.linux.org.uk]On Behalf Of Russell
King
Sent: Tuesday, March 09, 2004 3:48 PM
To: Jaroslav Kysela
Cc: Gupta, Kshitij; alsa-devel@lists.sourceforge.net
Subject: Re: [Alsa-devel] buffer producer/consumer sync


On Tue, Mar 09, 2004 at 10:53:57AM +0100, Jaroslav Kysela wrote:
> On Tue, 9 Mar 2004, Gupta, Kshitij wrote:
> > > Can someone comment on this and guide a little bit to solve this
problem.
> 
> Yes, on ARM platform you might have problem with MMU / cache coherency, 
> because appl_ptr and hw_ptr are mmaped to user space. I observed this 
> behaviour on SA11xx platform, too.
> 
> Russell King already notified us about this problem. See the mail archive 
> for the proper fix of the midlevel code.

There currently doesn't exist a public fix for this yet, so people using
ARM platforms will have to live without ALSA for the time being.
(Actually, you can still use ALSA but you must use OSS PCM emulation.)

As you say, appl_ptr and hw_ptr have cache coherency problems.  However,
a portable and acceptable solution does not exist today to solve this
problem which would be acceptable to ALSA.  The current preferred
solution is to call flush_dcache_page() on the page whenever the kernel
reads and writes such a page - obviously that is too expensive for ALSA.

Therefore, kernel architecture people need to trash this issue out, but
I'm only interested in doing that post-2.6.4, once we've managed to get
the DMA mapping stuff sorted properly.

Unfortunately I'm busy for the next three days with other stuff, so I
won't be able to look at any of this; I doubt 2.6.4 will be out before
Friday morning anyway.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

^ permalink raw reply	[flat|nested] 21+ messages in thread
* buffer producer/consumer sync
@ 2004-03-09  9:51 Gupta, Kshitij
  2004-03-09  9:53 ` Jaroslav Kysela
  0 siblings, 1 reply; 21+ messages in thread
From: Gupta, Kshitij @ 2004-03-09  9:51 UTC (permalink / raw)
  To: alsa-devel

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


> hi ,
> 	While debugging my alsa driver , some observations...
> 
> The flow goes like this
> 
> - cat  test.raw > /dev/pcm
> - Middle layer fills up the buffer (size = period_size).   Why does middle
> layer only fills up period_size ??????
> - ...(open / init etc)
> - Trigger with PLAY command is called
> 	a) audio_dma_process routine is called
> 		This routine starts a dma transfer for a size of period_size
> 	
> 	b) We get a end of transfer interrupt and our callback is called.
> In the callback function we call snd_pcm_period_elapsed to notify that one
> period is finished.  This function causes Trigger to be called again with
> STOP and then START again.  And the reason which I found after much
> debugging is this  :
> 		
> --------------------------------------------------------------------------
> ------------------------------------------------
> 	 if (avail >= runtime->stop_threshold) {
>                 snd_pcm_stop(substream,
>                              runtime->status->state ==
> SNDRV_PCM_STATE_DRAINING ?
>                              SNDRV_PCM_STATE_SETUP :
> SNDRV_PCM_STATE_XRUN);
> 
> this code is a part of snd_pcm_update_hw_ptr_post function in
> sound/core/pcm_lib.c
> --------------------------------------------------------------------------
> ------------------------------------------------
> 
> avail value is coming equal to runtime->stop_threshold and that is why we
> are getting a stop.  A trace of these values is :
> 
> initially 
> 	hw_ptr = 0	appl_ptr = period_size		avail =
> runtime->buffersize    	stop_threshold = runtime->buffersize
> (this is set by default)
> 
> after one DMA transfer 
> 	hw_ptr = period_size	appl_ptr = period_size(still the same value
> ... middle layer should have filled in more data and updated this )
> 	
> 	avail = hw_ptr + runtime->buffersize  - appl_ptr
> 
> 	so again avail = runtime->buffersize  , since hw_ptr is equal to
> appl_ptr.  
> 
> What we analyzed here is that After the DMA transfer starts and before the
> finish of the DMA transfer the alsa middle layer should fill up data from
> application layer (cat command in this context).   So probably DMA
> transfer is happening at a much faster rate than the middle layer can fill
> up more application buffers. 
> 
> Can someone comment on this and guide a little bit to solve this problem.
> 
> warm regards
> -kshitij

[-- Attachment #2: Type: text/html, Size: 4882 bytes --]

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

end of thread, other threads:[~2004-03-31 11:31 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-31  5:02 buffer producer/consumer sync Gupta, Kshitij
2004-03-31  7:31 ` Russell King
2004-03-31  7:44   ` Jaroslav Kysela
2004-03-31  7:53     ` Russell King
2004-03-31  8:10       ` Jaroslav Kysela
2004-03-31  8:11         ` Russell King
2004-03-31  8:29           ` Jaroslav Kysela
2004-03-31  8:53             ` Russell King
2004-03-31  9:07               ` Jaroslav Kysela
2004-03-31  9:10                 ` Russell King
2004-03-31  9:22                   ` Jaroslav Kysela
2004-03-31  9:27                     ` Russell King
2004-03-31 11:31                       ` James Courtier-Dutton
  -- strict thread matches above, loose matches on Subject: below --
2004-03-09 11:33 Gupta, Kshitij
2004-03-09 11:46 ` Russell King
2004-03-09 10:40 Gupta, Kshitij
2004-03-09  9:51 Gupta, Kshitij
2004-03-09  9:53 ` Jaroslav Kysela
2004-03-09 10:18   ` Russell King
2004-03-09 10:23     ` Jaroslav Kysela
2004-03-09 10:43       ` Russell King

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