linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* export pcie_flr and remove copies of it in drivers
@ 2017-04-13 14:53 Christoph Hellwig
  2017-04-13 14:53 ` [PATCH 1/7] PCI: export pcie_flr Christoph Hellwig
                   ` (7 more replies)
  0 siblings, 8 replies; 16+ messages in thread
From: Christoph Hellwig @ 2017-04-13 14:53 UTC (permalink / raw)
  To: Bjorn Helgaas, Giovanni Cabiddu, Salvatore Benedetto,
	Mike Marciniszyn, Dennis Dalessandro, Derek Chickles,
	Satanand Burla, Felix Manlunas, Raghu Vatsavayi, Jeff Kirsher
  Cc: linux-pci, qat-linux, linux-crypto, linux-rdma, netdev, linux-kernel

Hi all,

this exports the PCI layer pcie_flr helper, and removes various opencoded
copies of it.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/7] PCI: export pcie_flr
  2017-04-13 14:53 export pcie_flr and remove copies of it in drivers Christoph Hellwig
@ 2017-04-13 14:53 ` Christoph Hellwig
  2017-04-14 14:34   ` Bjorn Helgaas
  2017-04-13 14:53 ` [PATCH 2/7] PCI: call pcie_flr from reset_intel_82599_sfp_virtfn Christoph Hellwig
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2017-04-13 14:53 UTC (permalink / raw)
  To: Bjorn Helgaas, Giovanni Cabiddu, Salvatore Benedetto,
	Mike Marciniszyn, Dennis Dalessandro, Derek Chickles,
	Satanand Burla, Felix Manlunas, Raghu Vatsavayi, Jeff Kirsher
  Cc: linux-pci, qat-linux, linux-crypto, linux-rdma, netdev, linux-kernel

Currently we opencode the FLR sequence in lots of place, export a core
helper instead.  We split out the probing for FLR support as all the
non-core callers already know their hardware.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/pci/pci.c   | 34 +++++++++++++++++++++++++---------
 include/linux/pci.h |  1 +
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7904d02ffdb9..3256a63c5d08 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3773,24 +3773,38 @@ static void pci_flr_wait(struct pci_dev *dev)
 			 (i - 1) * 100);
 }
 
-static int pcie_flr(struct pci_dev *dev, int probe)
+/**
+ * pcie_has_flr - check if a device supports function level resets
+ * @dev:	device to check
+ *
+ * Returns true if the device advertises support for PCIe function level
+ * resets.
+ */
+static bool pcie_has_flr(struct pci_dev *dev)
 {
 	u32 cap;
 
 	pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &cap);
-	if (!(cap & PCI_EXP_DEVCAP_FLR))
-		return -ENOTTY;
-
-	if (probe)
-		return 0;
+	return cap & PCI_EXP_DEVCAP_FLR;
+}
 
+/**
+ * pcie_flr - initiate a PCIe function level reset
+ * @dev:	device to reset
+ *
+ * Initiate a function level reset on @dev.  The caller should ensure the
+ * device supports FLR before calling this function, e.g. by using the
+ * pcie_has_flr helper.
+ */
+void pcie_flr(struct pci_dev *dev)
+{
 	if (!pci_wait_for_pending_transaction(dev))
 		dev_err(&dev->dev, "timed out waiting for pending transaction; performing function level reset anyway\n");
 
 	pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);
 	pci_flr_wait(dev);
-	return 0;
 }
+EXPORT_SYMBOL_GPL(pcie_flr);
 
 static int pci_af_flr(struct pci_dev *dev, int probe)
 {
@@ -3971,9 +3985,11 @@ static int __pci_dev_reset(struct pci_dev *dev, int probe)
 	if (rc != -ENOTTY)
 		goto done;
 
-	rc = pcie_flr(dev, probe);
-	if (rc != -ENOTTY)
+	if (pcie_has_flr(dev)) {
+		pcie_flr(dev);
+		rc = 0;
 		goto done;
+	}
 
 	rc = pci_af_flr(dev, probe);
 	if (rc != -ENOTTY)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index eb3da1a04e6c..f35e51eddad0 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1052,6 +1052,7 @@ int pcie_get_mps(struct pci_dev *dev);
 int pcie_set_mps(struct pci_dev *dev, int mps);
 int pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed,
 			  enum pcie_link_width *width);
+void pcie_flr(struct pci_dev *dev);
 int __pci_reset_function(struct pci_dev *dev);
 int __pci_reset_function_locked(struct pci_dev *dev);
 int pci_reset_function(struct pci_dev *dev);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/7] PCI: call pcie_flr from reset_intel_82599_sfp_virtfn
  2017-04-13 14:53 export pcie_flr and remove copies of it in drivers Christoph Hellwig
  2017-04-13 14:53 ` [PATCH 1/7] PCI: export pcie_flr Christoph Hellwig
@ 2017-04-13 14:53 ` Christoph Hellwig
  2017-04-13 14:53 ` [PATCH 3/7] PCI: call pcie_flr from reset_chelsio_generic_dev Christoph Hellwig
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2017-04-13 14:53 UTC (permalink / raw)
  To: Bjorn Helgaas, Giovanni Cabiddu, Salvatore Benedetto,
	Mike Marciniszyn, Dennis Dalessandro, Derek Chickles,
	Satanand Burla, Felix Manlunas, Raghu Vatsavayi, Jeff Kirsher
  Cc: linux-pci, qat-linux, linux-crypto, linux-rdma, netdev, linux-kernel

The 82599 quirk contained an outdated copy of the FLR code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/pci/quirks.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 673683660b5c..b1775354cc69 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3642,19 +3642,11 @@ static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, int probe)
 	 *
 	 * The 82599 supports FLR on VFs, but FLR support is reported only
 	 * in the PF DEVCAP (sec 9.3.10.4), not in the VF DEVCAP (sec 9.5).
-	 * Therefore, we can't use pcie_flr(), which checks the VF DEVCAP.
+	 * Thus we must call pcie_flr directly without first checking if it is
+	 * supported.
 	 */
-
-	if (probe)
-		return 0;
-
-	if (!pci_wait_for_pending_transaction(dev))
-		dev_err(&dev->dev, "transaction is not cleared; proceeding with reset anyway\n");
-
-	pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);
-
-	msleep(100);
-
+	if (!probe)
+		pcie_flr(dev);
 	return 0;
 }
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/7] PCI: call pcie_flr from reset_chelsio_generic_dev
  2017-04-13 14:53 export pcie_flr and remove copies of it in drivers Christoph Hellwig
  2017-04-13 14:53 ` [PATCH 1/7] PCI: export pcie_flr Christoph Hellwig
  2017-04-13 14:53 ` [PATCH 2/7] PCI: call pcie_flr from reset_intel_82599_sfp_virtfn Christoph Hellwig
@ 2017-04-13 14:53 ` Christoph Hellwig
  2017-04-13 14:53 ` [PATCH 4/7] ixgbe: use pcie_flr instead of duplicating it Christoph Hellwig
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2017-04-13 14:53 UTC (permalink / raw)
  To: Bjorn Helgaas, Giovanni Cabiddu, Salvatore Benedetto,
	Mike Marciniszyn, Dennis Dalessandro, Derek Chickles,
	Satanand Burla, Felix Manlunas, Raghu Vatsavayi, Jeff Kirsher
  Cc: linux-pci, qat-linux, linux-crypto, linux-rdma, netdev, linux-kernel

Instead of copy & pasting and old version of the code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/pci/quirks.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index b1775354cc69..b54c0d986f2a 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3751,20 +3751,7 @@ static int reset_chelsio_generic_dev(struct pci_dev *dev, int probe)
 				      PCI_MSIX_FLAGS_ENABLE |
 				      PCI_MSIX_FLAGS_MASKALL);
 
-	/*
-	 * Start of pcie_flr() code sequence.  This reset code is a copy of
-	 * the guts of pcie_flr() because that's not an exported function.
-	 */
-
-	if (!pci_wait_for_pending_transaction(dev))
-		dev_err(&dev->dev, "transaction is not cleared; proceeding with reset anyway\n");
-
-	pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);
-	msleep(100);
-
-	/*
-	 * End of pcie_flr() code sequence.
-	 */
+	pcie_flr(dev);
 
 	/*
 	 * Restore the configuration information (BAR values, etc.) including
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/7] ixgbe: use pcie_flr instead of duplicating it
  2017-04-13 14:53 export pcie_flr and remove copies of it in drivers Christoph Hellwig
                   ` (2 preceding siblings ...)
  2017-04-13 14:53 ` [PATCH 3/7] PCI: call pcie_flr from reset_chelsio_generic_dev Christoph Hellwig
@ 2017-04-13 14:53 ` Christoph Hellwig
  2017-04-26 22:09   ` Jeff Kirsher
  2017-04-13 14:53 ` [PATCH 5/7] IB/hfi1: " Christoph Hellwig
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Christoph Hellwig @ 2017-04-13 14:53 UTC (permalink / raw)
  To: Bjorn Helgaas, Giovanni Cabiddu, Salvatore Benedetto,
	Mike Marciniszyn, Dennis Dalessandro, Derek Chickles,
	Satanand Burla, Felix Manlunas, Raghu Vatsavayi, Jeff Kirsher
  Cc: linux-pci, qat-linux, linux-crypto, linux-rdma, netdev, linux-kernel

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index a7a430a7be2c..543ddde5f8e2 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7112,18 +7112,6 @@ static void ixgbe_watchdog_flush_tx(struct ixgbe_adapter *adapter)
 }
 
 #ifdef CONFIG_PCI_IOV
-static inline void ixgbe_issue_vf_flr(struct ixgbe_adapter *adapter,
-				      struct pci_dev *vfdev)
-{
-	if (!pci_wait_for_pending_transaction(vfdev))
-		e_dev_warn("Issuing VFLR with pending transactions\n");
-
-	e_dev_err("Issuing VFLR for VF %s\n", pci_name(vfdev));
-	pcie_capability_set_word(vfdev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);
-
-	msleep(100);
-}
-
 static void ixgbe_check_for_bad_vf(struct ixgbe_adapter *adapter)
 {
 	struct ixgbe_hw *hw = &adapter->hw;
@@ -7156,7 +7144,7 @@ static void ixgbe_check_for_bad_vf(struct ixgbe_adapter *adapter)
 		pci_read_config_word(vfdev, PCI_STATUS, &status_reg);
 		if (status_reg != IXGBE_FAILED_READ_CFG_WORD &&
 		    status_reg & PCI_STATUS_REC_MASTER_ABORT)
-			ixgbe_issue_vf_flr(adapter, vfdev);
+			pcie_flr(vfdev);
 	}
 }
 
@@ -10244,7 +10232,7 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,
 		 * VFLR.  Just clean up the AER in that case.
 		 */
 		if (vfdev) {
-			ixgbe_issue_vf_flr(adapter, vfdev);
+			pcie_flr(vfdev);
 			/* Free device reference count */
 			pci_dev_put(vfdev);
 		}
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 5/7] IB/hfi1: use pcie_flr instead of duplicating it
  2017-04-13 14:53 export pcie_flr and remove copies of it in drivers Christoph Hellwig
                   ` (3 preceding siblings ...)
  2017-04-13 14:53 ` [PATCH 4/7] ixgbe: use pcie_flr instead of duplicating it Christoph Hellwig
@ 2017-04-13 14:53 ` Christoph Hellwig
  2017-04-13 14:53 ` [PATCH 6/7] crypto: qat: " Christoph Hellwig
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2017-04-13 14:53 UTC (permalink / raw)
  To: Bjorn Helgaas, Giovanni Cabiddu, Salvatore Benedetto,
	Mike Marciniszyn, Dennis Dalessandro, Derek Chickles,
	Satanand Burla, Felix Manlunas, Raghu Vatsavayi, Jeff Kirsher
  Cc: linux-pci, qat-linux, linux-crypto, linux-rdma, netdev, linux-kernel

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/infiniband/hw/hfi1/chip.c |  4 ++--
 drivers/infiniband/hw/hfi1/hfi.h  |  1 -
 drivers/infiniband/hw/hfi1/pcie.c | 30 ------------------------------
 3 files changed, 2 insertions(+), 33 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c
index 121a4c920f1b..d037f72e4d96 100644
--- a/drivers/infiniband/hw/hfi1/chip.c
+++ b/drivers/infiniband/hw/hfi1/chip.c
@@ -13610,14 +13610,14 @@ static void init_chip(struct hfi1_devdata *dd)
 		dd_dev_info(dd, "Resetting CSRs with FLR\n");
 
 		/* do the FLR, the DC reset will remain */
-		hfi1_pcie_flr(dd);
+		pcie_flr(dd->pcidev);
 
 		/* restore command and BARs */
 		restore_pci_variables(dd);
 
 		if (is_ax(dd)) {
 			dd_dev_info(dd, "Resetting CSRs with FLR\n");
-			hfi1_pcie_flr(dd);
+			pcie_flr(dd->pcidev);
 			restore_pci_variables(dd);
 		}
 	} else {
diff --git a/drivers/infiniband/hw/hfi1/hfi.h b/drivers/infiniband/hw/hfi1/hfi.h
index 0808e3c3ba39..40d7559fa723 100644
--- a/drivers/infiniband/hw/hfi1/hfi.h
+++ b/drivers/infiniband/hw/hfi1/hfi.h
@@ -1764,7 +1764,6 @@ int hfi1_pcie_init(struct pci_dev *, const struct pci_device_id *);
 void hfi1_pcie_cleanup(struct pci_dev *);
 int hfi1_pcie_ddinit(struct hfi1_devdata *, struct pci_dev *);
 void hfi1_pcie_ddcleanup(struct hfi1_devdata *);
-void hfi1_pcie_flr(struct hfi1_devdata *);
 int pcie_speeds(struct hfi1_devdata *);
 void request_msix(struct hfi1_devdata *, u32 *, struct hfi1_msix_entry *);
 void hfi1_enable_intx(struct pci_dev *);
diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c
index 0829fce06172..c81556e84831 100644
--- a/drivers/infiniband/hw/hfi1/pcie.c
+++ b/drivers/infiniband/hw/hfi1/pcie.c
@@ -240,36 +240,6 @@ void hfi1_pcie_ddcleanup(struct hfi1_devdata *dd)
 		iounmap(dd->piobase);
 }
 
-/*
- * Do a Function Level Reset (FLR) on the device.
- * Based on static function drivers/pci/pci.c:pcie_flr().
- */
-void hfi1_pcie_flr(struct hfi1_devdata *dd)
-{
-	int i;
-	u16 status;
-
-	/* no need to check for the capability - we know the device has it */
-
-	/* wait for Transaction Pending bit to clear, at most a few ms */
-	for (i = 0; i < 4; i++) {
-		if (i)
-			msleep((1 << (i - 1)) * 100);
-
-		pcie_capability_read_word(dd->pcidev, PCI_EXP_DEVSTA, &status);
-		if (!(status & PCI_EXP_DEVSTA_TRPND))
-			goto clear;
-	}
-
-	dd_dev_err(dd, "Transaction Pending bit is not clearing, proceeding with reset anyway\n");
-
-clear:
-	pcie_capability_set_word(dd->pcidev, PCI_EXP_DEVCTL,
-				 PCI_EXP_DEVCTL_BCR_FLR);
-	/* PCIe spec requires the function to be back within 100ms */
-	msleep(100);
-}
-
 static void msix_setup(struct hfi1_devdata *dd, int pos, u32 *msixcnt,
 		       struct hfi1_msix_entry *hfi1_msix_entry)
 {
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 6/7] crypto: qat: use pcie_flr instead of duplicating it
  2017-04-13 14:53 export pcie_flr and remove copies of it in drivers Christoph Hellwig
                   ` (4 preceding siblings ...)
  2017-04-13 14:53 ` [PATCH 5/7] IB/hfi1: " Christoph Hellwig
@ 2017-04-13 14:53 ` Christoph Hellwig
  2017-04-13 14:53 ` [PATCH 7/7] liquidio: " Christoph Hellwig
  2017-04-14 14:41 ` export pcie_flr and remove copies of it in drivers Bjorn Helgaas
  7 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2017-04-13 14:53 UTC (permalink / raw)
  To: Bjorn Helgaas, Giovanni Cabiddu, Salvatore Benedetto,
	Mike Marciniszyn, Dennis Dalessandro, Derek Chickles,
	Satanand Burla, Felix Manlunas, Raghu Vatsavayi, Jeff Kirsher
  Cc: linux-pci, qat-linux, linux-crypto, linux-rdma, netdev, linux-kernel

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/crypto/qat/qat_common/adf_aer.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/crypto/qat/qat_common/adf_aer.c b/drivers/crypto/qat/qat_common/adf_aer.c
index 2839fccdd84b..d3e25c37dc33 100644
--- a/drivers/crypto/qat/qat_common/adf_aer.c
+++ b/drivers/crypto/qat/qat_common/adf_aer.c
@@ -109,20 +109,7 @@ EXPORT_SYMBOL_GPL(adf_reset_sbr);
 
 void adf_reset_flr(struct adf_accel_dev *accel_dev)
 {
-	struct pci_dev *pdev = accel_to_pci_dev(accel_dev);
-	u16 control = 0;
-	int pos = 0;
-
-	dev_info(&GET_DEV(accel_dev), "Function level reset\n");
-	pos = pci_pcie_cap(pdev);
-	if (!pos) {
-		dev_err(&GET_DEV(accel_dev), "Restart device failed\n");
-		return;
-	}
-	pci_read_config_word(pdev, pos + PCI_EXP_DEVCTL, &control);
-	control |= PCI_EXP_DEVCTL_BCR_FLR;
-	pci_write_config_word(pdev, pos + PCI_EXP_DEVCTL, control);
-	msleep(100);
+	pcie_flr(accel_to_pci_dev(accel_dev));
 }
 EXPORT_SYMBOL_GPL(adf_reset_flr);
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 7/7] liquidio: use pcie_flr instead of duplicating it
  2017-04-13 14:53 export pcie_flr and remove copies of it in drivers Christoph Hellwig
                   ` (5 preceding siblings ...)
  2017-04-13 14:53 ` [PATCH 6/7] crypto: qat: " Christoph Hellwig
@ 2017-04-13 14:53 ` Christoph Hellwig
  2017-04-14 14:41 ` export pcie_flr and remove copies of it in drivers Bjorn Helgaas
  7 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2017-04-13 14:53 UTC (permalink / raw)
  To: Bjorn Helgaas, Giovanni Cabiddu, Salvatore Benedetto,
	Mike Marciniszyn, Dennis Dalessandro, Derek Chickles,
	Satanand Burla, Felix Manlunas, Raghu Vatsavayi, Jeff Kirsher
  Cc: linux-pci, qat-linux, linux-crypto, linux-rdma, netdev, linux-kernel

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/net/ethernet/cavium/liquidio/lio_vf_main.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
index 7b83be4ce1fe..321fe1d5b7b9 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
@@ -899,20 +899,7 @@ static void octeon_pci_flr(struct octeon_device *oct)
 	pci_write_config_word(oct->pci_dev, PCI_COMMAND,
 			      PCI_COMMAND_INTX_DISABLE);
 
-	/* Wait for Transaction Pending bit clean */
-	msleep(100);
-	pcie_capability_read_word(oct->pci_dev, PCI_EXP_DEVSTA, &status);
-	if (status & PCI_EXP_DEVSTA_TRPND) {
-		dev_info(&oct->pci_dev->dev, "Function reset incomplete after 100ms, sleeping for 5 seconds\n");
-		ssleep(5);
-		pcie_capability_read_word(oct->pci_dev, PCI_EXP_DEVSTA,
-					  &status);
-		if (status & PCI_EXP_DEVSTA_TRPND)
-			dev_info(&oct->pci_dev->dev, "Function reset still incomplete after 5s, reset anyway\n");
-	}
-	pcie_capability_set_word(oct->pci_dev, PCI_EXP_DEVCTL,
-				 PCI_EXP_DEVCTL_BCR_FLR);
-	mdelay(100);
+	pcie_flr(oct->pci_dev);
 
 	pci_cfg_access_unlock(oct->pci_dev);
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/7] PCI: export pcie_flr
  2017-04-13 14:53 ` [PATCH 1/7] PCI: export pcie_flr Christoph Hellwig
@ 2017-04-14 14:34   ` Bjorn Helgaas
  2017-04-14 15:56     ` Christoph Hellwig
  0 siblings, 1 reply; 16+ messages in thread
From: Bjorn Helgaas @ 2017-04-14 14:34 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Bjorn Helgaas, Giovanni Cabiddu, Salvatore Benedetto,
	Mike Marciniszyn, Dennis Dalessandro, Derek Chickles,
	Satanand Burla, Felix Manlunas, Raghu Vatsavayi, Jeff Kirsher,
	linux-pci, qat-linux, linux-crypto, linux-rdma, netdev,
	linux-kernel, Alex Williamson

[+cc Alex]

On Thu, Apr 13, 2017 at 04:53:33PM +0200, Christoph Hellwig wrote:
> Currently we opencode the FLR sequence in lots of place, export a core
> helper instead.  We split out the probing for FLR support as all the
> non-core callers already know their hardware.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/pci/pci.c   | 34 +++++++++++++++++++++++++---------
>  include/linux/pci.h |  1 +
>  2 files changed, 26 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 7904d02ffdb9..3256a63c5d08 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -3773,24 +3773,38 @@ static void pci_flr_wait(struct pci_dev *dev)
>  			 (i - 1) * 100);
>  }
>  
> -static int pcie_flr(struct pci_dev *dev, int probe)
> +/**
> + * pcie_has_flr - check if a device supports function level resets
> + * @dev:	device to check
> + *
> + * Returns true if the device advertises support for PCIe function level
> + * resets.
> + */
> +static bool pcie_has_flr(struct pci_dev *dev)
>  {
>  	u32 cap;
>  
>  	pcie_capability_read_dword(dev, PCI_EXP_DEVCAP, &cap);
> -	if (!(cap & PCI_EXP_DEVCAP_FLR))
> -		return -ENOTTY;
> -
> -	if (probe)
> -		return 0;
> +	return cap & PCI_EXP_DEVCAP_FLR;
> +}
>  
> +/**
> + * pcie_flr - initiate a PCIe function level reset
> + * @dev:	device to reset
> + *
> + * Initiate a function level reset on @dev.  The caller should ensure the
> + * device supports FLR before calling this function, e.g. by using the
> + * pcie_has_flr helper.

s/pcie_has_flr/pcie_has_flr()/

> + */
> +void pcie_flr(struct pci_dev *dev)
> +{
>  	if (!pci_wait_for_pending_transaction(dev))
>  		dev_err(&dev->dev, "timed out waiting for pending transaction; performing function level reset anyway\n");
>  
>  	pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);
>  	pci_flr_wait(dev);
> -	return 0;
>  }
> +EXPORT_SYMBOL_GPL(pcie_flr);
>  
>  static int pci_af_flr(struct pci_dev *dev, int probe)
>  {
> @@ -3971,9 +3985,11 @@ static int __pci_dev_reset(struct pci_dev *dev, int probe)
>  	if (rc != -ENOTTY)
>  		goto done;
>  
> -	rc = pcie_flr(dev, probe);
> -	if (rc != -ENOTTY)
> +	if (pcie_has_flr(dev)) {
> +		pcie_flr(dev);
> +		rc = 0;
>  		goto done;
> +	}

This performs an FLR (if supported) always, regardless of "probe".
I think it should look something like this instead:

  if (pcie_has_flr(dev)) {
    if (!probe)
      pcie_flr(dev);
    rc = 0;
    goto done;
  }

>  	rc = pci_af_flr(dev, probe);
>  	if (rc != -ENOTTY)
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index eb3da1a04e6c..f35e51eddad0 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1052,6 +1052,7 @@ int pcie_get_mps(struct pci_dev *dev);
>  int pcie_set_mps(struct pci_dev *dev, int mps);
>  int pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed,
>  			  enum pcie_link_width *width);
> +void pcie_flr(struct pci_dev *dev);
>  int __pci_reset_function(struct pci_dev *dev);
>  int __pci_reset_function_locked(struct pci_dev *dev);
>  int pci_reset_function(struct pci_dev *dev);
> -- 
> 2.11.0
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: export pcie_flr and remove copies of it in drivers
  2017-04-13 14:53 export pcie_flr and remove copies of it in drivers Christoph Hellwig
                   ` (6 preceding siblings ...)
  2017-04-13 14:53 ` [PATCH 7/7] liquidio: " Christoph Hellwig
@ 2017-04-14 14:41 ` Bjorn Helgaas
  2017-04-14 14:51   ` Bjorn Helgaas
  2017-04-14 15:57   ` Christoph Hellwig
  7 siblings, 2 replies; 16+ messages in thread
From: Bjorn Helgaas @ 2017-04-14 14:41 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Bjorn Helgaas, Giovanni Cabiddu, Salvatore Benedetto,
	Mike Marciniszyn, Dennis Dalessandro, Derek Chickles,
	Satanand Burla, Felix Manlunas, Raghu Vatsavayi, Jeff Kirsher,
	linux-pci, qat-linux, linux-crypto, linux-rdma, netdev,
	linux-kernel

On Thu, Apr 13, 2017 at 04:53:32PM +0200, Christoph Hellwig wrote:
> Hi all,
> 
> this exports the PCI layer pcie_flr helper, and removes various opencoded
> copies of it.

Looks good to me (except the comment on probe).  If you want to apply
the whole series via netdev or some non-PCI tree, here's my ack for
the drivers/pci parts, assuming the probe thing is resolved:

Acked-by: Bjorn Helgaas <bhelgaas@google.com>

Otherwise, I'd be glad to take the series given acks for the non-PCI
parts.  Just let me know.

Bjorn

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: export pcie_flr and remove copies of it in drivers
  2017-04-14 14:41 ` export pcie_flr and remove copies of it in drivers Bjorn Helgaas
@ 2017-04-14 14:51   ` Bjorn Helgaas
  2017-04-14 15:57     ` Christoph Hellwig
  2017-04-14 15:57   ` Christoph Hellwig
  1 sibling, 1 reply; 16+ messages in thread
From: Bjorn Helgaas @ 2017-04-14 14:51 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Christoph Hellwig, Giovanni Cabiddu, Salvatore Benedetto,
	Mike Marciniszyn, Dennis Dalessandro, Derek Chickles,
	Satanand Burla, Felix Manlunas, Raghu Vatsavayi, Jeff Kirsher,
	linux-pci, qat-linux, linux-crypto, linux-rdma, netdev,
	linux-kernel

On Fri, Apr 14, 2017 at 9:41 AM, Bjorn Helgaas <helgaas@kernel.org> wrote:
> On Thu, Apr 13, 2017 at 04:53:32PM +0200, Christoph Hellwig wrote:
>> Hi all,
>>
>> this exports the PCI layer pcie_flr helper, and removes various opencoded
>> copies of it.
>
> Looks good to me (except the comment on probe).  If you want to apply
> the whole series via netdev or some non-PCI tree, here's my ack for
> the drivers/pci parts, assuming the probe thing is resolved:
>
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
>
> Otherwise, I'd be glad to take the series given acks for the non-PCI
> parts.  Just let me know.

I do already have a patch (c5e4f0192ad2 ("PCI: Avoid FLR for Intel
82579 NICs")) on my pci/virtualization branch that touches pcie_flr()
and will conflict with this one.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/7] PCI: export pcie_flr
  2017-04-14 14:34   ` Bjorn Helgaas
@ 2017-04-14 15:56     ` Christoph Hellwig
  0 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2017-04-14 15:56 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Christoph Hellwig, Bjorn Helgaas, Giovanni Cabiddu,
	Salvatore Benedetto, Mike Marciniszyn, Dennis Dalessandro,
	Derek Chickles, Satanand Burla, Felix Manlunas, Raghu Vatsavayi,
	Jeff Kirsher, linux-pci, qat-linux, linux-crypto, linux-rdma,
	netdev, linux-kernel, Alex Williamson

> s/pcie_has_flr/pcie_has_flr()/

Ok.

> This performs an FLR (if supported) always, regardless of "probe".
> I think it should look something like this instead:
> 
>   if (pcie_has_flr(dev)) {
>     if (!probe)
>       pcie_flr(dev);
>     rc = 0;
>     goto done;
>   }

Indeed!

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: export pcie_flr and remove copies of it in drivers
  2017-04-14 14:41 ` export pcie_flr and remove copies of it in drivers Bjorn Helgaas
  2017-04-14 14:51   ` Bjorn Helgaas
@ 2017-04-14 15:57   ` Christoph Hellwig
  1 sibling, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2017-04-14 15:57 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Christoph Hellwig, Bjorn Helgaas, Giovanni Cabiddu,
	Salvatore Benedetto, Mike Marciniszyn, Dennis Dalessandro,
	Derek Chickles, Satanand Burla, Felix Manlunas, Raghu Vatsavayi,
	Jeff Kirsher, linux-pci, qat-linux, linux-crypto, linux-rdma,
	netdev, linux-kernel

On Fri, Apr 14, 2017 at 09:41:08AM -0500, Bjorn Helgaas wrote:
> Looks good to me (except the comment on probe).  If you want to apply
> the whole series via netdev or some non-PCI tree, here's my ack for
> the drivers/pci parts, assuming the probe thing is resolved:
> 
> Acked-by: Bjorn Helgaas <bhelgaas@google.com>
> 
> Otherwise, I'd be glad to take the series given acks for the non-PCI
> parts.  Just let me know.

I guess the best would be if you take the first three patches (once
resent) for the PCI tree for 4.12, then we can do the other patches
in the next merge window.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: export pcie_flr and remove copies of it in drivers
  2017-04-14 14:51   ` Bjorn Helgaas
@ 2017-04-14 15:57     ` Christoph Hellwig
  0 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2017-04-14 15:57 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Bjorn Helgaas, Christoph Hellwig, Giovanni Cabiddu,
	Salvatore Benedetto, Mike Marciniszyn, Dennis Dalessandro,
	Derek Chickles, Satanand Burla, Felix Manlunas, Raghu Vatsavayi,
	Jeff Kirsher, linux-pci, qat-linux, linux-crypto, linux-rdma,
	netdev, linux-kernel

On Fri, Apr 14, 2017 at 09:51:48AM -0500, Bjorn Helgaas wrote:
> > Otherwise, I'd be glad to take the series given acks for the non-PCI
> > parts.  Just let me know.
> 
> I do already have a patch (c5e4f0192ad2 ("PCI: Avoid FLR for Intel
> 82579 NICs")) on my pci/virtualization branch that touches pcie_flr()
> and will conflict with this one.

I'll take a look and will resend on top of that branch.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 4/7] ixgbe: use pcie_flr instead of duplicating it
  2017-04-13 14:53 ` [PATCH 4/7] ixgbe: use pcie_flr instead of duplicating it Christoph Hellwig
@ 2017-04-26 22:09   ` Jeff Kirsher
  0 siblings, 0 replies; 16+ messages in thread
From: Jeff Kirsher @ 2017-04-26 22:09 UTC (permalink / raw)
  To: Christoph Hellwig, Bjorn Helgaas, Giovanni Cabiddu,
	Salvatore Benedetto, Mike Marciniszyn, Dennis Dalessandro,
	Derek Chickles, Satanand Burla, Felix Manlunas, Raghu Vatsavayi
  Cc: linux-pci, qat-linux, linux-crypto, linux-rdma, netdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 325 bytes --]

On Thu, 2017-04-13 at 16:53 +0200, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 16 ++--------------
>  1 file changed, 2 insertions(+), 14 deletions(-)

Acked-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Sorry for the late ACK.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3/7] PCI: call pcie_flr from reset_chelsio_generic_dev
  2017-04-14 19:11 export pcie_flr and remove copies of it in drivers V2 Christoph Hellwig
@ 2017-04-14 19:11 ` Christoph Hellwig
  0 siblings, 0 replies; 16+ messages in thread
From: Christoph Hellwig @ 2017-04-14 19:11 UTC (permalink / raw)
  To: Bjorn Helgaas, Giovanni Cabiddu, Salvatore Benedetto,
	Mike Marciniszyn, Dennis Dalessandro, Derek Chickles,
	Satanand Burla, Felix Manlunas, Raghu Vatsavayi, Jeff Kirsher
  Cc: linux-pci, qat-linux, linux-crypto, linux-rdma, netdev, linux-kernel

Instead of copy & pasting and old version of the code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
---
 drivers/pci/quirks.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 8195ca294ee5..715ed8c08fa3 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -3750,20 +3750,7 @@ static int reset_chelsio_generic_dev(struct pci_dev *dev, int probe)
 				      PCI_MSIX_FLAGS_ENABLE |
 				      PCI_MSIX_FLAGS_MASKALL);
 
-	/*
-	 * Start of pcie_flr() code sequence.  This reset code is a copy of
-	 * the guts of pcie_flr() because that's not an exported function.
-	 */
-
-	if (!pci_wait_for_pending_transaction(dev))
-		dev_err(&dev->dev, "transaction is not cleared; proceeding with reset anyway\n");
-
-	pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_BCR_FLR);
-	msleep(100);
-
-	/*
-	 * End of pcie_flr() code sequence.
-	 */
+	pcie_flr(dev);
 
 	/*
 	 * Restore the configuration information (BAR values, etc.) including
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2017-04-26 22:09 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-13 14:53 export pcie_flr and remove copies of it in drivers Christoph Hellwig
2017-04-13 14:53 ` [PATCH 1/7] PCI: export pcie_flr Christoph Hellwig
2017-04-14 14:34   ` Bjorn Helgaas
2017-04-14 15:56     ` Christoph Hellwig
2017-04-13 14:53 ` [PATCH 2/7] PCI: call pcie_flr from reset_intel_82599_sfp_virtfn Christoph Hellwig
2017-04-13 14:53 ` [PATCH 3/7] PCI: call pcie_flr from reset_chelsio_generic_dev Christoph Hellwig
2017-04-13 14:53 ` [PATCH 4/7] ixgbe: use pcie_flr instead of duplicating it Christoph Hellwig
2017-04-26 22:09   ` Jeff Kirsher
2017-04-13 14:53 ` [PATCH 5/7] IB/hfi1: " Christoph Hellwig
2017-04-13 14:53 ` [PATCH 6/7] crypto: qat: " Christoph Hellwig
2017-04-13 14:53 ` [PATCH 7/7] liquidio: " Christoph Hellwig
2017-04-14 14:41 ` export pcie_flr and remove copies of it in drivers Bjorn Helgaas
2017-04-14 14:51   ` Bjorn Helgaas
2017-04-14 15:57     ` Christoph Hellwig
2017-04-14 15:57   ` Christoph Hellwig
2017-04-14 19:11 export pcie_flr and remove copies of it in drivers V2 Christoph Hellwig
2017-04-14 19:11 ` [PATCH 3/7] PCI: call pcie_flr from reset_chelsio_generic_dev Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).