diff mbox series

[2/2] IB/hfi1: Remove pci_parent_bus_reset() duplication

Message ID alpine.DEB.2.21.2306200235510.14084@angie.orcam.me.uk (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show
Series PCI+IB/hfi1: Fold duplicate secondary bus reset code | expand

Commit Message

Maciej W. Rozycki June 20, 2023, 9:49 a.m. UTC
Call pci_parent_bus_reset() rather than duplicating it in trigger_sbr().
There are extra preparatory checks made by the former function, but they 
are supposed to be neutral to the HFI1 device.

Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
---
 drivers/infiniband/hw/hfi1/pcie.c |   30 ++++--------------------------
 1 file changed, 4 insertions(+), 26 deletions(-)

linux-ib-hfi1-pcie-sbr-parent-bus-reset.diff

Comments

Ilpo Järvinen Aug. 8, 2023, 4:51 p.m. UTC | #1
On Tue, 20 Jun 2023, Maciej W. Rozycki wrote:

> Call pci_parent_bus_reset() rather than duplicating it in trigger_sbr().
> There are extra preparatory checks made by the former function, but they 
> are supposed to be neutral to the HFI1 device.
> 
> Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
> ---
>  drivers/infiniband/hw/hfi1/pcie.c |   30 ++++--------------------------
>  1 file changed, 4 insertions(+), 26 deletions(-)
> 
> linux-ib-hfi1-pcie-sbr-parent-bus-reset.diff
> Index: linux-macro/drivers/infiniband/hw/hfi1/pcie.c
> ===================================================================
> --- linux-macro.orig/drivers/infiniband/hw/hfi1/pcie.c
> +++ linux-macro/drivers/infiniband/hw/hfi1/pcie.c
> @@ -796,35 +796,13 @@ static void pcie_post_steps(struct hfi1_
>  /*
>   * Trigger a secondary bus reset (SBR) on ourselves using our parent.
>   *
> - * Based on pci_parent_bus_reset() which is not exported by the
> - * kernel core.
> + * This is an end around to do an SBR during probe time.  A new API
> + * needs to be implemented to have cleaner interface but this fixes
> + * the current brokenness.
>   */
>  static int trigger_sbr(struct hfi1_devdata *dd)
>  {
> -	struct pci_dev *dev = dd->pcidev;
> -	struct pci_dev *pdev;
> -
> -	/* need a parent */
> -	if (!dev->bus->self) {
> -		dd_dev_err(dd, "%s: no parent device\n", __func__);
> -		return -ENOTTY;
> -	}
> -
> -	/* should not be anyone else on the bus */
> -	list_for_each_entry(pdev, &dev->bus->devices, bus_list)
> -		if (pdev != dev) {
> -			dd_dev_err(dd,
> -				   "%s: another device is on the same bus\n",
> -				   __func__);
> -			return -ENOTTY;
> -		}
> -
> -	/*
> -	 * This is an end around to do an SBR during probe time. A new API needs
> -	 * to be implemented to have cleaner interface but this fixes the
> -	 * current brokenness
> -	 */
> -	return pci_bridge_secondary_bus_reset(dev->bus->self);
> +	return pci_parent_bus_reset(dd->pcidev, PCI_RESET_DO_RESET);
>  }

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
diff mbox series

Patch

Index: linux-macro/drivers/infiniband/hw/hfi1/pcie.c
===================================================================
--- linux-macro.orig/drivers/infiniband/hw/hfi1/pcie.c
+++ linux-macro/drivers/infiniband/hw/hfi1/pcie.c
@@ -796,35 +796,13 @@  static void pcie_post_steps(struct hfi1_
 /*
  * Trigger a secondary bus reset (SBR) on ourselves using our parent.
  *
- * Based on pci_parent_bus_reset() which is not exported by the
- * kernel core.
+ * This is an end around to do an SBR during probe time.  A new API
+ * needs to be implemented to have cleaner interface but this fixes
+ * the current brokenness.
  */
 static int trigger_sbr(struct hfi1_devdata *dd)
 {
-	struct pci_dev *dev = dd->pcidev;
-	struct pci_dev *pdev;
-
-	/* need a parent */
-	if (!dev->bus->self) {
-		dd_dev_err(dd, "%s: no parent device\n", __func__);
-		return -ENOTTY;
-	}
-
-	/* should not be anyone else on the bus */
-	list_for_each_entry(pdev, &dev->bus->devices, bus_list)
-		if (pdev != dev) {
-			dd_dev_err(dd,
-				   "%s: another device is on the same bus\n",
-				   __func__);
-			return -ENOTTY;
-		}
-
-	/*
-	 * This is an end around to do an SBR during probe time. A new API needs
-	 * to be implemented to have cleaner interface but this fixes the
-	 * current brokenness
-	 */
-	return pci_bridge_secondary_bus_reset(dev->bus->self);
+	return pci_parent_bus_reset(dd->pcidev, PCI_RESET_DO_RESET);
 }
 
 /*