All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] PCI: dwc: Remove the delay from PCIe probe path
@ 2024-01-24  9:25 Ajay Agarwal
  2024-01-24  9:25 ` [PATCH v1 1/2] PCI: dwc: Add helper function to print link status Ajay Agarwal
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ajay Agarwal @ 2024-01-24  9:25 UTC (permalink / raw)
  To: Jingoo Han, Johan Hovold, Manivannan Sadhasivam, Jon Hunter,
	Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
	Bjorn Helgaas, Manu Gautam, Doug Zobel, William McVicker,
	Serge Semin, Robin Murphy
  Cc: linux-pci, Ajay Agarwal

dw_pcie_host_init() waits for the link to come up regardless of
whether there has been an attempt to start the link. The 1 second
wait time is wasteful. Get rid of it if .start_link() is not
defined.

Ajay Agarwal (2):
  PCI: dwc: Add helper function to print link status
  PCI: dwc: Wait for link up only if link is started

 .../pci/controller/dwc/pcie-designware-host.c | 12 +++++++----
 drivers/pci/controller/dwc/pcie-designware.c  | 20 ++++++++++++-------
 drivers/pci/controller/dwc/pcie-designware.h  |  1 +
 3 files changed, 22 insertions(+), 11 deletions(-)

-- 
2.43.0.429.g432eaa2c6b-goog


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v1 1/2] PCI: dwc: Add helper function to print link status
  2024-01-24  9:25 [PATCH v1 0/2] PCI: dwc: Remove the delay from PCIe probe path Ajay Agarwal
@ 2024-01-24  9:25 ` Ajay Agarwal
  2024-01-24  9:25 ` [PATCH v1 2/2] PCI: dwc: Wait for link up only if link is started Ajay Agarwal
  2024-01-29  6:23 ` [PATCH v1 0/2] PCI: dwc: Remove the delay from PCIe probe path Manivannan Sadhasivam
  2 siblings, 0 replies; 5+ messages in thread
From: Ajay Agarwal @ 2024-01-24  9:25 UTC (permalink / raw)
  To: Jingoo Han, Johan Hovold, Manivannan Sadhasivam, Jon Hunter,
	Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
	Bjorn Helgaas, Manu Gautam, Doug Zobel, William McVicker,
	Serge Semin, Robin Murphy
  Cc: linux-pci, Ajay Agarwal

Add helper function `dw_pcie_print_link_status` to print the link
speed and width. This function can be called from various places
to print the link status when desired.

Signed-off-by: Ajay Agarwal <ajayagarwal@google.com>
---
 drivers/pci/controller/dwc/pcie-designware.c | 20 +++++++++++++-------
 drivers/pci/controller/dwc/pcie-designware.h |  1 +
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 250cf7f40b85..c067d2e960cf 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -645,9 +645,20 @@ void dw_pcie_disable_atu(struct dw_pcie *pci, u32 dir, int index)
 	dw_pcie_writel_atu(pci, dir, index, PCIE_ATU_REGION_CTRL2, 0);
 }
 
-int dw_pcie_wait_for_link(struct dw_pcie *pci)
+void dw_pcie_print_link_status(struct dw_pcie *pci)
 {
 	u32 offset, val;
+
+	offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
+	val = dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKSTA);
+
+	dev_info(pci->dev, "PCIe Gen.%u x%u link up\n",
+		 FIELD_GET(PCI_EXP_LNKSTA_CLS, val),
+		 FIELD_GET(PCI_EXP_LNKSTA_NLW, val));
+}
+
+int dw_pcie_wait_for_link(struct dw_pcie *pci)
+{
 	int retries;
 
 	/* Check if the link is up or not */
@@ -663,12 +674,7 @@ int dw_pcie_wait_for_link(struct dw_pcie *pci)
 		return -ETIMEDOUT;
 	}
 
-	offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP);
-	val = dw_pcie_readw_dbi(pci, offset + PCI_EXP_LNKSTA);
-
-	dev_info(pci->dev, "PCIe Gen.%u x%u link up\n",
-		 FIELD_GET(PCI_EXP_LNKSTA_CLS, val),
-		 FIELD_GET(PCI_EXP_LNKSTA_NLW, val));
+	dw_pcie_print_link_status(pci);
 
 	return 0;
 }
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 55ff76e3d384..164214a7219a 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -447,6 +447,7 @@ void dw_pcie_setup(struct dw_pcie *pci);
 void dw_pcie_iatu_detect(struct dw_pcie *pci);
 int dw_pcie_edma_detect(struct dw_pcie *pci);
 void dw_pcie_edma_remove(struct dw_pcie *pci);
+void dw_pcie_print_link_status(struct dw_pcie *pci);
 
 int dw_pcie_suspend_noirq(struct dw_pcie *pci);
 int dw_pcie_resume_noirq(struct dw_pcie *pci);
-- 
2.43.0.429.g432eaa2c6b-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH v1 2/2] PCI: dwc: Wait for link up only if link is started
  2024-01-24  9:25 [PATCH v1 0/2] PCI: dwc: Remove the delay from PCIe probe path Ajay Agarwal
  2024-01-24  9:25 ` [PATCH v1 1/2] PCI: dwc: Add helper function to print link status Ajay Agarwal
@ 2024-01-24  9:25 ` Ajay Agarwal
  2024-01-29  6:26   ` Manivannan Sadhasivam
  2024-01-29  6:23 ` [PATCH v1 0/2] PCI: dwc: Remove the delay from PCIe probe path Manivannan Sadhasivam
  2 siblings, 1 reply; 5+ messages in thread
From: Ajay Agarwal @ 2024-01-24  9:25 UTC (permalink / raw)
  To: Jingoo Han, Johan Hovold, Manivannan Sadhasivam, Jon Hunter,
	Lorenzo Pieralisi, Krzysztof Wilczyński, Rob Herring,
	Bjorn Helgaas, Manu Gautam, Doug Zobel, William McVicker,
	Serge Semin, Robin Murphy
  Cc: linux-pci, Ajay Agarwal

In dw_pcie_host_init(), regardless of whether the link has been
started or not, the code waits for the link to come up. Even in
cases where .start_link() is not defined the code ends up
spinning in a loop for one second. Since in some systems
dw_pcie_host_init() gets called during probe, this one second
loop for each PCIe interface instance ends up extending the boot
time.

Signed-off-by: Ajay Agarwal <ajayagarwal@google.com>
---
This is actually patch v6 for [1] which I have made a part of the
patch series.

v4 [2] was applied, but then reverted [3]. The reason being v4 added
a regression on some products which expect the link to not come
up as a part of the probe. Since v4 returned error from
dw_pcie_wait_for_link check, the probe function of these products
started to fail.

[1] https://lore.kernel.org/all/20240112093006.2832105-1-ajayagarwal@google.com/
[2] https://lore.kernel.org/all/20230412093425.3659088-1-ajayagarwal@google.com/
[3] https://lore.kernel.org/all/20230706082610.26584-1-johan+linaro@kernel.org/

 drivers/pci/controller/dwc/pcie-designware-host.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index 7991f0e179b2..e53132663d1d 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -487,14 +487,18 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
 	if (ret)
 		goto err_remove_edma;
 
-	if (!dw_pcie_link_up(pci)) {
+	if (dw_pcie_link_up(pci)) {
+		dw_pcie_print_link_status(pci);
+	} else {
 		ret = dw_pcie_start_link(pci);
 		if (ret)
 			goto err_remove_edma;
-	}
 
-	/* Ignore errors, the link may come up later */
-	dw_pcie_wait_for_link(pci);
+		if (pci->ops && pci->ops->start_link) {
+			/* Ignore errors, the link may come up later */
+			dw_pcie_wait_for_link(pci);
+		}
+	}
 
 	bridge->sysdata = pp;
 
-- 
2.43.0.429.g432eaa2c6b-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 0/2] PCI: dwc: Remove the delay from PCIe probe path
  2024-01-24  9:25 [PATCH v1 0/2] PCI: dwc: Remove the delay from PCIe probe path Ajay Agarwal
  2024-01-24  9:25 ` [PATCH v1 1/2] PCI: dwc: Add helper function to print link status Ajay Agarwal
  2024-01-24  9:25 ` [PATCH v1 2/2] PCI: dwc: Wait for link up only if link is started Ajay Agarwal
@ 2024-01-29  6:23 ` Manivannan Sadhasivam
  2 siblings, 0 replies; 5+ messages in thread
From: Manivannan Sadhasivam @ 2024-01-29  6:23 UTC (permalink / raw)
  To: Ajay Agarwal
  Cc: Jingoo Han, Johan Hovold, Jon Hunter, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
	Manu Gautam, Doug Zobel, William McVicker, Serge Semin,
	Robin Murphy, linux-pci

On Wed, Jan 24, 2024 at 02:55:31PM +0530, Ajay Agarwal wrote:
> dw_pcie_host_init() waits for the link to come up regardless of
> whether there has been an attempt to start the link. The 1 second
> wait time is wasteful. Get rid of it if .start_link() is not
> defined.
> 

Where is the changelog? Reviewers will first take a look at the cover letter to
understand the series. And this doesn't convey full information (history).

- Mani

> Ajay Agarwal (2):
>   PCI: dwc: Add helper function to print link status
>   PCI: dwc: Wait for link up only if link is started
> 
>  .../pci/controller/dwc/pcie-designware-host.c | 12 +++++++----
>  drivers/pci/controller/dwc/pcie-designware.c  | 20 ++++++++++++-------
>  drivers/pci/controller/dwc/pcie-designware.h  |  1 +
>  3 files changed, 22 insertions(+), 11 deletions(-)
> 
> -- 
> 2.43.0.429.g432eaa2c6b-goog
> 

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 2/2] PCI: dwc: Wait for link up only if link is started
  2024-01-24  9:25 ` [PATCH v1 2/2] PCI: dwc: Wait for link up only if link is started Ajay Agarwal
@ 2024-01-29  6:26   ` Manivannan Sadhasivam
  0 siblings, 0 replies; 5+ messages in thread
From: Manivannan Sadhasivam @ 2024-01-29  6:26 UTC (permalink / raw)
  To: Ajay Agarwal
  Cc: Jingoo Han, Johan Hovold, Jon Hunter, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
	Manu Gautam, Doug Zobel, William McVicker, Serge Semin,
	Robin Murphy, linux-pci

On Wed, Jan 24, 2024 at 02:55:33PM +0530, Ajay Agarwal wrote:
> In dw_pcie_host_init(), regardless of whether the link has been
> started or not, the code waits for the link to come up. Even in
> cases where .start_link() is not defined the code ends up
> spinning in a loop for one second. Since in some systems
> dw_pcie_host_init() gets called during probe, this one second
> loop for each PCIe interface instance ends up extending the boot
> time.
> 
> Signed-off-by: Ajay Agarwal <ajayagarwal@google.com>
> ---
> This is actually patch v6 for [1] which I have made a part of the
> patch series.
> 
> v4 [2] was applied, but then reverted [3]. The reason being v4 added
> a regression on some products which expect the link to not come
> up as a part of the probe. Since v4 returned error from
> dw_pcie_wait_for_link check, the probe function of these products
> started to fail.
> 

What happened to the previous thread [1]? You did not resolve my comment there
and posted a new series. You are not going to make progress if you skip
responding to review comments, sorry.

- Mani

[1] https://lore.kernel.org/linux-pci/20240120143434.GA5405@thinkpad/

> [1] https://lore.kernel.org/all/20240112093006.2832105-1-ajayagarwal@google.com/
> [2] https://lore.kernel.org/all/20230412093425.3659088-1-ajayagarwal@google.com/
> [3] https://lore.kernel.org/all/20230706082610.26584-1-johan+linaro@kernel.org/
> 
>  drivers/pci/controller/dwc/pcie-designware-host.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
> index 7991f0e179b2..e53132663d1d 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-host.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c
> @@ -487,14 +487,18 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
>  	if (ret)
>  		goto err_remove_edma;
>  
> -	if (!dw_pcie_link_up(pci)) {
> +	if (dw_pcie_link_up(pci)) {
> +		dw_pcie_print_link_status(pci);
> +	} else {
>  		ret = dw_pcie_start_link(pci);
>  		if (ret)
>  			goto err_remove_edma;
> -	}
>  
> -	/* Ignore errors, the link may come up later */
> -	dw_pcie_wait_for_link(pci);
> +		if (pci->ops && pci->ops->start_link) {
> +			/* Ignore errors, the link may come up later */
> +			dw_pcie_wait_for_link(pci);
> +		}
> +	}
>  
>  	bridge->sysdata = pp;
>  
> -- 
> 2.43.0.429.g432eaa2c6b-goog
> 

-- 
மணிவண்ணன் சதாசிவம்

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-01-29  6:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-24  9:25 [PATCH v1 0/2] PCI: dwc: Remove the delay from PCIe probe path Ajay Agarwal
2024-01-24  9:25 ` [PATCH v1 1/2] PCI: dwc: Add helper function to print link status Ajay Agarwal
2024-01-24  9:25 ` [PATCH v1 2/2] PCI: dwc: Wait for link up only if link is started Ajay Agarwal
2024-01-29  6:26   ` Manivannan Sadhasivam
2024-01-29  6:23 ` [PATCH v1 0/2] PCI: dwc: Remove the delay from PCIe probe path Manivannan Sadhasivam

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.