[PATCH 3/5] PCI: dwc: Convert eDMA mapping detection to being fully optional

From: Serge Semin
Date: Fri Feb 02 2024 - 11:02:35 EST


The DW eDMA CSRs mapping detection procedure doesn't work for the DW HDMA
controller. Moreover it isn't that easy to distinguish HDMA from eDMA if
the former controller available in place of the later one. Thus seeing DW
HDMA controller has the unrolled CSRs mapping only there is no better
choice but to rely on the HDMA-capable platform drivers having the
DMA-engine mapping format specified. In order to permit that let's convert
the eDMA mapping format auto-detection to being fully optional: execute
the DMA Ctrl-based CSRs mapping auto-detection only if no mapping format
was specific.

Note the DW_PCIE_CAP_EDMA_UNROLL flag semantics also imply the mapping
auto-detection optionality. But it doesn't indicate the type of the
controller. It's merely a fixup for the DW PCIe eDMA controllers which for
some reason don't support the DMA Ctrl-based CSRs mapping auto-detection
procedure (see note regarding the Renesas R-Car S4-8's PCIe). So it can't
be utilized for DW HDMA auto-detection. But after this change is applied
the flag will get to be redundant and will be subject for removal in one
of the subsequent commit.

Signed-off-by: Serge Semin <fancer.lancer@xxxxxxxxx>
---
drivers/pci/controller/dwc/pcie-designware.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 149c7a2a12f2..2243ffeb95b5 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -892,6 +892,14 @@ static int dw_pcie_edma_find_mf(struct dw_pcie *pci)
{
u32 val;

+ /*
+ * The platform drivers can pre-define the DMA controller mapping
+ * format especially if the auto-detection procedure doesn't work for
+ * them. In that case the CSRs base must be specified too.
+ */
+ if (pci->edma.mf != EDMA_MF_EDMA_LEGACY)
+ return pci->edma.reg_base ? 0 : -EINVAL;
+
/*
* Indirect eDMA CSRs access has been completely removed since v5.40a
* thus no space is now reserved for the eDMA channels viewport and
--
2.43.0


--vqp52he5ger5zlrw
Content-Type: text/x-patch; charset=us-ascii
Content-Disposition: attachment;
filename="0004-PCI-dwc-Convert-eDMA-channels-detection-to-being-opt.patch"