Re: Query related to pci_alloc_consistent()

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

 



On Tuesday 27 January 2009 06:55:43 am yogeshwar sonawane wrote:
> We are planning to design a PCIe based card which will function as an
> accelerator.
> Now, there can be more than 1 cards in a node. In some cases, i may
> want to give same input data to both the cards.
> I have stored my input data to one dma'ble buffer. Then i am asking
> both the cards to do READ DMA to that buffer.
> 
> 1) Can this be achievable & How ?

Sure.  In this case, you already have the buffer, so you don't want
pci_alloc_consistent() because that would allocate a new buffer.

You should call pci_map_single(), supplying the device and the buffer.
You can call pci_map_single() for as many devices as you want, using
the same buffer.  If the devices are just reading the buffer, there's
no synchronization between devices to worry about.

> 2) As we discussed, pci_alloc_consistent() may not be helpful. In case
> of streaming mapping ,If I have allocated one kernel buffer(using
> kmalloc or get_free_pages) and mapped it for card 1 using
> pci_map_single, then can I map the
> same buffer at same time for card 2 without any unmapping ?

Yes.  Just call pci_map_single() again using the same buffer but a
different device.  If the devices can write to the buffer, you're
responsible for synchronizing so one device doesn't overwrite another
device's data.  And of course, you have to worry about the lifetimes
of the mappings and the buffer itself.  Each pci_map_single() allocates
IOMMU resources, so be sure each call has a corresponding pci_unmap_single()
to deallocate them.  And make sure the buffer itself is deallocated
after all the mappings are gone.

Bjorn

> On Fri, Jan 23, 2009 at 12:32 AM, Grant Grundler
> <grundler@xxxxxxxxxxxxxxxx> wrote:
> > On Thu, Jan 22, 2009 at 04:56:22PM +0530, yogeshwar sonawane wrote:
> >> Hi all,
> >>
> >> If there are multiple PCIe cards of the same type, e.g. 3 or 4 network
> >> controllers, in a node.
> >> Now, if one allocates a buffer using pci_alloc_consistent() using
> >> pci_dev struct of one of the card.
> >>
> >> 1) Whether that buffer can be used by remaining cards also ?
> >> OR
> >> Whether DMA addresses returned by pci_alloc_consistent() can be used
> >> by all the cards explained in above situation ?
> >
> > What bjorn said.
> >
> >> 2) What will be the case for multiple platforms/architectures ?
> >
> > pci_alloc_consistent() should conform to Documentation/DMA-API.txt
> > and Documentation/DMA-mapping.txt. This is true for any platform or
> > architecture.
> >
> > BTW, the latter should be moved to Documentation/PCI....Jesse?
> >
> >
> >> 3) There can be multiple PCIe bridges giving multiple slots on some machines.
> >> What will happen, when above situation is considered in such machines ?
> >
> > What Bjorn said.
> >
> > hth,
> > grant
> >
> 


--
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