From 8aff03ca6b1078dd6a77b3836320329380351b22 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Sun, 16 Dec 2018 21:19:20 -0800 Subject: PCI: dwc: designware: Handle ->host_init() failures Port of a Linux commit 4a301766f5263dd94c1b95d1b1bbdf338afb1a37 In several dwc-based drivers, ->host_init() can fail, so make sure to propagate and handle this to avoid continuing operation of a driver or hardware in an invalid state. Signed-off-by: Bjorn Andersson Signed-off-by: Bjorn Helgaas Acked-by: Joao Pinto Acked-by: Jingoo Han Signed-off-by: Andrey Smirnov Signed-off-by: Sascha Hauer --- drivers/pci/pci-imx6.c | 4 +++- drivers/pci/pcie-designware-host.c | 7 +++++-- drivers/pci/pcie-designware.h | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/pci/pci-imx6.c b/drivers/pci/pci-imx6.c index 78aa5215ad..1807f29c9e 100644 --- a/drivers/pci/pci-imx6.c +++ b/drivers/pci/pci-imx6.c @@ -477,7 +477,7 @@ err_reset_phy: return ret; } -static void imx6_pcie_host_init(struct pcie_port *pp) +static int imx6_pcie_host_init(struct pcie_port *pp) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); struct imx6_pcie *imx6_pcie = to_imx6_pcie(pci); @@ -487,6 +487,8 @@ static void imx6_pcie_host_init(struct pcie_port *pp) imx6_pcie_deassert_core_reset(imx6_pcie); dw_pcie_setup_rc(pp); imx6_pcie_establish_link(imx6_pcie); + + return 0; } static int imx6_pcie_link_up(struct dw_pcie *pci) diff --git a/drivers/pci/pcie-designware-host.c b/drivers/pci/pcie-designware-host.c index 5de9cd8ea3..e98560818c 100644 --- a/drivers/pci/pcie-designware-host.c +++ b/drivers/pci/pcie-designware-host.c @@ -164,8 +164,11 @@ int __init dw_pcie_host_init(struct pcie_port *pp) if (ret) pci->num_viewport = 2; - if (pp->ops->host_init) - pp->ops->host_init(pp); + if (pp->ops->host_init) { + ret = pp->ops->host_init(pp); + if (ret) + return ret; + } pp->pci.parent = dev; pp->pci.pci_ops = &dw_pcie_ops; diff --git a/drivers/pci/pcie-designware.h b/drivers/pci/pcie-designware.h index b18f1b83e7..933c2b533d 100644 --- a/drivers/pci/pcie-designware.h +++ b/drivers/pci/pcie-designware.h @@ -99,7 +99,7 @@ struct dw_pcie_host_ops { unsigned int devfn, int where, int size, u32 *val); int (*wr_other_conf)(struct pcie_port *pp, struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val); - void (*host_init)(struct pcie_port *pp); + int (*host_init)(struct pcie_port *pp); void (*scan_bus)(struct pcie_port *pp); }; -- cgit v1.2.3