Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef1b5dad authored by Bjorn Helgaas's avatar Bjorn Helgaas
Browse files

Merge branch 'pci/virtualization' into next

* pci/virtualization:
  ixgbe: Use pcie_flr() instead of duplicating it
  IB/hfi1: Use pcie_flr() instead of duplicating it
  PCI: Call pcie_flr() from reset_chelsio_generic_dev()
  PCI: Call pcie_flr() from reset_intel_82599_sfp_virtfn()
  PCI: Export pcie_flr()
  PCI: Add sysfs sriov_drivers_autoprobe to control VF driver binding
  PCI: Avoid FLR for Intel 82579 NICs

Conflicts:
	include/linux/pci.h
parents 889e4dd9 63af8f7a
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -301,3 +301,25 @@ Contact: Emil Velikov <emil.l.velikov@gmail.com>
Description:
		This file contains the revision field of the the PCI device.
		The value comes from device config space. The file is read only.

What:		/sys/bus/pci/devices/.../sriov_drivers_autoprobe
Date:		April 2017
Contact:	Bodong Wang<bodong@mellanox.com>
Description:
		This file is associated with the PF of a device that
		supports SR-IOV.  It determines whether newly-enabled VFs
		are immediately bound to a driver.  It initially contains
		1, which means the kernel automatically binds VFs to a
		compatible driver immediately after they are enabled.  If
		an application writes 0 to the file before enabling VFs,
		the kernel will not bind VFs to a driver.

		A typical use case is to write 0 to this file, then enable
		VFs, then assign the newly-created VFs to virtual machines.
		Note that changing this file does not affect already-
		enabled VFs.  In this scenario, the user must first disable
		the VFs, write 0 to sriov_drivers_autoprobe, then re-enable
		the VFs.

		This is similar to /sys/bus/pci/drivers_autoprobe, but
		affects only the VFs associated with a specific PF.
+12 −0
Original line number Diff line number Diff line
@@ -68,6 +68,18 @@ To disable SR-IOV capability:
	echo  0 > \
        /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs

To enable auto probing VFs by a compatible driver on the host, run
command below before enabling SR-IOV capabilities. This is the
default behavior.
	echo 1 > \
        /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_drivers_autoprobe

To disable auto probing VFs by a compatible driver on the host, run
command below before enabling SR-IOV capabilities. Updating this
entry will not affect VFs which are already probed.
	echo  0 > \
        /sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_drivers_autoprobe

3.2 Usage example

Following piece of code illustrates the usage of the SR-IOV API.
+2 −2
Original line number Diff line number Diff line
@@ -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 {
+0 −1
Original line number Diff line number Diff line
@@ -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 *);
+0 −30
Original line number Diff line number Diff line
@@ -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)
{
Loading