Bugs in usb-skeleton.c??? :)
Hello, All!
As I understand, USB subsystem uses urb->transfer_buffer directly with DMA. I see that usb-skeleton.c and (at least) bluez's hci_usb allocates it without GFP_DMA flag. (skeleton with GFP_KERNEL, bluez with GFP_ATOMIC)
(checked versions are 2.4.32 and 2.6.17, ohci only)
Please advise.
Quoted 5 lines · Sergej Pupykin
Hello, All!
As I understand, USB subsystem uses
urb->transfer_bufferdirectly with DMA. I see thatusb-skeleton.cand (at least) bluez'shci_usballocates it withoutGFP_DMAflag. (skeleton withGFP_KERNEL, bluez withGFP_ATOMIC)
Hi,
I think GFP_DMA means something different than that you think it means. GFP_DMA is a bad old hack that means "this is for ISA bus cards to DMA to/from". Since there are no ISA bus USB controllers... the USB code doesn't need to use GFP_DMA.
Greetings,
Arjan van de Ven
Quoted 3 lines
Quoted 3 lines
As I understand, USB subsystem uses
urb->transfer_bufferdirectly with DMA. I see thatusb-skeleton.cand (at least) bluez'shci_usballocates it withoutGFP_DMAflag. (skeleton withGFP_KERNEL, bluez withGFP_ATOMIC)
AvdV> I think GFP_DMA means something different than that you think it means. AvdV> GFP_DMA is a bad old hack that means "this is for ISA bus cards to DMA AvdV> to/from". Since there are no ISA bus USB controllers... the USB code AvdV> doesn't need to use GFP_DMA.
Does kmalloc always allocate pages that can be used in DMA?
I see pci_map_single gives address that incremented later without page boundary checking. Are allocated pages sequented? (usb-ohci.c)
Quoted 10 lines · Sergej Pupykin
Quoted 3 lines
Quoted 3 lines
As I understand, USB subsystem uses
urb->transfer_bufferdirectly with DMA. I see thatusb-skeleton.cand (at least) bluez'shci_usballocates it withoutGFP_DMAflag. (skeleton withGFP_KERNEL, bluez withGFP_ATOMIC)AvdV> I think
GFP_DMAmeans something different than that you think it means. AvdV>GFP_DMAis a bad old hack that means "this is for ISA bus cards to DMA AvdV> to/from". Since there are no ISA bus USB controllers... the USB code AvdV> doesn't need to useGFP_DMA.Does kmalloc always allocate pages that can be used in DMA?
normally yes. HOWEVER....
Quoted 3 lines
I see
pci_map_singlegives address that incremented later without page boundary checking. Are allocated pages sequented? (usb-ohci.c)
..it is nicer to use the DMA allocation API (which internally may fall back to kmalloc etc), while kmalloc may work, it can be quite slow in how it's made to work. So it's just nicer to just use the DMA memory allocators... (see Documentation/DMA-API.txt file for a description of this)
Greetings,
Arjan van de Ven
Quoted 1 line
Quoted 1 line
Does kmalloc always allocate pages that can be used in DMA?
AvdV> normally yes. HOWEVER....
I use sh4 cpu...
AvdV> ..it is nicer to use the DMA allocation API (which internally may fall AvdV> back to kmalloc etc), while kmalloc may work, it can be quite slow in AvdV> how it's made to work. So it's just nicer to just use the DMA memory AvdV> allocators... (see Documentation/DMA-API.txt file for a description of AvdV> this)
Thanks, I'll try it.
Quoted 5 lines · Sergej Pupykin
Quoted 1 line
Quoted 1 line
Does kmalloc always allocate pages that can be used in DMA?
AvdV> normally yes. HOWEVER....
I use sh4 cpu...
on SH-4 traditionally the whole memory space is mapped all the time, so any space returned by kmalloc is DMA-able. (I don't know if this applies to the SH-4A core, too)
Quoted 5 lines
AvdV> ..it is nicer to use the DMA allocation API (which internally may fall AvdV> back to kmalloc etc), while kmalloc may work, it can be quite slow in AvdV> how it's made to work. So it's just nicer to just use the DMA memory AvdV> allocators... (see
Documentation/DMA-API.txtfile for a description of AvdV> this)
agree
Signature · 1 line
ml.