PCI: Move pci_dev_is/assign_added() to pci.h
Niklas Schnelle
maintainerPATCH v2 1/1 PCI: Move pci_dev_is/assign_added() to pci.h
The helper function pci_dev_is_added() from drivers/pci/pci.h is used in PCI arch code of both s390 and powerpc leading to awkward relative includes. Move it to the global include/linux/pci.h and get rid of these includes just for that one function.
---
Since v1:
- Fixed accidental removal of PCI_DPC_RECOVERED, PCI_DPC_RECOVERING defines and also move these to include/linux/pci.h
arch/powerpc/platforms/powernv/pci-sriov.c | 3 --- arch/powerpc/platforms/pseries/setup.c | 1 - arch/s390/pci/pci_sysfs.c | 2 -- drivers/pci/hotplug/acpiphp_glue.c | 1 - drivers/pci/pci.h | 15 --------------- include/linux/pci.h | 13 +++++++++++++ 6 files changed, 13 insertions(+), 22 deletions(-)
arch/powerpc/platforms/powernv/pci-sriov.c +0 -3
@@ -9,9 +9,6 @@#include "pci.h" -/* for pci_dev_is_added() */ -#include "../../../../drivers/pci/pci.h" -/* * The majority of the complexity in supporting SR-IOV on PowerNV comes from * the need to put the MMIO space for each VF into a separate PE. Internally
arch/powerpc/platforms/pseries/setup.c +0 -1
@@ -74,7 +74,6 @@#include <asm/hvconsole.h> #include "pseries.h" -#include "../../../../drivers/pci/pci.h" DEFINE_STATIC_KEY_FALSE (shared_processor);EXPORT_SYMBOL_GPL (shared_processor);
arch/s390/pci/pci_sysfs.c +0 -2
@@ -13,8 +13,6 @@#include <linux/stat.h> #include <linux/pci.h> -#include "../../../drivers/pci/pci.h" -#include <asm/sclp.h> #define zpci_attr (name, fmt, member) \
drivers/pci/hotplug/acpiphp_glue.c +0 -1
@@ -38,7 +38,6 @@#include <linux/slab.h> #include <linux/acpi.h> -#include "../pci.h" #include "acpiphp.h" static LIST_HEAD (bridge_list);
drivers/pci/pci.h +0 -15
@@ -383,21 +383,6 @@ static inline bool pci_dev_is_disconnected(const struct pci_dev *dev)return dev->error_state == pci_channel_io_perm_failure; } -/* pci_dev priv_flags */ -#define PCI_DEV_ADDED 0 -#define PCI_DPC_RECOVERED 1 -#define PCI_DPC_RECOVERING 2 - -static inline void pci_dev_assign_added (struct pci_dev *dev,bool added) -{ -assign_bit (PCI_DEV_ADDED , &dev->priv_flags, added); -} - -static inline bool pci_dev_is_added (const struct pci_dev *dev) -{ -return test_bit (PCI_DEV_ADDED , &dev->priv_flags); -} -#ifdef CONFIG_PCIEAER #include <linux/aer.h>
include/linux/pci.h +13 -0
@@ -507,6 +507,19 @@ struct pci_dev {unsigned long priv_flags;/* Private flags for the PCI driver */ }; +/* pci_dev priv_flags */ +#define PCI_DEV_ADDED 0 + +static inline void pci_dev_assign_added (struct pci_dev *dev,bool added) +{ +assign_bit (PCI_DEV_ADDED , &dev->priv_flags, added); +} + +static inline bool pci_dev_is_added (const struct pci_dev *dev) +{ +return test_bit (PCI_DEV_ADDED , &dev->priv_flags); +} +static inline struct pci_dev *pci_physfn (struct pci_dev *dev) {#ifdef CONFIG_PCI_IOV
Signature · 1 line
2.25.1
kernel test robot
build botI love your patch! Yet something to improve:
Hi Niklas,
I love your patch! Yet something to improve:
[auto build test ERROR on pci/next]
[also build test ERROR on powerpc/next s390/features pm/linux-next v5.14-rc2 next-20210720] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Niklas-Schnelle/PCI-Move-pci_dev_is-assign_added-to-pci-h/20210720-180050 base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next config: arm-buildonly-randconfig-r002-20210720 (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 10.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/52e04c39213cf20b8c6bc717cfda56103b871cd1
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Niklas-Schnelle/PCI-Move-pci_dev_is-assign_added-to-pci-h/20210720-180050 git checkout 52e04c39213cf20b8c6bc717cfda56103b871cd1
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-10.3.0 make.cross O=build_dir ARCH=arm SHELL=/bin/bash drivers/pci/pcie/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/pci/pcie/dpc.c: In function 'dpc_completed':
>> drivers/pci/pcie/dpc.c:85:15: error: 'PCI_DPC_RECOVERING' undeclared (first use in this function)
85 | if (test_bit(PCI_DPC_RECOVERING, &pdev->priv_flags))
| ^~~~~~~~~~~~~~~~~~
drivers/pci/pcie/dpc.c:85:15: note: each undeclared identifier is reported only once for each function it appears in
In file included from include/linux/bitops.h:32,
from include/linux/kernel.h:12,
from include/linux/delay.h:22,
from drivers/pci/pcie/dpc.c:12:
drivers/pci/pcie/dpc.c: In function 'pci_dpc_recovered':
>> drivers/pci/pcie/dpc.c:122:28: error: 'PCI_DPC_RECOVERED' undeclared (first use in this function)
122 | return test_and_clear_bit(PCI_DPC_RECOVERED, &pdev->priv_flags);
| ^~~~~~~~~~~~~~~~~
arch/arm/include/asm/bitops.h:181:24: note: in definition of macro 'ATOMIC_BITOP'
181 | (__builtin_constant_p(nr) ? ____atomic_##name(nr, p) : _##name(nr,p))
| ^~
drivers/pci/pcie/dpc.c:122:9: note: in expansion of macro 'test_and_clear_bit'
122 | return test_and_clear_bit(PCI_DPC_RECOVERED, &pdev->priv_flags);
| ^~~~~~~~~~~~~~~~~~
drivers/pci/pcie/dpc.c: In function 'dpc_reset_link':
drivers/pci/pcie/dpc.c:149:10: error: 'PCI_DPC_RECOVERING' undeclared (first use in this function)
149 | set_bit(PCI_DPC_RECOVERING, &pdev->priv_flags);
| ^~~~~~~~~~~~~~~~~~
arch/arm/include/asm/bitops.h:181:24: note: in definition of macro 'ATOMIC_BITOP'
181 | (__builtin_constant_p(nr) ? ____atomic_##name(nr, p) : _##name(nr,p))
| ^~
drivers/pci/pcie/dpc.c:149:2: note: in expansion of macro 'set_bit'
149 | set_bit(PCI_DPC_RECOVERING, &pdev->priv_flags);
| ^~~~~~~
drivers/pci/pcie/dpc.c:165:13: error: 'PCI_DPC_RECOVERED' undeclared (first use in this function)
165 | clear_bit(PCI_DPC_RECOVERED, &pdev->priv_flags);
| ^~~~~~~~~~~~~~~~~
arch/arm/include/asm/bitops.h:181:24: note: in definition of macro 'ATOMIC_BITOP'
181 | (__builtin_constant_p(nr) ? ____atomic_##name(nr, p) : _##name(nr,p))
| ^~
drivers/pci/pcie/dpc.c:165:3: note: in expansion of macro 'clear_bit'
165 | clear_bit(PCI_DPC_RECOVERED, &pdev->priv_flags);
| ^~~~~~~~~
drivers/pci/pcie/dpc.c: In function 'pci_dpc_recovered':
drivers/pci/pcie/dpc.c:123:1: error: control reaches end of non-void function [-Werror=return-type]
123 | }
| ^cc1: some warnings being treated as errors
vim +/PCI_DPC_RECOVERING +85 drivers/pci/pcie/dpc.c
a97396c6eb13f65b Lukas Wunner 2021-05-01 75
a97396c6eb13f65b Lukas Wunner 2021-05-01 76 #ifdef CONFIG_HOTPLUG_PCI_PCIE
a97396c6eb13f65b Lukas Wunner 2021-05-01 77 static bool dpc_completed(struct pci_dev *pdev)
a97396c6eb13f65b Lukas Wunner 2021-05-01 78 {
a97396c6eb13f65b Lukas Wunner 2021-05-01 79 u16 status;
a97396c6eb13f65b Lukas Wunner 2021-05-01 80
a97396c6eb13f65b Lukas Wunner 2021-05-01 81 pci_read_config_word(pdev, pdev->dpc_cap + PCI_EXP_DPC_STATUS, &status);
a97396c6eb13f65b Lukas Wunner 2021-05-01 82 if ((status != 0xffff) && (status & PCI_EXP_DPC_STATUS_TRIGGER))
a97396c6eb13f65b Lukas Wunner 2021-05-01 83 return false;
a97396c6eb13f65b Lukas Wunner 2021-05-01 84
a97396c6eb13f65b Lukas Wunner 2021-05-01 @85 if (test_bit(PCI_DPC_RECOVERING, &pdev->priv_flags))
a97396c6eb13f65b Lukas Wunner 2021-05-01 86 return false;
a97396c6eb13f65b Lukas Wunner 2021-05-01 87
a97396c6eb13f65b Lukas Wunner 2021-05-01 88 return true;
a97396c6eb13f65b Lukas Wunner 2021-05-01 89 }
a97396c6eb13f65b Lukas Wunner 2021-05-01 90
a97396c6eb13f65b Lukas Wunner 2021-05-01 91 /**
a97396c6eb13f65b Lukas Wunner 2021-05-01 92 * pci_dpc_recovered - whether DPC triggered and has recovered successfully
a97396c6eb13f65b Lukas Wunner 2021-05-01 93 * @pdev: PCI device
a97396c6eb13f65b Lukas Wunner 2021-05-01 94 *
a97396c6eb13f65b Lukas Wunner 2021-05-01 95 * Return true if DPC was triggered for @pdev and has recovered successfully.
a97396c6eb13f65b Lukas Wunner 2021-05-01 96 * Wait for recovery if it hasn't completed yet. Called from the PCIe hotplug
a97396c6eb13f65b Lukas Wunner 2021-05-01 97 * driver to recognize and ignore Link Down/Up events caused by DPC.
a97396c6eb13f65b Lukas Wunner 2021-05-01 98 */
a97396c6eb13f65b Lukas Wunner 2021-05-01 99 bool pci_dpc_recovered(struct pci_dev *pdev)
a97396c6eb13f65b Lukas Wunner 2021-05-01 100 {
a97396c6eb13f65b Lukas Wunner 2021-05-01 101 struct pci_host_bridge *host;
a97396c6eb13f65b Lukas Wunner 2021-05-01 102
a97396c6eb13f65b Lukas Wunner 2021-05-01 103 if (!pdev->dpc_cap)
a97396c6eb13f65b Lukas Wunner 2021-05-01 104 return false;
a97396c6eb13f65b Lukas Wunner 2021-05-01 105
a97396c6eb13f65b Lukas Wunner 2021-05-01 106 /*
a97396c6eb13f65b Lukas Wunner 2021-05-01 107 * Synchronization between hotplug and DPC is not supported
a97396c6eb13f65b Lukas Wunner 2021-05-01 108 * if DPC is owned by firmware and EDR is not enabled.
a97396c6eb13f65b Lukas Wunner 2021-05-01 109 */
a97396c6eb13f65b Lukas Wunner 2021-05-01 110 host = pci_find_host_bridge(pdev->bus);
a97396c6eb13f65b Lukas Wunner 2021-05-01 111 if (!host->native_dpc && !IS_ENABLED(CONFIG_PCIE_EDR))
a97396c6eb13f65b Lukas Wunner 2021-05-01 112 return false;
a97396c6eb13f65b Lukas Wunner 2021-05-01 113
a97396c6eb13f65b Lukas Wunner 2021-05-01 114 /*
a97396c6eb13f65b Lukas Wunner 2021-05-01 115 * Need a timeout in case DPC never completes due to failure of
a97396c6eb13f65b Lukas Wunner 2021-05-01 116 * dpc_wait_rp_inactive(). The spec doesn't mandate a time limit,
a97396c6eb13f65b Lukas Wunner 2021-05-01 117 * but reports indicate that DPC completes within 4 seconds.
a97396c6eb13f65b Lukas Wunner 2021-05-01 118 */
a97396c6eb13f65b Lukas Wunner 2021-05-01 119 wait_event_timeout(dpc_completed_waitqueue, dpc_completed(pdev),
a97396c6eb13f65b Lukas Wunner 2021-05-01 120 msecs_to_jiffies(4000));
a97396c6eb13f65b Lukas Wunner 2021-05-01 121
a97396c6eb13f65b Lukas Wunner 2021-05-01 @122 return test_and_clear_bit(PCI_DPC_RECOVERED, &pdev->priv_flags);
a97396c6eb13f65b Lukas Wunner 2021-05-01 123 }
a97396c6eb13f65b Lukas Wunner 2021-05-01 124 #endif /* CONFIG_HOTPLUG_PCI_PCIE */a97396c6eb13f65b Lukas Wunner 2021-05-01 125
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Niklas Schnelle
maintainerQuoted 10 lines · Niklas Schnelle
The helper function
pci_dev_is_added()fromdrivers/pci/pci.his used in PCI arch code of both s390 and powerpc leading to awkward relative includes. Move it to the globalinclude/linux/pci.hand get rid of these includes just for that one function.Signed-off-by Niklas Schnelle <[email protected]>---
Since v1:
- Fixed accidental removal ofPCI_DPC_RECOVERED,PCI_DPC_RECOVERINGdefines and also move these toinclude/linux/pci.h
Please disregard I actually sent the old patch ;-(
Quoted 10 lines
arch/powerpc/platforms/powernv/pci-sriov.c | 3 --- arch/powerpc/platforms/pseries/setup.c | 1 - arch/s390/pci/pci_sysfs.c | 2 -- drivers/pci/hotplug/acpiphp_glue.c | 1 - drivers/pci/pci.h | 15 --------------- include/linux/pci.h | 13 +++++++++++++ 6 files changed, 13 insertions(+), 22 deletions(-)
... snip ..