diff mbox series

[v5,4/4] asm-generic: Add new pci.h and use it

Message ID 20220721134924.596152-5-shorne@gmail.com (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Stafford Horne July 21, 2022, 1:49 p.m. UTC
The asm/pci.h used for many newer architectures share similar
definitions.  Move the common parts to asm-generic/pci.h to allow for
sharing code.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/lkml/CAK8P3a0JmPeczfmMBE__vn=Jbvf=nkbpVaZCycyv40pZNCJJXQ@mail.gmail.com/
Acked-by: Pierre Morel <pmorel@linux.ibm.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Stafford Horne <shorne@gmail.com>
---
Since v4:
 - Add reviewed-by

 arch/arm64/include/asm/pci.h | 10 ++--------
 arch/csky/include/asm/pci.h  | 17 ++---------------
 arch/riscv/include/asm/pci.h | 23 ++++-------------------
 arch/um/include/asm/pci.h    | 14 ++------------
 include/asm-generic/pci.h    | 32 ++++++++++++++++++++++++++++++++
 5 files changed, 42 insertions(+), 54 deletions(-)
 create mode 100644 include/asm-generic/pci.h

Comments

Bjorn Helgaas July 21, 2022, 5:37 p.m. UTC | #1
On Thu, Jul 21, 2022 at 10:49:24PM +0900, Stafford Horne wrote:
> The asm/pci.h used for many newer architectures share similar
> definitions.  Move the common parts to asm-generic/pci.h to allow for
> sharing code.
> 
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Link: https://lore.kernel.org/lkml/CAK8P3a0JmPeczfmMBE__vn=Jbvf=nkbpVaZCycyv40pZNCJJXQ@mail.gmail.com/
> Acked-by: Pierre Morel <pmorel@linux.ibm.com>
> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Stafford Horne <shorne@gmail.com>
> ---
> Since v4:
>  - Add reviewed-by
> 
>  arch/arm64/include/asm/pci.h | 10 ++--------
>  arch/csky/include/asm/pci.h  | 17 ++---------------
>  arch/riscv/include/asm/pci.h | 23 ++++-------------------
>  arch/um/include/asm/pci.h    | 14 ++------------
>  include/asm-generic/pci.h    | 32 ++++++++++++++++++++++++++++++++
>  5 files changed, 42 insertions(+), 54 deletions(-)
>  create mode 100644 include/asm-generic/pci.h

> +++ b/include/asm-generic/pci.h
> @@ -0,0 +1,32 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +
> +#ifndef __ASM_GENERIC_PCI_H
> +#define __ASM_GENERIC_PCI_H
> +
> +#include <linux/types.h>

Do we need <linux/types.h> here?  I don't see anything below that
depends on it.

> +#ifndef PCIBIOS_MIN_IO
> +#define PCIBIOS_MIN_IO		0
> +#endif
> +
> +#ifndef PCIBIOS_MIN_MEM
> +#define PCIBIOS_MIN_MEM		0
> +#endif
> +
> +#ifndef pcibios_assign_all_busses
> +/* For bootloaders that do not initialize the PCI bus */
> +#define pcibios_assign_all_busses() 1
> +#endif
> +
> +/* Enable generic resource mapping code in drivers/pci/ */
> +#define ARCH_GENERIC_PCI_MMAP_RESOURCE
> +
> +#ifdef CONFIG_PCI_DOMAINS
> +static inline int pci_proc_domain(struct pci_bus *bus)
> +{
> +	/* always show the domain in /proc */
> +	return 1;
> +}
> +#endif /* CONFIG_PCI_DOMAINS */
> +
> +#endif /* __ASM_GENERIC_PCI_H */
> -- 
> 2.36.1
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Stafford Horne July 21, 2022, 9:58 p.m. UTC | #2
On Thu, Jul 21, 2022 at 12:37:33PM -0500, Bjorn Helgaas wrote:
> On Thu, Jul 21, 2022 at 10:49:24PM +0900, Stafford Horne wrote:
> > The asm/pci.h used for many newer architectures share similar
> > definitions.  Move the common parts to asm-generic/pci.h to allow for
> > sharing code.
> > 
> > Suggested-by: Arnd Bergmann <arnd@arndb.de>
> > Link: https://lore.kernel.org/lkml/CAK8P3a0JmPeczfmMBE__vn=Jbvf=nkbpVaZCycyv40pZNCJJXQ@mail.gmail.com/
> > Acked-by: Pierre Morel <pmorel@linux.ibm.com>
> > Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
> > Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> > Signed-off-by: Stafford Horne <shorne@gmail.com>
> > ---
> > Since v4:
> >  - Add reviewed-by
> > 
> >  arch/arm64/include/asm/pci.h | 10 ++--------
> >  arch/csky/include/asm/pci.h  | 17 ++---------------
> >  arch/riscv/include/asm/pci.h | 23 ++++-------------------
> >  arch/um/include/asm/pci.h    | 14 ++------------
> >  include/asm-generic/pci.h    | 32 ++++++++++++++++++++++++++++++++
> >  5 files changed, 42 insertions(+), 54 deletions(-)
> >  create mode 100644 include/asm-generic/pci.h
> 
> > +++ b/include/asm-generic/pci.h
> > @@ -0,0 +1,32 @@
> > +/* SPDX-License-Identifier: GPL-2.0-only */
> > +
> > +#ifndef __ASM_GENERIC_PCI_H
> > +#define __ASM_GENERIC_PCI_H
> > +
> > +#include <linux/types.h>
> 
> Do we need <linux/types.h> here?  I don't see anything below that
> depends on it.

Thanks, you are right, I think some of the earlier functions may have needed it,
which is why I had it earlier.  But now that we have removed those we should be
able to remove this.

That said, I think some of the architecture includes could also be removed.  On
OpenRISC we are able to get away with only having the global asm-generic/pci.h
so we don't need a wrapper pci.h header at all.

However, I don't have everything setup to build all of those architectures so I
was being a bit conservative to remove headers.  I'll see what I can do in the
next version.

-Stafford

> > +#ifndef PCIBIOS_MIN_IO
> > +#define PCIBIOS_MIN_IO		0
> > +#endif
> > +
> > +#ifndef PCIBIOS_MIN_MEM
> > +#define PCIBIOS_MIN_MEM		0
> > +#endif
> > +
> > +#ifndef pcibios_assign_all_busses
> > +/* For bootloaders that do not initialize the PCI bus */
> > +#define pcibios_assign_all_busses() 1
> > +#endif
> > +
> > +/* Enable generic resource mapping code in drivers/pci/ */
> > +#define ARCH_GENERIC_PCI_MMAP_RESOURCE
> > +
> > +#ifdef CONFIG_PCI_DOMAINS
> > +static inline int pci_proc_domain(struct pci_bus *bus)
> > +{
> > +	/* always show the domain in /proc */
> > +	return 1;
> > +}
> > +#endif /* CONFIG_PCI_DOMAINS */
> > +
> > +#endif /* __ASM_GENERIC_PCI_H */
> > -- 
> > 2.36.1
> > 
> > 
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Arnd Bergmann July 22, 2022, 7:53 a.m. UTC | #3
On Thu, Jul 21, 2022 at 11:58 PM Stafford Horne <shorne@gmail.com> wrote:
> On Thu, Jul 21, 2022 at 12:37:33PM -0500, Bjorn Helgaas wrote:

>
> Thanks, you are right, I think some of the earlier functions may have needed it,
> which is why I had it earlier.  But now that we have removed those we should be
> able to remove this.
>
> That said, I think some of the architecture includes could also be removed.  On
> OpenRISC we are able to get away with only having the global asm-generic/pci.h
> so we don't need a wrapper pci.h header at all.
>
> However, I don't have everything setup to build all of those architectures so I
> was being a bit conservative to remove headers.  I'll see what I can do in the
> next version.

No need to worry about linux/types.h, this is pretty much included everywhere
already and neither the risk of extraneous includes or missing ones is
something to worry about. I'd just remove it if you do another respin, or
we can leave it in if Bjorn wants to just apply the v5 version.

       Arnd
Stafford Horne July 22, 2022, 9:43 p.m. UTC | #4
On Fri, Jul 22, 2022 at 09:53:07AM +0200, Arnd Bergmann wrote:
> On Thu, Jul 21, 2022 at 11:58 PM Stafford Horne <shorne@gmail.com> wrote:
> > On Thu, Jul 21, 2022 at 12:37:33PM -0500, Bjorn Helgaas wrote:
> 
> >
> > Thanks, you are right, I think some of the earlier functions may have needed it,
> > which is why I had it earlier.  But now that we have removed those we should be
> > able to remove this.
> >
> > That said, I think some of the architecture includes could also be removed.  On
> > OpenRISC we are able to get away with only having the global asm-generic/pci.h
> > so we don't need a wrapper pci.h header at all.
> >
> > However, I don't have everything setup to build all of those architectures so I
> > was being a bit conservative to remove headers.  I'll see what I can do in the
> > next version.
> 
> No need to worry about linux/types.h, this is pretty much included everywhere
> already and neither the risk of extraneous includes or missing ones is
> something to worry about. I'd just remove it if you do another respin, or
> we can leave it in if Bjorn wants to just apply the v5 version.

I will respin a v6 as we didn't get a reply on this.  Bjorn are you planning to
apply the series before the upcoming merge window?

Originally I was thinking to merge these with my OpenRISC PCI support patches as
OpenRISC depends on this.  However, the series is getting a bit more involved
for OpenRISC only.

Once you get it merged I will like to rebase my OpenRISC PCI support patches on
you branch.  Hopefully, we can make it by the merge window.

Also, Palmer has a conflict with the series and his RISC-V for-next branch.
He would like to have a tag or branch to be able to merge into is branch to
resolve the conflict.

-Stafford
Bjorn Helgaas July 22, 2022, 10:31 p.m. UTC | #5
On Sat, Jul 23, 2022 at 06:43:31AM +0900, Stafford Horne wrote:

> I will respin a v6 as we didn't get a reply on this.  Bjorn are you
> planning to apply the series before the upcoming merge window?

I see your v6, and I can apply it.  I only got patches 1, 2, 4
(without the csky patch).  Do you want that to go a separate route?  I
don't care either way, but not sure it improves things to split it
across trees.

Bjorn
Stafford Horne July 22, 2022, 10:56 p.m. UTC | #6
On Fri, Jul 22, 2022 at 05:31:46PM -0500, Bjorn Helgaas wrote:
> On Sat, Jul 23, 2022 at 06:43:31AM +0900, Stafford Horne wrote:
> 
> > I will respin a v6 as we didn't get a reply on this.  Bjorn are you
> > planning to apply the series before the upcoming merge window?
> 
> I see your v6, and I can apply it.  I only got patches 1, 2, 4
> (without the csky patch).  Do you want that to go a separate route?  I
> don't care either way, but not sure it improves things to split it
> across trees.

I sent 3/4 directly to you now.  Hopefully you see it.

Patch 4/4 depends on it in a sense so its best to keep 3/4 together.

-Stafford
Bjorn Helgaas July 22, 2022, 11:37 p.m. UTC | #7
On Sat, Jul 23, 2022 at 07:56:38AM +0900, Stafford Horne wrote:
> On Fri, Jul 22, 2022 at 05:31:46PM -0500, Bjorn Helgaas wrote:
> > On Sat, Jul 23, 2022 at 06:43:31AM +0900, Stafford Horne wrote:
> > 
> > > I will respin a v6 as we didn't get a reply on this.  Bjorn are you
> > > planning to apply the series before the upcoming merge window?
> > 
> > I see your v6, and I can apply it.  I only got patches 1, 2, 4
> > (without the csky patch).  Do you want that to go a separate route?  I
> > don't care either way, but not sure it improves things to split it
> > across trees.
> 
> I sent 3/4 directly to you now.  Hopefully you see it.
> 
> Patch 4/4 depends on it in a sense so its best to keep 3/4 together.

I saw 3/4 before because b4 found it, but I didn't know what you had
in mind.

I applied all 4 patches to pci/header-cleanup-immutable for v5.20.

It would be convenient if (in the future) you included a 0/n cover
letter where replies like this could go.

Bjorn
diff mbox series

Patch

diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h
index 682c922b5658..016eb6b46dc0 100644
--- a/arch/arm64/include/asm/pci.h
+++ b/arch/arm64/include/asm/pci.h
@@ -9,7 +9,6 @@ 
 #include <asm/io.h>
 
 #define PCIBIOS_MIN_IO		0x1000
-#define PCIBIOS_MIN_MEM		0
 
 /*
  * Set to 1 if the kernel should re-assign all PCI bus numbers
@@ -18,13 +17,8 @@ 
 	(pci_has_flag(PCI_REASSIGN_ALL_BUS))
 
 #define arch_can_pci_mmap_wc() 1
-#define ARCH_GENERIC_PCI_MMAP_RESOURCE	1
 
-#ifdef CONFIG_PCI
-static inline int pci_proc_domain(struct pci_bus *bus)
-{
-	return 1;
-}
-#endif  /* CONFIG_PCI */
+/* Generic PCI */
+#include <asm-generic/pci.h>
 
 #endif  /* __ASM_PCI_H */
diff --git a/arch/csky/include/asm/pci.h b/arch/csky/include/asm/pci.h
index 875bc028f8f6..42724c630d30 100644
--- a/arch/csky/include/asm/pci.h
+++ b/arch/csky/include/asm/pci.h
@@ -9,20 +9,7 @@ 
 
 #include <asm/io.h>
 
-#define PCIBIOS_MIN_IO		0
-#define PCIBIOS_MIN_MEM		0
-
-/* C-SKY shim does not initialize PCI bus */
-#define pcibios_assign_all_busses() 1
-
-#define ARCH_GENERIC_PCI_MMAP_RESOURCE	1
-
-#ifdef CONFIG_PCI
-static inline int pci_proc_domain(struct pci_bus *bus)
-{
-	/* always show the domain in /proc */
-	return 1;
-}
-#endif  /* CONFIG_PCI */
+/* Generic PCI */
+#include <asm-generic/pci.h>
 
 #endif  /* __ASM_CSKY_PCI_H */
diff --git a/arch/riscv/include/asm/pci.h b/arch/riscv/include/asm/pci.h
index f904df586c03..6ef4a1426194 100644
--- a/arch/riscv/include/asm/pci.h
+++ b/arch/riscv/include/asm/pci.h
@@ -12,23 +12,7 @@ 
 
 #include <asm/io.h>
 
-#define PCIBIOS_MIN_IO		0
-#define PCIBIOS_MIN_MEM		0
-
-/* RISC-V shim does not initialize PCI bus */
-#define pcibios_assign_all_busses() 1
-
-#define ARCH_GENERIC_PCI_MMAP_RESOURCE 1
-
-#ifdef CONFIG_PCI
-static inline int pci_proc_domain(struct pci_bus *bus)
-{
-	/* always show the domain in /proc */
-	return 1;
-}
-
-#ifdef	CONFIG_NUMA
-
+#if defined(CONFIG_PCI) && defined(CONFIG_NUMA)
 static inline int pcibus_to_node(struct pci_bus *bus)
 {
 	return dev_to_node(&bus->dev);
@@ -38,8 +22,9 @@  static inline int pcibus_to_node(struct pci_bus *bus)
 				 cpu_all_mask :				\
 				 cpumask_of_node(pcibus_to_node(bus)))
 #endif
-#endif	/* CONFIG_NUMA */
+#endif /* defined(CONFIG_PCI) && defined(CONFIG_NUMA) */
 
-#endif  /* CONFIG_PCI */
+/* Generic PCI */
+#include <asm-generic/pci.h>
 
 #endif  /* _ASM_RISCV_PCI_H */
diff --git a/arch/um/include/asm/pci.h b/arch/um/include/asm/pci.h
index 1211855aff34..34fe4921b5fa 100644
--- a/arch/um/include/asm/pci.h
+++ b/arch/um/include/asm/pci.h
@@ -4,18 +4,8 @@ 
 #include <linux/types.h>
 #include <asm/io.h>
 
-#define PCIBIOS_MIN_IO		0
-#define PCIBIOS_MIN_MEM		0
-
-#define pcibios_assign_all_busses() 1
-
-#ifdef CONFIG_PCI_DOMAINS
-static inline int pci_proc_domain(struct pci_bus *bus)
-{
-	/* always show the domain in /proc */
-	return 1;
-}
-#endif  /* CONFIG_PCI */
+/* Generic PCI */
+#include <asm-generic/pci.h>
 
 #ifdef CONFIG_PCI_MSI_IRQ_DOMAIN
 /*
diff --git a/include/asm-generic/pci.h b/include/asm-generic/pci.h
new file mode 100644
index 000000000000..3ceb0cb12321
--- /dev/null
+++ b/include/asm-generic/pci.h
@@ -0,0 +1,32 @@ 
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ASM_GENERIC_PCI_H
+#define __ASM_GENERIC_PCI_H
+
+#include <linux/types.h>
+
+#ifndef PCIBIOS_MIN_IO
+#define PCIBIOS_MIN_IO		0
+#endif
+
+#ifndef PCIBIOS_MIN_MEM
+#define PCIBIOS_MIN_MEM		0
+#endif
+
+#ifndef pcibios_assign_all_busses
+/* For bootloaders that do not initialize the PCI bus */
+#define pcibios_assign_all_busses() 1
+#endif
+
+/* Enable generic resource mapping code in drivers/pci/ */
+#define ARCH_GENERIC_PCI_MMAP_RESOURCE
+
+#ifdef CONFIG_PCI_DOMAINS
+static inline int pci_proc_domain(struct pci_bus *bus)
+{
+	/* always show the domain in /proc */
+	return 1;
+}
+#endif /* CONFIG_PCI_DOMAINS */
+
+#endif /* __ASM_GENERIC_PCI_H */