Re: asihpi: Need help converting volatile to memory barriers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 22, 2008 at 12:18:18PM +1300, Eliot Blennerhassett wrote:
> Greetings,
> 
> first, the meta-help request:
> Is there another place that I should be making this request? (lkml, kernel 
> newbies, linux driver project etc)?

lkml is best for this.

> Theres quite a bit written about barriers, but most seems to be assuming SMP 
> situation or memory mapped devices. Not much about devices doing DMA.
> I.e I have read Documentation/memory-barriers.txt
> 
> Now the actual question:
> Currently I have a driver that uses "volatile" - heres the relevant source.
> http://hg.alsa-project.org/alsa-driver/file/89222d702376/pci/asihpi/hpi6205.c
> 
> The "volatile" is applied to structures that are either read or written by 
> device DMA.  Certainly the driver in its current state doesn't work without 
> volatile qualifier. (BTW the device doesn't use host interrupts)
> 
> Structures ("interface") used for dma are allocated with dma_alloc_coherent()
> 
> In the following, am I using the barriers correctly?
> 
> 1) Reading something updated by DMA
> 
> volatile struct bus_master_interface *interface;
> while (interface->ack != OK) { 
> 	sleep(a while)  	
> 	[ device changes interface->ack by dma ]
> };
> === after conversion
> struct bus_master_interface *interface;
> while (interface->ack != OK) { 
> 	sleep(a while);
> 	rmb(); 
> };
> 
> Here the volatile or rmb is needed or the loop gets optimised away.

Using rmb() is correct, not volatile, as volatile might not really do
what you are expecting it to do on all versions of gcc and
architectures.

So please remove all instances of volatile, it is not correct to use it
within kernel code.

thanks,

greg k-h
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux