* [PATCH v3] powerpc/pci: Add option for using pci_to_OF_bus_map
@ 2023-02-06 11:39 Michael Ellerman
2023-02-06 22:48 ` Pali Rohár
2023-02-15 12:40 ` Michael Ellerman
0 siblings, 2 replies; 3+ messages in thread
From: Michael Ellerman @ 2023-02-06 11:39 UTC (permalink / raw)
To: linuxppc-dev; +Cc: pali
From: Pali Rohár <pali@kernel.org>
The "pci-OF-bus-map" property was declared deprecated in 2006 [1] and to
the best of everyone's knowledge is not used by anything anymore [2].
The creation of the property was disabled on powermac (arch/powerpc) in
2005 by commit 35499c0195e4 ("powerpc: Merge in 64-bit powermac
support."). But it is still created by default on CHRP.
On powermac the actual map (pci_to_OF_bus_map) is still used by default,
even though the device tree property is not created.
Add an option to enable/disable use of the pci_to_OF_bus_map, and
creation of the property (on CHRP).
Disabling the option allows enabling CONFIG_PPC_PCI_BUS_NUM_DOMAIN_DEPENDENT
which allows "normal" bus numbering and more than 256 buses, like 64-bit
and other architectures.
Mark the new option as default n, the intention is that the option and
the code will be removed in a future release.
[1]: https://lore.kernel.org/linuxppc-dev/1148016268.13249.14.camel@localhost.localdomain/
[2]: https://lore.kernel.org/all/575f239205e8635add81c9f902b7d9db7beb83ea.camel@kernel.crashing.org/
Signed-off-by: Pali Rohár <pali@kernel.org>
[mpe: Reword commit & help text, shrink option name, rework to fix build errors]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/Kconfig | 13 ++++++++++++-
arch/powerpc/include/asm/pci-bridge.h | 4 +++-
arch/powerpc/kernel/pci_32.c | 17 ++++++++++++-----
3 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index fad25aa602c8..7dcb011cebf2 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -388,9 +388,20 @@ config PPC_DCR
depends on PPC_DCR_NATIVE || PPC_DCR_MMIO
default y
+config PPC_PCI_OF_BUS_MAP
+ bool "Use pci_to_OF_bus_map (deprecated)"
+ depends on PPC32
+ depends on PPC_PMAC || PPC_CHRP
+ help
+ This option uses pci_to_OF_bus_map to map OF nodes to PCI devices, which
+ restricts the system to only having 256 PCI buses. On CHRP it also causes
+ the "pci-OF-bus-map" property to be created in the device tree.
+
+ If unsure, say "N".
+
config PPC_PCI_BUS_NUM_DOMAIN_DEPENDENT
depends on PPC32
- depends on !PPC_PMAC && !PPC_CHRP
+ depends on !PPC_PCI_OF_BUS_MAP
bool "Assign PCI bus numbers from zero individually for each PCI domain"
default y
help
diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index e18c95f4e1d4..71c1d26f2400 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -176,8 +176,10 @@ extern int pci_device_from_OF_node(struct device_node *node,
#endif
#ifndef CONFIG_PPC64
-#ifdef CONFIG_PPC_CHRP
+#ifdef CONFIG_PPC_PCI_OF_BUS_MAP
extern void pci_create_OF_bus_map(void);
+#else
+static inline void pci_create_OF_bus_map(void) {}
#endif
#else /* CONFIG_PPC64 */
diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
index 855b59892c5c..ce0c8623e563 100644
--- a/arch/powerpc/kernel/pci_32.c
+++ b/arch/powerpc/kernel/pci_32.c
@@ -62,7 +62,7 @@ fixup_cpc710_pci64(struct pci_dev* dev)
}
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CPC710_PCI64, fixup_cpc710_pci64);
-#if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_CHRP)
+#ifdef CONFIG_PPC_PCI_OF_BUS_MAP
static u8* pci_to_OF_bus_map;
static int pci_bus_count;
@@ -152,6 +152,7 @@ pcibios_make_OF_bus_map(void)
}
#endif
}
+#endif // CONFIG_PPC_PCI_OF_BUS_MAP
#ifdef CONFIG_PPC_PMAC
@@ -160,7 +161,9 @@ pcibios_make_OF_bus_map(void)
*/
int pci_device_from_OF_node(struct device_node *node, u8 *bus, u8 *devfn)
{
+#ifdef CONFIG_PPC_PCI_OF_BUS_MAP
struct pci_dev *dev = NULL;
+#endif
const __be32 *reg;
int size;
@@ -175,6 +178,9 @@ int pci_device_from_OF_node(struct device_node *node, u8 *bus, u8 *devfn)
*bus = (be32_to_cpup(®[0]) >> 16) & 0xff;
*devfn = (be32_to_cpup(®[0]) >> 8) & 0xff;
+#ifndef CONFIG_PPC_PCI_OF_BUS_MAP
+ return 0;
+#else
/* Ok, here we need some tweak. If we have already renumbered
* all busses, we can't rely on the OF bus number any more.
* the pci_to_OF_bus_map is not enough as several PCI busses
@@ -192,11 +198,12 @@ int pci_device_from_OF_node(struct device_node *node, u8 *bus, u8 *devfn)
}
return -ENODEV;
+#endif // CONFIG_PPC_PCI_OF_BUS_MAP
}
EXPORT_SYMBOL(pci_device_from_OF_node);
#endif
-#ifdef CONFIG_PPC_CHRP
+#ifdef CONFIG_PPC_PCI_OF_BUS_MAP
/* We create the "pci-OF-bus-map" property now so it appears in the
* /proc device tree
*/
@@ -221,9 +228,7 @@ pci_create_OF_bus_map(void)
of_node_put(dn);
}
}
-#endif
-
-#endif /* defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_CHRP) */
+#endif // CONFIG_PPC_PCI_OF_BUS_MAP
void pcibios_setup_phb_io_space(struct pci_controller *hose)
{
@@ -273,6 +278,7 @@ static int __init pcibios_init(void)
}
#if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_CHRP)
+#ifdef CONFIG_PPC_PCI_OF_BUS_MAP
pci_bus_count = next_busno;
/* OpenFirmware based machines need a map of OF bus
@@ -281,6 +287,7 @@ static int __init pcibios_init(void)
*/
if (pci_assign_all_buses)
pcibios_make_OF_bus_map();
+#endif
#endif
/* Call common code to handle resource allocation */
--
2.39.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] powerpc/pci: Add option for using pci_to_OF_bus_map
2023-02-06 11:39 [PATCH v3] powerpc/pci: Add option for using pci_to_OF_bus_map Michael Ellerman
@ 2023-02-06 22:48 ` Pali Rohár
2023-02-15 12:40 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Pali Rohár @ 2023-02-06 22:48 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
On Monday 06 February 2023 22:39:02 Michael Ellerman wrote:
> From: Pali Rohár <pali@kernel.org>
>
> The "pci-OF-bus-map" property was declared deprecated in 2006 [1] and to
> the best of everyone's knowledge is not used by anything anymore [2].
>
> The creation of the property was disabled on powermac (arch/powerpc) in
> 2005 by commit 35499c0195e4 ("powerpc: Merge in 64-bit powermac
> support."). But it is still created by default on CHRP.
>
> On powermac the actual map (pci_to_OF_bus_map) is still used by default,
> even though the device tree property is not created.
>
> Add an option to enable/disable use of the pci_to_OF_bus_map, and
> creation of the property (on CHRP).
>
> Disabling the option allows enabling CONFIG_PPC_PCI_BUS_NUM_DOMAIN_DEPENDENT
> which allows "normal" bus numbering and more than 256 buses, like 64-bit
> and other architectures.
>
> Mark the new option as default n, the intention is that the option and
> the code will be removed in a future release.
>
> [1]: https://lore.kernel.org/linuxppc-dev/1148016268.13249.14.camel@localhost.localdomain/
> [2]: https://lore.kernel.org/all/575f239205e8635add81c9f902b7d9db7beb83ea.camel@kernel.crashing.org/
>
> Signed-off-by: Pali Rohár <pali@kernel.org>
> [mpe: Reword commit & help text, shrink option name, rework to fix build errors]
Thank you for this!
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
> arch/powerpc/Kconfig | 13 ++++++++++++-
> arch/powerpc/include/asm/pci-bridge.h | 4 +++-
> arch/powerpc/kernel/pci_32.c | 17 ++++++++++++-----
> 3 files changed, 27 insertions(+), 7 deletions(-)
>
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index fad25aa602c8..7dcb011cebf2 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -388,9 +388,20 @@ config PPC_DCR
> depends on PPC_DCR_NATIVE || PPC_DCR_MMIO
> default y
>
> +config PPC_PCI_OF_BUS_MAP
> + bool "Use pci_to_OF_bus_map (deprecated)"
> + depends on PPC32
> + depends on PPC_PMAC || PPC_CHRP
> + help
> + This option uses pci_to_OF_bus_map to map OF nodes to PCI devices, which
> + restricts the system to only having 256 PCI buses. On CHRP it also causes
> + the "pci-OF-bus-map" property to be created in the device tree.
> +
> + If unsure, say "N".
> +
> config PPC_PCI_BUS_NUM_DOMAIN_DEPENDENT
> depends on PPC32
> - depends on !PPC_PMAC && !PPC_CHRP
> + depends on !PPC_PCI_OF_BUS_MAP
> bool "Assign PCI bus numbers from zero individually for each PCI domain"
> default y
> help
> diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
> index e18c95f4e1d4..71c1d26f2400 100644
> --- a/arch/powerpc/include/asm/pci-bridge.h
> +++ b/arch/powerpc/include/asm/pci-bridge.h
> @@ -176,8 +176,10 @@ extern int pci_device_from_OF_node(struct device_node *node,
> #endif
> #ifndef CONFIG_PPC64
>
> -#ifdef CONFIG_PPC_CHRP
> +#ifdef CONFIG_PPC_PCI_OF_BUS_MAP
> extern void pci_create_OF_bus_map(void);
> +#else
> +static inline void pci_create_OF_bus_map(void) {}
> #endif
>
> #else /* CONFIG_PPC64 */
> diff --git a/arch/powerpc/kernel/pci_32.c b/arch/powerpc/kernel/pci_32.c
> index 855b59892c5c..ce0c8623e563 100644
> --- a/arch/powerpc/kernel/pci_32.c
> +++ b/arch/powerpc/kernel/pci_32.c
> @@ -62,7 +62,7 @@ fixup_cpc710_pci64(struct pci_dev* dev)
> }
> DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CPC710_PCI64, fixup_cpc710_pci64);
>
> -#if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_CHRP)
> +#ifdef CONFIG_PPC_PCI_OF_BUS_MAP
>
> static u8* pci_to_OF_bus_map;
> static int pci_bus_count;
> @@ -152,6 +152,7 @@ pcibios_make_OF_bus_map(void)
> }
> #endif
> }
> +#endif // CONFIG_PPC_PCI_OF_BUS_MAP
>
>
> #ifdef CONFIG_PPC_PMAC
> @@ -160,7 +161,9 @@ pcibios_make_OF_bus_map(void)
> */
> int pci_device_from_OF_node(struct device_node *node, u8 *bus, u8 *devfn)
> {
> +#ifdef CONFIG_PPC_PCI_OF_BUS_MAP
> struct pci_dev *dev = NULL;
> +#endif
> const __be32 *reg;
> int size;
>
> @@ -175,6 +178,9 @@ int pci_device_from_OF_node(struct device_node *node, u8 *bus, u8 *devfn)
> *bus = (be32_to_cpup(®[0]) >> 16) & 0xff;
> *devfn = (be32_to_cpup(®[0]) >> 8) & 0xff;
>
> +#ifndef CONFIG_PPC_PCI_OF_BUS_MAP
> + return 0;
> +#else
> /* Ok, here we need some tweak. If we have already renumbered
> * all busses, we can't rely on the OF bus number any more.
> * the pci_to_OF_bus_map is not enough as several PCI busses
> @@ -192,11 +198,12 @@ int pci_device_from_OF_node(struct device_node *node, u8 *bus, u8 *devfn)
> }
>
> return -ENODEV;
> +#endif // CONFIG_PPC_PCI_OF_BUS_MAP
> }
> EXPORT_SYMBOL(pci_device_from_OF_node);
> #endif
>
> -#ifdef CONFIG_PPC_CHRP
> +#ifdef CONFIG_PPC_PCI_OF_BUS_MAP
> /* We create the "pci-OF-bus-map" property now so it appears in the
> * /proc device tree
> */
> @@ -221,9 +228,7 @@ pci_create_OF_bus_map(void)
> of_node_put(dn);
> }
> }
> -#endif
> -
> -#endif /* defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_CHRP) */
> +#endif // CONFIG_PPC_PCI_OF_BUS_MAP
>
> void pcibios_setup_phb_io_space(struct pci_controller *hose)
> {
> @@ -273,6 +278,7 @@ static int __init pcibios_init(void)
> }
>
> #if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_CHRP)
> +#ifdef CONFIG_PPC_PCI_OF_BUS_MAP
> pci_bus_count = next_busno;
>
> /* OpenFirmware based machines need a map of OF bus
> @@ -281,6 +287,7 @@ static int __init pcibios_init(void)
> */
> if (pci_assign_all_buses)
> pcibios_make_OF_bus_map();
> +#endif
> #endif
>
> /* Call common code to handle resource allocation */
> --
> 2.39.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] powerpc/pci: Add option for using pci_to_OF_bus_map
2023-02-06 11:39 [PATCH v3] powerpc/pci: Add option for using pci_to_OF_bus_map Michael Ellerman
2023-02-06 22:48 ` Pali Rohár
@ 2023-02-15 12:40 ` Michael Ellerman
1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2023-02-15 12:40 UTC (permalink / raw)
To: linuxppc-dev, Michael Ellerman; +Cc: pali
On Mon, 6 Feb 2023 22:39:02 +1100, Michael Ellerman wrote:
> From: Pali Rohár <pali@kernel.org>
>
> The "pci-OF-bus-map" property was declared deprecated in 2006 [1] and to
> the best of everyone's knowledge is not used by anything anymore [2].
>
> The creation of the property was disabled on powermac (arch/powerpc) in
> 2005 by commit 35499c0195e4 ("powerpc: Merge in 64-bit powermac
> support."). But it is still created by default on CHRP.
>
> [...]
Applied to powerpc/next.
[1/1] powerpc/pci: Add option for using pci_to_OF_bus_map
https://git.kernel.org/powerpc/c/5d2eb73aa0fd57844938a22bddc59f7bc8183924
cheers
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-15 12:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-06 11:39 [PATCH v3] powerpc/pci: Add option for using pci_to_OF_bus_map Michael Ellerman
2023-02-06 22:48 ` Pali Rohár
2023-02-15 12:40 ` Michael Ellerman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.