Skip to content

Commit d1b6f2e

Browse files
thom24kwilczynski
authored andcommitted
PCI: cadence: Extract link setup sequence from cdns_pcie_host_setup()
The function cdns_pcie_host_setup() mixes probe structure and link setup. The link setup must be done during the resume sequence. So extract it from cdns_pcie_host_setup() and create a dedicated function. Link: https://lore.kernel.org/linux-pci/20240102-j7200-pcie-s2r-v7-1-a2f9156da6c3@bootlin.com Signed-off-by: Thomas Richard <thomas.richard@bootlin.com> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Reviewed-by: Siddharth Vadapalli <s-vadapalli@ti.com>
1 parent 82c4be4 commit d1b6f2e

2 files changed

Lines changed: 32 additions & 13 deletions

File tree

drivers/pci/controller/cadence/pcie-cadence-host.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,30 @@ static int cdns_pcie_host_init(struct device *dev,
497497
return cdns_pcie_host_init_address_translation(rc);
498498
}
499499

500+
int cdns_pcie_host_link_setup(struct cdns_pcie_rc *rc)
501+
{
502+
struct cdns_pcie *pcie = &rc->pcie;
503+
struct device *dev = rc->pcie.dev;
504+
int ret;
505+
506+
if (rc->quirk_detect_quiet_flag)
507+
cdns_pcie_detect_quiet_min_delay_set(&rc->pcie);
508+
509+
cdns_pcie_host_enable_ptm_response(pcie);
510+
511+
ret = cdns_pcie_start_link(pcie);
512+
if (ret) {
513+
dev_err(dev, "Failed to start link\n");
514+
return ret;
515+
}
516+
517+
ret = cdns_pcie_host_start_link(rc);
518+
if (ret)
519+
dev_dbg(dev, "PCIe link never came up\n");
520+
521+
return 0;
522+
}
523+
500524
int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)
501525
{
502526
struct device *dev = rc->pcie.dev;
@@ -533,20 +557,9 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)
533557
return PTR_ERR(rc->cfg_base);
534558
rc->cfg_res = res;
535559

536-
if (rc->quirk_detect_quiet_flag)
537-
cdns_pcie_detect_quiet_min_delay_set(&rc->pcie);
538-
539-
cdns_pcie_host_enable_ptm_response(pcie);
540-
541-
ret = cdns_pcie_start_link(pcie);
542-
if (ret) {
543-
dev_err(dev, "Failed to start link\n");
544-
return ret;
545-
}
546-
547-
ret = cdns_pcie_host_start_link(rc);
560+
ret = cdns_pcie_host_link_setup(rc);
548561
if (ret)
549-
dev_dbg(dev, "PCIe link never came up\n");
562+
return ret;
550563

551564
for (bar = RP_BAR0; bar <= RP_NO_BAR; bar++)
552565
rc->avail_ib_bar[bar] = true;

drivers/pci/controller/cadence/pcie-cadence.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,10 +521,16 @@ static inline bool cdns_pcie_link_up(struct cdns_pcie *pcie)
521521
}
522522

523523
#ifdef CONFIG_PCIE_CADENCE_HOST
524+
int cdns_pcie_host_link_setup(struct cdns_pcie_rc *rc);
524525
int cdns_pcie_host_setup(struct cdns_pcie_rc *rc);
525526
void __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int devfn,
526527
int where);
527528
#else
529+
static inline int cdns_pcie_host_link_setup(struct cdns_pcie_rc *rc)
530+
{
531+
return 0;
532+
}
533+
528534
static inline int cdns_pcie_host_setup(struct cdns_pcie_rc *rc)
529535
{
530536
return 0;

0 commit comments

Comments
 (0)