PCI: Change the type of probe argument in reset functions
authorAmey Narkhede <ameynarkhede03@gmail.com>
Tue, 17 Aug 2021 18:05:00 +0000 (23:35 +0530)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 18 Aug 2021 22:32:42 +0000 (17:32 -0500)
Change the type of probe argument in functions which implement reset
methods from int to bool to make the context and intent clear.

Suggested-by: Alex Williamson <alex.williamson@redhat.com>
Link: https://lore.kernel.org/r/20210817180500.1253-10-ameynarkhede03@gmail.com
Signed-off-by: Amey Narkhede <ameynarkhede03@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
12 files changed:
drivers/crypto/cavium/nitrox/nitrox_main.c
drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
drivers/pci/hotplug/pciehp.h
drivers/pci/hotplug/pciehp_hpc.c
drivers/pci/hotplug/pnv_php.c
drivers/pci/pci-acpi.c
drivers/pci/pci.c
drivers/pci/pci.h
drivers/pci/pcie/aer.c
drivers/pci/quirks.c
include/linux/pci.h
include/linux/pci_hotplug.h

index 2db3fd5815c82419f7c4d1811886701cc693ccb8..6c61817996a3338b5a193557f7ffd5cb06fd3bb6 100644 (file)
@@ -306,7 +306,7 @@ static int nitrox_device_flr(struct pci_dev *pdev)
                return -ENOMEM;
        }
 
-       pcie_reset_flr(pdev, 0);
+       pcie_reset_flr(pdev, PCI_RESET_DO_RESET);
 
        pci_restore_state(pdev);
 
index d185df5acea694ad22802b3e9efde48c26011dce..ac821c5532a4ed366eec9eae450cecfe67f17241 100644 (file)
@@ -526,7 +526,7 @@ static void octeon_destroy_resources(struct octeon_device *oct)
                        oct->irq_name_storage = NULL;
                }
                /* Soft reset the octeon device before exiting */
-               if (!pcie_reset_flr(oct->pci_dev, 1))
+               if (!pcie_reset_flr(oct->pci_dev, PCI_RESET_PROBE))
                        octeon_pci_flr(oct);
                else
                        cn23xx_vf_ask_pf_to_do_flr(oct);
index d4a930881054de74ef0b53947e72dc13d3a7dc11..69fd401691be6e6a5ae4aa56f294ae591134039c 100644 (file)
@@ -184,7 +184,7 @@ void pciehp_release_ctrl(struct controller *ctrl);
 
 int pciehp_sysfs_enable_slot(struct hotplug_slot *hotplug_slot);
 int pciehp_sysfs_disable_slot(struct hotplug_slot *hotplug_slot);
-int pciehp_reset_slot(struct hotplug_slot *hotplug_slot, int probe);
+int pciehp_reset_slot(struct hotplug_slot *hotplug_slot, bool probe);
 int pciehp_get_attention_status(struct hotplug_slot *hotplug_slot, u8 *status);
 int pciehp_set_raw_indicator_status(struct hotplug_slot *h_slot, u8 status);
 int pciehp_get_raw_indicator_status(struct hotplug_slot *h_slot, u8 *status);
index 9d06939736c0f0634670bf346df2138905854d71..3024d7e85e6a70d53856c5a6a468c3c3e6d50a6e 100644 (file)
@@ -870,7 +870,7 @@ void pcie_disable_interrupt(struct controller *ctrl)
  * momentarily, if we see that they could interfere. Also, clear any spurious
  * events after.
  */
-int pciehp_reset_slot(struct hotplug_slot *hotplug_slot, int probe)
+int pciehp_reset_slot(struct hotplug_slot *hotplug_slot, bool probe)
 {
        struct controller *ctrl = to_ctrl(hotplug_slot);
        struct pci_dev *pdev = ctrl_dev(ctrl);
index 04565162a44954dbf97f5bd77b12c68f200586aa..f4c2e6e01be0498719ff2dbb14b4114d0e7a45d2 100644 (file)
@@ -526,7 +526,7 @@ scan:
        return 0;
 }
 
-static int pnv_php_reset_slot(struct hotplug_slot *slot, int probe)
+static int pnv_php_reset_slot(struct hotplug_slot *slot, bool probe)
 {
        struct pnv_php_slot *php_slot = to_pnv_php_slot(slot);
        struct pci_dev *bridge = php_slot->pdev;
index b63db75a3dbf4a244dccc98b18992febe7e5da5d..fe286c861187bd919336140e6d0527b36789d54b 100644 (file)
@@ -944,9 +944,9 @@ void pci_set_acpi_fwnode(struct pci_dev *dev)
 /**
  * pci_dev_acpi_reset - do a function level reset using _RST method
  * @dev: device to reset
- * @probe: check if _RST method is included in the acpi_device context.
+ * @probe: if true, return 0 if device supports _RST
  */
-int pci_dev_acpi_reset(struct pci_dev *dev, int probe)
+int pci_dev_acpi_reset(struct pci_dev *dev, bool probe)
 {
        acpi_handle handle = ACPI_HANDLE(&dev->dev);
 
index 4d9828160c48ad7aa1436229cf790c8890f45488..b87bac5e4572f9ddb3cc273e6f4443a4b52ad277 100644 (file)
@@ -4658,11 +4658,11 @@ EXPORT_SYMBOL_GPL(pcie_flr);
 /**
  * pcie_reset_flr - initiate a PCIe function level reset
  * @dev: device to reset
- * @probe: If set, only check if the device can be reset this way.
+ * @probe: if true, return 0 if device can be reset this way
  *
  * Initiate a function level reset on @dev.
  */
-int pcie_reset_flr(struct pci_dev *dev, int probe)
+int pcie_reset_flr(struct pci_dev *dev, bool probe)
 {
        if (dev->dev_flags & PCI_DEV_FLAGS_NO_FLR_RESET)
                return -ENOTTY;
@@ -4677,7 +4677,7 @@ int pcie_reset_flr(struct pci_dev *dev, int probe)
 }
 EXPORT_SYMBOL_GPL(pcie_reset_flr);
 
-static int pci_af_flr(struct pci_dev *dev, int probe)
+static int pci_af_flr(struct pci_dev *dev, bool probe)
 {
        int pos;
        u8 cap;
@@ -4724,7 +4724,7 @@ static int pci_af_flr(struct pci_dev *dev, int probe)
 /**
  * pci_pm_reset - Put device into PCI_D3 and back into PCI_D0.
  * @dev: Device to reset.
- * @probe: If set, only check if the device can be reset this way.
+ * @probe: if true, return 0 if the device can be reset this way.
  *
  * If @dev supports native PCI PM and its PCI_PM_CTRL_NO_SOFT_RESET flag is
  * unset, it will be reinitialized internally when going from PCI_D3hot to
@@ -4736,7 +4736,7 @@ static int pci_af_flr(struct pci_dev *dev, int probe)
  * by default (i.e. unless the @dev's d3hot_delay field has a different value).
  * Moreover, only devices in D0 can be reset by this function.
  */
-static int pci_pm_reset(struct pci_dev *dev, int probe)
+static int pci_pm_reset(struct pci_dev *dev, bool probe)
 {
        u16 csr;
 
@@ -4996,7 +4996,7 @@ int pci_bridge_secondary_bus_reset(struct pci_dev *dev)
 }
 EXPORT_SYMBOL_GPL(pci_bridge_secondary_bus_reset);
 
-static int pci_parent_bus_reset(struct pci_dev *dev, int probe)
+static int pci_parent_bus_reset(struct pci_dev *dev, bool probe)
 {
        struct pci_dev *pdev;
 
@@ -5014,7 +5014,7 @@ static int pci_parent_bus_reset(struct pci_dev *dev, int probe)
        return pci_bridge_secondary_bus_reset(dev->bus->self);
 }
 
-static int pci_reset_hotplug_slot(struct hotplug_slot *hotplug, int probe)
+static int pci_reset_hotplug_slot(struct hotplug_slot *hotplug, bool probe)
 {
        int rc = -ENOTTY;
 
@@ -5029,7 +5029,7 @@ static int pci_reset_hotplug_slot(struct hotplug_slot *hotplug, int probe)
        return rc;
 }
 
-static int pci_dev_reset_slot_function(struct pci_dev *dev, int probe)
+static int pci_dev_reset_slot_function(struct pci_dev *dev, bool probe)
 {
        if (dev->multifunction || dev->subordinate || !dev->slot ||
            dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET)
@@ -5038,7 +5038,7 @@ static int pci_dev_reset_slot_function(struct pci_dev *dev, int probe)
        return pci_reset_hotplug_slot(dev->slot->hotplug, probe);
 }
 
-static int pci_reset_bus_function(struct pci_dev *dev, int probe)
+static int pci_reset_bus_function(struct pci_dev *dev, bool probe)
 {
        int rc;
 
@@ -5204,7 +5204,7 @@ static ssize_t reset_method_store(struct device *dev,
                        goto error;
                }
 
-               if (pci_reset_fn_methods[m].reset_fn(pdev, 1)) {
+               if (pci_reset_fn_methods[m].reset_fn(pdev, PCI_RESET_PROBE)) {
                        pci_err(pdev, "Unsupported reset method '%s'", name);
                        goto error;
                }
@@ -5220,7 +5220,7 @@ static ssize_t reset_method_store(struct device *dev,
        reset_methods[n] = 0;
 
        /* Warn if dev-specific supported but not highest priority */
-       if (pci_reset_fn_methods[1].reset_fn(pdev, 1) == 0 &&
+       if (pci_reset_fn_methods[1].reset_fn(pdev, PCI_RESET_PROBE) == 0 &&
            reset_methods[0] != 1)
                pci_warn(pdev, "Device-specific reset disabled/de-prioritized by user");
        memcpy(pdev->reset_methods, reset_methods, sizeof(pdev->reset_methods));
@@ -5294,7 +5294,7 @@ int __pci_reset_function_locked(struct pci_dev *dev)
                if (!m)
                        return -ENOTTY;
 
-               rc = pci_reset_fn_methods[m].reset_fn(dev, 0);
+               rc = pci_reset_fn_methods[m].reset_fn(dev, PCI_RESET_DO_RESET);
                if (!rc)
                        return 0;
                if (rc != -ENOTTY)
@@ -5327,7 +5327,7 @@ void pci_init_reset_methods(struct pci_dev *dev)
 
        i = 0;
        for (m = 1; m < PCI_NUM_RESET_METHODS; m++) {
-               rc = pci_reset_fn_methods[m].reset_fn(dev, 1);
+               rc = pci_reset_fn_methods[m].reset_fn(dev, PCI_RESET_PROBE);
                if (!rc)
                        dev->reset_methods[i++] = m;
                else if (rc != -ENOTTY)
@@ -5644,7 +5644,7 @@ static void pci_slot_restore_locked(struct pci_slot *slot)
        }
 }
 
-static int pci_slot_reset(struct pci_slot *slot, int probe)
+static int pci_slot_reset(struct pci_slot *slot, bool probe)
 {
        int rc;
 
@@ -5672,7 +5672,7 @@ static int pci_slot_reset(struct pci_slot *slot, int probe)
  */
 int pci_probe_reset_slot(struct pci_slot *slot)
 {
-       return pci_slot_reset(slot, 1);
+       return pci_slot_reset(slot, PCI_RESET_PROBE);
 }
 EXPORT_SYMBOL_GPL(pci_probe_reset_slot);
 
@@ -5695,14 +5695,14 @@ static int __pci_reset_slot(struct pci_slot *slot)
 {
        int rc;
 
-       rc = pci_slot_reset(slot, 1);
+       rc = pci_slot_reset(slot, PCI_RESET_PROBE);
        if (rc)
                return rc;
 
        if (pci_slot_trylock(slot)) {
                pci_slot_save_and_disable_locked(slot);
                might_sleep();
-               rc = pci_reset_hotplug_slot(slot->hotplug, 0);
+               rc = pci_reset_hotplug_slot(slot->hotplug, PCI_RESET_DO_RESET);
                pci_slot_restore_locked(slot);
                pci_slot_unlock(slot);
        } else
@@ -5711,7 +5711,7 @@ static int __pci_reset_slot(struct pci_slot *slot)
        return rc;
 }
 
-static int pci_bus_reset(struct pci_bus *bus, int probe)
+static int pci_bus_reset(struct pci_bus *bus, bool probe)
 {
        int ret;
 
@@ -5757,14 +5757,14 @@ int pci_bus_error_reset(struct pci_dev *bridge)
                        goto bus_reset;
 
        list_for_each_entry(slot, &bus->slots, list)
-               if (pci_slot_reset(slot, 0))
+               if (pci_slot_reset(slot, PCI_RESET_DO_RESET))
                        goto bus_reset;
 
        mutex_unlock(&pci_slot_mutex);
        return 0;
 bus_reset:
        mutex_unlock(&pci_slot_mutex);
-       return pci_bus_reset(bridge->subordinate, 0);
+       return pci_bus_reset(bridge->subordinate, PCI_RESET_DO_RESET);
 }
 
 /**
@@ -5775,7 +5775,7 @@ bus_reset:
  */
 int pci_probe_reset_bus(struct pci_bus *bus)
 {
-       return pci_bus_reset(bus, 1);
+       return pci_bus_reset(bus, PCI_RESET_PROBE);
 }
 EXPORT_SYMBOL_GPL(pci_probe_reset_bus);
 
@@ -5789,7 +5789,7 @@ static int __pci_reset_bus(struct pci_bus *bus)
 {
        int rc;
 
-       rc = pci_bus_reset(bus, 1);
+       rc = pci_bus_reset(bus, PCI_RESET_PROBE);
        if (rc)
                return rc;
 
index 87cfd8db8827e556a2c3ffa350ed4e2601f99b01..05b7e7e04246741e00a4580591c1f1a6afce1991 100644 (file)
@@ -608,18 +608,18 @@ static inline int pci_enable_ptm(struct pci_dev *dev, u8 *granularity)
 struct pci_dev_reset_methods {
        u16 vendor;
        u16 device;
-       int (*reset)(struct pci_dev *dev, int probe);
+       int (*reset)(struct pci_dev *dev, bool probe);
 };
 
 struct pci_reset_fn_method {
-       int (*reset_fn)(struct pci_dev *pdev, int probe);
+       int (*reset_fn)(struct pci_dev *pdev, bool probe);
        char *name;
 };
 
 #ifdef CONFIG_PCI_QUIRKS
-int pci_dev_specific_reset(struct pci_dev *dev, int probe);
+int pci_dev_specific_reset(struct pci_dev *dev, bool probe);
 #else
-static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe)
+static inline int pci_dev_specific_reset(struct pci_dev *dev, bool probe)
 {
        return -ENOTTY;
 }
@@ -708,9 +708,9 @@ static inline int pci_aer_raw_clear_status(struct pci_dev *dev) { return -EINVAL
 int pci_acpi_program_hp_params(struct pci_dev *dev);
 extern const struct attribute_group pci_dev_acpi_attr_group;
 void pci_set_acpi_fwnode(struct pci_dev *dev);
-int pci_dev_acpi_reset(struct pci_dev *dev, int probe);
+int pci_dev_acpi_reset(struct pci_dev *dev, bool probe);
 #else
-static inline int pci_dev_acpi_reset(struct pci_dev *dev, int probe)
+static inline int pci_dev_acpi_reset(struct pci_dev *dev, bool probe)
 {
        return -ENOTTY;
 }
index 031379deb13048f1ca8f1fc995dbb886b51795b0..9784fdcf30061c7ffd407b73bf20f60a8c70ca62 100644 (file)
@@ -1407,7 +1407,7 @@ static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
        }
 
        if (type == PCI_EXP_TYPE_RC_EC || type == PCI_EXP_TYPE_RC_END) {
-               rc = pcie_reset_flr(dev, 0);
+               rc = pcie_reset_flr(dev, PCI_RESET_DO_RESET);
                if (!rc)
                        pci_info(dev, "has been reset\n");
                else
index a1b57b63c6242bc0039c0479f9f3849c6eacab82..e7657b8c8a337b43f5f2ea3cc681eb3ff0dce357 100644 (file)
@@ -3702,7 +3702,7 @@ DECLARE_PCI_FIXUP_SUSPEND_LATE(PCI_VENDOR_ID_INTEL,
  * reset a single function if other methods (e.g. FLR, PM D0->D3) are
  * not available.
  */
-static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, int probe)
+static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, bool probe)
 {
        /*
         * http://www.intel.com/content/dam/doc/datasheet/82599-10-gbe-controller-datasheet.pdf
@@ -3724,7 +3724,7 @@ static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, int probe)
 #define NSDE_PWR_STATE         0xd0100
 #define IGD_OPERATION_TIMEOUT  10000     /* set timeout 10 seconds */
 
-static int reset_ivb_igd(struct pci_dev *dev, int probe)
+static int reset_ivb_igd(struct pci_dev *dev, bool probe)
 {
        void __iomem *mmio_base;
        unsigned long timeout;
@@ -3767,7 +3767,7 @@ reset_complete:
 }
 
 /* Device-specific reset method for Chelsio T4-based adapters */
-static int reset_chelsio_generic_dev(struct pci_dev *dev, int probe)
+static int reset_chelsio_generic_dev(struct pci_dev *dev, bool probe)
 {
        u16 old_command;
        u16 msix_flags;
@@ -3845,14 +3845,14 @@ static int reset_chelsio_generic_dev(struct pci_dev *dev, int probe)
  *    Chapter 3: NVMe control registers
  *    Chapter 7.3: Reset behavior
  */
-static int nvme_disable_and_flr(struct pci_dev *dev, int probe)
+static int nvme_disable_and_flr(struct pci_dev *dev, bool probe)
 {
        void __iomem *bar;
        u16 cmd;
        u32 cfg;
 
        if (dev->class != PCI_CLASS_STORAGE_EXPRESS ||
-           pcie_reset_flr(dev, 1) || !pci_resource_start(dev, 0))
+           pcie_reset_flr(dev, PCI_RESET_PROBE) || !pci_resource_start(dev, 0))
                return -ENOTTY;
 
        if (probe)
@@ -3919,12 +3919,12 @@ static int nvme_disable_and_flr(struct pci_dev *dev, int probe)
  * device too soon after FLR.  A 250ms delay after FLR has heuristically
  * proven to produce reliably working results for device assignment cases.
  */
-static int delay_250ms_after_flr(struct pci_dev *dev, int probe)
+static int delay_250ms_after_flr(struct pci_dev *dev, bool probe)
 {
        if (probe)
-               return pcie_reset_flr(dev, 1);
+               return pcie_reset_flr(dev, PCI_RESET_PROBE);
 
-       pcie_reset_flr(dev, 0);
+       pcie_reset_flr(dev, PCI_RESET_DO_RESET);
 
        msleep(250);
 
@@ -3939,7 +3939,7 @@ static int delay_250ms_after_flr(struct pci_dev *dev, int probe)
 #define HINIC_OPERATION_TIMEOUT     15000      /* 15 seconds */
 
 /* Device-specific reset method for Huawei Intelligent NIC virtual functions */
-static int reset_hinic_vf_dev(struct pci_dev *pdev, int probe)
+static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe)
 {
        unsigned long timeout;
        void __iomem *bar;
@@ -4016,7 +4016,7 @@ static const struct pci_dev_reset_methods pci_dev_reset_methods[] = {
  * because when a host assigns a device to a guest VM, the host may need
  * to reset the device but probably doesn't have a driver for it.
  */
-int pci_dev_specific_reset(struct pci_dev *dev, int probe)
+int pci_dev_specific_reset(struct pci_dev *dev, bool probe)
 {
        const struct pci_dev_reset_methods *i;
 
index 98718f46a61c1d4954f9aa03355965baff4dadd4..a46363f29b6892a8f010bef8427b82f037796036 100644 (file)
@@ -52,6 +52,9 @@
 /* Number of reset methods used in pci_reset_fn_methods array in pci.c */
 #define PCI_NUM_RESET_METHODS 7
 
+#define PCI_RESET_PROBE                true
+#define PCI_RESET_DO_RESET     false
+
 /*
  * The PCI interface treats multi-function devices as independent
  * devices.  The slot/function address of each device is encoded
@@ -1234,7 +1237,7 @@ u32 pcie_bandwidth_available(struct pci_dev *dev, struct pci_dev **limiting_dev,
                             enum pci_bus_speed *speed,
                             enum pcie_link_width *width);
 void pcie_print_link_status(struct pci_dev *dev);
-int pcie_reset_flr(struct pci_dev *dev, int probe);
+int pcie_reset_flr(struct pci_dev *dev, bool probe);
 int pcie_flr(struct pci_dev *dev);
 int __pci_reset_function_locked(struct pci_dev *dev);
 int pci_reset_function(struct pci_dev *dev);
index 2dac431d94ac141edfa05b387c62258cce0db86c..3a10d6ec3ee7f9618418a4e8394de3e096c72c1a 100644 (file)
@@ -44,7 +44,7 @@ struct hotplug_slot_ops {
        int (*get_attention_status)     (struct hotplug_slot *slot, u8 *value);
        int (*get_latch_status)         (struct hotplug_slot *slot, u8 *value);
        int (*get_adapter_status)       (struct hotplug_slot *slot, u8 *value);
-       int (*reset_slot)               (struct hotplug_slot *slot, int probe);
+       int (*reset_slot)               (struct hotplug_slot *slot, bool probe);
 };
 
 /**