From 1a75d7c1077cf785b479cb975e42e09fff2839cd Mon Sep 17 00:00:00 2001
From: Daniel Palmer <[email protected]>
Date: Fri, 18 Apr 2025 18:28:26 +0900
Subject: [PATCH] of/address: Drop ISA parts when !CONFIG_ISA
The PCI parts are already wrapped in #ifdef CONFIG_PCI so it seems sensible to add #ifdef CONFIG_ISA around the ISA parts.
This reduces the code/data size a bit on configs with !CONFIG_ISA.
---
I thought about making this RFC as I'm a bit unsure if machines that need this ISA stuff actually select CONFIG_ISA or not.
The only in-kernel devicetrees that seem to use this are 4 old powerpc ones and I couldn't work out if those boards do end up with CONFIG_ISA.
But then again it seems odd for everyone to get this code for 4 old boards.
drivers/of/address.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/of/address.c +4 -0
@@ -277,6 +277,7 @@ int of_range_to_resource(struct device_node *np, int index, struct resource *res }EXPORT_SYMBOL (of_range_to_resource); +#ifdef CONFIG_ISA /* * ISA bus specific translator */
@@ -316,6 +317,7 @@ static unsigned int of_bus_isa_get_flags(const __be32 *addr) flags |=IORESOURCE_MEM ; return flags; } +#endif static int of_bus_default_flags_match (struct device_node *np) {
@@ -349,6 +351,7 @@ static const struct of_bus of_busses[] = { .get_flags = of_bus_pci_get_flags, },#endif /* CONFIG_PCI */ +#ifdef CONFIG_ISA /* ISA */ { .name = "isa",
@@ -360,6 +363,7 @@ static const struct of_bus of_busses[] = { .flag_cells = 1, .get_flags = of_bus_isa_get_flags, }, +#endif /* CONFIG_ISA */ /* Default with flags cell */ { .name = "default-flags",
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: (no subject)
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Conditionally compiling the OF 'isa' bus translator based on `CONFIG_ISA` breaks device tree…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Conditionally compiling the OF 'isa' bus translator based on CONFIG_ISA breaks device tree address translation for non-ISA architectures (e.g., ARM64) that use 'isa' nodes for LPC or legacy I/O bridges. --
commit 3f535ae9ca6c863a12c1d6dbcfcb4358a6f6ed4b
Author: Daniel Palmer <[email protected]>
of/address: Drop ISA parts when !CONFIG_ISA
This patch conditionally compiles the ISA parts of the Open Firmware address translator based on CONFIG_ISA to reduce code size.
Quoted 4 lines
drivers/of/address.c +0
-0
[ ... ]
drivers/of/address.c static const struct of_bus of_busses[] = { · line 366
Quoted 13 lines
drivers/of/address.c +2
-0@@ -349,6 +351,7 @@ static const struct of_bus of_busses[] = { .get_flags = of_bus_pci_get_flags, },#endif /* CONFIG_PCI */ +#ifdef CONFIG_ISA /* ISA */ { .name = "isa",@@ -360,6 +363,7 @@ static const struct of_bus of_busses[] = { .flag_cells = 1, .get_flags = of_bus_isa_get_flags, }, +#endif /* CONFIG_ISA */
[Severity: High]
Does this break device tree address translation for non-ISA architectures (like ARM64) that use 'isa' nodes for LPC or legacy I/O bridges?
Platforms like Hisilicon hip06/hip07 don't have CONFIG_ISA defined but still use 'isa' nodes. If this bus entry is compiled out, they will fall back to the 'default' OF bus translator.
The 'default' bus translator's get_flags method (of_bus_default_get_flags) unconditionally returns IORESOURCE_MEM. This causes __of_address_to_resource() to misclassify the I/O port and call of_translate_address() instead of of_translate_ioport().
Because Hisilicon LPC registers an indirect I/O host, of_translate_address() then fails with OF_BAD_ADDR (-EINVAL), causing probe failures for devices like UART and IPMI.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1