> That helps.  So a buffer used for device input should be allocated
> separately from anything written by the CPU, whereas a buffer used for
> device output can be shared with other data in a buffer allocated by
> kmalloc, but not on the stack.

Judging by this implementation from mips Doing so would be quite inefficient.

extern inline dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr,
                                        size_t size, int direction)
{
        if (direction == PCI_DMA_NONE)
                BUG();

#ifndef CONFIG_COHERENT_IO
        dma_cache_wback_inv((unsigned long)ptr, size);
#endif

        return virt_to_bus(ptr);
}

It is probably best to allocate all buffers seperately.

> How does the DMA driver arrange to flush the CPU's cache before starting a
> DMA out operation?  I didn't notice any particular code to do that in the
> UHCI HCD.

From hcd.c:

        if (!(urb->transfer_flags & URB_NO_DMA_MAP)
                        && hcd->controller->dma_mask) {
                if (usb_pipecontrol (urb->pipe))
                        urb->setup_dma = dma_map_single (
                                        hcd->controller,
                                        urb->setup_packet,
                                        sizeof (struct usb_ctrlrequest),
                                        DMA_TO_DEVICE);
                if (urb->transfer_buffer_length != 0)
                        urb->transfer_dma = dma_map_single (
                                        hcd->controller,
                                        urb->transfer_buffer,
                                        urb->transfer_buffer_length,
                                        usb_pipein (urb->pipe)
                                            ? DMA_FROM_DEVICE
                                            : DMA_TO_DEVICE);

The calls to dma_map_single().

        Regards
                Oliver



-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to