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

PCI: Remove reset_fn field from pci_dev

"reset_fn" indicates whether the device supports any reset mechanism.
Remove the use of reset_fn in favor of the reset_methods array that tracks
supported reset mechanisms of a device and their ordering.

The octeon driver incorrectly used reset_fn to detect whether the device
supports FLR or not. Use pcie_reset_flr() to probe whether it supports FLR.

Co-developed-by: Alex Williamson <alex.williamson@redhat.com>
Link: https://lore.kernel.org/r/20210817180500.1253-5-ameynarkhede03@gmail.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Amey Narkhede <ameynarkhede03@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>

authored by

Amey Narkhede and committed by
Bjorn Helgaas
4ec36dfe e20afa06

+6 -9
+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 (oct->pci_dev->reset_fn) 529 + if (!pcie_reset_flr(oct->pci_dev, 1)) 530 530 octeon_pci_flr(oct); 531 531 else 532 532 cn23xx_vf_ask_pf_to_do_flr(oct);
+1 -1
drivers/pci/pci-sysfs.c
··· 1367 1367 { 1368 1368 struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); 1369 1369 1370 - if (!pdev->reset_fn) 1370 + if (!pci_reset_supported(pdev)) 1371 1371 return 0; 1372 1372 1373 1373 return a->mode;
+3 -3
drivers/pci/pci.c
··· 5234 5234 { 5235 5235 int rc; 5236 5236 5237 - if (!dev->reset_fn) 5237 + if (!pci_reset_supported(dev)) 5238 5238 return -ENOTTY; 5239 5239 5240 5240 pci_dev_lock(dev); ··· 5270 5270 { 5271 5271 int rc; 5272 5272 5273 - if (!dev->reset_fn) 5273 + if (!pci_reset_supported(dev)) 5274 5274 return -ENOTTY; 5275 5275 5276 5276 pci_dev_save_and_disable(dev); ··· 5293 5293 { 5294 5294 int rc; 5295 5295 5296 - if (!dev->reset_fn) 5296 + if (!pci_reset_supported(dev)) 5297 5297 return -ENOTTY; 5298 5298 5299 5299 if (!pci_dev_trylock(dev))
-1
drivers/pci/probe.c
··· 2430 2430 2431 2431 pcie_report_downtraining(dev); 2432 2432 pci_init_reset_methods(dev); 2433 - dev->reset_fn = pci_reset_supported(dev); 2434 2433 } 2435 2434 2436 2435 /*
+1 -1
drivers/pci/quirks.c
··· 5626 5626 5627 5627 if (pdev->subsystem_vendor != PCI_VENDOR_ID_LENOVO || 5628 5628 pdev->subsystem_device != 0x222e || 5629 - !pdev->reset_fn) 5629 + !pci_reset_supported(pdev)) 5630 5630 return; 5631 5631 5632 5632 if (pci_enable_device_mem(pdev))
-1
drivers/pci/remove.c
··· 19 19 pci_pme_active(dev, false); 20 20 21 21 if (pci_dev_is_added(dev)) { 22 - dev->reset_fn = 0; 23 22 24 23 device_release_driver(&dev->dev); 25 24 pci_proc_detach_device(dev);
-1
include/linux/pci.h
··· 431 431 unsigned int state_saved:1; 432 432 unsigned int is_physfn:1; 433 433 unsigned int is_virtfn:1; 434 - unsigned int reset_fn:1; 435 434 unsigned int is_hotplug_bridge:1; 436 435 unsigned int shpc_managed:1; /* SHPC owned by shpchp */ 437 436 unsigned int is_thunderbolt:1; /* Thunderbolt controller */