PCI: dwc: Wait for link up only if link is started
PATCH v5 1/1 PCI: dwc: Wait for link up only if link is started
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 1 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.
Wait for the link up in only if the start_link() is defined.
---
v4 was applied, but then reverted. 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.
Changelog since v4:
- Do not return error from dw_pcie_wait_for_link check
.../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(-)
drivers/pci/controller/dwc/pcie-designware-host.c +8 -4
@@ -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;
drivers/pci/controller/dwc/pcie-designware.c +13 -7
@@ -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 ; }
drivers/pci/controller/dwc/pcie-designware.h +1 -0
@@ -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);
Signature · 1 line
2.43.0.381.gb435a96ce8-goog
Hi Mani
A friendly reminder for your review.
Quoted 7 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.
Which platform you are working on? Is that upstreamed? You should mention the specific platform where you are observing the issue.
Right now, intel-gw and designware-plat are the only drivers not defining that callback. First one definitely needs a fixup and I do not know how the latter works.
- Mani
Quoted 99 lines
Wait for the link up in only if the
start_link()is defined.Signed-off-by Ajay Agarwal <[email protected]>---
v4 was applied, but then reverted. 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 fromdw_pcie_wait_for_linkcheck, the probe function of these products started to fail.Changelog since v4:
- Do not return error fromdw_pcie_wait_for_linkcheck.../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(-)drivers/pci/controller/dwc/pcie-designware-host.c +8
-4@@ -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;drivers/pci/controller/dwc/pcie-designware.c +13
-7@@ -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 ; }drivers/pci/controller/dwc/pcie-designware.h +1
-0@@ -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);Signature · 1 line
2.43.0.381.gb435a96ce8-goog
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 9 lines · Manivannan Sadhasivam
Quoted 7 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.
Quoted 3 lines
Which platform you are working on? Is that upstreamed? You should mention the specific platform where you are observing the issue.
This is for the Pixel phone platform. The platform driver for the same is not upstreamed yet. It is in the process.
Quoted 108 lines
Right now, intel-gw and designware-plat are the only drivers not defining that callback. First one definitely needs a fixup and I do not know how the latter works.
- Mani
Quoted 99 lines
Wait for the link up in only if the
start_link()is defined.Signed-off-by Ajay Agarwal <[email protected]>---
v4 was applied, but then reverted. 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 fromdw_pcie_wait_for_linkcheck, the probe function of these products started to fail.Changelog since v4:
- Do not return error fromdw_pcie_wait_for_linkcheck.../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(-)drivers/pci/controller/dwc/pcie-designware-host.c +8
-4@@ -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;drivers/pci/controller/dwc/pcie-designware.c +13
-7@@ -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 ; }drivers/pci/controller/dwc/pcie-designware.h +1
-0@@ -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);Signature · 1 line
2.43.0.381.gb435a96ce8-googSignature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 10 lines · Ajay Agarwal
Quoted 9 lines · Manivannan Sadhasivam
Quoted 7 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.
Quoted 6 lines
Quoted 3 lines
Which platform you are working on? Is that upstreamed? You should mention the specific platform where you are observing the issue.
This is for the Pixel phone platform. The platform driver for the same is not upstreamed yet. It is in the process.
Then you should submit this patch at the time of the driver submission. Right now, you are trying to fix a problem which is not present in upstream. One can argue that it is a problem for designware-plat driver, but honestly I do not know how it works.
- Mani
Quoted 108 lines
Quoted 108 lines
Right now, intel-gw and designware-plat are the only drivers not defining that callback. First one definitely needs a fixup and I do not know how the latter works.
- Mani
Quoted 99 lines
Wait for the link up in only if the
start_link()is defined.Signed-off-by Ajay Agarwal <[email protected]>---
v4 was applied, but then reverted. 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 fromdw_pcie_wait_for_linkcheck, the probe function of these products started to fail.Changelog since v4:
- Do not return error fromdw_pcie_wait_for_linkcheck.../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(-)drivers/pci/controller/dwc/pcie-designware-host.c +8
-4@@ -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;drivers/pci/controller/dwc/pcie-designware.c +13
-7@@ -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 ; }drivers/pci/controller/dwc/pcie-designware.h +1
-0@@ -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);Signature · 1 line
2.43.0.381.gb435a96ce8-googSignature · 1 line
மணிவண்ணன் சதாசிவம்
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 18 lines · Manivannan Sadhasivam
Quoted 10 lines · Ajay Agarwal
Quoted 9 lines · Manivannan Sadhasivam
Quoted 7 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.Quoted 6 lines
Quoted 3 lines
Which platform you are working on? Is that upstreamed? You should mention the specific platform where you are observing the issue.
This is for the Pixel phone platform. The platform driver for the same is not upstreamed yet. It is in the process.
Quoted 7 lines
Then you should submit this patch at the time of the driver submission. Right now, you are trying to fix a problem which is not present in upstream. One can argue that it is a problem for designware-plat driver, but honestly I do not know how it works.
- Mani
Yes Mani, this can be a problem for the designware-plat driver. To me, the problem of a second being wasted in the probe path seems pretty obvious. We will wait for the link to be up even though we are not starting the link training. Can this patch be accepted considering the problem in the dw-plat driver then?
Additionally, I have made this patch a part of a series [1] to keep the functional and refactoring changes separate. Please let me know if you see a concern with that.
[1] https://lore.kernel.org/linux-pci/[email protected]/
Quoted 111 lines
Quoted 108 lines
Quoted 108 lines
Right now, intel-gw and designware-plat are the only drivers not defining that callback. First one definitely needs a fixup and I do not know how the latter works.
- Mani
Quoted 99 lines
Wait for the link up in only if the
start_link()is defined.Signed-off-by Ajay Agarwal <[email protected]>---
v4 was applied, but then reverted. 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 fromdw_pcie_wait_for_linkcheck, the probe function of these products started to fail.Changelog since v4:
- Do not return error fromdw_pcie_wait_for_linkcheck.../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(-)drivers/pci/controller/dwc/pcie-designware-host.c +8
-4@@ -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;drivers/pci/controller/dwc/pcie-designware.c +13
-7@@ -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 ; }drivers/pci/controller/dwc/pcie-designware.h +1
-0@@ -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);Signature · 1 line
2.43.0.381.gb435a96ce8-googSignature · 1 line
மணிவண்ணன் சதாசிவம்Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 24 lines · Ajay Agarwal
Quoted 23 lines · Manivannan Sadhasivam
Quoted 10 lines · Ajay Agarwal
Quoted 9 lines · Manivannan Sadhasivam
Quoted 7 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.Quoted 6 lines
Quoted 3 lines
Which platform you are working on? Is that upstreamed? You should mention the specific platform where you are observing the issue.
This is for the Pixel phone platform. The platform driver for the same is not upstreamed yet. It is in the process.
Then you should submit this patch at the time of the driver submission. Right now, you are trying to fix a problem which is not present in upstream. One can argue that it is a problem for designware-plat driver, but honestly I do not know how it works.
Quoted 8 lines
Quoted 2 lines
- Mani
Yes Mani, this can be a problem for the designware-plat driver. To me, the problem of a second being wasted in the probe path seems pretty obvious. We will wait for the link to be up even though we are not starting the link training. Can this patch be accepted considering the problem in the dw-plat driver then?
If that's the case with your driver, when are you starting the link training?
Quoted 4 lines
Additionally, I have made this patch a part of a series [1] to keep the functional and refactoring changes separate. Please let me know if you see a concern with that.
I have responded to this series with my concerns.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 27 lines · Manivannan Sadhasivam
Quoted 26 lines · Ajay Agarwal
Quoted 25 lines · Manivannan Sadhasivam
Quoted 10 lines · Ajay Agarwal
Quoted 9 lines · Manivannan Sadhasivam
Quoted 7 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.Quoted 6 lines
Quoted 3 lines
Which platform you are working on? Is that upstreamed? You should mention the specific platform where you are observing the issue.
This is for the Pixel phone platform. The platform driver for the same is not upstreamed yet. It is in the process.
Then you should submit this patch at the time of the driver submission. Right now, you are trying to fix a problem which is not present in upstream. One can argue that it is a problem for designware-plat driver, but honestly I do not know how it works.
- Mani
Quoted 9 lines
Quoted 6 lines
Yes Mani, this can be a problem for the designware-plat driver. To me, the problem of a second being wasted in the probe path seems pretty obvious. We will wait for the link to be up even though we are not starting the link training. Can this patch be accepted considering the problem in the dw-plat driver then?
If that's the case with your driver, when are you starting the link training?
The link training starts later based on a userspace/debugfs trigger.
Quoted 9 lines
Quoted 4 lines
Additionally, I have made this patch a part of a series [1] to keep the functional and refactoring changes separate. Please let me know if you see a concern with that.
I have responded to this series with my concerns.
- Mani
Sure, I will check there and respond. Thanks.
Quoted 2 lines
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 35 lines · Ajay Agarwal
Quoted 34 lines · Manivannan Sadhasivam
Quoted 32 lines · Ajay Agarwal
Quoted 18 lines · Manivannan Sadhasivam
Quoted 10 lines · Ajay Agarwal
Quoted 9 lines · Manivannan Sadhasivam
Quoted 7 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.Quoted 6 lines
Quoted 3 lines
Which platform you are working on? Is that upstreamed? You should mention the specific platform where you are observing the issue.
This is for the Pixel phone platform. The platform driver for the same is not upstreamed yet. It is in the process.
Quoted 7 lines
Then you should submit this patch at the time of the driver submission. Right now, you are trying to fix a problem which is not present in upstream. One can argue that it is a problem for designware-plat driver, but honestly I do not know how it works.
- Mani
Yes Mani, this can be a problem for the designware-plat driver. To me, the problem of a second being wasted in the probe path seems pretty obvious. We will wait for the link to be up even though we are not starting the link training. Can this patch be accepted considering the problem in the dw-plat driver then?
Quoted 4 lines
Quoted 2 lines
If that's the case with your driver, when are you starting the link training?
The link training starts later based on a userspace/debugfs trigger.
Why does it happen as such? What's the problem in starting the link during probe? Keep it in mind that if you rely on the userspace for starting the link based on a platform (like Android), then if the same SoC or peripheral instance get reused in other platform (non-android), the it won't be a seamless user experience.
If there are any other usecases, please state them.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 47 lines · Manivannan Sadhasivam
Quoted 35 lines · Ajay Agarwal
Quoted 34 lines · Manivannan Sadhasivam
Quoted 32 lines · Ajay Agarwal
Quoted 18 lines · Manivannan Sadhasivam
Quoted 10 lines · Ajay Agarwal
Quoted 9 lines · Manivannan Sadhasivam
Quoted 7 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.Quoted 6 lines
Quoted 3 lines
Which platform you are working on? Is that upstreamed? You should mention the specific platform where you are observing the issue.
This is for the Pixel phone platform. The platform driver for the same is not upstreamed yet. It is in the process.
Quoted 7 lines
Then you should submit this patch at the time of the driver submission. Right now, you are trying to fix a problem which is not present in upstream. One can argue that it is a problem for designware-plat driver, but honestly I do not know how it works.
- Mani
Yes Mani, this can be a problem for the designware-plat driver. To me, the problem of a second being wasted in the probe path seems pretty obvious. We will wait for the link to be up even though we are not starting the link training. Can this patch be accepted considering the problem in the dw-plat driver then?
Quoted 4 lines
Quoted 2 lines
If that's the case with your driver, when are you starting the link training?
The link training starts later based on a userspace/debugfs trigger.
Why does it happen as such? What's the problem in starting the link during probe? Keep it in mind that if you rely on the userspace for starting the link based on a platform (like Android), then if the same SoC or peripheral instance get reused in other platform (non-android), the it won't be a seamless user experience.
Quoted 4 lines
If there are any other usecases, please state them.
- Mani
This SoC is targeted for an android phone usecase and the endpoints being enumerated need to go through an appropriate and device specific power sequence which gets triggered only when the userspace is up. The PCIe probe cannot assume that the EPs have been powered up already and hence the link-up is not attempted.
Quoted 2 lines
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 50 lines · Ajay Agarwal
Quoted 49 lines · Manivannan Sadhasivam
Quoted 35 lines · Ajay Agarwal
Quoted 34 lines · Manivannan Sadhasivam
Quoted 32 lines · Ajay Agarwal
Quoted 18 lines · Manivannan Sadhasivam
Quoted 10 lines · Ajay Agarwal
Quoted 9 lines · Manivannan Sadhasivam
Quoted 7 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.Quoted 6 lines
Quoted 3 lines
Which platform you are working on? Is that upstreamed? You should mention the specific platform where you are observing the issue.
This is for the Pixel phone platform. The platform driver for the same is not upstreamed yet. It is in the process.
Quoted 7 lines
Then you should submit this patch at the time of the driver submission. Right now, you are trying to fix a problem which is not present in upstream. One can argue that it is a problem for designware-plat driver, but honestly I do not know how it works.
- Mani
Yes Mani, this can be a problem for the designware-plat driver. To me, the problem of a second being wasted in the probe path seems pretty obvious. We will wait for the link to be up even though we are not starting the link training. Can this patch be accepted considering the problem in the dw-plat driver then?
Quoted 4 lines
Quoted 2 lines
If that's the case with your driver, when are you starting the link training?
The link training starts later based on a userspace/debugfs trigger.
Why does it happen as such? What's the problem in starting the link during probe? Keep it in mind that if you rely on the userspace for starting the link based on a platform (like Android), then if the same SoC or peripheral instance get reused in other platform (non-android), the it won't be a seamless user experience.
If there are any other usecases, please state them.
Quoted 7 lines
Quoted 2 lines
- Mani
This SoC is targeted for an android phone usecase and the endpoints being enumerated need to go through an appropriate and device specific power sequence which gets triggered only when the userspace is up. The PCIe probe cannot assume that the EPs have been powered up already and hence the link-up is not attempted.
Still, I do not see the necessity to not call start_link() during probe. If you add PROBE_PREFER_ASYNCHRONOUS to your controller driver, this delay would become negligible. The reason why I'm against not calling start_link() is due to below reasons:
1. If the same SoC gets reused for other platforms, even other android phones that powers up the endpoints during boot, then it creates a dependency with userspace to always start the link even though the devices were available. That's why we should never fix the behavior of the controller drivers based on a single platform.
2. This will create fragmentation among the DWC glue drivers w.r.t the behavior and will become a maintenance nightmare (there are enough already).
So, I'd suggest you to use the asynchronous probe mentioned above so that other drivers may probe in parallel thus avoiding the delay that you are worried about.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 53 lines · Manivannan Sadhasivam
Quoted 52 lines · Ajay Agarwal
Quoted 51 lines · Manivannan Sadhasivam
Quoted 35 lines · Ajay Agarwal
Quoted 34 lines · Manivannan Sadhasivam
Quoted 32 lines · Ajay Agarwal
Quoted 18 lines · Manivannan Sadhasivam
Quoted 10 lines · Ajay Agarwal
Quoted 9 lines · Manivannan Sadhasivam
Quoted 7 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.Quoted 6 lines
Quoted 3 lines
Which platform you are working on? Is that upstreamed? You should mention the specific platform where you are observing the issue.
This is for the Pixel phone platform. The platform driver for the same is not upstreamed yet. It is in the process.
Quoted 7 lines
Then you should submit this patch at the time of the driver submission. Right now, you are trying to fix a problem which is not present in upstream. One can argue that it is a problem for designware-plat driver, but honestly I do not know how it works.
- Mani
Yes Mani, this can be a problem for the designware-plat driver. To me, the problem of a second being wasted in the probe path seems pretty obvious. We will wait for the link to be up even though we are not starting the link training. Can this patch be accepted considering the problem in the dw-plat driver then?
Quoted 4 lines
Quoted 2 lines
If that's the case with your driver, when are you starting the link training?
The link training starts later based on a userspace/debugfs trigger.
Why does it happen as such? What's the problem in starting the link during probe? Keep it in mind that if you rely on the userspace for starting the link based on a platform (like Android), then if the same SoC or peripheral instance get reused in other platform (non-android), the it won't be a seamless user experience.
If there are any other usecases, please state them.
- Mani
Quoted 7 lines
Quoted 5 lines
This SoC is targeted for an android phone usecase and the endpoints being enumerated need to go through an appropriate and device specific power sequence which gets triggered only when the userspace is up. The PCIe probe cannot assume that the EPs have been powered up already and hence the link-up is not attempted.
Still, I do not see the necessity to not call
start_link()during probe. If you
I am not adding any logic/condition around calling the start_link() itself. I am only avoiding the wait for the link to be up if the controller driver has not defined start_link().
Quoted 9 lines
add
PROBE_PREFER_ASYNCHRONOUSto your controller driver, this delay would become negligible. The reason why I'm against not callingstart_link()is due to below reasons:1. If the same SoC gets reused for other platforms, even other android phones that powers up the endpoints during boot, then it creates a dependency with userspace to always start the link even though the devices were available. That's why we should never fix the behavior of the controller drivers based on a single platform.
I wonder how the behavior is changing with this patch. Do you have an example of a platform which does not have start_link() defined but would like to still wait for a second for the link to come up?
For example, consider the intel-gw driver. The 1 sec wait time in its probe path is also a waste because it explicitly starts link training later in time.
Quoted 11 lines
2. This will create fragmentation among the DWC glue drivers w.r.t the behavior and will become a maintenance nightmare (there are enough already).
So, I'd suggest you to use the asynchronous probe mentioned above so that other drivers may probe in parallel thus avoiding the delay that you are worried about.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
On Tue, Jan 30, 2024 at 02:30:27PM +0530, Ajay Agarwal wrote:
[...]
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 11 lines
Quoted 4 lines
Quoted 2 lines
If that's the case with your driver, when are you starting the link training?
The link training starts later based on a userspace/debugfs trigger.
Why does it happen as such? What's the problem in starting the link during probe? Keep it in mind that if you rely on the userspace for starting the link based on a platform (like Android), then if the same SoC or peripheral instance get reused in other platform (non-android), the it won't be a seamless user experience.
Quoted 4 lines
If there are any other usecases, please state them.
- Mani
This SoC is targeted for an android phone usecase and the endpoints being enumerated need to go through an appropriate and device specific power sequence which gets triggered only when the userspace is up. The PCIe probe cannot assume that the EPs have been powered up already and hence the link-up is not attempted.
Quoted 5 lines
Quoted 1 line
Still, I do not see the necessity to not call
start_link()during probe. If youI am not adding any logic/condition around calling the
start_link()itself. I am only avoiding the wait for the link to be up if the controller driver has not definedstart_link().
I'm saying that not defining the start_link() callback itself is wrong.
Quoted 4 lines
Quoted 4 lines
add
PROBE_PREFER_ASYNCHRONOUSto your controller driver, this delay would become negligible. The reason why I'm against not callingstart_link()is due to below reasons:
Quoted 9 lines
Quoted 5 lines
1. If the same SoC gets reused for other platforms, even other android phones that powers up the endpoints during boot, then it creates a dependency with userspace to always start the link even though the devices were available. That's why we should never fix the behavior of the controller drivers based on a single platform.
I wonder how the behavior is changing with this patch. Do you have an example of a platform which does not have
start_link()defined but would like to still wait for a second for the link to come up?
Did you went through my reply completely? I mentioned that the 1s delay would be gone if you add the async flag to your driver and you are ignoring that.
But again, I'm saying that not defining start_link() itself is wrong and I've already mentioned the reasons.
Quoted 4 lines
For example, consider the intel-gw driver. The 1 sec wait time in its probe path is also a waste because it explicitly starts link training later in time.
I previously mentioned that the intel-gw needs fixing since there is no point in starting the link and waiting for it to come up in its probe() if the DWC core is already doing that.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 25 lines · Manivannan Sadhasivam
On Tue, Jan 30, 2024 at 02:30:27PM +0530, Ajay Agarwal wrote:
[...]
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 11 lines
Quoted 4 lines
Quoted 2 lines
If that's the case with your driver, when are you starting the link training?
The link training starts later based on a userspace/debugfs trigger.
Why does it happen as such? What's the problem in starting the link during probe? Keep it in mind that if you rely on the userspace for starting the link based on a platform (like Android), then if the same SoC or peripheral instance get reused in other platform (non-android), the it won't be a seamless user experience.
Quoted 4 lines
If there are any other usecases, please state them.
- Mani
This SoC is targeted for an android phone usecase and the endpoints being enumerated need to go through an appropriate and device specific power sequence which gets triggered only when the userspace is up. The PCIe probe cannot assume that the EPs have been powered up already and hence the link-up is not attempted.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Still, I do not see the necessity to not call
start_link()during probe. If youI am not adding any logic/condition around calling the
start_link()itself. I am only avoiding the wait for the link to be up if the controller driver has not definedstart_link().I'm saying that not defining the
start_link()callback itself is wrong.
Whether the start_link() should be defined or not, is a different design discussion. We currently have 2 drivers in upstream (intel-gw and dw-plat) which do not have start_link() defined. Waiting for the link to come up for the platforms using those drivers is not a good idea. And that is what we are trying to avoid.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
add
PROBE_PREFER_ASYNCHRONOUSto your controller driver, this delay would become negligible. The reason why I'm against not callingstart_link()is due to below reasons:1. If the same SoC gets reused for other platforms, even other android phones that powers up the endpoints during boot, then it creates a dependency with userspace to always start the link even though the devices were available. That's why we should never fix the behavior of the controller drivers based on a single platform.
Quoted 8 lines
Quoted 4 lines
I wonder how the behavior is changing with this patch. Do you have an example of a platform which does not have
start_link()defined but would like to still wait for a second for the link to come up?Did you went through my reply completely? I mentioned that the 1s delay would be gone if you add the async flag to your driver and you are ignoring that.
Yes, I did go through your suggestion of async probe and that might solve my problem of the 1 sec delay. But I would like to fix the problem at the core.
Quoted 8 lines
But again, I'm saying that not defining
start_link()itself is wrong and I've already mentioned the reasons.Quoted 4 lines
For example, consider the intel-gw driver. The 1 sec wait time in its probe path is also a waste because it explicitly starts link training later in time.
Quoted 8 lines
I previously mentioned that the intel-gw needs fixing since there is no point in starting the link and waiting for it to come up in its
probe()if the DWC core is already doing that.- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
I think we are at a dead-end in terms of agreeing to a policy. I would like the maintainers to pitch in here with their views.
Quoted 32 lines · Ajay Agarwal
Quoted 31 lines · Manivannan Sadhasivam
On Tue, Jan 30, 2024 at 02:30:27PM +0530, Ajay Agarwal wrote:
[...]
Quoted 26 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
Quoted 2 lines
If that's the case with your driver, when are you starting the link training?
The link training starts later based on a userspace/debugfs trigger.
Why does it happen as such? What's the problem in starting the link during probe? Keep it in mind that if you rely on the userspace for starting the link based on a platform (like Android), then if the same SoC or peripheral instance get reused in other platform (non-android), the it won't be a seamless user experience.
If there are any other usecases, please state them.
- Mani
Quoted 7 lines
Quoted 5 lines
This SoC is targeted for an android phone usecase and the endpoints being enumerated need to go through an appropriate and device specific power sequence which gets triggered only when the userspace is up. The PCIe probe cannot assume that the EPs have been powered up already and hence the link-up is not attempted.
Still, I do not see the necessity to not call
start_link()during probe. If youI am not adding any logic/condition around calling the
start_link()itself. I am only avoiding the wait for the link to be up if the controller driver has not definedstart_link().
Quoted 8 lines
Quoted 2 lines
I'm saying that not defining the
start_link()callback itself is wrong.Whether the
start_link()should be defined or not, is a different design discussion. We currently have 2 drivers in upstream (intel-gw and dw-plat) which do not havestart_link()defined. Waiting for the link to come up for the platforms using those drivers is not a good idea. And that is what we are trying to avoid.
NO. The sole intention of this patch is to fix the delay observed with _your_ out-of-tree controller driver as you explicitly said before. Impact for the existing 2 drivers are just a side effect.
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 9 lines
add
PROBE_PREFER_ASYNCHRONOUSto your controller driver, this delay would become negligible. The reason why I'm against not callingstart_link()is due to below reasons:1. If the same SoC gets reused for other platforms, even other android phones that powers up the endpoints during boot, then it creates a dependency with userspace to always start the link even though the devices were available. That's why we should never fix the behavior of the controller drivers based on a single platform.
I wonder how the behavior is changing with this patch. Do you have an example of a platform which does not have
start_link()defined but would like to still wait for a second for the link to come up?
Quoted 7 lines
Quoted 3 lines
Did you went through my reply completely? I mentioned that the 1s delay would be gone if you add the async flag to your driver and you are ignoring that.
Yes, I did go through your suggestion of async probe and that might solve my problem of the 1 sec delay. But I would like to fix the problem at the core.
There is no problem at the core. The problem is with some controller drivers. Please do not try to fix a problem which is not there. There are no _special_ reasons for those 2 drivers to not define start_link() callback. I'm trying to point you in the right path, but you are always chosing the other one.
Quoted 12 lines
Quoted 12 lines
But again, I'm saying that not defining
start_link()itself is wrong and I've already mentioned the reasons.Quoted 4 lines
For example, consider the intel-gw driver. The 1 sec wait time in its probe path is also a waste because it explicitly starts link training later in time.
I previously mentioned that the intel-gw needs fixing since there is no point in starting the link and waiting for it to come up in its
probe()if the DWC core is already doing that.
Quoted 6 lines
Quoted 4 lines
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்I think we are at a dead-end in terms of agreeing to a policy. I would like the maintainers to pitch in here with their views.
I'm the maintainer of the DWC drivers that you are proposing the patch for. If you happen to spin future revision of this series, please carry:
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 42 lines · Manivannan Sadhasivam
Quoted 32 lines · Ajay Agarwal
Quoted 31 lines · Manivannan Sadhasivam
On Tue, Jan 30, 2024 at 02:30:27PM +0530, Ajay Agarwal wrote:
[...]
Quoted 26 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
Quoted 2 lines
If that's the case with your driver, when are you starting the link training?
The link training starts later based on a userspace/debugfs trigger.
Why does it happen as such? What's the problem in starting the link during probe? Keep it in mind that if you rely on the userspace for starting the link based on a platform (like Android), then if the same SoC or peripheral instance get reused in other platform (non-android), the it won't be a seamless user experience.
If there are any other usecases, please state them.
- Mani
Quoted 7 lines
Quoted 5 lines
This SoC is targeted for an android phone usecase and the endpoints being enumerated need to go through an appropriate and device specific power sequence which gets triggered only when the userspace is up. The PCIe probe cannot assume that the EPs have been powered up already and hence the link-up is not attempted.
Still, I do not see the necessity to not call
start_link()during probe. If youI am not adding any logic/condition around calling the
start_link()itself. I am only avoiding the wait for the link to be up if the controller driver has not definedstart_link().Quoted 8 lines
Quoted 2 lines
I'm saying that not defining the
start_link()callback itself is wrong.Whether the
start_link()should be defined or not, is a different design discussion. We currently have 2 drivers in upstream (intel-gw and dw-plat) which do not havestart_link()defined. Waiting for the link to come up for the platforms using those drivers is not a good idea. And that is what we are trying to avoid.
Quoted 4 lines
NO. The sole intention of this patch is to fix the delay observed with _your_ out-of-tree controller driver as you explicitly said before. Impact for the existing 2 drivers are just a side effect.
Hi Mani,
What is the expectation from the pcie-designware-host driver? If the .start_link() has to be defined by the vendor driver, then shouldn't the probe be failed if the vendor has not defined it? Thereby failing the probe for intel-gw and pcie-dw-plat drivers?
Additionally, if the link fails to come up even after 1 sec of wait time, shouldn't the probe be failed in that case too?
My understanding of these drivers is that the .start_link() is an OPTIONAL callback and that the dw_pcie_host_init should help setup the SW structures regardless of whether the .start_link() has been defined or not, and whether the link is up or not. The vendor should be allowed to train the link at a later point of time as well.
Please let me know your thoughts.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
add
PROBE_PREFER_ASYNCHRONOUSto your controller driver, this delay would become negligible. The reason why I'm against not callingstart_link()is due to below reasons:1. If the same SoC gets reused for other platforms, even other android phones that powers up the endpoints during boot, then it creates a dependency with userspace to always start the link even though the devices were available. That's why we should never fix the behavior of the controller drivers based on a single platform.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
I wonder how the behavior is changing with this patch. Do you have an example of a platform which does not have
start_link()defined but would like to still wait for a second for the link to come up?Did you went through my reply completely? I mentioned that the 1s delay would be gone if you add the async flag to your driver and you are ignoring that.
The async probe might not help in all the cases. Consider a situation where the PCIe is probed after the boot is already completed. The user will face the delay then. Do you agree?
Quoted 38 lines
Quoted 4 lines
Yes, I did go through your suggestion of async probe and that might solve my problem of the 1 sec delay. But I would like to fix the problem at the core.
There is no problem at the core. The problem is with some controller drivers. Please do not try to fix a problem which is not there. There are no _special_ reasons for those 2 drivers to not define
start_link()callback. I'm trying to point you in the right path, but you are always chosing the other one.Quoted 12 lines
Quoted 12 lines
But again, I'm saying that not defining
start_link()itself is wrong and I've already mentioned the reasons.Quoted 4 lines
For example, consider the intel-gw driver. The 1 sec wait time in its probe path is also a waste because it explicitly starts link training later in time.
I previously mentioned that the intel-gw needs fixing since there is no point in starting the link and waiting for it to come up in its
probe()if the DWC core is already doing that.Quoted 6 lines
Quoted 4 lines
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்I think we are at a dead-end in terms of agreeing to a policy. I would like the maintainers to pitch in here with their views.
I'm the maintainer of the DWC drivers that you are proposing the patch for. If you happen to spin future revision of this series, please carry:
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
+ Joao
Quoted 47 lines · Ajay Agarwal
Quoted 42 lines · Manivannan Sadhasivam
Quoted 32 lines · Ajay Agarwal
Quoted 31 lines · Manivannan Sadhasivam
On Tue, Jan 30, 2024 at 02:30:27PM +0530, Ajay Agarwal wrote:
[...]
Quoted 26 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
Quoted 2 lines
If that's the case with your driver, when are you starting the link training?
The link training starts later based on a userspace/debugfs trigger.
Why does it happen as such? What's the problem in starting the link during probe? Keep it in mind that if you rely on the userspace for starting the link based on a platform (like Android), then if the same SoC or peripheral instance get reused in other platform (non-android), the it won't be a seamless user experience.
If there are any other usecases, please state them.
- Mani
Quoted 7 lines
Quoted 5 lines
This SoC is targeted for an android phone usecase and the endpoints being enumerated need to go through an appropriate and device specific power sequence which gets triggered only when the userspace is up. The PCIe probe cannot assume that the EPs have been powered up already and hence the link-up is not attempted.
Still, I do not see the necessity to not call
start_link()during probe. If youI am not adding any logic/condition around calling the
start_link()itself. I am only avoiding the wait for the link to be up if the controller driver has not definedstart_link().Quoted 8 lines
Quoted 2 lines
I'm saying that not defining the
start_link()callback itself is wrong.Whether the
start_link()should be defined or not, is a different design discussion. We currently have 2 drivers in upstream (intel-gw and dw-plat) which do not havestart_link()defined. Waiting for the link to come up for the platforms using those drivers is not a good idea. And that is what we are trying to avoid.Quoted 4 lines
NO. The sole intention of this patch is to fix the delay observed with _your_ out-of-tree controller driver as you explicitly said before. Impact for the existing 2 drivers are just a side effect.
Quoted 6 lines
Hi Mani,
What is the expectation from the pcie-designware-host driver? If the .start_link() has to be defined by the vendor driver, then shouldn't the probe be failed if the vendor has not defined it? Thereby failing the probe for intel-gw and pcie-dw-plat drivers?
intel-gw maintainer agreed to fix the driver [1], but I cannot really comment on the other one. It is not starting the link at all, so don't know how it works. I've CCed the driver author to get some idea.
Quoted 3 lines
Additionally, if the link fails to come up even after 1 sec of wait time, shouldn't the probe be failed in that case too?
Why? The device can be attached at any point of time. What I'm stressing is, the driver should check for the link to be up during probe and if there is no device, then it should just continue and hope for the device to show up later. This way, the driver can detect the powered up devices during boot and also detect the hotplug devices.
Quoted 6 lines
My understanding of these drivers is that the .start_link() is an OPTIONAL callback and that the
dw_pcie_host_initshould help setup the SW structures regardless of whether the .start_link() has been defined or not, and whether the link is up or not. The vendor should be allowed to train the link at a later point of time as well.
What do you mean by later point of time? Bringing the link through debugfs? NO. We cannot let each driver behave differently, unless there is a really valid reason.
Quoted 15 lines
Please let me know your thoughts.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 9 lines
add
PROBE_PREFER_ASYNCHRONOUSto your controller driver, this delay would become negligible. The reason why I'm against not callingstart_link()is due to below reasons:1. If the same SoC gets reused for other platforms, even other android phones that powers up the endpoints during boot, then it creates a dependency with userspace to always start the link even though the devices were available. That's why we should never fix the behavior of the controller drivers based on a single platform.
I wonder how the behavior is changing with this patch. Do you have an example of a platform which does not have
start_link()defined but would like to still wait for a second for the link to come up?
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Did you went through my reply completely? I mentioned that the 1s delay would be gone if you add the async flag to your driver and you are ignoring that.
The async probe might not help in all the cases. Consider a situation where the PCIe is probed after the boot is already completed. The user will face the delay then. Do you agree?
You mean loading the driver module post boot? If the link is still not up, yes the users will see the 1sec delay.
But again, the point I'm trying to make here is, all the drivers have to follow one flow. We cannot let each driver do its way of starting the link. There could be exceptions if we get a valid reason for a driver to not do so, but so far I haven't come across such reason. (the existing drivers, intel-gw and designware-plat are not exceptions, but they need fixing).
For your driver, you said that the userspace brings up the link, post boot when the devices are powered on. So starting the link during probe incurs 1s delay, as there would be no devices. But I suggested you to enable async probe to nullify the 1s delay during probe and you confirmed that it fixes the issue for you.
Then you are again debating about not defining the start_link() callback :(
I've made by point clear, please do not take inspiration from those drivers, they really need fixing. And for your usecase, allowing the controller driver to start the link post boot just because a device on your Pixel phone comes up later is not a good argument. You _should_not_ define the behavior of a controller driver based on one platform, it is really a bad design.
- Mani
Quoted 38 lines
Quoted 38 lines
Quoted 4 lines
Yes, I did go through your suggestion of async probe and that might solve my problem of the 1 sec delay. But I would like to fix the problem at the core.
There is no problem at the core. The problem is with some controller drivers. Please do not try to fix a problem which is not there. There are no _special_ reasons for those 2 drivers to not define
start_link()callback. I'm trying to point you in the right path, but you are always chosing the other one.Quoted 12 lines
Quoted 12 lines
But again, I'm saying that not defining
start_link()itself is wrong and I've already mentioned the reasons.Quoted 4 lines
For example, consider the intel-gw driver. The 1 sec wait time in its probe path is also a waste because it explicitly starts link training later in time.
I previously mentioned that the intel-gw needs fixing since there is no point in starting the link and waiting for it to come up in its
probe()if the DWC core is already doing that.Quoted 6 lines
Quoted 4 lines
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்I think we are at a dead-end in terms of agreeing to a policy. I would like the maintainers to pitch in here with their views.
I'm the maintainer of the DWC drivers that you are proposing the patch for. If you happen to spin future revision of this series, please carry:
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 7 lines · Manivannan Sadhasivam
...
... And for your usecase, allowing the controller driver to start the link post boot just because a device on your Pixel phone comes up later is not a good argument. You _should_not_ define the behavior of a controller driver based on one platform, it is really a bad design.
I haven't followed the entire discussion, and I don't know much about the specifics of Ajay's situation, but from the controller driver's point of view, shouldn't a device coming up later look like a normal hot-add?
I think most drivers are designed with the assumption that Endpoints are present and powered up at the time of host controller probe, which seems a little stronger than necessary.
I think the host controller probe should initialize the Root Port such that its LTSSM enters the Detect state, and that much should be basically straight-line code with no waiting. If no Endpoint is attached, i.e., "the slot is empty", it would be nice if the probe could then complete immediately without waiting at all.
If the link comes up later, could we handle it as a hot-add? This might be an actual hot-add, or it might be that an Endpoint was present at boot but link training didn't complete until later.
I admit it doesn't look trivial to actually implement this. We would need to be able to detect link-up events, e.g., via hotplug or other link management interrupts. Lacking that hardware functionality, we might need driver-specific code to wait for the link to come up (possibly drivers could skip the wait if they can detect the "slot empty" case).
Also, the hotplug functionality (pciehp or acpiphp) is currently initialized later and there's probably a race with enabling and detecting hot-add events in the "slot occupied" case.
Bjorn
Quoted 9 lines · Bjorn Helgaas
Quoted 7 lines · Manivannan Sadhasivam
...
... And for your usecase, allowing the controller driver to start the link post boot just because a device on your Pixel phone comes up later is not a good argument. You _should_not_ define the behavior of a controller driver based on one platform, it is really a bad design.
Quoted 5 lines
I haven't followed the entire discussion, and I don't know much about the specifics of Ajay's situation, but from the controller driver's point of view, shouldn't a device coming up later look like a normal hot-add?
Yes, but most of the form factors that these drivers work with do not support native hotplug. So users have to rescan the bus through sysfs.
Quoted 4 lines
I think most drivers are designed with the assumption that Endpoints are present and powered up at the time of host controller probe, which seems a little stronger than necessary.
Most of the drivers work with endpoints that are fixed in the board design (like M.2), so the endpoints would be up when the controller probes.
Quoted 6 lines
I think the host controller probe should initialize the Root Port such that its LTSSM enters the Detect state, and that much should be basically straight-line code with no waiting. If no Endpoint is attached, i.e., "the slot is empty", it would be nice if the probe could then complete immediately without waiting at all.
Atleast on Qcom platforms, the LTSSM would be in "Detect" state even if no endpoints are found during probe. Then once an endpoint comes up later, link training happens and user can rescan the bus through sysfs.
But, I don't know the real need of 1s loop to wait for the link. It predates my work on DWC drivers. Maybe Lorenzo could shed some light. I could not find the reference in both DWC and PCIe specs (maybe my grep was bad).
Quoted 11 lines
If the link comes up later, could we handle it as a hot-add? This might be an actual hot-add, or it might be that an Endpoint was present at boot but link training didn't complete until later.
I admit it doesn't look trivial to actually implement this. We would need to be able to detect link-up events, e.g., via hotplug or other link management interrupts. Lacking that hardware functionality, we might need driver-specific code to wait for the link to come up (possibly drivers could skip the wait if they can detect the "slot empty" case).
Quoted 4 lines
Also, the hotplug functionality (pciehp or acpiphp) is currently initialized later and there's probably a race with enabling and detecting hot-add events in the "slot occupied" case.
As I mentioned above, hotplug is not possible in all the cases. There is a series floating to add GPIO based hotplug, but still that requires board designers to route a dedicated GPIO to the endpoint.
To conclude, we do need to check for the existence of the endpoints during probe. But whether the driver should wait for 1s for the link to come up, should be clarified by Lorenzo.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 33 lines · Manivannan Sadhasivam
Quoted 9 lines · Bjorn Helgaas
Quoted 7 lines · Manivannan Sadhasivam
...
... And for your usecase, allowing the controller driver to start the link post boot just because a device on your Pixel phone comes up later is not a good argument. You _should_not_ define the behavior of a controller driver based on one platform, it is really a bad design.
Quoted 4 lines
I haven't followed the entire discussion, and I don't know much about the specifics of Ajay's situation, but from the controller driver's point of view, shouldn't a device coming up later look like a normal hot-add?
Yes, but most of the form factors that these drivers work with do not support native hotplug. So users have to rescan the bus through sysfs.
Quoted 3 lines
I think most drivers are designed with the assumption that Endpoints are present and powered up at the time of host controller probe, which seems a little stronger than necessary.
Most of the drivers work with endpoints that are fixed in the board design (like M.2), so the endpoints would be up when the controller probes.
Quoted 5 lines
I think the host controller probe should initialize the Root Port such that its LTSSM enters the Detect state, and that much should be basically straight-line code with no waiting. If no Endpoint is attached, i.e., "the slot is empty", it would be nice if the probe could then complete immediately without waiting at all.
Quoted 4 lines
Atleast on Qcom platforms, the LTSSM would be in "Detect" state even if no endpoints are found during probe. Then once an endpoint comes up later, link training happens and user can rescan the bus through sysfs.
Can the hardware tell us when the link state changes? If so, we should be able to scan the bus automatically without the need for sysfs. For example, if the Root Port advertised PCI_EXP_FLAGS_SLOT, we might be able to use a Data Link Layer State Changed interrupt to scan the bus via pciehp when the Endpoint is powered up, even if the Endpoint is actually soldered down and not physically hot-pluggable.
Bjorn
Quoted 39 lines · Bjorn Helgaas
Quoted 33 lines · Manivannan Sadhasivam
Quoted 9 lines · Bjorn Helgaas
Quoted 7 lines · Manivannan Sadhasivam
...
... And for your usecase, allowing the controller driver to start the link post boot just because a device on your Pixel phone comes up later is not a good argument. You _should_not_ define the behavior of a controller driver based on one platform, it is really a bad design.
Quoted 4 lines
I haven't followed the entire discussion, and I don't know much about the specifics of Ajay's situation, but from the controller driver's point of view, shouldn't a device coming up later look like a normal hot-add?
Yes, but most of the form factors that these drivers work with do not support native hotplug. So users have to rescan the bus through sysfs.
Quoted 3 lines
I think most drivers are designed with the assumption that Endpoints are present and powered up at the time of host controller probe, which seems a little stronger than necessary.
Most of the drivers work with endpoints that are fixed in the board design (like M.2), so the endpoints would be up when the controller probes.
Quoted 5 lines
I think the host controller probe should initialize the Root Port such that its LTSSM enters the Detect state, and that much should be basically straight-line code with no waiting. If no Endpoint is attached, i.e., "the slot is empty", it would be nice if the probe could then complete immediately without waiting at all.
Quoted 4 lines
Atleast on Qcom platforms, the LTSSM would be in "Detect" state even if no endpoints are found during probe. Then once an endpoint comes up later, link training happens and user can rescan the bus through sysfs.
Quoted 7 lines
Can the hardware tell us when the link state changes? If so, we should be able to scan the bus automatically without the need for sysfs. For example, if the Root Port advertised
PCI_EXP_FLAGS_SLOT, we might be able to use a Data Link Layer State Changed interrupt to scan the bus via pciehp when the Endpoint is powered up, even if the Endpoint is actually soldered down and not physically hot-pluggable.
I don't think the state change interrupt is generated on Qcom platforms. I will check with the hw team and reply back.
As a reply to my earlier question on requiring 1s delay for waiting for the link to come up during boot:
PCIe spec r5, sec 6.6.1 says:
"Unless Readiness Notifications mechanisms are used, the Root Complex and/or system software must allow at least 1.0 s after a Conventional Reset of a device, before determining that the device is broken if it fails to return a Successful Completion status for a valid Configuration Request. This period is independent of how quickly Link training completes."
So this might be the reason. If so, I don't see a way to avoid the delay.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 58 lines · Manivannan Sadhasivam
Quoted 9 lines · Bjorn Helgaas
Quoted 7 lines · Manivannan Sadhasivam
...
... And for your usecase, allowing the controller driver to start the link post boot just because a device on your Pixel phone comes up later is not a good argument. You _should_not_ define the behavior of a controller driver based on one platform, it is really a bad design.
Quoted 5 lines
I haven't followed the entire discussion, and I don't know much about the specifics of Ajay's situation, but from the controller driver's point of view, shouldn't a device coming up later look like a normal hot-add?
Yes, but most of the form factors that these drivers work with do not support native hotplug. So users have to rescan the bus through sysfs.
Quoted 4 lines
I think most drivers are designed with the assumption that Endpoints are present and powered up at the time of host controller probe, which seems a little stronger than necessary.
Most of the drivers work with endpoints that are fixed in the board design (like M.2), so the endpoints would be up when the controller probes.
Quoted 6 lines
I think the host controller probe should initialize the Root Port such that its LTSSM enters the Detect state, and that much should be basically straight-line code with no waiting. If no Endpoint is attached, i.e., "the slot is empty", it would be nice if the probe could then complete immediately without waiting at all.
Atleast on Qcom platforms, the LTSSM would be in "Detect" state even if no endpoints are found during probe. Then once an endpoint comes up later, link training happens and user can rescan the bus through sysfs.
But, I don't know the real need of 1s loop to wait for the link. It predates my work on DWC drivers. Maybe Lorenzo could shed some light. I could not find the reference in both DWC and PCIe specs (maybe my grep was bad).
Quoted 11 lines
If the link comes up later, could we handle it as a hot-add? This might be an actual hot-add, or it might be that an Endpoint was present at boot but link training didn't complete until later.
I admit it doesn't look trivial to actually implement this. We would need to be able to detect link-up events, e.g., via hotplug or other link management interrupts. Lacking that hardware functionality, we might need driver-specific code to wait for the link to come up (possibly drivers could skip the wait if they can detect the "slot empty" case).
Quoted 4 lines
Also, the hotplug functionality (pciehp or acpiphp) is currently initialized later and there's probably a race with enabling and detecting hot-add events in the "slot occupied" case.
Quoted 8 lines
As I mentioned above, hotplug is not possible in all the cases. There is a series floating to add GPIO based hotplug, but still that requires board designers to route a dedicated GPIO to the endpoint.
To conclude, we do need to check for the existence of the endpoints during probe. But whether the driver should wait for 1s for the link to come up, should be clarified by Lorenzo.
Lorenzo himself applied my patch [1] which had caused the regression on QCOM platforms. So I am assuming that he is okay with removing this 1s delay.
[1] https://lore.kernel.org/all/[email protected]/
Quoted 4 lines
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 67 lines · Ajay Agarwal
Quoted 58 lines · Manivannan Sadhasivam
Quoted 9 lines · Bjorn Helgaas
Quoted 7 lines · Manivannan Sadhasivam
...
... And for your usecase, allowing the controller driver to start the link post boot just because a device on your Pixel phone comes up later is not a good argument. You _should_not_ define the behavior of a controller driver based on one platform, it is really a bad design.
Quoted 5 lines
I haven't followed the entire discussion, and I don't know much about the specifics of Ajay's situation, but from the controller driver's point of view, shouldn't a device coming up later look like a normal hot-add?
Yes, but most of the form factors that these drivers work with do not support native hotplug. So users have to rescan the bus through sysfs.
Quoted 4 lines
I think most drivers are designed with the assumption that Endpoints are present and powered up at the time of host controller probe, which seems a little stronger than necessary.
Most of the drivers work with endpoints that are fixed in the board design (like M.2), so the endpoints would be up when the controller probes.
Quoted 6 lines
I think the host controller probe should initialize the Root Port such that its LTSSM enters the Detect state, and that much should be basically straight-line code with no waiting. If no Endpoint is attached, i.e., "the slot is empty", it would be nice if the probe could then complete immediately without waiting at all.
Atleast on Qcom platforms, the LTSSM would be in "Detect" state even if no endpoints are found during probe. Then once an endpoint comes up later, link training happens and user can rescan the bus through sysfs.
But, I don't know the real need of 1s loop to wait for the link. It predates my work on DWC drivers. Maybe Lorenzo could shed some light. I could not find the reference in both DWC and PCIe specs (maybe my grep was bad).
Quoted 11 lines
If the link comes up later, could we handle it as a hot-add? This might be an actual hot-add, or it might be that an Endpoint was present at boot but link training didn't complete until later.
I admit it doesn't look trivial to actually implement this. We would need to be able to detect link-up events, e.g., via hotplug or other link management interrupts. Lacking that hardware functionality, we might need driver-specific code to wait for the link to come up (possibly drivers could skip the wait if they can detect the "slot empty" case).
Quoted 4 lines
Also, the hotplug functionality (pciehp or acpiphp) is currently initialized later and there's probably a race with enabling and detecting hot-add events in the "slot occupied" case.
Quoted 8 lines
As I mentioned above, hotplug is not possible in all the cases. There is a series floating to add GPIO based hotplug, but still that requires board designers to route a dedicated GPIO to the endpoint.
To conclude, we do need to check for the existence of the endpoints during probe. But whether the driver should wait for 1s for the link to come up, should be clarified by Lorenzo.
Quoted 6 lines
Lorenzo himself applied my patch [1] which had caused the regression on QCOM platforms. So I am assuming that he is okay with removing this 1s delay.
Hi Mani, I am wondering if you have any thoughts on the above comment?
Quoted 4 lines
Quoted 4 lines
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 63 lines · Manivannan Sadhasivam
+ Joao
Quoted 47 lines · Ajay Agarwal
Quoted 42 lines · Manivannan Sadhasivam
Quoted 32 lines · Ajay Agarwal
Quoted 31 lines · Manivannan Sadhasivam
On Tue, Jan 30, 2024 at 02:30:27PM +0530, Ajay Agarwal wrote:
[...]
Quoted 26 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
Quoted 2 lines
If that's the case with your driver, when are you starting the link training?
The link training starts later based on a userspace/debugfs trigger.
Why does it happen as such? What's the problem in starting the link during probe? Keep it in mind that if you rely on the userspace for starting the link based on a platform (like Android), then if the same SoC or peripheral instance get reused in other platform (non-android), the it won't be a seamless user experience.
If there are any other usecases, please state them.
- Mani
Quoted 7 lines
Quoted 5 lines
This SoC is targeted for an android phone usecase and the endpoints being enumerated need to go through an appropriate and device specific power sequence which gets triggered only when the userspace is up. The PCIe probe cannot assume that the EPs have been powered up already and hence the link-up is not attempted.
Still, I do not see the necessity to not call
start_link()during probe. If youI am not adding any logic/condition around calling the
start_link()itself. I am only avoiding the wait for the link to be up if the controller driver has not definedstart_link().Quoted 8 lines
Quoted 2 lines
I'm saying that not defining the
start_link()callback itself is wrong.Whether the
start_link()should be defined or not, is a different design discussion. We currently have 2 drivers in upstream (intel-gw and dw-plat) which do not havestart_link()defined. Waiting for the link to come up for the platforms using those drivers is not a good idea. And that is what we are trying to avoid.Quoted 4 lines
NO. The sole intention of this patch is to fix the delay observed with _your_ out-of-tree controller driver as you explicitly said before. Impact for the existing 2 drivers are just a side effect.
Quoted 6 lines
Hi Mani,
What is the expectation from the pcie-designware-host driver? If the .start_link() has to be defined by the vendor driver, then shouldn't the probe be failed if the vendor has not defined it? Thereby failing the probe for intel-gw and pcie-dw-plat drivers?intel-gw maintainer agreed to fix the driver [1], but I cannot really comment on the other one. It is not starting the link at all, so don't know how it works. I've CCed the driver author to get some idea.
Quoted 7 lines
Quoted 3 lines
Additionally, if the link fails to come up even after 1 sec of wait time, shouldn't the probe be failed in that case too?
Why? The device can be attached at any point of time. What I'm stressing is, the driver should check for the link to be up during probe and if there is no device, then it should just continue and hope for the device to show up later.
My change is still checking whether the link is up during probe. If yes, print the link status (negotiated speed and width). If no, and the .start_link() exists, then call the same and wait for 1 second for the link to be up.
Quoted 3 lines
This way, the driver can detect the powered up devices during boot and also detect the hotplug devices.
If the .start_link() is not defined, how will the link come up? Are you assuming that the bootloader might have enabled link training?
Quoted 11 lines
Quoted 6 lines
My understanding of these drivers is that the .start_link() is an OPTIONAL callback and that the
dw_pcie_host_initshould help setup the SW structures regardless of whether the .start_link() has been defined or not, and whether the link is up or not. The vendor should be allowed to train the link at a later point of time as well.What do you mean by later point of time? Bringing the link through debugfs? NO. We cannot let each driver behave differently, unless there is a really valid reason.
pci_rescan_bus() is an exported API. I am assuming that this means that it is supposed to be used by modules when they know that the link is up. If a module wishes to bring the link up using debugfs or some other HW trigger, why is that a bad design? In my opinion, this is providing more options to the HW/product designer and the module author, in addition to the already existing .start_link() callback.
Quoted 32 lines
Quoted 15 lines
Please let me know your thoughts.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 9 lines
add
PROBE_PREFER_ASYNCHRONOUSto your controller driver, this delay would become negligible. The reason why I'm against not callingstart_link()is due to below reasons:1. If the same SoC gets reused for other platforms, even other android phones that powers up the endpoints during boot, then it creates a dependency with userspace to always start the link even though the devices were available. That's why we should never fix the behavior of the controller drivers based on a single platform.
I wonder how the behavior is changing with this patch. Do you have an example of a platform which does not have
start_link()defined but would like to still wait for a second for the link to come up?Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Did you went through my reply completely? I mentioned that the 1s delay would be gone if you add the async flag to your driver and you are ignoring that.
The async probe might not help in all the cases. Consider a situation where the PCIe is probed after the boot is already completed. The user will face the delay then. Do you agree?
You mean loading the driver module post boot? If the link is still not up, yes the users will see the 1sec delay.
But again, the point I'm trying to make here is, all the drivers have to follow one flow. We cannot let each driver do its way of starting the link. There could be exceptions if we get a valid reason for a driver to not do so, but so far I haven't come across such reason. (the existing drivers, intel-gw and designware-plat are not exceptions, but they need fixing).
Quoted 6 lines
For your driver, you said that the userspace brings up the link, post boot when the devices are powered on. So starting the link during probe incurs 1s delay, as there would be no devices. But I suggested you to enable async probe to nullify the 1s delay during probe and you confirmed that it fixes the issue for you.
There are emulation/simulation platforms in which 1 second of runtime can correspond to ~1 hour of real-world time. Even if PCIe is probed asyncronously, it will still block the next set of processes.
Quoted 2 lines
Then you are again debating about not defining the
start_link()callback :(
I am not sure why you think I am debating against defining the .start_link() callback. It is clearly an optional pointer and I am choosing to not use it because of the usecase. And if it is optional and I am not using it, why waste 1 sec of runtime waiting for the link? Do we have an example in upstream of platforms where this 1 sec could prove useful where link training is not being started by the platform driver but EPs have to be detected because they are present and powered-up?
Quoted 49 lines
I've made by point clear, please do not take inspiration from those drivers, they really need fixing. And for your usecase, allowing the controller driver to start the link post boot just because a device on your Pixel phone comes up later is not a good argument. You _should_not_ define the behavior of a controller driver based on one platform, it is really a bad design.
- Mani
Quoted 38 lines
Quoted 38 lines
Quoted 4 lines
Yes, I did go through your suggestion of async probe and that might solve my problem of the 1 sec delay. But I would like to fix the problem at the core.
There is no problem at the core. The problem is with some controller drivers. Please do not try to fix a problem which is not there. There are no _special_ reasons for those 2 drivers to not define
start_link()callback. I'm trying to point you in the right path, but you are always chosing the other one.Quoted 12 lines
Quoted 12 lines
But again, I'm saying that not defining
start_link()itself is wrong and I've already mentioned the reasons.Quoted 4 lines
For example, consider the intel-gw driver. The 1 sec wait time in its probe path is also a waste because it explicitly starts link training later in time.
I previously mentioned that the intel-gw needs fixing since there is no point in starting the link and waiting for it to come up in its
probe()if the DWC core is already doing that.Quoted 6 lines
Quoted 4 lines
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்I think we are at a dead-end in terms of agreeing to a policy. I would like the maintainers to pitch in here with their views.
I'm the maintainer of the DWC drivers that you are proposing the patch for. If you happen to spin future revision of this series, please carry:
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 68 lines · Ajay Agarwal
Quoted 67 lines · Manivannan Sadhasivam
+ Joao
Quoted 47 lines · Ajay Agarwal
Quoted 42 lines · Manivannan Sadhasivam
Quoted 32 lines · Ajay Agarwal
Quoted 31 lines · Manivannan Sadhasivam
On Tue, Jan 30, 2024 at 02:30:27PM +0530, Ajay Agarwal wrote:
[...]
Quoted 26 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
Quoted 2 lines
If that's the case with your driver, when are you starting the link training?
The link training starts later based on a userspace/debugfs trigger.
Why does it happen as such? What's the problem in starting the link during probe? Keep it in mind that if you rely on the userspace for starting the link based on a platform (like Android), then if the same SoC or peripheral instance get reused in other platform (non-android), the it won't be a seamless user experience.
If there are any other usecases, please state them.
- Mani
Quoted 7 lines
Quoted 5 lines
This SoC is targeted for an android phone usecase and the endpoints being enumerated need to go through an appropriate and device specific power sequence which gets triggered only when the userspace is up. The PCIe probe cannot assume that the EPs have been powered up already and hence the link-up is not attempted.
Still, I do not see the necessity to not call
start_link()during probe. If youI am not adding any logic/condition around calling the
start_link()itself. I am only avoiding the wait for the link to be up if the controller driver has not definedstart_link().Quoted 8 lines
Quoted 2 lines
I'm saying that not defining the
start_link()callback itself is wrong.Whether the
start_link()should be defined or not, is a different design discussion. We currently have 2 drivers in upstream (intel-gw and dw-plat) which do not havestart_link()defined. Waiting for the link to come up for the platforms using those drivers is not a good idea. And that is what we are trying to avoid.Quoted 4 lines
NO. The sole intention of this patch is to fix the delay observed with _your_ out-of-tree controller driver as you explicitly said before. Impact for the existing 2 drivers are just a side effect.
Quoted 6 lines
Hi Mani,
What is the expectation from the pcie-designware-host driver? If the .start_link() has to be defined by the vendor driver, then shouldn't the probe be failed if the vendor has not defined it? Thereby failing the probe for intel-gw and pcie-dw-plat drivers?intel-gw maintainer agreed to fix the driver [1], but I cannot really comment on the other one. It is not starting the link at all, so don't know how it works. I've CCed the driver author to get some idea.
Quoted 3 lines
Additionally, if the link fails to come up even after 1 sec of wait time, shouldn't the probe be failed in that case too?
Quoted 8 lines
Quoted 3 lines
Why? The device can be attached at any point of time. What I'm stressing is, the driver should check for the link to be up during probe and if there is no device, then it should just continue and hope for the device to show up later.
My change is still checking whether the link is up during probe. If yes, print the link status (negotiated speed and width). If no, and the .start_link() exists, then call the same and wait for 1 second for the link to be up.
There is a reason why we are wating for 1s for the device to show up during probe. Please look at my earlier reply to Bjorn.
Quoted 6 lines
Quoted 3 lines
This way, the driver can detect the powered up devices during boot and also detect the hotplug devices.
If the .start_link() is not defined, how will the link come up? Are you assuming that the bootloader might have enabled link training?
Yes, something like that. But that assumption is moot in the first place.
Quoted 11 lines
Quoted 11 lines
Quoted 6 lines
My understanding of these drivers is that the .start_link() is an OPTIONAL callback and that the
dw_pcie_host_initshould help setup the SW structures regardless of whether the .start_link() has been defined or not, and whether the link is up or not. The vendor should be allowed to train the link at a later point of time as well.What do you mean by later point of time? Bringing the link through debugfs? NO. We cannot let each driver behave differently, unless there is a really valid reason.
Quoted 7 lines
pci_rescan_bus()is an exported API. I am assuming that this means that it is supposed to be used by modules when they know that the link is up. If a module wishes to bring the link up using debugfs or some other HW trigger, why is that a bad design? In my opinion, this is providing more options to the HW/product designer and the module author, in addition to the already existing .start_link() callback.
If the driver _knows_ that the device is up, then rescanning the bus makes sense. But here we are checking for the existence of the device.
Quoted 38 lines
Quoted 32 lines
Quoted 15 lines
Please let me know your thoughts.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 9 lines
add
PROBE_PREFER_ASYNCHRONOUSto your controller driver, this delay would become negligible. The reason why I'm against not callingstart_link()is due to below reasons:1. If the same SoC gets reused for other platforms, even other android phones that powers up the endpoints during boot, then it creates a dependency with userspace to always start the link even though the devices were available. That's why we should never fix the behavior of the controller drivers based on a single platform.
I wonder how the behavior is changing with this patch. Do you have an example of a platform which does not have
start_link()defined but would like to still wait for a second for the link to come up?Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Did you went through my reply completely? I mentioned that the 1s delay would be gone if you add the async flag to your driver and you are ignoring that.
The async probe might not help in all the cases. Consider a situation where the PCIe is probed after the boot is already completed. The user will face the delay then. Do you agree?
You mean loading the driver module post boot? If the link is still not up, yes the users will see the 1sec delay.
But again, the point I'm trying to make here is, all the drivers have to follow one flow. We cannot let each driver do its way of starting the link. There could be exceptions if we get a valid reason for a driver to not do so, but so far I haven't come across such reason. (the existing drivers, intel-gw and designware-plat are not exceptions, but they need fixing).
Quoted 6 lines
For your driver, you said that the userspace brings up the link, post boot when the devices are powered on. So starting the link during probe incurs 1s delay, as there would be no devices. But I suggested you to enable async probe to nullify the 1s delay during probe and you confirmed that it fixes the issue for you.
Quoted 4 lines
There are emulation/simulation platforms in which 1 second of runtime can correspond to ~1 hour of real-world time. Even if PCIe is probed asyncronously, it will still block the next set of processes.
Which simulation/emulation platform? The one during pre-production stage? If there is no endpoint connected, why would you enable the controller first place? And how can the endpoint show up later during simulation? Why can't it be up earlier?
Quoted 10 lines
Quoted 2 lines
Then you are again debating about not defining the
start_link()callback :(I am not sure why you think I am debating against defining the .start_link() callback. It is clearly an optional pointer and I am choosing to not use it because of the usecase. And if it is optional and I am not using it, why waste 1 sec of runtime waiting for the link? Do we have an example in upstream of platforms where this 1 sec could prove useful where link training is not being started by the platform driver but EPs have to be detected because they are present and powered-up?
Please tell me how the link is started in your case without start_link() callback.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 72 lines · Manivannan Sadhasivam
Quoted 71 lines · Ajay Agarwal
Quoted 70 lines · Manivannan Sadhasivam
+ Joao
Quoted 47 lines · Ajay Agarwal
Quoted 42 lines · Manivannan Sadhasivam
Quoted 32 lines · Ajay Agarwal
Quoted 31 lines · Manivannan Sadhasivam
On Tue, Jan 30, 2024 at 02:30:27PM +0530, Ajay Agarwal wrote:
[...]
Quoted 26 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
Quoted 2 lines
If that's the case with your driver, when are you starting the link training?
The link training starts later based on a userspace/debugfs trigger.
Why does it happen as such? What's the problem in starting the link during probe? Keep it in mind that if you rely on the userspace for starting the link based on a platform (like Android), then if the same SoC or peripheral instance get reused in other platform (non-android), the it won't be a seamless user experience.
If there are any other usecases, please state them.
- Mani
Quoted 7 lines
Quoted 5 lines
This SoC is targeted for an android phone usecase and the endpoints being enumerated need to go through an appropriate and device specific power sequence which gets triggered only when the userspace is up. The PCIe probe cannot assume that the EPs have been powered up already and hence the link-up is not attempted.
Still, I do not see the necessity to not call
start_link()during probe. If youI am not adding any logic/condition around calling the
start_link()itself. I am only avoiding the wait for the link to be up if the controller driver has not definedstart_link().Quoted 8 lines
Quoted 2 lines
I'm saying that not defining the
start_link()callback itself is wrong.Whether the
start_link()should be defined or not, is a different design discussion. We currently have 2 drivers in upstream (intel-gw and dw-plat) which do not havestart_link()defined. Waiting for the link to come up for the platforms using those drivers is not a good idea. And that is what we are trying to avoid.Quoted 4 lines
NO. The sole intention of this patch is to fix the delay observed with _your_ out-of-tree controller driver as you explicitly said before. Impact for the existing 2 drivers are just a side effect.
Quoted 6 lines
Hi Mani,
What is the expectation from the pcie-designware-host driver? If the .start_link() has to be defined by the vendor driver, then shouldn't the probe be failed if the vendor has not defined it? Thereby failing the probe for intel-gw and pcie-dw-plat drivers?intel-gw maintainer agreed to fix the driver [1], but I cannot really comment on the other one. It is not starting the link at all, so don't know how it works. I've CCed the driver author to get some idea.
Quoted 3 lines
Additionally, if the link fails to come up even after 1 sec of wait time, shouldn't the probe be failed in that case too?
Why? The device can be attached at any point of time. What I'm stressing is, the driver should check for the link to be up during probe and if there is no device, then it should just continue and hope for the device to show up later.
Quoted 9 lines
Quoted 5 lines
My change is still checking whether the link is up during probe. If yes, print the link status (negotiated speed and width). If no, and the .start_link() exists, then call the same and wait for 1 second for the link to be up.
There is a reason why we are wating for 1s for the device to show up during probe. Please look at my earlier reply to Bjorn.
Yes, I looked at that. I am not sure if that is the real reason behind this delay. The explanation that you quoted from the spec talks about allowing 1s delay for the EP to return a completion. Whereas the delay here is to wait for the link training itself to be completed.
We could surely wait for Lorenzo to explain the reason behind this delay, but he himself approved the earlier patch [1] (which caused the regression and had to be reverted):
[1] https://lore.kernel.org/all/[email protected]/
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
This way, the driver can detect the powered up devices during boot and also detect the hotplug devices.
If the .start_link() is not defined, how will the link come up? Are you assuming that the bootloader might have enabled link training?
Yes, something like that. But that assumption is moot in the first place.
Isnt it weird that a PCIe driver, which will most likely initialize all the resources like power, resets, clocks etc., relies on the bootloader to have enabled the link training?
I think it is safe to assume that a driver should have the start_link() defined if it wishes to bring the link up during probe.
Quoted 19 lines
Quoted 11 lines
Quoted 11 lines
Quoted 6 lines
My understanding of these drivers is that the .start_link() is an OPTIONAL callback and that the
dw_pcie_host_initshould help setup the SW structures regardless of whether the .start_link() has been defined or not, and whether the link is up or not. The vendor should be allowed to train the link at a later point of time as well.What do you mean by later point of time? Bringing the link through debugfs? NO. We cannot let each driver behave differently, unless there is a really valid reason.
Quoted 7 lines
pci_rescan_bus()is an exported API. I am assuming that this means that it is supposed to be used by modules when they know that the link is up. If a module wishes to bring the link up using debugfs or some other HW trigger, why is that a bad design? In my opinion, this is providing more options to the HW/product designer and the module author, in addition to the already existing .start_link() callback.
Quoted 3 lines
If the driver _knows_ that the device is up, then rescanning the bus makes sense. But here we are checking for the existence of the device.
Yeah, so the driver could _know_ that the device is up later in the game, right? And then re-scan the bus? Why wait for 1 sec here?
Quoted 38 lines
Quoted 38 lines
Quoted 38 lines
Quoted 15 lines
Please let me know your thoughts.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 9 lines
add
PROBE_PREFER_ASYNCHRONOUSto your controller driver, this delay would become negligible. The reason why I'm against not callingstart_link()is due to below reasons:1. If the same SoC gets reused for other platforms, even other android phones that powers up the endpoints during boot, then it creates a dependency with userspace to always start the link even though the devices were available. That's why we should never fix the behavior of the controller drivers based on a single platform.
I wonder how the behavior is changing with this patch. Do you have an example of a platform which does not have
start_link()defined but would like to still wait for a second for the link to come up?Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Did you went through my reply completely? I mentioned that the 1s delay would be gone if you add the async flag to your driver and you are ignoring that.
The async probe might not help in all the cases. Consider a situation where the PCIe is probed after the boot is already completed. The user will face the delay then. Do you agree?
You mean loading the driver module post boot? If the link is still not up, yes the users will see the 1sec delay.
But again, the point I'm trying to make here is, all the drivers have to follow one flow. We cannot let each driver do its way of starting the link. There could be exceptions if we get a valid reason for a driver to not do so, but so far I haven't come across such reason. (the existing drivers, intel-gw and designware-plat are not exceptions, but they need fixing).
For your driver, you said that the userspace brings up the link, post boot when the devices are powered on. So starting the link during probe incurs 1s delay, as there would be no devices. But I suggested you to enable async probe to nullify the 1s delay during probe and you confirmed that it fixes the issue for you.
Quoted 6 lines
Quoted 4 lines
There are emulation/simulation platforms in which 1 second of runtime can correspond to ~1 hour of real-world time. Even if PCIe is probed asyncronously, it will still block the next set of processes.
Which simulation/emulation platform? The one during pre-production stage? If
Yes, the pre-production stage emulation platform.
Quoted 1 line
there is no endpoint connected, why would you enable the controller first place?
The endpoint is connected. But my usecase requires me to not bring it up by default. Rather, I start the link training later using debugfs. So I want to test my driver probe without attempting link training and thereby, I face the 1 sec delay. I want to avoid it.
Quoted 3 lines
And how can the endpoint show up later during simulation? Why can't it be up earlier?
As explained above, I use debugfs to bring the link up later. The logic for that is present in my platform driver. Once the link is up, I call pci_rescan_bus() to enumerate the EP.
Quoted 11 lines
Quoted 10 lines
Quoted 2 lines
Then you are again debating about not defining the
start_link()callback :(I am not sure why you think I am debating against defining the .start_link() callback. It is clearly an optional pointer and I am choosing to not use it because of the usecase. And if it is optional and I am not using it, why waste 1 sec of runtime waiting for the link? Do we have an example in upstream of platforms where this 1 sec could prove useful where link training is not being started by the platform driver but EPs have to be detected because they are present and powered-up?
Quoted 3 lines
Please tell me how the link is started in your case without
start_link()callback.
As explained above, one method is to use debugfs to start the link training. The actual usecase is for the userspace to start the link training based on certain GPIO events from the endpoint.
Quoted 4 lines
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Manivannan Sadhasivam
maintainerQuoted 79 lines · Ajay Agarwal
Quoted 78 lines · Manivannan Sadhasivam
Quoted 76 lines · Ajay Agarwal
Quoted 63 lines · Manivannan Sadhasivam
+ Joao
Quoted 47 lines · Ajay Agarwal
Quoted 42 lines · Manivannan Sadhasivam
Quoted 32 lines · Ajay Agarwal
Quoted 31 lines · Manivannan Sadhasivam
On Tue, Jan 30, 2024 at 02:30:27PM +0530, Ajay Agarwal wrote:
[...]
Quoted 26 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
If that's the case with your driver, when are you starting the link training?
The link training starts later based on a userspace/debugfs trigger.
Why does it happen as such? What's the problem in starting the link during probe? Keep it in mind that if you rely on the userspace for starting the link based on a platform (like Android), then if the same SoC or peripheral instance get reused in other platform (non-android), the it won't be a seamless user experience.
If there are any other usecases, please state them.
- Mani
Quoted 7 lines
Quoted 5 lines
This SoC is targeted for an android phone usecase and the endpoints being enumerated need to go through an appropriate and device specific power sequence which gets triggered only when the userspace is up. The PCIe probe cannot assume that the EPs have been powered up already and hence the link-up is not attempted.
Still, I do not see the necessity to not call
start_link()during probe. If youI am not adding any logic/condition around calling the
start_link()itself. I am only avoiding the wait for the link to be up if the controller driver has not definedstart_link().Quoted 8 lines
Quoted 2 lines
I'm saying that not defining the
start_link()callback itself is wrong.Whether the
start_link()should be defined or not, is a different design discussion. We currently have 2 drivers in upstream (intel-gw and dw-plat) which do not havestart_link()defined. Waiting for the link to come up for the platforms using those drivers is not a good idea. And that is what we are trying to avoid.Quoted 4 lines
NO. The sole intention of this patch is to fix the delay observed with _your_ out-of-tree controller driver as you explicitly said before. Impact for the existing 2 drivers are just a side effect.
Quoted 6 lines
Hi Mani,
What is the expectation from the pcie-designware-host driver? If the .start_link() has to be defined by the vendor driver, then shouldn't the probe be failed if the vendor has not defined it? Thereby failing the probe for intel-gw and pcie-dw-plat drivers?intel-gw maintainer agreed to fix the driver [1], but I cannot really comment on the other one. It is not starting the link at all, so don't know how it works. I've CCed the driver author to get some idea.
Quoted 7 lines
Quoted 3 lines
Additionally, if the link fails to come up even after 1 sec of wait time, shouldn't the probe be failed in that case too?
Why? The device can be attached at any point of time. What I'm stressing is, the driver should check for the link to be up during probe and if there is no device, then it should just continue and hope for the device to show up later.
My change is still checking whether the link is up during probe. If yes, print the link status (negotiated speed and width). If no, and the .start_link() exists, then call the same and wait for 1 second for the link to be up.
Quoted 8 lines
Quoted 3 lines
There is a reason why we are wating for 1s for the device to show up during probe. Please look at my earlier reply to Bjorn.
Yes, I looked at that. I am not sure if that is the real reason behind this delay. The explanation that you quoted from the spec talks about allowing 1s delay for the EP to return a completion. Whereas the delay here is to wait for the link training itself to be completed.
It is implied, afaiu. But the best person to comment here is Lorenzo.
Quoted 4 lines
We could surely wait for Lorenzo to explain the reason behind this delay, but he himself approved the earlier patch [1] (which caused the regression and had to be reverted):
This is not a valid argument.
Quoted 9 lines
[1] https://lore.kernel.org/all/[email protected]/
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
This way, the driver can detect the powered up devices during boot and also detect the hotplug devices.
If the .start_link() is not defined, how will the link come up? Are you assuming that the bootloader might have enabled link training?
Quoted 6 lines
Quoted 2 lines
Yes, something like that. But that assumption is moot in the first place.
Isnt it weird that a PCIe driver, which will most likely initialize all the resources like power, resets, clocks etc., relies on the bootloader to have enabled the link training?
That's why I said that assumption is 'moot'.
Quoted 3 lines
I think it is safe to assume that a driver should have the
start_link()defined if it wishes to bring the link up during probe.
I keep repeating this. But let me do one more time.
There should be a valid reason for a driver to defer the start_link(). In your case, the problem is you are tying the driver with the Android usecase which is not going to work on other platforms. What is worse is, you are forcing the users to enable the link training post boot. It may work for you currently, as you need to bring up the endpoint manually for various reasons, but what if some other OEM has connected an endpoint that gets powered on during the controller probe? Still the user has to start the link manually. Will that provide a nice user experience? NO. Then the developers will start complaining that they cannot see the endpoint during boot even though it got powered up properly.
Second, we cannot have different policies for different drivers to start the link unless there is a valid reason. This will become a maintenance burden. For sure, there are differences in the current drivers, but those should be fixed instead of extended.
So to address your issue, I can suggest two things:
1. Wait for Lorenzo to clarify the 1s loop while waiting for link up. If that seem to be required, then keep this patch out-of-tree. Btw, your driver is still out-of-tree...
2. Try to bringup the endpoint during boot itself. We already have a series to achieve that [1].
- Mani
[1] https://lore.kernel.org/linux-pci/[email protected]/
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 143 lines · Manivannan Sadhasivam
Quoted 79 lines · Ajay Agarwal
Quoted 78 lines · Manivannan Sadhasivam
Quoted 76 lines · Ajay Agarwal
Quoted 63 lines · Manivannan Sadhasivam
+ Joao
Quoted 47 lines · Ajay Agarwal
Quoted 42 lines · Manivannan Sadhasivam
Quoted 32 lines · Ajay Agarwal
Quoted 31 lines · Manivannan Sadhasivam
On Tue, Jan 30, 2024 at 02:30:27PM +0530, Ajay Agarwal wrote:
[...]
Quoted 26 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
If that's the case with your driver, when are you starting the link training?
The link training starts later based on a userspace/debugfs trigger.
Why does it happen as such? What's the problem in starting the link during
probe? Keep it in mind that if you rely on the userspace for starting the link
based on a platform (like Android), then if the same SoC or peripheral instance
get reused in other platform (non-android), the it won't be a seamless user
experience.If there are any other usecases, please state them.
- Mani
Quoted 7 lines
Quoted 5 lines
This SoC is targeted for an android phone usecase and the endpoints being enumerated need to go through an appropriate and device specific power sequence which gets triggered only when the userspace is up. The PCIe probe cannot assume that the EPs have been powered up already and hence the link-up is not attempted.
Still, I do not see the necessity to not call
start_link()during probe. If youI am not adding any logic/condition around calling the
start_link()itself. I am only avoiding the wait for the link to be up if the controller driver has not definedstart_link().Quoted 8 lines
Quoted 2 lines
I'm saying that not defining the
start_link()callback itself is wrong.Whether the
start_link()should be defined or not, is a different design discussion. We currently have 2 drivers in upstream (intel-gw and dw-plat) which do not havestart_link()defined. Waiting for the link to come up for the platforms using those drivers is not a good idea. And that is what we are trying to avoid.Quoted 4 lines
NO. The sole intention of this patch is to fix the delay observed with _your_ out-of-tree controller driver as you explicitly said before. Impact for the existing 2 drivers are just a side effect.
Quoted 6 lines
Hi Mani,
What is the expectation from the pcie-designware-host driver? If the .start_link() has to be defined by the vendor driver, then shouldn't the probe be failed if the vendor has not defined it? Thereby failing the probe for intel-gw and pcie-dw-plat drivers?intel-gw maintainer agreed to fix the driver [1], but I cannot really comment on the other one. It is not starting the link at all, so don't know how it works. I've CCed the driver author to get some idea.
Quoted 7 lines
Quoted 3 lines
Additionally, if the link fails to come up even after 1 sec of wait time, shouldn't the probe be failed in that case too?
Why? The device can be attached at any point of time. What I'm stressing is, the driver should check for the link to be up during probe and if there is no device, then it should just continue and hope for the device to show up later.
My change is still checking whether the link is up during probe. If yes, print the link status (negotiated speed and width). If no, and the .start_link() exists, then call the same and wait for 1 second for the link to be up.
Quoted 8 lines
Quoted 3 lines
There is a reason why we are wating for 1s for the device to show up during probe. Please look at my earlier reply to Bjorn.
Yes, I looked at that. I am not sure if that is the real reason behind this delay. The explanation that you quoted from the spec talks about allowing 1s delay for the EP to return a completion. Whereas the delay here is to wait for the link training itself to be completed.
It is implied, afaiu. But the best person to comment here is Lorenzo.
Quoted 4 lines
We could surely wait for Lorenzo to explain the reason behind this delay, but he himself approved the earlier patch [1] (which caused the regression and had to be reverted):
This is not a valid argument.
Quoted 9 lines
[1] https://lore.kernel.org/all/[email protected]/
Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
This way, the driver can detect the powered up devices during boot and also detect the hotplug devices.
If the .start_link() is not defined, how will the link come up? Are you assuming that the bootloader might have enabled link training?
Quoted 6 lines
Quoted 2 lines
Yes, something like that. But that assumption is moot in the first place.
Isnt it weird that a PCIe driver, which will most likely initialize all the resources like power, resets, clocks etc., relies on the bootloader to have enabled the link training?
That's why I said that assumption is 'moot'.
Quoted 3 lines
I think it is safe to assume that a driver should have the
start_link()defined if it wishes to bring the link up during probe.I keep repeating this. But let me do one more time.
There should be a valid reason for a driver to defer the
start_link(). In your case, the problem is you are tying the driver with the Android usecase which is not going to work on other platforms. What is worse is, you are forcing the users to enable the link training post boot. It may work for you currently, as you need to bring up the endpoint manually for various reasons, but what if some other OEM has connected an endpoint that gets powered on during the controller probe? Still the user has to start the link manually. Will that provide a nice user experience? NO. Then the developers will start complaining that they cannot see the endpoint during boot even though it got powered up properly.Second, we cannot have different policies for different drivers to start the link unless there is a valid reason. This will become a maintenance burden. For sure, there are differences in the current drivers, but those should be fixed instead of extended.
So to address your issue, I can suggest two things:
1. Wait for Lorenzo to clarify the 1s loop while waiting for link up. If that seem to be required, then keep this patch out-of-tree. Btw, your driver is still out-of-tree...
Quoted 9 lines
2. Try to bringup the endpoint during boot itself. We already have a series to achieve that [1].
- Mani
[1] https://lore.kernel.org/linux-pci/[email protected]/
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Hello Mani
Restarting this discussion for skipping the 1 sec of wait time if a certain platform does not necessarily wish or expect to bring the link up during probe time. I discussed with William and we think that a module parameter can be added which if true, would lead to the skipping of the wait time. By default, this parameter would be false, thereby ensuring that the current behaviour to wait for the link is maintained.
Please let me know if this is worth exploring.
Quoted 8 lines · Ajay Agarwal
Restarting this discussion for skipping the 1 sec of wait time if a certain platform does not necessarily wish or expect to bring the link up during probe time. I discussed with William and we think that a module parameter can be added which if true, would lead to the skipping of the wait time. By default, this parameter would be false, thereby ensuring that the current behaviour to wait for the link is maintained.
Please let me know if this is worth exploring.
No, module parameters are a thing of the past (except possibly in vendor kernels). The default behaviour should just work.
Johan
Quoted 9 lines · Johan Hovold
Quoted 7 lines · Ajay Agarwal
Restarting this discussion for skipping the 1 sec of wait time if a certain platform does not necessarily wish or expect to bring the link up during probe time. I discussed with William and we think that a module parameter can be added which if true, would lead to the skipping of the wait time. By default, this parameter would be false, thereby ensuring that the current behaviour to wait for the link is maintained.
Quoted 5 lines
Quoted 1 line
Please let me know if this is worth exploring.
No, module parameters are a thing of the past (except possibly in vendor kernels). The default behaviour should just work.
+1
Btw, you need to come up with a valid argument for not enabling the link during probe. Also, not waiting for link during probe is also not going to work across all platforms where the controller is used, unless your hardware supports hotplug or LINK_UP IRQ.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 12 lines · Manivannan Sadhasivam
Quoted 11 lines · Johan Hovold
Quoted 8 lines · Ajay Agarwal
Restarting this discussion for skipping the 1 sec of wait time if a certain platform does not necessarily wish or expect to bring the link up during probe time. I discussed with William and we think that a module parameter can be added which if true, would lead to the skipping of the wait time. By default, this parameter would be false, thereby ensuring that the current behaviour to wait for the link is maintained.
Please let me know if this is worth exploring.
Quoted 7 lines
Quoted 3 lines
No, module parameters are a thing of the past (except possibly in vendor kernels). The default behaviour should just work.
+1
Btw, you need to come up with a valid argument for not enabling the link during
The argument for the link to not come up during probe is simply that the product does not need the link to be up during probe. The requirement is that the PCIe RC SW structures be prepared for link-up later, when there is a trigger from the userspace or the vendor kernel driver.
I am looking to treat this like USB, say. The USB DWC could be probed when the cable is not connected. That does not fail the probe. Later when the cable is connected, the USB link comes up and the enumeration is performed.
Quoted 3 lines
probe. Also, not waiting for link during probe is also not going to work across all platforms where the controller is used, unless your hardware supports hotplug or
LINK_UPIRQ.
We do not necessarily need the hotplug or LINK_UP IRQ right? Once the LTSSM training is enabled using the triggers I mentioned above, I can then wait for the link to come up using dw_pcie_wait_for_link. IOW, polling for the link, which is what the dw_pcie_host_init does.
Quoted 5 lines
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 17 lines · Ajay Agarwal
Quoted 16 lines · Manivannan Sadhasivam
Quoted 14 lines · Johan Hovold
Quoted 8 lines · Ajay Agarwal
Restarting this discussion for skipping the 1 sec of wait time if a certain platform does not necessarily wish or expect to bring the link up during probe time. I discussed with William and we think that a module parameter can be added which if true, would lead to the skipping of the wait time. By default, this parameter would be false, thereby ensuring that the current behaviour to wait for the link is maintained.
Please let me know if this is worth exploring.
No, module parameters are a thing of the past (except possibly in vendor kernels). The default behaviour should just work.
Quoted 8 lines
Quoted 3 lines
+1
Btw, you need to come up with a valid argument for not enabling the link during
The argument for the link to not come up during probe is simply that the product does not need the link to be up during probe. The requirement is that the PCIe RC SW structures be prepared for link-up later, when there is a trigger from the userspace or the vendor kernel driver.
This is the problem. You are fixing the behavior of the controller driver to a single product line and this is not going to work if the same controller is used in a different product. Instead you should fix the userspace.
Quoted 5 lines
I am looking to treat this like USB, say. The USB DWC could be probed when the cable is not connected. That does not fail the probe. Later when the cable is connected, the USB link comes up and the enumeration is performed.
Same with DWC controllers as well, probe doesn't fail even if the link did not come up. Previously you were trying to avoid the delay while waiting for the link up during probe (for which I also asked you to probe the controller driver asynchronously to mitigate the delay). Is this the same case still?
And what makes me nervous is the fact that you are trying to upstream a change for your downstream driver, which is a big no-go.
Quoted 8 lines
Quoted 3 lines
probe. Also, not waiting for link during probe is also not going to work across all platforms where the controller is used, unless your hardware supports hotplug or
LINK_UPIRQ.We do not necessarily need the hotplug or
LINK_UPIRQ right? Once the LTSSM training is enabled using the triggers I mentioned above, I can then wait for the link to come up usingdw_pcie_wait_for_link. IOW, polling for the link, which is what thedw_pcie_host_initdoes.
Oh, you do not want link training to be started during probe? So how your 'userspace trigger' is starting it? What is the reason to hold off the link training?
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Hi Mani and Johan,
Quoted 27 lines · Manivannan Sadhasivam
Quoted 17 lines · Ajay Agarwal
Quoted 16 lines · Manivannan Sadhasivam
Quoted 14 lines · Johan Hovold
Quoted 8 lines · Ajay Agarwal
Restarting this discussion for skipping the 1 sec of wait time if a certain platform does not necessarily wish or expect to bring the link up during probe time. I discussed with William and we think that a module parameter can be added which if true, would lead to the skipping of the wait time. By default, this parameter would be false, thereby ensuring that the current behaviour to wait for the link is maintained.
Please let me know if this is worth exploring.
No, module parameters are a thing of the past (except possibly in vendor kernels). The default behaviour should just work.
Quoted 8 lines
Quoted 3 lines
+1
Btw, you need to come up with a valid argument for not enabling the link during
The argument for the link to not come up during probe is simply that the product does not need the link to be up during probe. The requirement is that the PCIe RC SW structures be prepared for link-up later, when there is a trigger from the userspace or the vendor kernel driver.
Quoted 4 lines
This is the problem. You are fixing the behavior of the controller driver to a single product line and this is not going to work if the same controller is used in a different product. Instead you should fix the userspace.
Do you have an alternative suggestion on how to fix this in userspace without a module parameter? I'd argue that module parameters are very much still used in the upstream kernel to allow the userspace platform (Android in this case) to control driver behavior at module load time. Here are some recent examples I found on lore:
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
By default (without any module parameter set by userspace), the driver would behave as it does today and spin for 1s on probe waiting for the link to come up. That will work for both Android and other Linux distros. We are only proposing the parameter to allow userspace to optimize boot time by skipping the link up wait time on probe when the userspace knows how to properly handle this.
<snip>
Quoted 4 lines
Same with DWC controllers as well, probe doesn't fail even if the link did not come up. Previously you were trying to avoid the delay while waiting for the link up during probe (for which I also asked you to probe the controller driver asynchronously to mitigate the delay). Is this the same case still?
Async probing may work, but that is just hiding the problem we are trying to address -- unnecessarily spinning for 1s on probe. If userspace can handle bringing up the link later, then IMO it's a valid argument to allow the driver to skip the 1s delay.
Quoted 3 lines
And what makes me nervous is the fact that you are trying to upstream a change for your downstream driver, which is a big no-go.
As you may know, we (Google and Linaro) are actively upstreaming Pixel 6 drivers and will be adding support for the gs101 PCIe driver in the near future. So this isn't just for a downstream driver running Android.
Thanks,
Will
Quoted 30 lines · William McVicker
Hi Mani and Johan,
Quoted 27 lines · Manivannan Sadhasivam
Quoted 25 lines · Ajay Agarwal
Quoted 12 lines · Manivannan Sadhasivam
Quoted 11 lines · Johan Hovold
Quoted 8 lines · Ajay Agarwal
Restarting this discussion for skipping the 1 sec of wait time if a certain platform does not necessarily wish or expect to bring the link up during probe time. I discussed with William and we think that a module parameter can be added which if true, would lead to the skipping of the wait time. By default, this parameter would be false, thereby ensuring that the current behaviour to wait for the link is maintained.
Please let me know if this is worth exploring.
Quoted 7 lines
Quoted 3 lines
No, module parameters are a thing of the past (except possibly in vendor kernels). The default behaviour should just work.
+1
Btw, you need to come up with a valid argument for not enabling the link during
The argument for the link to not come up during probe is simply that the product does not need the link to be up during probe. The requirement is that the PCIe RC SW structures be prepared for link-up later, when there is a trigger from the userspace or the vendor kernel driver.
Quoted 7 lines
Quoted 4 lines
This is the problem. You are fixing the behavior of the controller driver to a single product line and this is not going to work if the same controller is used in a different product. Instead you should fix the userspace.
Do you have an alternative suggestion on how to fix this in userspace without a module parameter?
For that you need to explain the requirement clearly. Why does the userspace need to trigger the kernel?
Quoted 5 lines
I'd argue that module parameters are very much still used
in the upstream kernel to allow the userspace platform (Android in this case) to control driver behavior at module load time. Here are some recent examples I found on lore:
These are not going to help. Greg himself has said in many threads that module params are dead. It just makes the code messy. These are still used for some exceptional cases though.
Quoted 17 lines
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/By default (without any module parameter set by userspace), the driver would behave as it does today and spin for 1s on probe waiting for the link to come up. That will work for both Android and other Linux distros. We are only proposing the parameter to allow userspace to optimize boot time by skipping the link up wait time on probe when the userspace knows how to properly handle this.
<snip>
Quoted 4 lines
Same with DWC controllers as well, probe doesn't fail even if the link did not come up. Previously you were trying to avoid the delay while waiting for the link up during probe (for which I also asked you to probe the controller driver asynchronously to mitigate the delay). Is this the same case still?
Quoted 5 lines
Async probing may work, but that is just hiding the problem we are trying to address -- unnecessarily spinning for 1s on probe. If userspace can handle bringing up the link later, then IMO it's a valid argument to allow the driver to skip the 1s delay.
Again, you need to present us a full picture here and not provide a hint. How does the userspace bring up the link? Why the kernel has to depend on it?
Quoted 8 lines
Quoted 3 lines
And what makes me nervous is the fact that you are trying to upstream a change for your downstream driver, which is a big no-go.
As you may know, we (Google and Linaro) are actively upstreaming Pixel 6 drivers and will be adding support for the gs101 PCIe driver in the near future. So this isn't just for a downstream driver running Android.
But this patch is being proposed for more than 6 months (~1year?) without any evidence of the controller driver in question. With GKI, who knows which vendor driver is going to be a module.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 8 lines · Manivannan Sadhasivam
Quoted 6 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.
Quoted 6 lines
Which platform you are working on? Is that upstreamed? You should mention the specific platform where you are observing the issue.
Right now, intel-gw and designware-plat are the only drivers not defining that callback. First one definitely needs a fixup and I do not know how the latter works.
What fixup do you have in mind for intel-gw?
It looks a little strange to me because it duplicates dw_pcie_setup_rc() and dw_pcie_wait_for_link(): dw_pcie_host_init() calls them first via pp->ops->init(), and then calls them a second time directly:
struct dw_pcie_host_ops intel_pcie_dw_ops = {
.init = intel_pcie_rc_init
} intel_pcie_probe
pp->ops = &intel_pcie_dw_ops
dw_pcie_host_init(pp)
if (pp->ops->init)
pp->ops->init
intel_pcie_rc_init
intel_pcie_host_setup
dw_pcie_setup_rc # <--
dw_pcie_wait_for_link # <--
dw_pcie_setup_rc # <--
dw_pcie_wait_for_link # <--
Is that what you're thinking?
Bjorn
[+cc Chuanhua Lei, intel-gw maintainer, sorry I forgot this!]
Quoted 42 lines · Bjorn Helgaas
Quoted 8 lines · Manivannan Sadhasivam
Quoted 6 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.Quoted 6 lines
Which platform you are working on? Is that upstreamed? You should mention the specific platform where you are observing the issue.
Right now, intel-gw and designware-plat are the only drivers not defining that callback. First one definitely needs a fixup and I do not know how the latter works.
What fixup do you have in mind for intel-gw?
It looks a little strange to me because it duplicates
dw_pcie_setup_rc()anddw_pcie_wait_for_link():dw_pcie_host_init()calls them first viapp->ops->init(), and then calls them a second time directly:struct dw_pcie_host_ops intel_pcie_dw_ops = { .init = intel_pcie_rc_init }
intel_pcie_probe
pp->ops=&intel_pcie_dw_ops
dw_pcie_host_init(pp)
if (pp->ops->init)
pp->ops->init
intel_pcie_rc_init
intel_pcie_host_setup
dw_pcie_setup_rc# <--
dw_pcie_wait_for_link# <--
dw_pcie_setup_rc# <--
dw_pcie_wait_for_link# <--Is that what you're thinking?
Bjorn
Quoted 44 lines · Bjorn Helgaas
[+cc Chuanhua Lei, intel-gw maintainer, sorry I forgot this!]
Quoted 41 lines · Bjorn Helgaas
Quoted 8 lines · Manivannan Sadhasivam
Quoted 6 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.Quoted 6 lines
Which platform you are working on? Is that upstreamed? You should mention the specific platform where you are observing the issue.
Right now, intel-gw and designware-plat are the only drivers not defining that callback. First one definitely needs a fixup and I do not know how the latter works.
What fixup do you have in mind for intel-gw?
It looks a little strange to me because it duplicates
dw_pcie_setup_rc()anddw_pcie_wait_for_link():dw_pcie_host_init()calls them first viapp->ops->init(), and then calls them a second time directly:struct dw_pcie_host_ops intel_pcie_dw_ops = { .init = intel_pcie_rc_init }
intel_pcie_probe
pp->ops=&intel_pcie_dw_ops
dw_pcie_host_init(pp)
if (pp->ops->init)
pp->ops->init
intel_pcie_rc_init
intel_pcie_host_setup
dw_pcie_setup_rc# <--
dw_pcie_wait_for_link# <--
dw_pcie_setup_rc# <--
dw_pcie_wait_for_link# <--Is that what you're thinking?
Right. There is no need of this driver duplicating dw_pcie_setup_rc() and dw_pcie_wait_for_link(). Perhaps those functions were added to dw_pcie_host_init() after this driver got upstreamed and the author failed to take this driver into account.
But my point was, the new drivers _should_not_ take inspiration from this driver to not define start_link() callback at the first place (unless there is a real requirement).
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
We will work on the updated version to remove the duplication.
Chuanhua
From: Manivannan Sadhasivam <[email protected]>
Sent: Thursday, February 1, 2024 3:32 PM
To: Bjorn Helgaas <[email protected]>
Cc: Ajay Agarwal <[email protected]>; Jingoo Han <[email protected]>; Johan Hovold <[email protected]>; Jon Hunter <[email protected]>; Lorenzo Pieralisi <[email protected]>; Krzysztof Wilczyński <[email protected]>; Rob Herring <[email protected]>; Bjorn Helgaas <[email protected]>; Manu Gautam <[email protected]>; Doug Zobel <[email protected]>; William McVicker <[email protected]>; Serge Semin <[email protected]>; Robin Murphy <[email protected]>; [email protected] <[email protected]>; Lei Chuan Hua <[email protected]> Subject: Re: [PATCH v5] PCI: dwc: Wait for link up only if link is started
This email was sent from outside of MaxLinear.
Quoted 44 lines · Bjorn Helgaas
[+cc Chuanhua Lei, intel-gw maintainer, sorry I forgot this!]
Quoted 41 lines · Bjorn Helgaas
Quoted 8 lines · Manivannan Sadhasivam
Quoted 6 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.Quoted 6 lines
Which platform you are working on? Is that upstreamed? You should mention the specific platform where you are observing the issue.
Right now, intel-gw and designware-plat are the only drivers not defining that callback. First one definitely needs a fixup and I do not know how the latter works.
What fixup do you have in mind for intel-gw?
It looks a little strange to me because it duplicates
dw_pcie_setup_rc()anddw_pcie_wait_for_link():dw_pcie_host_init()calls them first viapp->ops->init(), and then calls them a second time directly:struct
dw_pcie_host_opsintel_pcie_dw_ops= {
.init =intel_pcie_rc_init
}
intel_pcie_probe
pp->ops=&intel_pcie_dw_opsdw_pcie_host_init(pp)
if (pp->ops->init)
pp->ops->init
intel_pcie_rc_init
intel_pcie_host_setup
dw_pcie_setup_rc # <-- dw_pcie_wait_for_link # <-- dw_pcie_setup_rc # <-- dw_pcie_wait_for_link # <--Is that what you're thinking?
Right. There is no need of this driver duplicating dw_pcie_setup_rc() and dw_pcie_wait_for_link(). Perhaps those functions were added to dw_pcie_host_init() after this driver got upstreamed and the author failed to take this driver into account.
But my point was, the new drivers _should_not_ take inspiration from this driver to not define start_link() callback at the first place (unless there is a real requirement).
- Mani
--
மணிவண்ணன் சதாசிவம்
[+cc Bjorn A, Fabio, Xiaolei, who reported the v4 issue]
Quoted 6 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.
s/start_link()/.start_link()/ to hint that this is a function pointer, not a function name in its own right (also below).
s/1/one/ to be consistent.
s/pcie/PCIe/ to follow spec usage.
Quoted 8 lines
Wait for the link up in only if the
start_link()is defined.Signed-off-by Ajay Agarwal <[email protected]>---
v4 was applied, but then reverted. 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 fromdw_pcie_wait_for_linkcheck, the probe function of these products started to fail.
I know this part doesn't get included in the commit log, but I think it would be nice to include the relevant commits here:
da56a1bfbab5 ("PCI: dwc: Wait for link up only if link is started") c5097b9869a1 ("Revert "PCI: dwc: Wait for link up only if link is started"")
because the latter includes details about the actual failure, so we can review this with that platform in mind.
Quoted 65 lines
Changelog since v4:
- Do not return error fromdw_pcie_wait_for_linkcheck.../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(-)drivers/pci/controller/dwc/pcie-designware-host.c +8
-4@@ -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;drivers/pci/controller/dwc/pcie-designware.c +12
-1@@ -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 ; }
drivers/pci/controller/dwc/pcie-designware.c int dw_pcie_wait_for_link(struct dw_pcie *pci) · line 680
Quoted 10 lines
drivers/pci/controller/dwc/pcie-designware.c +1
-6- 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 ; }
This part (pcie-designware.c and pcie-designware.h changes) could arguably be in a separate patch so they're not a distraction from the important functional change.
Quoted 15 lines
drivers/pci/controller/dwc/pcie-designware.h +1
-0@@ -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);Signature · 1 line
2.43.0.381.gb435a96ce8-goog
Quoted 10 lines · Bjorn Helgaas
[+cc Bjorn A, Fabio, Xiaolei, who reported the v4 issue]
Quoted 6 lines · 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 wherestart_link()is not defined the code ends up spinning in a loop for 1 second. Since in some systemsdw_pcie_host_init()gets called during probe, this one second loop for each pcie interface instance ends up extending the boot time.
Quoted 5 lines
s/start_link()/.start_link()/ to hint that this is a function pointer, not a function name in its own right (also below).
s/1/one/ to be consistent.
s/pcie/PCIe/ to follow spec usage.
Sure, will fix it in the patch series.
Quoted 9 lines
Quoted 8 lines
Wait for the link up in only if the
start_link()is defined.Signed-off-by Ajay Agarwal <[email protected]>---
v4 was applied, but then reverted. 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 fromdw_pcie_wait_for_linkcheck, the probe function of these products started to fail.
Quoted 9 lines
I know this part doesn't get included in the commit log, but I think it would be nice to include the relevant commits here:
da56a1bfbab5("PCI: dwc: Wait for link up only if link is started")c5097b9869a1("Revert "PCI: dwc: Wait for link up only if link is started"")because the latter includes details about the actual failure, so we can review this with that platform in mind.
Sure, will add the details in the patch series.
Quoted 73 lines
Quoted 73 lines
Changelog since v4:
- Do not return error fromdw_pcie_wait_for_linkcheck.../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(-)drivers/pci/controller/dwc/pcie-designware-host.c +8
-4@@ -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;drivers/pci/controller/dwc/pcie-designware.c +13
-7@@ -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);
Quoted 7 lines
drivers/pci/controller/dwc/pcie-designware.c int dw_pcie_wait_for_link(struct dw_pcie *pci) · line 680
Quoted 2 lines
drivers/pci/controller/dwc/pcie-designware.c +0
-0return 0 ; }This part (
pcie-designware.candpcie-designware.hchanges) could arguably be in a separate patch so they're not a distraction from the important functional change.
Sure, will separate it out in the patch series.
Quoted 15 lines
Quoted 15 lines
drivers/pci/controller/dwc/pcie-designware.h +1
-0@@ -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);Signature · 1 line
2.43.0.381.gb435a96ce8-goog