Re: howto provide io memory to PCI card

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

 



Eike,

dma_sync_single_for_cpu() takes a 'struct device *', but the device I'm using with pci_alloc_consistent() is a 'struct pci_dev *'. where do I get the 'struct device *'? I looked at the pci_dev structure, and it doesn't seem to have a pertinent member i can use. Should I just declare one locally?

  thanks for helping me through this.

--CB


Rolf Eike Beer wrote:
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

-
This message is intended only for the addressee and may contain information that is company confidential or privileged. Any technical data in this message may be exported only in accordance with the U.S. International Traffic in Arms Regulations (22 CFR Parts 120-130) or the Export Administration Regulations (15 CFR Parts 730-774). Unauthorized use is strictly prohibited and may be unlawful. If you are not the intended recipient, or the person responsible for delivering to the intended recipient, you should not read, copy, disclose or otherwise use this message. If you have received this email in error, please delete it, and advise the sender immediately. - --
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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