分类: LINUX
2011-09-08 10:29:54
今天做移植的时候,随手记录一下,今天所遇到的问题解决方法。
在linux2.6.34和之前的代码中还可以使用usb_buffer_alloc 和 usb_buffer_free 这两个函数,在2.6.35和之后的内核中
usb_buffer_alloc 和 usb_buffer_free这两个函数已不在使用了,可以用usb_alloc_coherent 和 usb_free_coherent代替。把驱动里分配内存与释放内存释放函数修改就好了,只需要把函数名替换就可以。
这是rename的patch:
USB: rename usb_buffer_alloc() and usb_buffer_free()
For more clearance what the functions actually do,
usb_buffer_alloc() is renamed to usb_alloc_coherent()
usb_buffer_free() is renamed to usb_free_coherent()
They should only be used in code which really needs DMA coherency.
[added compatibility macros so we can convert things easier - gregkh]
Signed-off-by: Daniel Mack
Cc: Alan Stern
Cc: Pedro Ribeiro
Signed-off-by: Greg Kroah-Hartman
说是为了更好的从名字看出这个函数真实做的事情:DMA coherency
linux提供两种方式,来保证使用dma时,内存和硬件cache的一致性:
1.Coherent DMA mapping
When
using this mapping, the kernel ensures that there will be no cache
coherency problems between the memory and the hardware device; this
means that every write operation performed by the CPU on a RAM location
is immediately visible to the hardware device, and vice versa. This type
of mapping is also called "synchronous" or "consistent."
2.Streaming DMA mapping
When
using this mapping, the device driver must take care of cache coherency
problems by using the proper synchronization helper functions. This
type of mapping is also called "asynchronous" or "non-coherent."
如果采用第一种方式的话,就是由kernel来保证一致性,驱动程序是不用考虑的,这种方法的缺点是在某些体系结构上,效率很低;如果采用第二种方式的
话,那么是有驱动程序来保证一致性的,所以当驱动要使用dma来进行数据传输时,必须首先检测内存和硬件cache的一致性,linux提供了这类方法。
原文地址:http://blog.csdn.net/linfeng999/article/details/6410224