[PATCH 4/5] PCI: dwc: Convert eDMA channels detection to being optional

From: Serge Semin
Date: Fri Feb 02 2024 - 12:12:46 EST


DW HDMA controller channels can't be auto-detected. Thus there is no way
but to rely on the HDMA-capable platform drivers having the number of
channels specified. In order to permit that convert the
dw_pcie_edma_find_chan() method to executing the DMA Ctrl CSR-based number
of channels detection procedure only if no channels amount was specified,
otherwise just sanity check the specified values.

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

diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 2243ffeb95b5..4d53a71ab1b4 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -933,12 +933,20 @@ static int dw_pcie_edma_find_chan(struct dw_pcie *pci)
{
u32 val;

- val = dw_pcie_readl_dma(pci, PCIE_DMA_CTRL);
+ if (!pci->edma.ll_wr_cnt && !pci->edma.ll_rd_cnt) {
+ if (pci->edma.mf == EDMA_MF_HDMA_NATIVE)
+ return -EINVAL;
+
+ val = dw_pcie_readl_dma(pci, PCIE_DMA_CTRL);

- pci->edma.ll_wr_cnt = FIELD_GET(PCIE_DMA_NUM_WR_CHAN, val);
- pci->edma.ll_rd_cnt = FIELD_GET(PCIE_DMA_NUM_RD_CHAN, val);
+ pci->edma.ll_wr_cnt = FIELD_GET(PCIE_DMA_NUM_WR_CHAN, val);
+ pci->edma.ll_rd_cnt = FIELD_GET(PCIE_DMA_NUM_RD_CHAN, val);
+ }

- /* Sanity check the channels count if the mapping was incorrect */
+ /*
+ * Sanity check the channels count in case if the mapping was
+ * incorrectly detected/specified by the glue-driver.
+ */
if (!pci->edma.ll_wr_cnt || pci->edma.ll_wr_cnt > EDMA_MAX_WR_CH ||
!pci->edma.ll_rd_cnt || pci->edma.ll_rd_cnt > EDMA_MAX_RD_CH)
return -EINVAL;
--
2.43.0


--vqp52he5ger5zlrw
Content-Type: text/x-patch; charset=us-ascii
Content-Disposition: attachment;
filename="0005-PCI-dwc-Drop-DW_PCIE_CAP_EDMA_UNROLL-flag.patch"