Opened 9 years ago

Closed 6 years ago

#4575 closed defect (obsolete)

problem with DMA addressing on 2.6 bcm47xx

Reported by: anonymous Owned by: developers
Priority: high Milestone:
Component: kernel Version: Trunk
Keywords: Cc: tomas.vanek@…


I tried to stream dvb-t from usb tuner on BCM4710. usb-dvb driver did not send any dvb-t data, like in #3058

Going deeper to OHCI level, debugging showed a dma address in BULK urb is like 0x21230000 instead of proper phys address 0x01230000 - so obviously DMA didn't write to RAM and successful usb read returned zeroed buffer.

The problem origins in drivers/usb/core/hcd.c map_urb_for_dma().
If there is no URB_NO_TRANSFER_DMA_MAP flag the function calls dma_map_single() on the buffer address allocated in a standard way by dma_alloc_coherent(). The problem is the virtual address of a buffer is shifted to uncached area by UNCAC_ADDR(). Subsequent call to virt_to_phys() conversion gives bad result.


  allocates buffer at virt addr 0x81230000 by get_free_pages()
  converts by UNCAC_ADDR() ((addr) - PAGE_OFFSET + UNCAC_BASE)
  and returns

urb->transfer_buffer= 0xA1230000

  calls dma_map_single(,0xA1230000,,)
    calls plat_map_dma_mem()
      calls virt_to_phys(addr)
        returns addr - PAGE_OFFSET + PHYS_OFFSET

urb->transfer_dma= 0x21230000
 - WRONG, should by phys addr 0x01230000

Man page of virt_to_phys() says that addr should be only one directly mapped or allocated. Ok then dma_map_single() or plat_map_dma_mem() should test UNCAC_BASE area and CAC_ADDR() back. Moreover, when uncached area is used, the call to dma_sync() seems superfluous.

The problem may badly influence portability of any usb device driver to BCM47.. (maybe BCM..) arch and is not an easy one to trace (spent two days myself). So please don't close with worksforme until you understand what I reported.

Attachments (1)

920-cache-wround.patch (3.3 KB) - added by acoul <alex at> 9 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 9 years ago by anonymous

Tested on r14382, bcm47xx kernel 2.6.28

comment:2 follow-up: Changed 9 years ago by michu at neophobdotcom

I also have USB issues with my bcm47xx, I use an USB Audio Card and Wifi - and I "hear" actually Wifi traffic on my audio.

check those links:

maybe related?

comment:3 in reply to: ↑ 2 ; follow-up: Changed 9 years ago by anonymous

Replying to michu at neophobdotcom:

If you can hear any correct sound (and you do so) the problem is NOT related.

comment:4 Changed 9 years ago by anonymous

I tested this patch:

--- a/arch/mips/include/asm/mach-generic/dma-coherence.h	2009-02-13 21:50:00.000000000 +0100
+++ b/arch/mips/include/asm/mach-generic/dma-coherence.h	2009-02-13 21:47:36.000000000 +0100
@@ -14,13 +14,7 @@ struct device;
 static inline dma_addr_t plat_map_dma_mem(struct device *dev, void *addr,
 	size_t size)
-#ifdef CONFIG_64BIT
 	return virt_to_phys(addr);
-	// Don't we need here a conversion like 
-	// return KDM_TO_PHYS(addr);
-	return CPHYSADDR(addr);
 static inline dma_addr_t plat_map_dma_mem_page(struct device *dev,

Basic system wokrs OK. dvb-t works but still have some issues - makes system instable.

comment:5 in reply to: ↑ 3 Changed 9 years ago by anonymous

Replying to anonymous:

Replying to michu at neophobdotcom:

If you can hear any correct sound (and you do so) the problem is NOT related.

sound is working fine, i just "hear" for example each ping, if i ping my machine - so i guess its not related...

comment:6 Changed 9 years ago by anonymous

Bingo! Applying #4293 "bcm47xx - kernel and BCM4710A0 cache workarounds" solved system instability. DVB-T now works OK.

comment:7 Changed 9 years ago by anonymous

Sorry I was too fast. System is not stable even with #4293 patch. Just problems are less frequent. Most probably they are related to OHCI DMA writes generally, not to the subject of this ticket.

Changed 9 years ago by acoul <alex at>

comment:9 Changed 9 years ago by acoul <alex at>

please discard the above patch, wrong ticket

comment:10 Changed 6 years ago by nbd

  • Resolution set to obsolete
  • Status changed from new to closed
  • Version set to Trunk

Add Comment

Modify Ticket

as closed .
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.