of/address: Drop ISA parts when !CONFIG_ISA
PATCH 1/1 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.
---
Sorry for the spam, somehow I botched sending a patch..
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 reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Wrapping the 'isa' OF bus translator in `#ifdef CONFIG_ISA` breaks I/O address translation for…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Wrapping the 'isa' OF bus translator in #ifdef CONFIG_ISA breaks I/O address translation for LPC/ISA bridges on architectures that do not enable CONFIG_ISA. --
commit 2b56de0432a2e0bc839872a80da8947f0a3d2b72
Author: Daniel Palmer <[email protected]>
of/address: Drop ISA parts when !CONFIG_ISA
This commit wraps the ISA-specific address translation code in of/address.c with #ifdef CONFIG_ISA. This is intended to reduce code and data size on configurations that do not enable CONFIG_ISA.
Quoted 4 lines
drivers/of/address.c +0
-0
[ ... ]
Quoted 8 lines
drivers/of/address.c +1
-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",
drivers/of/address.c
Quoted 9 lines
drivers/of/address.c +1
-0.addresses = "reg", .match = of_bus_isa_match, .count_cells = of_bus_isa_count_cells, .map = of_bus_isa_map, .translate = of_bus_default_flags_translate, .flag_cells = 1, .get_flags = of_bus_isa_get_flags, }, +#endif /* CONFIG_ISA */
[Severity: High]
Will this break I/O address translation for LPC/ISA bridges on architectures that do not enable CONFIG_ISA?
While the architecture itself might not have CONFIG_ISA enabled (such as ARM64, PowerPC, or MIPS), they often still use LPC bridges in their device trees for devices like RTC, UART, or IPMI nodes.
If this "isa" translator is completely disabled, the bus mapping will fall back to the "default" translator. The default translator will incorrectly parse these resources as IORESOURCE_MEM instead of IORESOURCE_IO.
Could this prevent drivers relying on I/O space access from probing or mapping resources correctly on those platforms?
Quoted 3 lines
drivers/of/address.c +0
-0/* Default with flags cell */ { .name = "default-flags",
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Hi Daniel, (Replying to myself..)
Quoted 7 lines · Daniel Palmer
The PCI parts are already wrapped in #ifdef
CONFIG_PCIso it seems sensible to add #ifdefCONFIG_ISAaround the ISA parts.This reduces the code/data size a bit on configs with !CONFIG_ISA.
Quoted 7 lines
Signed-off-by Daniel Palmer <[email protected]>---
Sorry for the spam, somehow I botched sending a patch..
I thought about making this RFC as I'm a bit unsure if machines that need this ISA stuff actually select
CONFIG_ISAor not.
So sashiko worked out what is going on here. A few machines have things connected via an LPC bus that is derived from ISA and needs the code to parse those nodes but those machines don't select CONFIG_ISA. There seem to be ~15 devicetrees in total that actually need it (1 in x86, 1 in arm64, a few in mips/loongson for loongson machines, and then a few in ppc).
I made a series that adds CONFIG_OF_ISA to enable this code, selects it in the places that needs it, and then does the original part of disabling the code if not needed. I will wait a bit before sending. The reason to do this is I am using devicetree to boot a machine with 4MB of RAM and a 7MHz CPU. Removing dead code/data like this helps.
Cheers!
Rob Herring
maintainerQuoted 25 lines · Daniel Palmer
Hi Daniel, (Replying to myself..)
Quoted 7 lines · Daniel Palmer
The PCI parts are already wrapped in #ifdef
CONFIG_PCIso it seems sensible to add #ifdefCONFIG_ISAaround the ISA parts.This reduces the code/data size a bit on configs with !CONFIG_ISA.
Quoted 7 lines
Signed-off-by Daniel Palmer <[email protected]>---
Sorry for the spam, somehow I botched sending a patch..
I thought about making this RFC as I'm a bit unsure if machines that need this ISA stuff actually select
CONFIG_ISAor not.So sashiko worked out what is going on here. A few machines have things connected via an LPC bus that is derived from ISA and needs the code to parse those nodes but those machines don't select
CONFIG_ISA. There seem to be ~15 devicetrees in total that actually need it (1 in x86, 1 in arm64, a few in mips/loongson for loongson machines, and then a few in ppc).
Quoted 5 lines
I made a series that adds
CONFIG_OF_ISAto enable this code, selects it in the places that needs it, and then does the original part of disabling the code if not needed. I will wait a bit before sending. The reason to do this is I am using devicetree to boot a machine with 4MB of RAM and a 7MHz CPU. Removing dead code/data like this helps.
I tend to not want more CONFIG_OF_foo options, but okay I guess.
Alternatively, maybe CONFIG_ISA should just be enabled with these drivers. Doesn't really look like there's actually much or any code for CONFIG_ISA. The biggest issue might be the option doesn't exist on arm64.
Rob
Hi Rob,
Quoted 6 lines · Rob Herring
Quoted 5 lines
I made a series that adds
CONFIG_OF_ISAto enable this code, selects it in the places that needs it, and then does the original part of disabling the code if not needed. I will wait a bit before sending. The reason to do this is I am using devicetree to boot a machine with 4MB of RAM and a 7MHz CPU. Removing dead code/data like this helps.
Quoted 6 lines
I tend to not want more
CONFIG_OF_foooptions, but okay I guess.Alternatively, maybe
CONFIG_ISAshould just be enabled with these drivers. Doesn't really look like there's actually much or any code forCONFIG_ISA. The biggest issue might be the option doesn't exist on arm64.
I guess I'll try sending a patch for arm64 to add CONFIG_ISA and select it for the drivers that need the ISA bits in address.c
Thanks,
Daniel