Skip to contentSkip to conversation

PCI: qcom: Skip wait for link up if global IRQ handler is present

PATCH In review Krishna chaitanya chundru 3 participants 5 messages Sep 20, 2024 – Sep 30, 2024

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover PCI: qcom: Skip wait for link up if global IRQ handler is present

In scenarios where a global IRQ handler is available to manage link up interrupts, it may not be necessary to wait for the link to be up during PCI initialization. This change helps in reducing the overall bootup time.

As part of the PCIe link up event, the ICC and OPP values are updated.

---
Changes in v2:
- Updated the bypass_link_up_wait name to linkup_irq & added comment as suggested (mani).
- seperated the icc and opp update patch (mani).
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Krishna chaitanya chundru (2):
PCI: qcom: Skip wait for link up if global IRQ handler is present
PCI: qcom: Update ICC and OPP values during link up event

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

---
base-commit: 9aaeb87ce1e966169a57f53a02ba05b30880ffb8
change-id: 20240911-remove_wait-ad46248dc9f0

Best regards,

Signature · 1 line
Krishna chaitanya chundru <[email protected]>
#1 lore raw

PATCH v2 1/2 PCI: qcom: Skip wait for link up if global IRQ handler is present

In cases where a global IRQ handler is present to manage link up interrupts, it may not be necessary to wait for the link to be up during PCI initialization which optimizes the bootup time.

Move platform_get_irq_byname_optional() above to set linkup_irq before dw_pcie_host_init() as this flag is used in this function only.

---
 drivers/pci/controller/dwc/pcie-designware-host.c | 11 +++++++++--
 drivers/pci/controller/dwc/pcie-designware.h      |  1 +
 drivers/pci/controller/dwc/pcie-qcom.c            |  5 ++++-
 3 files changed, 14 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pcie-designware-host.c +9 -2
index 3e41865c7290..b7d20a1bab0a 100644
@@ -530,8 +530,15 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
 			goto err_remove_edma;
 	}
 
-	/* Ignore errors, the link may come up later */
-	dw_pcie_wait_for_link(pci);
+	/*
+	 * Note: The link up delay is skipped only when a link up IRQ is present.
+	 * This flag should not be used to bypass the link up delay for arbitrary
+	 * reasons.
+	 *
+	 * Ignore errors, the link may come up later.
+	 */
+	if (!pp->linkup_irq)
+		dw_pcie_wait_for_link(pci);
 
 	bridge->sysdata = pp;
 
drivers/pci/controller/dwc/pcie-designware.h +1 -0
index e518f81ea80c..b850f0a74695 100644
@@ -348,6 +348,7 @@ struct dw_pcie_rp {
 	bool			use_atu_msg;
 	int			msg_atu_index;
 	struct resource		*msg_res;
+	bool			linkup_irq;
 };
 
 struct dw_pcie_ep_ops {
drivers/pci/controller/dwc/pcie-qcom.c +4 -1
index 88a98be930e3..905c9154fc65 100644
@@ -1686,6 +1686,10 @@ static int qcom_pcie_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, pcie);
 
+	irq = platform_get_irq_byname_optional(pdev, "global");
+	if (irq > 0)
+		pp->linkup_irq = true;
+
 	ret = dw_pcie_host_init(pp);
 	if (ret) {
 		dev_err(dev, "cannot initialize host\n");
@@ -1699,7 +1703,6 @@ static int qcom_pcie_probe(struct platform_device *pdev)
 		goto err_host_deinit;
 	}
 
-	irq = platform_get_irq_byname_optional(pdev, "global");
 	if (irq > 0) {
 		ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
 						qcom_pcie_global_irq_thread,
Signature · 1 line
2.34.1
#2 lore raw

On Fri, Sep 20, 2024 at 03:47:59PM +0530, Krishna chaitanya chundru wrote:

Subject should be modified to reflect the fact that the link up is skipped in the dwc driver.

PCI: dwc: Skip waiting for link up if vendor drivers can detect Link up event

Quoted 4 lines

In cases where a global IRQ handler is present to manage link up interrupts, it may not be necessary to wait for the link to be up during PCI initialization which optimizes the bootup time.

How about,

"If the vendor drivers can detect the Link up event using mechanisms such as Link up IRQ, then waiting for Link up during probe is not needed. So let's skip waiting for link to be up if the driver supports 'linkup_irq'.

Currently, only Qcom RC driver supports the 'linkup_irq' as it can detect the Link Up event using its own 'global IRQ' interrupt."

Techincally, you could also split the dwc and qcom driver changes into two patches. One adding the option to skip the wait and another making use of it.

Quoted 3 lines

Move platform_get_irq_byname_optional() above to set linkup_irq before dw_pcie_host_init() as this flag is used in this function only.

This is not a valid justification. You are moving it so that the 'pp->linkup_irq' flag is set before calling dw_pcie_host_init() API that waits for the link to be up. Mention it clearly.

Quoted 13 lines
---
 drivers/pci/controller/dwc/pcie-designware-host.c | 11 +++++++++--
 drivers/pci/controller/dwc/pcie-designware.h      |  1 +
 drivers/pci/controller/dwc/pcie-qcom.c            |  5 ++++-
 3 files changed, 14 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pcie-designware-host.c +0 -0
index 3e41865c7290..b7d20a1bab0a 100644
@@ -530,8 +530,15 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
 			goto err_remove_edma;

drivers/pci/controller/dwc/pcie-designware-host.c int dw_pcie_host_init(struct dw_pcie_rp *pp) · line 538

Quoted 10 lines
drivers/pci/controller/dwc/pcie-designware-host.c +6 -2
 	}
 
-	/* Ignore errors, the link may come up later */
-	dw_pcie_wait_for_link(pci);
+	/*
+	 * Note: The link up delay is skipped only when a link up IRQ is present.
+	 * This flag should not be used to bypass the link up delay for arbitrary
+	 * reasons.
+	 *
+	 * Ignore errors, the link may come up later.

Maybe you can move this comment just above dw_pcie_wait_for_link().

- Mani

Quoted 45 lines
drivers/pci/controller/dwc/pcie-designware-host.c +3 -0
+	 */
+	if (!pp->linkup_irq)
+		dw_pcie_wait_for_link(pci);
 
 	bridge->sysdata = pp;
 
drivers/pci/controller/dwc/pcie-designware.h +1 -0
index e518f81ea80c..b850f0a74695 100644
@@ -348,6 +348,7 @@ struct dw_pcie_rp {
 	bool			use_atu_msg;
 	int			msg_atu_index;
 	struct resource		*msg_res;
+	bool			linkup_irq;
 };
 
 struct dw_pcie_ep_ops {
drivers/pci/controller/dwc/pcie-qcom.c +4 -1
index 88a98be930e3..905c9154fc65 100644
@@ -1686,6 +1686,10 @@ static int qcom_pcie_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, pcie);
 
+	irq = platform_get_irq_byname_optional(pdev, "global");
+	if (irq > 0)
+		pp->linkup_irq = true;
+
 	ret = dw_pcie_host_init(pp);
 	if (ret) {
 		dev_err(dev, "cannot initialize host\n");
@@ -1699,7 +1703,6 @@ static int qcom_pcie_probe(struct platform_device *pdev)
 		goto err_host_deinit;
 	}
 
-	irq = platform_get_irq_byname_optional(pdev, "global");
 	if (irq > 0) {
 		ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
 						qcom_pcie_global_irq_thread,
Signature · 2 lines
-- 
2.34.1
Signature · 1 line
மணிவண்ணன் சதாசிவம்
#3 lore raw
Quoted 11 lines · Manivannan Sadhasivam

On Fri, Sep 20, 2024 at 03:47:59PM +0530, Krishna chaitanya chundru wrote:

Subject should be modified to reflect the fact that the link up is skipped in the dwc driver.

PCI: dwc: Skip waiting for link up if vendor drivers can detect Link up event

Quoted 3 lines

In cases where a global IRQ handler is present to manage link up interrupts, it may not be necessary to wait for the link to be up during PCI initialization which optimizes the bootup time.

Quoted 6 lines

How about,

"If the vendor drivers can detect the Link up event using mechanisms such as Link up IRQ, then waiting for Link up during probe is not needed. So let's skip waiting for link to be up if the driver supports 'linkup_irq'.

I avoid the "let's do X" structure because "let's do" is a proposal. The patch actually *does* it, so it's more than a proposal.

Also, it would be helpful to extend this with a note about *why* we can avoid waiting, i.e., if we can be notified when the link comes up, we can enumerate downstream devices then instead of waiting here.

I suppose the "global" name is already set by DTs, but the name seems far too general to me.

Bjorn

#4 lore raw

PATCH v2 2/2 PCI: qcom: Update ICC and OPP values during link up event

In reply to Krishna chaitanya chundru

As part of the PCIe link up event, update ICC and OPP values as at this point only driver can know the link speed and width of the PCIe link.

---
 drivers/pci/controller/dwc/pcie-qcom.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/pci/controller/dwc/pcie-qcom.c +2 -0
index 905c9154fc65..e3c17276027a 100644
@@ -1552,6 +1552,8 @@ static irqreturn_t qcom_pcie_global_irq_thread(int irq, void *data)
 		pci_lock_rescan_remove();
 		pci_rescan_bus(pp->bridge->bus);
 		pci_unlock_rescan_remove();
+
+		qcom_pcie_icc_opp_update(pcie);
 	} else {
 		dev_WARN_ONCE(dev, 1, "Received unknown event. INT_STATUS: 0x%08x\n",
 			      status);
Signature · 1 line
2.34.1