On Fri, 28 Jul 2006, Pete Zaitcev wrote: > On Fri, 28 Jul 2006 16:29:57 -0400 (EDT), Alan Stern <[EMAIL PROTECTED]> > wrote: > > > usbmon crashed when I tried using it with dummy-hcd, because it doesn't > > check whether the bus's controller actually does use DMA before trying to > > map the buffer. This patch (as755) fixes it. > > Ewww. This fixes the immediate problem, but not completely, IMHO. > > The problem arises because hcd_buffer_alloc (or any other implementation > of bus->op->buffer_alloc) does not return any indication if they actually > allocated the buffer with dma_buffer_alloc or kmalloc.
Actually they do. If the buffer was allocated using kmalloc then the DMA pointer is set to ~(dma_addr_t) 0. I suppose the patch could have checked for that instead, although it would mean doing a 64-bit operation. > Zero DMA handle > is valid on some platforms. But the code checks for zero DMA _mask_, not zero DMA _handle_. A zero mask unambiguously indicates that the device can't use DMA. > Therefore, your fix replicates the test > made inside hcd_buffer_alloc. But if anyone ever overrides it, we risk > of getting it wrong again. It's not just hcd_buffer_alloc. Look at how hcd_submit_urb calls dma_map_single. > Why do we even have this bus operation method? It's documented in usb.c:usb_buffer_alloc. Obviously the idea is to map a frequently-used DMA buffer just once instead of over and over. Are you asking why the method is per-bus? I don't know; the current implementation doesn't use this feature. Alan Stern ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel