Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: Change the type of probe argument in reset functions

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>

authored by

Amey Narkhede and committed by
Bjorn Helgaas
9bdc81ce 6937b7dd

+51 -48
+1 -1
drivers/crypto/cavium/nitrox/nitrox_main.c
··· 306 306 return -ENOMEM; 307 307 } 308 308 309 - pcie_reset_flr(pdev, 0); 309 + pcie_reset_flr(pdev, PCI_RESET_DO_RESET); 310 310 311 311 pci_restore_state(pdev); 312 312
+1 -1
drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
··· 526 526 oct->irq_name_storage = NULL; 527 527 } 528 528 /* Soft reset the octeon device before exiting */ 529 - if (!pcie_reset_flr(oct->pci_dev, 1)) 529 + if (!pcie_reset_flr(oct->pci_dev, PCI_RESET_PROBE)) 530 530 octeon_pci_flr(oct); 531 531 else 532 532 cn23xx_vf_ask_pf_to_do_flr(oct);
+1 -1
drivers/pci/hotplug/pciehp.h
··· 184 184 185 185 int pciehp_sysfs_enable_slot(struct hotplug_slot *hotplug_slot); 186 186 int pciehp_sysfs_disable_slot(struct hotplug_slot *hotplug_slot); 187 - int pciehp_reset_slot(struct hotplug_slot *hotplug_slot, int probe); 187 + int pciehp_reset_slot(struct hotplug_slot *hotplug_slot, bool probe); 188 188 int pciehp_get_attention_status(struct hotplug_slot *hotplug_slot, u8 *status); 189 189 int pciehp_set_raw_indicator_status(struct hotplug_slot *h_slot, u8 status); 190 190 int pciehp_get_raw_indicator_status(struct hotplug_slot *h_slot, u8 *status);
+1 -1
drivers/pci/hotplug/pciehp_hpc.c
··· 870 870 * momentarily, if we see that they could interfere. Also, clear any spurious 871 871 * events after. 872 872 */ 873 - int pciehp_reset_slot(struct hotplug_slot *hotplug_slot, int probe) 873 + int pciehp_reset_slot(struct hotplug_slot *hotplug_slot, bool probe) 874 874 { 875 875 struct controller *ctrl = to_ctrl(hotplug_slot); 876 876 struct pci_dev *pdev = ctrl_dev(ctrl);
+1 -1
drivers/pci/hotplug/pnv_php.c
··· 526 526 return 0; 527 527 } 528 528 529 - static int pnv_php_reset_slot(struct hotplug_slot *slot, int probe) 529 + static int pnv_php_reset_slot(struct hotplug_slot *slot, bool probe) 530 530 { 531 531 struct pnv_php_slot *php_slot = to_pnv_php_slot(slot); 532 532 struct pci_dev *bridge = php_slot->pdev;
+2 -2
drivers/pci/pci-acpi.c
··· 944 944 /** 945 945 * pci_dev_acpi_reset - do a function level reset using _RST method 946 946 * @dev: device to reset 947 - * @probe: check if _RST method is included in the acpi_device context. 947 + * @probe: if true, return 0 if device supports _RST 948 948 */ 949 - int pci_dev_acpi_reset(struct pci_dev *dev, int probe) 949 + int pci_dev_acpi_reset(struct pci_dev *dev, bool probe) 950 950 { 951 951 acpi_handle handle = ACPI_HANDLE(&dev->dev); 952 952
+22 -22
drivers/pci/pci.c
··· 4658 4658 /** 4659 4659 * pcie_reset_flr - initiate a PCIe function level reset 4660 4660 * @dev: device to reset 4661 - * @probe: If set, only check if the device can be reset this way. 4661 + * @probe: if true, return 0 if device can be reset this way 4662 4662 * 4663 4663 * Initiate a function level reset on @dev. 4664 4664 */ 4665 - int pcie_reset_flr(struct pci_dev *dev, int probe) 4665 + int pcie_reset_flr(struct pci_dev *dev, bool probe) 4666 4666 { 4667 4667 if (dev->dev_flags & PCI_DEV_FLAGS_NO_FLR_RESET) 4668 4668 return -ENOTTY; ··· 4677 4677 } 4678 4678 EXPORT_SYMBOL_GPL(pcie_reset_flr); 4679 4679 4680 - static int pci_af_flr(struct pci_dev *dev, int probe) 4680 + static int pci_af_flr(struct pci_dev *dev, bool probe) 4681 4681 { 4682 4682 int pos; 4683 4683 u8 cap; ··· 4724 4724 /** 4725 4725 * pci_pm_reset - Put device into PCI_D3 and back into PCI_D0. 4726 4726 * @dev: Device to reset. 4727 - * @probe: If set, only check if the device can be reset this way. 4727 + * @probe: if true, return 0 if the device can be reset this way. 4728 4728 * 4729 4729 * If @dev supports native PCI PM and its PCI_PM_CTRL_NO_SOFT_RESET flag is 4730 4730 * unset, it will be reinitialized internally when going from PCI_D3hot to ··· 4736 4736 * by default (i.e. unless the @dev's d3hot_delay field has a different value). 4737 4737 * Moreover, only devices in D0 can be reset by this function. 4738 4738 */ 4739 - static int pci_pm_reset(struct pci_dev *dev, int probe) 4739 + static int pci_pm_reset(struct pci_dev *dev, bool probe) 4740 4740 { 4741 4741 u16 csr; 4742 4742 ··· 4996 4996 } 4997 4997 EXPORT_SYMBOL_GPL(pci_bridge_secondary_bus_reset); 4998 4998 4999 - static int pci_parent_bus_reset(struct pci_dev *dev, int probe) 4999 + static int pci_parent_bus_reset(struct pci_dev *dev, bool probe) 5000 5000 { 5001 5001 struct pci_dev *pdev; 5002 5002 ··· 5014 5014 return pci_bridge_secondary_bus_reset(dev->bus->self); 5015 5015 } 5016 5016 5017 - static int pci_reset_hotplug_slot(struct hotplug_slot *hotplug, int probe) 5017 + static int pci_reset_hotplug_slot(struct hotplug_slot *hotplug, bool probe) 5018 5018 { 5019 5019 int rc = -ENOTTY; 5020 5020 ··· 5029 5029 return rc; 5030 5030 } 5031 5031 5032 - static int pci_dev_reset_slot_function(struct pci_dev *dev, int probe) 5032 + static int pci_dev_reset_slot_function(struct pci_dev *dev, bool probe) 5033 5033 { 5034 5034 if (dev->multifunction || dev->subordinate || !dev->slot || 5035 5035 dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET) ··· 5038 5038 return pci_reset_hotplug_slot(dev->slot->hotplug, probe); 5039 5039 } 5040 5040 5041 - static int pci_reset_bus_function(struct pci_dev *dev, int probe) 5041 + static int pci_reset_bus_function(struct pci_dev *dev, bool probe) 5042 5042 { 5043 5043 int rc; 5044 5044 ··· 5204 5204 goto error; 5205 5205 } 5206 5206 5207 - if (pci_reset_fn_methods[m].reset_fn(pdev, 1)) { 5207 + if (pci_reset_fn_methods[m].reset_fn(pdev, PCI_RESET_PROBE)) { 5208 5208 pci_err(pdev, "Unsupported reset method '%s'", name); 5209 5209 goto error; 5210 5210 } ··· 5220 5220 reset_methods[n] = 0; 5221 5221 5222 5222 /* Warn if dev-specific supported but not highest priority */ 5223 - if (pci_reset_fn_methods[1].reset_fn(pdev, 1) == 0 && 5223 + if (pci_reset_fn_methods[1].reset_fn(pdev, PCI_RESET_PROBE) == 0 && 5224 5224 reset_methods[0] != 1) 5225 5225 pci_warn(pdev, "Device-specific reset disabled/de-prioritized by user"); 5226 5226 memcpy(pdev->reset_methods, reset_methods, sizeof(pdev->reset_methods)); ··· 5294 5294 if (!m) 5295 5295 return -ENOTTY; 5296 5296 5297 - rc = pci_reset_fn_methods[m].reset_fn(dev, 0); 5297 + rc = pci_reset_fn_methods[m].reset_fn(dev, PCI_RESET_DO_RESET); 5298 5298 if (!rc) 5299 5299 return 0; 5300 5300 if (rc != -ENOTTY) ··· 5327 5327 5328 5328 i = 0; 5329 5329 for (m = 1; m < PCI_NUM_RESET_METHODS; m++) { 5330 - rc = pci_reset_fn_methods[m].reset_fn(dev, 1); 5330 + rc = pci_reset_fn_methods[m].reset_fn(dev, PCI_RESET_PROBE); 5331 5331 if (!rc) 5332 5332 dev->reset_methods[i++] = m; 5333 5333 else if (rc != -ENOTTY) ··· 5644 5644 } 5645 5645 } 5646 5646 5647 - static int pci_slot_reset(struct pci_slot *slot, int probe) 5647 + static int pci_slot_reset(struct pci_slot *slot, bool probe) 5648 5648 { 5649 5649 int rc; 5650 5650 ··· 5672 5672 */ 5673 5673 int pci_probe_reset_slot(struct pci_slot *slot) 5674 5674 { 5675 - return pci_slot_reset(slot, 1); 5675 + return pci_slot_reset(slot, PCI_RESET_PROBE); 5676 5676 } 5677 5677 EXPORT_SYMBOL_GPL(pci_probe_reset_slot); 5678 5678 ··· 5695 5695 { 5696 5696 int rc; 5697 5697 5698 - rc = pci_slot_reset(slot, 1); 5698 + rc = pci_slot_reset(slot, PCI_RESET_PROBE); 5699 5699 if (rc) 5700 5700 return rc; 5701 5701 5702 5702 if (pci_slot_trylock(slot)) { 5703 5703 pci_slot_save_and_disable_locked(slot); 5704 5704 might_sleep(); 5705 - rc = pci_reset_hotplug_slot(slot->hotplug, 0); 5705 + rc = pci_reset_hotplug_slot(slot->hotplug, PCI_RESET_DO_RESET); 5706 5706 pci_slot_restore_locked(slot); 5707 5707 pci_slot_unlock(slot); 5708 5708 } else ··· 5711 5711 return rc; 5712 5712 } 5713 5713 5714 - static int pci_bus_reset(struct pci_bus *bus, int probe) 5714 + static int pci_bus_reset(struct pci_bus *bus, bool probe) 5715 5715 { 5716 5716 int ret; 5717 5717 ··· 5757 5757 goto bus_reset; 5758 5758 5759 5759 list_for_each_entry(slot, &bus->slots, list) 5760 - if (pci_slot_reset(slot, 0)) 5760 + if (pci_slot_reset(slot, PCI_RESET_DO_RESET)) 5761 5761 goto bus_reset; 5762 5762 5763 5763 mutex_unlock(&pci_slot_mutex); 5764 5764 return 0; 5765 5765 bus_reset: 5766 5766 mutex_unlock(&pci_slot_mutex); 5767 - return pci_bus_reset(bridge->subordinate, 0); 5767 + return pci_bus_reset(bridge->subordinate, PCI_RESET_DO_RESET); 5768 5768 } 5769 5769 5770 5770 /** ··· 5775 5775 */ 5776 5776 int pci_probe_reset_bus(struct pci_bus *bus) 5777 5777 { 5778 - return pci_bus_reset(bus, 1); 5778 + return pci_bus_reset(bus, PCI_RESET_PROBE); 5779 5779 } 5780 5780 EXPORT_SYMBOL_GPL(pci_probe_reset_bus); 5781 5781 ··· 5789 5789 { 5790 5790 int rc; 5791 5791 5792 - rc = pci_bus_reset(bus, 1); 5792 + rc = pci_bus_reset(bus, PCI_RESET_PROBE); 5793 5793 if (rc) 5794 5794 return rc; 5795 5795
+6 -6
drivers/pci/pci.h
··· 608 608 struct pci_dev_reset_methods { 609 609 u16 vendor; 610 610 u16 device; 611 - int (*reset)(struct pci_dev *dev, int probe); 611 + int (*reset)(struct pci_dev *dev, bool probe); 612 612 }; 613 613 614 614 struct pci_reset_fn_method { 615 - int (*reset_fn)(struct pci_dev *pdev, int probe); 615 + int (*reset_fn)(struct pci_dev *pdev, bool probe); 616 616 char *name; 617 617 }; 618 618 619 619 #ifdef CONFIG_PCI_QUIRKS 620 - int pci_dev_specific_reset(struct pci_dev *dev, int probe); 620 + int pci_dev_specific_reset(struct pci_dev *dev, bool probe); 621 621 #else 622 - static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe) 622 + static inline int pci_dev_specific_reset(struct pci_dev *dev, bool probe) 623 623 { 624 624 return -ENOTTY; 625 625 } ··· 708 708 int pci_acpi_program_hp_params(struct pci_dev *dev); 709 709 extern const struct attribute_group pci_dev_acpi_attr_group; 710 710 void pci_set_acpi_fwnode(struct pci_dev *dev); 711 - int pci_dev_acpi_reset(struct pci_dev *dev, int probe); 711 + int pci_dev_acpi_reset(struct pci_dev *dev, bool probe); 712 712 #else 713 - static inline int pci_dev_acpi_reset(struct pci_dev *dev, int probe) 713 + static inline int pci_dev_acpi_reset(struct pci_dev *dev, bool probe) 714 714 { 715 715 return -ENOTTY; 716 716 }
+1 -1
drivers/pci/pcie/aer.c
··· 1407 1407 } 1408 1408 1409 1409 if (type == PCI_EXP_TYPE_RC_EC || type == PCI_EXP_TYPE_RC_END) { 1410 - rc = pcie_reset_flr(dev, 0); 1410 + rc = pcie_reset_flr(dev, PCI_RESET_DO_RESET); 1411 1411 if (!rc) 1412 1412 pci_info(dev, "has been reset\n"); 1413 1413 else
+10 -10
drivers/pci/quirks.c
··· 3702 3702 * reset a single function if other methods (e.g. FLR, PM D0->D3) are 3703 3703 * not available. 3704 3704 */ 3705 - static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, int probe) 3705 + static int reset_intel_82599_sfp_virtfn(struct pci_dev *dev, bool probe) 3706 3706 { 3707 3707 /* 3708 3708 * http://www.intel.com/content/dam/doc/datasheet/82599-10-gbe-controller-datasheet.pdf ··· 3724 3724 #define NSDE_PWR_STATE 0xd0100 3725 3725 #define IGD_OPERATION_TIMEOUT 10000 /* set timeout 10 seconds */ 3726 3726 3727 - static int reset_ivb_igd(struct pci_dev *dev, int probe) 3727 + static int reset_ivb_igd(struct pci_dev *dev, bool probe) 3728 3728 { 3729 3729 void __iomem *mmio_base; 3730 3730 unsigned long timeout; ··· 3767 3767 } 3768 3768 3769 3769 /* Device-specific reset method for Chelsio T4-based adapters */ 3770 - static int reset_chelsio_generic_dev(struct pci_dev *dev, int probe) 3770 + static int reset_chelsio_generic_dev(struct pci_dev *dev, bool probe) 3771 3771 { 3772 3772 u16 old_command; 3773 3773 u16 msix_flags; ··· 3845 3845 * Chapter 3: NVMe control registers 3846 3846 * Chapter 7.3: Reset behavior 3847 3847 */ 3848 - static int nvme_disable_and_flr(struct pci_dev *dev, int probe) 3848 + static int nvme_disable_and_flr(struct pci_dev *dev, bool probe) 3849 3849 { 3850 3850 void __iomem *bar; 3851 3851 u16 cmd; 3852 3852 u32 cfg; 3853 3853 3854 3854 if (dev->class != PCI_CLASS_STORAGE_EXPRESS || 3855 - pcie_reset_flr(dev, 1) || !pci_resource_start(dev, 0)) 3855 + pcie_reset_flr(dev, PCI_RESET_PROBE) || !pci_resource_start(dev, 0)) 3856 3856 return -ENOTTY; 3857 3857 3858 3858 if (probe) ··· 3919 3919 * device too soon after FLR. A 250ms delay after FLR has heuristically 3920 3920 * proven to produce reliably working results for device assignment cases. 3921 3921 */ 3922 - static int delay_250ms_after_flr(struct pci_dev *dev, int probe) 3922 + static int delay_250ms_after_flr(struct pci_dev *dev, bool probe) 3923 3923 { 3924 3924 if (probe) 3925 - return pcie_reset_flr(dev, 1); 3925 + return pcie_reset_flr(dev, PCI_RESET_PROBE); 3926 3926 3927 - pcie_reset_flr(dev, 0); 3927 + pcie_reset_flr(dev, PCI_RESET_DO_RESET); 3928 3928 3929 3929 msleep(250); 3930 3930 ··· 3939 3939 #define HINIC_OPERATION_TIMEOUT 15000 /* 15 seconds */ 3940 3940 3941 3941 /* Device-specific reset method for Huawei Intelligent NIC virtual functions */ 3942 - static int reset_hinic_vf_dev(struct pci_dev *pdev, int probe) 3942 + static int reset_hinic_vf_dev(struct pci_dev *pdev, bool probe) 3943 3943 { 3944 3944 unsigned long timeout; 3945 3945 void __iomem *bar; ··· 4016 4016 * because when a host assigns a device to a guest VM, the host may need 4017 4017 * to reset the device but probably doesn't have a driver for it. 4018 4018 */ 4019 - int pci_dev_specific_reset(struct pci_dev *dev, int probe) 4019 + int pci_dev_specific_reset(struct pci_dev *dev, bool probe) 4020 4020 { 4021 4021 const struct pci_dev_reset_methods *i; 4022 4022
+4 -1
include/linux/pci.h
··· 52 52 /* Number of reset methods used in pci_reset_fn_methods array in pci.c */ 53 53 #define PCI_NUM_RESET_METHODS 7 54 54 55 + #define PCI_RESET_PROBE true 56 + #define PCI_RESET_DO_RESET false 57 + 55 58 /* 56 59 * The PCI interface treats multi-function devices as independent 57 60 * devices. The slot/function address of each device is encoded ··· 1237 1234 enum pci_bus_speed *speed, 1238 1235 enum pcie_link_width *width); 1239 1236 void pcie_print_link_status(struct pci_dev *dev); 1240 - int pcie_reset_flr(struct pci_dev *dev, int probe); 1237 + int pcie_reset_flr(struct pci_dev *dev, bool probe); 1241 1238 int pcie_flr(struct pci_dev *dev); 1242 1239 int __pci_reset_function_locked(struct pci_dev *dev); 1243 1240 int pci_reset_function(struct pci_dev *dev);
+1 -1
include/linux/pci_hotplug.h
··· 44 44 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value); 45 45 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value); 46 46 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value); 47 - int (*reset_slot) (struct hotplug_slot *slot, int probe); 47 + int (*reset_slot) (struct hotplug_slot *slot, bool probe); 48 48 }; 49 49 50 50 /**