• Serge Semin's avatar
    PCI: dwc: Introduce dma-ranges property support for RC-host · 8522e17d
    Serge Semin authored
    In accordance with the generic PCIe Root Port DT-bindings the "dma-ranges"
    property has the same format as the "ranges" property. The only difference
    is in their semantics. The "dma-ranges" property describes the PCIe-to-CPU
    memory mapping in opposite to the CPU-to-PCIe mapping of the "ranges"
    property. Even though the DW PCIe controllers are normally equipped with
    the internal Address Translation Unit which inbound and outbound tables
    can be used to implement both properties semantics, it was surprising for
    me to discover that the host-related part of the DW PCIe driver currently
    supports the "ranges" property only while the "dma-ranges" windows are
    just ignored. Having the "dma-ranges" supported in the driver would be
    very handy for the platforms, that don't tolerate the 1:1 CPU-PCIe memory
    mapping and require a customized PCIe memory layout. So let's fix that by
    introducing the "dma-ranges" property support.
    
    First of all we suggest to rename the dw_pcie_prog_inbound_atu() method to
    dw_pcie_prog_ep_inbound_atu() and create a new version of the
    dw_pcie_prog_inbound_atu() function. Thus we'll have two methods for the
    RC and EP controllers respectively in the same way as it has been
    developed for the outbound ATU setup methods.
    
    Secondly aside with the memory window index and type the new
    dw_pcie_prog_inbound_atu() function will accept CPU address, PCIe address
    and size as its arguments. These parameters define the PCIe and CPU memory
    ranges which will be used to setup the respective inbound ATU mapping. The
    passed parameters need to be verified against the ATU ranges constraints
    in the same way as it is done for the outbound ranges.
    
    Finally the DMA-ranges detected for the PCIe controller need to be
    converted to the inbound ATU entries during the host controller
    initialization procedure. It will be done in the framework of the
    dw_pcie_iatu_setup() method. Note before setting the inbound ranges up we
    need to disable all the inbound ATU entries in order to prevent unexpected
    PCIe TLPs translations defined by some third party software like
    bootloaders.
    
    Link: https://lore.kernel.org/r/20221113191301.5526-16-Sergey.Semin@baikalelectronics.ruSigned-off-by: default avatarSerge Semin <Sergey.Semin@baikalelectronics.ru>
    Signed-off-by: default avatarLorenzo Pieralisi <lpieralisi@kernel.org>
    Reviewed-by: default avatarRob Herring <robh@kernel.org>
    Reviewed-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
    8522e17d
pcie-designware.h 15.9 KB