On May 13, 2013, at 1:53 AM, satish kondapalli <[email protected]> wrote:
> Thanks Andrew,
>
> I did a simple experiment on Dellr720 server for allocating PCIe DMA capable
> memory. This server has 64GB of physical memory.
>
> First experiment:
> --------------------------
>
> In option ROM driver start function, i tried allocating different sizes of
> memory allocation ( from 128MB to 4GB of memory) with PCI AllocateBuffer and
> Map function. Driver successfully allocated and maped up to 2GB. But It
> failed to allocate 3GB of memory.
>
> Attached the driver source code file.
>
> Here is my question:
> 1) Why i am not able to allocate more than 3GB of memory eventhough system
> has 64GB of physical memory?
>
Don't know. Don't care. Depending on the amount of DMA capable memory being
returned makes your drive non-conformant to UEFI.
> In all mapping requests the resulting NumberOfBytes actually mapped may be
> less than the requested amount. In this case, the DMA operation will have to
> be broken up into smaller chunks. The Map() function will map as much of the
> DMA operation as it can at one time. The caller may have to loop on Map() and
> Unmap() in order to complete a large DMA transfer.
Thanks,
Andrew Fish
>
> Thanks
> Sateesh
>
>
>
> On Thu, May 9, 2013 at 10:07 PM, Andrew Fish <[email protected]> wrote:
>
> On May 9, 2013, at 6:50 AM, satish kondapalli <[email protected]> wrote:
>
> > Hi,
> >
> > I have DellR720 server with 16GB of physical Memory. I am testing the
> > option ROM driver on this server and my driver is executed successfully.
> > But while booting Linux from hard disk it failed with the following error
> > message on screen
> > "can not allocate memory Failed to allocate scratch mem!".
> >
> > If i remove my card from server its booted fine.
> >
> > Here is my question:
> > 1) In UEFI, is there any memory allocation size restriction?(In my driver i
> > allocated EfiBootServicesData memory.)
> > 2) is it possible to allocate 4GB of pcie DMA capable memory? In my case it
> > failed for 64MB.
>
> The only legal way to allocate a DMA buffer is to use
> EFI_PCI_IO_PROTOCOL.AllocateBuffer() and then call
> EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Map() with an Operation like
> EfiPciOperationBusMasterCommonBuffer64.
>
>
> > 3) if i want a 4GB of PCIe DMA capable memory how to allocate?
> >
>
>
> 13.4 EFI PCI I/O Protocol - EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.Map()
>
> Bus master operations that require both read and write access or require
> multiple host device interactions within the same mapped region must use
> EfiPciOperation- BusMasterCommonBuffer or
> EfiPciOperationBusMasterCommonBuffer64. However, only memory allocated via
> the AllocateBuffer() interface can be mapped for this type of operation.
>
> In all mapping requests the resulting NumberOfBytes actually mapped may be
> less than the requested amount. In this case, the DMA operation will have to
> be broken up into smaller chunks. The Map() function will map as much of the
> DMA operation as it can at one time. The caller may have to loop on Map() and
> Unmap() in order to complete a large DMA transfer.
>
>
> Note: If you map as EfiPciOperationBusMasterCommonBuffer or
> EfiPciOperationBusMasterCommonBuffer64 you don't need to Map() and Unmap() on
> each DMA transfer.
>
> Thanks,
>
> Andrew Fish
>
> PS DMA coherency is for the most part handled in hardware on a PC so not
> following the rules may appear to work. But if you port that driver to ARM it
> will fail horribly. Not to mention a massively parallel high end X64 system
> could fail too if you don't follow the rules.
>
> PPS Don't assume that the address of the DMA buffer is the same from the CPU
> and PCI perspective. The PCI card needs to use DeviceAddress, and it does not
> have to be the same as the HostAddress. The EFI DMA flows our outlined in13.2
> PCI Root Bridge I/O Protocol:
>
> DMA Bus Master Read Operation
> • Call Map() for EfiPciOperationBusMasterRead or
> EfiPciOperationBusMasterRead64.
> • Program the DMA Bus Master with the DeviceAddress returned by Map().
> • Start the DMA Bus Master.
> • Wait for DMA Bus Master to complete the read operation.
> • Call Unmap().
>
> DMA Bus Master Write Operation
> • Call Map() for EfiPciOperationBusMasterWrite or
> EfiPciOperationBusMasterRead64.
> • Program the DMA Bus Master with the DeviceAddress returned by Map().
> • Start the DMA Bus Master.
> • Wait for DMA Bus Master to complete the write operation.
> • Perform a PCI controller specific read transaction to flush all PCI write
> buffers (See PCI Specification Section 3.2.5.2) .
> • Call Flush().
> • Call Unmap().
>
> DMA Bus Master Common Buffer Operation
> • Call AllocateBuffer() to allocate a common buffer.
> • Call Map() for EfiPciOperationBusMasterCommonBuffer or
> EfiPciOperationBusMasterCommonBuffer64.
> • Program the DMA Bus Master with the DeviceAddress returned by Map().
> • The common buffer can now be accessed equally by the processor and the DMA
> bus master.
> • Call Unmap().
> • Call FreeBuffer().
>
>
> > Thanks
> > Sateesh
> >
> > ------------------------------------------------------------------------------
> > Learn Graph Databases - Download FREE O'Reilly Book
> > "Graph Databases" is the definitive new guide to graph databases and
> > their applications. This 200-page book is written by three acclaimed
> > leaders in the field. The early access version is available now.
> > Download your free book today!
> > http://p.sf.net/sfu/neotech_d2d_may_______________________________________________
> > edk2-devel mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and
> their applications. This 200-page book is written by three acclaimed
> leaders in the field. The early access version is available now.
> Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>
> <pci_SpDrv.c>------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and
> their applications. This 200-page book is written by three acclaimed
> leaders in the field. The early access version is available now.
> Download your free book today!
> http://p.sf.net/sfu/neotech_d2d_may_______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/edk2-devel
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel