All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* uio_dmem_genirq.c and DMA mapping to user space ?
@ 2017-09-12 12:18 Joakim Tjernlund
  2017-09-12 12:37 ` gregkh
  0 siblings, 1 reply; 3+ messages in thread
From: Joakim Tjernlund @ 2017-09-12 12:18 UTC (permalink / raw
  To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org

Hi

I am trying to use the uio_dmem_genirq.c driver for allocating DMA memory to a PCI device
using the uio_pci_generic.c driver.

I got as far as defining an UIO dev containing only Dynamic DMA memory and
now I am stuck.
I can see how DMA memory is allocated when opening the /dev/uio device but I cannot
figure out how to mmap this memory to User space as well so I can share this
memory with the PCI device and my user space driver.

What am I missing?

 Jocke

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: uio_dmem_genirq.c and DMA mapping to user space ?
  2017-09-12 12:18 uio_dmem_genirq.c and DMA mapping to user space ? Joakim Tjernlund
@ 2017-09-12 12:37 ` gregkh
  2017-09-12 14:08   ` Joakim Tjernlund
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2017-09-12 12:37 UTC (permalink / raw
  To: Joakim Tjernlund; +Cc: linux-kernel@vger.kernel.org

On Tue, Sep 12, 2017 at 12:18:27PM +0000, Joakim Tjernlund wrote:
> Hi
> 
> I am trying to use the uio_dmem_genirq.c driver for allocating DMA memory to a PCI device
> using the uio_pci_generic.c driver.
> 
> I got as far as defining an UIO dev containing only Dynamic DMA memory and
> now I am stuck.
> I can see how DMA memory is allocated when opening the /dev/uio device but I cannot
> figure out how to mmap this memory to User space as well so I can share this
> memory with the PCI device and my user space driver.
> 
> What am I missing?

Why can't you call mmap() on the fd you created when you opened
/dev/uio?  What happens when you do that?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: uio_dmem_genirq.c and DMA mapping to user space ?
  2017-09-12 12:37 ` gregkh
@ 2017-09-12 14:08   ` Joakim Tjernlund
  0 siblings, 0 replies; 3+ messages in thread
From: Joakim Tjernlund @ 2017-09-12 14:08 UTC (permalink / raw
  To: gregkh@linuxfoundation.org; +Cc: linux-kernel@vger.kernel.org

On Tue, 2017-09-12 at 05:37 -0700, gregkh@linuxfoundation.org wrote:
> On Tue, Sep 12, 2017 at 12:18:27PM +0000, Joakim Tjernlund wrote:
> > Hi
> > 
> > I am trying to use the uio_dmem_genirq.c driver for allocating DMA memory to a PCI device
> > using the uio_pci_generic.c driver.
> > 
> > I got as far as defining an UIO dev containing only Dynamic DMA memory and
> > now I am stuck.
> > I can see how DMA memory is allocated when opening the /dev/uio device but I cannot
> > figure out how to mmap this memory to User space as well so I can share this
> > memory with the PCI device and my user space driver.
> > 
> > What am I missing?
> 
> Why can't you call mmap() on the fd you created when you opened
> /dev/uio?  What happens when you do that?

Haven't tried that as I figured it had to be something similar as UIO PCI
where you can have several memory regions and therefore must mmap one of
the resource files under sys:
# > pwd
/sys/bus/pci/drivers/uio_pci_generic/0000:01:00.0/uio/uio8/device
leipzig device # cat /sys/devices/platform/ffe250000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/resource
0x0000000c10000000 0x0000000c11ffffff 0x0000000000140204
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
leipzig device # pwd
/sys/bus/pci/drivers/uio_pci_generic/0000:01:00.0/uio/uio8/device
leipzig device # cat resource
0x0000000c10000000 0x0000000c11ffffff 0x0000000000140204
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0x0000000000000000
leipzig device # ls resource*
resource  resource0

Here one opens and mmaps resource0 to get at
 0x0000000c10000000 0x0000000c11ffffff 0x0000000000140204

 Jocke

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-09-12 14:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-12 12:18 uio_dmem_genirq.c and DMA mapping to user space ? Joakim Tjernlund
2017-09-12 12:37 ` gregkh
2017-09-12 14:08   ` Joakim Tjernlund

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.