Skip to contentSkip to conversation

Bugs in usb-skeleton.c??? :)

DISCUSSION Sergej Pupykin 3 participants 6 messages Jul 13, 2006

lore
Share & tools
lore
#0 lore raw

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.

#1 lore raw
Quoted 5 lines · Sergej Pupykin

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)

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

#2 lore raw
Quoted 3 lines
Quoted 3 lines

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)

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)

#3 lore raw
Quoted 10 lines · Sergej Pupykin
Quoted 3 lines
Quoted 3 lines

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)

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?

normally yes. HOWEVER....

Quoted 3 lines

I see pci_map_single gives 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

#4 lore raw
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.

#5 lore raw
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.txt file for a description of AvdV> this)

agree

Signature · 1 line
 ml.