Message ID | 1529467995-28780-5-git-send-email-okaya@codeaurora.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi Sinan,
I love your patch! Yet something to improve:
[auto build test ERROR on pci/next]
[also build test ERROR on v4.18-rc1 next-20180619]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Sinan-Kaya/PCI-handle-error-return-from-pci_reset_bridge_secondary_bus/20180620-121648
base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
config: x86_64-allyesconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
drivers/infiniband//hw/hfi1/pcie.c: In function 'trigger_sbr':
>> drivers/infiniband//hw/hfi1/pcie.c:908:23: error: passing argument 1 of 'pci_reset_bus' from incompatible pointer type [-Werror=incompatible-pointer-types]
return pci_reset_bus(dev->bus);
^~~
In file included from drivers/infiniband//hw/hfi1/pcie.c:48:0:
include/linux/pci.h:1099:5: note: expected 'struct pci_dev *' but argument is of type 'struct pci_bus *'
int pci_reset_bus(struct pci_dev *dev);
^~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/pci_reset_bus +908 drivers/infiniband//hw/hfi1/pcie.c
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 873
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 874 /*
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 875 * Trigger a secondary bus reset (SBR) on ourselves using our parent.
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 876 *
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 877 * Based on pci_parent_bus_reset() which is not exported by the
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 878 * kernel core.
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 879 */
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 880 static int trigger_sbr(struct hfi1_devdata *dd)
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 881 {
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 882 struct pci_dev *dev = dd->pcidev;
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 883 struct pci_dev *pdev;
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 884
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 885 /* need a parent */
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 886 if (!dev->bus->self) {
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 887 dd_dev_err(dd, "%s: no parent device\n", __func__);
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 888 return -ENOTTY;
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 889 }
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 890
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 891 /* should not be anyone else on the bus */
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 892 list_for_each_entry(pdev, &dev->bus->devices, bus_list)
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 893 if (pdev != dev) {
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 894 dd_dev_err(dd,
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 895 "%s: another device is on the same bus\n",
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 896 __func__);
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 897 return -ENOTTY;
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 898 }
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 899
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 900 /*
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 901 * A secondary bus reset (SBR) issues a hot reset to our device.
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 902 * The following routine does a 1s wait after the reset is dropped
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 903 * per PCI Trhfa (recovery time). PCIe 3.0 section 6.6.1 -
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 904 * Conventional Reset, paragraph 3, line 35 also says that a 1s
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 905 * delay after a reset is required. Per spec requirements,
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 906 * the link is either working or not after that point.
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 907 */
f001109e drivers/infiniband/hw/hfi1/pcie.c Sinan Kaya 2018-06-20 @908 return pci_reset_bus(dev->bus);
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 909 }
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 910
:::::: The code at line 908 was first introduced by commit
:::::: f001109e94b74baebb3621ce1c7ba114a858adb3 IB/hfi1: use pci_reset_bus() for initiating pci secondary bus reset
:::::: TO: Sinan Kaya <okaya@codeaurora.org>
:::::: CC: 0day robot <lkp@intel.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi Sinan,
I love your patch! Perhaps something to improve:
[auto build test WARNING on pci/next]
[also build test WARNING on v4.18-rc1 next-20180620]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Sinan-Kaya/PCI-handle-error-return-from-pci_reset_bridge_secondary_bus/20180620-121648
base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
>> drivers/infiniband/hw/hfi1/pcie.c:908:33: sparse: incorrect type in argument 1 (different base types) @@ expected struct pci_dev *dev @@ got struct pci_dev *dev @@
drivers/infiniband/hw/hfi1/pcie.c:908:33: expected struct pci_dev *dev
drivers/infiniband/hw/hfi1/pcie.c:908:33: got struct pci_bus *bus
drivers/infiniband/hw/hfi1/pcie.c: In function 'trigger_sbr':
drivers/infiniband/hw/hfi1/pcie.c:908:23: error: passing argument 1 of 'pci_reset_bus' from incompatible pointer type [-Werror=incompatible-pointer-types]
return pci_reset_bus(dev->bus);
^~~
In file included from drivers/infiniband/hw/hfi1/pcie.c:48:0:
include/linux/pci.h:1099:5: note: expected 'struct pci_dev *' but argument is of type 'struct pci_bus *'
int pci_reset_bus(struct pci_dev *dev);
^~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +908 drivers/infiniband/hw/hfi1/pcie.c
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 873
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 874 /*
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 875 * Trigger a secondary bus reset (SBR) on ourselves using our parent.
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 876 *
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 877 * Based on pci_parent_bus_reset() which is not exported by the
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 878 * kernel core.
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 879 */
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 880 static int trigger_sbr(struct hfi1_devdata *dd)
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 881 {
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 882 struct pci_dev *dev = dd->pcidev;
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 883 struct pci_dev *pdev;
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 884
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 885 /* need a parent */
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 886 if (!dev->bus->self) {
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 887 dd_dev_err(dd, "%s: no parent device\n", __func__);
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 888 return -ENOTTY;
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 889 }
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 890
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 891 /* should not be anyone else on the bus */
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 892 list_for_each_entry(pdev, &dev->bus->devices, bus_list)
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 893 if (pdev != dev) {
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 894 dd_dev_err(dd,
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 895 "%s: another device is on the same bus\n",
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 896 __func__);
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 897 return -ENOTTY;
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 898 }
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 899
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 900 /*
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 901 * A secondary bus reset (SBR) issues a hot reset to our device.
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 902 * The following routine does a 1s wait after the reset is dropped
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 903 * per PCI Trhfa (recovery time). PCIe 3.0 section 6.6.1 -
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 904 * Conventional Reset, paragraph 3, line 35 also says that a 1s
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 905 * delay after a reset is required. Per spec requirements,
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 906 * the link is either working or not after that point.
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 907 */
f001109e drivers/infiniband/hw/hfi1/pcie.c Sinan Kaya 2018-06-20 @908 return pci_reset_bus(dev->bus);
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 909 }
77241056 drivers/staging/rdma/hfi1/pcie.c Mike Marciniszyn 2015-07-30 910
:::::: The code at line 908 was first introduced by commit
:::::: f001109e94b74baebb3621ce1c7ba114a858adb3 IB/hfi1: use pci_reset_bus() for initiating pci secondary bus reset
:::::: TO: Sinan Kaya <okaya@codeaurora.org>
:::::: CC: 0day robot <lkp@intel.com>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 79a1566..a44b948 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4798,7 +4798,7 @@ EXPORT_SYMBOL_GPL(pci_probe_reset_slot); * * Return 0 on success, non-zero on error. */ -int pci_reset_slot(struct pci_slot *slot) +static int __pci_reset_slot(struct pci_slot *slot) { int rc; @@ -4814,7 +4814,6 @@ int pci_reset_slot(struct pci_slot *slot) return rc; } -EXPORT_SYMBOL_GPL(pci_reset_slot); /** * __pci_try_reset_slot - Try to reset a PCI slot @@ -4878,7 +4877,7 @@ int pci_probe_reset_bus(struct pci_bus *bus) EXPORT_SYMBOL_GPL(pci_probe_reset_bus); /** - * pci_reset_bus - reset a PCI bus + * __pci_reset_bus - reset a PCI bus * @bus: top level PCI bus to reset * * Do a bus reset on the given bus and any subordinate buses, saving @@ -4886,7 +4885,7 @@ EXPORT_SYMBOL_GPL(pci_probe_reset_bus); * * Return 0 on success, non-zero on error. */ -int pci_reset_bus(struct pci_bus *bus) +static int __pci_reset_bus(struct pci_bus *bus) { int rc; @@ -4902,6 +4901,26 @@ int pci_reset_bus(struct pci_bus *bus) return rc; } + +/** + * pci_reset_bus - reset a PCI bus + * @pdev: top level PCI device to reset via slot/bus + * + * Do a slot/bus reset on the given bus and any subordinate buses, saving + * and restoring state of all devices. + * + * Return 0 on success, non-zero on error. + */ +int pci_reset_bus(struct pci_dev *pdev) +{ + bool slot = false; + + if (!pci_probe_reset_slot(pdev->slot)) + slot = true; + + return slot ? __pci_reset_slot(pdev->slot) : + __pci_reset_bus(pdev->bus); +} EXPORT_SYMBOL_GPL(pci_reset_bus); /** diff --git a/include/linux/pci.h b/include/linux/pci.h index f5c85b6..e68ca2e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1095,9 +1095,8 @@ int pci_reset_function(struct pci_dev *dev); int pci_reset_function_locked(struct pci_dev *dev); int pci_try_reset_function(struct pci_dev *dev); int pci_probe_reset_slot(struct pci_slot *slot); -int pci_reset_slot(struct pci_slot *slot); int pci_probe_reset_bus(struct pci_bus *bus); -int pci_reset_bus(struct pci_bus *bus); +int pci_reset_bus(struct pci_dev *dev); int pci_try_reset_bus(struct pci_dev *dev); void pci_reset_secondary_bus(struct pci_dev *dev); void pcibios_reset_secondary_bus(struct pci_dev *dev);
Drivers are expected to call pci_reset_slot() or pci_reset_bus() by querying if a system supports hotplug or not. A survey showed that most drivers don't do this and we are leaking hotplug capability to the user. Hide pci_slot_reset() from drivers and embed into pci_bus_reset(). Change pci_reset_bus() parameter from struct pci_bus to struct pci_dev. Signed-off-by: Sinan Kaya <okaya@codeaurora.org> --- drivers/pci/pci.c | 27 +++++++++++++++++++++++---- include/linux/pci.h | 3 +-- 2 files changed, 24 insertions(+), 6 deletions(-)