LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2] PCI: Move pci_dev_is/assign_added() to pci.h
@ 2021-07-20  9:58 Niklas Schnelle
  2021-07-20 13:48 ` kernel test robot
  2021-07-20 13:59 ` Niklas Schnelle
  0 siblings, 2 replies; 3+ messages in thread
From: Niklas Schnelle @ 2021-07-20  9:58 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, Michael Ellerman, Paul Mackerras,
	linux-pci, linux-kernel, linux-s390, linux-arch, linuxppc-dev

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.

Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
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(-)

diff --git a/arch/powerpc/platforms/powernv/pci-sriov.c b/arch/powerpc/platforms/powernv/pci-sriov.c
index 28aac933a439..2e0ca5451e85 100644
--- a/arch/powerpc/platforms/powernv/pci-sriov.c
+++ b/arch/powerpc/platforms/powernv/pci-sriov.c
@@ -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
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 631a0d57b6cd..17585ec9f955 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -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);
diff --git a/arch/s390/pci/pci_sysfs.c b/arch/s390/pci/pci_sysfs.c
index 6e2450c2b9c1..8dbe54ef8f8e 100644
--- a/arch/s390/pci/pci_sysfs.c
+++ b/arch/s390/pci/pci_sysfs.c
@@ -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)					\
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index f031302ad401..4cb963f88183 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -38,7 +38,6 @@
 #include <linux/slab.h>
 #include <linux/acpi.h>
 
-#include "../pci.h"
 #include "acpiphp.h"
 
 static LIST_HEAD(bridge_list);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 93dcdd431072..a159cd0f6f05 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -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>
 
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 540b377ca8f6..b3b7bafa17e5 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -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
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] PCI: Move pci_dev_is/assign_added() to pci.h
  2021-07-20  9:58 [PATCH v2] PCI: Move pci_dev_is/assign_added() to pci.h Niklas Schnelle
@ 2021-07-20 13:48 ` kernel test robot
  2021-07-20 13:59 ` Niklas Schnelle
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2021-07-20 13:48 UTC (permalink / raw)
  To: Niklas Schnelle, Bjorn Helgaas
  Cc: kbuild-all, linux-arch, linux-s390, linux-pci, linux-kernel,
	Paul Mackerras, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 8262 bytes --]

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
Reported-by: kernel test robot <lkp@intel.com>

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@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 40907 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] PCI: Move pci_dev_is/assign_added() to pci.h
  2021-07-20  9:58 [PATCH v2] PCI: Move pci_dev_is/assign_added() to pci.h Niklas Schnelle
  2021-07-20 13:48 ` kernel test robot
@ 2021-07-20 13:59 ` Niklas Schnelle
  1 sibling, 0 replies; 3+ messages in thread
From: Niklas Schnelle @ 2021-07-20 13:59 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Benjamin Herrenschmidt, Michael Ellerman, Paul Mackerras,
	linux-pci, linux-kernel, linux-s390, linux-arch, linuxppc-dev

On Tue, 2021-07-20 at 11:58 +0200, Niklas Schnelle wrote:
> 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.
> 
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
> ---
> Since v1:
> - Fixed accidental removal of PCI_DPC_RECOVERED, PCI_DPC_RECOVERING
>   defines and also move these to include/linux/pci.h

Please disregard I actually sent the old patch ;-(

> 
>  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 ..


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-20 14:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-20  9:58 [PATCH v2] PCI: Move pci_dev_is/assign_added() to pci.h Niklas Schnelle
2021-07-20 13:48 ` kernel test robot
2021-07-20 13:59 ` Niklas Schnelle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).