All of lore.kernel.org
 help / color / mirror / Atom feed
From: Serge Semin <fancer.lancer@gmail.com>
To: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: Frank Li <frank.li@nxp.com>,
	"lpieralisi@kernel.org" <lpieralisi@kernel.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"kw@linux.com" <kw@linux.com>,
	"bhelgaas@google.com" <bhelgaas@google.com>,
	"krzk+dt@kernel.org" <krzk+dt@kernel.org>,
	"marek.vasut+renesas@gmail.com" <marek.vasut+renesas@gmail.com>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-renesas-soc@vger.kernel.org" 
	<linux-renesas-soc@vger.kernel.org>
Subject: Re: [EXT] RE: [PATCH v7 5/9] PCI: dwc: Avoid reading a register to detect whether eDMA exists
Date: Wed, 14 Dec 2022 02:11:22 +0300	[thread overview]
Message-ID: <20221213231122.irtewerzhz73dnxl@mobilestation> (raw)
In-Reply-To: <20221212171102.GF20655@thinkpad>

On Mon, Dec 12, 2022 at 10:41:02PM +0530, Manivannan Sadhasivam wrote:
> On Mon, Dec 12, 2022 at 07:56:00PM +0300, Serge Semin wrote:
> > On Mon, Dec 12, 2022 at 06:26:58PM +0530, Manivannan Sadhasivam wrote:
> > > Hi Serge,
> > > 
> > > On Sun, Dec 11, 2022 at 06:28:49PM +0300, Serge Semin wrote:
> > > > Hi Frank
> > > > 
> > > > On Fri, Dec 09, 2022 at 03:52:42PM +0000, Frank Li wrote:
> > > > > Hi Serge,
> > > > > 
> > > > > > From: Serge Semin, Sent: Thursday, December 8, 2022 11:01 PM
> > > > > >
> > > > > > Cc += Frank Li
> > > > > >
> > > > > > @Frank could you have a look at the thread and check the content of
> > > > > > the CSRs dbi+0x8f8 and dbi+0x978 on available to you DW PCIe +EDMA
> > > > > > devices?
> > > > > 
> > > > 
> > > > > [    2.598038] imx6q-pcie 5f010000.pcie_ep: imx_add_pcie_ep: +0x8f8 = 3438302a, +0x978 = 00010001
> > > > 
> > > > Thanks for the reply. So it's 4.80a with the legacy viewport-based
> > > > access. Alas it isn't what we need in this thread. We'll need
> > > > @Mani's respond in order to decide how to fix the auto-detection
> > > > procedure.
> > > > 
> > > 
> > 
> > > Sorry for the late reply!
> > > 
> > > With below diff on the EP:
> > > 
> > > diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
> > > index 6f3805228a18..0eb4d3218738 100644
> > > --- a/drivers/pci/controller/dwc/pcie-designware.c
> > > +++ b/drivers/pci/controller/dwc/pcie-designware.c
> > > @@ -665,6 +665,10 @@ static int dw_pcie_edma_find_chip(struct dw_pcie *pci)
> > >         if (val == 0xFFFFFFFF && pci->edma.reg_base) {
> > >                 pci->edma.mf = EDMA_MF_EDMA_UNROLL;
> > >  
> > > +               dev_info(pci->dev, "%s: +0x8f8 = %08x, +0x978 = %08x\n", __func__,
> > > +                       dw_pcie_readl_dbi(pci, 0x8f8),
> > > +                       dw_pcie_readl_dbi(pci, 0x978));
> > > +
> > >                 val = dw_pcie_readl_dma(pci, PCIE_DMA_CTRL);
> > >         } else if (val != 0xFFFFFFFF) {
> > >                 pci->edma.mf = EDMA_MF_EDMA_LEGACY;
> > > 
> > > 
> > > The output was:
> > > 
> > > qcom-pcie-ep 1c08000.pcie-ep: dw_pcie_edma_find_chip: +0x8f8 = 3533302a, +0x978 = ffffffff
> > > 
> > > Hope this helps!
> > 
> > Great! Thanks. This indeed helps. So it's 5.30a IP-core. Just one
> > quick question. Does that device have eDMA embedded into the DW PCIe
> > controller?
> > 
> 

> Yes it is and it is the test platform I use for eDMA/PCI_EP work.

So the procedure works well for IP-core 5.30a and AFAICS it doesn't
for 5.40a (eDMA viewport-based CSRs are missing in the HW-manual) and
for an unexpected reason in IP-core 5.20a synthesized for Renesas
R-Car Gen4 PCIe. Thus this seems more like a vendor-specific problem,
than a version-specific one since the HW-manual in both 5.20a and
5.30a cases state that the dbi+0x978 register must have FFs if the CSR
doesn't exist. It doesn't exist if the next statement is false:
!CX_PL_REG_DISABLE && CC_DMA_ENABLE && !CC_UNROLL_ENABLE && CC_DEVICE_TYPE!=3
So seeing the R-Car Gen4 PCIe has the unrolled eDMA mapping the
dbi+0x978 registers must contain FFs.

The best solution in this case would be to have a special
capability flag which would force the unrolled eDMA mapping for the
problematic devices. Like this:
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -840,8 +840,14 @@ static int dw_pcie_edma_find_chip(struct dw_pcie *pci)
 	 * Indirect eDMA CSRs access has been completely removed since v5.40a
 	 * thus no space is now reserved for the eDMA channels viewport and
 	 * former DMA CTRL register is no longer fixed to FFs.
+	 *
+	 * Note some devices for unknown reason may have zeros in the eDMA CTRL
+	 * register even though the HW-manual explicitly states there must FFs
+	 * if the unrolled mapping is enabled. For such cases the low-level
+	 * drivers are supposed to manually activate the unrolled mapping to
+	 * bypass the auto-detection procedure.
 	 */
-	if (dw_pcie_ver_is_ge(pci, 540A)) {
+	if (dw_pcie_ver_is_ge(pci, 540A) || dw_pcie_cap_is(pci, EDMA_UNROLL)) {
 		val = 0xFFFFFFFF;
 	else
 		val = dw_pcie_readl_dbi(pci, PCIE_DMA_VIEWPORT_BASE + PCIE_DMA_CTRL);
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -52,7 +52,8 @@
 /* DWC PCIe controller capabilities */
 #define DW_PCIE_CAP_REQ_RES		0
 #define DW_PCIE_CAP_IATU_UNROLL		1
-#define DW_PCIE_CAP_CDM_CHECK		2
+#define DW_PCIE_CAP_EDMA_UNROLL		2
+#define DW_PCIE_CAP_CDM_CHECK		3
 
 #define dw_pcie_cap_is(_pci, _cap) \
 	test_bit(DW_PCIE_CAP_ ## _cap, &(_pci)->caps)

The patch above is based on the updated version of my patchset, which
I'll resubmit for review tomorrow. I'll add @Yoshihiro in Cc-list of
the series.

-Serge(y)

> 
> Thanks,
> Mani
> 
> > -Serge(y)
> > 
> > > 
> > > Thanks,
> > > Mani
> > > 
> > > > -Serge(y)
> > > > 
> > > > > 
> > > > > Frank Li
> > > > > 
> > > > > 
> > > 
> > > -- 
> > > மணிவண்ணன் சதாசிவம்
> 
> -- 
> மணிவண்ணன் சதாசிவம்

  reply	other threads:[~2022-12-13 23:11 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-21 12:43 [PATCH v7 0/9] PCI: rcar-gen4: Add R-Car Gen4 PCIe support Yoshihiro Shimoda
2022-11-21 12:43 ` [PATCH v7 1/9] dt-bindings: PCI: renesas: Add R-Car Gen4 PCIe Host Yoshihiro Shimoda
2022-11-21 12:43 ` [PATCH v7 2/9] dt-bindings: PCI: renesas: Add R-Car Gen4 PCIe Endpoint Yoshihiro Shimoda
2022-11-21 12:43 ` [PATCH v7 3/9] PCI: Add PCI_EXP_LNKCAP_MLW macros Yoshihiro Shimoda
2022-11-21 12:43 ` [PATCH v7 4/9] PCI: designware-ep: Expose dw_pcie_ep_exit() to module Yoshihiro Shimoda
2022-11-21 12:43 ` [PATCH v7 5/9] PCI: dwc: Avoid reading a register to detect whether eDMA exists Yoshihiro Shimoda
2022-11-22 13:55   ` Manivannan Sadhasivam
2022-11-27 23:55     ` Serge Semin
2022-11-28  2:52       ` Yoshihiro Shimoda
2022-11-28 11:59         ` Serge Semin
2022-11-28 12:41           ` Yoshihiro Shimoda
2022-11-28 16:11             ` Serge Semin
2022-11-29  0:21               ` Yoshihiro Shimoda
2022-12-08 12:26                 ` Yoshihiro Shimoda
2022-12-08 14:01                   ` Serge Semin
2022-12-09  7:45                     ` Yoshihiro Shimoda
     [not found]                       ` <HE1PR0401MB23319A9F4AF7630A82249D65881C9@HE1PR0401MB2331.eurprd04.prod.outlook.com>
2022-12-11 15:28                         ` [EXT] " Serge Semin
2022-12-12 12:56                           ` Manivannan Sadhasivam
2022-12-12 16:56                             ` Serge Semin
2022-12-12 17:11                               ` Manivannan Sadhasivam
2022-12-13 23:11                                 ` Serge Semin [this message]
2022-11-21 12:43 ` [PATCH v7 6/9] PCI: dwc: Add support for triggering legacy IRQs Yoshihiro Shimoda
2022-11-21 12:43 ` [PATCH v7 7/9] PCI: rcar-gen4: Add R-Car Gen4 PCIe Host support Yoshihiro Shimoda
2022-11-22 15:04   ` Bjorn Helgaas
2022-11-25 11:37     ` Yoshihiro Shimoda
2022-11-21 12:43 ` [PATCH v7 8/9] PCI: rcar-gen4-ep: Add R-Car Gen4 PCIe Endpoint support Yoshihiro Shimoda
2022-11-21 12:44 ` [PATCH v7 9/9] MAINTAINERS: Update PCI DRIVER FOR RENESAS R-CAR for R-Car Gen4 Yoshihiro Shimoda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221213231122.irtewerzhz73dnxl@mobilestation \
    --to=fancer.lancer@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=frank.li@nxp.com \
    --cc=krzk+dt@kernel.org \
    --cc=kw@linux.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=marek.vasut+renesas@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.