* [PATCH] PCI: dwc: Allow platform driver to skip the wait for link
@ 2023-04-04 17:41 Ajay Agarwal
2023-04-05 13:33 ` Lorenzo Pieralisi
0 siblings, 1 reply; 2+ messages in thread
From: Ajay Agarwal @ 2023-04-04 17:41 UTC (permalink / raw)
To: Jingoo Han, Gustavo Pimentel, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, nikhilnd, manugautam
Cc: Bjorn Helgaas, linux-pci, Ajay Agarwal
Currently as a part of device probe, the driver waits for the
link to come up for up to 1 second. If the link training is not
enabled by default or as a part of host_init, then this wait for
the link can be skipped to save the 1 second of wait time.
Allow the platform driver to skip this wait for the link up by
setting a flag `skip_wait_for_link`. This flag will be false by
default, thereby preserving the legacy behavior for existing
platform drivers.
Signed-off-by: Ajay Agarwal <ajayagarwal@google.com>
---
drivers/pci/controller/dwc/pcie-designware-host.c | 9 +++++++--
drivers/pci/controller/dwc/pcie-designware.h | 1 +
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
index 9952057c8819..3425eb17b467 100644
--- a/drivers/pci/controller/dwc/pcie-designware-host.c
+++ b/drivers/pci/controller/dwc/pcie-designware-host.c
@@ -491,8 +491,13 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
goto err_remove_edma;
}
- /* Ignore errors, the link may come up later */
- dw_pcie_wait_for_link(pci);
+ /*
+ * If the platform driver sets `skip_wait_for_link` because it knows the
+ * link will not be up, do not wait for it. Save 1 sec of wait time.
+ * Else, test for the link. Ignore errors, the link may come up later
+ */
+ if (!pp->skip_wait_for_link)
+ dw_pcie_wait_for_link(pci);
bridge->sysdata = pp;
diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
index 79713ce075cc..f8f6dad5c948 100644
--- a/drivers/pci/controller/dwc/pcie-designware.h
+++ b/drivers/pci/controller/dwc/pcie-designware.h
@@ -297,6 +297,7 @@ struct dw_pcie_host_ops {
struct dw_pcie_rp {
bool has_msi_ctrl:1;
bool cfg0_io_shared:1;
+ bool skip_wait_for_link:1;
u64 cfg0_base;
void __iomem *va_cfg0_base;
u32 cfg0_size;
--
2.40.0.348.gf938b09366-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] PCI: dwc: Allow platform driver to skip the wait for link
2023-04-04 17:41 [PATCH] PCI: dwc: Allow platform driver to skip the wait for link Ajay Agarwal
@ 2023-04-05 13:33 ` Lorenzo Pieralisi
0 siblings, 0 replies; 2+ messages in thread
From: Lorenzo Pieralisi @ 2023-04-05 13:33 UTC (permalink / raw)
To: Ajay Agarwal
Cc: Jingoo Han, Gustavo Pimentel, Krzysztof Wilczyński,
Rob Herring, nikhilnd, manugautam, Bjorn Helgaas, linux-pci
On Tue, Apr 04, 2023 at 11:11:41PM +0530, Ajay Agarwal wrote:
> Currently as a part of device probe, the driver waits for the
> link to come up for up to 1 second. If the link training is not
> enabled by default or as a part of host_init, then this wait for
> the link can be skipped to save the 1 second of wait time.
>
> Allow the platform driver to skip this wait for the link up by
> setting a flag `skip_wait_for_link`. This flag will be false by
> default, thereby preserving the legacy behavior for existing
> platform drivers.
>
> Signed-off-by: Ajay Agarwal <ajayagarwal@google.com>
> ---
> drivers/pci/controller/dwc/pcie-designware-host.c | 9 +++++++--
> drivers/pci/controller/dwc/pcie-designware.h | 1 +
> 2 files changed, 8 insertions(+), 2 deletions(-)
A previous patch handles this change, dropping this one,
please chime in in this thread if needed:
https://lore.kernel.org/linux-pci/ZC12lN9Cs0QlPhVh@lpieralisi
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c
> index 9952057c8819..3425eb17b467 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-host.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-host.c
> @@ -491,8 +491,13 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp)
> goto err_remove_edma;
> }
>
> - /* Ignore errors, the link may come up later */
> - dw_pcie_wait_for_link(pci);
> + /*
> + * If the platform driver sets `skip_wait_for_link` because it knows the
> + * link will not be up, do not wait for it. Save 1 sec of wait time.
> + * Else, test for the link. Ignore errors, the link may come up later
> + */
> + if (!pp->skip_wait_for_link)
> + dw_pcie_wait_for_link(pci);
>
> bridge->sysdata = pp;
>
> diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h
> index 79713ce075cc..f8f6dad5c948 100644
> --- a/drivers/pci/controller/dwc/pcie-designware.h
> +++ b/drivers/pci/controller/dwc/pcie-designware.h
> @@ -297,6 +297,7 @@ struct dw_pcie_host_ops {
> struct dw_pcie_rp {
> bool has_msi_ctrl:1;
> bool cfg0_io_shared:1;
> + bool skip_wait_for_link:1;
> u64 cfg0_base;
> void __iomem *va_cfg0_base;
> u32 cfg0_size;
> --
> 2.40.0.348.gf938b09366-goog
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-04-05 13:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-04 17:41 [PATCH] PCI: dwc: Allow platform driver to skip the wait for link Ajay Agarwal
2023-04-05 13:33 ` Lorenzo Pieralisi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox