Skip to contentSkip to conversation

drm/sun4i: fix build failure with CONFIG_DRM_SUN8I_MIXER=m

PATCH In review Maxime Ripard 3 participants 9 messages Sep 11, 2018 – Sep 13, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/sun4i: fix build failure with CONFIG_DRM_SUN8I_MIXER=m

Having DRM_SUN4I built-in but DRM_SUN8I_MIXER as a loadable module results in a link error, as we try to access a symbol from the sun8i_tcon_top.ko module:

ERROR: "sun8i_tcon_top_de_config" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_set_hdmi_src" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_of_table" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!

This solves the problem by adding a silent symbol for the tcon_top module, building it as a separate module in exactly the cases that we need it, but in a way that it is reachable by the other modules.

Fixes cf77d79b4e29 ("drm/sun4i: tcon: Add another way for matching mixers with tcon")
Fixes 0305189afb32 ("drm/sun4i: tcon: Add support for R40 TCON")
---
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/gpu/drm/sun4i/sun4i_tcon.c +11 -3
index 4834c90b4912..c78cd35a1294 100644
@@ -974,7 +974,8 @@ static bool sun4i_tcon_connected_to_tcon_top(struct device_node *node)
 
 	remote = of_graph_get_remote_node(node, 0, -1);
 	if (remote) {
-		ret = !!of_match_node(sun8i_tcon_top_of_table, remote);
+		ret = !!(IS_ENABLED(CONFIG_DRM_SUN8I_TCON_TOP) &&
+			 of_match_node(sun8i_tcon_top_of_table, remote));
 		of_node_put(remote);
 	}
 
@@ -1402,13 +1403,20 @@ static int sun8i_r40_tcon_tv_set_mux(struct sun4i_tcon *tcon,
 	if (!pdev)
 		return -EINVAL;
 
-	if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) {
+	if (IS_ENABLED(CONFIG_DRM_SUN8I_TCON_TOP) &&
+	    encoder->encoder_type == DRM_MODE_ENCODER_TMDS) {
 		ret = sun8i_tcon_top_set_hdmi_src(&pdev->dev, id);
 		if (ret)
 			return ret;
 	}
 
-	return sun8i_tcon_top_de_config(&pdev->dev, tcon->id, id);
+	if (IS_ENABLED(CONFIG_DRM_SUN8I_TCON_TOP)) {
+		ret = sun8i_tcon_top_de_config(&pdev->dev, tcon->id, id);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
 }
 
 static const struct sun4i_tcon_quirks sun4i_a10_quirks = {
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Maxime Ripard

Having DRM_SUN4I built-in but DRM_SUN8I_MIXER as a loadable module results in a link error, as we try to access a symbol from the sun8i_tcon_top.ko module:

ERROR: "sun8i_tcon_top_de_config" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_set_hdmi_src" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_of_table" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!

Quoted 8 lines

This solves the problem by adding a silent symbol for the tcon_top module, building it as a separate module in exactly the cases that we need it, but in a way that it is reachable by the other modules.

Fixes cf77d79b4e29 ("drm/sun4i: tcon: Add another way for matching mixers with tcon")
Fixes 0305189afb32 ("drm/sun4i: tcon: Add support for R40 TCON")

But I can't help myself and drop the usual questions when I see a small soc driver with more Kconfigs than anything else ... is all this pain worth it? I know that maybe the desktop approach of stuffing half a million lines of driver code into one .ko might be a bit too much for socs, but this seems overkill.

I'm also pretty sure it's not justified by any real data, compared to overall code size of a drm stack, that shows it's a substantial enough saving that it's worth it.

Imo, if you really care about building a minimal driver, stuff everything into one .ko and then LTO out the uneeded bits. We've done these experiments for i915, that _actually_ saves a ton of binary size, with fairly minimal code and maintenance impact. Still, we decided the payoff is simply too small to bother making it a production thing.

Cheers, Daniel

Quoted 48 lines
---
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/gpu/drm/sun4i/sun4i_tcon.c +11 -3
index 4834c90b4912..c78cd35a1294 100644
@@ -974,7 +974,8 @@ static bool sun4i_tcon_connected_to_tcon_top(struct device_node *node)
 
 	remote = of_graph_get_remote_node(node, 0, -1);
 	if (remote) {
-		ret = !!of_match_node(sun8i_tcon_top_of_table, remote);
+		ret = !!(IS_ENABLED(CONFIG_DRM_SUN8I_TCON_TOP) &&
+			 of_match_node(sun8i_tcon_top_of_table, remote));
 		of_node_put(remote);
 	}
 
@@ -1402,13 +1403,20 @@ static int sun8i_r40_tcon_tv_set_mux(struct sun4i_tcon *tcon,
 	if (!pdev)
 		return -EINVAL;
 
-	if (encoder->encoder_type == DRM_MODE_ENCODER_TMDS) {
+	if (IS_ENABLED(CONFIG_DRM_SUN8I_TCON_TOP) &&
+	    encoder->encoder_type == DRM_MODE_ENCODER_TMDS) {
 		ret = sun8i_tcon_top_set_hdmi_src(&pdev->dev, id);
 		if (ret)
 			return ret;
 	}
 
-	return sun8i_tcon_top_de_config(&pdev->dev, tcon->id, id);
+	if (IS_ENABLED(CONFIG_DRM_SUN8I_TCON_TOP)) {
+		ret = sun8i_tcon_top_de_config(&pdev->dev, tcon->id, id);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
 }
 
 static const struct sun4i_tcon_quirks sun4i_a10_quirks = {
Signature · 6 lines
2.17.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 25 lines · Daniel Vetter
Quoted 7 lines · Maxime Ripard

Having DRM_SUN4I built-in but DRM_SUN8I_MIXER as a loadable module results in a link error, as we try to access a symbol from the sun8i_tcon_top.ko module:

ERROR: "sun8i_tcon_top_de_config" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_set_hdmi_src" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_of_table" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!

Quoted 8 lines

This solves the problem by adding a silent symbol for the tcon_top module, building it as a separate module in exactly the cases that we need it, but in a way that it is reachable by the other modules.

Fixes cf77d79b4e29 ("drm/sun4i: tcon: Add another way for matching mixers with tcon")
Fixes 0305189afb32 ("drm/sun4i: tcon: Add support for R40 TCON")

But I can't help myself and drop the usual questions when I see a small soc driver with more Kconfigs than anything else ... is all this pain worth it? I know that maybe the desktop approach of stuffing half a million lines of driver code into one .ko might be a bit too much for socs, but this seems overkill.

Quoted 3 lines

I'm also pretty sure it's not justified by any real data, compared to overall code size of a drm stack, that shows it's a substantial enough saving that it's worth it.

I'm currently running on a project where the boot time to a qt application from power off should be less than a second. You want to remove anything you can spare in some situations. And yeah, DRM is the biggest thing in the way to do that.

Quoted 5 lines

Imo, if you really care about building a minimal driver, stuff everything into one .ko and then LTO out the uneeded bits. We've done these experiments for i915, that _actually_ saves a ton of binary size, with fairly minimal code and maintenance impact. Still, we decided the payoff is simply too small to bother making it a production thing.

LTO isn't enabled yet in mainline, is it?

Maxime

Signature · 3 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
Quoted 26 lines · Maxime Ripard
Quoted 25 lines · Daniel Vetter
Quoted 7 lines · Maxime Ripard

Having DRM_SUN4I built-in but DRM_SUN8I_MIXER as a loadable module results in a link error, as we try to access a symbol from the sun8i_tcon_top.ko module:

ERROR: "sun8i_tcon_top_de_config" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_set_hdmi_src" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_of_table" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!

Quoted 8 lines

This solves the problem by adding a silent symbol for the tcon_top module, building it as a separate module in exactly the cases that we need it, but in a way that it is reachable by the other modules.

Fixes cf77d79b4e29 ("drm/sun4i: tcon: Add another way for matching mixers with tcon")
Fixes 0305189afb32 ("drm/sun4i: tcon: Add support for R40 TCON")

But I can't help myself and drop the usual questions when I see a small soc driver with more Kconfigs than anything else ... is all this pain worth it? I know that maybe the desktop approach of stuffing half a million lines of driver code into one .ko might be a bit too much for socs, but this seems overkill.

Quoted 8 lines
Quoted 3 lines

I'm also pretty sure it's not justified by any real data, compared to overall code size of a drm stack, that shows it's a substantial enough saving that it's worth it.

I'm currently running on a project where the boot time to a qt application from power off should be less than a second. You want to remove anything you can spare in some situations. And yeah, DRM is the biggest thing in the way to do that.

Oh I know all about the 1s people. But is binary size really that important figure? I know it's a bit more to load&decompress, but it shouldn't have any impact on anything running at runtime.

Quoted 7 lines
Quoted 5 lines

Imo, if you really care about building a minimal driver, stuff everything into one .ko and then LTO out the uneeded bits. We've done these experiments for i915, that _actually_ saves a ton of binary size, with fairly minimal code and maintenance impact. Still, we decided the payoff is simply too small to bother making it a production thing.

LTO isn't enabled yet in mainline, is it?

Unfortunately not :-/ We've done the analysis and reported to the internal people who asked for this that "lto is what you want", but nothing thus far. I guess the price tag of making LTO work is a bit too much. Ofc doesn't just need LTO, but also needs some trickery to make sure all the optional paths are statically determined to never run. But (at least for us) that's just a few changes to the pci table, and hard-coding the device info structure. OF/DT would probably need some work, but should be doable too.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw
Quoted 32 lines · Daniel Vetter
Quoted 30 lines · Maxime Ripard
Quoted 28 lines · Daniel Vetter
Quoted 7 lines · Maxime Ripard

Having DRM_SUN4I built-in but DRM_SUN8I_MIXER as a loadable module results in a link error, as we try to access a symbol from the sun8i_tcon_top.ko module:

ERROR: "sun8i_tcon_top_de_config" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_set_hdmi_src" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_of_table" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!

Quoted 8 lines

This solves the problem by adding a silent symbol for the tcon_top module, building it as a separate module in exactly the cases that we need it, but in a way that it is reachable by the other modules.

Fixes cf77d79b4e29 ("drm/sun4i: tcon: Add another way for matching mixers with tcon")
Fixes 0305189afb32 ("drm/sun4i: tcon: Add support for R40 TCON")

But I can't help myself and drop the usual questions when I see a small soc driver with more Kconfigs than anything else ... is all this pain worth it? I know that maybe the desktop approach of stuffing half a million lines of driver code into one .ko might be a bit too much for socs, but this seems overkill.

I'm also pretty sure it's not justified by any real data, compared to overall code size of a drm stack, that shows it's a substantial enough saving that it's worth it.

Quoted 8 lines
Quoted 4 lines

I'm currently running on a project where the boot time to a qt application from power off should be less than a second. You want to remove anything you can spare in some situations. And yeah, DRM is the biggest thing in the way to do that.

Oh I know all about the 1s people. But is binary size really that important figure? I know it's a bit more to load&decompress, but it shouldn't have any impact on anything running at runtime.

It really depends on the combination of the CPU speed, the storage speed, and the compression algorithm. To give you a figure, a quite good storage device in our case has a bandwith of 10MB/s. If you add a MB, you lose a tenth of your budget, decompression excluded.

The sole edid_cea_modes, drm_dmt_modes and edid_est_modes, combined, already take around 50kB. That's around .5% of our time budget just dedicated to loading structures we will never need, without the option to compile them out.

Maxime

Signature · 3 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#5 lore raw
Quoted 47 lines · Maxime Ripard
Quoted 32 lines · Daniel Vetter
Quoted 30 lines · Maxime Ripard
Quoted 28 lines · Daniel Vetter
Quoted 7 lines · Maxime Ripard

Having DRM_SUN4I built-in but DRM_SUN8I_MIXER as a loadable module results in a link error, as we try to access a symbol from the sun8i_tcon_top.ko module:

ERROR: "sun8i_tcon_top_de_config" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_set_hdmi_src" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_of_table" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!

Quoted 8 lines

This solves the problem by adding a silent symbol for the tcon_top module, building it as a separate module in exactly the cases that we need it, but in a way that it is reachable by the other modules.

Fixes cf77d79b4e29 ("drm/sun4i: tcon: Add another way for matching mixers with tcon")
Fixes 0305189afb32 ("drm/sun4i: tcon: Add support for R40 TCON")

But I can't help myself and drop the usual questions when I see a small soc driver with more Kconfigs than anything else ... is all this pain worth it? I know that maybe the desktop approach of stuffing half a million lines of driver code into one .ko might be a bit too much for socs, but this seems overkill.

I'm also pretty sure it's not justified by any real data, compared to overall code size of a drm stack, that shows it's a substantial enough saving that it's worth it.

Quoted 8 lines
Quoted 4 lines

I'm currently running on a project where the boot time to a qt application from power off should be less than a second. You want to remove anything you can spare in some situations. And yeah, DRM is the biggest thing in the way to do that.

Oh I know all about the 1s people. But is binary size really that important figure? I know it's a bit more to load&decompress, but it shouldn't have any impact on anything running at runtime.

It really depends on the combination of the CPU speed, the storage speed, and the compression algorithm. To give you a figure, a quite good storage device in our case has a bandwith of 10MB/s. If you add a MB, you lose a tenth of your budget, decompression excluded.

Quoted 4 lines

The sole edid_cea_modes, drm_dmt_modes and edid_est_modes, combined, already take around 50kB. That's around .5% of our time budget just dedicated to loading structures we will never need, without the option to compile them out.

Yup, if you want to make drm_edid.c optional, you need LTO. Because I think we've already gone way overboard with making stuff optional in the drm core, there's lots of silly little Kconfigs with imo questionable value. Also, 50kb ... what does that look like compressed? Should compress exceedingly well.

But that's not what I asked about really, I asked about all the Kconfigs in su4i. Are those worth it? Especially compared to fixing this for real, using something like LTO (plus making a few things hard-coded, per machine configuration, so that gcc can figure it all out).
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw
Quoted 60 lines · Daniel Vetter
Quoted 47 lines · Maxime Ripard
Quoted 32 lines · Daniel Vetter
Quoted 30 lines · Maxime Ripard
Quoted 28 lines · Daniel Vetter
Quoted 7 lines · Maxime Ripard

Having DRM_SUN4I built-in but DRM_SUN8I_MIXER as a loadable module results in a link error, as we try to access a symbol from the sun8i_tcon_top.ko module:

ERROR: "sun8i_tcon_top_de_config" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_set_hdmi_src" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_of_table" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!

Quoted 8 lines

This solves the problem by adding a silent symbol for the tcon_top module, building it as a separate module in exactly the cases that we need it, but in a way that it is reachable by the other modules.

Fixes cf77d79b4e29 ("drm/sun4i: tcon: Add another way for matching mixers with tcon")
Fixes 0305189afb32 ("drm/sun4i: tcon: Add support for R40 TCON")

But I can't help myself and drop the usual questions when I see a small soc driver with more Kconfigs than anything else ... is all this pain worth it? I know that maybe the desktop approach of stuffing half a million lines of driver code into one .ko might be a bit too much for socs, but this seems overkill.

I'm also pretty sure it's not justified by any real data, compared to overall code size of a drm stack, that shows it's a substantial enough saving that it's worth it.

Quoted 8 lines
Quoted 4 lines

I'm currently running on a project where the boot time to a qt application from power off should be less than a second. You want to remove anything you can spare in some situations. And yeah, DRM is the biggest thing in the way to do that.

Oh I know all about the 1s people. But is binary size really that important figure? I know it's a bit more to load&decompress, but it shouldn't have any impact on anything running at runtime.

It really depends on the combination of the CPU speed, the storage speed, and the compression algorithm. To give you a figure, a quite good storage device in our case has a bandwith of 10MB/s. If you add a MB, you lose a tenth of your budget, decompression excluded.

Quoted 4 lines

The sole edid_cea_modes, drm_dmt_modes and edid_est_modes, combined, already take around 50kB. That's around .5% of our time budget just dedicated to loading structures we will never need, without the option to compile them out.

Yup, if you want to make drm_edid.c optional, you need LTO. Because I think we've already gone way overboard with making stuff optional in the drm core, there's lots of silly little Kconfigs with imo questionable value. Also, 50kb ... what does that look like compressed? Should compress exceedingly well.

Quoted 5 lines

But that's not what I asked about really, I asked about all the Kconfigs in su4i. Are those worth it? Especially compared to fixing this for real, using something like LTO (plus making a few things hard-coded, per machine configuration, so that gcc can figure it all out).

You're asking whether a 5 minutes effort is worth it compared to a 5 weeks one (at best) to port the LTO patches, making it sure it works ok on ARM, and then debugging whether some entry point has been removed or not.

Plus, given that it's a driver that could or couldn't be loaded depending on the device tree, you would have to keep that driver in even with LTO, even though you know you have zero chance to execute that code at runtime.

Maxime

Signature · 3 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#7 lore raw
Quoted 21 lines · Maxime Ripard
Quoted 9 lines · Daniel Vetter
Quoted 1 line · Maxime Ripard

On Wed, Sep 12, 2018 at 04:25:36PM +0200, Daniel Vetter wrote:

Yup, if you want to make drm_edid.c optional, you need LTO. Because I think we've already gone way overboard with making stuff optional in the drm core, there's lots of silly little Kconfigs with imo questionable value. Also, 50kb ... what does that look like compressed? Should compress exceedingly well.

Quoted 5 lines

But that's not what I asked about really, I asked about all the Kconfigs in su4i. Are those worth it? Especially compared to fixing this for real, using something like LTO (plus making a few things hard-coded, per machine configuration, so that gcc can figure it all out).

You're asking whether a 5 minutes effort is worth it compared to a 5 weeks one (at best) to port the LTO patches, making it sure it works ok on ARM, and then debugging whether some entry point has been removed or not.

Quoted 4 lines

Plus, given that it's a driver that could or couldn't be loaded depending on the device tree, you would have to keep that driver in even with LTO, even though you know you have zero chance to execute that code at runtime.

I have spent a few weeks on getting ARM kernels to build with LTO, based on earlier work from Nico and others. This requires a couple of patches for the common cases, but gets increasingly complex when you add in some other options (thumb2 kernel, XIP_KERNEL, MTD_XIP, OABI, ftrace, gcov, multi-cpu, ...) that each add their own conflicting requirements. I gave up in the end, before even trying to run any of those kernels.

I think for x86-64 and arm64, we have a realistic chance of making it work in general, on arm32 the best case I can think of would be to support some of the common configurations.

Arnd
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#8 lore raw
In reply to Daniel Vetter
Quoted 12 lines · Daniel Vetter
Quoted 11 lines · Maxime Ripard

Having DRM_SUN4I built-in but DRM_SUN8I_MIXER as a loadable module results in a link error, as we try to access a symbol from the sun8i_tcon_top.ko module:

ERROR: "sun8i_tcon_top_de_config" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_set_hdmi_src" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!
ERROR: "sun8i_tcon_top_of_table" [drivers/gpu/drm/sun4i/sun4i-tcon.ko] undefined!

This solves the problem by adding a silent symbol for the tcon_top module, building it as a separate module in exactly the cases that we need it, but in a way that it is reachable by the other modules.

Quoted 6 lines
Quoted 4 lines
Fixes cf77d79b4e29 ("drm/sun4i: tcon: Add another way for matching mixers with tcon")
Fixes 0305189afb32 ("drm/sun4i: tcon: Add support for R40 TCON")

It's pushed, thanks!
Maxime

Signature · 3 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel