Re: PCI driver confusion

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

 



On 1/6/06, Medeiros Edward M NPRI <MedeirosEM@xxxxxxxxxxxxxxxxx> wrote:
>
>
> Hello,
>
>
>
> I am writing a driver for a PCI data acquisition board for the 2.6 kernel.
> My board has DMA capability and generates an interrupt when it has completed
> a DMA transfer.  Once the data is buffered I want a user-space process to
> perform signal processing operations on the data.  Can anyone offer advice
> on how to accomplish the following?

If your app can block, you can make it block on a read call and send
the data when you get it
If not, then send a SIGURS1 (or some signal) to your app when the DMA
is complete. On recving SIGUSR1, your App should call read, and it
will get the data.


> Obviously in order to do a DMA transfer the board needs the address of a DMA
> destination buffer.  If a user-space process is to access the data this DMA
> buffer must be in user space.  How can I pass a user-space address to my PCI
> driver.  Can a user-space process call a driver function and pass this
> address as an argument?

Unless you are handling very high data traffic through your card (like
a Gbps NIC)... you must first allocate kernel memory and then DMA to
that, and copy from that kernel buffer location to the user space. The
reasons for using kernel buffers for DMA are multiple...

First and Most important - User mem sees ONLY Virtual Addresses which
are translated by the MMU on processor. Hence these Virtual addresses
are different from Physical Addresses which the PCI card sees (since
they are not translated by the Processor's MMU). Besides this, other
issues include

- what if user buffer mem allocated was in High Mem, & ur device is
not high mem capable?
- what if the pages of user buffer were swapped out?

Regards,
Bhanu.

--
The difference between Theory and Practice is more so in Practice than
in Theory.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux