public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] of/platform: Don't include reserved memory compatibles that aren't needed
@ 2026-03-31 21:57 Daniel Palmer
  2026-04-01 10:54 ` Krzysztof Kozlowski
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Palmer @ 2026-03-31 21:57 UTC (permalink / raw)
  To: robh, saravanak; +Cc: devicetree, linux-kernel, Daniel Palmer

There are a number of very platform specific compatibles for reserved
memory that the vast majority of people don't need and they waste
196/200 bytes each.

Wrap the platform specific compatibles so that they are only included
if needed.

Signed-off-by: Daniel Palmer <daniel@thingy.jp>
---
 drivers/of/platform.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index ba591fbceb56..0e6c2844e542 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -489,12 +489,22 @@ EXPORT_SYMBOL_GPL(of_platform_default_populate);
 
 static const struct of_device_id reserved_mem_matches[] = {
 	{ .compatible = "phram" },
+#if IS_ENABLED(CONFIG_QCOM_RMTFS_MEM)
 	{ .compatible = "qcom,rmtfs-mem" },
+#endif
+#if IS_ENABLED(CONFIG_QCOM_COMMAND_DB)
 	{ .compatible = "qcom,cmd-db" },
+#endif
+#if IS_ENABLED(CONFIG_QCOM_SMEM)
 	{ .compatible = "qcom,smem" },
+#endif
 	{ .compatible = "ramoops" },
+#if IS_ENABLED(CONFIG_NVMEM_RMEM)
 	{ .compatible = "nvmem-rmem" },
+#endif
+#if IS_ENABLED(CONFIG_OPEN_DICE)
 	{ .compatible = "google,open-dice" },
+#endif
 	{}
 };
 
-- 
2.51.0


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

* Re: [PATCH] of/platform: Don't include reserved memory compatibles that aren't needed
  2026-03-31 21:57 [PATCH] of/platform: Don't include reserved memory compatibles that aren't needed Daniel Palmer
@ 2026-04-01 10:54 ` Krzysztof Kozlowski
  2026-04-04  2:22   ` Daniel Palmer
  0 siblings, 1 reply; 3+ messages in thread
From: Krzysztof Kozlowski @ 2026-04-01 10:54 UTC (permalink / raw)
  To: Daniel Palmer; +Cc: robh, saravanak, devicetree, linux-kernel

On Wed, Apr 01, 2026 at 06:57:35AM +0900, Daniel Palmer wrote:
> There are a number of very platform specific compatibles for reserved
> memory that the vast majority of people don't need and they waste
> 196/200 bytes each.

We don't want #ifdefs in the code because they are more difficult to
maintain and review. Following your approach we would need to add such
ifdefs in multiple other places, so I am not convinced it is worth.

And this file should not be having different rules than rest of drivers.

Best regards,
Krzysztof


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

* Re: [PATCH] of/platform: Don't include reserved memory compatibles that aren't needed
  2026-04-01 10:54 ` Krzysztof Kozlowski
@ 2026-04-04  2:22   ` Daniel Palmer
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Palmer @ 2026-04-04  2:22 UTC (permalink / raw)
  To: Krzysztof Kozlowski; +Cc: robh, saravanak, devicetree, linux-kernel

Hi Krzysztof,

On Wed, 1 Apr 2026 at 19:54, Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On Wed, Apr 01, 2026 at 06:57:35AM +0900, Daniel Palmer wrote:
> > There are a number of very platform specific compatibles for reserved
> > memory that the vast majority of people don't need and they waste
> > 196/200 bytes each.
>
> We don't want #ifdefs in the code because they are more difficult to
> maintain and review. Following your approach we would need to add such
> ifdefs in multiple other places, so I am not convinced it is worth.

I sort of disagree here. At the moment these compatibles are not
coupled to the code that uses them at all.
If that code gets deleted or moved for some reason, the Kconfig symbol
they belong to will disappear but since these compatibles aren't
coupled to them and are in a file on the other side of the kernel
it'll be easy to miss them.
If they are wrapped in something that links them back to where they
are used grep or whatever indexer can spot them.

> And this file should not be having different rules than rest of drivers.

There are other places with #ifdefs in match tables. It would be nice
if there was a nicer way to do it in C but there doesn't seem to be.
It would be nice if vendor specific stuff wasn't in the core code but
I don't see a nice way of fixing that either.
And if you want to see some of the more crazy examples of match tables
take a look here:
https://elixir.bootlin.com/linux/v7.0-rc6/source/drivers/cpufreq/cpufreq-dt-platdev.c

Since these matches are not the size of the compatible string but
actually 200 bytes on 64 bit machines the two megatables in that
driver will consume about 40K. It doesn't seem like much but DT is
being used by systems that have megabytes of RAM like a RISC-V
softcore on an FPGA. I think they might prefer to have a 40K of usable
memory over 40K of tables that don't contain any values that are
actually used on their machine ever... and it could be cleaned up
easily by wrapping each of the vendor specific chunks in the Kconfig
symbol for their platform.

Cheers,

Daniel

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

end of thread, other threads:[~2026-04-04  2:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31 21:57 [PATCH] of/platform: Don't include reserved memory compatibles that aren't needed Daniel Palmer
2026-04-01 10:54 ` Krzysztof Kozlowski
2026-04-04  2:22   ` Daniel Palmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox