Re: howto provide io memory to PCI card

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Charles Brown wrote:
> Eike,
> 
>    A followup on the pci_alloc_consistent.  Once the hardware has
> deposited data into the buffer, how do I copy out of that buffer into a
> user space buffer? memcpy_fromio? Do I need to ioremap it, first?
> something like;

> > // get memory that is usable by DMA
> > outmem = pci_alloc_consistent(pdev, PAGE_SIZE, &outmem_phys);
> > // tell board about it
> > memcpy_toio(dest + 4, &outmem_phys, sizeof(outmem_phys));

Nope, it's easier: pci_alloc_consistent() will return you 2 addresses: the 
physical one (which you pass to the device) and the "software" one, i.e. what 
the kernel can see. When you notice that your device is finished you call 
dma_sync_single_for_cpu() to make sure will be accessible by your CPU(s) 
(caches and the like need to be noticed) and then you can simply memcpy() from 
your kernel buffer to whereever you like.

Eike

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux