[RFC PATCH] imx: skip unused compatible strings in drivers

Converting to DM increases binary size and breaks building some boards (i.e. tbs2910, gcc 9.2). The approach to address this issue via cutting off unused properties/nodes in device tree via custom u-boot.dtsi was not welcome, even if the affected boards do not pass the built-in device tree to the kernel. Try to drop not required compatible strings in drivers when building for different iMX variants. This saves a few bytes when building for i.MX6, with current buildman default GCC 9.2:
all -843.0 bss +8.0 data -40.0 rodata -547.0 text -264.0
Signed-off-by: Anatolij Gustschin agust@denx.de Cc: Heiko Schocher hs@denx.de Cc: Peng Fan peng.fan@nxp.com Cc: Joe Hershberger joe.hershberger@ni.com Cc: Lukasz Majewski lukma@denx.de Cc: Marek Vasut marex@denx.de Cc: Stefano Babic sbabic@denx.de --- drivers/i2c/mxc_i2c.c | 3 +++ drivers/mmc/fsl_esdhc_imx.c | 18 ++++++++++++++++++ drivers/net/fec_mxc.c | 16 ++++++++++++++++ drivers/pinctrl/nxp/pinctrl-imx6.c | 14 ++++++++++++++ drivers/serial/serial_mxc.c | 10 ++++++++++ 5 files changed, 61 insertions(+)
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index 3b0d27e6cd..abef9d888e 100644 --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -1058,7 +1058,10 @@ static const struct dm_i2c_ops mxc_i2c_ops = {
static const struct udevice_id mxc_i2c_ids[] = { { .compatible = "fsl,imx21-i2c", }, +#if defined(CONFIG_VF610) || defined(CONFIG_FSL_LSCH2) || \ + defined(CONFIG_FSL_LSCH3) || defined(CONFIG_ARCH_LS1021A) { .compatible = "fsl,vf610-i2c", .data = I2C_QUIRK_FLAG, }, +#endif {} };
diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c index 588d6a9d76..6943e4867e 100644 --- a/drivers/mmc/fsl_esdhc_imx.c +++ b/drivers/mmc/fsl_esdhc_imx.c @@ -1601,31 +1601,49 @@ static const struct dm_mmc_ops fsl_esdhc_ops = { }; #endif
+#if defined(CONFIG_ARCH_MX7) static struct esdhc_soc_data usdhc_imx7d_data = { .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 | ESDHC_FLAG_HS400, }; +#endif
+#if defined(CONFIG_ARCH_IMX8) || defined(CONFIG_ARCH_IMX8M) static struct esdhc_soc_data usdhc_imx8qm_data = { .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 | ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES, }; +#endif
static const struct udevice_id fsl_esdhc_ids[] = { +#ifdef CONFIG_ARCH_MX5 { .compatible = "fsl,imx53-esdhc", }, +#endif +#ifdef CONFIG_ARCH_MX6 { .compatible = "fsl,imx6ul-usdhc", }, { .compatible = "fsl,imx6sx-usdhc", }, { .compatible = "fsl,imx6sl-usdhc", }, { .compatible = "fsl,imx6q-usdhc", }, +#endif +#ifdef CONFIG_ARCH_MX7 { .compatible = "fsl,imx7d-usdhc", .data = (ulong)&usdhc_imx7d_data,}, +#endif +#ifdef CONFIG_ARCH_MX7ULP { .compatible = "fsl,imx7ulp-usdhc", }, +#endif +#ifdef CONFIG_ARCH_IMX8 { .compatible = "fsl,imx8qm-usdhc", .data = (ulong)&usdhc_imx8qm_data,}, +#endif +#ifdef CONFIG_ARCH_IMX8M { .compatible = "fsl,imx8mm-usdhc", .data = (ulong)&usdhc_imx8qm_data,}, { .compatible = "fsl,imx8mn-usdhc", .data = (ulong)&usdhc_imx8qm_data,}, { .compatible = "fsl,imx8mq-usdhc", .data = (ulong)&usdhc_imx8qm_data,}, +#endif +#ifdef CONFIG_ARCH_IMXRT { .compatible = "fsl,imxrt-usdhc", }, +#endif { .compatible = "fsl,esdhc", }, { /* sentinel */ } }; diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 9ae2db033e..d829b5b5ba 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -1574,14 +1574,30 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev) }
static const struct udevice_id fecmxc_ids[] = { +#ifdef CONFIG_ARCH_MX28 { .compatible = "fsl,imx28-fec" }, +#endif +#ifdef CONFIG_ARCH_MX6 { .compatible = "fsl,imx6q-fec" }, +#endif +#ifdef CONFIG_MX6SL { .compatible = "fsl,imx6sl-fec" }, +#endif +#ifdef CONFIG_MX6SX { .compatible = "fsl,imx6sx-fec" }, +#endif +#ifdef CONFIG_MX6UL { .compatible = "fsl,imx6ul-fec" }, +#endif +#ifdef CONFIG_ARCH_MX5 { .compatible = "fsl,imx53-fec" }, +#endif +#ifdef CONFIG_ARCH_MX7 { .compatible = "fsl,imx7d-fec" }, +#endif +#ifdef CONFIG_ARCH_VF610 { .compatible = "fsl,mvf600-fec" }, +#endif { } };
diff --git a/drivers/pinctrl/nxp/pinctrl-imx6.c b/drivers/pinctrl/nxp/pinctrl-imx6.c index aafa3057ad..dff4954344 100644 --- a/drivers/pinctrl/nxp/pinctrl-imx6.c +++ b/drivers/pinctrl/nxp/pinctrl-imx6.c @@ -12,14 +12,18 @@
static struct imx_pinctrl_soc_info imx6_pinctrl_soc_info __section(".data");
+#ifdef CONFIG_MX6UL /* FIXME Before reloaction, BSS is overlapped with DT area */ static struct imx_pinctrl_soc_info imx6ul_pinctrl_soc_info = { .flags = ZERO_OFFSET_VALID, }; +#endif
+#if defined(CONFIG_MX6SLL) || defined(CONFIG_MX6ULL) static struct imx_pinctrl_soc_info imx6_snvs_pinctrl_soc_info = { .flags = ZERO_OFFSET_VALID, }; +#endif
static int imx6_pinctrl_probe(struct udevice *dev) { @@ -32,12 +36,22 @@ static int imx6_pinctrl_probe(struct udevice *dev) static const struct udevice_id imx6_pinctrl_match[] = { { .compatible = "fsl,imx6q-iomuxc", .data = (ulong)&imx6_pinctrl_soc_info }, { .compatible = "fsl,imx6dl-iomuxc", .data = (ulong)&imx6_pinctrl_soc_info }, +#ifdef CONFIG_MX6SL { .compatible = "fsl,imx6sl-iomuxc", .data = (ulong)&imx6_pinctrl_soc_info }, +#endif +#ifdef CONFIG_MX6SLL { .compatible = "fsl,imx6sll-iomuxc-snvs", .data = (ulong)&imx6_snvs_pinctrl_soc_info }, { .compatible = "fsl,imx6sll-iomuxc", .data = (ulong)&imx6_pinctrl_soc_info }, +#endif +#ifdef CONFIG_MX6SX { .compatible = "fsl,imx6sx-iomuxc", .data = (ulong)&imx6_pinctrl_soc_info }, +#endif +#ifdef CONFIG_MX6UL { .compatible = "fsl,imx6ul-iomuxc", .data = (ulong)&imx6ul_pinctrl_soc_info }, +#endif +#ifdef CONFIG_MX6ULL { .compatible = "fsl,imx6ull-iomuxc-snvs", .data = (ulong)&imx6_snvs_pinctrl_soc_info }, +#endif { /* sentinel */ } };
diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c index 42abb96a26..f4a0d56e09 100644 --- a/drivers/serial/serial_mxc.c +++ b/drivers/serial/serial_mxc.c @@ -343,11 +343,21 @@ static int mxc_serial_ofdata_to_platdata(struct udevice *dev)
static const struct udevice_id mxc_serial_ids[] = { { .compatible = "fsl,imx21-uart" }, +#ifdef CONFIG_ARCH_MX5 { .compatible = "fsl,imx53-uart" }, +#endif +#ifdef CONFIG_ARCH_MX6SX { .compatible = "fsl,imx6sx-uart" }, +#endif +#if defined(CONFIG_ARCH_MX6UL) || defined(CONFIG_ARCH_MX6ULL) { .compatible = "fsl,imx6ul-uart" }, +#endif +#ifdef CONFIG_ARCH_MX7 { .compatible = "fsl,imx7d-uart" }, +#endif +#if defined(CONFIG_ARCH_MX6) || defined(CONFIG_ARCH_MX6SL) || defined(CONFIG_ARCH_MX6SLL) { .compatible = "fsl,imx6q-uart" }, +#endif { } }; #endif

On 25.05.20 22:24, Anatolij Gustschin wrote:
Converting to DM increases binary size and breaks building some boards (i.e. tbs2910, gcc 9.2). The approach to address this issue via cutting off unused properties/nodes in device tree via custom u-boot.dtsi was not welcome, even if the affected boards do not pass the built-in device tree to the kernel.
But there is CONFIG_OF_REMOVE_PROPS="dmas dma-names interrupt-parent interrupts interrupts-extended interrupt-names interrupt-map interrupt-map-mask" in tbs2910_defconfig. So removing properties is already done via this config option. Removing nodes is not implemented (yet? AFAIK). But would be welcome if someone implements this in a similar way, I think.
Soeren
Try to drop not required compatible strings in drivers when building for different iMX variants. This saves a few bytes when building for i.MX6, with current buildman default GCC 9.2:
all -843.0 bss +8.0 data -40.0 rodata -547.0 text -264.0
Signed-off-by: Anatolij Gustschin agust@denx.de Cc: Heiko Schocher hs@denx.de Cc: Peng Fan peng.fan@nxp.com Cc: Joe Hershberger joe.hershberger@ni.com Cc: Lukasz Majewski lukma@denx.de Cc: Marek Vasut marex@denx.de Cc: Stefano Babic sbabic@denx.de
drivers/i2c/mxc_i2c.c | 3 +++ drivers/mmc/fsl_esdhc_imx.c | 18 ++++++++++++++++++ drivers/net/fec_mxc.c | 16 ++++++++++++++++ drivers/pinctrl/nxp/pinctrl-imx6.c | 14 ++++++++++++++ drivers/serial/serial_mxc.c | 10 ++++++++++ 5 files changed, 61 insertions(+)
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index 3b0d27e6cd..abef9d888e 100644 --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -1058,7 +1058,10 @@ static const struct dm_i2c_ops mxc_i2c_ops = {
static const struct udevice_id mxc_i2c_ids[] = { { .compatible = "fsl,imx21-i2c", }, +#if defined(CONFIG_VF610) || defined(CONFIG_FSL_LSCH2) || \
- defined(CONFIG_FSL_LSCH3) || defined(CONFIG_ARCH_LS1021A) { .compatible = "fsl,vf610-i2c", .data = I2C_QUIRK_FLAG, },
+#endif {} };
diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c index 588d6a9d76..6943e4867e 100644 --- a/drivers/mmc/fsl_esdhc_imx.c +++ b/drivers/mmc/fsl_esdhc_imx.c @@ -1601,31 +1601,49 @@ static const struct dm_mmc_ops fsl_esdhc_ops = { }; #endif
+#if defined(CONFIG_ARCH_MX7) static struct esdhc_soc_data usdhc_imx7d_data = { .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 | ESDHC_FLAG_HS400, }; +#endif
+#if defined(CONFIG_ARCH_IMX8) || defined(CONFIG_ARCH_IMX8M) static struct esdhc_soc_data usdhc_imx8qm_data = { .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 | ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES, }; +#endif
static const struct udevice_id fsl_esdhc_ids[] = { +#ifdef CONFIG_ARCH_MX5 { .compatible = "fsl,imx53-esdhc", }, +#endif +#ifdef CONFIG_ARCH_MX6 { .compatible = "fsl,imx6ul-usdhc", }, { .compatible = "fsl,imx6sx-usdhc", }, { .compatible = "fsl,imx6sl-usdhc", }, { .compatible = "fsl,imx6q-usdhc", }, +#endif +#ifdef CONFIG_ARCH_MX7 { .compatible = "fsl,imx7d-usdhc", .data = (ulong)&usdhc_imx7d_data,}, +#endif +#ifdef CONFIG_ARCH_MX7ULP { .compatible = "fsl,imx7ulp-usdhc", }, +#endif +#ifdef CONFIG_ARCH_IMX8 { .compatible = "fsl,imx8qm-usdhc", .data = (ulong)&usdhc_imx8qm_data,}, +#endif +#ifdef CONFIG_ARCH_IMX8M { .compatible = "fsl,imx8mm-usdhc", .data = (ulong)&usdhc_imx8qm_data,}, { .compatible = "fsl,imx8mn-usdhc", .data = (ulong)&usdhc_imx8qm_data,}, { .compatible = "fsl,imx8mq-usdhc", .data = (ulong)&usdhc_imx8qm_data,}, +#endif +#ifdef CONFIG_ARCH_IMXRT { .compatible = "fsl,imxrt-usdhc", }, +#endif { .compatible = "fsl,esdhc", }, { /* sentinel */ } }; diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 9ae2db033e..d829b5b5ba 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -1574,14 +1574,30 @@ static int fecmxc_ofdata_to_platdata(struct udevice *dev) }
static const struct udevice_id fecmxc_ids[] = { +#ifdef CONFIG_ARCH_MX28 { .compatible = "fsl,imx28-fec" }, +#endif +#ifdef CONFIG_ARCH_MX6 { .compatible = "fsl,imx6q-fec" }, +#endif +#ifdef CONFIG_MX6SL { .compatible = "fsl,imx6sl-fec" }, +#endif +#ifdef CONFIG_MX6SX { .compatible = "fsl,imx6sx-fec" }, +#endif +#ifdef CONFIG_MX6UL { .compatible = "fsl,imx6ul-fec" }, +#endif +#ifdef CONFIG_ARCH_MX5 { .compatible = "fsl,imx53-fec" }, +#endif +#ifdef CONFIG_ARCH_MX7 { .compatible = "fsl,imx7d-fec" }, +#endif +#ifdef CONFIG_ARCH_VF610 { .compatible = "fsl,mvf600-fec" }, +#endif { } };
diff --git a/drivers/pinctrl/nxp/pinctrl-imx6.c b/drivers/pinctrl/nxp/pinctrl-imx6.c index aafa3057ad..dff4954344 100644 --- a/drivers/pinctrl/nxp/pinctrl-imx6.c +++ b/drivers/pinctrl/nxp/pinctrl-imx6.c @@ -12,14 +12,18 @@
static struct imx_pinctrl_soc_info imx6_pinctrl_soc_info __section(".data");
+#ifdef CONFIG_MX6UL /* FIXME Before reloaction, BSS is overlapped with DT area */ static struct imx_pinctrl_soc_info imx6ul_pinctrl_soc_info = { .flags = ZERO_OFFSET_VALID, }; +#endif
+#if defined(CONFIG_MX6SLL) || defined(CONFIG_MX6ULL) static struct imx_pinctrl_soc_info imx6_snvs_pinctrl_soc_info = { .flags = ZERO_OFFSET_VALID, }; +#endif
static int imx6_pinctrl_probe(struct udevice *dev) { @@ -32,12 +36,22 @@ static int imx6_pinctrl_probe(struct udevice *dev) static const struct udevice_id imx6_pinctrl_match[] = { { .compatible = "fsl,imx6q-iomuxc", .data = (ulong)&imx6_pinctrl_soc_info }, { .compatible = "fsl,imx6dl-iomuxc", .data = (ulong)&imx6_pinctrl_soc_info }, +#ifdef CONFIG_MX6SL { .compatible = "fsl,imx6sl-iomuxc", .data = (ulong)&imx6_pinctrl_soc_info }, +#endif +#ifdef CONFIG_MX6SLL { .compatible = "fsl,imx6sll-iomuxc-snvs", .data = (ulong)&imx6_snvs_pinctrl_soc_info }, { .compatible = "fsl,imx6sll-iomuxc", .data = (ulong)&imx6_pinctrl_soc_info }, +#endif +#ifdef CONFIG_MX6SX { .compatible = "fsl,imx6sx-iomuxc", .data = (ulong)&imx6_pinctrl_soc_info }, +#endif +#ifdef CONFIG_MX6UL { .compatible = "fsl,imx6ul-iomuxc", .data = (ulong)&imx6ul_pinctrl_soc_info }, +#endif +#ifdef CONFIG_MX6ULL { .compatible = "fsl,imx6ull-iomuxc-snvs", .data = (ulong)&imx6_snvs_pinctrl_soc_info }, +#endif { /* sentinel */ } };
diff --git a/drivers/serial/serial_mxc.c b/drivers/serial/serial_mxc.c index 42abb96a26..f4a0d56e09 100644 --- a/drivers/serial/serial_mxc.c +++ b/drivers/serial/serial_mxc.c @@ -343,11 +343,21 @@ static int mxc_serial_ofdata_to_platdata(struct udevice *dev)
static const struct udevice_id mxc_serial_ids[] = { { .compatible = "fsl,imx21-uart" }, +#ifdef CONFIG_ARCH_MX5 { .compatible = "fsl,imx53-uart" }, +#endif +#ifdef CONFIG_ARCH_MX6SX { .compatible = "fsl,imx6sx-uart" }, +#endif +#if defined(CONFIG_ARCH_MX6UL) || defined(CONFIG_ARCH_MX6ULL) { .compatible = "fsl,imx6ul-uart" }, +#endif +#ifdef CONFIG_ARCH_MX7 { .compatible = "fsl,imx7d-uart" }, +#endif +#if defined(CONFIG_ARCH_MX6) || defined(CONFIG_ARCH_MX6SL) || defined(CONFIG_ARCH_MX6SLL) { .compatible = "fsl,imx6q-uart" }, +#endif { } }; #endif

On 5/26/20 1:12 PM, Soeren Moch wrote:
On 25.05.20 22:24, Anatolij Gustschin wrote:
Converting to DM increases binary size and breaks building some boards (i.e. tbs2910, gcc 9.2). The approach to address this issue via cutting off unused properties/nodes in device tree via custom u-boot.dtsi was not welcome, even if the affected boards do not pass the built-in device tree to the kernel.
But there is CONFIG_OF_REMOVE_PROPS="dmas dma-names interrupt-parent interrupts interrupts-extended interrupt-names interrupt-map interrupt-map-mask" in tbs2910_defconfig. So removing properties is already done via this config option. Removing nodes is not implemented (yet? AFAIK). But would be welcome if someone implements this in a similar way, I think.
Why don't we turn this the other way around -- put the { compat string , driver } tuple list into a U-Boot linker list, then filter this linker list against a DT which will be used for the platform (what if there are multiple DTs?), and then scrub all unreferrenced symbols.

On 26.05.20 13:25, Marek Vasut wrote:
On 5/26/20 1:12 PM, Soeren Moch wrote:
On 25.05.20 22:24, Anatolij Gustschin wrote:
Converting to DM increases binary size and breaks building some boards (i.e. tbs2910, gcc 9.2). The approach to address this issue via cutting off unused properties/nodes in device tree via custom u-boot.dtsi was not welcome, even if the affected boards do not pass the built-in device tree to the kernel.
But there is CONFIG_OF_REMOVE_PROPS="dmas dma-names interrupt-parent interrupts interrupts-extended interrupt-names interrupt-map interrupt-map-mask" in tbs2910_defconfig. So removing properties is already done via this config option. Removing nodes is not implemented (yet? AFAIK). But would be welcome if someone implements this in a similar way, I think.
Why don't we turn this the other way around -- put the { compat string , driver } tuple list into a U-Boot linker list, then filter this linker list against a DT which will be used for the platform (what if there are multiple DTs?), and then scrub all unreferrenced symbols.
I think we discussed this idea earlier, and indeed this sounds more promising. Apparently it is more difficult to implement, so this CONFIG_OF_REMOVE_PROPS was done as first step. Unfortunately I'm not familiar with fdt transformations, nor linker scripts. So I cannot really judge the required effort. But I would be happy if someone else implements this.
Soeren

On Tue, 26 May 2020 13:25:00 +0200 Marek Vasut marex@denx.de wrote:
On 5/26/20 1:12 PM, Soeren Moch wrote:
On 25.05.20 22:24, Anatolij Gustschin wrote:
Converting to DM increases binary size and breaks building some boards (i.e. tbs2910, gcc 9.2). The approach to address this issue via cutting off unused properties/nodes in device tree via custom u-boot.dtsi was not welcome, even if the affected boards do not pass the built-in device tree to the kernel.
But there is CONFIG_OF_REMOVE_PROPS="dmas dma-names interrupt-parent interrupts interrupts-extended interrupt-names interrupt-map interrupt-map-mask" in tbs2910_defconfig. So removing properties is already done via this config option. Removing nodes is not implemented (yet? AFAIK). But would be welcome if someone implements this in a similar way, I think.
Why don't we turn this the other way around -- put the { compat string , driver } tuple list into a U-Boot linker list, then filter this linker list against a DT which will be used for the platform (what if there are multiple DTs?), and then scrub all unreferrenced symbols.
This might be a topic again when new bloat causes build breakage again. For now I've succeeded to build the tbs2910 board with default CI tool chain without this patch (by making DM_VIDEO parts optional). Stripping unused compatible entries doesn't save much here (around 800 bytes). So the question is if it is worth the effort to implement such scrubbing.
-- Anatolij

On 5/26/20 1:58 PM, Anatolij Gustschin wrote:
On Tue, 26 May 2020 13:25:00 +0200 Marek Vasut marex@denx.de wrote:
On 5/26/20 1:12 PM, Soeren Moch wrote:
On 25.05.20 22:24, Anatolij Gustschin wrote:
Converting to DM increases binary size and breaks building some boards (i.e. tbs2910, gcc 9.2). The approach to address this issue via cutting off unused properties/nodes in device tree via custom u-boot.dtsi was not welcome, even if the affected boards do not pass the built-in device tree to the kernel.
But there is CONFIG_OF_REMOVE_PROPS="dmas dma-names interrupt-parent interrupts interrupts-extended interrupt-names interrupt-map interrupt-map-mask" in tbs2910_defconfig. So removing properties is already done via this config option. Removing nodes is not implemented (yet? AFAIK). But would be welcome if someone implements this in a similar way, I think.
Why don't we turn this the other way around -- put the { compat string , driver } tuple list into a U-Boot linker list, then filter this linker list against a DT which will be used for the platform (what if there are multiple DTs?), and then scrub all unreferrenced symbols.
This might be a topic again when new bloat causes build breakage again. For now I've succeeded to build the tbs2910 board with default CI tool chain without this patch (by making DM_VIDEO parts optional). Stripping unused compatible entries doesn't save much here (around 800 bytes). So the question is if it is worth the effort to implement such scrubbing.
It is if you can remove all the unused compatibles and all the data/rodata they reference. I think it would be nice to prototype this at least and see how much this really saves. I suspect for SPL this might be interesting even more.

Subject: Re: [RFC PATCH] imx: skip unused compatible strings in drivers
On Tue, 26 May 2020 13:25:00 +0200 Marek Vasut marex@denx.de wrote:
On 5/26/20 1:12 PM, Soeren Moch wrote:
On 25.05.20 22:24, Anatolij Gustschin wrote:
Converting to DM increases binary size and breaks building some boards (i.e. tbs2910, gcc 9.2). The approach to address this issue via cutting off unused properties/nodes in device tree via custom u-boot.dtsi was not welcome, even if the affected boards do not pass the built-in device tree to the kernel.
But there is CONFIG_OF_REMOVE_PROPS="dmas dma-names
interrupt-parent
interrupts interrupts-extended interrupt-names interrupt-map interrupt-map-mask" in tbs2910_defconfig. So removing properties is already done via this config option. Removing nodes is not implemented (yet? AFAIK). But would be welcome if someone implements this in a similar way, I think.
Why don't we turn this the other way around -- put the { compat string , driver } tuple list into a U-Boot linker list, then filter this linker list against a DT which will be used for the platform (what if there are multiple DTs?), and then scrub all unreferrenced symbols.
This might be a topic again when new bloat causes build breakage again. For now I've succeeded to build the tbs2910 board with default CI tool chain without this patch (by making DM_VIDEO parts optional). Stripping unused compatible entries doesn't save much here (around 800 bytes). So the question is if it is worth the effort to implement such scrubbing.
I vote for this. Whether u-boot or SPL, currently the size is larger and larger.
Thanks, Peng.
-- Anatolij

On 5/26/20 2:40 PM, Peng Fan wrote:
Subject: Re: [RFC PATCH] imx: skip unused compatible strings in drivers
On Tue, 26 May 2020 13:25:00 +0200 Marek Vasut marex@denx.de wrote:
On 5/26/20 1:12 PM, Soeren Moch wrote:
On 25.05.20 22:24, Anatolij Gustschin wrote:
Converting to DM increases binary size and breaks building some boards (i.e. tbs2910, gcc 9.2). The approach to address this issue via cutting off unused properties/nodes in device tree via custom u-boot.dtsi was not welcome, even if the affected boards do not pass the built-in device tree to the kernel.
But there is CONFIG_OF_REMOVE_PROPS="dmas dma-names
interrupt-parent
interrupts interrupts-extended interrupt-names interrupt-map interrupt-map-mask" in tbs2910_defconfig. So removing properties is already done via this config option. Removing nodes is not implemented (yet? AFAIK). But would be welcome if someone implements this in a similar way, I think.
Why don't we turn this the other way around -- put the { compat string , driver } tuple list into a U-Boot linker list, then filter this linker list against a DT which will be used for the platform (what if there are multiple DTs?), and then scrub all unreferrenced symbols.
This might be a topic again when new bloat causes build breakage again. For now I've succeeded to build the tbs2910 board with default CI tool chain without this patch (by making DM_VIDEO parts optional). Stripping unused compatible entries doesn't save much here (around 800 bytes). So the question is if it is worth the effort to implement such scrubbing.
I vote for this. Whether u-boot or SPL, currently the size is larger and larger.
Can you send a patch prototyping this ?

On Tue, 26 May 2020 14:42:08 +0200 Marek Vasut marex@denx.de wrote:
On 5/26/20 2:40 PM, Peng Fan wrote:
Subject: Re: [RFC PATCH] imx: skip unused compatible strings in drivers
On Tue, 26 May 2020 13:25:00 +0200 Marek Vasut marex@denx.de wrote:
On 5/26/20 1:12 PM, Soeren Moch wrote:
On 25.05.20 22:24, Anatolij Gustschin wrote:
Converting to DM increases binary size and breaks building some boards (i.e. tbs2910, gcc 9.2). The approach to address this issue via cutting off unused properties/nodes in device tree via custom u-boot.dtsi was not welcome, even if the affected boards do not pass the built-in device tree to the kernel.
But there is CONFIG_OF_REMOVE_PROPS="dmas dma-names
interrupt-parent
interrupts interrupts-extended interrupt-names interrupt-map interrupt-map-mask" in tbs2910_defconfig. So removing properties is already done via this config option. Removing nodes is not implemented (yet? AFAIK). But would be welcome if someone implements this in a similar way, I think.
Why don't we turn this the other way around -- put the { compat string , driver } tuple list into a U-Boot linker list, then filter this linker list against a DT which will be used for the platform (what if there are multiple DTs?), and then scrub all unreferrenced symbols.
This might be a topic again when new bloat causes build breakage again. For now I've succeeded to build the tbs2910 board with default CI tool chain without this patch (by making DM_VIDEO parts optional). Stripping unused compatible entries doesn't save much here (around 800 bytes). So the question is if it is worth the effort to implement such scrubbing.
I vote for this. Whether u-boot or SPL, currently the size is larger and larger.
Can you send a patch prototyping this ?
I'm not working on this, so do not expect patches from me, at least not in the near future.
-- Anatolij

On Tue, 26 May 2020 13:12:46 +0200 Soeren Moch smoch@web.de wrote:
On 25.05.20 22:24, Anatolij Gustschin wrote:
Converting to DM increases binary size and breaks building some boards (i.e. tbs2910, gcc 9.2). The approach to address this issue via cutting off unused properties/nodes in device tree via custom u-boot.dtsi was not welcome, even if the affected boards do not pass the built-in device tree to the kernel.
But there is CONFIG_OF_REMOVE_PROPS="dmas dma-names interrupt-parent interrupts interrupts-extended interrupt-names interrupt-map interrupt-map-mask" in tbs2910_defconfig. So removing properties is already done via this config option. Removing nodes is not implemented (yet? AFAIK). But would be welcome if someone implements this in a similar way, I think.
Yes, I've added this CONFIG_OF_REMOVE_PROPS list on request because an earlier patch [1] was not very welcome. But this older patch already did deleting unused nodes, in a different way.
[1] http://patchwork.ozlabs.org/project/uboot/patch/20191206183047.1313-1-agust@...
-- Anatolij
participants (4)
-
Anatolij Gustschin
-
Marek Vasut
-
Peng Fan
-
Soeren Moch