在移植rt3070驱动的时候编译遇到的问题
现在移植wifi的驱动rt370模块到 mini210 上面 移植的方法和网络上面的差不多 但是在编译的生成模块的过程中,出现函数未定义的状况,usb_buffer_alloc和usb_buffer_free ,没有被定义,原本我以为是没有包含的头文件,后来看网络上面说是 以前的版本内核用这两个函数,我这个内核版本是linux-3.0.8版本的 这两个函数已经被另外两个函数代替了
usb_alloc_coherent和usb_free_coherent 然后把内核源码中的这个两个函数替换 编译就ok了
这是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 daniel@caiaq.de
Cc: Alan Stern stern@rowland.harvard.edu
Cc: Pedro Ribeiro pedrib@gmail.com
Signed-off-by: Greg Kroah-Hartman gregkh@suse.de
说是为了更好的从名字看出这个函数真实做的事情: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提供了这类方法。
我遇到的另一个问题是 编译的时候FATAL: modpost: GPL-incompatible module rt3070ap.ko uses GPL-only symbol '__rcu_read_unlock'
这个问题我查找了好多网站 说是要改内核中的文件 去掉那个GPL认证
If you get this error:
GPL-only symbol__rcu_read
or
GPL-only symbol__rcu_read
when you build ati-drivers on rt-kernel
Solution: Edit kernel/rcupreempt.c. Change
SYMBOL__rcu_read
to
SYMBOL__rcu_read
and
SYMBOL__rcu_read
to
SYMBOL__rcu_read
And rebuild kernel
仿照这个修改了一下 成功了。
