simplefb: add clock handling
Subsystems (3)
This is needed for the sunxi platform, where the u-boot initialized display engine gets disabled by the clocks framework if certain clocks are not claimed. Once these clocks are disabled, register content is lost, and there is no turning back unless a full display driver is loaded, which kind of beats the purpose of having simplefb running.
The lack of clock handling should plague more hardware, but so far rpi is the best known user of simplefb, and its stepmotherly handling of the arm core has kept these sort of issues from the kernel.
The sunxi u-boot side code can be found here:
https://groups.google.com/forum/#!topic/linux-sunxi/dPs958sIXvY
Patch 3 might be controversial, as this does not achieve anything real today, since the status property in dt is only really evaluated when dealing with a nodes memory. It still seems like a good idea to at least flag this memory or node as disabled, as we really have no way back when the clocks get disabled.
Luc Verhaegen.
PATCH 1/4 simplefb: formalize pseudo palette handling
--- drivers/video/fbdev/simplefb.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-)
drivers/video/fbdev/simplefb.c +12 -3
@@ -41,6 +41,8 @@ static struct fb_var_screeninfo simplefb_var = { .vmode = FB_VMODE_NONINTERLACED, }; +#define PSEUDO_PALETTE_SIZE 16 +static int simplefb_setcolreg (u_int regno,u_int red,u_int green,u_int blue,u_int transp,struct fb_info *info) {
@@ -50,7 +52,7 @@ static int simplefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,u32 cb = blue >> (16 - info->var.blue.length);u32 value; -if (regno >=16 ) +if (regno >=PSEUDO_PALETTE_SIZE )return -EINVAL ; value = (cr << info->var.red.offset) |
@@ -163,11 +165,16 @@ static int simplefb_parse_pd(struct platform_device *pdev,return 0 ; } +struct simplefb_par { +u32 palette[PSEUDO_PALETTE_SIZE ]; +}; +static int simplefb_probe (struct platform_device *pdev) {int ret;struct simplefb_params params;struct fb_info *info; +struct simplefb_par *par;struct resource *mem;if (fb_get_options ("simplefb" ,NULL ))
@@ -188,11 +195,13 @@ static int simplefb_probe(struct platform_device *pdev)return -EINVAL ; } - info =framebuffer_alloc (sizeof (u32) *16 , &pdev->dev); + info =framebuffer_alloc (sizeof (struct simplefb_par ), &pdev->dev);if (!info)return -ENOMEM ;platform_set_drvdata (pdev, info); + par = info->par; + info->fix = simplefb_fix; info->fix.smem_start = mem->start; info->fix.smem_len =resource_size (mem);
@@ -225,7 +234,7 @@ static int simplefb_probe(struct platform_device *pdev)framebuffer_release (info);return -ENODEV ; } - info->pseudo_palette = (void *)(info +1 ); + info->pseudo_palette = (void *) par->palette; dev_info(&pdev->dev, "framebuffer at 0x%lx, 0x%x bytes, mapped to 0x%p\n", info->fix.smem_start, info->fix.smem_len,
Signature · 1 line
1.7.7
PATCH 1/4 simplefb: formalize pseudo palette handling
Hi
Quoted 28 lines · Luc Verhaegen
Signed-off-by Luc Verhaegen <[email protected]>--- drivers/video/fbdev/simplefb.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-)drivers/video/fbdev/simplefb.c +3
-1@@ -41,6 +41,8 @@ static struct fb_var_screeninfo simplefb_var = { .vmode = FB_VMODE_NONINTERLACED, }; +#define PSEUDO_PALETTE_SIZE 16 +static int simplefb_setcolreg (u_int regno,u_int red,u_int green,u_int blue,u_int transp,struct fb_info *info) {@@ -50,7 +52,7 @@ static int simplefb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,u32 cb = blue >> (16 - info->var.blue.length);u32 value; -if (regno >=16 ) +if (regno >=PSEUDO_PALETTE_SIZE )return -EINVAL ; value = (cr << info->var.red.offset) |
drivers/video/fbdev/simplefb.c static int simplefb_parse_pd(struct platform_device *pdev, · line 171
Quoted 7 lines
drivers/video/fbdev/simplefb.c +4
-0@@ -163,11 +165,16 @@ static int simplefb_parse_pd(struct platform_device *pdev,return 0 ; } +struct simplefb_par { +u32 palette[PSEUDO_PALETTE_SIZE ]; +}; +
I'd move that definition to the top of the file.
Quoted 25 lines
drivers/video/fbdev/simplefb.c +4
-1static int simplefb_probe (struct platform_device *pdev) {int ret;struct simplefb_params params;struct fb_info *info; +struct simplefb_par *par;struct resource *mem;if (fb_get_options ("simplefb" ,NULL ))@@ -188,11 +195,13 @@ static int simplefb_probe(struct platform_device *pdev)return -EINVAL ; } - info =framebuffer_alloc (sizeof (u32) *16 , &pdev->dev); + info =framebuffer_alloc (sizeof (struct simplefb_par ), &pdev->dev);if (!info)return -ENOMEM ;platform_set_drvdata (pdev, info); + par = info->par; + info->fix = simplefb_fix; info->fix.smem_start = mem->start; info->fix.smem_len =resource_size (mem);
drivers/video/fbdev/simplefb.c static int simplefb_probe(struct platform_device *pdev) · line 237
Quoted 5 lines
drivers/video/fbdev/simplefb.c +1
-1@@ -225,7 +234,7 @@ static int simplefb_probe(struct platform_device *pdev)framebuffer_release (info);return -ENODEV ; } - info->pseudo_palette = (void *)(info +1 ); + info->pseudo_palette = (void *) par->palette;
I think coding-style is this (i.e., no whitespace):
info->pseudo_palette = (void*)par->palette;
Patch is fine with me:
Thanks
David
Quoted 10 lines
drivers/video/fbdev/simplefb.c +0
-1dev_info(&pdev->dev, "framebuffer at 0x%lx, 0x%x bytes, mapped to 0x%p\n", info->fix.smem_start, info->fix.smem_len, --1.7.7
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/4 simplefb: formalize pseudo palette handling
Quoted 9 lines · David Herrmann
drivers/video/fbdev/simplefb.c static int simplefb_probe(struct platform_device *pdev) · line 237
Quoted 6 lines
drivers/video/fbdev/simplefb.c +1
-1@@ -225,7 +234,7 @@ static int simplefb_probe(struct platform_device *pdev)framebuffer_release (info);return -ENODEV ; } - info->pseudo_palette = (void *)(info +1 ); + info->pseudo_palette = (void *) par->palette;I think coding-style is this (i.e., no whitespace):
info->pseudo_palette = (void*)par->palette;
<casts-are-evil>
Is this cast even needed?
</casts-are-evil>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
PATCH 1/4 simplefb: formalize pseudo palette handling
Hi
Quoted 11 lines · Geert Uytterhoeven
Quoted 9 lines · David Herrmann
drivers/video/fbdev/simplefb.c static int simplefb_probe(struct platform_device *pdev) · line 237
Quoted 6 lines
drivers/video/fbdev/simplefb.c +1
-1@@ -225,7 +234,7 @@ static int simplefb_probe(struct platform_device *pdev)framebuffer_release (info);return -ENODEV ; } - info->pseudo_palette = (void *)(info +1 ); + info->pseudo_palette = (void *) par->palette;I think coding-style is this (i.e., no whitespace):
info->pseudo_palette = (void*)par->palette;
Quoted 3 lines
<casts-are-evil>
Is this cast even needed?
</casts-are-evil>
"pseudo_palette" is "void*", so not at all.
Thanks
David
PATCH 1/4 simplefb: formalize pseudo palette handling
In reply to Luc VerhaegenQuoted 1 line · Luc Verhaegen
Signed-off-by Luc Verhaegen <[email protected]>
Patch description?
Assuming any comments anyone else had are addressed, patches 1 and 2 both,
PATCH 2/4 simplefb: add goto error path to probe
In reply to Luc Verhaegen--- drivers/video/fbdev/simplefb.c | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-)
drivers/video/fbdev/simplefb.c +13 -7
@@ -220,8 +220,8 @@ static int simplefb_probe(struct platform_device *pdev) info->apertures =alloc_apertures (1 );if (!info->apertures) { -framebuffer_release (info); -return -ENOMEM ; + ret = -ENOMEM ; + goto error_fb_release; } info->apertures->ranges[0 ].base = info->fix.smem_start; info->apertures->ranges[0 ].size = info->fix.smem_len;
@@ -231,8 +231,8 @@ static int simplefb_probe(struct platform_device *pdev) info->screen_base =ioremap_wc (info->fix.smem_start, info->fix.smem_len);if (!info->screen_base) { -framebuffer_release (info); -return -ENODEV ; + ret = -ENODEV ; + goto error_fb_release; } info->pseudo_palette = (void *) par->palette;
@@ -247,14 +247,20 @@ static int simplefb_probe(struct platform_device *pdev) ret =register_framebuffer (info);if (ret <0 ) {dev_err (&pdev->dev,"Unable to register simplefb: %d\n" , ret); -iounmap (info->screen_base); -framebuffer_release (info); -return ret; + goto error_unmap; }dev_info (&pdev->dev,"fb%d: simplefb registered!\n" , info->node);return 0 ; + + error_unmap: +iounmap (info->screen_base); + + error_fb_release: +framebuffer_release (info); + +return ret; }static int simplefb_remove (struct platform_device *pdev)
Signature · 1 line
1.7.7
PATCH 2/4 simplefb: add goto error path to probe
Hi
Quoted 42 lines · Luc Verhaegen
Signed-off-by Luc Verhaegen <[email protected]>--- drivers/video/fbdev/simplefb.c | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-)drivers/video/fbdev/simplefb.c +5
-7@@ -220,8 +220,8 @@ static int simplefb_probe(struct platform_device *pdev) info->apertures =alloc_apertures (1 );if (!info->apertures) { -framebuffer_release (info); -return -ENOMEM ; + ret = -ENOMEM ; + goto error_fb_release; } info->apertures->ranges[0 ].base = info->fix.smem_start; info->apertures->ranges[0 ].size = info->fix.smem_len;@@ -231,8 +231,8 @@ static int simplefb_probe(struct platform_device *pdev) info->screen_base =ioremap_wc (info->fix.smem_start, info->fix.smem_len);if (!info->screen_base) { -framebuffer_release (info); -return -ENODEV ; + ret = -ENODEV ; + goto error_fb_release; } info->pseudo_palette = (void *) par->palette;@@ -247,14 +247,20 @@ static int simplefb_probe(struct platform_device *pdev) ret =register_framebuffer (info);if (ret <0 ) {dev_err (&pdev->dev,"Unable to register simplefb: %d\n" , ret); -iounmap (info->screen_base); -framebuffer_release (info); -return ret; + goto error_unmap; }dev_info (&pdev->dev,"fb%d: simplefb registered!\n" , info->node);
drivers/video/fbdev/simplefb.c static int simplefb_probe(struct platform_device *pdev) · line 263
Quoted 10 lines
drivers/video/fbdev/simplefb.c +8
-0return 0 ; + + error_unmap: +iounmap (info->screen_base); + + error_fb_release: +framebuffer_release (info); + +return ret;
Again, I'd use different coding-style, but I will leave that to Stephen and Tomi:
Thanks
David
Quoted 10 lines
drivers/video/fbdev/simplefb.c +0
-1}static int simplefb_remove (struct platform_device *pdev) --1.7.7
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/4 simplefb: add goto error path to probe
Quoted 59 lines · David Herrmann
Hi
Quoted 42 lines · Luc Verhaegen
Signed-off-by Luc Verhaegen <[email protected]>--- drivers/video/fbdev/simplefb.c | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-)drivers/video/fbdev/simplefb.c +5
-7@@ -220,8 +220,8 @@ static int simplefb_probe(struct platform_device *pdev) info->apertures =alloc_apertures (1 );if (!info->apertures) { -framebuffer_release (info); -return -ENOMEM ; + ret = -ENOMEM ; + goto error_fb_release; } info->apertures->ranges[0 ].base = info->fix.smem_start; info->apertures->ranges[0 ].size = info->fix.smem_len;@@ -231,8 +231,8 @@ static int simplefb_probe(struct platform_device *pdev) info->screen_base =ioremap_wc (info->fix.smem_start, info->fix.smem_len);if (!info->screen_base) { -framebuffer_release (info); -return -ENODEV ; + ret = -ENODEV ; + goto error_fb_release; } info->pseudo_palette = (void *) par->palette;@@ -247,14 +247,20 @@ static int simplefb_probe(struct platform_device *pdev) ret =register_framebuffer (info);if (ret <0 ) {dev_err (&pdev->dev,"Unable to register simplefb: %d\n" , ret); -iounmap (info->screen_base); -framebuffer_release (info); -return ret; + goto error_unmap; }dev_info (&pdev->dev,"fb%d: simplefb registered!\n" , info->node);drivers/video/fbdev/simplefb.c static int simplefb_probe(struct platform_device *pdev) · line 263
Quoted 10 lines
drivers/video/fbdev/simplefb.c +8
-0return 0 ; + + error_unmap: +iounmap (info->screen_base); + + error_fb_release: +framebuffer_release (info); + +return ret;Again, I'd use different coding-style, but I will leave that to Stephen and Tomi:
Quoted 1 line
Reviewed-by David Herrmann <[email protected]>
While the discussion about the last two patches rages on, can you state what coding style changes you would like to see here, as i am not clear as to what exactly is off with the above code.
Luc Verhaegen.
PATCH 2/4 simplefb: add goto error path to probe
Hi
Quoted 60 lines · Luc Verhaegen
Quoted 59 lines · David Herrmann
Hi
Quoted 42 lines · Luc Verhaegen
Signed-off-by Luc Verhaegen <[email protected]>--- drivers/video/fbdev/simplefb.c | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-)drivers/video/fbdev/simplefb.c +5
-7@@ -220,8 +220,8 @@ static int simplefb_probe(struct platform_device *pdev) info->apertures =alloc_apertures (1 );if (!info->apertures) { -framebuffer_release (info); -return -ENOMEM ; + ret = -ENOMEM ; + goto error_fb_release; } info->apertures->ranges[0 ].base = info->fix.smem_start; info->apertures->ranges[0 ].size = info->fix.smem_len;@@ -231,8 +231,8 @@ static int simplefb_probe(struct platform_device *pdev) info->screen_base =ioremap_wc (info->fix.smem_start, info->fix.smem_len);if (!info->screen_base) { -framebuffer_release (info); -return -ENODEV ; + ret = -ENODEV ; + goto error_fb_release; } info->pseudo_palette = (void *) par->palette;@@ -247,14 +247,20 @@ static int simplefb_probe(struct platform_device *pdev) ret =register_framebuffer (info);if (ret <0 ) {dev_err (&pdev->dev,"Unable to register simplefb: %d\n" , ret); -iounmap (info->screen_base); -framebuffer_release (info); -return ret; + goto error_unmap; }dev_info (&pdev->dev,"fb%d: simplefb registered!\n" , info->node);drivers/video/fbdev/simplefb.c static int simplefb_probe(struct platform_device *pdev) · line 263
Quoted 10 lines
drivers/video/fbdev/simplefb.c +8
-0return 0 ; + + error_unmap: +iounmap (info->screen_base); + + error_fb_release: +framebuffer_release (info); + +return ret;Again, I'd use different coding-style, but I will leave that to Stephen and Tomi:
Quoted 5 lines
Quoted 1 line
Reviewed-by David Herrmann <[email protected]>While the discussion about the last two patches rages on, can you state what coding style changes you would like to see here, as i am not clear as to what exactly is off with the above code.
I'd skip the leading whitespace and the newlines, like this:
+error_unmap:
+ iounmap(info->screen_base);
+error_fb_release:
+ framebuffer_release(info);
+ return ret;
at least that's my conception how we format error paths in drivers/video/.
Thanks
David
PATCH 2/4 simplefb: add goto error path to probe
Quoted 11 lines · David Herrmann
Hi
I'd skip the leading whitespace and the newlines, like this:
drivers/video/fbdev/simplefb.c +5
-0+error_unmap: +iounmap (info->screen_base); +error_fb_release: +framebuffer_release (info); +return ret;at least that's my conception how we format error paths in
drivers/video/.
Will do. Thanks.
Luc Verhaegen.
PATCH 3/4 simplefb: disable dt node upon remove
In reply to Luc VerhaegenThe next commit will handle clocks correctly, so that these do not get automatically disabled on certain SoC simplefb implementations. As a result, the removal of this simplefb driver, and the release of the clocks, is rather final, and only a full display driver can work after this. So, it makes sense to also flag the dt node as disabled, even though it has no real value today.
--- drivers/video/fbdev/simplefb.c | 43 ++++++++++++++++++++++++++++++++++++--- 1 files changed, 39 insertions(+), 4 deletions(-)
drivers/video/fbdev/simplefb.c +39 -4
@@ -138,6 +138,32 @@ static int simplefb_parse_dt(struct platform_device *pdev,return 0 ; } +/* +* Make sure that nothing tries to inadvertedly re-use this node... +*/ +static int +simplefb_dt_disable (struct platform_device *pdev) +{ +struct device_node *np = pdev->dev.of_node; +struct property *property; +int ret; + + property =kzalloc (sizeof (struct property ),GFP_KERNEL ); +if (!property) +return -ENOMEM ; + + property->name ="status" ; + property->value ="disabled" ; + property->length =strlen (property->value) +1 ; + + ret =of_update_property (np, property); +if (ret) +dev_err (&pdev->dev,"%s: failed to update property: %d\n" , + __func__, ret); + +return ret; +} +static int simplefb_parse_pd (struct platform_device *pdev,struct simplefb_params *params) {
@@ -187,17 +213,20 @@ static int simplefb_probe(struct platform_device *pdev) ret =simplefb_parse_dt (pdev, ¶ms);if (ret) -return ret; + goto error_dt_disable; mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!mem) {dev_err (&pdev->dev,"No memory resource\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto error_dt_disable; } info =framebuffer_alloc (sizeof (struct simplefb_par ), &pdev->dev); -if (!info) -return -ENOMEM ; +if (!info) { + ret = -ENOMEM ; + goto error_dt_disable; + }platform_set_drvdata (pdev, info); par = info->par;
@@ -260,6 +289,10 @@ static int simplefb_probe(struct platform_device *pdev) error_fb_release:framebuffer_release (info); + error_dt_disable: +if (!dev_get_platdata (&pdev->dev) && pdev->dev.of_node) +simplefb_dt_disable (pdev); +return ret; }
@@ -269,6 +302,8 @@ static int simplefb_remove(struct platform_device *pdev)unregister_framebuffer (info);framebuffer_release (info); +if (!dev_get_platdata (&pdev->dev) && pdev->dev.of_node) +simplefb_dt_disable (pdev);return 0 ; }
Signature · 1 line
1.7.7
PATCH 3/4 simplefb: disable dt node upon remove
Quoted 8 lines · Luc Verhaegen
The next commit will handle clocks correctly, so that these do not get automatically disabled on certain SoC simplefb implementations. As a result, the removal of this simplefb driver, and the release of the clocks, is rather final, and only a full display driver can work after this. So, it makes sense to also flag the dt node as disabled, even though it has no real value today.
Signed-off-by Luc Verhaegen <[email protected]>
Please, no.
Drivers should not be modifying the device tree without and exceptionally good reason for doing so. Drivers are to treat the DT as immutable.
* the exception is an overlay driver which add new devices to the kernel. Definitely not the case here.
g.
Quoted 94 lines
--- drivers/video/fbdev/simplefb.c | 43 ++++++++++++++++++++++++++++++++++++--- 1 files changed, 39 insertions(+), 4 deletions(-)drivers/video/fbdev/simplefb.c +39
-5@@ -138,6 +138,32 @@ static int simplefb_parse_dt(struct platform_device *pdev,return 0 ; } +/* +* Make sure that nothing tries to inadvertedly re-use this node... +*/ +static int +simplefb_dt_disable (struct platform_device *pdev) +{ +struct device_node *np = pdev->dev.of_node; +struct property *property; +int ret; + + property =kzalloc (sizeof (struct property ),GFP_KERNEL ); +if (!property) +return -ENOMEM ; + + property->name ="status" ; + property->value ="disabled" ; + property->length =strlen (property->value) +1 ; + + ret =of_update_property (np, property); +if (ret) +dev_err (&pdev->dev,"%s: failed to update property: %d\n" , + __func__, ret); + +return ret; +} +static int simplefb_parse_pd (struct platform_device *pdev,struct simplefb_params *params) {@@ -187,17 +213,20 @@ static int simplefb_probe(struct platform_device *pdev) ret =simplefb_parse_dt (pdev, ¶ms);if (ret) -return ret; + goto error_dt_disable; mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (!mem) {dev_err (&pdev->dev,"No memory resource\n" ); -return -EINVAL ; + ret = -EINVAL ; + goto error_dt_disable; } info =framebuffer_alloc (sizeof (struct simplefb_par ), &pdev->dev); -if (!info) -return -ENOMEM ; +if (!info) { + ret = -ENOMEM ; + goto error_dt_disable; + }platform_set_drvdata (pdev, info); par = info->par;@@ -260,6 +289,10 @@ static int simplefb_probe(struct platform_device *pdev) error_fb_release:framebuffer_release (info); + error_dt_disable: +if (!dev_get_platdata (&pdev->dev) && pdev->dev.of_node) +simplefb_dt_disable (pdev); +return ret; }@@ -269,6 +302,8 @@ static int simplefb_remove(struct platform_device *pdev)unregister_framebuffer (info);framebuffer_release (info); +if (!dev_get_platdata (&pdev->dev) && pdev->dev.of_node) +simplefb_dt_disable (pdev);return 0 ; } --1.7.7
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 3/4 simplefb: disable dt node upon remove
Hi
Quoted 10 lines · Grant Likely
Quoted 8 lines · Luc Verhaegen
The next commit will handle clocks correctly, so that these do not get automatically disabled on certain SoC simplefb implementations. As a result, the removal of this simplefb driver, and the release of the clocks, is rather final, and only a full display driver can work after this. So, it makes sense to also flag the dt node as disabled, even though it has no real value today.
Signed-off-by Luc Verhaegen <[email protected]>
Quoted 8 lines
Please, no.
Drivers should not be modifying the device tree without and exceptionally good reason for doing so. Drivers are to treat the DT as immutable.
* the exception is an overlay driver which add new devices to the kernel. Definitely not the case here.
Why? I think we have exactly that case:
* DT describes the real hw properly and those parts are immutable
* Additionally, bootloaders create firmware-framebuffers and create simple-framebuffer devices for them. Those are valid as long as no driver reconfigured the real hw.
* Once a real hw-driver loads, it might destroy the existing framebuffers, thus, it should also destroy the platform device.
* If the real hw-driver is unloaded, it might re-create the FB and thus create a new (or enable the old) platform device.
Or, in a nutshell: A "simple-framebuffer" device is basically a platform-device for framebuffers. Framebuffers can be created and destroyed during runtime. The reason we create platform-devices for them, is to allow dummy drivers to be probed. Real hw-drivers obviously bind to the parent bus device.
Other ideas are obviously welcome, but so far all of the other ideas sounded like big hacks (like remove_conflicting_framebuffers() so far..).
Thanks
David
PATCH 3/4 simplefb: disable dt node upon remove
Quoted 16 lines · David Herrmann
Hi
Quoted 12 lines · Grant Likely
Quoted 8 lines · Luc Verhaegen
The next commit will handle clocks correctly, so that these do not get automatically disabled on certain SoC simplefb implementations. As a result, the removal of this simplefb driver, and the release of the clocks, is rather final, and only a full display driver can work after this. So, it makes sense to also flag the dt node as disabled, even though it has no real value today.
Signed-off-by Luc Verhaegen <[email protected]>Please, no.
Quoted 8 lines
Quoted 6 lines
Drivers should not be modifying the device tree without and exceptionally good reason for doing so. Drivers are to treat the DT as immutable.
* the exception is an overlay driver which add new devices to the kernel. Definitely not the case here.
Why?
The majority of the DT code is based on the assumption of a static tree. Pantelis has been working on being able to modify it at runtime with overlays, but he has had to go through a lot of rework because it is not a trivial task. When you get into modifying the DT, you need to have a lot more understanding of the side effects to changing the tree. The DT structure also has a lifecycle that can go beyond the current lifecycle of the kernel. The kexec tool will extract the current tree from the kernel, make the appropriate modifications, and use that to boot the next kernel. Allowing any driver to modify the tree has side effects beyond just the current kernel.
In this specific case, it will interact badly with the work Pantelis is doing to make platform devices work with overlays. Modifying the status property will cause the associated struct device to get removed in the middle of probing a driver for that device! That will most likely cause an oops.
Besides, Luc straight out *said*: "...even though it has no real value today". In what circumstance is that justification for modifying the tree?
Quoted 22 lines
I think we have exactly that case:
* DT describes the real hw properly and those parts are immutable
* Additionally, bootloaders create firmware-framebuffers and create simple-framebuffer devices for them. Those are valid as long as no driver reconfigured the real hw.
* Once a real hw-driver loads, it might destroy the existing framebuffers, thus, it should also destroy the platform device.
* If the real hw-driver is unloaded, it might re-create the FB and thus create a new (or enable the old) platform device.Or, in a nutshell: A "simple-framebuffer" device is basically a platform-device for framebuffers. Framebuffers can be created and destroyed during runtime. The reason we create platform-devices for them, is to allow dummy drivers to be probed. Real hw-drivers obviously bind to the parent bus device.
Other ideas are obviously welcome, but so far all of the other ideas sounded like big hacks (like
remove_conflicting_framebuffers()so far..).Thanks
David
PATCH 3/4 simplefb: disable dt node upon remove
Hi
Quoted 8 lines · Grant Likely
Quoted 6 lines · David Herrmann
Quoted 2 lines · Grant Likely
* the exception is an overlay driver which add new devices to the kernel. Definitely not the case here.
Why?
Quoted 10 lines
The majority of the DT code is based on the assumption of a static tree. Pantelis has been working on being able to modify it at runtime with overlays, but he has had to go through a lot of rework because it is not a trivial task. When you get into modifying the DT, you need to have a lot more understanding of the side effects to changing the tree. The DT structure also has a lifecycle that can go beyond the current lifecycle of the kernel. The kexec tool will extract the current tree from the kernel, make the appropriate modifications, and use that to boot the next kernel. Allowing any driver to modify the tree has side effects beyond just the current kernel.
Ok, fair enough. So we leave the DT untouched. That still allows calling device_add() / device_del() on platform-devices, right?
Quoted 9 lines
In this specific case, it will interact badly with the work Pantelis is doing to make platform devices work with overlays. Modifying the status property will cause the associated struct device to get removed in the middle of probing a driver for that device! That will most likely cause an oops.
Besides, Luc straight out *said*: "...even though it has no real value today". In what circumstance is that justification for modifying the tree?
Sorry, I wasn't clear enough: I'm not arguing in favor of this patch. I just want to figure out what to do once we implement hardware-handover for graphics devices on non-x86 (which this series is kinda preparing for). This patch just reminded me, that we could do this on a DT level, instead of driver-core level. But I'm fine with avoiding that, if you warn about complications.
Thanks
David
PATCH 3/4 simplefb: disable dt node upon remove
In reply to Grant LikelyQuoted 18 lines · Grant Likely
The majority of the DT code is based on the assumption of a static tree. Pantelis has been working on being able to modify it at runtime with overlays, but he has had to go through a lot of rework because it is not a trivial task. When you get into modifying the DT, you need to have a lot more understanding of the side effects to changing the tree. The DT structure also has a lifecycle that can go beyond the current lifecycle of the kernel. The kexec tool will extract the current tree from the kernel, make the appropriate modifications, and use that to boot the next kernel. Allowing any driver to modify the tree has side effects beyond just the current kernel.
In this specific case, it will interact badly with the work Pantelis is doing to make platform devices work with overlays. Modifying the status property will cause the associated struct device to get removed in the middle of probing a driver for that device! That will most likely cause an oops.
Quoted 3 lines
Besides, Luc straight out *said*: "...even though it has no real value today". In what circumstance is that justification for modifying the tree?
With that sentence i meant that given the current state of things, it has no real value.
It has no value currently as re-probing simplefb is not going to happen. But it's not a big leap to turn simplefb into a proper module. Not that that makes much sense, but that's never stopped anyone.
To me it seemed simple, dt is what drives simplefb, so dt then also becomes responsible for making sure that simplefb or another driver does not attempt to blindly use this info again. The way this is implemented i do not care for in any way, i just knew that i could not do nothing here, given the catastrophic effect disabling the clocks has on simplefb on sunxi. Given the discussion that errupted here, i'd say that this does need some resolution, and altering the dt is going to have to be part of the solution.
In any case, i will gladly drop this patch, as it is not absolutely necessary. But it should be very clear that there is no going back on this dt node after the clocks were released once.
Luc Verhaegen.
[linux-sunxi] Re: [PATCH 3/4] simplefb: disable dt node upon remove
Quoted 39 lines · Luc Verhaegen
Quoted 18 lines · Grant Likely
The majority of the DT code is based on the assumption of a static tree. Pantelis has been working on being able to modify it at runtime with overlays, but he has had to go through a lot of rework because it is not a trivial task. When you get into modifying the DT, you need to have a lot more understanding of the side effects to changing the tree. The DT structure also has a lifecycle that can go beyond the current lifecycle of the kernel. The kexec tool will extract the current tree from the kernel, make the appropriate modifications, and use that to boot the next kernel. Allowing any driver to modify the tree has side effects beyond just the current kernel.
In this specific case, it will interact badly with the work Pantelis is doing to make platform devices work with overlays. Modifying the status property will cause the associated struct device to get removed in the middle of probing a driver for that device! That will most likely cause an oops.
Quoted 3 lines
Besides, Luc straight out *said*: "...even though it has no real value today". In what circumstance is that justification for modifying the tree?
With that sentence i meant that given the current state of things, it has no real value.
It has no value currently as re-probing simplefb is not going to happen. But it's not a big leap to turn simplefb into a proper module. Not that that makes much sense, but that's never stopped anyone.
To me it seemed simple, dt is what drives simplefb, so dt then also becomes responsible for making sure that simplefb or another driver does not attempt to blindly use this info again. The way this is implemented i do not care for in any way, i just knew that i could not do nothing here, given the catastrophic effect disabling the clocks has on simplefb on sunxi. Given the discussion that errupted here, i'd say that this does need some resolution, and altering the dt is going to have to be part of the solution.
Quoted 5 lines
In any case, i will gladly drop this patch, as it is not absolutely necessary. But it should be very clear that there is no going back on this dt node after the clocks were released once.
Luc Verhaegen.
What about approaching this from the other end? U-Boot could add a property named "once-only" or so.
Luc Verhaegen.
[linux-sunxi] Re: [PATCH 3/4] simplefb: disable dt node upon remove
Quoted 40 lines · Luc Verhaegen
Quoted 39 lines · Luc Verhaegen
Quoted 18 lines · Grant Likely
The majority of the DT code is based on the assumption of a static tree. Pantelis has been working on being able to modify it at runtime with overlays, but he has had to go through a lot of rework because it is not a trivial task. When you get into modifying the DT, you need to have a lot more understanding of the side effects to changing the tree. The DT structure also has a lifecycle that can go beyond the current lifecycle of the kernel. The kexec tool will extract the current tree from the kernel, make the appropriate modifications, and use that to boot the next kernel. Allowing any driver to modify the tree has side effects beyond just the current kernel.
In this specific case, it will interact badly with the work Pantelis is doing to make platform devices work with overlays. Modifying the status property will cause the associated struct device to get removed in the middle of probing a driver for that device! That will most likely cause an oops.
Quoted 3 lines
Besides, Luc straight out *said*: "...even though it has no real value today". In what circumstance is that justification for modifying the tree?
With that sentence i meant that given the current state of things, it has no real value.
It has no value currently as re-probing simplefb is not going to happen. But it's not a big leap to turn simplefb into a proper module. Not that that makes much sense, but that's never stopped anyone.
To me it seemed simple, dt is what drives simplefb, so dt then also becomes responsible for making sure that simplefb or another driver does not attempt to blindly use this info again. The way this is implemented i do not care for in any way, i just knew that i could not do nothing here, given the catastrophic effect disabling the clocks has on simplefb on sunxi. Given the discussion that errupted here, i'd say that this does need some resolution, and altering the dt is going to have to be part of the solution.
Quoted 8 lines
Quoted 5 lines
In any case, i will gladly drop this patch, as it is not absolutely necessary. But it should be very clear that there is no going back on this dt node after the clocks were released once.
Luc Verhaegen.
What about approaching this from the other end? U-Boot could add a property named "once-only" or so.
Device tree is supposed to be a static description of the hardware usable on all operating systems. It is the wrong mechanism for communicating between uboot and the kernel. Use something like atags or the kernel command line to tell the kernel that the console has already been set up.
The switch over from simple to KMS should not be done via a node add/del to the device tree either. No one has removed the device from the system, the device tree should not be changing.
Some Linux mechanism inside the kernel needs to handle that transition. Somehow simple needs to hang onto the clocks, let go of the device, load KMS, then exit?
Quoted 7 lines
Luc Verhaegen.
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe at googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
[linux-sunxi] Re: [PATCH 3/4] simplefb: disable dt node upon remove
Quoted 47 lines · jonsmirl at gmail.com
Quoted 46 lines · Luc Verhaegen
Quoted 44 lines · Luc Verhaegen
Quoted 18 lines · Grant Likely
The majority of the DT code is based on the assumption of a static tree. Pantelis has been working on being able to modify it at runtime with overlays, but he has had to go through a lot of rework because it is not a trivial task. When you get into modifying the DT, you need to have a lot more understanding of the side effects to changing the tree. The DT structure also has a lifecycle that can go beyond the current lifecycle of the kernel. The kexec tool will extract the current tree from the kernel, make the appropriate modifications, and use that to boot the next kernel. Allowing any driver to modify the tree has side effects beyond just the current kernel.
In this specific case, it will interact badly with the work Pantelis is doing to make platform devices work with overlays. Modifying the status property will cause the associated struct device to get removed in the middle of probing a driver for that device! That will most likely cause an oops.
Quoted 3 lines
Besides, Luc straight out *said*: "...even though it has no real value today". In what circumstance is that justification for modifying the tree?
With that sentence i meant that given the current state of things, it has no real value.
It has no value currently as re-probing simplefb is not going to happen. But it's not a big leap to turn simplefb into a proper module. Not that that makes much sense, but that's never stopped anyone.
To me it seemed simple, dt is what drives simplefb, so dt then also becomes responsible for making sure that simplefb or another driver does not attempt to blindly use this info again. The way this is implemented i do not care for in any way, i just knew that i could not do nothing here, given the catastrophic effect disabling the clocks has on simplefb on sunxi. Given the discussion that errupted here, i'd say that this does need some resolution, and altering the dt is going to have to be part of the solution.
In any case, i will gladly drop this patch, as it is not absolutely necessary. But it should be very clear that there is no going back on this dt node after the clocks were released once.
Luc Verhaegen.
Quoted 8 lines
Quoted 2 lines
What about approaching this from the other end? U-Boot could add a property named "once-only" or so.
Device tree is supposed to be a static description of the hardware usable on all operating systems. It is the wrong mechanism for communicating between uboot and the kernel. Use something like atags or the kernel command line to tell the kernel that the console has already been set up.
Not accurate. While it is primarily hardware description, it is also used for firmware communication. There is loads of precedence for this. The /chosen node is the most significant example, but there are other places where the tree is used to provide state. For example, the current-speed property on UART nodes.
Quoted 3 lines
The switch over from simple to KMS should not be done via a node add/del to the device tree either. No one has removed the device from the system, the device tree should not be changing.
The simple-framebuffer binding appears to be insufficient in this regard in that it doesn't have any linkage with the actual device providing the framebuffer. Ideally, I would put the simple framebuffer state directly into the video device node and use the chosen node to point to the stdout device (probably with the stdout-path property). Then the driver already knows it can just ignore the simple properties because it owns the device node when it binds.
That said, simple-framebuffer as it stands is in use so we're not going to deprecate it. I would like to see an addition that specifies how a controller can be associated with a simple framebuffer node.
BTW, Is anyone currently using the simple framebuffer for early console? For early console we would want to start using it well before setting up platform devices.
g.
PATCH 3/4 simplefb: disable dt node upon remove
Quoted 4 lines · Grant Likely
BTW, Is anyone currently using the simple framebuffer for early console? For early console we would want to start using it well before setting up platform devices.
The code that sets up simplefb for sunxi is primarily for providing a console in u-boot (using the ancient cfbconsole infrastructure). From what i can tell, the u-boot code for rpi is about showing a splash screen (using the much newer lcd infrastructure).
With u-boot showing a console, it really seemed only a small step to add simplefb. And quite a few people in our sunxi community are interested in it, primarily for u-boot and early console, and only secondarily as a stop-gap for a full driver.
Luc Verhaegen.
PATCH 3/4 simplefb: disable dt node upon remove
Quoted 10 lines · Luc Verhaegen
Quoted 4 lines · Grant Likely
BTW, Is anyone currently using the simple framebuffer for early console? For early console we would want to start using it well before setting up platform devices.
The code that sets up simplefb for sunxi is primarily for providing a console in u-boot (using the ancient cfbconsole infrastructure). From what i can tell, the u-boot code for rpi is about showing a splash screen (using the much newer lcd infrastructure).
There's no splash screen on the Pi in the upstream U-Boot code. The LCD displays the U-Boot console/stdout. If USB support for the Pi's USB host is ever sent upstream, that will allow the user to use USB/LCD for U-Boot control, rather than serial.
PATCH 3/4 simplefb: disable dt node upon remove
Quoted 11 lines · Stephen Warren
Quoted 5 lines · Luc Verhaegen
The code that sets up simplefb for sunxi is primarily for providing a console in u-boot (using the ancient cfbconsole infrastructure). From what i can tell, the u-boot code for rpi is about showing a splash screen (using the much newer lcd infrastructure).
There's no splash screen on the Pi in the upstream U-Boot code. The LCD displays the U-Boot console/stdout. If USB support for the Pi's USB host is ever sent upstream, that will allow the user to use USB/LCD for U-Boot control, rather than serial.
Ah ok, i hadn't immediately found a tie with the lcd code and cfbconsole code, so apparently i didn't dig down far enough.
Luc Verhaegen.
PATCH 3/4 simplefb: disable dt node upon remove
In reply to Luc VerhaegenQuoted 11 lines · Luc Verhaegen
Quoted 4 lines · Grant Likely
BTW, Is anyone currently using the simple framebuffer for early console? For early console we would want to start using it well before setting up platform devices.
The code that sets up simplefb for sunxi is primarily for providing a console in u-boot (using the ancient cfbconsole infrastructure). From what i can tell, the u-boot code for rpi is about showing a splash screen (using the much newer lcd infrastructure).
Quoted 4 lines
With u-boot showing a console, it really seemed only a small step to add simplefb. And quite a few people in our sunxi community are interested in it, primarily for u-boot and early console, and only secondarily as a stop-gap for a full driver.
Both of which make sense and should be supported, so I agree we need to find a solution.
The problem I think comes down to the handoff mechanism. There are a lot of different video controllers which could all be configured for a simple framebuffer.
I don't think the "run this only once" test is the right approach. Sometimes the simple framebuffer will never be torn down. It is conceivable that a simple framebuffer will get /added/ at runtime with an overlay, or even rebound to the driver. The simple framebuffer driver really needs to be explicitly told from outside itself that it is being taken over since it doesn't actually have the information to know when a framebuffer becomes invalid. Only the real video driver can provide that information.
How does the sunxi driver currently take over from the simplefb?
g.
PATCH 3/4 simplefb: disable dt node upon remove
Quoted 8 lines · Grant Likely
Both of which make sense and should be supported, so I agree we need to find a solution.
The problem I think comes down to the handoff mechanism. There are a lot of different video controllers which could all be configured for a simple framebuffer.
Quoted 8 lines
I don't think the "run this only once" test is the right approach. Sometimes the simple framebuffer will never be torn down. It is conceivable that a simple framebuffer will get /added/ at runtime with an overlay, or even rebound to the driver. The simple framebuffer driver really needs to be explicitly told from outside itself that it is being taken over since it doesn't actually have the information to know when a framebuffer becomes invalid. Only the real video driver can provide that information.
There really are two separate issues here:
1) making sure that nothing tries to use the freshly died simplefb again.
2) doing a clean handover to another, usually hw specific, driver.
1 is what i hoped to superficially solve with this patch. 2 can be very smart about things as the replacement driver actually should know the hw.
I kind of like the idea of an "only-once" (there must be a better name for this) property. This allows the driver/device infrastructure to handle things much more cleanly, and allows me to state this from u-boot for sunxi, while Stephen wouldn't need to for rpi. I currently don't know how or where this could be handled, i just know that this smells like a decent solution which could solve my concern while at least avoiding the probe issue you mentioned earlier.
Quoted 1 line
How does the sunxi driver currently take over from the simplefb?
Not at all. A big blob of KMS code exists for our sunxi-3.4 kernel, where i can load the original display driver quickly and easily. This tree predates most of DT. I was rather hoping that the simplefb stop-gap didn't require me to have fully engineered everything yesterday already.
Luc Verhaegen.
[linux-sunxi] Re: [PATCH 3/4] simplefb: disable dt node upon remove
In reply to Grant LikelyQuoted 57 lines · Grant Likely
Quoted 47 lines · jonsmirl at gmail.com
Quoted 46 lines · Luc Verhaegen
Quoted 44 lines · Luc Verhaegen
Quoted 18 lines · Grant Likely
The majority of the DT code is based on the assumption of a static tree. Pantelis has been working on being able to modify it at runtime with overlays, but he has had to go through a lot of rework because it is not a trivial task. When you get into modifying the DT, you need to have a lot more understanding of the side effects to changing the tree. The DT structure also has a lifecycle that can go beyond the current lifecycle of the kernel. The kexec tool will extract the current tree from the kernel, make the appropriate modifications, and use that to boot the next kernel. Allowing any driver to modify the tree has side effects beyond just the current kernel.
In this specific case, it will interact badly with the work Pantelis is doing to make platform devices work with overlays. Modifying the status property will cause the associated struct device to get removed in the middle of probing a driver for that device! That will most likely cause an oops.
Quoted 3 lines
Besides, Luc straight out *said*: "...even though it has no real value today". In what circumstance is that justification for modifying the tree?
With that sentence i meant that given the current state of things, it has no real value.
It has no value currently as re-probing simplefb is not going to happen. But it's not a big leap to turn simplefb into a proper module. Not that that makes much sense, but that's never stopped anyone.
To me it seemed simple, dt is what drives simplefb, so dt then also becomes responsible for making sure that simplefb or another driver does not attempt to blindly use this info again. The way this is implemented i do not care for in any way, i just knew that i could not do nothing here, given the catastrophic effect disabling the clocks has on simplefb on sunxi. Given the discussion that errupted here, i'd say that this does need some resolution, and altering the dt is going to have to be part of the solution.
In any case, i will gladly drop this patch, as it is not absolutely necessary. But it should be very clear that there is no going back on this dt node after the clocks were released once.
Luc Verhaegen.
Quoted 8 lines
Quoted 2 lines
What about approaching this from the other end? U-Boot could add a property named "once-only" or so.
Device tree is supposed to be a static description of the hardware usable on all operating systems. It is the wrong mechanism for communicating between uboot and the kernel. Use something like atags or the kernel command line to tell the kernel that the console has already been set up.
Quoted 5 lines
Not accurate. While it is primarily hardware description, it is also used for firmware communication. There is loads of precedence for this. The /chosen node is the most significant example, but there are other places where the tree is used to provide state. For example, the current-speed property on UART nodes.
I do seem to recall you telling me a long time ago that those chosen nodes were a mistake (or maybe it was Matt Sealey). I'm pretty wary of opening to door to device trees carrying a bunch of state. Five years from now the DT is going to look like a Christmas tree.
Quoted 22 lines
Quoted 4 lines
The switch over from simple to KMS should not be done via a node add/del to the device tree either. No one has removed the device from the system, the device tree should not be changing.
The simple-framebuffer binding appears to be insufficient in this regard in that it doesn't have any linkage with the actual device providing the framebuffer. Ideally, I would put the simple framebuffer state directly into the video device node and use the chosen node to point to the stdout device (probably with the stdout-path property). Then the driver already knows it can just ignore the simple properties because it owns the device node when it binds.
That said, simple-framebuffer as it stands is in use so we're not going to deprecate it. I would like to see an addition that specifies how a controller can be associated with a simple framebuffer node.
BTW, Is anyone currently using the simple framebuffer for early console? For early console we would want to start using it well before setting up platform devices.
g.
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
[linux-sunxi] Re: [PATCH 3/4] simplefb: disable dt node upon remove
Quoted 64 lines · jonsmirl at gmail.com
Quoted 57 lines · Grant Likely
Quoted 47 lines · jonsmirl at gmail.com
Quoted 46 lines · Luc Verhaegen
Quoted 44 lines · Luc Verhaegen
Quoted 18 lines · Grant Likely
The majority of the DT code is based on the assumption of a static tree. Pantelis has been working on being able to modify it at runtime with overlays, but he has had to go through a lot of rework because it is not a trivial task. When you get into modifying the DT, you need to have a lot more understanding of the side effects to changing the tree. The DT structure also has a lifecycle that can go beyond the current lifecycle of the kernel. The kexec tool will extract the current tree from the kernel, make the appropriate modifications, and use that to boot the next kernel. Allowing any driver to modify the tree has side effects beyond just the current kernel.
In this specific case, it will interact badly with the work Pantelis is doing to make platform devices work with overlays. Modifying the status property will cause the associated struct device to get removed in the middle of probing a driver for that device! That will most likely cause an oops.
Quoted 3 lines
Besides, Luc straight out *said*: "...even though it has no real value today". In what circumstance is that justification for modifying the tree?
With that sentence i meant that given the current state of things, it has no real value.
It has no value currently as re-probing simplefb is not going to happen. But it's not a big leap to turn simplefb into a proper module. Not that that makes much sense, but that's never stopped anyone.
To me it seemed simple, dt is what drives simplefb, so dt then also becomes responsible for making sure that simplefb or another driver does not attempt to blindly use this info again. The way this is implemented i do not care for in any way, i just knew that i could not do nothing here, given the catastrophic effect disabling the clocks has on simplefb on sunxi. Given the discussion that errupted here, i'd say that this does need some resolution, and altering the dt is going to have to be part of the solution.
In any case, i will gladly drop this patch, as it is not absolutely necessary. But it should be very clear that there is no going back on this dt node after the clocks were released once.
Luc Verhaegen.
Quoted 8 lines
Quoted 2 lines
What about approaching this from the other end? U-Boot could add a property named "once-only" or so.
Device tree is supposed to be a static description of the hardware usable on all operating systems. It is the wrong mechanism for communicating between uboot and the kernel. Use something like atags or the kernel command line to tell the kernel that the console has already been set up.
Quoted 5 lines
Not accurate. While it is primarily hardware description, it is also used for firmware communication. There is loads of precedence for this. The /chosen node is the most significant example, but there are other places where the tree is used to provide state. For example, the current-speed property on UART nodes.
Quoted 4 lines
I do seem to recall you telling me a long time ago that those chosen nodes were a mistake (or maybe it was Matt Sealey). I'm pretty wary of opening to door to device trees carrying a bunch of state. Five years from now the DT is going to look like a Christmas tree.
Wasn't me. Carrying state in the DT provided by firmware is perfectly reasonable in my opinion.
g.
[linux-sunxi] Re: [PATCH 3/4] simplefb: disable dt node upon remove
Quoted 65 lines · Grant Likely
Quoted 64 lines · jonsmirl at gmail.com
Quoted 62 lines · Grant Likely
Quoted 47 lines · jonsmirl at gmail.com
Quoted 46 lines · Luc Verhaegen
Quoted 44 lines · Luc Verhaegen
Quoted 18 lines · Grant Likely
The majority of the DT code is based on the assumption of a static tree. Pantelis has been working on being able to modify it at runtime with overlays, but he has had to go through a lot of rework because it is not a trivial task. When you get into modifying the DT, you need to have a lot more understanding of the side effects to changing the tree. The DT structure also has a lifecycle that can go beyond the current lifecycle of the kernel. The kexec tool will extract the current tree from the kernel, make the appropriate modifications, and use that to boot the next kernel. Allowing any driver to modify the tree has side effects beyond just the current kernel.
In this specific case, it will interact badly with the work Pantelis is doing to make platform devices work with overlays. Modifying the status property will cause the associated struct device to get removed in the middle of probing a driver for that device! That will most likely cause an oops.
Quoted 3 lines
Besides, Luc straight out *said*: "...even though it has no real value today". In what circumstance is that justification for modifying the tree?
With that sentence i meant that given the current state of things, it has no real value.
It has no value currently as re-probing simplefb is not going to happen. But it's not a big leap to turn simplefb into a proper module. Not that that makes much sense, but that's never stopped anyone.
To me it seemed simple, dt is what drives simplefb, so dt then also becomes responsible for making sure that simplefb or another driver does not attempt to blindly use this info again. The way this is implemented i do not care for in any way, i just knew that i could not do nothing here, given the catastrophic effect disabling the clocks has on simplefb on sunxi. Given the discussion that errupted here, i'd say that this does need some resolution, and altering the dt is going to have to be part of the solution.
In any case, i will gladly drop this patch, as it is not absolutely necessary. But it should be very clear that there is no going back on this dt node after the clocks were released once.
Luc Verhaegen.
Quoted 8 lines
Quoted 2 lines
What about approaching this from the other end? U-Boot could add a property named "once-only" or so.
Device tree is supposed to be a static description of the hardware usable on all operating systems. It is the wrong mechanism for communicating between uboot and the kernel. Use something like atags or the kernel command line to tell the kernel that the console has already been set up.
Not accurate. While it is primarily hardware description, it is also used for firmware communication. There is loads of precedence for this. The /chosen node is the most significant example, but there are other places where the tree is used to provide state. For example, the current-speed property on UART nodes.
Quoted 7 lines
Quoted 4 lines
I do seem to recall you telling me a long time ago that those chosen nodes were a mistake (or maybe it was Matt Sealey). I'm pretty wary of opening to door to device trees carrying a bunch of state. Five years from now the DT is going to look like a Christmas tree.
Wasn't me. Carrying state in the DT provided by firmware is perfectly reasonable in my opinion.
So what are the rules going to be? Once the OS is up and starts changing things the state in the DT and the OS are going to diverge. How does this get handled for a kernel driver that can load/unload? Should the kernel remove those state nodes as soon as it alters the state?
Quoted 2 lines
g.
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
[linux-sunxi] Re: [PATCH 3/4] simplefb: disable dt node upon remove
tor 2014-08-14 klockan 08:07 -0400 skrev jonsmirl at gmail.com:
Quoted 5 lines
So what are the rules going to be? Once the OS is up and starts changing things the state in the DT and the OS are going to diverge. How does this get handled for a kernel driver that can load/unload? Should the kernel remove those state nodes as soon as it alters the state?
hardware that is no longer there should also not be represented/active in DT.
A simple fb that have been torn down is no more, no different from never having been there. It can be argued that it never was in the first place (i.e. that it is not actually hardware) but that it another can of worms and both have their benefits and drawbacks. One thing is certain however, as far as simplefb is concerned it is hardware, not really any different from a persistent framebuffer with hardwired settings in hardware.
Regarding kexec, it's the responsibility of the kernel doing kexec to make sure DT and hardware matches for the next started kernel. With hardware that can be reconfigured it is not safe to assume that the DT can be passed as-is from before the kernel reconfigured hardware. If the currently running kernel wants to set up a framebuffer for simplefb use by the next kernel than it's free to do so, but in either case it needs to provide the right information to next kernel.
If it was given a simplefb node, but then killed the simplefb then no simplefb node should be provided to the next kernel. If it was not given a simplefb node, but have configured the hardware suitable for simplefb node then it may provide a simplefb node.
A UART that have changed rate no longer have that rate.
Same applies to numerous other items as well. If a kernel remaps IRQs, bus addresses, or whatever in hardware aspects where such changes is possible then DT needs to be updated as well. A bit less common than a simplefb being destroyed by driver reconfiguring the framebuffer, but if you look at it from a little distance then the problem is exactly the same. Hardware is not 100% static, and therefore hardware description also can not be 100% static. And hardware is getting more and more dynamically reconfigurable.
A DT that contains false information is generally worse than no DT / not having that information at all.
Regards
Henrik
[linux-sunxi] Re: [PATCH 3/4] simplefb: disable dt node upon remove
Quoted 11 lines · Henrik Nordstr?m
tor 2014-08-14 klockan 08:07 -0400 skrev jonsmirl at gmail.com:
Quoted 5 lines
So what are the rules going to be? Once the OS is up and starts changing things the state in the DT and the OS are going to diverge. How does this get handled for a kernel driver that can load/unload? Should the kernel remove those state nodes as soon as it alters the state?
hardware that is no longer there should also not be represented/active in DT.
Quoted 7 lines
A simple fb that have been torn down is no more, no different from never having been there. It can be argued that it never was in the first place (i.e. that it is not actually hardware) but that it another can of worms and both have their benefits and drawbacks. One thing is certain however, as far as simplefb is concerned it is hardware, not really any different from a persistent framebuffer with hardwired settings in hardware.
How does the kernel know what clocks to protect? A list in the simplefb node? This list of clocks is a reason for adding simplefb to the compatible list for the real hardware. That way it won't be duplicated.
The issues with parameter conflicts between simplefb and the real hardware can be dealt with. If the real hardware wants to add the simplefb compatible field it will need to get its parameters sorted out so that they don't conflict. Clock syntax is standardized in the DTS so it shouldn't be a problem.
You can also argue that simplefb should never occur in a DTS file. It is something that uboot will add. And then the kernel will remove when simplefb loads KMS.
That logic should apply to all of these dynamic fields. You don't want stale state data in the DT.
Quoted 31 lines
Regarding kexec, it's the responsibility of the kernel doing kexec to make sure DT and hardware matches for the next started kernel. With hardware that can be reconfigured it is not safe to assume that the DT can be passed as-is from before the kernel reconfigured hardware. If the currently running kernel wants to set up a framebuffer for simplefb use by the next kernel than it's free to do so, but in either case it needs to provide the right information to next kernel.
If it was given a simplefb node, but then killed the simplefb then no simplefb node should be provided to the next kernel. If it was not given a simplefb node, but have configured the hardware suitable for simplefb node then it may provide a simplefb node.
A UART that have changed rate no longer have that rate.
Same applies to numerous other items as well. If a kernel remaps IRQs, bus addresses, or whatever in hardware aspects where such changes is possible then DT needs to be updated as well. A bit less common than a simplefb being destroyed by driver reconfiguring the framebuffer, but if you look at it from a little distance then the problem is exactly the same. Hardware is not 100% static, and therefore hardware description also can not be 100% static. And hardware is getting more and more dynamically reconfigurable.
A DT that contains false information is generally worse than no DT / not having that information at all.
Regards
Henrik
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
[linux-sunxi] Re: [PATCH 3/4] simplefb: disable dt node upon remove
Quoted 26 lines · jonsmirl at gmail.com
Quoted 11 lines · Henrik Nordstr?m
tor 2014-08-14 klockan 08:07 -0400 skrev jonsmirl at gmail.com:
Quoted 5 lines
So what are the rules going to be? Once the OS is up and starts changing things the state in the DT and the OS are going to diverge. How does this get handled for a kernel driver that can load/unload? Should the kernel remove those state nodes as soon as it alters the state?
hardware that is no longer there should also not be represented/active in DT.
Quoted 7 lines
A simple fb that have been torn down is no more, no different from never having been there. It can be argued that it never was in the first place (i.e. that it is not actually hardware) but that it another can of worms and both have their benefits and drawbacks. One thing is certain however, as far as simplefb is concerned it is hardware, not really any different from a persistent framebuffer with hardwired settings in hardware.
How does the kernel know what clocks to protect? A list in the simplefb node? This list of clocks is a reason for adding simplefb to the compatible list for the real hardware. That way it won't be duplicated.
Quoted 5 lines
The issues with parameter conflicts between simplefb and the real hardware can be dealt with. If the real hardware wants to add the simplefb compatible field it will need to get its parameters sorted out so that they don't conflict. Clock syntax is standardized in the DTS so it shouldn't be a problem.
It shouldn't be, but apparently, some disagree.
Anyway, I'm not sure having the simplefb compatible would work in this use-case, mainly for two reasons:
- Most likely, the bindings are going to be very different. Not only about which properties you'll have, but also what you will place in these properties. reg for example have the memory address of the buffer in the simplefb case, while in the KMS driver case, it would have the memory address of the registers.
- There's will be a single driver probed. So if you want to go down the hand over road (which is a bit premature at this point if you ask me, but anyway), you will have no driver probed to hand over to.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140815/3cb2347d/attachment.sig>
[linux-sunxi] Re: [PATCH 3/4] simplefb: disable dt node upon remove
Quoted 35 lines · Maxime Ripard
Quoted 26 lines · jonsmirl at gmail.com
Quoted 11 lines · Henrik Nordstr?m
tor 2014-08-14 klockan 08:07 -0400 skrev jonsmirl at gmail.com:
Quoted 5 lines
So what are the rules going to be? Once the OS is up and starts changing things the state in the DT and the OS are going to diverge. How does this get handled for a kernel driver that can load/unload? Should the kernel remove those state nodes as soon as it alters the state?
hardware that is no longer there should also not be represented/active in DT.
Quoted 7 lines
A simple fb that have been torn down is no more, no different from never having been there. It can be argued that it never was in the first place (i.e. that it is not actually hardware) but that it another can of worms and both have their benefits and drawbacks. One thing is certain however, as far as simplefb is concerned it is hardware, not really any different from a persistent framebuffer with hardwired settings in hardware.
How does the kernel know what clocks to protect? A list in the simplefb node? This list of clocks is a reason for adding simplefb to the compatible list for the real hardware. That way it won't be duplicated.
Quoted 5 lines
The issues with parameter conflicts between simplefb and the real hardware can be dealt with. If the real hardware wants to add the simplefb compatible field it will need to get its parameters sorted out so that they don't conflict. Clock syntax is standardized in the DTS so it shouldn't be a problem.
It shouldn't be, but apparently, some disagree.
Quoted 11 lines
Anyway, I'm not sure having the simplefb compatible would work in this use-case, mainly for two reasons:
- Most likely, the bindings are going to be very different. Not only about which properties you'll have, but also what you will place in these properties. reg for example have the memory address of the buffer in the simplefb case, while in the KMS driver case, it would have the memory address of the registers.
- There's will be a single driver probed. So if you want to go down the hand over road (which is a bit premature at this point if you ask me, but anyway), you will have no driver probed to hand over to.
The graphic drivers have already been down this road before. Simplefb should be a driver library not a driver. DRM is also a driver library.
So to implement simplefb whip up a real skeleton driver for the video hardware that parses the DT and then pokes the appropriate info into the simplefb library. Initially that driver will just include the calls out to the simplefb library. Later on it can get KMS implemented. This real driver will get bound to the hardware and have a dependency that loads the simplefb driver library.
Now there is no handover problem. Only a single driver is ever attached to the hardware. When it wants to go into KMS mode it makes a call into the simplefb library to shut down whatever it is doing.
But you still need a mechanism for uboot to signal that it has set up simplefb. Adding a dynamic node like this might work...
video0: video at 01c21800 {
compatible = "allwinner,sun4i-a10-video";
clocks = <&apb0_gates 6>, <&ir0_clk>;
clock-names = "apb", "video";
interrupts = <0 5 4>;
reg = <0x01c21800 0x40>;
status = "enabled";
simplefb {
new namespace for simplefb parameters
}
};
I would have suggested a driver library earlier but it has been a while since I worked on DRM and I forgot about it.
Quoted 7 lines
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
PATCH 3/4 simplefb: disable dt node upon remove
In reply to David HerrmannQuoted 23 lines · David Herrmann
Hi
Quoted 10 lines · Grant Likely
Quoted 8 lines · Luc Verhaegen
The next commit will handle clocks correctly, so that these do not get automatically disabled on certain SoC simplefb implementations. As a result, the removal of this simplefb driver, and the release of the clocks, is rather final, and only a full display driver can work after this. So, it makes sense to also flag the dt node as disabled, even though it has no real value today.
Signed-off-by Luc Verhaegen <[email protected]>Quoted 8 lines
Please, no.
Drivers should not be modifying the device tree without and exceptionally good reason for doing so. Drivers are to treat the DT as immutable.
* the exception is an overlay driver which add new devices to the kernel. Definitely not the case here.
Quoted 9 lines
Why? I think we have exactly that case:
* DT describes the real hw properly and those parts are immutable
* Additionally, bootloaders create firmware-framebuffers and create simple-framebuffer devices for them. Those are valid as long as no driver reconfigured the real hw.
* Once a real hw-driver loads, it might destroy the existing framebuffers, thus, it should also destroy the platform device.
* If the real hw-driver is unloaded, it might re-create the FB and thus create a new (or enable the old) platform device.
My intention was always that a bootloader's addition of a simplefb node to the DT would be user-configurable or driven by the original DT content. As such, there shouldn't ever be both a DT node describing the "real" HW and simplefb. In other words, if the DT already has the "real" DT node, the bootloader should automatically (or under user command) not add the simpefb node.
[linux-sunxi] Re: [PATCH 3/4] simplefb: disable dt node upon remove
Quoted 40 lines · Stephen Warren
Quoted 28 lines · David Herrmann
Hi
Quoted 13 lines · Grant Likely
Quoted 9 lines · Luc Verhaegen
The next commit will handle clocks correctly, so that these do not get automatically disabled on certain SoC simplefb implementations. As a result, the removal of this simplefb driver, and the release of the clocks, is rather final, and only a full display driver can work after this. So, it makes sense to also flag the dt node as disabled, even though it has no real value today.
Signed-off-by Luc Verhaegen <[email protected]>Quoted 8 lines
Please, no.
Drivers should not be modifying the device tree without and exceptionally good reason for doing so. Drivers are to treat the DT as immutable.
* the exception is an overlay driver which add new devices to the kernel. Definitely not the case here.
Quoted 9 lines
Why? I think we have exactly that case:
* DT describes the real hw properly and those parts are immutable
* Additionally, bootloaders create firmware-framebuffers and create simple-framebuffer devices for them. Those are valid as long as no driver reconfigured the real hw.
* Once a real hw-driver loads, it might destroy the existing framebuffers, thus, it should also destroy the platform device.
* If the real hw-driver is unloaded, it might re-create the FB and thus create a new (or enable the old) platform device.
Quoted 6 lines
My intention was always that a bootloader's addition of a simplefb node to the DT would be user-configurable or driven by the original DT content. As such, there shouldn't ever be both a DT node describing the "real" HW and simplefb. In other words, if the DT already has the "real" DT node, the bootloader should automatically (or under user command) not add the simpefb node.
DT is just the wrong mechanism to signal this, use an ATAG or kernel command line parameter.
real hardware has compatible = "real-hardware-name, simplefb"
simplefb is built into kernel. It will attach to the device because of the compatible string. Then it can look at the command line and see if the bootloader also supported simplefb and already set things up.
Then some mechanism will have to be designed to arrange a handoff between simplefb and the chip specific KMS driver. But that's a Linux problem, not a DT one.
Quoted 8 lines
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe at googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
[linux-sunxi] Re: [PATCH 3/4] simplefb: disable dt node upon remove
Quoted 53 lines · jonsmirl at gmail.com
Quoted 40 lines · Stephen Warren
Quoted 28 lines · David Herrmann
Hi
Quoted 13 lines · Grant Likely
Quoted 9 lines · Luc Verhaegen
The next commit will handle clocks correctly, so that these do not get automatically disabled on certain SoC simplefb implementations. As a result, the removal of this simplefb driver, and the release of the clocks, is rather final, and only a full display driver can work after this. So, it makes sense to also flag the dt node as disabled, even though it has no real value today.
Signed-off-by Luc Verhaegen <[email protected]>Quoted 8 lines
Please, no.
Drivers should not be modifying the device tree without and exceptionally good reason for doing so. Drivers are to treat the DT as immutable.
* the exception is an overlay driver which add new devices to the kernel. Definitely not the case here.
Quoted 9 lines
Why? I think we have exactly that case:
* DT describes the real hw properly and those parts are immutable
* Additionally, bootloaders create firmware-framebuffers and create simple-framebuffer devices for them. Those are valid as long as no driver reconfigured the real hw.
* Once a real hw-driver loads, it might destroy the existing framebuffers, thus, it should also destroy the platform device.
* If the real hw-driver is unloaded, it might re-create the FB and thus create a new (or enable the old) platform device.Quoted 6 lines
My intention was always that a bootloader's addition of a simplefb node to the DT would be user-configurable or driven by the original DT content. As such, there shouldn't ever be both a DT node describing the "real" HW and simplefb. In other words, if the DT already has the "real" DT node, the bootloader should automatically (or under user command) not add the simpefb node.
DT is just the wrong mechanism to signal this, use an ATAG or kernel command line parameter.
real hardware has compatible = "real-hardware-name, simplefb"
Quoted 7 lines
simplefb is built into kernel. It will attach to the device because of the compatible string. Then it can look at the command line and see if the bootloader also supported simplefb and already set things up.
Then some mechanism will have to be designed to arrange a handoff between simplefb and the chip specific KMS driver. But that's a Linux problem, not a DT one.
Having a single DT node that conforms to both the binding for "real-hardware-name" and "simplefb" doesn't seem like a good approach. What if the properties required by the two bindings conflict in some way? The approach you advocate certainly hasn't ever been used AFAIK.
[linux-sunxi] Re: [PATCH 3/4] simplefb: disable dt node upon remove
Quoted 76 lines · Stephen Warren
Quoted 66 lines · jonsmirl at gmail.com
Quoted 47 lines · Stephen Warren
Quoted 33 lines · David Herrmann
Hi
Quoted 16 lines · Grant Likely
Quoted 10 lines · Luc Verhaegen
The next commit will handle clocks correctly, so that these do not get automatically disabled on certain SoC simplefb implementations. As a result, the removal of this simplefb driver, and the release of the clocks, is rather final, and only a full display driver can work after this. So, it makes sense to also flag the dt node as disabled, even though it has no real value today.
Signed-off-by Luc Verhaegen <[email protected]>Quoted 8 lines
Please, no.
Drivers should not be modifying the device tree without and exceptionally good reason for doing so. Drivers are to treat the DT as immutable.
* the exception is an overlay driver which add new devices to the kernel. Definitely not the case here.
Quoted 9 lines
Why? I think we have exactly that case:
* DT describes the real hw properly and those parts are immutable
* Additionally, bootloaders create firmware-framebuffers and create simple-framebuffer devices for them. Those are valid as long as no driver reconfigured the real hw.
* Once a real hw-driver loads, it might destroy the existing framebuffers, thus, it should also destroy the platform device.
* If the real hw-driver is unloaded, it might re-create the FB and thus create a new (or enable the old) platform device.Quoted 9 lines
My intention was always that a bootloader's addition of a simplefb node to
the DT would be user-configurable or driven by the original DT content. As
such, there shouldn't ever be both a DT node describing the "real" HW and simplefb. In other words, if the DT already has the "real" DT node, the bootloader should automatically (or under user command) not add the simpefb
node.DT is just the wrong mechanism to signal this, use an ATAG or kernel command line parameter.
real hardware has compatible = "real-hardware-name, simplefb"
Quoted 7 lines
simplefb is built into kernel. It will attach to the device because of the compatible string. Then it can look at the command line and see if the bootloader also supported simplefb and already set things up.
Then some mechanism will have to be designed to arrange a handoff between simplefb and the chip specific KMS driver. But that's a Linux problem, not a DT one.
Quoted 4 lines
Having a single DT node that conforms to both the binding for "real-hardware-name" and "simplefb" doesn't seem like a good approach. What if the properties required by the two bindings conflict in some way? The approach you advocate certainly hasn't ever been used AFAIK.
I believe we do have something like this - SPI core implements a lot of core DT functions. All SPI nodes use this core. Then hardware specific attributes are added.
The conflicts would need to get sorted out. That's why we should have a schema in place for device tree. Then the properties for specific video hardware would inherit from the properties for simplefb.
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
PATCH 4/4 simplefb: add clock handling code
In reply to Luc VerhaegenThis claims and enables clocks listed in the simple framebuffer dt node. This is needed so that the display engine, in case the required clocks are known by the kernel code and are described in the dt, will remain properly enabled.
--- drivers/video/fbdev/simplefb.c | 103 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 101 insertions(+), 2 deletions(-)
drivers/video/fbdev/simplefb.c +101 -2
@@ -26,6 +26,7 @@#include <linux/module.h> #include <linux/platform_data/simplefb.h> #include <linux/platform_device.h> +#include <linux/clk-provider.h> static struct fb_fix_screeninfo simplefb_fix = { .id ="simple" ,
@@ -191,8 +192,101 @@ static int simplefb_parse_pd(struct platform_device *pdev,return 0 ; } +/* +* Clock handling code. +* +* Here we handle the clocks property of our "simple-framebuffer" dt node. +* This is necessary so that we can make sure that any clocks needed by +* the display engine that the bootloader set up for us (and for which it +* provided a simplefb dt node), stay up, for the life of the simplefb +* driver. +* +* When the driver unloads, we cleanly disable, and then release the clocks. +*/ +struct simplefb_clock { +struct list_head list; +struct clk *clock; +}; + +/* +* We only complain about errors here, no action is taken as the most likely +* error can only happen due to a mismatch between the bootloader which set +* up simplefb, and the clock definitions in the device tree. Chances are +* that there are no adverse effects, and if there are, a clean teardown of +* the fb probe will not help us much either. So just complain and carry on, +* and hope that the user actually gets a working fb at the end of things. +*/ +static void +simplefb_clocks_init (struct platform_device *pdev,struct list_head *list) +{ +struct device_node *np = pdev->dev.of_node; +int clock_count, i; + +INIT_LIST_HEAD (list); + +if (dev_get_platdata (&pdev->dev) || !np) +return ; + + clock_count =of_clk_get_parent_count (np); +for (i =0 ; i < clock_count; i++) { +struct simplefb_clock *entry; +struct clk *clock =of_clk_get (np, i); +int ret; + +if (IS_ERR (clock)) { +dev_err (&pdev->dev,"%s: clock %d not found: %ld\n" , + __func__, i,PTR_ERR (clock)); +continue ; + } + + ret =clk_prepare_enable (clock); +if (ret) { +dev_err (&pdev->dev, +"%s: failed to enable clock %d: %d\n" , + __func__, i, ret); +clk_put (clock); +continue ; + } + + entry =kzalloc (sizeof (struct simplefb_clock ),GFP_KERNEL ); +if (!entry) { +dev_err (&pdev->dev, +"%s: failed to alloc clock %d list entry.\n" , + __func__, i); +clk_disable_unprepare (clock); +clk_put (clock); +continue ; + } + + entry->clock = clock; +/* +* add to the front of the list, so we disable clocks in the +* correct order. +*/ +list_add (&entry->list, list); + } +} + +static void +simplefb_clocks_destroy (struct list_head *list) +{ +struct list_head *pos, *n; + +list_for_each_safe (pos, n, list) { +struct simplefb_clock *entry = + container_of(pos, struct simplefb_clock, list); + +list_del (&entry->list); + +clk_disable_unprepare (entry->clock); +clk_put (entry->clock); +kfree (entry); + } +} +struct simplefb_par {u32 palette[PSEUDO_PALETTE_SIZE ]; +struct list_head clock_list[1 ]; };static int simplefb_probe (struct platform_device *pdev)
@@ -265,6 +359,8 @@ static int simplefb_probe(struct platform_device *pdev) } info->pseudo_palette = (void *) par->palette; +simplefb_clocks_init (pdev, par->clock_list); +dev_info (&pdev->dev,"framebuffer at 0x%lx, 0x%x bytes, mapped to 0x%p\n" , info->fix.smem_start, info->fix.smem_len, info->screen_base);
@@ -276,14 +372,15 @@ static int simplefb_probe(struct platform_device *pdev) ret =register_framebuffer (info);if (ret <0 ) {dev_err (&pdev->dev,"Unable to register simplefb: %d\n" , ret); - goto error_unmap; + goto error_clocks; }dev_info (&pdev->dev,"fb%d: simplefb registered!\n" , info->node);return 0 ; - error_unmap: + error_clocks: +simplefb_clocks_destroy (par->clock_list);iounmap (info->screen_base); error_fb_release:
@@ -299,8 +396,10 @@ static int simplefb_probe(struct platform_device *pdev)static int simplefb_remove (struct platform_device *pdev) {struct fb_info *info =platform_get_drvdata (pdev); +struct simplefb_par *par = info->par;unregister_framebuffer (info); +simplefb_clocks_destroy (par->clock_list);framebuffer_release (info);if (!dev_get_platdata (&pdev->dev) && pdev->dev.of_node)simplefb_dt_disable (pdev);
Signature · 1 line
1.7.7
PATCH 4/4 simplefb: add clock handling code
Quoted 4 lines · Luc Verhaegen
This claims and enables clocks listed in the simple framebuffer dt node. This is needed so that the display engine, in case the required clocks are known by the kernel code and are described in the dt, will remain properly enabled.
I think this make simplefb not simple any more, which rather goes against the whole point of it.
I specifically conceived simplefb to know about nothing more than the memory address and pixel layout of the memory buffer. I certainly don't like the idea of expanding simplefb to anything beyond that, and IIRC *not* extending is was a condition agreed when it was first merged. If more knowledge than that is required, then there needs to be a HW-specific driver to manage any clocks/resets/video registers, etc.
The correct way to handle this without a complete DRM/KMS/... driver is to avoid the clocks in question being turned off at boot. I thought there was a per-clock flag to prevent disabling an unused clock? If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?). For example, the Tegra clock driver has a clock initialization table which IIRC was used for this purpose before we got a DRM/KMS driver. That way, all the details are kept inside the kernel code, and don't end up influencing the DT representation of simplefb.
PATCH 4/4 simplefb: add clock handling code
Quoted 10 lines · Stephen Warren
I think this make simplefb not simple any more, which rather goes against the whole point of it.
I specifically conceived simplefb to know about nothing more than the memory address and pixel layout of the memory buffer. I certainly don't like the idea of expanding simplefb to anything beyond that, and IIRC *not* extending is was a condition agreed when it was first merged. If more knowledge than that is required, then there needs to be a HW-specific driver to manage any clocks/resets/video registers, etc.
Yes. Simplefb quickly becomes anything but, doesn't it. Perhaps DenialFB would've been a better name for it ;p
Quoted 9 lines
The correct way to handle this without a complete DRM/KMS/... driver is to avoid the clocks in question being turned off at boot. I thought there was a per-clock flag to prevent disabling an unused clock? If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?). For example, the Tegra clock driver has a clock initialization table which IIRC was used for this purpose before we got a DRM/KMS driver. That way, all the details are kept inside the kernel code, and don't end up influencing the DT representation of simplefb.
How was simplefb handled on tegra? Where is the code for that? I didn't see anything in u-boot for instance.
But the code for handling clocks where they are supposed to be handled is pretty generic from where i sit.
Luc Verhaegen.
PATCH 4/4 simplefb: add clock handling code
In reply to Stephen WarrenQuoted 9 lines · Stephen Warren
Quoted 4 lines · Luc Verhaegen
This claims and enables clocks listed in the simple framebuffer dt node. This is needed so that the display engine, in case the required clocks are known by the kernel code and are described in the dt, will remain properly enabled.
I think this make simplefb not simple any more, which rather goes against the whole point of it.
Quoted 7 lines
I specifically conceived simplefb to know about nothing more than the memory address and pixel layout of the memory buffer. I certainly don't like the idea of expanding simplefb to anything beyond that, and IIRC *not* extending is was a condition agreed when it was first merged. If more knowledge than that is required, then there needs to be a HW-specific driver to manage any clocks/resets/video registers, etc.
I'm sorry, but how is that not simple? clocks enabling is step 1 in a driver in order to communicate somehow with the controller. Reset is a different story, because arguably, if simplefb is there, the controller is already out of reset.
And I don't see why video registers are coming into the discussion here. The code Luc posted doesn't access any register, at all. It just makes sure the needed controller keep going.
Quoted 2 lines
The correct way to handle this without a complete DRM/KMS/... driver is to avoid the clocks in question being turned off at boot.
Which is exactly what this code does, using the generic DT bindings to express dependency for a given clock. How is this wrong?
Quoted 2 lines
I thought there was a per-clock flag to prevent disabling an unused clock?
No, last time I heard, Mike Turquette was against it.
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when clk_get should have the consumer device as an argument.
Quoted 4 lines
For example, the Tegra clock driver has a clock initialization table which IIRC was used for this purpose before we got a DRM/KMS driver. That way, all the details are kept inside the kernel code, and don't end up influencing the DT representation of simplefb.
I don't really see how the optional usage of a generic property influences badly the DT representation of simplefb.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140813/a2333ac8/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi,
Quoted 48 lines · Maxime Ripard
Quoted 9 lines · Stephen Warren
Quoted 4 lines · Luc Verhaegen
This claims and enables clocks listed in the simple framebuffer dt node. This is needed so that the display engine, in case the required clocks are known by the kernel code and are described in the dt, will remain properly enabled.
I think this make simplefb not simple any more, which rather goes against the whole point of it.
Quoted 7 lines
I specifically conceived simplefb to know about nothing more than the memory address and pixel layout of the memory buffer. I certainly don't like the idea of expanding simplefb to anything beyond that, and IIRC *not* extending is was a condition agreed when it was first merged. If more knowledge than that is required, then there needs to be a HW-specific driver to manage any clocks/resets/video registers, etc.
I'm sorry, but how is that not simple? clocks enabling is step 1 in a driver in order to communicate somehow with the controller. Reset is a different story, because arguably, if simplefb is there, the controller is already out of reset.
And I don't see why video registers are coming into the discussion here. The code Luc posted doesn't access any register, at all. It just makes sure the needed controller keep going.
Quoted 2 lines
The correct way to handle this without a complete DRM/KMS/... driver is to avoid the clocks in question being turned off at boot.
Which is exactly what this code does, using the generic DT bindings to express dependency for a given clock. How is this wrong?
Quoted 2 lines
I thought there was a per-clock flag to prevent disabling an unused clock?
No, last time I heard, Mike Turquette was against it.
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.
Quoted 7 lines
Quoted 4 lines
For example, the Tegra clock driver has a clock initialization table which IIRC was used for this purpose before we got a DRM/KMS driver. That way, all the details are kept inside the kernel code, and don't end up influencing the DT representation of simplefb.
I don't really see how the optional usage of a generic property influences badly the DT representation of simplefb.
+1 to all that Maxime said.
Also as can be seen in other discussion on this patch set, simplefb should not be seen as something orthogonal to having a full kms driver.
So just write a full kms driver is not the answer IMHO. What we want is for a bootloader setup console to be available through simplefb bindings so that the kernel can show output without depending on module loading, and thus can show errors if things go bad before a kms driver gets loaded.
And no build kms into the kernel is not the answer. We've all been working hard to be able to build more generic kernels, so as to get generic distro support. And generic distros will build kms as modules, as there are simply to many different kms drivers to build them all in.
Regards,
Hans
PATCH 4/4 simplefb: add clock handling code
Op 14 aug. 2014, om 11:37 heeft Hans de Goede <[email protected]> het volgende geschreven:
Quoted 70 lines
Hi,
Quoted 48 lines · Maxime Ripard
Quoted 9 lines · Stephen Warren
Quoted 4 lines · Luc Verhaegen
This claims and enables clocks listed in the simple framebuffer dt node. This is needed so that the display engine, in case the required clocks are known by the kernel code and are described in the dt, will remain properly enabled.
I think this make simplefb not simple any more, which rather goes against the whole point of it.
Quoted 7 lines
I specifically conceived simplefb to know about nothing more than the memory address and pixel layout of the memory buffer. I certainly don't like the idea of expanding simplefb to anything beyond that, and IIRC *not* extending is was a condition agreed when it was first merged. If more knowledge than that is required, then there needs to be a HW-specific driver to manage any clocks/resets/video registers, etc.
I'm sorry, but how is that not simple? clocks enabling is step 1 in a driver in order to communicate somehow with the controller. Reset is a different story, because arguably, if simplefb is there, the controller is already out of reset.
And I don't see why video registers are coming into the discussion here. The code Luc posted doesn't access any register, at all. It just makes sure the needed controller keep going.
Quoted 2 lines
The correct way to handle this without a complete DRM/KMS/... driver is to avoid the clocks in question being turned off at boot.
Which is exactly what this code does, using the generic DT bindings to express dependency for a given clock. How is this wrong?
Quoted 2 lines
I thought there was a per-clock flag to prevent disabling an unused clock?
No, last time I heard, Mike Turquette was against it.
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Quoted 7 lines
Quoted 4 lines
For example, the Tegra clock driver has a clock initialization table which IIRC was used for this purpose before we got a DRM/KMS driver. That way, all the details are kept inside the kernel code, and don't end up influencing the DT representation of simplefb.
I don't really see how the optional usage of a generic property influences badly the DT representation of simplefb.
+1 to all that Maxime said.
Also as can be seen in other discussion on this patch set, simplefb should not be seen as something orthogonal to having a full kms driver.
So just write a full kms driver is not the answer IMHO. What we want is for a bootloader setup console to be available through simplefb bindings so that the kernel can show output without depending on module loading, and thus can show errors if things go bad before a kms driver gets loaded.
Quoted 5 lines
And no build kms into the kernel is not the answer. We've all been working hard to be able to build more generic kernels, so as to get generic distro support. And generic distros will build kms as modules, as there are simply to many different kms drivers to build them all in.
How many DRM drivers are there on ARM and what's the size impact of building them all into the kernel? I know from experience that it's not possible on x86 especially with efifb in the mix, but I wonder what the situation on ARM is. I only have TI, sunxi and exynos boards to test on and building in both TI drm drivers and the exynos one seems to work. Note that I'm not talking about the non-DRM abortions that maskerade as graphics drivers for ARM SoCs, only proper DRM ones.
regards,
Koen
PATCH 4/4 simplefb: add clock handling code
Quoted 7 lines · Koen Kooi
How many DRM drivers are there on ARM and what's the size impact of building them all into the kernel? I know from experience that it's not possible on x86 especially with efifb in the mix, but I wonder what the situation on ARM is. I only have TI, sunxi and exynos boards to test on and building in both TI drm drivers and the exynos one seems to work. Note that I'm not talking about the non-DRM abortions that maskerade as graphics drivers for ARM SoCs, only proper DRM ones.
regards,
Koen
A quick check tells me that my current sunxi-3.4 sunxi_drm.ko measures 1.7MB, for currently about 8kloc (the binary seems excessively big though), which is just display. This still lacks many key features (lcd gpio, backlight pwm, lvds, ints), so it will grow ~1kloc still.
Also, i constantly am re-loading this (how else does one develop any sizable amount of code?), so it does that cleanly and correctly, which seems quite contrary to your experience with ARM drm drivers.
Luc Verhaegen.
PATCH 4/4 simplefb: add clock handling code
Hi,
Quoted 11 lines · Luc Verhaegen
Quoted 7 lines · Koen Kooi
How many DRM drivers are there on ARM and what's the size impact of building them all into the kernel? I know from experience that it's not possible on x86 especially with efifb in the mix, but I wonder what the situation on ARM is. I only have TI, sunxi and exynos boards to test on and building in both TI drm drivers and the exynos one seems to work. Note that I'm not talking about the non-DRM abortions that maskerade as graphics drivers for ARM SoCs, only proper DRM ones.
regards,
Koen
A quick check tells me that my current sunxi-3.4 sunxi_drm.ko measures 1.7MB
That likely is with debug-info, try running "strip --strip-debug" on the .ko file. Note don't use plain "strip" that ruins kernel modules.
Regards,
Hans
p.s.
I'm leaving home (and the internet) for vacation tomorrow. I'll be back on Mon Aug 25.
PATCH 4/4 simplefb: add clock handling code
In reply to Koen KooiHi,
Quoted 73 lines · Koen Kooi
Op 14 aug. 2014, om 11:37 heeft Hans de Goede <[email protected]> het volgende geschreven:
Quoted 70 lines
Hi,
Quoted 48 lines · Maxime Ripard
Quoted 9 lines · Stephen Warren
Quoted 4 lines · Luc Verhaegen
This claims and enables clocks listed in the simple framebuffer dt node. This is needed so that the display engine, in case the required clocks are known by the kernel code and are described in the dt, will remain properly enabled.
I think this make simplefb not simple any more, which rather goes against the whole point of it.
Quoted 7 lines
I specifically conceived simplefb to know about nothing more than the memory address and pixel layout of the memory buffer. I certainly don't like the idea of expanding simplefb to anything beyond that, and IIRC *not* extending is was a condition agreed when it was first merged. If more knowledge than that is required, then there needs to be a HW-specific driver to manage any clocks/resets/video registers, etc.
I'm sorry, but how is that not simple? clocks enabling is step 1 in a driver in order to communicate somehow with the controller. Reset is a different story, because arguably, if simplefb is there, the controller is already out of reset.
And I don't see why video registers are coming into the discussion here. The code Luc posted doesn't access any register, at all. It just makes sure the needed controller keep going.
Quoted 2 lines
The correct way to handle this without a complete DRM/KMS/... driver is to avoid the clocks in question being turned off at boot.
Which is exactly what this code does, using the generic DT bindings to express dependency for a given clock. How is this wrong?
Quoted 2 lines
I thought there was a per-clock flag to prevent disabling an unused clock?
No, last time I heard, Mike Turquette was against it.
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Quoted 7 lines
Quoted 4 lines
For example, the Tegra clock driver has a clock initialization table which IIRC was used for this purpose before we got a DRM/KMS driver. That way, all the details are kept inside the kernel code, and don't end up influencing the DT representation of simplefb.
I don't really see how the optional usage of a generic property influences badly the DT representation of simplefb.
+1 to all that Maxime said.
Also as can be seen in other discussion on this patch set, simplefb should not be seen as something orthogonal to having a full kms driver.
So just write a full kms driver is not the answer IMHO. What we want is for a bootloader setup console to be available through simplefb bindings so that the kernel can show output without depending on module loading, and thus can show errors if things go bad before a kms driver gets loaded.
Quoted 7 lines
Quoted 5 lines
And no build kms into the kernel is not the answer. We've all been working hard to be able to build more generic kernels, so as to get generic distro support. And generic distros will build kms as modules, as there are simply to many different kms drivers to build them all in.
How many DRM drivers are there on ARM and what's the size impact of building them all into the kernel?
I don't know how many we've today, but I do know that we will have twice as more next year, and 4x as more the year after that, etc.
IOW this does not scale.
Regards,
Hans
PATCH 4/4 simplefb: add clock handling code
In reply to Maxime RipardQuoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 9 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.
Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140825/ea172bb2/attachment.sig>
PATCH 4/4 simplefb: add clock handling code
Quoted 9 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 6 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
Quoted 7 lines
Quoted 3 lines
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Are you saying that this driver would become "dirty" with such a patch?
If so, we really have an issue in the kernel.
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140825/4c060f75/attachment.sig>
PATCH 4/4 simplefb: add clock handling code
Quoted 14 lines · Maxime Ripard
Quoted 13 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 9 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.
Quoted 5 lines
Quoted 3 lines
Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Are you saying that this driver would become "dirty" with such a patch?
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
Quoted 1 line
If so, we really have an issue in the kernel.
Can you elaborate?
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140825/68317adf/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi,
Quoted 19 lines · Thierry Reding
Quoted 18 lines · Maxime Ripard
Quoted 16 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 9 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Quoted 5 lines
Quoted 1 line
Are you saying that this driver would become "dirty" with such a patch?
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
I can only assume that this problem was never hit on tegra because when kms support (and thus also a clock driver for the video plls) was introduced simplefb support was dropped at the same time, or the gates are not being disabled for some other reason.
As for the suggestion to simply never disable the plls / ahb gates by blocking them from ever being disabled in the sunxi clock driver, that is not really a solution either, as we want to be able to turn these things off to safe power on screen blank once control has been turned over to the kms driver.
And while at it let me also tackle the don't use simplefb only use kms argument, that means that the clocks will be turned off until the kms module loads, which will cause noticable screen flicker / video output resync, something which we've been trying to get rid of for years now.
And no, build in the kms driver is not an answer either. That works nicely for firmware, but not for generic Linux distributions supporting a wide range of boards.
Regards,
Hans
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 22 lines · Hans de Goede
Quoted 21 lines · Thierry Reding
Quoted 19 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 6 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
Quoted 7 lines
Quoted 3 lines
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Are you saying that this driver would become "dirty" with such a patch?
Quoted 8 lines
Quoted 3 lines
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
It is platform specific in that your platform may require certain clocks to remain on. The next platform may require power domains to remain on during boot and yet another one may rely on regulators to stay on during boot. By your argument simplefb will need to be taught to handle pretty much every type of resource that the kernel has.
Quoted 4 lines
As for the suggestion to simply never disable the plls / ahb gates by blocking them from ever being disabled in the sunxi clock driver, that is not really a solution either, as we want to be able to turn these things off to safe power on screen blank once control has been turned over to the kms driver.
Then perhaps part of the hand-off procedure between simplefb and DRM/KMS should involve marking PLLs or "gates" as properly managed.
Quoted 8 lines
And while at it let me also tackle the don't use simplefb only use kms argument, that means that the clocks will be turned off until the kms module loads, which will cause noticable screen flicker / video output resync, something which we've been trying to get rid of for years now.
And no, build in the kms driver is not an answer either. That works nicely for firmware, but not for generic Linux distributions supporting a wide range of boards.
Odd... I didn't offer any of those two as solutions to the problem.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140825/5a2fa3c4/attachment-0001.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 32 lines · Thierry Reding
Quoted 22 lines · Hans de Goede
Quoted 21 lines · Thierry Reding
Quoted 19 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 6 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
Quoted 7 lines
Quoted 3 lines
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Are you saying that this driver would become "dirty" with such a patch?
Quoted 8 lines
Quoted 3 lines
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
Quoted 5 lines
It is platform specific in that your platform may require certain clocks to remain on. The next platform may require power domains to remain on during boot and yet another one may rely on regulators to stay on during boot. By your argument simplefb will need to be taught to handle pretty much every type of resource that the kernel has.
Why can't simplefb be a driver library that is called from a device specific device driver that only claims the clocks (or regulators)? Then build all of these device specific drivers into the generic ARM kernel. They will be quite small since all they do is claim the clocks (or regulator). Maybe we can even figure out some protocol for removing the unused ones from memory later.
Later during the boot process the device specific driver can load its KMS code which has also been implemented as a driver library. Maybe use E_PROBE_DEFER to do this. Match on the device ID, claim the clocks, defer until the full KMS library can be loaded.
Quoted 21 lines
Quoted 5 lines
As for the suggestion to simply never disable the plls / ahb gates by blocking them from ever being disabled in the sunxi clock driver, that is not really a solution either, as we want to be able to turn these things off to safe power on screen blank once control has been turned over to the kms driver.
Then perhaps part of the hand-off procedure between simplefb and DRM/KMS should involve marking PLLs or "gates" as properly managed.
Quoted 8 lines
And while at it let me also tackle the don't use simplefb only use kms argument, that means that the clocks will be turned off until the kms module loads, which will cause noticable screen flicker / video output resync, something which we've been trying to get rid of for years now.
And no, build in the kms driver is not an answer either. That works nicely for firmware, but not for generic Linux distributions supporting a wide range of boards.
Odd... I didn't offer any of those two as solutions to the problem.
Thierry
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi,
Quoted 47 lines · jonsmirl at gmail.com
Quoted 32 lines · Thierry Reding
Quoted 22 lines · Hans de Goede
Quoted 21 lines · Thierry Reding
Quoted 19 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 6 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
Quoted 7 lines
Quoted 3 lines
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Are you saying that this driver would become "dirty" with such a patch?
Quoted 8 lines
Quoted 3 lines
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
Quoted 5 lines
It is platform specific in that your platform may require certain clocks to remain on. The next platform may require power domains to remain on during boot and yet another one may rely on regulators to stay on during boot. By your argument simplefb will need to be taught to handle pretty much every type of resource that the kernel has.
Why can't simplefb be a driver library that is called from a device specific device driver that only claims the clocks (or regulators)? Then build all of these device specific drivers into the generic ARM kernel. They will be quite small since all they do is claim the clocks (or regulator). Maybe we can even figure out some protocol for removing the unused ones from memory later.
Quoted 4 lines
Later during the boot process the device specific driver can load its KMS code which has also been implemented as a driver library. Maybe use
E_PROBE_DEFERto do this. Match on the device ID, claim the clocks, defer until the full KMS library can be loaded.
There is no need for all this complexity, all that is needed is for the simplefb driver to be thought to claim + enable any clocks listed in its dt node.
Then once we want to do a handover, all is needed is a single simplefb unregister call, at which point simplefb will disable the clocks and release them. Note that this will be a nop as they should already be claimed and enabled by the kms driver at this time.
Regards,
Hans
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 50 lines · Hans de Goede
Hi,
Quoted 47 lines · jonsmirl at gmail.com
Quoted 32 lines · Thierry Reding
Quoted 22 lines · Hans de Goede
Quoted 21 lines · Thierry Reding
Quoted 19 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 6 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
Quoted 7 lines
Quoted 3 lines
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Are you saying that this driver would become "dirty" with such a patch?
Quoted 8 lines
Quoted 3 lines
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
Quoted 5 lines
It is platform specific in that your platform may require certain clocks to remain on. The next platform may require power domains to remain on during boot and yet another one may rely on regulators to stay on during boot. By your argument simplefb will need to be taught to handle pretty much every type of resource that the kernel has.
Why can't simplefb be a driver library that is called from a device specific device driver that only claims the clocks (or regulators)? Then build all of these device specific drivers into the generic ARM kernel. They will be quite small since all they do is claim the clocks (or regulator). Maybe we can even figure out some protocol for removing the unused ones from memory later.
Quoted 8 lines
Quoted 4 lines
Later during the boot process the device specific driver can load its KMS code which has also been implemented as a driver library. Maybe use
E_PROBE_DEFERto do this. Match on the device ID, claim the clocks, defer until the full KMS library can be loaded.There is no need for all this complexity, all that is needed is for the simplefb driver to be thought to claim + enable any clocks listed in its dt node.
Out of curiosity, how does this work in practice? How does the bootloader create this entry? Does it scan the DT to see which clocks the real hardware device references and then simply copies them to the simplefb node?
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140825/8917c9ee/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 7 lines · Thierry Reding
Out of curiosity, how does this work in practice? How does the bootloader create this entry? Does it scan the DT to see which clocks the real hardware device references and then simply copies them to the simplefb node?
Thierry
https://www.mail-archive.com/linux-sunxi at googlegroups.com/msg06619.html
Luc Verhaegen.
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 10 lines · Luc Verhaegen
Quoted 7 lines · Thierry Reding
Out of curiosity, how does this work in practice? How does the bootloader create this entry? Does it scan the DT to see which clocks the real hardware device references and then simply copies them to the simplefb node?
Thierry
https://www.mail-archive.com/linux-sunxi at googlegroups.com/msg06619.html
That looks like a royal pain. Again, I think it'd be much simpler (but not less code, unfortunately) to do this on a per-resource basis. That way these low-level firmware drivers in the kernel can stay trivial, keeping the real complexity where they belong: in hardware-specific drivers such as DRM/KMS.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140826/6bf72076/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 10 lines · Thierry Reding
Quoted 9 lines · Luc Verhaegen
Quoted 7 lines · Thierry Reding
Out of curiosity, how does this work in practice? How does the bootloader create this entry? Does it scan the DT to see which clocks the real hardware device references and then simply copies them to the simplefb node?
Thierry
Quoted 7 lines
Quoted 1 line
https://www.mail-archive.com/linux-sunxi at googlegroups.com/msg06619.html
That looks like a royal pain. Again, I think it'd be much simpler (but not less code, unfortunately) to do this on a per-resource basis. That way these low-level firmware drivers in the kernel can stay trivial, keeping the real complexity where they belong: in hardware-specific drivers such as DRM/KMS.
So we have to write a DRM/KMS driver in order to have display working while waiting for a DRM/KMS driver to be worked on? Come on...
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140826/9ce87b4d/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 13 lines · Maxime Ripard
Quoted 12 lines · Thierry Reding
Quoted 10 lines · Luc Verhaegen
Quoted 7 lines · Thierry Reding
Out of curiosity, how does this work in practice? How does the bootloader create this entry? Does it scan the DT to see which clocks the real hardware device references and then simply copies them to the simplefb node?
Thierry
https://www.mail-archive.com/linux-sunxi at googlegroups.com/msg06619.html
Quoted 8 lines
Quoted 5 lines
That looks like a royal pain. Again, I think it'd be much simpler (but not less code, unfortunately) to do this on a per-resource basis. That way these low-level firmware drivers in the kernel can stay trivial, keeping the real complexity where they belong: in hardware-specific drivers such as DRM/KMS.
So we have to write a DRM/KMS driver in order to have display working while waiting for a DRM/KMS driver to be worked on? Come on...
Perhaps you should go and read this thread again. That's not at all what I've been saying.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140826/55aeadd6/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingQuoted 56 lines · Thierry Reding
Quoted 55 lines · Hans de Goede
Hi,
Quoted 51 lines · jonsmirl at gmail.com
Quoted 32 lines · Thierry Reding
Quoted 22 lines · Hans de Goede
Quoted 21 lines · Thierry Reding
Quoted 19 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 6 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
Quoted 7 lines
Quoted 3 lines
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Are you saying that this driver would become "dirty" with such a patch?
Quoted 8 lines
Quoted 3 lines
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
Quoted 5 lines
It is platform specific in that your platform may require certain clocks to remain on. The next platform may require power domains to remain on during boot and yet another one may rely on regulators to stay on during boot. By your argument simplefb will need to be taught to handle pretty much every type of resource that the kernel has.
Why can't simplefb be a driver library that is called from a device specific device driver that only claims the clocks (or regulators)? Then build all of these device specific drivers into the generic ARM kernel. They will be quite small since all they do is claim the clocks (or regulator). Maybe we can even figure out some protocol for removing the unused ones from memory later.
Later during the boot process the device specific driver can load its KMS code which has also been implemented as a driver library. Maybe use
E_PROBE_DEFERto do this. Match on the device ID, claim the clocks, defer until the full KMS library can be loaded.
Quoted 8 lines
Quoted 3 lines
There is no need for all this complexity, all that is needed is for the simplefb driver to be thought to claim + enable any clocks listed in its dt node.
Out of curiosity, how does this work in practice? How does the bootloader create this entry? Does it scan the DT to see which clocks the real hardware device references and then simply copies them to the simplefb node?
That's why this is such a problem. There is a general rule in Linux - one device, one driver. All of the kernel device driver code is written around this assumption. We're trying to make two drivers for one device and the kernel is not designed to support that. There shouldn't be an independent 'simplefb' node. That is creating two device descriptions for a single device.
Adding 'chosen' information to the devices nodes might work.
video at 1345 {
compatible = "sunxi-a20-video";
reg = <...>;
clocks = <...>;
chosen {
compatible = "simplefb"; // dynamically added by uboot
buffer = <0x4564>; // dynamically added by uboot };
};
This will initialize the simplefb driver without attaching it to any specific hardware. It can then look in its parent node for clocks and regulators and claim them.
Quoted 2 lines
Thierry
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi,
Quoted 62 lines · jonsmirl at gmail.com
Quoted 60 lines · Thierry Reding
Quoted 58 lines · Hans de Goede
Hi,
Quoted 47 lines · jonsmirl at gmail.com
Quoted 32 lines · Thierry Reding
Quoted 22 lines · Hans de Goede
Quoted 21 lines · Thierry Reding
Quoted 19 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 6 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
Quoted 7 lines
Quoted 3 lines
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Are you saying that this driver would become "dirty" with such a patch?
Quoted 8 lines
Quoted 3 lines
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
Quoted 5 lines
It is platform specific in that your platform may require certain clocks to remain on. The next platform may require power domains to remain on during boot and yet another one may rely on regulators to stay on during boot. By your argument simplefb will need to be taught to handle pretty much every type of resource that the kernel has.
Why can't simplefb be a driver library that is called from a device specific device driver that only claims the clocks (or regulators)? Then build all of these device specific drivers into the generic ARM kernel. They will be quite small since all they do is claim the clocks (or regulator). Maybe we can even figure out some protocol for removing the unused ones from memory later.
Quoted 4 lines
Later during the boot process the device specific driver can load its KMS code which has also been implemented as a driver library. Maybe use
E_PROBE_DEFERto do this. Match on the device ID, claim the clocks, defer until the full KMS library can be loaded.There is no need for all this complexity, all that is needed is for the simplefb driver to be thought to claim + enable any clocks listed in its dt node.
Quoted 7 lines
Quoted 4 lines
Out of curiosity, how does this work in practice? How does the bootloader create this entry? Does it scan the DT to see which clocks the real hardware device references and then simply copies them to the simplefb node?
That's why this is such a problem. There is a general rule in Linux - one device, one driver.
A general rule with exceptions such as, drumroll ... , video devices, e.g. efifb vs kms drivers are the exact same thing, or good old vgacon vs kms drivers.
Or any other special firmware interfaces for early output (be it serial or video) vs a later loaded / initialized more complete hardware specific driver.
Also in the usb world there are quite a few examples where your once device one driver rule does not hold either, but that is not really relevant.
Regards,
Hans
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to jonsmirl at gmail.comQuoted 47 lines · jonsmirl at gmail.com
Quoted 32 lines · Thierry Reding
Quoted 22 lines · Hans de Goede
Quoted 21 lines · Thierry Reding
Quoted 19 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 6 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
Quoted 7 lines
Quoted 3 lines
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Are you saying that this driver would become "dirty" with such a patch?
Quoted 8 lines
Quoted 3 lines
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
Quoted 5 lines
It is platform specific in that your platform may require certain clocks to remain on. The next platform may require power domains to remain on during boot and yet another one may rely on regulators to stay on during boot. By your argument simplefb will need to be taught to handle pretty much every type of resource that the kernel has.
Why can't simplefb be a driver library that is called from a device specific device driver that only claims the clocks (or regulators)? Then build all of these device specific drivers into the generic ARM kernel. They will be quite small since all they do is claim the clocks (or regulator). Maybe we can even figure out some protocol for removing the unused ones from memory later.
Quoted 4 lines
Later during the boot process the device specific driver can load its KMS code which has also been implemented as a driver library. Maybe use
E_PROBE_DEFERto do this. Match on the device ID, claim the clocks, defer until the full KMS library can be loaded.
That sounds like the most scalable solution so far. On the other hand, as I understand it, the simplefb driver was designed to take over the framebuffer set up by firmware, so it's somewhat odd that the driver would have to deal with resources in the first place. If we push the resource problem into the respective subsystems we keep the simplefb driver completely hardware agnostic.
And we'll also be solving this problem for other types of drivers at the same time. Firmware may after all initialize clocks and other resources for other types of devices too. Handling resources in the drivers would therefore imply that every driver needs to cope with this.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140825/15f8788c/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingHi,
Quoted 38 lines · Thierry Reding
Quoted 22 lines · Hans de Goede
Quoted 21 lines · Thierry Reding
Quoted 19 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 6 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
Quoted 7 lines
Quoted 3 lines
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Are you saying that this driver would become "dirty" with such a patch?
Quoted 8 lines
Quoted 3 lines
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
It is platform specific in that your platform may require certain clocks to remain on. The next platform may require power domains to remain on during boot and yet another one may rely on regulators to stay on during boot. By your argument simplefb will need to be taught to handle pretty much every type of resource that the kernel has.
Quoted 7 lines
Quoted 4 lines
As for the suggestion to simply never disable the plls / ahb gates by blocking them from ever being disabled in the sunxi clock driver, that is not really a solution either, as we want to be able to turn these things off to safe power on screen blank once control has been turned over to the kms driver.
Then perhaps part of the hand-off procedure between simplefb and DRM/KMS should involve marking PLLs or "gates" as properly managed.
And by your earlier argument also power domains, regulators, etc. So now we need to add code to each of the clock core, power-domain core, regulator core, etc. to have them now about this initially unmanaged state thing you're introducing, as well as modify all involved clock / regulator / etc. drivers to mark certain resources as unmanaged.
Or we add a single simple and clean patch to the simplefb driver for dealing with clocks, and worry about all the other hypothetical problems later...
Regards,
Hans
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 46 lines · Hans de Goede
Hi,
Quoted 43 lines · Thierry Reding
Quoted 22 lines · Hans de Goede
Quoted 21 lines · Thierry Reding
Quoted 19 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 6 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
Quoted 7 lines
Quoted 3 lines
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Are you saying that this driver would become "dirty" with such a patch?
Quoted 8 lines
Quoted 3 lines
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
It is platform specific in that your platform may require certain clocks to remain on. The next platform may require power domains to remain on during boot and yet another one may rely on regulators to stay on during boot. By your argument simplefb will need to be taught to handle pretty much every type of resource that the kernel has.
Quoted 4 lines
As for the suggestion to simply never disable the plls / ahb gates by blocking them from ever being disabled in the sunxi clock driver, that is not really a solution either, as we want to be able to turn these things off to safe power on screen blank once control has been turned over to the kms driver.
Quoted 8 lines
Quoted 2 lines
Then perhaps part of the hand-off procedure between simplefb and DRM/KMS should involve marking PLLs or "gates" as properly managed.
And by your earlier argument also power domains, regulators, etc. So now we need to add code to each of the clock core, power-domain core, regulator core, etc. to have them now about this initially unmanaged state thing you're introducing, as well as modify all involved clock / regulator / etc. drivers to mark certain resources as unmanaged.
Hmm... that's true. But we already have a way to deal with exactly this situation for regulators. There's a property called regulator-boot-on which a bootloader should set whet it has enabled a given regulator. It can of course also be set statically in a DTS if it's know upfront that a bootloader will always enable it. Perhaps what we need is a similar property for clocks so that the clock framework will not inadvertently turn off a clock that's still being used.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140825/c50267c3/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 7 lines · Thierry Reding
Hmm... that's true. But we already have a way to deal with exactly this situation for regulators. There's a property called regulator-boot-on which a bootloader should set whet it has enabled a given regulator. It can of course also be set statically in a DTS if it's know upfront that a bootloader will always enable it. Perhaps what we need is a similar property for clocks so that the clock framework will not inadvertently turn off a clock that's still being used.
Except that such a property won't work either. Regulators with regulator-boot-on will still be disabled if there's no one to claim it. Just like what happens currently for the clocks.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140825/69496455/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 10 lines · Maxime Ripard
Quoted 7 lines · Thierry Reding
Hmm... that's true. But we already have a way to deal with exactly this situation for regulators. There's a property called regulator-boot-on which a bootloader should set whet it has enabled a given regulator. It can of course also be set statically in a DTS if it's know upfront that a bootloader will always enable it. Perhaps what we need is a similar property for clocks so that the clock framework will not inadvertently turn off a clock that's still being used.
Except that such a property won't work either.
Of course it won't work if it's designed not to work. The solution to that is to design it in a way that it works and does exactly what we want it to do.
Quoted 2 lines
Regulators with regulator-boot-on will still be disabled if there's no one to claim it. Just like what happens currently for the clocks.
I was somewhat surprised by this, but it can indeed easily be verified. It seems to me somewhat at odds with the definition of such a property.
Mark,
You've probably not read the whole backlog, but the discussion revolves around hand-off of resources from firmware to kernel (via DT in this case). If firmware initializes a device (display controller in this particular case) and enables resources needed by the device to work properly then in order to properly hand over resources from firmware to kernel we need a way to communicate the state of these resources. For regulators the regulator-boot-on property is specified to do exactly that. However the implementation will automatically disable a regulator marked boot-on if it hasn't been claimed by any driver after the initcall stage completes.
I find that rather odd since I always assumed that a regulator marked boot-on would not be touched by the core at all, assuming that firmware set it up properly and that it would be required (even if not explicitly claimed).
The issue that this causes is that we can't properly hand-off devices initialized by firmware because the regulator will be disabled after the initcall stage and then enabled when the driver loads. In case of display the result will usually be flicker. The same applies to other types of resources (in this case clocks).
Two categories of drivers have this issue: drivers built as modules (or that defer probing) and therefore won't be probed until after initcalls have run and generic low-level drivers that take over firmware devices (simplefb in this case) that don't know anything about the resource that the devices need.
Also Cc'ing Mike, perhaps he has ideas on how to solve this problem for clocks specifically.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140826/1616b071/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 7 lines · Thierry Reding
Quoted 2 lines · Maxime Ripard
Regulators with regulator-boot-on will still be disabled if there's no one to claim it. Just like what happens currently for the clocks.
I was somewhat surprised by this, but it can indeed easily be verified. It seems to me somewhat at odds with the definition of such a property.
That depends what you think it should do - it's there for handover from the bootloader in cases where we can't read the state.
Quoted 8 lines
that. However the implementation will automatically disable a regulator marked boot-on if it hasn't been claimed by any driver after the initcall stage completes.
I find that rather odd since I always assumed that a regulator marked boot-on would not be touched by the core at all, assuming that firmware set it up properly and that it would be required (even if not explicitly claimed).
No, there's a separate always-on property if we don't want to disable. We can't assume that the "proper" setup is that the supply should be left on.
Quoted 2 lines
Two categories of drivers have this issue: drivers built as modules (or that defer probing) and therefore won't be probed until after initcalls
We really need a later initcall to manage handover to userspace (probably triggered by a combination of userspace saying it's done doing initial module enumeration and the deferred probe grinding to a halt).
Quoted 3 lines
have run and generic low-level drivers that take over firmware devices (simplefb in this case) that don't know anything about the resource that the devices need.
I don't understand this use case, sorry - it sounds like a buggy system
design and/or integration. If the firmware is managing the resource
then Linux really shouldn't be talking to it at all without coordinating
with firmware. How can such a system work otherwise?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140826/f6affe2b/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 11 lines · Mark Brown
Quoted 7 lines · Thierry Reding
Quoted 2 lines · Maxime Ripard
Regulators with regulator-boot-on will still be disabled if there's no one to claim it. Just like what happens currently for the clocks.
I was somewhat surprised by this, but it can indeed easily be verified. It seems to me somewhat at odds with the definition of such a property.
That depends what you think it should do - it's there for handover from the bootloader in cases where we can't read the state.
True. The description leaves a lot of room for interpretation, though.
- regulator-boot-on: bootloader/firmware enabled regulator
Quoted 10 lines
Quoted 8 lines
that. However the implementation will automatically disable a regulator marked boot-on if it hasn't been claimed by any driver after the initcall stage completes.
I find that rather odd since I always assumed that a regulator marked boot-on would not be touched by the core at all, assuming that firmware set it up properly and that it would be required (even if not explicitly claimed).
No, there's a separate always-on property if we don't want to disable.
But always-on means that it can't ever be disabled. In this case what we'd need is a "don't disable automatically because it's needed, but we may want to switch it off at a later point to save power."
Quoted 2 lines
We can't assume that the "proper" setup is that the supply should be left on.
Right, we can't assume it, but if we're given appropriate hints I think it's fair to keep resources set up by firmware untouched.
Quoted 6 lines
Quoted 2 lines
Two categories of drivers have this issue: drivers built as modules (or that defer probing) and therefore won't be probed until after initcalls
We really need a later initcall to manage handover to userspace (probably triggered by a combination of userspace saying it's done doing initial module enumeration and the deferred probe grinding to a halt).
Yes, perhaps that would be another option.
Quoted 8 lines
Quoted 3 lines
have run and generic low-level drivers that take over firmware devices (simplefb in this case) that don't know anything about the resource that the devices need.
I don't understand this use case, sorry - it sounds like a buggy system design and/or integration. If the firmware is managing the resource then Linux really shouldn't be talking to it at all without coordinating with firmware. How can such a system work otherwise?
The firmware isn't really managing resources. It's setting up state that the kernel shouldn't be modifying. Currently the kernel assumes that no firmware exists and just disables everything that's not being used. That is a reasonable default, but it also limits what we can do. I think if we provided a good interface to communicate state between firmware and kernel then we could easily do this kind of hand-off.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140826/0dfb00f3/attachment-0001.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 7 lines · Thierry Reding
Quoted 4 lines · Mark Brown
Quoted 4 lines
I find that rather odd since I always assumed that a regulator marked boot-on would not be touched by the core at all, assuming that firmware set it up properly and that it would be required (even if not explicitly claimed).
Quoted 5 lines
Quoted 1 line
No, there's a separate always-on property if we don't want to disable.
But always-on means that it can't ever be disabled. In this case what we'd need is a "don't disable automatically because it's needed, but we may want to switch it off at a later point to save power."
Such a property wouldn't make much sense, it should also apply to the driver at which point it's just the same as always-on.
Quoted 5 lines
Quoted 2 lines
We can't assume that the "proper" setup is that the supply should be left on.
Right, we can't assume it, but if we're given appropriate hints I think it's fair to keep resources set up by firmware untouched.
I really can't see any sensible way to do that in an OS neutral thing like DT.
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
have run and generic low-level drivers that take over firmware devices (simplefb in this case) that don't know anything about the resource that the devices need.
I don't understand this use case, sorry - it sounds like a buggy system design and/or integration. If the firmware is managing the resource then Linux really shouldn't be talking to it at all without coordinating with firmware. How can such a system work otherwise?
Quoted 6 lines
The firmware isn't really managing resources. It's setting up state that the kernel shouldn't be modifying. Currently the kernel assumes that no firmware exists and just disables everything that's not being used. That is a reasonable default, but it also limits what we can do. I think if we provided a good interface to communicate state between firmware and kernel then we could easily do this kind of hand-off.
I'm afraid that's confusing me even further. If the "firmware devices"
don't know anything about the resources as you say then presumably they
need to be always on since they obviously won't be able to control them
and there is going to be no handoff?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140826/af8f2fb5/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 17 lines · Mark Brown
Quoted 7 lines · Thierry Reding
Quoted 4 lines · Mark Brown
Quoted 4 lines
I find that rather odd since I always assumed that a regulator marked boot-on would not be touched by the core at all, assuming that firmware set it up properly and that it would be required (even if not explicitly claimed).
Quoted 5 lines
Quoted 1 line
No, there's a separate always-on property if we don't want to disable.
But always-on means that it can't ever be disabled. In this case what we'd need is a "don't disable automatically because it's needed, but we may want to switch it off at a later point to save power."
Such a property wouldn't make much sense, it should also apply to the driver at which point it's just the same as always-on.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
We can't assume that the "proper" setup is that the supply should be left on.
Right, we can't assume it, but if we're given appropriate hints I think it's fair to keep resources set up by firmware untouched.
I really can't see any sensible way to do that in an OS neutral thing like DT.
It should be possible to simply define a property for this that the firmware can add to the device tree.
There are other subsystems for example where we don't touch resources unless they are explicitly accessed. GPIO and pinmux are two examples of those. The reason is precisely so that we don't undo anything that the firmware already set up and that may be needed during boot.
Quoted 16 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
have run and generic low-level drivers that take over firmware devices (simplefb in this case) that don't know anything about the resource that the devices need.
I don't understand this use case, sorry - it sounds like a buggy system design and/or integration. If the firmware is managing the resource then Linux really shouldn't be talking to it at all without coordinating with firmware. How can such a system work otherwise?
Quoted 6 lines
The firmware isn't really managing resources. It's setting up state that the kernel shouldn't be modifying. Currently the kernel assumes that no firmware exists and just disables everything that's not being used. That is a reasonable default, but it also limits what we can do. I think if we provided a good interface to communicate state between firmware and kernel then we could easily do this kind of hand-off.
Quoted 4 lines
I'm afraid that's confusing me even further. If the "firmware devices" don't know anything about the resources as you say then presumably they need to be always on since they obviously won't be able to control them and there is going to be no handoff?
How this works with simplefb is that the firmware (U-Boot for example) sets up everything needed to scan out a framebuffer. The firmware will typically use this for a boot splash or a console. It's akin to the standard VGA console on x86.
Before booting the kernel it will modify the DTB and insert a node that contains information about the framebuffer that was set up. The node contains properties that define the resolution, the format and the physical address of the framebuffer memory. An in-kernel driver will then be able to use that information very early in the boot process to show the console (to replace the serial console that's usually not available on consumer devices). Later on when a real driver can be loaded it should take over the resources from simplefb and remove it.
So the firmware does control the resources to a point where the display hardware is initialized and then it will happily forget about them. The device will keep scanning out the framebuffer and simplefb can update it with boot messages. To prevent the console from suddenly disappearing the kernel needs to make sure that the resources aren't inadvertently turned off at some more or less random point in time.
The resources don't need to be always on, only as long as there isn't a proper driver to manage them. Once that driver has requested the resources it will likely want to control them to save power. Therefore I think the most straightforward way would be for the kernel not to touch any of these resources until they've been explicitly requested. Even if we don't want to rely on firmware doing the right thing by default, I think it's still valuable to take hints from firmware when it provides them so rather than defaulting to not touching any resources what I proposed is to mark resources that shouldn't be touched.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140826/2d0076ce/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 13 lines · Thierry Reding
Quoted 11 lines · Mark Brown
Quoted 7 lines · Thierry Reding
Quoted 2 lines · Mark Brown
We can't assume that the "proper" setup is that the supply should be left on.
Right, we can't assume it, but if we're given appropriate hints I think it's fair to keep resources set up by firmware untouched.
I really can't see any sensible way to do that in an OS neutral thing like DT.
Quoted 7 lines
It should be possible to simply define a property for this that the firmware can add to the device tree.
There are other subsystems for example where we don't touch resources unless they are explicitly accessed. GPIO and pinmux are two examples of those. The reason is precisely so that we don't undo anything that the firmware already set up and that may be needed during boot.
GPIOs and pinmuxes are quite different in both how they get set up (you don't typically have their configuration set in ROM and shoehorned into the board which is what we're dealing with for a lot of PMICs) and in the consequences of leaving them alone.
I really don't think defining a custom property to work around a timing issue in a particular OS startup sequence is the best way forwards here
- we should solve our startup sequencing issue rather than layer on hacks, otherwise we're adding fragility and work to the system. The flag would need to be explicitly added and then it means we're stuck with the behaviour even if the system gets smarter.
Quoted 8 lines
Before booting the kernel it will modify the DTB and insert a node that contains information about the framebuffer that was set up. The node contains properties that define the resolution, the format and the physical address of the framebuffer memory. An in-kernel driver will then be able to use that information very early in the boot process to show the console (to replace the serial console that's usually not available on consumer devices). Later on when a real driver can be loaded it should take over the resources from simplefb and remove it.
OK, so this is not meaningfully different to just loading the driver
normally - it's exactly the same scenario.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140826/57d05d8e/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry Redingtis 2014-08-26 klockan 12:55 +0200 skrev Thierry Reding:
Quoted 6 lines
So the firmware does control the resources to a point where the display hardware is initialized and then it will happily forget about them. The device will keep scanning out the framebuffer and simplefb can update it with boot messages. To prevent the console from suddenly disappearing the kernel needs to make sure that the resources aren't inadvertently turned off at some more or less random point in time.
Which imho is until simplefb is unbound from the device.
Separately to this there needs to be a in-kernel handover procedure where a new driver (i.e. video kms driver) can bind to a device and take over resources, but it's completely unrelated to who owns the hardware resources while simplefb is the active driver for the device.
It is not clear to me where the hardware resources should be listed in DT, being it a simplefb node or part of the actual hardware device node properly marked as dynamic boot defaults or something else? It's somewhere inbetween hardware and virtual device, and somewhat volatile. As far as simplefb is concerned it is a hardware desription of the framebuffer, but for a kms driver it's no more than firmware handover of boottime settings and ceases to exists once the kms driver have reconfigured the hardware.
What I can do is to list some properties that these settings need to provide:
1. Handover of hardware settings from bootloader to kernel.
2. Hardware description for simplefb use. It's at this level not really any different from any other hardware.
3. Volatile and removed when kms driver have reconfigured the hardware or it's been decided that the (virtual) device should not be active.
Regarding 3 and kexec as mentioned earlier. A new set of properties may be added again for kexec usage to describe the current framebuffer for the new kernel but op to the system which prepares for kexec to determine. Should be no different in mechanism from bootloader to kernel handover (the kexecing kernel is the bootloader in kexec case).
Regards
Henrik
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 8 lines · Henrik Nordstr?m
It is not clear to me where the hardware resources should be listed in DT, being it a simplefb node or part of the actual hardware device node properly marked as dynamic boot defaults or something else? It's somewhere inbetween hardware and virtual device, and somewhat volatile. As far as simplefb is concerned it is a hardware desription of the framebuffer, but for a kms driver it's no more than firmware handover of boottime settings and ceases to exists once the kms driver have reconfigured the hardware.
Is simplefb something that should be in the device tree distinctly in
the first place - shouldn't it be a subset of the functionality of the
video nodes? It's the same hardware being driven differently.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140827/b867ffed/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 11 lines · Mark Brown
Quoted 8 lines · Henrik Nordstr?m
It is not clear to me where the hardware resources should be listed in DT, being it a simplefb node or part of the actual hardware device node properly marked as dynamic boot defaults or something else? It's somewhere inbetween hardware and virtual device, and somewhat volatile. As far as simplefb is concerned it is a hardware desription of the framebuffer, but for a kms driver it's no more than firmware handover of boottime settings and ceases to exists once the kms driver have reconfigured the hardware.
Quoted 3 lines
Is simplefb something that should be in the device tree distinctly in the first place - shouldn't it be a subset of the functionality of the video nodes? It's the same hardware being driven differently.
Therorically, yes, but that would mean knowing beforehand what the final binding will look like, even before submitting the driver. Since the bindings are always reviewed, and most of the time changed slightly, that wouldn't work very well with the DT as a stable ABI policy I guess.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140827/5c253fd7/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi Maxime,
Quoted 16 lines · Maxime Ripard
Quoted 11 lines · Mark Brown
Quoted 8 lines · Henrik Nordstr?m
It is not clear to me where the hardware resources should be listed in DT, being it a simplefb node or part of the actual hardware device node properly marked as dynamic boot defaults or something else? It's somewhere inbetween hardware and virtual device, and somewhat volatile. As far as simplefb is concerned it is a hardware desription of the framebuffer, but for a kms driver it's no more than firmware handover of boottime settings and ceases to exists once the kms driver have reconfigured the hardware.
Quoted 3 lines
Is simplefb something that should be in the device tree distinctly in the first place - shouldn't it be a subset of the functionality of the video nodes? It's the same hardware being driven differently.
Quoted 5 lines
Therorically, yes, but that would mean knowing beforehand what the final binding will look like, even before submitting the driver. Since the bindings are always reviewed, and most of the time changed slightly, that wouldn't work very well with the DT as a stable ABI policy I guess.
If you don't know how the bindings for a device will look like at the time of writing your DTS, you're always screwed, whether you add a simpefb node or not.
If you know how the bindings look like, just add the device, with an extra "linux,simplefb" compatibility value.
If you don't know how the bindings look like, do your utter best in guessing. Your DTS must be amended later anyway, either because you guessed wrong[*] (in case you added a node to have simplefb working), or because you have to add a real device node (in case you didn't add one for simplefb).
[*] Actually you may have guessed right, in which case it'll continue
working as-is, and everybody will be happy.
Whether you want to keep backwards-compatibility in your future driver with the "guessed wrong" node is up to you.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi!
Quoted 30 lines · Geert Uytterhoeven
Hi Maxime,
Quoted 16 lines · Maxime Ripard
Quoted 11 lines · Mark Brown
Quoted 8 lines · Henrik Nordstr?m
It is not clear to me where the hardware resources should be listed in DT, being it a simplefb node or part of the actual hardware device node properly marked as dynamic boot defaults or something else? It's somewhere inbetween hardware and virtual device, and somewhat volatile. As far as simplefb is concerned it is a hardware desription of the framebuffer, but for a kms driver it's no more than firmware handover of boottime settings and ceases to exists once the kms driver have reconfigured the hardware.
Quoted 3 lines
Is simplefb something that should be in the device tree distinctly in the first place - shouldn't it be a subset of the functionality of the video nodes? It's the same hardware being driven differently.
Quoted 5 lines
Therorically, yes, but that would mean knowing beforehand what the final binding will look like, even before submitting the driver. Since the bindings are always reviewed, and most of the time changed slightly, that wouldn't work very well with the DT as a stable ABI policy I guess.
If you don't know how the bindings for a device will look like at the time of writing your DTS, you're always screwed, whether you add a simpefb node or not.
Quoted 7 lines
If you know how the bindings look like, just add the device, with an extra "linux,simplefb" compatibility value.
If you don't know how the bindings look like, do your utter best in guessing. Your DTS must be amended later anyway, either because you guessed wrong[*] (in case you added a node to have simplefb working), or because you have to add a real device node (in case you didn't add one for simplefb).
Let's be conservative and consider the case where we would guess wrong.
If we just rely on a simplefb node, when reviewing and integrating the "new" bindings to describe accureately the various IPs involved in the display path, we would obviously create new compatibles for them. Since it's new compatibles, we can come up with any binding we'd like, without have to consider the backward compatibility, since it's a new binding.
Then, we just remove the simplefb, all is good.
If we were to try to create our bindings for all the IPs involved, and were not pleased with the binding anymore when merging the driver, then we would have to break the bindings, since we don't introduce a new compatible anymore, but modifying an existing one.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140827/c3b72ee2/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 25 lines · Maxime Ripard
Quoted 14 lines
Quoted 9 lines
Quoted 3 lines
Is simplefb something that should be in the device tree distinctly in the first place - shouldn't it be a subset of the functionality of the video nodes? It's the same hardware being driven differently.
Therorically, yes, but that would mean knowing beforehand what the final binding will look like, even before submitting the driver. Since the bindings are always reviewed, and most of the time changed slightly, that wouldn't work very well with the DT as a stable ABI policy I guess.
If you don't know how the bindings for a device will look like at the time of writing your DTS, you're always screwed, whether you add a simpefb node or not.
Quoted 7 lines
If you know how the bindings look like, just add the device, with an extra "linux,simplefb" compatibility value.
If you don't know how the bindings look like, do your utter best in guessing. Your DTS must be amended later anyway, either because you guessed wrong[*] (in case you added a node to have simplefb working), or because you have to add a real device node (in case you didn't add one for simplefb).Let's be conservative and consider the case where we would guess wrong.
Quoted 8 lines
If we just rely on a simplefb node, when reviewing and integrating the "new" bindings to describe accureately the various IPs involved in the display path, we would obviously create new compatibles for them. Since it's new compatibles, we can come up with any binding we'd like, without have to consider the backward compatibility, since it's a new binding.
Then, we just remove the simplefb, all is good.
I would keep the simplefb compatible value. Else you break compatibility with old kernels that don't have your new driver.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 34 lines · Geert Uytterhoeven
Quoted 32 lines · Maxime Ripard
Quoted 14 lines
Quoted 9 lines
Quoted 3 lines
Is simplefb something that should be in the device tree distinctly in the first place - shouldn't it be a subset of the functionality of the video nodes? It's the same hardware being driven differently.
Therorically, yes, but that would mean knowing beforehand what the final binding will look like, even before submitting the driver. Since the bindings are always reviewed, and most of the time changed slightly, that wouldn't work very well with the DT as a stable ABI policy I guess.
If you don't know how the bindings for a device will look like at the time of writing your DTS, you're always screwed, whether you add a simpefb node or not.
Quoted 7 lines
If you know how the bindings look like, just add the device, with an extra "linux,simplefb" compatibility value.
If you don't know how the bindings look like, do your utter best in guessing. Your DTS must be amended later anyway, either because you guessed wrong[*] (in case you added a node to have simplefb working), or because you have to add a real device node (in case you didn't add one for simplefb).Let's be conservative and consider the case where we would guess wrong.
If we just rely on a simplefb node, when reviewing and integrating the "new" bindings to describe accureately the various IPs involved in the display path, we would obviously create new compatibles for them. Since it's new compatibles, we can come up with any binding we'd like, without have to consider the backward compatibility, since it's a new binding.
Quoted 4 lines
Quoted 1 line
Then, we just remove the simplefb, all is good.
I would keep the simplefb compatible value. Else you break compatibility with old kernels that don't have your new driver.
Yes, true. Since the simplefb will be injected by u-boot, it will be there anyway.
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140827/f1cfe555/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Maxime RipardQuoted 51 lines · Maxime Ripard
Hi!
Quoted 30 lines · Geert Uytterhoeven
Hi Maxime,
Quoted 16 lines · Maxime Ripard
Quoted 11 lines · Mark Brown
Quoted 8 lines · Henrik Nordstr?m
It is not clear to me where the hardware resources should be listed in DT, being it a simplefb node or part of the actual hardware device node properly marked as dynamic boot defaults or something else? It's somewhere inbetween hardware and virtual device, and somewhat volatile. As far as simplefb is concerned it is a hardware desription of the framebuffer, but for a kms driver it's no more than firmware handover of boottime settings and ceases to exists once the kms driver have reconfigured the hardware.
Quoted 3 lines
Is simplefb something that should be in the device tree distinctly in the first place - shouldn't it be a subset of the functionality of the video nodes? It's the same hardware being driven differently.
Quoted 5 lines
Therorically, yes, but that would mean knowing beforehand what the final binding will look like, even before submitting the driver. Since the bindings are always reviewed, and most of the time changed slightly, that wouldn't work very well with the DT as a stable ABI policy I guess.
If you don't know how the bindings for a device will look like at the time of writing your DTS, you're always screwed, whether you add a simpefb node or not.
Quoted 7 lines
If you know how the bindings look like, just add the device, with an extra "linux,simplefb" compatibility value.
If you don't know how the bindings look like, do your utter best in guessing. Your DTS must be amended later anyway, either because you guessed wrong[*] (in case you added a node to have simplefb working), or because you have to add a real device node (in case you didn't add one for simplefb).Let's be conservative and consider the case where we would guess wrong.
If we just rely on a simplefb node, when reviewing and integrating the "new" bindings to describe accureately the various IPs involved in the display path, we would obviously create new compatibles for them. Since it's new compatibles, we can come up with any binding we'd like, without have to consider the backward compatibility, since it's a new binding.
Quoted 6 lines
Then, we just remove the simplefb, all is good.
If we were to try to create our bindings for all the IPs involved, and were not pleased with the binding anymore when merging the driver, then we would have to break the bindings, since we don't introduce a new compatible anymore, but modifying an existing one.
It's usually a bad idea to merge a binding without an appropriate implementation thereof in a driver. It's been done in the past and very often has resulted in bindings that turned out unusable.
You could start out small and only describe the various individual IP blocks that exist in the hardware with reg, interrupts, clock, etc. properties, most of which should be known up front. Then you could try to find out where simplefb fits best.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140827/3c54a330/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Maxime Ripardons 2014-08-27 klockan 10:55 +0200 skrev Maxime Ripard:
Quoted 6 lines
If we just rely on a simplefb node, when reviewing and integrating the "new" bindings to describe accureately the various IPs involved in the display path, we would obviously create new compatibles for them. Since it's new compatibles, we can come up with any binding we'd like, without have to consider the backward compatibility, since it's a new binding.
My gut feeling is that the attributes needed by simplefb belong in the actual hardware node somehow, with a standard layout so it can be applied on all compatible video devices.
The complication is that these attributes is volatile and not really set/defined by hardware. Similar to UART baud rate (and kernel command line if you like).
Regards
Henrik
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Geert UytterhoevenHi All,
Quoted 38 lines · Geert Uytterhoeven
Hi Maxime,
Quoted 16 lines · Maxime Ripard
Quoted 11 lines · Mark Brown
Quoted 8 lines · Henrik Nordstr?m
It is not clear to me where the hardware resources should be listed in DT, being it a simplefb node or part of the actual hardware device node properly marked as dynamic boot defaults or something else? It's somewhere inbetween hardware and virtual device, and somewhat volatile. As far as simplefb is concerned it is a hardware desription of the framebuffer, but for a kms driver it's no more than firmware handover of boottime settings and ceases to exists once the kms driver have reconfigured the hardware.
Quoted 3 lines
Is simplefb something that should be in the device tree distinctly in the first place - shouldn't it be a subset of the functionality of the video nodes? It's the same hardware being driven differently.
Quoted 5 lines
Therorically, yes, but that would mean knowing beforehand what the final binding will look like, even before submitting the driver. Since the bindings are always reviewed, and most of the time changed slightly, that wouldn't work very well with the DT as a stable ABI policy I guess.
If you don't know how the bindings for a device will look like at the time of writing your DTS, you're always screwed, whether you add a simpefb node or not.
If you know how the bindings look like, just add the device, with an extra "linux,simplefb" compatibility value.
If you don't know how the bindings look like, do your utter best in guessing. Your DTS must be amended later anyway, either because you guessed wrong[*] (in case you added a node to have simplefb working), or because you have to add a real device node (in case you didn't add one for simplefb).
Quoted 4 lines
[*] Actually you may have guessed right, in which case it'll continue
working as-is, and everybody will be happy.
Whether you want to keep backwards-compatibility in your future driver with the "guessed wrong" node is up to you.
I apologise if I'm stepping on anyone's toes or horribly misrepresenting device tree's capabilities, but couldn't we start out with something like:
disp at whatever {
compatible = "sunxi,sun4i-disp";
clocks = <&stuff 1>, <&stuff 2>, <&stuff 3>;
}as our binding?
u-boot could then set up a framebuffer and mangle this to:
disp at whatever {
compatible = "sunxi,sun4i-disp", "linux,simplefb";
clocks = <&stuff 1>, <&stuff 2>, <&stuff 3>;
// simplefb stuff
}Hell, if we have a reserved memory driver, couldn't we then mangle this to something like:
disp at whatever {
compatible = "sunxi,sun4i-disp", "linux,simplefb";
clocks = <&stuff 1>, <&stuff 2>, <&stuff 3>;
// simplefb stuff
// reserved mem stuff
}simplefb is modified to be smart enough to grab the clocks (that's a small amount of code that almost every DT-enabled driver has, right?) and if we're going to use the reserved memory driver to ensure nobody messes with it's in-memory framebuffer, it'll have to deal with that too.
Eventually sunxi-kms gets submitted, and it takes the "sunxi,sun4i-disp" compatible, which we've already defined, however we need some more stuff so we just add more stuff to the binding and end up with something like:
disp at whatever {
compatible = "sunxi,sun4i-disp";
clocks = <&stuff 1>, <&stuff 2>, <&stuff 3>;
// sunxi-kms stuff
}I believe there'd be no backwards compatibility issues as we're only adding, not subtracting or modifying. We already know which clocks are required for the display IP, right? And if not, we can add them. I believe this minimises the mangling u-boot has to do (at least initially) and is forward and backward compatible.
That'd work, right?
Thanks,
Signature · 5 lines
Julian Calaby Email: julian.calaby at gmail.com Profile: http://www.google.com/profiles/julian.calaby/ .Plan: http://sites.google.com/site/juliancalaby/
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi Julian,
Quoted 47 lines · Julian Calaby
Hi All,
Quoted 38 lines · Geert Uytterhoeven
Hi Maxime,
Quoted 16 lines · Maxime Ripard
Quoted 11 lines · Mark Brown
Quoted 8 lines · Henrik Nordstr?m
It is not clear to me where the hardware resources should be listed in DT, being it a simplefb node or part of the actual hardware device node properly marked as dynamic boot defaults or something else? It's somewhere inbetween hardware and virtual device, and somewhat volatile. As far as simplefb is concerned it is a hardware desription of the framebuffer, but for a kms driver it's no more than firmware handover of boottime settings and ceases to exists once the kms driver have reconfigured the hardware.
Quoted 3 lines
Is simplefb something that should be in the device tree distinctly in the first place - shouldn't it be a subset of the functionality of the video nodes? It's the same hardware being driven differently.
Quoted 5 lines
Therorically, yes, but that would mean knowing beforehand what the final binding will look like, even before submitting the driver. Since the bindings are always reviewed, and most of the time changed slightly, that wouldn't work very well with the DT as a stable ABI policy I guess.
If you don't know how the bindings for a device will look like at the time of writing your DTS, you're always screwed, whether you add a simpefb node or not.
If you know how the bindings look like, just add the device, with an extra "linux,simplefb" compatibility value.
If you don't know how the bindings look like, do your utter best in guessing. Your DTS must be amended later anyway, either because you guessed wrong[*] (in case you added a node to have simplefb working), or because you have to add a real device node (in case you didn't add one for simplefb).Quoted 4 lines
[*] Actually you may have guessed right, in which case it'll continue
working as-is, and everybody will be happy.
Whether you want to keep backwards-compatibility in your future driver with the "guessed wrong" node is up to you.
Quoted 7 lines
I apologise if I'm stepping on anyone's toes or horribly misrepresenting device tree's capabilities, but couldn't we start out with something like:
disp at whatever { compatible = "sunxi,sun4i-disp"; clocks = <&stuff 1>, <&stuff 2>, <&stuff 3>;
Unfortunately, it's slightly more complicated than that, since there is several clocks involved, that feed several different IPs that need to stay on.
In this patch, and given the current code we have, we need to have the gates for the HDMI controller, the LCD controller and the display backend, which are three different IPs, with one clock each, that would be described by three different nodes.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140827/a190f9d6/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingQuoted 56 lines · Thierry Reding
Quoted 46 lines · Hans de Goede
Hi,
Quoted 43 lines · Thierry Reding
Quoted 22 lines · Hans de Goede
Quoted 21 lines · Thierry Reding
Quoted 19 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 6 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
Quoted 7 lines
Quoted 3 lines
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Are you saying that this driver would become "dirty" with such a patch?
Quoted 8 lines
Quoted 3 lines
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
It is platform specific in that your platform may require certain clocks to remain on. The next platform may require power domains to remain on during boot and yet another one may rely on regulators to stay on during boot. By your argument simplefb will need to be taught to handle pretty much every type of resource that the kernel has.
Quoted 4 lines
As for the suggestion to simply never disable the plls / ahb gates by blocking them from ever being disabled in the sunxi clock driver, that is not really a solution either, as we want to be able to turn these things off to safe power on screen blank once control has been turned over to the kms driver.
Quoted 8 lines
Quoted 2 lines
Then perhaps part of the hand-off procedure between simplefb and DRM/KMS should involve marking PLLs or "gates" as properly managed.
And by your earlier argument also power domains, regulators, etc. So now we need to add code to each of the clock core, power-domain core, regulator core, etc. to have them now about this initially unmanaged state thing you're introducing, as well as modify all involved clock / regulator / etc. drivers to mark certain resources as unmanaged.
Quoted 7 lines
Hmm... that's true. But we already have a way to deal with exactly this situation for regulators. There's a property called regulator-boot-on which a bootloader should set whet it has enabled a given regulator. It can of course also be set statically in a DTS if it's know upfront that a bootloader will always enable it. Perhaps what we need is a similar property for clocks so that the clock framework will not inadvertently turn off a clock that's still being used.
There should probably be a generic 'boot-initialized;' property that
can be added to any DT device node. Then uboot can add that property
to the device node for anything it has turned on.
You could even use it to add more info 'boot-initialized = <"9600 8 N 1">;'
That passes the info in an OS agnostic manner.
Quoted 2 lines
Thierry
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingQuoted 27 lines · Thierry Reding
Quoted 26 lines · Hans de Goede
Quoted 24 lines · Thierry Reding
Quoted 14 lines · Maxime Ripard
Quoted 13 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 9 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Quoted 5 lines
Quoted 3 lines
Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Are you saying that this driver would become "dirty" with such a patch?
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
Quoted 7 lines
Quoted 4 lines
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
It is platform specific in that your platform may require certain clocks to remain on.
The platform doesn't. simplefb does. simplefb is the obvious consumer for these clocks, and given the current API and abstraction we have, it should be the one claiming the clocks too.
Quoted 4 lines
The next platform may require power domains to remain on during boot and yet another one may rely on regulators to stay on during boot. By your argument simplefb will need to be taught to handle pretty much every type of resource that the kernel has.
And I wouldn't find anything wrong with that. We're already doing so for any generic driver in the kernel (AHCI, EHCI comes to my mind first, there's probably a lot of others). Why wouldn't we do as such for this one?
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140825/066f03bd/attachment-0001.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 33 lines · Maxime Ripard
Quoted 32 lines · Thierry Reding
Quoted 30 lines · Hans de Goede
Quoted 19 lines · Thierry Reding
Quoted 18 lines · Maxime Ripard
Quoted 16 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 9 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Quoted 5 lines
Quoted 1 line
Are you saying that this driver would become "dirty" with such a patch?
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
Quoted 6 lines
Quoted 2 lines
It is platform specific in that your platform may require certain clocks to remain on.
The platform doesn't. simplefb does. simplefb is the obvious consumer for these clocks, and given the current API and abstraction we have, it should be the one claiming the clocks too.
No. simplefb just wants to write to some memory that hardware has been set up to scan out. The platform requires that the clocks be on. Other platforms may not even allow turning off the clocks.
Quoted 9 lines
Quoted 4 lines
The next platform may require power domains to remain on during boot and yet another one may rely on regulators to stay on during boot. By your argument simplefb will need to be taught to handle pretty much every type of resource that the kernel has.
And I wouldn't find anything wrong with that. We're already doing so for any generic driver in the kernel (AHCI, EHCI comes to my mind first, there's probably a lot of others). Why wouldn't we do as such for this one?
Yes, and we've had similar discussions in those subsystems too.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140825/32926166/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 3 lines · Thierry Reding
No. simplefb just wants to write to some memory that hardware has been set up to scan out. The platform requires that the clocks be on.
Simplefb also requires that the memory is there and is persistent. Fine for discrete graphics cards, fine for rpi where most things are hidden from the ARM core anyway, not so fine for anybody else.
Luc Verhaegen.
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 8 lines · Luc Verhaegen
Quoted 3 lines · Thierry Reding
No. simplefb just wants to write to some memory that hardware has been set up to scan out. The platform requires that the clocks be on.
Simplefb also requires that the memory is there and is persistent. Fine for discrete graphics cards, fine for rpi where most things are hidden from the ARM core anyway, not so fine for anybody else.
I don't understand. This patch series isn't changing anything about the memory aspects of the driver yet it's working for you on sunxi, isn't it? So it can't be all that broken.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140826/9b9b9f75/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 10 lines · Thierry Reding
Quoted 8 lines · Luc Verhaegen
Quoted 3 lines · Thierry Reding
No. simplefb just wants to write to some memory that hardware has been set up to scan out. The platform requires that the clocks be on.
Simplefb also requires that the memory is there and is persistent. Fine for discrete graphics cards, fine for rpi where most things are hidden from the ARM core anyway, not so fine for anybody else.
Quoted 5 lines
I don't understand. This patch series isn't changing anything about the memory aspects of the driver yet it's working for you on sunxi, isn't it? So it can't be all that broken.
Thierry
Oh, i had to go wrestle with UBoot options and reserve 8MB off the top, which the kernel never gets told about. A nice throwback to x86 IGP bioses, a past i had thought i had left behind forgood.
Luc Verhaegen.
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 15 lines · Luc Verhaegen
Quoted 14 lines · Thierry Reding
Quoted 8 lines · Luc Verhaegen
Quoted 3 lines · Thierry Reding
No. simplefb just wants to write to some memory that hardware has been set up to scan out. The platform requires that the clocks be on.
Simplefb also requires that the memory is there and is persistent. Fine for discrete graphics cards, fine for rpi where most things are hidden from the ARM core anyway, not so fine for anybody else.
I don't understand. This patch series isn't changing anything about the memory aspects of the driver yet it's working for you on sunxi, isn't it? So it can't be all that broken.
Quoted 5 lines
Quoted 1 line
Thierry
Oh, i had to go wrestle with UBoot options and reserve 8MB off the top, which the kernel never gets told about. A nice throwback to x86 IGP bioses, a past i had thought i had left behind forgood.
Can you not use the reserved memory code (drivers/of/of_reserved_mem.c in the kernel)? I think that's the generally accepted way to do this with DT.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140826/18f0c06c/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 22 lines · Thierry Reding
Quoted 15 lines · Luc Verhaegen
Quoted 14 lines · Thierry Reding
Quoted 8 lines · Luc Verhaegen
Quoted 3 lines · Thierry Reding
No. simplefb just wants to write to some memory that hardware has been set up to scan out. The platform requires that the clocks be on.
Simplefb also requires that the memory is there and is persistent. Fine for discrete graphics cards, fine for rpi where most things are hidden from the ARM core anyway, not so fine for anybody else.
I don't understand. This patch series isn't changing anything about the memory aspects of the driver yet it's working for you on sunxi, isn't it? So it can't be all that broken.
Quoted 5 lines
Quoted 1 line
Thierry
Oh, i had to go wrestle with UBoot options and reserve 8MB off the top, which the kernel never gets told about. A nice throwback to x86 IGP bioses, a past i had thought i had left behind forgood.
Quoted 5 lines
Can you not use the reserved memory code (
drivers/of/of_reserved_mem.cin the kernel)? I think that's the generally accepted way to do this with DT.Thierry
It was mentioned to me, and I probably could do that, but this seemed even more DT wrangling from within u-boot, and it didn't seem finished yet. Plus, all of this already was way more wrangling than i bargained for, especially with the promise of "simple"-fb. Then there is the really awkward way in which one gets to define clocks outside of a dts/compiler (you've seen the code, right?), i really did not feel like repeating something like that.
Luc Verhaegen.
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 29 lines · Luc Verhaegen
Quoted 22 lines · Thierry Reding
Quoted 15 lines · Luc Verhaegen
Quoted 14 lines · Thierry Reding
Quoted 8 lines · Luc Verhaegen
Quoted 3 lines · Thierry Reding
No. simplefb just wants to write to some memory that hardware has been set up to scan out. The platform requires that the clocks be on.
Simplefb also requires that the memory is there and is persistent. Fine for discrete graphics cards, fine for rpi where most things are hidden from the ARM core anyway, not so fine for anybody else.
I don't understand. This patch series isn't changing anything about the memory aspects of the driver yet it's working for you on sunxi, isn't it? So it can't be all that broken.
Quoted 5 lines
Quoted 1 line
Thierry
Oh, i had to go wrestle with UBoot options and reserve 8MB off the top, which the kernel never gets told about. A nice throwback to x86 IGP bioses, a past i had thought i had left behind forgood.
Quoted 5 lines
Can you not use the reserved memory code (
drivers/of/of_reserved_mem.cin the kernel)? I think that's the generally accepted way to do this with DT.Thierry
Quoted 7 lines
It was mentioned to me, and I probably could do that, but this seemed even more DT wrangling from within u-boot, and it didn't seem finished yet. Plus, all of this already was way more wrangling than i bargained for, especially with the promise of "simple"-fb. Then there is the really awkward way in which one gets to define clocks outside of a dts/compiler (you've seen the code, right?), i really did not feel like repeating something like that.
It could most probably be turned into fairly generic and reusable code so that others can use it. And it would give you a way of recovering those 8 MiB of memory that you'd otherwise loose.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140826/b66e355c/attachment-0001.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingQuoted 37 lines · Thierry Reding
Quoted 36 lines · Maxime Ripard
Quoted 34 lines · Thierry Reding
Quoted 22 lines · Hans de Goede
Quoted 21 lines · Thierry Reding
Quoted 19 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 6 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
Quoted 7 lines
Quoted 3 lines
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Are you saying that this driver would become "dirty" with such a patch?
Quoted 8 lines
Quoted 3 lines
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
It is platform specific in that your platform may require certain clocks to remain on.
Quoted 7 lines
Quoted 3 lines
The platform doesn't. simplefb does. simplefb is the obvious consumer for these clocks, and given the current API and abstraction we have, it should be the one claiming the clocks too.
No. simplefb just wants to write to some memory that hardware has been set up to scan out. The platform requires that the clocks be on. Other platforms may not even allow turning off the clocks.
Like what? the rpi? Come on. Just because the videocore is some black box we know nothing about doesn't mean we should use it as an example.
Any decent enough SoC, with a decent support in the kernel will have clocks for this, and I really wonder how simplefb will behave once its clocks will be turned off...
Quoted 11 lines
Quoted 9 lines
Quoted 4 lines
The next platform may require power domains to remain on during boot and yet another one may rely on regulators to stay on during boot. By your argument simplefb will need to be taught to handle pretty much every type of resource that the kernel has.
And I wouldn't find anything wrong with that. We're already doing so for any generic driver in the kernel (AHCI, EHCI comes to my mind first, there's probably a lot of others). Why wouldn't we do as such for this one?
Yes, and we've had similar discussions in those subsystems too.
Similar discussion, with different outcomes it seems.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140825/cef297d9/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 42 lines · Maxime Ripard
Quoted 41 lines · Thierry Reding
Quoted 39 lines · Maxime Ripard
Quoted 27 lines · Thierry Reding
Quoted 26 lines · Hans de Goede
Quoted 24 lines · Thierry Reding
Quoted 14 lines · Maxime Ripard
Quoted 13 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 9 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Quoted 5 lines
Quoted 3 lines
Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Are you saying that this driver would become "dirty" with such a patch?
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
Quoted 7 lines
Quoted 4 lines
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
It is platform specific in that your platform may require certain clocks to remain on.
The platform doesn't. simplefb does. simplefb is the obvious consumer for these clocks, and given the current API and abstraction we have, it should be the one claiming the clocks too.
Quoted 6 lines
Quoted 3 lines
No. simplefb just wants to write to some memory that hardware has been set up to scan out. The platform requires that the clocks be on. Other platforms may not even allow turning off the clocks.
Like what? the rpi? Come on. Just because the videocore is some black box we know nothing about doesn't mean we should use it as an example.
You make it sound like the Raspberry Pi is somehow less important than sunxi.
Quoted 3 lines
Any decent enough SoC, with a decent support in the kernel will have clocks for this, and I really wonder how simplefb will behave once its clocks will be turned off...
There are other devices besides ARM SoCs that may want to use this driver and that don't have clock support.
But you're missing my point. What I'm saying is that the simplefb driver is meant to serve as a way to take over whatever framebuffer a firmware set up. Therefore I think it makes the most sense to assume that nothing needs to be controlled in any way since already been set up by firmware. Eventually there should be a driver that takes over from simplefb that knows how to properly handle the device's specifics, but that's not simplefb.
The goal of this patch series is to keep clocks from being turned off. But that's not what it does. What it does is turn clocks on to prevent them from being turned off. In my opinion that's a workaround for a deficiency in the kernel (and the firmware/kernel interface) and I think it should be fixed at the root. So a much better solution would be to establish a way for firmware to communicate to the kernel that a given resource has been enabled by firmware and shouldn't be disabled. Such a solution can be implement for all types of resources and can be reused by all drivers since they don't have to worry about these details.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140826/6aaaf58f/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 47 lines · Thierry Reding
Quoted 46 lines · Maxime Ripard
Quoted 44 lines · Thierry Reding
Quoted 33 lines · Maxime Ripard
Quoted 32 lines · Thierry Reding
Quoted 30 lines · Hans de Goede
Quoted 19 lines · Thierry Reding
Quoted 18 lines · Maxime Ripard
Quoted 16 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Wed, Aug 13, 2014 at 10:38:09AM -0600, Stephen Warren wrote:
[...]
Quoted 9 lines
Quoted 2 lines
If not, perhaps the clock driver should force the clock to be enabled (perhaps only if the DRM/KMS driver isn't enabled?).
I'm sorry, but I'm not going to take any code that will do that in our clock driver.
I'm not going to have a huge list of ifdef depending on configuration options to know which clock to enable, especially when
clk_getshould have the consumer device as an argument.Are you saying is that you want to solve a platform-specific problem by pushing code into simple, generic drivers so that your platform code can stay "clean"?
Quoted 5 lines
Quoted 1 line
Are you saying that this driver would become "dirty" with such a patch?
Yes. Others have said the same and even provided alternative solutions on how to solve what's seemingly a platform-specific problem in a platform-specific way.
This is not platform specific, any platform with a complete clock driver will suffer from the same problem (the clock driver disabling unclaimed ahb gates, and thus killing the video output) if it wants to use simplefb for early console support.
Quoted 6 lines
Quoted 2 lines
It is platform specific in that your platform may require certain clocks to remain on.
The platform doesn't. simplefb does. simplefb is the obvious consumer for these clocks, and given the current API and abstraction we have, it should be the one claiming the clocks too.
No. simplefb just wants to write to some memory that hardware has been set up to scan out. The platform requires that the clocks be on. Other platforms may not even allow turning off the clocks.
Quoted 5 lines
Quoted 2 lines
Like what? the rpi? Come on. Just because the videocore is some black box we know nothing about doesn't mean we should use it as an example.
You make it sound like the Raspberry Pi is somehow less important than sunxi.
No. It's just bad example for driver development because on rpi you are not in control of the hardware. Then the issue of enabling and disabling clock becomes moot because you do not have access to clock at all.
Quoted 7 lines
Quoted 4 lines
Any decent enough SoC, with a decent support in the kernel will have clocks for this, and I really wonder how simplefb will behave once its clocks will be turned off...
There are other devices besides ARM SoCs that may want to use this driver and that don't have clock support.
Then the clock support part should be compiled out in that case. Just like any other driver that has code that is disabled when some kernel susbsystem is compiled out.
Quoted 8 lines
But you're missing my point. What I'm saying is that the simplefb driver is meant to serve as a way to take over whatever framebuffer a firmware set up. Therefore I think it makes the most sense to assume that nothing needs to be controlled in any way since already been set up by firmware. Eventually there should be a driver that takes over from simplefb that knows how to properly handle the device's specifics, but that's not simplefb.
The simplefb driver is not controlling anything but is using resources set up by firmware.
Currently DT has no way to express that state so the proposed solution is to state in DT that simplefb controls the resources that are needed for the framebuffer on the platform. Which resources are that is platform specific and that platform specific is handled by the bootloader that fills in what resources simplefb so 'controls' in its DT node.
This way the resource is not disabled by the generic kernel framework such as the clock framework.
Quoted 8 lines
The goal of this patch series is to keep clocks from being turned off. But that's not what it does. What it does is turn clocks on to prevent them from being turned off. In my opinion that's a workaround for a deficiency in the kernel (and the
firmware/kernelinterface) and I think it should be fixed at the root. So a much better solution would be to establish a way for firmware to communicate to the kernel that a given resource has been enabled by firmware and shouldn't be disabled.
That's not the case here. If you later decide you do not want a framebuffer you should be able to stop simplefb, disable the clock that it claimed and reclaim the fb memory even if you do not replace it with a full KMS driver. That way you would not need a special 'headless server bootloader' so long as you do not mind your server os installation enables the display temporarily during boot.
Thanks
Michal
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingQuoted 9 lines · Thierry Reding
Quoted 6 lines
Quoted 3 lines
No. simplefb just wants to write to some memory that hardware has been set up to scan out. The platform requires that the clocks be on. Other platforms may not even allow turning off the clocks.
Like what? the rpi? Come on. Just because the videocore is some black box we know nothing about doesn't mean we should use it as an example.
You make it sound like the Raspberry Pi is somehow less important than sunxi.
No. What I mean is that it seems like we are somehow punished, or at least blamed, for having a better and more complete kernel support.
Quoted 6 lines
Quoted 3 lines
Any decent enough SoC, with a decent support in the kernel will have clocks for this, and I really wonder how simplefb will behave once its clocks will be turned off...
There are other devices besides ARM SoCs that may want to use this driver and that don't have clock support.
And in this case, with this patch, simplefb will not claim any clock, nor will fail probing.
Quoted 7 lines
But you're missing my point. What I'm saying is that the simplefb driver is meant to serve as a way to take over whatever framebuffer a firmware set up. Therefore I think it makes the most sense to assume that nothing needs to be controlled in any way since already been set up by firmware. Eventually there should be a driver that takes over from simplefb that knows how to properly handle the device's specifics, but that's not simplefb.
I guess such a hand over if it were to happen in the kernel would involve the second driver claiming the resources before the first one release them. How is that different in this case?
Quoted 9 lines
The goal of this patch series is to keep clocks from being turned off. But that's not what it does. What it does is turn clocks on to prevent them from being turned off. In my opinion that's a workaround for a deficiency in the kernel (and the
firmware/kernelinterface) and I think it should be fixed at the root. So a much better solution would be to establish a way for firmware to communicate to the kernel that a given resource has been enabled by firmware and shouldn't be disabled. Such a solution can be implement for all types of resources and can be reused by all drivers since they don't have to worry about these details.
Mike Turquette repeatedly said that he was against such a DT property:
https://lkml.org/lkml/2014/5/12/693
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140826/0a274db7/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 5 lines · Maxime Ripard
Quoted 4 lines · Thierry Reding
Quoted 4 lines
Quoted 3 lines
No. simplefb just wants to write to some memory that hardware has been set up to scan out. The platform requires that the clocks be on. Other platforms may not even allow turning off the clocks.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Like what? the rpi? Come on. Just because the videocore is some black box we know nothing about doesn't mean we should use it as an example.
You make it sound like the Raspberry Pi is somehow less important than sunxi.
No. What I mean is that it seems like we are somehow punished, or at least blamed, for having a better and more complete kernel support.
This isn't a competition. Nobody's punishing or blaming anyone. This is about finding the best solution for the problem at hand.
Quoted 18 lines
Quoted 6 lines
Quoted 3 lines
Any decent enough SoC, with a decent support in the kernel will have clocks for this, and I really wonder how simplefb will behave once its clocks will be turned off...
There are other devices besides ARM SoCs that may want to use this driver and that don't have clock support.
And in this case, with this patch, simplefb will not claim any clock, nor will fail probing.
Quoted 7 lines
But you're missing my point. What I'm saying is that the simplefb driver is meant to serve as a way to take over whatever framebuffer a firmware set up. Therefore I think it makes the most sense to assume that nothing needs to be controlled in any way since already been set up by firmware. Eventually there should be a driver that takes over from simplefb that knows how to properly handle the device's specifics, but that's not simplefb.
Quoted 3 lines
I guess such a hand over if it were to happen in the kernel would involve the second driver claiming the resources before the first one release them. How is that different in this case?
It's different in that that driver will be hardware specific and know exactly what clock and other resources are required. It will have a device-specific binding.
Quoted 10 lines
Quoted 9 lines
The goal of this patch series is to keep clocks from being turned off. But that's not what it does. What it does is turn clocks on to prevent them from being turned off. In my opinion that's a workaround for a deficiency in the kernel (and the
firmware/kernelinterface) and I think it should be fixed at the root. So a much better solution would be to establish a way for firmware to communicate to the kernel that a given resource has been enabled by firmware and shouldn't be disabled. Such a solution can be implement for all types of resources and can be reused by all drivers since they don't have to worry about these details.
Quoted 2 lines
Mike Turquette repeatedly said that he was against such a DT property:
https://lkml.org/lkml/2014/5/12/693
Mike says in that email that he's opposing the addition of a property for clocks that is the equivalent of regulator-always-on. That's not what this is about. If at all it'd be a property to mark a clock that should not be disabled by default because it's essential.
Adding Mike on this subthread too.
Either way, Mark already suggested a different alternative in another subthread, namely to add a new kind of checkpoint at which subsystems can call a "disable unused" function that's called later than a late initcall. This is not going to fix things for you immediately because the clocks will still be switched off (only later) if you don't have a real driver that's claiming the clocks. But you can work around that for now by making the relevant clocks always on and remove that workaround once a real driver is loaded that knows how to handle them properly.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140826/587fca7a/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi,
Quoted 64 lines · Thierry Reding
Quoted 5 lines · Maxime Ripard
Quoted 4 lines · Thierry Reding
Quoted 4 lines
Quoted 3 lines
No. simplefb just wants to write to some memory that hardware has been set up to scan out. The platform requires that the clocks be on. Other platforms may not even allow turning off the clocks.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Like what? the rpi? Come on. Just because the videocore is some black box we know nothing about doesn't mean we should use it as an example.
You make it sound like the Raspberry Pi is somehow less important than sunxi.
No. What I mean is that it seems like we are somehow punished, or at least blamed, for having a better and more complete kernel support.
This isn't a competition. Nobody's punishing or blaming anyone. This is about finding the best solution for the problem at hand.
Quoted 18 lines
Quoted 6 lines
Quoted 3 lines
Any decent enough SoC, with a decent support in the kernel will have clocks for this, and I really wonder how simplefb will behave once its clocks will be turned off...
There are other devices besides ARM SoCs that may want to use this driver and that don't have clock support.
And in this case, with this patch, simplefb will not claim any clock, nor will fail probing.
Quoted 7 lines
But you're missing my point. What I'm saying is that the simplefb driver is meant to serve as a way to take over whatever framebuffer a firmware set up. Therefore I think it makes the most sense to assume that nothing needs to be controlled in any way since already been set up by firmware. Eventually there should be a driver that takes over from simplefb that knows how to properly handle the device's specifics, but that's not simplefb.
Quoted 3 lines
I guess such a hand over if it were to happen in the kernel would involve the second driver claiming the resources before the first one release them. How is that different in this case?
It's different in that that driver will be hardware specific and know exactly what clock and other resources are required. It will have a device-specific binding.
Quoted 10 lines
Quoted 9 lines
The goal of this patch series is to keep clocks from being turned off. But that's not what it does. What it does is turn clocks on to prevent them from being turned off. In my opinion that's a workaround for a deficiency in the kernel (and the
firmware/kernelinterface) and I think it should be fixed at the root. So a much better solution would be to establish a way for firmware to communicate to the kernel that a given resource has been enabled by firmware and shouldn't be disabled. Such a solution can be implement for all types of resources and can be reused by all drivers since they don't have to worry about these details.Quoted 2 lines
Mike Turquette repeatedly said that he was against such a DT property:
https://lkml.org/lkml/2014/5/12/693Mike says in that email that he's opposing the addition of a property for clocks that is the equivalent of regulator-always-on. That's not what this is about. If at all it'd be a property to mark a clock that should not be disabled by default because it's essential.
Adding Mike on this subthread too.
Quoted 9 lines
Either way, Mark already suggested a different alternative in another subthread, namely to add a new kind of checkpoint at which subsystems can call a "disable unused" function that's called later than a late initcall. This is not going to fix things for you immediately because the clocks will still be switched off (only later) if you don't have a real driver that's claiming the clocks. But you can work around that for now by making the relevant clocks always on and remove that workaround once a real driver is loaded that knows how to handle them properly.
This will simply not work, and is a ton more complicated then simply teaching simplefb about a clocks property, which is a really simple and clean patch.
First of all let me explain why this won't work. When should those subsystems call this "later then a late initcall" call ? the kms driver may very well be a kernel module, which will be loaded by userspace, so we would need this to be triggered by userspace, but when ?
When the initrd is done? What then if the kms driver is not in the initrd, so maybe when udev is done enumerating devices, but what then if the kernel is still enumerating hardware at this time? Will we just put a sleep 30 in our initscripts to make sure the kernel is done scanning all busses, will that be long enough? Maybe we need to re-introduce the scsi_wait_done kernel module which was added as an ugly hack to allow userspace to wait for the kernel to have finished scanning scsi (and ata / sata) busses, for controllers found at the time the module was load. Which never worked reliable, because it would be possible that the controller itself still needed to be discovered. We've spend years cleaning up userspace enough to be able to kill scsi_wait_done. We've already been down this road of waiting for hw enumeration to be done, and the problem is that on modern systems *it is never done*.
So second of all, Thierry, what exactly is the technical argument against adding support for dealing with clocks to simplefb ? I've heard a lot of people in favor of it, and only pretty much you against it, and your argument so far seems to boil down to "I don't like it", which is not really a technical sound argument IMHO. Moreover all the alternatives seem to be horribly complicated and most of them also seem to have several issues which will make them simply not work reliable.
Regards,
Hans
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Can you please fix you mail setup. You're addressing me directly in this email, yet I'm neither in To: nor Cc: headers. That's really annoying.
Quoted 81 lines · Hans de Goede
Hi,
Quoted 64 lines · Thierry Reding
Quoted 5 lines · Maxime Ripard
Quoted 4 lines · Thierry Reding
Quoted 4 lines
Quoted 3 lines
No. simplefb just wants to write to some memory that hardware has been set up to scan out. The platform requires that the clocks be on. Other platforms may not even allow turning off the clocks.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Like what? the rpi? Come on. Just because the videocore is some black box we know nothing about doesn't mean we should use it as an example.
You make it sound like the Raspberry Pi is somehow less important than sunxi.
No. What I mean is that it seems like we are somehow punished, or at least blamed, for having a better and more complete kernel support.
This isn't a competition. Nobody's punishing or blaming anyone. This is about finding the best solution for the problem at hand.
Quoted 18 lines
Quoted 6 lines
Quoted 3 lines
Any decent enough SoC, with a decent support in the kernel will have clocks for this, and I really wonder how simplefb will behave once its clocks will be turned off...
There are other devices besides ARM SoCs that may want to use this driver and that don't have clock support.
And in this case, with this patch, simplefb will not claim any clock, nor will fail probing.
Quoted 7 lines
But you're missing my point. What I'm saying is that the simplefb driver is meant to serve as a way to take over whatever framebuffer a firmware set up. Therefore I think it makes the most sense to assume that nothing needs to be controlled in any way since already been set up by firmware. Eventually there should be a driver that takes over from simplefb that knows how to properly handle the device's specifics, but that's not simplefb.
Quoted 3 lines
I guess such a hand over if it were to happen in the kernel would involve the second driver claiming the resources before the first one release them. How is that different in this case?
It's different in that that driver will be hardware specific and know exactly what clock and other resources are required. It will have a device-specific binding.
Quoted 10 lines
Quoted 9 lines
The goal of this patch series is to keep clocks from being turned off. But that's not what it does. What it does is turn clocks on to prevent them from being turned off. In my opinion that's a workaround for a deficiency in the kernel (and the
firmware/kernelinterface) and I think it should be fixed at the root. So a much better solution would be to establish a way for firmware to communicate to the kernel that a given resource has been enabled by firmware and shouldn't be disabled. Such a solution can be implement for all types of resources and can be reused by all drivers since they don't have to worry about these details.Quoted 2 lines
Mike Turquette repeatedly said that he was against such a DT property:
https://lkml.org/lkml/2014/5/12/693Mike says in that email that he's opposing the addition of a property for clocks that is the equivalent of regulator-always-on. That's not what this is about. If at all it'd be a property to mark a clock that should not be disabled by default because it's essential.
Adding Mike on this subthread too.
Quoted 9 lines
Either way, Mark already suggested a different alternative in another subthread, namely to add a new kind of checkpoint at which subsystems can call a "disable unused" function that's called later than a late initcall. This is not going to fix things for you immediately because the clocks will still be switched off (only later) if you don't have a real driver that's claiming the clocks. But you can work around that for now by making the relevant clocks always on and remove that workaround once a real driver is loaded that knows how to handle them properly.
This will simply not work, and is a ton more complicated then simply teaching simplefb about a clocks property, which is a really simple and clean patch.
Quoted 8 lines
First of all let me explain why this won't work. When should those subsystems call this "later then a late initcall" call ? the kms driver may very well be a kernel module, which will be loaded by userspace, so we would need this to be triggered by userspace, but when ?
When the initrd is done? What then if the kms driver is not in the initrd, so maybe when udev is done enumerating devices, but what then if the kernel is still enumerating hardware at this time?
Usually an initrd knows how to wait for all or a given set of devices to be probed. udev is pretty good for that.
Quoted 11 lines
Will we just put a sleep 30
in our initscripts to make sure the kernel is done scanning all busses, will that be long enough? Maybe we need to re-introduce thescsi_wait_donekernel module which was added as an ugly hack to allow userspace to wait for the kernel to have finished scanning scsi (and ata / sata) busses, for controllers found at the time the module was load. Which never worked reliable, because it would be possible that the controller itself still needed to be discovered. We've spend years cleaning up userspace enough to be able to killscsi_wait_done. We've already been down this road of waiting for hw enumeration to be done, and the problem is that on modern systems *it is never done*.
Those are mostly integration issues. If you don't load the driver from initrd then I don't think anybody will complain when there's flicker when it finally gets loaded. The whole point of this is to have early access to the framebuffer and get display and graphics going as soon as possible, so please don't pull in hypothetical scenarios where people manually load drivers half an hour after the system has booted.
Quoted 2 lines
So second of all, Thierry, what exactly is the technical argument against adding support for dealing with clocks to simplefb ?
I've already stated technical arguments against it. You could just go back and read the thread again, or would you rather want me to repeat them for your convenience?
Quoted 1 line
I've heard a lot of people in favor of it,
Of course you have, all the people in favour of it are sunxi people that really want to see this merged because it gives them working display after U-Boot.
Quoted 1 line
and only pretty much you against it,
At least Stephen also spoke out about it. But this quickly devolved into the kind of thread you want to get out of as quickly as possible, so I can't blame him for not continuing this discussion. In fact I'm very much regretting getting into this in the first place. You clearly have no intention to even consider any possible other solution that what was posted, so it's pretty useless to try and convince you.
Quoted 1 line
and your argument so far seems to boil down to "I don't like it",
I'm not surprised that you think so since you seem to be very selective in what you read (or register) and what you don't.
Quoted 4 lines
is not really a technical sound argument IMHO. Moreover all the alternatives seem to be horribly complicated and most of them also seem to have several issues which will make them simply not work reliable.
I'm not an unreasonable person, or at least I like to think so, and if there really isn't a better solution then I won't object to this patch any longer. But as it stands I am not convinced that this is the best solution, so I think we should keep the discussion going for a bit and see if we really can't come up with something that will fix this for a more general case rather than just your particular use-case. It's evidently a recurring problem that others suffer from, too.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140827/0eb53001/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi,
Quoted 2 lines · Thierry Reding
Can you please fix you mail setup. You're addressing me directly in this email, yet I'm neither in To: nor Cc: headers. That's really annoying.
Sorry, I'll pay closer attention that you're in the To when I'm directly addressing you next time.
Quoted 1 line · Hans de Goede
<snip>
Quoted 19 lines
Quoted 19 lines
Quoted 9 lines
Either way, Mark already suggested a different alternative in another subthread, namely to add a new kind of checkpoint at which subsystems can call a "disable unused" function that's called later than a late initcall. This is not going to fix things for you immediately because the clocks will still be switched off (only later) if you don't have a real driver that's claiming the clocks. But you can work around that for now by making the relevant clocks always on and remove that workaround once a real driver is loaded that knows how to handle them properly.
This will simply not work, and is a ton more complicated then simply teaching simplefb about a clocks property, which is a really simple and clean patch.
First of all let me explain why this won't work. When should those subsystems call this "later then a late initcall" call ? the kms driver may very well be a kernel module, which will be loaded by userspace, so we would need this to be triggered by userspace, but when ?
Quoted 6 lines
Quoted 3 lines
When the initrd is done? What then if the kms driver is not in the initrd, so maybe when udev is done enumerating devices, but what then if the kernel is still enumerating hardware at this time?
Usually an initrd knows how to wait for all or a given set of devices to be probed. udev is pretty good for that.
udev does not have a clue how to wait for all devices, it can be used to wait for a specific device to show up, that is true, but this requires adding specific logic for this (class of) device to the initrd init process, which is really sub-optimal.
Quoted 12 lines
Quoted 11 lines
Will we just put a sleep 30
in our initscripts to make sure the kernel is done scanning all busses, will that be long enough? Maybe we need to re-introduce thescsi_wait_donekernel module which was added as an ugly hack to allow userspace to wait for the kernel to have finished scanning scsi (and ata / sata) busses, for controllers found at the time the module was load. Which never worked reliable, because it would be possible that the controller itself still needed to be discovered. We've spend years cleaning up userspace enough to be able to killscsi_wait_done. We've already been down this road of waiting for hw enumeration to be done, and the problem is that on modern systems *it is never done*.
Quoted 6 lines
Those are mostly integration issues. If you don't load the driver from initrd then I don't think anybody will complain when there's flicker when it finally gets loaded. The whole point of this is to have early access to the framebuffer and get display and graphics going as soon as possible, so please don't pull in hypothetical scenarios where people manually load drivers half an hour after the system has booted.
In another mail in this thread you've mentioned 2 uses for simplefb:
1) Serving as *the* fb until a kms driver is present
2) Allowing for output of early kernel boot messages.
I agree that those are the 2 use-cases we're dealing with here.
Note that the whole discussion we're having hear about disabling the clocks once hardware probing is "done", is moot for 1. One possible way mentioned of dealing with 1. is to mark these clocks as always on for now, and then we need to drop this hack (I cannot call this anything else then a hack), once we get kms, meaning interdependencies between the dropping patch and the kms adding patches, etc. All not very pretty.
For 2. We have what you call "mostly integration issues". Allow me to copy and paste in another bit of this thread here:
Quoted 4 lines
Quoted 2 lines
I've been doing low level Linux development for 10 years now and I've worked a lot on storage (raid, iscsi, fcoe support, etc.) in the past.
Ah, so this is now officially a pissing contest, is it?
No I'm merely trying to explain that I've a ton of experience with what you seem to think of as merely integration issues, and they are a royal PITA, and thus to be avoided at all costs. Really, please just trust me on this one, doing the whole add some later then late init call type is a bad idea.
Quoted 6 lines
Quoted 2 lines
So second of all, Thierry, what exactly is the technical argument against adding support for dealing with clocks to simplefb ?
I've already stated technical arguments against it. You could just go back and read the thread again, or would you rather want me to repeat them for your convenience?
It is a long thread, IIRC your main arguments against this are:
1) You don't want this kind of platform-specific knowledge in simplefb
2) That simplefb is supposed to be simple, and this is not simple
As for 1. several people have already argued that clocks as such are an abstract concept, found one many platforms and as such are not platform specific.
Any generic hw driver dealing with embedded platforms, be it ahci, ohci, ehci, etc. has ended up adding abstract support for things like clocks (and other resources). I say abstract support here, since to all these drivers the support was added in a way that no platform specific knowledge is necessary, they just deal with clocks not caring about the specific underlying clock implementation, clock names, etc.
This really is unavoidable. The framebuffer memory needed was mentioned as another example of a resource in this thread. You suggested using the new mem-reserve framework for this. I agree that that is the right thing to do, but even then we still need a way to tie this reserved mem to the simplefb, so that the kernel can know when it is no longer used and can be added to the general memory pool.
If you look at how almost all dt bindings work, then the dt node for a device specifies the resources needed, I don't see why simplefb would be so special that it should be different here. I agree that it is important to get the abstractions right here, but to me it seems that the right abstraction is to be consistent with how all other devices are abstracted and to add needed resources to the dt node for the simplefb.
As for 2. Yes this will add some more code to simplefb, more code but code which is not complicated in anyway, so the simplefb code would become larger but still stay simple. Were as all the suggested alternatives sofar are at least an order of magnitude more complicated, crossing many subsystems, demanding coordination with userspace, etc.
Quoted 5 lines
Quoted 1 line
I've heard a lot of people in favor of it,
Of course you have, all the people in favour of it are sunxi people that really want to see this merged because it gives them working display after U-Boot.
I don't think that that is entirely fair towards Maxime, yes Maxime is a sunxi person, but he usually pushed back hard against anything he considers not clean enough, even if it would enable highly desirable functionality.
Quoted 10 lines
Quoted 2 lines
and only pretty much you against it,
At least Stephen also spoke out about it. But this quickly devolved into the kind of thread you want to get out of as quickly as possible, so I can't blame him for not continuing this discussion. In fact I'm very much regretting getting into this in the first place. You clearly have no intention to even consider any possible other solution that what was posted, so it's pretty useless to try and convince you.
Quoted 4 lines
Quoted 1 line
and your argument so far seems to boil down to "I don't like it",
I'm not surprised that you think so since you seem to be very selective in what you read (or register) and what you don't.
See above, I've summarized the 2 arguments which you've made as "I don't like it" before since to me they seem to be subjective arguments, you say it is too platform specific, but where is the divide line for something being _too_ platform specific ? I realize in the end everything is pretty much subjective. I apologize for the "I don't like it" characterization that was not fair of me.
Quoted 9 lines
Quoted 5 lines
is not really a technical sound argument IMHO. Moreover all the alternatives seem to be horribly complicated and most of them also seem to have several issues which will make them simply not work reliable.
I'm not an unreasonable person, or at least I like to think so, and if there really isn't a better solution then I won't object to this patch any longer.
That is good to hear.
Quoted 1 line
But as it stands I am not convinced that this is the best solution
I'm very much open to a better solution, but so far everything suggested is so much more complicated, that I don;t consider any of the suggestions done so far better.
Quoted 4 lines
so I think we should keep the discussion going for a bit and see if we really can't come up with something that will fix this for a more general case rather than just your particular use-case. It's evidently a recurring problem that others suffer from, too.
Yes needing resources despite the device being behind some generic interface where the main driver code for that interface has no knowledge about such resources sofar, because e.g. on PC-s this was not necessary is a recurring problem, which has been solved already 3 times at least, see the ohci-, ehci- and ahci-platform drivers, and for all 3 the conclusion was that the best solution was to simple add the resources to the dt-node, and add code to claim and enable them.
Regards,
Hans
Quoted 3 lines
Thierry
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 1 line · Hans de Goede
Quoted 1 line · Thierry Reding
snip
Quoted 14 lines
In another mail in this thread you've mentioned 2 uses for simplefb:
1) Serving as *the* fb until a kms driver is present
2) Allowing for output of early kernel boot messages.I agree that those are the 2 use-cases we're dealing with here.
Note that the whole discussion we're having hear about disabling the clocks once hardware probing is "done", is moot for 1. One possible way mentioned of dealing with 1. is to mark these clocks as always on for now, and then we need to drop this hack (I cannot call this anything else then a hack), once we get kms, meaning interdependencies between the dropping patch and the kms adding patches, etc. All not very pretty.
Quoted 2 lines
For 2. We have what you call "mostly integration issues". Allow me to copy and paste in another bit of this thread here:
These are two independent problems.
Quoted 1 line
1) Serving as *the* fb until a kms driver is present
Why can't we whip together a real device specific fbdev driver and quit trying to run without a device specific driver in place? History has shown that to be bad idea except during early boot when there isn't a choice.
fbdev drivers are pretty simple things and you don't have to make one that implements every feature. fbdev driver don't even have to implement mode setting. They can just live with the mode initially provided and refuse to change it. Communicating this initial mode info on the kernel command line is already supported so we don't even need a device tree change. This is the transition tool until KMS gets written.
But it needs to be a device specific fbdev implementation, not simplefb. That's because the device specific driver is going to claim those clocks and regulators.
Quoted 1 line
2) Allowing for output of early kernel boot messages.
For this to work the kernel needs to know two things - address of the framebuffer and the x/y layout. Then just nuke this display when the kernel finishes the boot process.
One of two things will happen.
1) the fbdev driver has been loaded. It has claimed the clocks, taken care of memory, etc. If KMS is around, load it instead. When kernel tries to nuke the display nothing will happen.
2) Your display goes blank because the kernel has disabled clocks and reclaimed the memory. Take that as a hint to write a fbdev driver.
pages more snipped....
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi,
On 08/27/2014 02:44 PM, jonsmirl at gmail.com wrote:
<snip>
Quoted 6 lines
Quoted 1 line
1) Serving as *the* fb until a kms driver is present
Why can't we whip together a real device specific fbdev driver and quit trying to run without a device specific driver in place? History has shown that to be bad idea except during early boot when there isn't a choice.
Writing a kms driver and getting it upstream is not a simple task, and starting with a too limited implementation is dangerous as we need to get the devicetree binding first from the get go.
IOW this is not really a realistic answer to problem 1.
<snip>
Quoted 5 lines
Quoted 1 line
2) Allowing for output of early kernel boot messages.
For this to work the kernel needs to know two things - address of the framebuffer and the x/y layout. Then just nuke this display when the kernel finishes the boot process.
Please read my earlier mails on how completely flawed it is to write "when the kernel finishes the boot process". The problem is that there is no way to really determine when this happens.
Regards,
Hans
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 8 lines · Hans de Goede
Hi,
On 08/27/2014 02:44 PM, jonsmirl at gmail.com wrote:
<snip>
Quoted 2 lines
Quoted 1 line
1) Serving as *the* fb until a kms driver is present
Quoted 8 lines
Quoted 4 lines
Why can't we whip together a real device specific fbdev driver and quit trying to run without a device specific driver in place? History has shown that to be bad idea except during early boot when there isn't a choice.
Writing a kms driver and getting it upstream is not a simple task, and starting with a too limited implementation is dangerous as we need to get the devicetree binding first from the get go.
I didn't say write a kms driver, I said write a fbdev driver. Look in drivers/video/fbdev. fbdev drivers are used on many embedded systems. Its what we used for years before kms came along.
Quoted 7 lines
IOW this is not really a realistic answer to problem 1.
<snip>
Quoted 2 lines
Quoted 1 line
2) Allowing for output of early kernel boot messages.
Quoted 7 lines
Quoted 3 lines
For this to work the kernel needs to know two things - address of the framebuffer and the x/y layout. Then just nuke this display when the kernel finishes the boot process.
Please read my earlier mails on how completely flawed it is to write "when the kernel finishes the boot process". The problem is that there is no way to really determine when this happens.
Let me rephrase that, when the existing code in the clk system and regulator systems decide to do their clean up the display will get nuked.
Quoted 9 lines
Regards,
Hans
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe at googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Hans de GoedeQuoted 23 lines · Hans de Goede
Hi,
On 08/27/2014 02:44 PM, jonsmirl at gmail.com wrote:
<snip>
Quoted 6 lines
Quoted 1 line
1) Serving as *the* fb until a kms driver is present
Why can't we whip together a real device specific fbdev driver and quit trying to run without a device specific driver in place? History has shown that to be bad idea except during early boot when there isn't a choice.
Writing a kms driver and getting it upstream is not a simple task, and starting with a too limited implementation is dangerous as we need to get the devicetree binding first from the get go.
IOW this is not really a realistic answer to problem 1.
<snip>
Quoted 2 lines
Quoted 1 line
2) Allowing for output of early kernel boot messages.
Quoted 7 lines
Quoted 3 lines
For this to work the kernel needs to know two things - address of the framebuffer and the x/y layout. Then just nuke this display when the kernel finishes the boot process.
Please read my earlier mails on how completely flawed it is to write "when the kernel finishes the boot process". The problem is that there is no way to really determine when this happens.
That doesn't mean we can't create new ways to signal this. One option would be for userspace to signal this, another would be to have critical subsystems broadcast such events so that things like the clock framework can listen for those and react accordingly. The fact remains that disabling all unused clocks unconditinally at late_initcall time is not (always) the right thing to do.
What this really is is a policy decision and traditionally we don't like to dictate policy in the kernel, so having something like an optional feature that would allow userspace to notify the kernel that it's initialized doesn't sound like a bad idea. This doesn't necessarily have to mean that all possible devices have been probed (users could choose to blacklist modules, etc.) but just an indication that the system is done with essential tasks (for desktop distributions I would assume that means the graphical login manager has started).
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140827/fd1a80e0/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Hans de GoedeQuoted 36 lines · Hans de Goede
Hi,
Quoted 2 lines · Thierry Reding
Can you please fix you mail setup. You're addressing me directly in this email, yet I'm neither in To: nor Cc: headers. That's really annoying.
Sorry, I'll pay closer attention that you're in the To when I'm directly addressing you next time.
Quoted 1 line · Hans de Goede
<snip>
Quoted 23 lines
Quoted 22 lines
Quoted 9 lines
Either way, Mark already suggested a different alternative in another subthread, namely to add a new kind of checkpoint at which subsystems can call a "disable unused" function that's called later than a late initcall. This is not going to fix things for you immediately because the clocks will still be switched off (only later) if you don't have a real driver that's claiming the clocks. But you can work around that for now by making the relevant clocks always on and remove that workaround once a real driver is loaded that knows how to handle them properly.
This will simply not work, and is a ton more complicated then simply teaching simplefb about a clocks property, which is a really simple and clean patch.
First of all let me explain why this won't work. When should those subsystems call this "later then a late initcall" call ? the kms driver may very well be a kernel module, which will be loaded by userspace, so we would need this to be triggered by userspace, but when ?
When the initrd is done? What then if the kms driver is not in the initrd, so maybe when udev is done enumerating devices, but what then if the kernel is still enumerating hardware at this time?
Quoted 7 lines
Quoted 2 lines
Usually an initrd knows how to wait for all or a given set of devices to be probed. udev is pretty good for that.
udev does not have a clue how to wait for all devices, it can be used to wait for a specific device to show up, that is true, but this requires adding specific logic for this (class of) device to the initrd init process, which is really sub-optimal.
I thought pretty much every distribution that did anything remotely related to early DRM/KMS like plymouth and whatnot already had this specific logic. It's been a while since I dealt with all that, but something roughly like this used to be present in pretty much all distributions:
udevadm trigger --subsystem-match=graphics \ --subsystem-match=drm \ --subsystem-match=tty udevadm settle
The effect of that being that udevadm settle would block as long as devices were still being probed. Admittedly this was all long before deferred probing was introduced, so I have no idea how well it plays with it. But optimizing deferred probing is an entirely different topic currently under discussion that should help sorting this out, too.
Quoted 24 lines
Quoted 12 lines
Quoted 11 lines
Will we just put a sleep 30
in our initscripts to make sure the kernel is done scanning all busses, will that be long enough? Maybe we need to re-introduce thescsi_wait_donekernel module which was added as an ugly hack to allow userspace to wait for the kernel to have finished scanning scsi (and ata / sata) busses, for controllers found at the time the module was load. Which never worked reliable, because it would be possible that the controller itself still needed to be discovered. We've spend years cleaning up userspace enough to be able to killscsi_wait_done. We've already been down this road of waiting for hw enumeration to be done, and the problem is that on modern systems *it is never done*.Quoted 6 lines
Those are mostly integration issues. If you don't load the driver from initrd then I don't think anybody will complain when there's flicker when it finally gets loaded. The whole point of this is to have early access to the framebuffer and get display and graphics going as soon as possible, so please don't pull in hypothetical scenarios where people manually load drivers half an hour after the system has booted.
In another mail in this thread you've mentioned 2 uses for simplefb:
1) Serving as *the* fb until a kms driver is present
2) Allowing for output of early kernel boot messages.
Quoted 8 lines
I agree that those are the 2 use-cases we're dealing with here.
Note that the whole discussion we're having hear about disabling the clocks once hardware probing is "done", is moot for 1. One possible way mentioned of dealing with 1. is to mark these clocks as always on for now, and then we need to drop this hack (I cannot call this anything else then a hack), once we get kms, meaning interdependencies between the dropping patch and the kms adding patches, etc. All not very pretty.
I don't think it's that bad. When your real driver is merged you can still keep the clocks always on for a release cycle if you worry about any fallout. It's unlikely to going to be your last driver that you merge and people aren't immediately going to build products based on it, so it's unlikely that anyone will notice the wasted power.
Quoted 6 lines
For 2. We have what you call "mostly integration issues". Allow me to copy and paste in another bit of this thread here:
Quoted 3 lines
Quoted 2 lines
I've been doing low level Linux development for 10 years now and I've worked a lot on storage (raid, iscsi, fcoe support, etc.) in the past.
Quoted 6 lines
Quoted 1 line
Ah, so this is now officially a pissing contest, is it?
No I'm merely trying to explain that I've a ton of experience with what you seem to think of as merely integration issues, and they are a royal PITA, and thus to be avoided at all costs. Really, please just trust me on this one, doing the whole add some later then late init call type is a bad idea.
Well, you could equally just trust me on this one when I say adding clock support for this driver is bad. Stalemate.
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
So second of all, Thierry, what exactly is the technical argument against adding support for dealing with clocks to simplefb ?
I've already stated technical arguments against it. You could just go back and read the thread again, or would you rather want me to repeat them for your convenience?
Quoted 8 lines
It is a long thread, IIRC your main arguments against this are:
1) You don't want this kind of platform-specific knowledge in simplefb
2) That simplefb is supposed to be simple, and this is not simpleAs for 1. several people have already argued that clocks as such are an abstract concept, found one many platforms and as such are not platform specific.
That alone doesn't justify this patch. SoCs often have a requirement to enable clocks in a specific order, for example. Other systems may need to coordinate clocks with resets in a specific order or enable power domains and such. All that is very SoC specific and if we don't make it very clear what this driver assumes about the state of the system, then we can't object to anybody adding support for those later on either. The result of that is going to be a driver that needs to handle all kinds of combinations of resources.
So while clocks themselves are fairly generic the way in which they need to be used is highly platform-specific.
Let me also reiterate what I've said a couple of times already. The issue here isn't that simplefb needs to manage these clocks in any way. Firmware has already set them up so that display works. The reason why you need this patch is so that the clock framework doesn't automatically turn them off. With the proposed patch the driver enables these clocks, but that's not what it needs to do, they are already on. It's a work around to prevent the clock framework into not disabling them.
So as far as I'm concerned this points to a fundamental issue with how the clock framework handles unused clocks. Therefore that is the problem that should be solved, not worked around.
Quoted 6 lines
Any generic hw driver dealing with embedded platforms, be it ahci, ohci, ehci, etc. has ended up adding abstract support for things like clocks (and other resources). I say abstract support here, since to all these drivers the support was added in a way that no platform specific knowledge is necessary, they just deal with clocks not caring about the specific underlying clock implementation, clock names, etc.
Yes, I know that. You and I both had a very similar discussion not so long ago. But the above aren't quite the same as simplefb. The devices follow at least a well-known standard (EHCI, OHCI, AHCI), so there's bound to be more commonalities between them than between the various display devices that simplefb potentially can support.
Interestingly though, if you look at what hardware really is supported by the generic drivers that deal with embedded platforms, there isn't all that much diversity (I've manually stripped out non-DTS occurrences since they aren't relevant for this discussion):
$ git grep -n generic-ohci arch/arm/boot/dts/sun4i-a10.dtsi:451: compatible = "allwinner,sun4i-a10-ohci", "generic-ohci"; arch/arm/boot/dts/sun4i-a10.dtsi:492: compatible = "allwinner,sun4i-a10-ohci", "generic-ohci"; arch/arm/boot/dts/sun5i-a10s.dtsi:403: compatible = "allwinner,sun5i-a10s-ohci", "generic-ohci"; arch/arm/boot/dts/sun5i-a13.dtsi:376: compatible = "allwinner,sun5i-a13-ohci", "generic-ohci"; arch/arm/boot/dts/sun6i-a31.dtsi:410: compatible = "allwinner,sun6i-a31-ohci", "generic-ohci"; arch/arm/boot/dts/sun6i-a31.dtsi:432: compatible = "allwinner,sun6i-a31-ohci", "generic-ohci"; arch/arm/boot/dts/sun6i-a31.dtsi:443: compatible = "allwinner,sun6i-a31-ohci", "generic-ohci"; arch/arm/boot/dts/sun7i-a20.dtsi:535: compatible = "allwinner,sun7i-a20-ohci", "generic-ohci"; arch/arm/boot/dts/sun7i-a20.dtsi:576: compatible = "allwinner,sun7i-a20-ohci", "generic-ohci"; arch/powerpc/boot/dts/akebono.dts:144: compatible = "ibm,476gtr-ohci", "generic-ohci"; arch/powerpc/boot/dts/akebono.dts:151: compatible = "ibm,476gtr-ohci", "generic-ohci";
$ git grep -n generic-ehci arch/arm/boot/dts/rk3288.dtsi:199: compatible = "generic-ehci"; arch/arm/boot/dts/rk3288.dtsi:210: compatible = "generic-ehci"; arch/arm/boot/dts/sun4i-a10.dtsi:441: compatible = "allwinner,sun4i-a10-ehci", "generic-ehci"; arch/arm/boot/dts/sun4i-a10.dtsi:482: compatible = "allwinner,sun4i-a10-ehci", "generic-ehci"; arch/arm/boot/dts/sun5i-a10s.dtsi:393: compatible = "allwinner,sun5i-a10s-ehci", "generic-ehci"; arch/arm/boot/dts/sun5i-a13.dtsi:366: compatible = "allwinner,sun5i-a13-ehci", "generic-ehci"; arch/arm/boot/dts/sun6i-a31.dtsi:399: compatible = "allwinner,sun6i-a31-ehci", "generic-ehci"; arch/arm/boot/dts/sun6i-a31.dtsi:421: compatible = "allwinner,sun6i-a31-ehci", "generic-ehci"; arch/arm/boot/dts/sun7i-a20.dtsi:525: compatible = "allwinner,sun7i-a20-ehci", "generic-ehci"; arch/arm/boot/dts/sun7i-a20.dtsi:566: compatible = "allwinner,sun7i-a20-ehci", "generic-ehci"; arch/powerpc/boot/dts/akebono.dts:130: compatible = "ibm,476gtr-ehci", "generic-ehci";
For generic-ahci there aren't any matches, but here are a few that are marked compatible with it using different compatible strings:
$ git grep -n snps,spear-ahci arch/arm/boot/dts/spear1310.dtsi:60: compatible = "snps,spear-ahci"; arch/arm/boot/dts/spear1310.dtsi:69: compatible = "snps,spear-ahci"; arch/arm/boot/dts/spear1310.dtsi:78: compatible = "snps,spear-ahci"; arch/arm/boot/dts/spear1340.dtsi:43: compatible = "snps,spear-ahci";
$ git grep -n snps,exynos5440-ahci arch/arm/boot/dts/exynos5440.dtsi:241: compatible = "snps,exynos5440-ahci";
$ git grep -n 'ibm,476gtr-ahci' arch/powerpc/boot/dts/akebono.dts:123: compatible = "ibm,476gtr-ahci";
$ git grep -n 'snps,dwc-ahci' arch/arm/boot/dts/dra7.dtsi:1049: compatible = "snps,dwc-ahci"; arch/arm/boot/dts/exynos5250.dtsi:265: compatible = "snps,dwc-ahci"; arch/arm/boot/dts/omap5.dtsi:919: compatible = "snps,dwc-ahci";
That looks fairly homogenous to me. There are also things like this (from the ahci_platform.c driver):
if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci")) hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ;
With more supported hardware there's bound to be more quirks like that.
So there's a couple of SoCs and boards that actually are generic enough to work with a generic driver. And then there's a whole bunch of other drivers for hardware that's compliant with the same standard yet needs different drivers. To me that's a clear indication that there isn't enough genericity to warrant a generic driver in the first place.
The commonality is in the functionality and defined by the standard registers. But there's little to no commonality in how that interface is glued into the SoC. Luckily the above subsystems implement the standard hardware programming in a library, so that non-generic drivers can still make use of most of the generic code.
Quoted 6 lines
This really is unavoidable. The framebuffer memory needed was mentioned as another example of a resource in this thread. You suggested using the new mem-reserve framework for this. I agree that that is the right thing to do, but even then we still need a way to tie this reserved mem to the simplefb, so that the kernel can know when it is no longer used and can be added to the general memory pool.
Yes, memory handling seems like it isn't handled optimally by simplefb. To be fair the simplefb driver predates the reserved-memory bindings. I think it might be worthwhile to investigate on how to extend the binding to make use of that, though. I think the assumption currently is that the framebuffer memory will be lost forever (it needs to be carved out of the physical memory that the kernel gets to see). I couldn't find any code that returned reserved-memory to the kernel, but it's certainly a feature that I think we want. Especially if the firmware framebuffer is large (as in 1080p).
Quoted 7 lines
If you look at how almost all dt bindings work, then the dt node for a device specifies the resources needed, I don't see why simplefb would be so special that it should be different here. I agree that it is important to get the abstractions right here, but to me it seems that the right abstraction is to be consistent with how all other devices are abstracted and to add needed resources to the dt node for the simplefb.
But simplefb is fundamentally different from other devices. It isn't a physical device at all. It's a virtual device that reuses resources as set up by some other piece of code (firmware). It implies that there's nothing that needs to be managed. It should only create a framebuffer with the given parameters and allow the kernel (and userspace) to render into it.
The only way you can deal with such virtual, completely generic devices is by being very explicit about the requirements. For simplefb the assumptions are that firmware set everything up and passes information about what it set up to the kernel so that it can be reused. None of the resources need to be explicitly managed because they have all been properly configured. For that reason, again, I think the right way is for the kernel not to switch off any of the used resources.
If you want to equate simplefb to other drivers then it is fundamentally broken anyway. Given only what's in the DTB the simplefb driver won't be able to do anything useful. Consider what would happen if the firmware didn't set up all the resources. Then the DT is missing resets, power supplies and all that to make it work.
Quoted 5 lines
As for 2. Yes this will add some more code to simplefb, more code but code which is not complicated in anyway, so the simplefb code would become larger but still stay simple. Were as all the suggested alternatives sofar are at least an order of magnitude more complicated, crossing many subsystems, demanding coordination with userspace, etc.
I'm not objecting to this patch because of the complexity, but because it is an illusion that the code is in any way generic.
Quoted 5 lines
Quoted 4 lines
so I think we should keep the discussion going for a bit and see if we really can't come up with something that will fix this for a more general case rather than just your particular use-case. It's evidently a recurring problem that others suffer from, too.
Quoted 7 lines
Yes needing resources despite the device being behind some generic interface where the main driver code for that interface has no knowledge about such resources sofar, because e.g. on PC-s this was not necessary is a recurring problem, which has been solved already 3 times at least, see the ohci-, ehci- and ahci-platform drivers, and for all 3 the conclusion was that the best solution was to simple add the resources to the dt-node, and add code to claim and enable them.
And as I pointed out above in all three cases the generic platform driver is only marginally useful because many SoCs have specific requirements that make them incompatible with the generic driver.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140827/9be6c8a7/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi,
Quoted 1 line · Thierry Reding
On Wed, Aug 27, 2014 at 12:35:24PM +0200, Hans de Goede wrote:
<snip>
Quoted 16 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
So second of all, Thierry, what exactly is the technical argument against adding support for dealing with clocks to simplefb ?
I've already stated technical arguments against it. You could just go back and read the thread again, or would you rather want me to repeat them for your convenience?
Quoted 8 lines
It is a long thread, IIRC your main arguments against this are:
1) You don't want this kind of platform-specific knowledge in simplefb
2) That simplefb is supposed to be simple, and this is not simpleAs for 1. several people have already argued that clocks as such are an abstract concept, found one many platforms and as such are not platform specific.
Quoted 8 lines
That alone doesn't justify this patch. SoCs often have a requirement to enable clocks in a specific order, for example. Other systems may need to coordinate clocks with resets in a specific order or enable power domains and such. All that is very SoC specific and if we don't make it very clear what this driver assumes about the state of the system, then we can't object to anybody adding support for those later on either. The result of that is going to be a driver that needs to handle all kinds of combinations of resources.
The problems your talking about here all have to do with ordering how things are enabled, but what we're talking about here is keeping things enabled which are already enabled by the bootloader, so there is no ordering problem.
Quoted 11 lines
So while clocks themselves are fairly generic the way in which they need to be used is highly platform-specific.
Let me also reiterate what I've said a couple of times already. The issue here isn't that simplefb needs to manage these clocks in any way. Firmware has already set them up so that display works. The reason why you need this patch is so that the clock framework doesn't automatically turn them off. With the proposed patch the driver enables these clocks, but that's not what it needs to do, they are already on. It's a work around to prevent the clock framework into not disabling them.
Quoted 3 lines
So as far as I'm concerned this points to a fundamental issue with how the clock framework handles unused clocks. Therefore that is the problem that should be solved, not worked around.
Hmm I see, in my mind the problem is not that the clk framework disables unused clocks, but that no one is marking the clocks in question as used. Someone should mark these clocks as used so that they do not get disabled.
We could add a clk_mark_in_use function and have the simplefb patch call that instead of clk_prepare_and_enable, or maybe even better just only claim the clks and teach the clk framework to not disable claimed clk in its cleanup run. That would make it clear that simplefb is not enabling anything, just claiming resource its need to avoid them getting removed from underneath simplefb, would that work for you ?
Quoted 13 lines
Quoted 6 lines
Any generic hw driver dealing with embedded platforms, be it ahci, ohci, ehci, etc. has ended up adding abstract support for things like clocks (and other resources). I say abstract support here, since to all these drivers the support was added in a way that no platform specific knowledge is necessary, they just deal with clocks not caring about the specific underlying clock implementation, clock names, etc.
Yes, I know that. You and I both had a very similar discussion not so long ago. But the above aren't quite the same as simplefb. The devices follow at least a well-known standard (EHCI, OHCI, AHCI), so there's bound to be more commonalities between them than between the various display devices that simplefb potentially can support.
Quoted 4 lines
Interestingly though, if you look at what hardware really is supported by the generic drivers that deal with embedded platforms, there isn't all that much diversity (I've manually stripped out non-DTS occurrences since they aren't relevant for this discussion):
That is because the generic platform drivers were only added recently to stop the insanity where each new soc got its own ohci-soc.c / ehci-soc.c file.
<snip>
Quoted 2 lines
arch/arm/boot/dts/rk3288.dtsi:199: compatible = "generic-ehci"; arch/arm/boot/dts/rk3288.dtsi:210: compatible = "generic-ehci";
(offtopic) And I see that despite the recent addition, we actually already have our first non sunxi user, good, I didn't even know the rockchip guys were using this :)
And I know that there are quite a few more in the pipeline (waiting for their usb phy and dt patches to get merged).
<snip>
Quoted 4 lines
So there's a couple of SoCs and boards that actually are generic enough to work with a generic driver. And then there's a whole bunch of other drivers for hardware that's compliant with the same standard yet needs different drivers.
No, there are a lot of other drivers which were written before someone decided that having 10-20 drivers which were 90% copy and paste of each other was a bad idea, but we're really going offtopic here.
<snip>
Quoted 7 lines
Quoted 6 lines
This really is unavoidable. The framebuffer memory needed was mentioned as another example of a resource in this thread. You suggested using the new mem-reserve framework for this. I agree that that is the right thing to do, but even then we still need a way to tie this reserved mem to the simplefb, so that the kernel can know when it is no longer used and can be added to the general memory pool.
Quoted 9 lines
Yes, memory handling seems like it isn't handled optimally by simplefb. To be fair the simplefb driver predates the reserved-memory bindings. I think it might be worthwhile to investigate on how to extend the binding to make use of that, though. I think the assumption currently is that the framebuffer memory will be lost forever (it needs to be carved out of the physical memory that the kernel gets to see). I couldn't find any code that returned reserved-memory to the kernel, but it's certainly a feature that I think we want. Especially if the firmware framebuffer is large (as in 1080p).
Ack.
Quoted 15 lines
Quoted 7 lines
If you look at how almost all dt bindings work, then the dt node for a device specifies the resources needed, I don't see why simplefb would be so special that it should be different here. I agree that it is important to get the abstractions right here, but to me it seems that the right abstraction is to be consistent with how all other devices are abstracted and to add needed resources to the dt node for the simplefb.
But simplefb is fundamentally different from other devices. It isn't a physical device at all. It's a virtual device that reuses resources as set up by some other piece of code (firmware). It implies that there's nothing that needs to be managed. It should only create a framebuffer with the given parameters and allow the kernel (and userspace) to render into it.
Quoted 8 lines
The only way you can deal with such virtual, completely generic devices is by being very explicit about the requirements. For simplefb the assumptions are that firmware set everything up and passes information about what it set up to the kernel so that it can be reused.
None of the resources need to be explicitly managed because they have all been properly configured. For that reason, again, I think the right way is for the kernel not to switch off any of the used resources.
The key word here is "the used resources" to me this is not about simlefb managing resources, but marking them as used as long as it needs them, like it will need to do for the reserved mem chunk.
<snip>
Quoted 8 lines
Quoted 5 lines
As for 2. Yes this will add some more code to simplefb, more code but code which is not complicated in anyway, so the simplefb code would become larger but still stay simple. Were as all the suggested alternatives sofar are at least an order of magnitude more complicated, crossing many subsystems, demanding coordination with userspace, etc.
I'm not objecting to this patch because of the complexity, but because it is an illusion that the code is in any way generic.
Ok.
Regards,
Hans
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 32 lines · Hans de Goede
Hi,
Quoted 1 line · Thierry Reding
On Wed, Aug 27, 2014 at 12:35:24PM +0200, Hans de Goede wrote:
<snip>
Quoted 16 lines
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
So second of all, Thierry, what exactly is the technical argument against adding support for dealing with clocks to simplefb ?
I've already stated technical arguments against it. You could just go back and read the thread again, or would you rather want me to repeat them for your convenience?
Quoted 8 lines
It is a long thread, IIRC your main arguments against this are:
1) You don't want this kind of platform-specific knowledge in simplefb
2) That simplefb is supposed to be simple, and this is not simpleAs for 1. several people have already argued that clocks as such are an abstract concept, found one many platforms and as such are not platform specific.
Quoted 8 lines
That alone doesn't justify this patch. SoCs often have a requirement to enable clocks in a specific order, for example. Other systems may need to coordinate clocks with resets in a specific order or enable power domains and such. All that is very SoC specific and if we don't make it very clear what this driver assumes about the state of the system, then we can't object to anybody adding support for those later on either. The result of that is going to be a driver that needs to handle all kinds of combinations of resources.
Quoted 4 lines
The problems your talking about here all have to do with ordering how things are enabled, but what we're talking about here is keeping things enabled which are already enabled by the bootloader, so there is no ordering problem.
See what I did there? I tricked you into saying what I've been saying all along. =) It's about keeping things enabled which have been enabled by the bootloader. That's the root of the problem.
Quoted 19 lines
Quoted 11 lines
So while clocks themselves are fairly generic the way in which they need to be used is highly platform-specific.
Let me also reiterate what I've said a couple of times already. The issue here isn't that simplefb needs to manage these clocks in any way. Firmware has already set them up so that display works. The reason why you need this patch is so that the clock framework doesn't automatically turn them off. With the proposed patch the driver enables these clocks, but that's not what it needs to do, they are already on. It's a work around to prevent the clock framework into not disabling them.
Quoted 3 lines
So as far as I'm concerned this points to a fundamental issue with how the clock framework handles unused clocks. Therefore that is the problem that should be solved, not worked around.
Hmm I see, in my mind the problem is not that the clk framework disables unused clocks, but that no one is marking the clocks in question as used. Someone should mark these clocks as used so that they do not get disabled.
Quoted 6 lines
We could add a
clk_mark_in_usefunction and have the simplefb patch call that instead ofclk_prepare_and_enable, or maybe even better just only claim the clks and teach the clk framework to not disable claimed clk in its cleanup run. That would make it clear that simplefb is not enabling anything, just claiming resource its need to avoid them getting removed from underneath simplefb, would that work for you ?
That would be more accurate, but it boils down to the same problem where we still need a driver to claim the resources in some way whereas the problem is fundamentally one where the bootloader should be telling the kernel not to disable it. It's in fact the bootloader that's claiming the resources.
Quoted 13 lines
Quoted 13 lines
Quoted 6 lines
Any generic hw driver dealing with embedded platforms, be it ahci, ohci, ehci, etc. has ended up adding abstract support for things like clocks (and other resources). I say abstract support here, since to all these drivers the support was added in a way that no platform specific knowledge is necessary, they just deal with clocks not caring about the specific underlying clock implementation, clock names, etc.
Yes, I know that. You and I both had a very similar discussion not so long ago. But the above aren't quite the same as simplefb. The devices follow at least a well-known standard (EHCI, OHCI, AHCI), so there's bound to be more commonalities between them than between the various display devices that simplefb potentially can support.
Quoted 8 lines
Quoted 4 lines
Interestingly though, if you look at what hardware really is supported by the generic drivers that deal with embedded platforms, there isn't all that much diversity (I've manually stripped out non-DTS occurrences since they aren't relevant for this discussion):
That is because the generic platform drivers were only added recently to stop the insanity where each new soc got its own
ohci-soc.c/ehci-soc.cfile.
Insanity is subjective.
Quoted 5 lines
Quoted 2 lines
arch/arm/boot/dts/rk3288.dtsi:199: compatible = "generic-ehci"; arch/arm/boot/dts/rk3288.dtsi:210: compatible = "generic-ehci";(offtopic) And I see that despite the recent addition, we actually already have our first non sunxi user, good, I didn't even know the rockchip guys were using this :)
FWIW, the rk3288 entry is broken. It should really contain an SoC specific compatible string as well.
Quoted 2 lines
And I know that there are quite a few more in the pipeline (waiting for their usb phy and dt patches to get merged).
As far as I'm concerned that's all a mistake (and catastrophy waiting to happen), but hey, there's only so many hours in a day so I've got to pick my battles.
Quoted 8 lines
Quoted 4 lines
So there's a couple of SoCs and boards that actually are generic enough to work with a generic driver. And then there's a whole bunch of other drivers for hardware that's compliant with the same standard yet needs different drivers.
No, there are a lot of other drivers which were written before someone decided that having 10-20 drivers which were 90% copy and paste of each other was a bad idea, but we're really going offtopic here.
The copy and paste is for code that's platform specific. The clocks have different names, resets are different, supplies are different. The fact that many can currently use the same driver is likely just coincidence rather than design and it's entirely possible that at some point they'll add support for a more advanced feature that makes them incompatible with the rest of the generic drivers. And then you have a big mess because you need to add quirks all over the place.
And this isn't all that far off-topic, since simplefb also needs to deal with this kind of situation. And what I've been arguing is that in order to really be generic it has to make assumptions, one of which is that it uses only resources that it doesn't need to explicitly handle.
Quoted 20 lines
Quoted 19 lines
Quoted 7 lines
If you look at how almost all dt bindings work, then the dt node for a device specifies the resources needed, I don't see why simplefb would be so special that it should be different here. I agree that it is important to get the abstractions right here, but to me it seems that the right abstraction is to be consistent with how all other devices are abstracted and to add needed resources to the dt node for the simplefb.
But simplefb is fundamentally different from other devices. It isn't a physical device at all. It's a virtual device that reuses resources as set up by some other piece of code (firmware). It implies that there's nothing that needs to be managed. It should only create a framebuffer with the given parameters and allow the kernel (and userspace) to render into it.
The only way you can deal with such virtual, completely generic devices is by being very explicit about the requirements. For simplefb the assumptions are that firmware set everything up and passes information about what it set up to the kernel so that it can be reused.
Quoted 7 lines
Quoted 3 lines
None of the resources need to be explicitly managed because they have all been properly configured. For that reason, again, I think the right way is for the kernel not to switch off any of the used resources.
The key word here is "the used resources" to me this is not about simlefb managing resources, but marking them as used as long as it needs them, like it will need to do for the reserved mem chunk.
The difference between the clocks and the memory resource is that the driver needs to directly access the memory (it needs to map it and provide a userspace mapping for it) whereas it doesn't need to touch the clocks (except to workaround a Linux-specific implementation detail).
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140827/d30e8512/attachment-0001.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi,
On 08/27/2014 04:16 PM, Thierry Reding wrote:
<snip>
Quoted 7 lines
Quoted 4 lines
The problems your talking about here all have to do with ordering how things are enabled, but what we're talking about here is keeping things enabled which are already enabled by the bootloader, so there is no ordering problem.
See what I did there? I tricked you into saying what I've been saying all along. =)
He he :)
Quoted 2 lines
It's about keeping things enabled which have been enabled by the bootloader. That's the root of the problem.
Ok so we all seem to largely agree on most things here:
1) Somehow some clks must be marked used so as to not get disabled
2) We don't want to hardcode these clocks into the kernel (sunxi) clk driver, instead the bootloader should tell the kernel about these clocks.
So the only point of discussion left seems to be how to do 2...
<snip>
Quoted 11 lines
Quoted 10 lines
Hmm I see, in my mind the problem is not that the clk framework disables unused clocks, but that no one is marking the clocks in question as used. Someone should mark these clocks as used so that they do not get disabled.
We could add a
clk_mark_in_usefunction and have the simplefb patch call that instead ofclk_prepare_and_enable, or maybe even better just only claim the clks and teach the clk framework to not disable claimed clk in its cleanup run. That would make it clear that simplefb is not enabling anything, just claiming resource its need to avoid them getting removed from underneath simplefb, would that work for you ?
Quoted 5 lines
That would be more accurate, but it boils down to the same problem where we still need a driver to claim the resources in some way whereas the problem is fundamentally one where the bootloader should be telling the kernel not to disable it. It's in fact the bootloader that's claiming the resources.
Yes, but those resources do not belong to the bootloader in a sense that traditional bootloader / firmware claimed resources (e.g. acpi reserved resources) do. These traditional resources are claimed for ever.
Where as these resources are claimed by the bootloader to keep the simplefb it provides working, as soon as the simplefb is no longer used, they become unused.
<snip off-topic generic-ehci discussion>
Quoted 12 lines
Quoted 3 lines
No, there are a lot of other drivers which were written before someone decided that having 10-20 drivers which were 90% copy and paste of each other was a bad idea, but we're really going offtopic here.
The copy and paste is for code that's platform specific. The clocks have different names, resets are different, supplies are different. The fact that many can currently use the same driver is likely just coincidence rather than design and it's entirely possible that at some point they'll add support for a more advanced feature that makes them incompatible with the rest of the generic drivers. And then you have a big mess because you need to add quirks all over the place.
Quoted 4 lines
And this isn't all that far off-topic, since simplefb also needs to deal with this kind of situation. And what I've been arguing is that in order to really be generic it has to make assumptions, one of which is that it uses only resources that it doesn't need to explicitly handle.
I can understand that you're worried about generic ?hci drivers dealing with clocks / resets / etc. As there may be strict ordering requirements there, but for simplefb that is not the case.
All we're asking for is for a way to communicate 2 things to the kernel:
1) These resources are in use (we are not asking the kernel to do anything with them, rather the opposite, we're asking to leave them alone so no ordering issues)
2) Tie these resources to simplefb so that the kernel can know when they are no longer in use, and it may e.g. re-use the memory
To me the most logical and also most "correct" way of modelling this is to put the resources inside the simplefb dt node.
<snip>
Quoted 8 lines
Quoted 3 lines
The key word here is "the used resources" to me this is not about simlefb managing resources, but marking them as used as long as it needs them, like it will need to do for the reserved mem chunk.
The difference between the clocks and the memory resource is that the driver needs to directly access the memory (it needs to map it and provide a userspace mapping for it) whereas it doesn't need to touch the clocks (except to workaround a Linux-specific implementation detail).
Erm, no, the need to map the memory and the memory being a resource which may be released are an orthogonal problem. E.g. a system with dedicated framebuffer memory won't need to use a reserved main-memory chunk, nor need to worry about returning that mem when simplefb is no longer in use.
Regards,
Hans
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 19 lines · Hans de Goede
Hi,
On 08/27/2014 04:16 PM, Thierry Reding wrote:
<snip>
Quoted 7 lines
Quoted 4 lines
The problems your talking about here all have to do with ordering how things are enabled, but what we're talking about here is keeping things enabled which are already enabled by the bootloader, so there is no ordering problem.
See what I did there? I tricked you into saying what I've been saying all along. =)
He he :)
Quoted 2 lines
It's about keeping things enabled which have been enabled by the bootloader. That's the root of the problem.
Quoted 7 lines
Ok so we all seem to largely agree on most things here:
1) Somehow some clks must be marked used so as to not get disabled
2) We don't want to hardcode these clocks into the kernel (sunxi) clk driver, instead the bootloader should tell the kernel about these clocks.So the only point of discussion left seems to be how to do 2...
Wouldn't it be a lot simpler just to use existing fbdev (not KMS) and whip together a device specific driver that claims the proper resources? And just implement the minimal about of fbdev possible? fbdev already is a driver library.
---
An independent issue is the early printk equivalent. For that you need an address and the x/y layout
Quoted 88 lines
<snip>
Quoted 11 lines
Quoted 10 lines
Hmm I see, in my mind the problem is not that the clk framework disables unused clocks, but that no one is marking the clocks in question as used. Someone should mark these clocks as used so that they do not get disabled.
We could add a
clk_mark_in_usefunction and have the simplefb patch call that instead ofclk_prepare_and_enable, or maybe even better just only claim the clks and teach the clk framework to not disable claimed clk in its cleanup run. That would make it clear that simplefb is not enabling anything, just claiming resource its need to avoid them getting removed from underneath simplefb, would that work for you ?Quoted 5 lines
That would be more accurate, but it boils down to the same problem where we still need a driver to claim the resources in some way whereas the problem is fundamentally one where the bootloader should be telling the kernel not to disable it. It's in fact the bootloader that's claiming the resources.
Yes, but those resources do not belong to the bootloader in a sense that traditional bootloader / firmware claimed resources (e.g. acpi reserved resources) do. These traditional resources are claimed for ever.
Where as these resources are claimed by the bootloader to keep the simplefb it provides working, as soon as the simplefb is no longer used, they become unused.
<snip off-topic generic-ehci discussion>
Quoted 12 lines
Quoted 3 lines
No, there are a lot of other drivers which were written before someone decided that having 10-20 drivers which were 90% copy and paste of each other was a bad idea, but we're really going offtopic here.
The copy and paste is for code that's platform specific. The clocks have different names, resets are different, supplies are different. The fact that many can currently use the same driver is likely just coincidence rather than design and it's entirely possible that at some point they'll add support for a more advanced feature that makes them incompatible with the rest of the generic drivers. And then you have a big mess because you need to add quirks all over the place.
Quoted 4 lines
And this isn't all that far off-topic, since simplefb also needs to deal with this kind of situation. And what I've been arguing is that in order to really be generic it has to make assumptions, one of which is that it uses only resources that it doesn't need to explicitly handle.
I can understand that you're worried about generic ?hci drivers dealing with clocks / resets / etc. As there may be strict ordering requirements there, but for simplefb that is not the case.
All we're asking for is for a way to communicate 2 things to the kernel:
1) These resources are in use (we are not asking the kernel to do anything with them, rather the opposite, we're asking to leave them alone so no ordering issues)
2) Tie these resources to simplefb so that the kernel can know when they are no longer in use, and it may e.g. re-use the memory
To me the most logical and also most "correct" way of modelling this is to put the resources inside the simplefb dt node.
<snip>
Quoted 8 lines
Quoted 3 lines
The key word here is "the used resources" to me this is not about simlefb managing resources, but marking them as used as long as it needs them, like it will need to do for the reserved mem chunk.
The difference between the clocks and the memory resource is that the driver needs to directly access the memory (it needs to map it and provide a userspace mapping for it) whereas it doesn't need to touch the clocks (except to workaround a Linux-specific implementation detail).
Erm, no, the need to map the memory and the memory being a resource which may be released are an orthogonal problem. E.g. a system with dedicated framebuffer memory won't need to use a reserved main-memory chunk, nor need to worry about returning that mem when simplefb is no longer in use.
Regards,
Hans
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe at googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 9 lines · jonsmirl at gmail.com
Quoted 4 lines
2) We don't want to hardcode these clocks into the kernel (sunxi) clk driver, instead the bootloader should tell the kernel about these clocks.
So the only point of discussion left seems to be how to do 2...
Wouldn't it be a lot simpler just to use existing fbdev (not KMS) and whip together a device specific driver that claims the proper resources? And just implement the minimal about of fbdev possible? fbdev already is a driver library.
Like... drivers/video/fbdev/offb.c?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 4 lines · Geert Uytterhoeven
Quoted 3 lines · jonsmirl at gmail.com
Quoted 3 lines
2) We don't want to hardcode these clocks into the kernel (sunxi) clk driver, instead the bootloader should tell the kernel about these clocks.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
So the only point of discussion left seems to be how to do 2...
Wouldn't it be a lot simpler just to use existing fbdev (not KMS) and whip together a device specific driver that claims the proper resources? And just implement the minimal about of fbdev possible? fbdev already is a driver library.
Like...
drivers/video/fbdev/offb.c?
I'd probably reclassify drivers/video/fbdev/simplefb.c as a skeleton and use it as a template for making device specific versions of it.
I don't see why there is so much resistance to just making device specific fb drivers. Whenever the KMS driver gets written just disable the device specific fb driver in the build.
Quoted 11 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.orgIn personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 13 lines · jonsmirl at gmail.com
Quoted 11 lines · Geert Uytterhoeven
Quoted 9 lines · jonsmirl at gmail.com
Quoted 4 lines
2) We don't want to hardcode these clocks into the kernel (sunxi) clk driver, instead the bootloader should tell the kernel about these clocks.
So the only point of discussion left seems to be how to do 2...
Wouldn't it be a lot simpler just to use existing fbdev (not KMS) and whip together a device specific driver that claims the proper resources? And just implement the minimal about of fbdev possible? fbdev already is a driver library.
Quoted 8 lines
Quoted 1 line
Like...
drivers/video/fbdev/offb.c?I'd probably reclassify
drivers/video/fbdev/simplefb.cas a skeleton and use it as a template for making device specific versions of it.I don't see why there is so much resistance to just making device specific fb drivers. Whenever the KMS driver gets written just disable the device specific fb driver in the build.
I explicitly named offb, because it already supports living with the video mode initialized by Open Firmware, which is passed to the kernel in a device tree.
Signature · 10 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 19 lines · Geert Uytterhoeven
Quoted 18 lines · jonsmirl at gmail.com
Quoted 4 lines · Geert Uytterhoeven
Quoted 3 lines · jonsmirl at gmail.com
Quoted 3 lines
2) We don't want to hardcode these clocks into the kernel (sunxi) clk driver, instead the bootloader should tell the kernel about these clocks.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
So the only point of discussion left seems to be how to do 2...
Wouldn't it be a lot simpler just to use existing fbdev (not KMS) and whip together a device specific driver that claims the proper resources? And just implement the minimal about of fbdev possible? fbdev already is a driver library.
Like...
drivers/video/fbdev/offb.c?I'd probably reclassify
drivers/video/fbdev/simplefb.cas a skeleton and use it as a template for making device specific versions of it.
Quoted 7 lines
Quoted 3 lines
I don't see why there is so much resistance to just making device specific fb drivers. Whenever the KMS driver gets written just disable the device specific fb driver in the build.
I explicitly named offb, because it already supports living with the video mode initialized by Open Firmware, which is passed to the kernel in a device tree.
Not sure how that works. It from a PowerMac
arch/powerpc/platforms/powermac/bootx_init.carch/powerpc/kernel/prom_init.c
Quoted 12 lines
--
Gr{oetje,eeting}s,Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.orgIn personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to jonsmirl at gmail.comQuoted 13 lines · jonsmirl at gmail.com
Quoted 11 lines · Geert Uytterhoeven
Quoted 9 lines · jonsmirl at gmail.com
Quoted 4 lines
2) We don't want to hardcode these clocks into the kernel (sunxi) clk driver, instead the bootloader should tell the kernel about these clocks.
So the only point of discussion left seems to be how to do 2...
Wouldn't it be a lot simpler just to use existing fbdev (not KMS) and whip together a device specific driver that claims the proper resources? And just implement the minimal about of fbdev possible? fbdev already is a driver library.
Quoted 8 lines
Quoted 1 line
Like...
drivers/video/fbdev/offb.c?I'd probably reclassify
drivers/video/fbdev/simplefb.cas a skeleton and use it as a template for making device specific versions of it.I don't see why there is so much resistance to just making device specific fb drivers. Whenever the KMS driver gets written just disable the device specific fb driver in the build.
Except that is not the goal here. The simplefb or whatever replacement is supposed to stay as a generic driver compiled into kernel whereas the complete platform-specific driver is supposed to be provided as module and loaded at the init system's leasure sometime during boot. This way you can have generic distribution kernel which supports many devices but does not have built-in support for every graphics hardware.
Thanks
Michal
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 19 lines · Michal Suchanek
Quoted 18 lines · jonsmirl at gmail.com
Quoted 4 lines · Geert Uytterhoeven
Quoted 3 lines · jonsmirl at gmail.com
Quoted 3 lines
2) We don't want to hardcode these clocks into the kernel (sunxi) clk driver, instead the bootloader should tell the kernel about these clocks.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
So the only point of discussion left seems to be how to do 2...
Wouldn't it be a lot simpler just to use existing fbdev (not KMS) and whip together a device specific driver that claims the proper resources? And just implement the minimal about of fbdev possible? fbdev already is a driver library.
Like...
drivers/video/fbdev/offb.c?I'd probably reclassify
drivers/video/fbdev/simplefb.cas a skeleton and use it as a template for making device specific versions of it.
Quoted 6 lines
Quoted 3 lines
I don't see why there is so much resistance to just making device specific fb drivers. Whenever the KMS driver gets written just disable the device specific fb driver in the build.
Except that is not the goal here. The simplefb or whatever replacement is supposed to stay as a generic driver compiled into kernel whereas
There is no generic solution to this problem as this entire thread has illustrated. The clocks/regulators needed by each SOC vary.
So there are two solutions..
1) modify simplefb to have some kind of heuristic that tries to guess what needs to be protected. A heuristic that is probably going to fail on every new SOC.
2) Spend a day implementing a device specific fbdev driver that does the correct thing all of the time. These drivers would sit in initrd and load before the clock/regulator clean up shuts everything off. Use the existing simplefb code as a template for doing this.
Quoted 14 lines
the complete platform-specific driver is supposed to be provided as module and loaded at the init system's leasure sometime during boot. This way you can have generic distribution kernel which supports many devices but does not have built-in support for every graphics hardware.
Thanks
Michal
--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe at googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Signature · 2 lines
Jon Smirl jonsmirl at gmail.com
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 5 lines · jonsmirl at gmail.com
2) Spend a day implementing a device specific fbdev driver that does the correct thing all of the time. These drivers would sit in initrd and load before the clock/regulator clean up shuts everything off. Use the existing simplefb code as a template for doing this.
If that finally ends this discussion, i'll more than happily do it. I'm sure that we've all could've done this a hundred times in the time we've wasted here.
Good call Geert.
Luc Verhaegen.
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to jonsmirl at gmail.comQuoted 27 lines · jonsmirl at gmail.com
Quoted 19 lines · Michal Suchanek
Quoted 18 lines · jonsmirl at gmail.com
Quoted 4 lines · Geert Uytterhoeven
Quoted 3 lines · jonsmirl at gmail.com
Quoted 3 lines
2) We don't want to hardcode these clocks into the kernel (sunxi) clk driver, instead the bootloader should tell the kernel about these clocks.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
So the only point of discussion left seems to be how to do 2...
Wouldn't it be a lot simpler just to use existing fbdev (not KMS) and whip together a device specific driver that claims the proper resources? And just implement the minimal about of fbdev possible? fbdev already is a driver library.
Like...
drivers/video/fbdev/offb.c?I'd probably reclassify
drivers/video/fbdev/simplefb.cas a skeleton and use it as a template for making device specific versions of it.Quoted 6 lines
Quoted 3 lines
I don't see why there is so much resistance to just making device specific fb drivers. Whenever the KMS driver gets written just disable the device specific fb driver in the build.
Except that is not the goal here. The simplefb or whatever replacement is supposed to stay as a generic driver compiled into kernel whereas
Quoted 7 lines
There is no generic solution to this problem as this entire thread has illustrated. The clocks/regulators needed by each SOC vary.
So there are two solutions..
1) modify simplefb to have some kind of heuristic that tries to guess what needs to be protected. A heuristic that is probably going to fail on every new SOC.
You do not need a heuristic when the bootloader that enabled the clocks and regulators can tell you which.
And this patch was initially about adding support to simplefb to read from DT where u-boot fills in the clocks that are needed for HDMI output to keep running on sunxi.
Quoted 5 lines
2) Spend a day implementing a device specific fbdev driver that does the correct thing all of the time. These drivers would sit in initrd and load before the clock/regulator clean up shuts everything off. Use the existing simplefb code as a template for doing this.
But then you need to spend a day implementing such driver for every SoC and it will not work before initrd is loaded.
In contrast simplefb with resource management support can work on any platform where the bootloader enables framebuffer and then can be compiled into generic kernel and work before even initrd is loaded.
Thanks
Michal
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to jonsmirl at gmail.comQuoted 24 lines · jonsmirl at gmail.com
Quoted 23 lines · Michal Suchanek
Quoted 21 lines · jonsmirl at gmail.com
Quoted 4 lines · Geert Uytterhoeven
Quoted 3 lines · jonsmirl at gmail.com
Quoted 3 lines
2) We don't want to hardcode these clocks into the kernel (sunxi) clk driver, instead the bootloader should tell the kernel about these clocks.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
So the only point of discussion left seems to be how to do 2...
Wouldn't it be a lot simpler just to use existing fbdev (not KMS) and whip together a device specific driver that claims the proper resources? And just implement the minimal about of fbdev possible? fbdev already is a driver library.
Like...
drivers/video/fbdev/offb.c?I'd probably reclassify
drivers/video/fbdev/simplefb.cas a skeleton and use it as a template for making device specific versions of it.I don't see why there is so much resistance to just making device specific fb drivers. Whenever the KMS driver gets written just disable the device specific fb driver in the build.
Quoted 5 lines
Quoted 2 lines
Except that is not the goal here. The simplefb or whatever replacement is supposed to stay as a generic driver compiled into kernel whereas
There is no generic solution to this problem as this entire thread has illustrated. The clocks/regulators needed by each SOC vary.
There is a generic solution. Genericity only works if you define a well defined set of assumptions. In this case the assumptions are that some firmware sets up display hardware to scan out from a memory region and communicates the location, layout and format of that memory region so that a generic driver can write into that framebuffer.
The generic solution here works because we've eliminated the platform specificities and let firmware take care of it.
Quoted 9 lines
So there are two solutions..
1) modify simplefb to have some kind of heuristic that tries to guess what needs to be protected. A heuristic that is probably going to fail on every new SOC.2) Spend a day implementing a device specific fbdev driver that does the correct thing all of the time. These drivers would sit in initrd and load before the clock/regulator clean up shuts everything off. Use the existing simplefb code as a template for doing this.
There's a third possibility: find a way to prevent the clock framework (and any other resource framework for that matter) from forcefully disabling things that they shouldn't.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140829/e055b012/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Hans de GoedeQuoted 1 line · Hans de Goede
On 08/27/2014 04:16 PM, Thierry Reding wrote:
[...]
Quoted 17 lines
Quoted 11 lines
Quoted 10 lines
Hmm I see, in my mind the problem is not that the clk framework disables unused clocks, but that no one is marking the clocks in question as used. Someone should mark these clocks as used so that they do not get disabled.
We could add a
clk_mark_in_usefunction and have the simplefb patch call that instead ofclk_prepare_and_enable, or maybe even better just only claim the clks and teach the clk framework to not disable claimed clk in its cleanup run. That would make it clear that simplefb is not enabling anything, just claiming resource its need to avoid them getting removed from underneath simplefb, would that work for you ?Quoted 5 lines
That would be more accurate, but it boils down to the same problem where we still need a driver to claim the resources in some way whereas the problem is fundamentally one where the bootloader should be telling the kernel not to disable it. It's in fact the bootloader that's claiming the resources.
Quoted 3 lines
Yes, but those resources do not belong to the bootloader in a sense that traditional bootloader / firmware claimed resources (e.g. acpi reserved resources) do. These traditional resources are claimed for ever.
I thought that at least on x86 there was a way for the kernel to reclaim memory set apart for an early framebuffer.
Quoted 3 lines
Where as these resources are claimed by the bootloader to keep the simplefb it provides working, as soon as the simplefb is no longer used, they become unused.
Right. And when simplefb goes away it is because a real driver is taking over, in which case it will claim the resources explicitly.
Quoted 17 lines
Quoted 8 lines
The copy and paste is for code that's platform specific. The clocks have different names, resets are different, supplies are different. The fact that many can currently use the same driver is likely just coincidence rather than design and it's entirely possible that at some point they'll add support for a more advanced feature that makes them incompatible with the rest of the generic drivers. And then you have a big mess because you need to add quirks all over the place.
Quoted 4 lines
And this isn't all that far off-topic, since simplefb also needs to deal with this kind of situation. And what I've been arguing is that in order to really be generic it has to make assumptions, one of which is that it uses only resources that it doesn't need to explicitly handle.
I can understand that you're worried about generic ?hci drivers dealing with clocks / resets / etc. As there may be strict ordering requirements there, but for simplefb that is not the case.
Quoted 5 lines
All we're asking for is for a way to communicate 2 things to the kernel:
1) These resources are in use (we are not asking the kernel to do anything with them, rather the opposite, we're asking to leave them alone so no ordering issues)
Right. That's the issue that needs to be solved. We still only disagree on how it should be solved.
Quoted 2 lines
2) Tie these resources to simplefb so that the kernel can know when they are no longer in use, and it may e.g. re-use the memory
For the memory there shouldn't be a problem because it's already in the DT node anyway. It has to be there so that simplefb knows where to write to.
For all the other resources, if 1) is solved properly then 2) becomes a non-issue.
Quoted 2 lines
To me the most logical and also most "correct" way of modelling this is to put the resources inside the simplefb dt node.
Except that simplefb isn't a real device, so there's a hard time justifying its existence in DT as it is. Claiming resources from a virtual device doesn't sound correct to me at all.
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
The key word here is "the used resources" to me this is not about simlefb managing resources, but marking them as used as long as it needs them, like it will need to do for the reserved mem chunk.
The difference between the clocks and the memory resource is that the driver needs to directly access the memory (it needs to map it and provide a userspace mapping for it) whereas it doesn't need to touch the clocks (except to workaround a Linux-specific implementation detail).
Quoted 5 lines
Erm, no, the need to map the memory and the memory being a resource which may be released are an orthogonal problem. E.g. a system with dedicated framebuffer memory won't need to use a reserved main-memory chunk, nor need to worry about returning that mem when simplefb is no longer in use.
I would think the memory should still be reserved anyway to make sure nothing else is writing over it. And it's in the device tree anyway because the driver needs to know where to put framebuffer content. So the point I was trying to make is that we can't treat the memory in the same way as clocks because it needs to be explicitly managed. Whereas clocks don't. The driver is simply too generic to know what to do with the clocks. It doesn't know what frequency they should be running at or what they're used for, so by any definition of what DT should describe they're useless for this virtual device.
Furthermore it's fairly likely that as your kernel support progresses you'll find that the driver all of a sudden needs to manage some other type of resource that you just haven't needed until now because it may default to being always on. Then you'll have a hard time keeping backwards-compatibility and will have to resort to the kinds of hacks that you don't want to see in the kernel.
So it really boils down to the DT needing to describe a complete device with all the dependencies. And just clocks aren't the complete description. But if you want the complete description then you're going to need a complete driver as well and simplefb is out of the picture anyway. Once again, the current, basic form of the binding allows for a completely generic implementation of the driver because it makes assumptions about firmware setting things up the right way so that the driver doesn't have to.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140829/29e057cd/attachment-0001.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi,
Quoted 60 lines · Thierry Reding
Quoted 1 line · Hans de Goede
On 08/27/2014 04:16 PM, Thierry Reding wrote:
[...]
Quoted 17 lines
Quoted 11 lines
Quoted 10 lines
Hmm I see, in my mind the problem is not that the clk framework disables unused clocks, but that no one is marking the clocks in question as used. Someone should mark these clocks as used so that they do not get disabled.
We could add a
clk_mark_in_usefunction and have the simplefb patch call that instead ofclk_prepare_and_enable, or maybe even better just only claim the clks and teach the clk framework to not disable claimed clk in its cleanup run. That would make it clear that simplefb is not enabling anything, just claiming resource its need to avoid them getting removed from underneath simplefb, would that work for you ?Quoted 5 lines
That would be more accurate, but it boils down to the same problem where we still need a driver to claim the resources in some way whereas the problem is fundamentally one where the bootloader should be telling the kernel not to disable it. It's in fact the bootloader that's claiming the resources.
Quoted 3 lines
Yes, but those resources do not belong to the bootloader in a sense that traditional bootloader / firmware claimed resources (e.g. acpi reserved resources) do. These traditional resources are claimed for ever.
I thought that at least on x86 there was a way for the kernel to reclaim memory set apart for an early framebuffer.
Quoted 3 lines
Where as these resources are claimed by the bootloader to keep the simplefb it provides working, as soon as the simplefb is no longer used, they become unused.
Right. And when simplefb goes away it is because a real driver is taking over, in which case it will claim the resources explicitly.
Quoted 17 lines
Quoted 8 lines
The copy and paste is for code that's platform specific. The clocks have different names, resets are different, supplies are different. The fact that many can currently use the same driver is likely just coincidence rather than design and it's entirely possible that at some point they'll add support for a more advanced feature that makes them incompatible with the rest of the generic drivers. And then you have a big mess because you need to add quirks all over the place.
Quoted 4 lines
And this isn't all that far off-topic, since simplefb also needs to deal with this kind of situation. And what I've been arguing is that in order to really be generic it has to make assumptions, one of which is that it uses only resources that it doesn't need to explicitly handle.
I can understand that you're worried about generic ?hci drivers dealing with clocks / resets / etc. As there may be strict ordering requirements there, but for simplefb that is not the case.
Quoted 5 lines
All we're asking for is for a way to communicate 2 things to the kernel:
1) These resources are in use (we are not asking the kernel to do anything with them, rather the opposite, we're asking to leave them alone so no ordering issues)
Right. That's the issue that needs to be solved. We still only disagree on how it should be solved.
Quoted 6 lines
Quoted 2 lines
2) Tie these resources to simplefb so that the kernel can know when they are no longer in use, and it may e.g. re-use the memory
For the memory there shouldn't be a problem because it's already in the DT node anyway. It has to be there so that simplefb knows where to write to.
The memory information currently in the dt node is not complete enough to reclaim memory, e.g. the sunxi driver always reserves 8M, but the simplefb reg entry only describes the part actually used for the framebuffer.
Quoted 9 lines
For all the other resources, if 1) is solved properly then 2) becomes a non-issue.
Quoted 2 lines
To me the most logical and also most "correct" way of modelling this is to put the resources inside the simplefb dt node.
Except that simplefb isn't a real device, so there's a hard time justifying its existence in DT as it is. Claiming resources from a virtual device doesn't sound correct to me at all.
Yet you want it to claim memory that does not seem consistent to me.
Quoted 16 lines
Quoted 10 lines
Quoted 9 lines
Quoted 4 lines
The key word here is "the used resources" to me this is not about simlefb managing resources, but marking them as used as long as it needs them, like it will need to do for the reserved mem chunk.
The difference between the clocks and the memory resource is that the driver needs to directly access the memory (it needs to map it and provide a userspace mapping for it) whereas it doesn't need to touch the clocks (except to workaround a Linux-specific implementation detail).
Quoted 5 lines
Erm, no, the need to map the memory and the memory being a resource which may be released are an orthogonal problem. E.g. a system with dedicated framebuffer memory won't need to use a reserved main-memory chunk, nor need to worry about returning that mem when simplefb is no longer in use.
Quoted 3 lines
I would think the memory should still be reserved anyway to make sure nothing else is writing over it. And it's in the device tree anyway because the driver needs to know where to put framebuffer content.
No, the address were to write framebuffer contents currently is in the simplefb node, not the actually backing memory info. I can fully see some crazy hardware where a chunk of main memory is reserved for some funky video engine, and then that chunk of memory gets accessed through io-mem addresses for framebuffer access (e.g. the hardware may need this to know when the fb is dirtied).
Quoted 7 lines
So
the point I was trying to make is that we can't treat the memory in the same way as clocks because it needs to be explicitly managed. Whereas clocks don't. The driver is simply too generic to know what to do with the clocks. It doesn't know what frequency they should be running at or what they're used for, so by any definition of what DT should describe they're useless for this virtual device.
I don't see why you keep insisting that the memory is so special, it is just another resource which we need to claim, and tie to the simplefb node so that it can be re-used (or disabled) when simplefb is no longer used (it could e.g. be unbound explicitly on headless systems).
Quoted 6 lines
Furthermore it's fairly likely that as your kernel support progresses you'll find that the driver all of a sudden needs to manage some other type of resource that you just haven't needed until now because it may default to being always on. Then you'll have a hard time keeping backwards-compatibility and will have to resort to the kinds of hacks that you don't want to see in the kernel.
kernel support? This is about u-boot's video code and the simplefb bindings.
Quoted 5 lines
So it really boils down to the DT needing to describe a complete device with all the dependencies. And just clocks aren't the complete description. But if you want the complete description then you're going to need a complete driver as well and simplefb is out of the picture anyway.
Yes we eventually need a full kernel driver, with its own bindings, that is not what this is about.
Quoted 4 lines
Once again, the current, basic form of the binding allows for a completely generic implementation of the driver because it makes assumptions about firmware setting things up the right way so that the driver doesn't have to.
Except that it does not work because it does not claim the necessary resources.
We seem to be at a point where this discussion is just going in circles, and since there seems to be no reasonable alternative to the proposed solution of adding the clocks to the simplefb node, can you please just stop blocking progress on this?
Your objection to this has been duly noted, but no one is forcing you or other people to actually use the clocks property in your implementation of simplefb. So if your 101% certain that this is a bad idea, can you please just let us (the sunxi people) make our own mistakes and learn from those ? As we actually plan to use the clocks property, we will be the ones which will have to deal with any issues. For the record, I don't think this is a bad idea myself, but that just brings us full circle again.
I'm willing to look into just marking the clocks as used, instead of actually enabling them.
Regards,
Hans
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 2 lines · Hans de Goede
Quoted 1 line · Thierry Reding
On Thu, Aug 28, 2014 at 02:15:40PM +0200, Hans de Goede wrote:
[...]
Quoted 10 lines
Quoted 6 lines
Quoted 2 lines
2) Tie these resources to simplefb so that the kernel can know when they are no longer in use, and it may e.g. re-use the memory
For the memory there shouldn't be a problem because it's already in the DT node anyway. It has to be there so that simplefb knows where to write to.
The memory information currently in the dt node is not complete enough to reclaim memory, e.g. the sunxi driver always reserves 8M, but the simplefb reg entry only describes the part actually used for the framebuffer.
You can easily fix that.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
To me the most logical and also most "correct" way of modelling this is to put the resources inside the simplefb dt node.
Except that simplefb isn't a real device, so there's a hard time justifying its existence in DT as it is. Claiming resources from a virtual device doesn't sound correct to me at all.
Yet you want it to claim memory that does not seem consistent to me.
Because it needs to explicitly access that memory. It does not need to explicitly access the clocks.
Quoted 19 lines
Quoted 15 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
The key word here is "the used resources" to me this is not about simlefb managing resources, but marking them as used as long as it needs them, like it will need to do for the reserved mem chunk.
The difference between the clocks and the memory resource is that the driver needs to directly access the memory (it needs to map it and provide a userspace mapping for it) whereas it doesn't need to touch the clocks (except to workaround a Linux-specific implementation detail).
Quoted 5 lines
Erm, no, the need to map the memory and the memory being a resource which may be released are an orthogonal problem. E.g. a system with dedicated framebuffer memory won't need to use a reserved main-memory chunk, nor need to worry about returning that mem when simplefb is no longer in use.
Quoted 3 lines
I would think the memory should still be reserved anyway to make sure nothing else is writing over it. And it's in the device tree anyway because the driver needs to know where to put framebuffer content.
Quoted 6 lines
No, the address were to write framebuffer contents currently is in the simplefb node, not the actually backing memory info. I can fully see some crazy hardware where a chunk of main memory is reserved for some funky video engine, and then that chunk of memory gets accessed through io-mem addresses for framebuffer access (e.g. the hardware may need this to know when the fb is dirtied).
We're drifting off into the realm of hypotheses here. Of course if you can't make the hardware work with these simple assumptions because it's too whacky then that's just tough luck.
Quoted 10 lines
Quoted 7 lines
So
the point I was trying to make is that we can't treat the memory in the same way as clocks because it needs to be explicitly managed. Whereas clocks don't. The driver is simply too generic to know what to do with the clocks. It doesn't know what frequency they should be running at or what they're used for, so by any definition of what DT should describe they're useless for this virtual device.I don't see why you keep insisting that the memory is so special, it is just another resource which we need to claim,
It's the only resource which we need to claim. Because it is the only resource that needs to be explicitly accessed. simplefb is useless if you don't write to that memory.
Quoted 3 lines
and tie to the simplefb node
so that it can be re-used (or disabled) when simplefb is no longer used (it could e.g. be unbound explicitly on headless systems).
On headless systems the firmware shouldn't be setting up a framebuffer in the first place.
Quoted 8 lines
Quoted 6 lines
Furthermore it's fairly likely that as your kernel support progresses you'll find that the driver all of a sudden needs to manage some other type of resource that you just haven't needed until now because it may default to being always on. Then you'll have a hard time keeping backwards-compatibility and will have to resort to the kinds of hacks that you don't want to see in the kernel.
kernel support? This is about u-boot's video code and the simplefb bindings.
And the kernel doesn't need to use the simplefb bindings? Why are we even having this conversation, then?
Quoted 8 lines
Quoted 5 lines
So it really boils down to the DT needing to describe a complete device with all the dependencies. And just clocks aren't the complete description. But if you want the complete description then you're going to need a complete driver as well and simplefb is out of the picture anyway.
Yes we eventually need a full kernel driver, with its own bindings, that is not what this is about.
It is to some degree. The whole point of simplefb is to provide a useful graphical output until a full driver is in place. The way to achieve that is by taking advantage of the firmware setting things up for you. Which is what I've been saying all along. If the firmware has already set things up for you, you shouldn't need to do anything special like enabling clocks because they are already on.
Oh, and let me restate that that's not actually what the patch is doing. It isn't enabling clocks at all. It's merely a workaround to keep them running.
Quoted 7 lines
Quoted 4 lines
Once again, the current, basic form of the binding allows for a completely generic implementation of the driver because it makes assumptions about firmware setting things up the right way so that the driver doesn't have to.
Except that it does not work because it does not claim the necessary resources.
Wrong. The reason it doesn't work is because the clock framework disables the clocks. That's a Linux-specific implementation detail and therefore shouldn't influence the binding in any way.
Quoted 4 lines
We seem to be at a point where this discussion is just going in circles, and since there seems to be no reasonable alternative to the proposed solution of adding the clocks to the simplefb node, can you please just stop blocking progress on this?
A couple of different solutions to the problem were proposed during the discussion. It's just that nobody's been willing to take a step back and look at this from a different perspective.
Quoted 1 line
Your objection to this has been duly noted,
Right. Ignored is how I would put it.
Quoted 5 lines
but no one is forcing you or
other people to actually use the clocks property in your implementation of simplefb. So if your 101% certain that this is a bad idea, can you please just let us (the sunxi people) make our own mistakes and learn from those ?
Ugh... This isn't just about letting you make your own mistakes. This is about solving things in a wrong way (and device specific way) and baking something into an ABI that really doesn't need to be there. And more specifically if we let clocks be "managed" by simplefb we can no longer claim that it is simple and therefore can't block adding all other sorts of device-specific hacks to it.
Quoted 2 lines
As we actually plan to use the clocks property, we will be the ones which will have to deal with any issues.
Wrong. Everyone that potentially wants to use the driver will have to deal with this.
Anyway, I am getting tired of this whole discussion and as you already said we're not making any progress. You really should repost this series to the devicetree mailing list and give people there a chance to look at the proposed changes. If everybody else is fine with it my objections will be overruled anyway. I'll just have to sort out/live with the mess when I want to use simplefb for hand-off.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140829/50c0b7e1/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingQuoted 7 lines · Thierry Reding
I would think the memory should still be reserved anyway to make sure nothing else is writing over it. And it's in the device tree anyway because the driver needs to know where to put framebuffer content. So the point I was trying to make is that we can't treat the memory in the same way as clocks because it needs to be explicitly managed. Whereas clocks don't. The driver is simply too generic to know what to do with the clocks.
You agreed on the fact that the only thing we need to do with the clocks is claim them. Really, I don't find what's complicated there (or not generic).
Quoted 1 line
It doesn't know what frequency they should be running at
We don't care about that. Just like we don't care about which frequency is the memory bus running at. It will just run at whatever frequency is appropriate.
Quoted 1 line
or what they're used for
And we don't care about that either. You're not interested in what output the framebuffer is setup to use, which is pretty much the same here, this is the same thing here.
Quoted 9 lines
so by any definition of what DT should describe they're useless for this virtual device.
Furthermore it's fairly likely that as your kernel support progresses you'll find that the driver all of a sudden needs to manage some other type of resource that you just haven't needed until now because it may default to being always on. Then you'll have a hard time keeping backwards-compatibility and will have to resort to the kinds of hacks that you don't want to see in the kernel.
Not such a hard time. An older DT wouldn't define the new requirements anyway, so they wouldn't be used, and we would end up in pretty much the current case.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140829/bd8b3639/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 9 lines · Maxime Ripard
Quoted 7 lines · Thierry Reding
I would think the memory should still be reserved anyway to make sure nothing else is writing over it. And it's in the device tree anyway because the driver needs to know where to put framebuffer content. So the point I was trying to make is that we can't treat the memory in the same way as clocks because it needs to be explicitly managed. Whereas clocks don't. The driver is simply too generic to know what to do with the clocks.
Quoted 3 lines
You agreed on the fact that the only thing we need to do with the clocks is claim them. Really, I don't find what's complicated there (or not generic).
That's not what I agreed on. What I said is that the only thing we need to do with the clocks is nothing. They are already in the state that they need to be.
Quoted 5 lines
Quoted 1 line
It doesn't know what frequency they should be running at
We don't care about that. Just like we don't care about which frequency is the memory bus running at. It will just run at whatever frequency is appropriate.
Exactly. And you shouldn't have to care about them at all. Firmware has already configured the clocks to run at the correct frequencies, and it has made sure that they are enabled.
Quoted 5 lines
Quoted 1 line
or what they're used for
And we don't care about that either. You're not interested in what output the framebuffer is setup to use, which is pretty much the same here, this is the same thing here.
That's precisely what I've been saying. The only thing that simplefb cares about is the memory it should be using and the format of the pixels (and how many of them) it writes into that memory. Everything else is assumed to have been set up.
Including clocks.
Quoted 10 lines
Quoted 9 lines
so by any definition of what DT should describe they're useless for this virtual device.
Furthermore it's fairly likely that as your kernel support progresses you'll find that the driver all of a sudden needs to manage some other type of resource that you just haven't needed until now because it may default to being always on. Then you'll have a hard time keeping backwards-compatibility and will have to resort to the kinds of hacks that you don't want to see in the kernel.
Quoted 3 lines
Not such a hard time. An older DT wouldn't define the new requirements anyway, so they wouldn't be used, and we would end up in pretty much the current case.
Except that you have firmware in the wild that sets up an incomplete simplefb node and if you don't want to break compatibility you need to provide fallbacks for the resources that aren't listed in the DT node. And given that those fallbacks are all very board specific you'll need to find ways to keep them enabled if you want to keep existing setups working.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140829/d35e608e/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 34 lines · Thierry Reding
Quoted 9 lines · Maxime Ripard
Quoted 7 lines · Thierry Reding
I would think the memory should still be reserved anyway to make sure nothing else is writing over it. And it's in the device tree anyway because the driver needs to know where to put framebuffer content. So the point I was trying to make is that we can't treat the memory in the same way as clocks because it needs to be explicitly managed. Whereas clocks don't. The driver is simply too generic to know what to do with the clocks.
Quoted 3 lines
You agreed on the fact that the only thing we need to do with the clocks is claim them. Really, I don't find what's complicated there (or not generic).
That's not what I agreed on. What I said is that the only thing we need to do with the clocks is nothing. They are already in the state that they need to be.
Quoted 5 lines
Quoted 1 line
It doesn't know what frequency they should be running at
We don't care about that. Just like we don't care about which frequency is the memory bus running at. It will just run at whatever frequency is appropriate.
Exactly. And you shouldn't have to care about them at all. Firmware has already configured the clocks to run at the correct frequencies, and it has made sure that they are enabled.
Quoted 5 lines
Quoted 1 line
or what they're used for
And we don't care about that either. You're not interested in what output the framebuffer is setup to use, which is pretty much the same here, this is the same thing here.
Quoted 6 lines
That's precisely what I've been saying. The only thing that simplefb cares about is the memory it should be using and the format of the pixels (and how many of them) it writes into that memory. Everything else is assumed to have been set up.
Including clocks.
And for simplefb to work it should claim the memory and clock so that nothing else in the kernel uses them or reclaims them as unused. That currently the memory is reserved by excluding it from memory usable by the kernel is a hack, not proper resource management. And so is keeping all clocks enabled in case something used them.
Quoted 15 lines
Quoted 11 lines
Quoted 10 lines
so by any definition of what DT should describe they're useless for this virtual device.
Furthermore it's fairly likely that as your kernel support progresses you'll find that the driver all of a sudden needs to manage some other type of resource that you just haven't needed until now because it may default to being always on. Then you'll have a hard time keeping backwards-compatibility and will have to resort to the kinds of hacks that you don't want to see in the kernel.
Quoted 3 lines
Not such a hard time. An older DT wouldn't define the new requirements anyway, so they wouldn't be used, and we would end up in pretty much the current case.
Quoted 7 lines
Except that you have firmware in the wild that sets up an incomplete simplefb node and if you don't want to break compatibility you need to provide fallbacks for the resources that aren't listed in the DT node. And given that those fallbacks are all very board specific you'll need to find ways to keep them enabled if you want to keep existing setups working.
Except in this case either the simplefb does not need clocks the user had to set up the kernel argument to not disable unused clocks so the user of such firmware is well aware of that limitation.
Thanks
Michal
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingQuoted 10 lines · Thierry Reding
Quoted 9 lines · Maxime Ripard
Quoted 7 lines · Thierry Reding
I would think the memory should still be reserved anyway to make sure nothing else is writing over it. And it's in the device tree anyway because the driver needs to know where to put framebuffer content. So the point I was trying to make is that we can't treat the memory in the same way as clocks because it needs to be explicitly managed. Whereas clocks don't. The driver is simply too generic to know what to do with the clocks.
Quoted 7 lines
Quoted 3 lines
You agreed on the fact that the only thing we need to do with the clocks is claim them. Really, I don't find what's complicated there (or not generic).
That's not what I agreed on. What I said is that the only thing we need to do with the clocks is nothing. They are already in the state that they need to be.
Claim was probably a poor choice of words, but still. We have to keep the clock running, and both the solution you've been giving and this patch do so in a generic way.
Quoted 16 lines
Quoted 5 lines
Quoted 1 line
It doesn't know what frequency they should be running at
We don't care about that. Just like we don't care about which frequency is the memory bus running at. It will just run at whatever frequency is appropriate.
Exactly. And you shouldn't have to care about them at all. Firmware has already configured the clocks to run at the correct frequencies, and it has made sure that they are enabled.
Quoted 5 lines
Quoted 1 line
or what they're used for
And we don't care about that either. You're not interested in what output the framebuffer is setup to use, which is pretty much the same here, this is the same thing here.
Quoted 6 lines
That's precisely what I've been saying. The only thing that simplefb cares about is the memory it should be using and the format of the pixels (and how many of them) it writes into that memory. Everything else is assumed to have been set up.
Including clocks.
We're really discussing in circles here.
Mike?
Your opinion would be very valuable.
Quoted 14 lines
Quoted 10 lines
Quoted 9 lines
so by any definition of what DT should describe they're useless for this virtual device.
Furthermore it's fairly likely that as your kernel support progresses you'll find that the driver all of a sudden needs to manage some other type of resource that you just haven't needed until now because it may default to being always on. Then you'll have a hard time keeping backwards-compatibility and will have to resort to the kinds of hacks that you don't want to see in the kernel.
Quoted 3 lines
Not such a hard time. An older DT wouldn't define the new requirements anyway, so they wouldn't be used, and we would end up in pretty much the current case.
Quoted 6 lines
Except that you have firmware in the wild that sets up an incomplete simplefb node and if you don't want to break compatibility you need to provide fallbacks for the resources that aren't listed in the DT node. And given that those fallbacks are all very board specific you'll need to find ways to keep them enabled if you want to keep existing setups working.
How would an *optional* property break those users?
If you don't need any clock to be kept running (or are hiding them under the carpet), of course you don't need such a property.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140902/6a77288d/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoting Maxime Ripard (2014-09-02 02:25:08)
Quoted 44 lines · Thierry Reding
Quoted 10 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 7 lines
I would think the memory should still be reserved anyway to make sure nothing else is writing over it. And it's in the device tree anyway because the driver needs to know where to put framebuffer content. So the point I was trying to make is that we can't treat the memory in the same way as clocks because it needs to be explicitly managed. Whereas clocks don't. The driver is simply too generic to know what to do with the clocks.
Quoted 7 lines
Quoted 3 lines
You agreed on the fact that the only thing we need to do with the clocks is claim them. Really, I don't find what's complicated there (or not generic).
That's not what I agreed on. What I said is that the only thing we need to do with the clocks is nothing. They are already in the state that they need to be.
Claim was probably a poor choice of words, but still. We have to keep the clock running, and both the solution you've been giving and this patch do so in a generic way.
Quoted 21 lines
Quoted 5 lines
Quoted 1 line
It doesn't know what frequency they should be running at
We don't care about that. Just like we don't care about which frequency is the memory bus running at. It will just run at whatever frequency is appropriate.
Exactly. And you shouldn't have to care about them at all. Firmware has already configured the clocks to run at the correct frequencies, and it has made sure that they are enabled.
Quoted 5 lines
Quoted 1 line
or what they're used for
And we don't care about that either. You're not interested in what output the framebuffer is setup to use, which is pretty much the same here, this is the same thing here.
That's precisely what I've been saying. The only thing that simplefb cares about is the memory it should be using and the format of the pixels (and how many of them) it writes into that memory. Everything else is assumed to have been set up.
Quoted 6 lines
Quoted 1 line
Including clocks.
We're really discussing in circles here.
Mike?
-EHIGHLATENCYRESPONSE
I forgot about this thread. Sorry.
In an attempt to provide the least helpful answer possible, I will stay clear of all of the stuff relating to "how simple should simplefb be" and the related reserved memory discussion.
A few times in this thread it is stated that we can't prevent unused clocks from being disabled. That is only partially true.
The clock framework DOES provide a flag to prevent UNUSED clocks from being disabled at late_initcall-time by a clock "garbage collector" mechanism. Maxime and others familiar with the clock framework are aware of this.
What the framework doesn't do is to allow for a magic flag in DT, in platform_data or elsewhere that says, "don't let me get turned off until the right driver claims me". That would be an external or alternative method for preventing a clock from being disabled. We have a method for preventing clocks from being disabled. It is as follows:
struct clk *my_clk = clk_get(...);clk_prepare_enable(my_clk);
That is how it should be done. Period.
With that said I think that Luc's approach is very sensible. I'm not sure what purpose in the universe DT is supposed to serve if not for _this_exact_case_. We have a nice abstracted driver, usable by many people. The hardware details of how it is hooked up at the board level can all be hidden behind stable DT bindings that everyone already uses.
What more could you want?
Regards,
Mike
Quoted 34 lines
Your opinion would be very valuable.
Quoted 14 lines
Quoted 10 lines
Quoted 9 lines
so by any definition of what DT should describe they're useless for this virtual device.
Furthermore it's fairly likely that as your kernel support progresses you'll find that the driver all of a sudden needs to manage some other type of resource that you just haven't needed until now because it may default to being always on. Then you'll have a hard time keeping backwards-compatibility and will have to resort to the kinds of hacks that you don't want to see in the kernel.
Quoted 3 lines
Not such a hard time. An older DT wouldn't define the new requirements anyway, so they wouldn't be used, and we would end up in pretty much the current case.
Quoted 6 lines
Except that you have firmware in the wild that sets up an incomplete simplefb node and if you don't want to break compatibility you need to provide fallbacks for the resources that aren't listed in the DT node. And given that those fallbacks are all very board specific you'll need to find ways to keep them enabled if you want to keep existing setups working.
How would an *optional* property break those users?
If you don't need any clock to be kept running (or are hiding them under the carpet), of course you don't need such a property.
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 77 lines · Mike Turquette
Quoting Maxime Ripard (2014-09-02 02:25:08)
Quoted 44 lines · Thierry Reding
Quoted 10 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 7 lines
I would think the memory should still be reserved anyway to make sure nothing else is writing over it. And it's in the device tree anyway because the driver needs to know where to put framebuffer content. So the point I was trying to make is that we can't treat the memory in the same way as clocks because it needs to be explicitly managed. Whereas clocks don't. The driver is simply too generic to know what to do with the clocks.
Quoted 7 lines
Quoted 3 lines
You agreed on the fact that the only thing we need to do with the clocks is claim them. Really, I don't find what's complicated there (or not generic).
That's not what I agreed on. What I said is that the only thing we need to do with the clocks is nothing. They are already in the state that they need to be.
Claim was probably a poor choice of words, but still. We have to keep the clock running, and both the solution you've been giving and this patch do so in a generic way.
Quoted 21 lines
Quoted 5 lines
Quoted 1 line
It doesn't know what frequency they should be running at
We don't care about that. Just like we don't care about which frequency is the memory bus running at. It will just run at whatever frequency is appropriate.
Exactly. And you shouldn't have to care about them at all. Firmware has already configured the clocks to run at the correct frequencies, and it has made sure that they are enabled.
Quoted 5 lines
Quoted 1 line
or what they're used for
And we don't care about that either. You're not interested in what output the framebuffer is setup to use, which is pretty much the same here, this is the same thing here.
That's precisely what I've been saying. The only thing that simplefb cares about is the memory it should be using and the format of the pixels (and how many of them) it writes into that memory. Everything else is assumed to have been set up.
Quoted 6 lines
Quoted 1 line
Including clocks.
We're really discussing in circles here.
Mike?
-EHIGHLATENCYRESPONSEI forgot about this thread. Sorry.
In an attempt to provide the least helpful answer possible, I will stay clear of all of the stuff relating to "how simple should simplefb be" and the related reserved memory discussion.
A few times in this thread it is stated that we can't prevent unused clocks from being disabled. That is only partially true.
The clock framework DOES provide a flag to prevent UNUSED clocks from being disabled at late_initcall-time by a clock "garbage collector" mechanism. Maxime and others familiar with the clock framework are aware of this.
What the framework doesn't do is to allow for a magic flag in DT, in
platform_dataor elsewhere that says, "don't let me get turned off until the right driver claims me". That would be an external or alternative method for preventing a clock from being disabled. We have a method for preventing clocks from being disabled. It is as follows:struct clk
*my_clk=clk_get(...);clk_prepare_enable(my_clk);
Quoted 7 lines
That is how it should be done. Period.
With that said I think that Luc's approach is very sensible. I'm not sure what purpose in the universe DT is supposed to serve if not for _this_exact_case_. We have a nice abstracted driver, usable by many people. The hardware details of how it is hooked up at the board level can all be hidden behind stable DT bindings that everyone already uses.
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
If we start extending the binding with board-level details we end up duplicating the device tree node for the proper video device. Also note that it won't stop at clocks. Other setups will require regulators to be listed in this device tree node as well so that they don't get disabled at late_initcall. And the regulator bindings don't provide a method to list an arbitrary number of clocks in a single property in the way that the clocks property works.
There may be also resets involved. Fortunately the reset framework is minimalistic enough not to care about asserting all unused resets at late_initcall. And other things like power domains may also need to be kept on.
Passing in clock information via the device tree already requires a non- trivial amount of code in the firmware. A similar amount of code would be necessary for each type of resource that needs to be kept enabled. In addition to the above some devices may also require resources that have no generic bindings. That just doesn't scale.
The only reasonable thing for simplefb to do is not deal with any kind of resource at all (except perhaps area that contains the framebuffer memory).
So how about instead of requiring resources to be explicitly claimed we introduce something like the below patch? The intention being to give "firmware device" drivers a way of signalling to the clock framework that they need rely on clocks set up by firmware and when they no longer need them. This implements essentially what Mark (CC'ing again on this subthread) suggested earlier in this thread. Basically, it will allow drivers to determine the time when unused clocks are really unused. It will of course only work when used correctly by drivers. For the case of simplefb I'd expect its .probe() implementation to call the new clk_ignore_unused() function and once it has handed over control of the display hardware to the real driver it can call clk_unignore_unused() to signal that all unused clocks that it cares about have now been claimed. This is "reference counted" and can therefore be used by more than a single driver if necessary. Similar functionality could be added for other resource subsystems as needed.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-clk-Allow-drivers-to-reference-unused-clocks.patch
Type: text/x-diff
Size: 5230 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/c3794a2c/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/c3794a2c/attachment-0001.sig>
Re: [linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi Thierry,
(CC linux-pm, as PM is the real reason behind disabling unused clocks) (CC gregkh and lkml, for driver core)
Quoted 80 lines · Thierry Reding
Quoted 79 lines · Mike Turquette
Quoting Maxime Ripard (2014-09-02 02:25:08)
Quoted 44 lines · Thierry Reding
Quoted 10 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 7 lines
I would think the memory should still be reserved anyway to make sure nothing else is writing over it. And it's in the device tree anyway because the driver needs to know where to put framebuffer content. So the point I was trying to make is that we can't treat the memory in the same way as clocks because it needs to be explicitly managed. Whereas clocks don't. The driver is simply too generic to know what to do with the clocks.
Quoted 7 lines
Quoted 3 lines
You agreed on the fact that the only thing we need to do with the clocks is claim them. Really, I don't find what's complicated there (or not generic).
That's not what I agreed on. What I said is that the only thing we need to do with the clocks is nothing. They are already in the state that they need to be.
Claim was probably a poor choice of words, but still. We have to keep the clock running, and both the solution you've been giving and this patch do so in a generic way.
Quoted 21 lines
Quoted 5 lines
Quoted 1 line
It doesn't know what frequency they should be running at
We don't care about that. Just like we don't care about which frequency is the memory bus running at. It will just run at whatever frequency is appropriate.
Exactly. And you shouldn't have to care about them at all. Firmware has already configured the clocks to run at the correct frequencies, and it has made sure that they are enabled.
Quoted 5 lines
Quoted 1 line
or what they're used for
And we don't care about that either. You're not interested in what output the framebuffer is setup to use, which is pretty much the same here, this is the same thing here.
That's precisely what I've been saying. The only thing that simplefb cares about is the memory it should be using and the format of the pixels (and how many of them) it writes into that memory. Everything else is assumed to have been set up.
Quoted 6 lines
Quoted 1 line
Including clocks.
We're really discussing in circles here.
Mike?
-EHIGHLATENCYRESPONSEI forgot about this thread. Sorry.
In an attempt to provide the least helpful answer possible, I will stay clear of all of the stuff relating to "how simple should simplefb be" and the related reserved memory discussion.
A few times in this thread it is stated that we can't prevent unused clocks from being disabled. That is only partially true.
The clock framework DOES provide a flag to prevent UNUSED clocks from being disabled at late_initcall-time by a clock "garbage collector" mechanism. Maxime and others familiar with the clock framework are aware of this.
What the framework doesn't do is to allow for a magic flag in DT, in
platform_dataor elsewhere that says, "don't let me get turned off until the right driver claims me". That would be an external or alternative method for preventing a clock from being disabled. We have a method for preventing clocks from being disabled. It is as follows:struct clk
*my_clk=clk_get(...);clk_prepare_enable(my_clk);That is how it should be done. Period.
Quoted 8 lines
Quoted 5 lines
With that said I think that Luc's approach is very sensible. I'm not sure what purpose in the universe DT is supposed to serve if not for _this_exact_case_. We have a nice abstracted driver, usable by many people. The hardware details of how it is hooked up at the board level can all be hidden behind stable DT bindings that everyone already uses.
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many
It doesn't deal with "hardware details for hardware components for which no driver is available (yet)". That's why the hardware is still in a usable state, after the firmware has set it up.
Clocks, regulators, PM domains typically have system-wide implications, and thus need system-wide drivers (in the absence of such drivers, things would work as-is).
Note that the driver still requests resources (ioremap the frame buffer), so it needs to know about that tiny piece of hardware detail.
Quoted 4 lines
people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
The latter indeed complicates things. But see below... [*]
Quoted 7 lines
If we start extending the binding with board-level details we end up duplicating the device tree node for the proper video device. Also note that it won't stop at clocks. Other setups will require regulators to be listed in this device tree node as well so that they don't get disabled at
late_initcall. And the regulator bindings don't provide a method to list an arbitrary number of clocks in a single property in the way that the clocks property works.
Then (optional) regulator support needs to be added.
Quoted 4 lines
There may be also resets involved. Fortunately the reset framework is minimalistic enough not to care about asserting all unused resets at
late_initcall. And other things like power domains may also need to be kept on.
Fortunately, unlike clocks, PM domains are first class citizens in the device framework, as they're handled by the driver core.
So just adding a power-domains property to DTS will work, without any driver change.
Quoted 5 lines
Passing in clock information via the device tree already requires a non- trivial amount of code in the firmware. A similar amount of code would be necessary for each type of resource that needs to be kept enabled. In addition to the above some devices may also require resources that have no generic bindings. That just doesn't scale.
[*] The firmware does need to make sure the clocks, regulators, PM domains, ... are up and running for the initial video mode, too. So it already needs to have this knowledge (unless enabled by SoC reset-state).
Quoted 4 lines
The only reasonable thing for simplefb to do is not deal with any kind of resource at all (except perhaps area that contains the framebuffer memory).
Quoted 15 lines
So how about instead of requiring resources to be explicitly claimed we introduce something like the below patch? The intention being to give "firmware device" drivers a way of signalling to the clock framework that they need rely on clocks set up by firmware and when they no longer need them. This implements essentially what Mark (CC'ing again on this subthread) suggested earlier in this thread. Basically, it will allow drivers to determine the time when unused clocks are really unused. It will of course only work when used correctly by drivers. For the case of simplefb I'd expect its .probe() implementation to call the new
clk_ignore_unused()function and once it has handed over control of the display hardware to the real driver it can callclk_unignore_unused()to signal that all unused clocks that it cares about have now been claimed. This is "reference counted" and can therefore be used by more than a single driver if necessary. Similar functionality could be added for other resource subsystems as needed.
This still won't work for modules, right? Or am I missing something? With modules you will never know in advance what will be used and what won't be used, so you need to keep all clocks, regulators, PM domains, ... up and running?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 100 lines · Geert Uytterhoeven
Hi Thierry,
(CC linux-pm, as PM is the real reason behind disabling unused clocks) (CC gregkh and lkml, for driver core)
Quoted 80 lines · Thierry Reding
Quoted 79 lines · Mike Turquette
Quoting Maxime Ripard (2014-09-02 02:25:08)
Quoted 44 lines · Thierry Reding
Quoted 10 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 7 lines
I would think the memory should still be reserved anyway to make sure nothing else is writing over it. And it's in the device tree anyway because the driver needs to know where to put framebuffer content. So the point I was trying to make is that we can't treat the memory in the same way as clocks because it needs to be explicitly managed. Whereas clocks don't. The driver is simply too generic to know what to do with the clocks.
Quoted 7 lines
Quoted 3 lines
You agreed on the fact that the only thing we need to do with the clocks is claim them. Really, I don't find what's complicated there (or not generic).
That's not what I agreed on. What I said is that the only thing we need to do with the clocks is nothing. They are already in the state that they need to be.
Claim was probably a poor choice of words, but still. We have to keep the clock running, and both the solution you've been giving and this patch do so in a generic way.
Quoted 21 lines
Quoted 5 lines
Quoted 1 line
It doesn't know what frequency they should be running at
We don't care about that. Just like we don't care about which frequency is the memory bus running at. It will just run at whatever frequency is appropriate.
Exactly. And you shouldn't have to care about them at all. Firmware has already configured the clocks to run at the correct frequencies, and it has made sure that they are enabled.
Quoted 5 lines
Quoted 1 line
or what they're used for
And we don't care about that either. You're not interested in what output the framebuffer is setup to use, which is pretty much the same here, this is the same thing here.
That's precisely what I've been saying. The only thing that simplefb cares about is the memory it should be using and the format of the pixels (and how many of them) it writes into that memory. Everything else is assumed to have been set up.
Quoted 6 lines
Quoted 1 line
Including clocks.
We're really discussing in circles here.
Mike?
-EHIGHLATENCYRESPONSEI forgot about this thread. Sorry.
In an attempt to provide the least helpful answer possible, I will stay clear of all of the stuff relating to "how simple should simplefb be" and the related reserved memory discussion.
A few times in this thread it is stated that we can't prevent unused clocks from being disabled. That is only partially true.
The clock framework DOES provide a flag to prevent UNUSED clocks from being disabled at late_initcall-time by a clock "garbage collector" mechanism. Maxime and others familiar with the clock framework are aware of this.
What the framework doesn't do is to allow for a magic flag in DT, in
platform_dataor elsewhere that says, "don't let me get turned off until the right driver claims me". That would be an external or alternative method for preventing a clock from being disabled. We have a method for preventing clocks from being disabled. It is as follows:struct clk
*my_clk=clk_get(...);clk_prepare_enable(my_clk);That is how it should be done. Period.
Quoted 8 lines
Quoted 5 lines
With that said I think that Luc's approach is very sensible. I'm not sure what purpose in the universe DT is supposed to serve if not for _this_exact_case_. We have a nice abstracted driver, usable by many people. The hardware details of how it is hooked up at the board level can all be hidden behind stable DT bindings that everyone already uses.
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many
It doesn't deal with "hardware details for hardware components for which no driver is available (yet)". That's why the hardware is still in a usable state, after the firmware has set it up.
Quoted 6 lines
Clocks, regulators, PM domains typically have system-wide implications, and thus need system-wide drivers (in the absence of such drivers, things would work as-is).
Note that the driver still requests resources (ioremap the frame buffer), so it needs to know about that tiny piece of hardware detail.
That's not a hardware detail. Or at least it isn't hardware specific. It is needed and the same irrespective of display hardware. Clocks, power domains, regulators and all those are not always the same.
Quoted 15 lines
Quoted 4 lines
people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
The latter indeed complicates things. But see below... [*]
Quoted 7 lines
If we start extending the binding with board-level details we end up duplicating the device tree node for the proper video device. Also note that it won't stop at clocks. Other setups will require regulators to be listed in this device tree node as well so that they don't get disabled at
late_initcall. And the regulator bindings don't provide a method to list an arbitrary number of clocks in a single property in the way that the clocks property works.
Quoted 1 line
Then (optional) regulator support needs to be added.
Can you elaborate?
Quoted 9 lines
Quoted 4 lines
There may be also resets involved. Fortunately the reset framework is minimalistic enough not to care about asserting all unused resets at
late_initcall. And other things like power domains may also need to be kept on.Fortunately, unlike clocks, PM domains are first class citizens in the device framework, as they're handled by the driver core.
So just adding a power-domains property to DTS will work, without any driver change.
Well, the device driver would also need to call into the PM runtime framework to enable all the first class citizen magic. But even if it were to do that, you'd still need to add all the domains to the DTB.
Note that I'm saying DT*B* here, because the firmware needs to fill in those properties after the DTS has been compiled. And since most of these resources are linked via phandle you actually need to resolve these first before you can fill in the new properties of this dynamically created node.
So firmware needs to know exactly what device tree node to look for, find a corresponding phandle and then put the phandle value in the simplefb device tree node. And it needs to know intimate details about the clock provider binding because it needs to add an appropriate specifier, too.
And then all of a sudden something that was supposed to be simple and generic needs to know the specifics of some hardware device.
Quoted 9 lines
Quoted 5 lines
Passing in clock information via the device tree already requires a non- trivial amount of code in the firmware. A similar amount of code would be necessary for each type of resource that needs to be kept enabled. In addition to the above some devices may also require resources that have no generic bindings. That just doesn't scale.
[*] The firmware does need to make sure the clocks, regulators, PM domains, ... are up and running for the initial video mode, too. So it already needs to have this knowledge (unless enabled by SoC reset-state).
Certainly. But not all firmware will use a DTB (or in fact the same DTB as the kernel) to derive this information from, so it still needs to inspect the DTB that will be passed to the kernel and painfully extract information from various nodes and put it into a new node.
But that's not even the issue. You say yourself that the firmware set everything up itself already. My point is: why should the kernel have to do everything again, only to come to the conclusion that it doesn't have to touch hardware at all because it's already in the state that it should be?
In fact, Linux will at some point set things up from scratch anyway with a fully-fledged driver. But doing it in simplefb too would be doubly wasteful.
Quoted 20 lines
Quoted 4 lines
The only reasonable thing for simplefb to do is not deal with any kind of resource at all (except perhaps area that contains the framebuffer memory).
Quoted 15 lines
So how about instead of requiring resources to be explicitly claimed we introduce something like the below patch? The intention being to give "firmware device" drivers a way of signalling to the clock framework that they need rely on clocks set up by firmware and when they no longer need them. This implements essentially what Mark (CC'ing again on this subthread) suggested earlier in this thread. Basically, it will allow drivers to determine the time when unused clocks are really unused. It will of course only work when used correctly by drivers. For the case of simplefb I'd expect its .probe() implementation to call the new
clk_ignore_unused()function and once it has handed over control of the display hardware to the real driver it can callclk_unignore_unused()to signal that all unused clocks that it cares about have now been claimed. This is "reference counted" and can therefore be used by more than a single driver if necessary. Similar functionality could be added for other resource subsystems as needed.
Quoted 4 lines
This still won't work for modules, right? Or am I missing something? With modules you will never know in advance what will be used and what won't be used, so you need to keep all clocks, regulators, PM domains, ... up and running?
No. The way this works is that your firmware shim driver, simplefb in this case, will call clk_ignore_unused() to tell the clock framework that it uses clocks set up by the firmware, and therefore requests that no clocks should be considered unused (for now). Later on when the proper driver has successfully taken over from the shim driver, the shim driver can unregister itself and call clk_unignore_unused(), which will drop its "reference" on the unused clocks. When all references have been dropped the clock framework will then disable all remaining unused clocks.
In practice this will mean that all unused clocks will remain in their current state until the shim driver relinquishes control to the proper OS driver. And if that never happens then we're at least still left with a working framebuffer.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/92b8d2ff/attachment-0001.sig>
Re: [linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi Thierry,
Quoted 14 lines · Thierry Reding
Quoted 13 lines · Geert Uytterhoeven
(CC linux-pm, as PM is the real reason behind disabling unused clocks) (CC gregkh and lkml, for driver core)
Quoted 7 lines · Thierry Reding
If we start extending the binding with board-level details we end up duplicating the device tree node for the proper video device. Also note that it won't stop at clocks. Other setups will require regulators to be listed in this device tree node as well so that they don't get disabled at
late_initcall. And the regulator bindings don't provide a method to list an arbitrary number of clocks in a single property in the way that the clocks property works.
Quoted 3 lines
Quoted 1 line
Then (optional) regulator support needs to be added.
Can you elaborate?
I'm not so familiar with regulators, but I guess it's similar to clocks?
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
There may be also resets involved. Fortunately the reset framework is minimalistic enough not to care about asserting all unused resets at
late_initcall. And other things like power domains may also need to be kept on.
Quoted 8 lines
Quoted 4 lines
Fortunately, unlike clocks, PM domains are first class citizens in the device framework, as they're handled by the driver core.
So just adding a power-domains property to DTS will work, without any driver change.Well, the device driver would also need to call into the PM runtime framework to enable all the first class citizen magic. But even if it were to do that, you'd still need to add all the domains to the DTB.
Powering up domains can be done solely by the device-specific PM domain code, without PM runtime. If simplefb is tied to the PM domain and doesn't do any PM runtime, the domain will stay powered on (only unused PM domains are powered down via late_initcall).
Quoted 11 lines
Note that I'm saying DT*B* here, because the firmware needs to fill in those properties after the DTS has been compiled. And since most of these resources are linked via phandle you actually need to resolve these first before you can fill in the new properties of this dynamically created node.
So firmware needs to know exactly what device tree node to look for, find a corresponding phandle and then put the phandle value in the simplefb device tree node. And it needs to know intimate details about the clock provider binding because it needs to add an appropriate specifier, too.
Indeed. Complicated.
Quoted 2 lines
And then all of a sudden something that was supposed to be simple and generic needs to know the specifics of some hardware device.
And suddenly we wish we could write a real driver and put the stuff in the DTS, not DTB...
Quoted 25 lines
Quoted 20 lines
Quoted 4 lines
The only reasonable thing for simplefb to do is not deal with any kind of resource at all (except perhaps area that contains the framebuffer memory).
Quoted 15 lines
So how about instead of requiring resources to be explicitly claimed we introduce something like the below patch? The intention being to give "firmware device" drivers a way of signalling to the clock framework that they need rely on clocks set up by firmware and when they no longer need them. This implements essentially what Mark (CC'ing again on this subthread) suggested earlier in this thread. Basically, it will allow drivers to determine the time when unused clocks are really unused. It will of course only work when used correctly by drivers. For the case of simplefb I'd expect its .probe() implementation to call the new
clk_ignore_unused()function and once it has handed over control of the display hardware to the real driver it can callclk_unignore_unused()to signal that all unused clocks that it cares about have now been claimed. This is "reference counted" and can therefore be used by more than a single driver if necessary. Similar functionality could be added for other resource subsystems as needed.Quoted 4 lines
This still won't work for modules, right? Or am I missing something? With modules you will never know in advance what will be used and what won't be used, so you need to keep all clocks, regulators, PM domains, ... up and running?
Quoted 9 lines
No. The way this works is that your firmware shim driver, simplefb in this case, will call
clk_ignore_unused()to tell the clock framework that it uses clocks set up by the firmware, and therefore requests that no clocks should be considered unused (for now). Later on when the proper driver has successfully taken over from the shim driver, the shim driver can unregister itself and callclk_unignore_unused(), which will drop its "reference" on the unused clocks. When all references have been dropped the clock framework will then disable all remaining unused clocks.
So the shim must be built-in, not modular.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 18 lines · Geert Uytterhoeven
Hi Thierry,
Quoted 14 lines · Thierry Reding
Quoted 13 lines · Geert Uytterhoeven
(CC linux-pm, as PM is the real reason behind disabling unused clocks) (CC gregkh and lkml, for driver core)
Quoted 7 lines · Thierry Reding
If we start extending the binding with board-level details we end up duplicating the device tree node for the proper video device. Also note that it won't stop at clocks. Other setups will require regulators to be listed in this device tree node as well so that they don't get disabled at
late_initcall. And the regulator bindings don't provide a method to list an arbitrary number of clocks in a single property in the way that the clocks property works.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Then (optional) regulator support needs to be added.
Can you elaborate?
I'm not so familiar with regulators, but I guess it's similar to clocks?
The bindings are different. Essentially what you use is a *-supply property per regulator. There is no way to specify more than one regulator in a single property.
So if you want to keep that generic you have to do crazy things like:
simplefb {
enable-0-supply = <®1>;
enable-1-supply = <®2>;
...
};I suppose a more generic supplies property could be created to support this use-case, but I think this kind of proves my point. The only way that the original proposal is going to work for other resources is if they follow the same kind of binding. I don't think it makes sense to introduce such a prerequisite merely because it would make life easy for some exotic driver with a very specific application.
Quoted 5 lines
Quoted 2 lines
And then all of a sudden something that was supposed to be simple and generic needs to know the specifics of some hardware device.
And suddenly we wish we could write a real driver and put the stuff in the DTS, not DTB...
Oh, there's no doubt a real driver would be preferrable. Note that simplefb is only meant to be a shim to pass a framebuffer from firmware to kernel. In some cases it can be used with longer lifetime, like for example if you really want to have graphical output but the real driver isn't there yet.
Being a shim driver is precisely the reason why I think the binding shouldn't be extended to cover all possible types of resources. That should all go into the binding for the real device.
Quoted 35 lines
Quoted 25 lines
Quoted 20 lines
Quoted 4 lines
The only reasonable thing for simplefb to do is not deal with any kind of resource at all (except perhaps area that contains the framebuffer memory).
Quoted 15 lines
So how about instead of requiring resources to be explicitly claimed we introduce something like the below patch? The intention being to give "firmware device" drivers a way of signalling to the clock framework that they need rely on clocks set up by firmware and when they no longer need them. This implements essentially what Mark (CC'ing again on this subthread) suggested earlier in this thread. Basically, it will allow drivers to determine the time when unused clocks are really unused. It will of course only work when used correctly by drivers. For the case of simplefb I'd expect its .probe() implementation to call the new
clk_ignore_unused()function and once it has handed over control of the display hardware to the real driver it can callclk_unignore_unused()to signal that all unused clocks that it cares about have now been claimed. This is "reference counted" and can therefore be used by more than a single driver if necessary. Similar functionality could be added for other resource subsystems as needed.Quoted 4 lines
This still won't work for modules, right? Or am I missing something? With modules you will never know in advance what will be used and what won't be used, so you need to keep all clocks, regulators, PM domains, ... up and running?
Quoted 9 lines
No. The way this works is that your firmware shim driver, simplefb in this case, will call
clk_ignore_unused()to tell the clock framework that it uses clocks set up by the firmware, and therefore requests that no clocks should be considered unused (for now). Later on when the proper driver has successfully taken over from the shim driver, the shim driver can unregister itself and callclk_unignore_unused(), which will drop its "reference" on the unused clocks. When all references have been dropped the clock framework will then disable all remaining unused clocks.
Quoted 1 line
So the shim must be built-in, not modular.
Correct. Making it a module isn't very useful in my opinion. You'd loose all the advantages.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/08c17aac/attachment.sig>
Re: [linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingQuoted 105 lines · Thierry Reding
Quoted 104 lines · Geert Uytterhoeven
Hi Thierry,
(CC linux-pm, as PM is the real reason behind disabling unused clocks) (CC gregkh and lkml, for driver core)
Quoted 80 lines · Thierry Reding
Quoted 79 lines · Mike Turquette
Quoting Maxime Ripard (2014-09-02 02:25:08)
Quoted 44 lines · Thierry Reding
Quoted 10 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 7 lines
I would think the memory should still be reserved anyway to make sure nothing else is writing over it. And it's in the device tree anyway because the driver needs to know where to put framebuffer content. So the point I was trying to make is that we can't treat the memory in the same way as clocks because it needs to be explicitly managed. Whereas clocks don't. The driver is simply too generic to know what to do with the clocks.
Quoted 7 lines
Quoted 3 lines
You agreed on the fact that the only thing we need to do with the clocks is claim them. Really, I don't find what's complicated there (or not generic).
That's not what I agreed on. What I said is that the only thing we need to do with the clocks is nothing. They are already in the state that they need to be.
Claim was probably a poor choice of words, but still. We have to keep the clock running, and both the solution you've been giving and this patch do so in a generic way.
Quoted 21 lines
Quoted 5 lines
Quoted 1 line
It doesn't know what frequency they should be running at
We don't care about that. Just like we don't care about which frequency is the memory bus running at. It will just run at whatever frequency is appropriate.
Exactly. And you shouldn't have to care about them at all. Firmware has already configured the clocks to run at the correct frequencies, and it has made sure that they are enabled.
Quoted 5 lines
Quoted 1 line
or what they're used for
And we don't care about that either. You're not interested in what output the framebuffer is setup to use, which is pretty much the same here, this is the same thing here.
That's precisely what I've been saying. The only thing that simplefb cares about is the memory it should be using and the format of the pixels (and how many of them) it writes into that memory. Everything else is assumed to have been set up.
Quoted 6 lines
Quoted 1 line
Including clocks.
We're really discussing in circles here.
Mike?
-EHIGHLATENCYRESPONSEI forgot about this thread. Sorry.
In an attempt to provide the least helpful answer possible, I will stay clear of all of the stuff relating to "how simple should simplefb be" and the related reserved memory discussion.
A few times in this thread it is stated that we can't prevent unused clocks from being disabled. That is only partially true.
The clock framework DOES provide a flag to prevent UNUSED clocks from being disabled at late_initcall-time by a clock "garbage collector" mechanism. Maxime and others familiar with the clock framework are aware of this.
What the framework doesn't do is to allow for a magic flag in DT, in
platform_dataor elsewhere that says, "don't let me get turned off until the right driver claims me". That would be an external or alternative method for preventing a clock from being disabled. We have a method for preventing clocks from being disabled. It is as follows:struct clk
*my_clk=clk_get(...);clk_prepare_enable(my_clk);That is how it should be done. Period.
Quoted 8 lines
Quoted 5 lines
With that said I think that Luc's approach is very sensible. I'm not sure what purpose in the universe DT is supposed to serve if not for _this_exact_case_. We have a nice abstracted driver, usable by many people. The hardware details of how it is hooked up at the board level can all be hidden behind stable DT bindings that everyone already uses.
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many
It doesn't deal with "hardware details for hardware components for which no driver is available (yet)". That's why the hardware is still in a usable state, after the firmware has set it up.
Clocks, regulators, PM domains typically have system-wide implications, and thus need system-wide drivers (in the absence of such drivers, things would work as-is).
Quoted 6 lines
Quoted 2 lines
Note that the driver still requests resources (ioremap the frame buffer), so it needs to know about that tiny piece of hardware detail.
That's not a hardware detail. Or at least it isn't hardware specific. It is needed and the same irrespective of display hardware. Clocks, power domains, regulators and all those are not always the same.
The framebuffer address, format, etc. is as hardware specific as the clocks needed to run the crtc, regulators to power the backlight, etc.
You see this from the point of view of a platform that has not clock driver. Then the platform has no clock information whatsoever, for any driver. That's platform specific too.
Why do we have to go back to this *again*?
Quoted 21 lines
Quoted 10 lines
Quoted 5 lines
There may be also resets involved. Fortunately the reset framework is minimalistic enough not to care about asserting all unused resets at
late_initcall. And other things like power domains may also need to be kept on.Fortunately, unlike clocks, PM domains are first class citizens in the device framework, as they're handled by the driver core.
So just adding a power-domains property to DTS will work, without any driver change.Well, the device driver would also need to call into the PM runtime framework to enable all the first class citizen magic. But even if it were to do that, you'd still need to add all the domains to the DTB.
Note that I'm saying DT*B* here, because the firmware needs to fill in those properties after the DTS has been compiled. And since most of these resources are linked via phandle you actually need to resolve these first before you can fill in the new properties of this dynamically created node.
Quoted 8 lines
So firmware needs to know exactly what device tree node to look for, find a corresponding phandle and then put the phandle value in the simplefb device tree node. And it needs to know intimate details about the clock provider binding because it needs to add an appropriate specifier, too.
And then all of a sudden something that was supposed to be simple and generic needs to know the specifics of some hardware device.
Note however that all the specific is in the firmware driver. The linux simplefb driver only needs to read DT entries which is generic hardware-neutral thing. It needs to handle clocks on platform that do have a clock driver, yes. There is no way around that. See below.
Quoted 16 lines
Quoted 10 lines
Quoted 6 lines
Passing in clock information via the device tree already requires a non- trivial amount of code in the firmware. A similar amount of code would be necessary for each type of resource that needs to be kept enabled. In addition to the above some devices may also require resources that have no generic bindings. That just doesn't scale.
[*] The firmware does need to make sure the clocks, regulators, PM domains, ... are up and running for the initial video mode, too. So it already needs to have this knowledge (unless enabled by SoC reset-state).
Certainly. But not all firmware will use a DTB (or in fact the same DTB as the kernel) to derive this information from, so it still needs to inspect the DTB that will be passed to the kernel and painfully extract information from various nodes and put it into a new node.
Quoted 5 lines
But that's not even the issue. You say yourself that the firmware set everything up itself already. My point is: why should the kernel have to do everything again, only to come to the conclusion that it doesn't have to touch hardware at all because it's already in the state that it should be?
It will do nothing. It will just read from DTB what firmware has set up and inform all the relevant generic frameworks that these resources are in use. The device-specific driver (if any) will then keep the resource in question enabled. So all that is this patch doing is to correct the kernel's resource bookkeeping.
Quoted 4 lines
In fact, Linux will at some point set things up from scratch anyway with a fully-fledged driver. But doing it in simplefb too would be doubly wasteful.
It may or may not. And by having the bookkeeping straight we give that choice to the user.
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
The only reasonable thing for simplefb to do is not deal with any kind of resource at all (except perhaps area that contains the framebuffer memory).
So how about instead of requiring resources to be explicitly claimed we introduce something like the below patch? The intention being to give "firmware device" drivers a way of signalling to the clock framework that they need rely on clocks set up by firmware and when they no longer need them. This implements essentially what Mark (CC'ing again on this subthread) suggested earlier in this thread. Basically, it will allow drivers to determine the time when unused clocks are really unused. It will of course only work when used correctly by drivers. For the case of simplefb I'd expect its .probe() implementation to call the new
clk_ignore_unused()function and once it has handed over control of the display hardware to the real driver it can callclk_unignore_unused()to signal that all unused clocks that it cares about have now been claimed. This is "reference counted" and can therefore be used by more than a single driver if necessary. Similar functionality could be added for other resource subsystems as needed.
Quoted 4 lines
Quoted 4 lines
This still won't work for modules, right? Or am I missing something? With modules you will never know in advance what will be used and what won't be used, so you need to keep all clocks, regulators, PM domains, ... up and running?
Simplefb cannot work as module on any platform. Once kernel reclaims the resources used by simplefb it cannot be started because kernel has no way to reenable the resources (memory, clocks, etc). Reclaiming the simplefb memory is currently not supported but once it is added loading simplefb as module is no-go on any platform.
Quoted 11 lines
No. The way this works is that your firmware shim driver, simplefb in this case, will call
clk_ignore_unused()to tell the clock framework that it uses clocks set up by the firmware, and therefore requests that no clocks should be considered unused (for now). Later on when the proper driver has successfully taken over from the shim driver, the shim driver can unregister itself and callclk_unignore_unused(), which will drop its "reference" on the unused clocks. When all references have been dropped the clock framework will then disable all remaining unused clocks.
Quoted 4 lines
In practice this will mean that all unused clocks will remain in their current state until the shim driver relinquishes control to the proper OS driver. And if that never happens then we're at least still left with a working framebuffer.
This does not work. Firstly if you do not have a full driver (because there is none or because kernel did not find the module, ...) then you could run with the shim driver and have all clocks managed properly. This is not possible with clk_ignore_unused.
Secondly clk_ignore_unused does not really mark clock as used. It only skips disabling them at certain point at kernel startup so that kernel survives that point and clock problems can be debugged. It is not meant as an option to be used for running the kernel indefinitely. It is indeed flawed: if at later point enabling or disabling a clock results in a parent clock becoming unused it is still disabled. This can affect many clocks if enabling a clock results in clock reparenting.
Sure, clk_ignore_unused could be fixed to actually mark all clocks enabled at boot time as used so that they are never disabled but that's orthogonal to fixing simplefb so that when it is in use the clock framework can work normally and can be tested, debugged, and used for saving power by disabling unused clocks.
So please stop repeating that managing system resources is system-specific and not fit for simplefb driver. It's been said enough times, and enough times pointed out that simplefb driver must as any other driver manage its resources (or more specifically tell the kernel to manage them) to work properly. And that reading a list of resources from DT and telling kernel to manage them is not system specific, only specific to resource frameworks enabled on the platform in question. That is you may need support for as many resource frameworks as the platform has if they are ever used for framebuffer.
Thanks
Michal
Re: [linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 109 lines · Michal Suchanek
Quoted 108 lines · Thierry Reding
Quoted 106 lines · Geert Uytterhoeven
Hi Thierry,
(CC linux-pm, as PM is the real reason behind disabling unused clocks) (CC gregkh and lkml, for driver core)
Quoted 80 lines · Thierry Reding
Quoted 79 lines · Mike Turquette
Quoting Maxime Ripard (2014-09-02 02:25:08)
Quoted 44 lines · Thierry Reding
Quoted 10 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 7 lines
I would think the memory should still be reserved anyway to make sure nothing else is writing over it. And it's in the device tree anyway because the driver needs to know where to put framebuffer content. So the point I was trying to make is that we can't treat the memory in the same way as clocks because it needs to be explicitly managed. Whereas clocks don't. The driver is simply too generic to know what to do with the clocks.
Quoted 7 lines
Quoted 3 lines
You agreed on the fact that the only thing we need to do with the clocks is claim them. Really, I don't find what's complicated there (or not generic).
That's not what I agreed on. What I said is that the only thing we need to do with the clocks is nothing. They are already in the state that they need to be.
Claim was probably a poor choice of words, but still. We have to keep the clock running, and both the solution you've been giving and this patch do so in a generic way.
Quoted 21 lines
Quoted 5 lines
Quoted 1 line
It doesn't know what frequency they should be running at
We don't care about that. Just like we don't care about which frequency is the memory bus running at. It will just run at whatever frequency is appropriate.
Exactly. And you shouldn't have to care about them at all. Firmware has already configured the clocks to run at the correct frequencies, and it has made sure that they are enabled.
Quoted 5 lines
Quoted 1 line
or what they're used for
And we don't care about that either. You're not interested in what output the framebuffer is setup to use, which is pretty much the same here, this is the same thing here.
That's precisely what I've been saying. The only thing that simplefb cares about is the memory it should be using and the format of the pixels (and how many of them) it writes into that memory. Everything else is assumed to have been set up.
Quoted 6 lines
Quoted 1 line
Including clocks.
We're really discussing in circles here.
Mike?
-EHIGHLATENCYRESPONSEI forgot about this thread. Sorry.
In an attempt to provide the least helpful answer possible, I will stay clear of all of the stuff relating to "how simple should simplefb be" and the related reserved memory discussion.
A few times in this thread it is stated that we can't prevent unused clocks from being disabled. That is only partially true.
The clock framework DOES provide a flag to prevent UNUSED clocks from being disabled at late_initcall-time by a clock "garbage collector" mechanism. Maxime and others familiar with the clock framework are aware of this.
What the framework doesn't do is to allow for a magic flag in DT, in
platform_dataor elsewhere that says, "don't let me get turned off until the right driver claims me". That would be an external or alternative method for preventing a clock from being disabled. We have a method for preventing clocks from being disabled. It is as follows:struct clk
*my_clk=clk_get(...);clk_prepare_enable(my_clk);That is how it should be done. Period.
Quoted 8 lines
Quoted 5 lines
With that said I think that Luc's approach is very sensible. I'm not sure what purpose in the universe DT is supposed to serve if not for _this_exact_case_. We have a nice abstracted driver, usable by many people. The hardware details of how it is hooked up at the board level can all be hidden behind stable DT bindings that everyone already uses.
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many
It doesn't deal with "hardware details for hardware components for which no driver is available (yet)". That's why the hardware is still in a usable state, after the firmware has set it up.
Clocks, regulators, PM domains typically have system-wide implications, and thus need system-wide drivers (in the absence of such drivers, things would work as-is).
Note that the driver still requests resources (ioremap the frame buffer), so it needs to know about that tiny piece of hardware detail.
Quoted 6 lines
Quoted 3 lines
That's not a hardware detail. Or at least it isn't hardware specific. It is needed and the same irrespective of display hardware. Clocks, power domains, regulators and all those are not always the same.
The framebuffer address, format, etc. is as hardware specific as the clocks needed to run the crtc, regulators to power the backlight, etc.
Framebuffer address and format are not hardware specific. Every display driver requires them.
Quoted 2 lines
You see this from the point of view of a platform that has not clock driver.
Wrong. What platform's point of view do you think I look at this from?
Quoted 4 lines
Then the platform has no clock information whatsoever, for any driver. That's platform specific too.
Why do we have to go back to this *again*?
What exactly are we going back to again?
Quoted 26 lines
Quoted 26 lines
Quoted 9 lines
Quoted 4 lines
There may be also resets involved. Fortunately the reset framework is minimalistic enough not to care about asserting all unused resets at
late_initcall. And other things like power domains may also need to be kept on.Fortunately, unlike clocks, PM domains are first class citizens in the device framework, as they're handled by the driver core.
So just adding a power-domains property to DTS will work, without any driver change.Well, the device driver would also need to call into the PM runtime framework to enable all the first class citizen magic. But even if it were to do that, you'd still need to add all the domains to the DTB.
Note that I'm saying DT*B* here, because the firmware needs to fill in those properties after the DTS has been compiled. And since most of these resources are linked via phandle you actually need to resolve these first before you can fill in the new properties of this dynamically created node.
So firmware needs to know exactly what device tree node to look for, find a corresponding phandle and then put the phandle value in the simplefb device tree node. And it needs to know intimate details about the clock provider binding because it needs to add an appropriate specifier, too.
Quoted 6 lines
Quoted 2 lines
And then all of a sudden something that was supposed to be simple and generic needs to know the specifics of some hardware device.
Note however that all the specific is in the firmware driver. The linux simplefb driver only needs to read DT entries which is generic hardware-neutral thing.
No. The DT entries are very hardware-specific. That's precisely the reason why I think it's wrong to put this into the simplefb node, because simplefb is an abstraction of the real hardware underneath.
Quoted 21 lines
Quoted 15 lines
Quoted 9 lines
Quoted 5 lines
Passing in clock information via the device tree already requires a non- trivial amount of code in the firmware. A similar amount of code would be necessary for each type of resource that needs to be kept enabled. In addition to the above some devices may also require resources that have no generic bindings. That just doesn't scale.
[*] The firmware does need to make sure the clocks, regulators, PM domains, ... are up and running for the initial video mode, too. So it already needs to have this knowledge (unless enabled by SoC reset-state).
Certainly. But not all firmware will use a DTB (or in fact the same DTB as the kernel) to derive this information from, so it still needs to inspect the DTB that will be passed to the kernel and painfully extract information from various nodes and put it into a new node.
Quoted 5 lines
But that's not even the issue. You say yourself that the firmware set everything up itself already. My point is: why should the kernel have to do everything again, only to come to the conclusion that it doesn't have to touch hardware at all because it's already in the state that it should be?
Quoted 5 lines
It will do nothing. It will just read from DTB what firmware has set up and inform all the relevant generic frameworks that these resources are in use. The device-specific driver (if any) will then keep the resource in question enabled. So all that is this patch doing is to correct the kernel's resource bookkeeping.
It's the device-specific driver that should be doing the book-keeping. simplefb is only a stop-gap until a proper driver has been loaded. It should never be considered a fully-functional driver, because it does not know anything about the display hardware.
Quoted 6 lines
Quoted 3 lines
In fact, Linux will at some point set things up from scratch anyway with a fully-fledged driver. But doing it in simplefb too would be doubly wasteful.
It may or may not. And by having the bookkeeping straight we give that choice to the user.
What I'm proposing isn't really all that different. All it does is prevent resources from being considered unused by default if a driver that we know relies on an unspecified set of resources is active.
Quoted 15 lines
Quoted 10 lines
No. The way this works is that your firmware shim driver, simplefb in this case, will call
clk_ignore_unused()to tell the clock framework that it uses clocks set up by the firmware, and therefore requests that no clocks should be considered unused (for now). Later on when the proper driver has successfully taken over from the shim driver, the shim driver can unregister itself and callclk_unignore_unused(), which will drop its "reference" on the unused clocks. When all references have been dropped the clock framework will then disable all remaining unused clocks.Quoted 4 lines
In practice this will mean that all unused clocks will remain in their current state until the shim driver relinquishes control to the proper OS driver. And if that never happens then we're at least still left with a working framebuffer.
Quoted 4 lines
This does not work. Firstly if you do not have a full driver (because there is none or because kernel did not find the module, ...) then you could run with the shim driver and have all clocks managed properly. This is not possible with
clk_ignore_unused.
Huh? Why not?
Quoted 1 line
Secondly
clk_ignore_unuseddoes not really mark clock as used.
Right. If that were the case it'd be called clk_use_unused() or similar.
Quoted 9 lines
It only
skips disabling them at certain point at kernel startup so that kernel survives that point and clock problems can be debugged. It is not meant as an option to be used for running the kernel indefinitely. It is indeed flawed: if at later point enabling or disabling a clock results in a parent clock becoming unused it is still disabled. This can affect many clocks if enabling a clock results in clock reparenting.
Quoted 5 lines
Sure,
clk_ignore_unusedcould be fixed to actually mark all clocks enabled at boot time as used so that they are never disabled but that's orthogonal to fixing simplefb so that when it is in use the clock framework can work normally and can be tested, debugged, and used for saving power by disabling unused clocks.
Look, nobody's claiming that using the clk_ignore_unused command-line argument is a good long-term solution. And it doesn't have to. Once you have a proper display driver for your platform the problem goes away entirely.
That is unless you also want to use simplefb for early boot and seamless transition between firmware and kernel, in which case we'll return to this discussion.
Quoted 5 lines
So please stop repeating that managing system resources is system-specific and not fit for simplefb driver. It's been said enough times, and enough times pointed out that simplefb driver must as any other driver manage its resources (or more specifically tell the kernel to manage them) to work properly.
simplefb isn't anything like any other driver. If you want a proper driver, go write a DRM/KMS driver and we can all stop having this discussion. That's the right thing to do.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/b9e52029/attachment-0001.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingQuoted 86 lines · Thierry Reding
Quoted 77 lines · Mike Turquette
Quoting Maxime Ripard (2014-09-02 02:25:08)
Quoted 44 lines · Thierry Reding
Quoted 10 lines · Maxime Ripard
Quoted 9 lines · Thierry Reding
Quoted 7 lines
I would think the memory should still be reserved anyway to make sure nothing else is writing over it. And it's in the device tree anyway because the driver needs to know where to put framebuffer content. So the point I was trying to make is that we can't treat the memory in the same way as clocks because it needs to be explicitly managed. Whereas clocks don't. The driver is simply too generic to know what to do with the clocks.
Quoted 7 lines
Quoted 3 lines
You agreed on the fact that the only thing we need to do with the clocks is claim them. Really, I don't find what's complicated there (or not generic).
That's not what I agreed on. What I said is that the only thing we need to do with the clocks is nothing. They are already in the state that they need to be.
Claim was probably a poor choice of words, but still. We have to keep the clock running, and both the solution you've been giving and this patch do so in a generic way.
Quoted 21 lines
Quoted 5 lines
Quoted 1 line
It doesn't know what frequency they should be running at
We don't care about that. Just like we don't care about which frequency is the memory bus running at. It will just run at whatever frequency is appropriate.
Exactly. And you shouldn't have to care about them at all. Firmware has already configured the clocks to run at the correct frequencies, and it has made sure that they are enabled.
Quoted 5 lines
Quoted 1 line
or what they're used for
And we don't care about that either. You're not interested in what output the framebuffer is setup to use, which is pretty much the same here, this is the same thing here.
That's precisely what I've been saying. The only thing that simplefb cares about is the memory it should be using and the format of the pixels (and how many of them) it writes into that memory. Everything else is assumed to have been set up.
Quoted 6 lines
Quoted 1 line
Including clocks.
We're really discussing in circles here.
Mike?
-EHIGHLATENCYRESPONSEI forgot about this thread. Sorry.
In an attempt to provide the least helpful answer possible, I will stay clear of all of the stuff relating to "how simple should simplefb be" and the related reserved memory discussion.
A few times in this thread it is stated that we can't prevent unused clocks from being disabled. That is only partially true.
The clock framework DOES provide a flag to prevent UNUSED clocks from being disabled at late_initcall-time by a clock "garbage collector" mechanism. Maxime and others familiar with the clock framework are aware of this.
What the framework doesn't do is to allow for a magic flag in DT, in
platform_dataor elsewhere that says, "don't let me get turned off until the right driver claims me". That would be an external or alternative method for preventing a clock from being disabled. We have a method for preventing clocks from being disabled. It is as follows:struct clk
*my_clk=clk_get(...);clk_prepare_enable(my_clk);Quoted 7 lines
That is how it should be done. Period.
With that said I think that Luc's approach is very sensible. I'm not sure what purpose in the universe DT is supposed to serve if not for _this_exact_case_. We have a nice abstracted driver, usable by many people. The hardware details of how it is hooked up at the board level can all be hidden behind stable DT bindings that everyone already uses.
Quoted 6 lines
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
Which makes the whole even simpler, since the firmware already knows all about which clocks it had to enable.
Quoted 19 lines
If we start extending the binding with board-level details we end up duplicating the device tree node for the proper video device. Also note that it won't stop at clocks. Other setups will require regulators to be listed in this device tree node as well so that they don't get disabled at
late_initcall. And the regulator bindings don't provide a method to list an arbitrary number of clocks in a single property in the way that the clocks property works.There may be also resets involved. Fortunately the reset framework is minimalistic enough not to care about asserting all unused resets at
late_initcall. And other things like power domains may also need to be kept on.Passing in clock information via the device tree already requires a non- trivial amount of code in the firmware. A similar amount of code would be necessary for each type of resource that needs to be kept enabled. In addition to the above some devices may also require resources that have no generic bindings. That just doesn't scale.
Quoted 3 lines
The only reasonable thing for simplefb to do is not deal with any kind of resource at all (except perhaps area that contains the framebuffer memory).
You should really read that thread:
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-September/284726.html
It's quite interesting, because you'll see that:
A) Your approach, even on the platform you're working on, doesn't work. Or at least, isn't reliable.
B) Other maintainers, precisely like Mark, came to the same conclusion than Mike.
Quoted 7 lines
So how about instead of requiring resources to be explicitly claimed we introduce something like the below patch? The intention being to give "firmware device" drivers a way of signalling to the clock framework that they need rely on clocks set up by firmware and when they no longer need them. This implements essentially what Mark (CC'ing again on this subthread) suggested earlier in this thread. Basically, it will allow drivers to determine the time when unused clocks are really unused. It
Quoted 8 lines
will of course only work when used correctly by drivers. For the case of simplefb I'd expect its .probe() implementation to call the new
clk_ignore_unused()function and once it has handed over control of the display hardware to the real driver it can callclk_unignore_unused()to signal that all unused clocks that it cares about have now been claimed. This is "reference counted" and can therefore be used by more than a single driver if necessary. Similar functionality could be added for other resource subsystems as needed.
So, just to be clear, instead of doing a generic clk_get and clk_prepare_enable, you're willing to do a just as much generic clk_ignore_unused call?
How is that less generic? You know that you are going to call that for regulator, reset, power domains, just as you would have needed to with the proper API, unless that with this kind of solution, you would have to modify *every* framework that might interact with any resource involved in getting simplefb running?
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later clk_disable call from another driver.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/86543453/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 1 line · Maxime Ripard
On Mon, Sep 29, 2014 at 10:06:39AM +0200, Thierry Reding wrote:
[...]
Quoted 9 lines
Quoted 6 lines
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
Which makes the whole even simpler, since the firmware already knows all about which clocks it had to enable.
It makes things very complicated in the firmware because it now needs to be able to generate DTB content that we would otherwise be able to do much easier with a text editor.
Quoted 23 lines
Quoted 19 lines
If we start extending the binding with board-level details we end up duplicating the device tree node for the proper video device. Also note that it won't stop at clocks. Other setups will require regulators to be listed in this device tree node as well so that they don't get disabled at
late_initcall. And the regulator bindings don't provide a method to list an arbitrary number of clocks in a single property in the way that the clocks property works.There may be also resets involved. Fortunately the reset framework is minimalistic enough not to care about asserting all unused resets at
late_initcall. And other things like power domains may also need to be kept on.Passing in clock information via the device tree already requires a non- trivial amount of code in the firmware. A similar amount of code would be necessary for each type of resource that needs to be kept enabled. In addition to the above some devices may also require resources that have no generic bindings. That just doesn't scale.
Quoted 3 lines
The only reasonable thing for simplefb to do is not deal with any kind of resource at all (except perhaps area that contains the framebuffer memory).
Quoted 6 lines
You should really read that thread:
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-September/284726.htmlIt's quite interesting, because you'll see that:
A) Your approach, even on the platform you're working on, doesn't work. Or at least, isn't reliable.
What platform exactly do you think I'm working on? Why do you think what I proposed isn't going to work or be reliable? I don't see any arguments in the thread that would imply that.
Quoted 2 lines
B) Other maintainers, precisely like Mark, came to the same conclusion than Mike.
Well, and others didn't.
Also I think if you read that thread and look at my proposal it matches exactly what was discussed as one of the solutions at one point in the thread.
Quoted 16 lines
Quoted 7 lines
So how about instead of requiring resources to be explicitly claimed we introduce something like the below patch? The intention being to give "firmware device" drivers a way of signalling to the clock framework that they need rely on clocks set up by firmware and when they no longer need them. This implements essentially what Mark (CC'ing again on this subthread) suggested earlier in this thread. Basically, it will allow drivers to determine the time when unused clocks are really unused. It
Quoted 8 lines
will of course only work when used correctly by drivers. For the case of simplefb I'd expect its .probe() implementation to call the new
clk_ignore_unused()function and once it has handed over control of the display hardware to the real driver it can callclk_unignore_unused()to signal that all unused clocks that it cares about have now been claimed. This is "reference counted" and can therefore be used by more than a single driver if necessary. Similar functionality could be added for other resource subsystems as needed.
Quoted 3 lines
So, just to be clear, instead of doing a generic
clk_getandclk_prepare_enable, you're willing to do a just as much genericclk_ignore_unusedcall?
Yes.
Quoted 1 line
How is that less generic?
It's more generic. That's the whole point.
The difference is that with the solution I proposed we don't have to keep track of all the resources. We know that firmware has set them up and we know that a real driver will properly take them over at some point, so duplicating what the real driver does within the simplefb driver is just that, duplication. We don't allow duplication anywhere else in the kernel, why should simplefb be an exception?
Quoted 5 lines
You know that you are going to call that for regulator, reset, power domains, just as you would have needed to with the proper API, unless that with this kind of solution, you would have to modify *every* framework that might interact with any resource involved in getting simplefb running?
We have to add handling for every kind of resource either way. Also if this evolves into a common pattern we can easily wrap it up in a single function call.
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.
If we need to prevent that, then that's something that could be fixed, too. But both this and the other thread at least agree on the fact that simplefb is a shim driver that's going to be replaced by something real at some point, so hopefully concurrent users aren't the problem because that would cause the real driver to break too.
Also note that if some other driver could call clk_disable() it could just as easily call clk_set_rate() and break simplefb.
Furthermore isn't it a bug for a driver to call clk_disable() before a preceding clk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/3e3ca957/attachment-0001.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi Thierry,
Quoted 17 lines · Thierry Reding
Quoted 1 line
How is that less generic?
It's more generic. That's the whole point.
The difference is that with the solution I proposed we don't have to keep track of all the resources. We know that firmware has set them up and we know that a real driver will properly take them over at some point, so duplicating what the real driver does within the simplefb driver is just that, duplication. We don't allow duplication anywhere else in the kernel, why should simplefb be an exception?
Quoted 5 lines
You know that you are going to call that for regulator, reset, power domains, just as you would have needed to with the proper API, unless that with this kind of solution, you would have to modify *every* framework that might interact with any resource involved in getting simplefb running?
Quoted 3 lines
We have to add handling for every kind of resource either way. Also if this evolves into a common pattern we can easily wrap it up in a single function call.
disable_all_power_management(), as this is not limited to clocks.
Quoted 9 lines
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.Furthermore isn't it a bug for a driver to call
clk_disable()before a precedingclk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.
Calling clk_disable() preceding clk_enable() is a bug.
Calling clk_disable() after clk_enable() will disable the clock (and its parents)
if the clock subsystem thinks there are no other users, which is what will happen here.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 21 lines · Geert Uytterhoeven
Hi Thierry,
Quoted 17 lines · Thierry Reding
Quoted 1 line
How is that less generic?
It's more generic. That's the whole point.
The difference is that with the solution I proposed we don't have to keep track of all the resources. We know that firmware has set them up and we know that a real driver will properly take them over at some point, so duplicating what the real driver does within the simplefb driver is just that, duplication. We don't allow duplication anywhere else in the kernel, why should simplefb be an exception?
Quoted 5 lines
You know that you are going to call that for regulator, reset, power domains, just as you would have needed to with the proper API, unless that with this kind of solution, you would have to modify *every* framework that might interact with any resource involved in getting simplefb running?
Quoted 5 lines
Quoted 3 lines
We have to add handling for every kind of resource either way. Also if this evolves into a common pattern we can easily wrap it up in a single function call.
disable_all_power_management(), as this is not limited to clocks.
Right. But it isn't all power management either. It just shouldn't turn everything unused off. Clocks, regulators, power domains and so on which are used can very well be power managed.
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.Furthermore isn't it a bug for a driver to call
clk_disable()before a precedingclk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.
Quoted 6 lines
Calling
clk_disable()precedingclk_enable()is a bug.Calling
clk_disable()afterclk_enable()will disable the clock (and its parents)
if the clock subsystem thinks there are no other users, which is what will happen here.
Right. I'm not sure this is really applicable to this situation, though. Either way, if there are other users of a clock then they will just as likely want to modify the rate at which point simplefb will break just as badly.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/6eb50a02/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi Thierry,
Quoted 10 lines · Thierry Reding
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
You know that you are going to call that for regulator, reset, power domains, just as you would have needed to with the proper API, unless that with this kind of solution, you would have to modify *every* framework that might interact with any resource involved in getting simplefb running?
We have to add handling for every kind of resource either way. Also if this evolves into a common pattern we can easily wrap it up in a single function call.
Quoted 5 lines
Quoted 1 line
disable_all_power_management(), as this is not limited to clocks.Right. But it isn't all power management either. It just shouldn't turn everything unused off. Clocks, regulators, power domains and so on which are used can very well be power managed.
No they can't, as the clock/regulator/PM domain core cannot know if any of the used ones are also used by a shim driver like simplefb. Clocks and regulators may be shared. PM domains can contain multiple hardware blocks. Without more knowledge, the only safe thing is not disabling anything.
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.Furthermore isn't it a bug for a driver to call
clk_disable()before a precedingclk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.
Quoted 8 lines
Quoted 6 lines
Calling
clk_disable()precedingclk_enable()is a bug.Calling
clk_disable()afterclk_enable()will disable the clock (and its parents)
if the clock subsystem thinks there are no other users, which is what will happen here.Right. I'm not sure this is really applicable to this situation, though.
Yes it is: if all users of a clock/regulator/PM domain are gone, it will be disabled. Bad luck for simplefb still needing them.
Quoted 3 lines
Either way, if there are other users of a clock then they will just as likely want to modify the rate at which point simplefb will break just as badly.
BTW, this can also happen for clocks that are properly used. I guess the clock core code does some arbitration to handle such cases.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 20 lines · Geert Uytterhoeven
Hi Thierry,
Quoted 10 lines · Thierry Reding
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
You know that you are going to call that for regulator, reset, power domains, just as you would have needed to with the proper API, unless that with this kind of solution, you would have to modify *every* framework that might interact with any resource involved in getting simplefb running?
We have to add handling for every kind of resource either way. Also if this evolves into a common pattern we can easily wrap it up in a single function call.
Quoted 5 lines
Quoted 1 line
disable_all_power_management(), as this is not limited to clocks.Right. But it isn't all power management either. It just shouldn't turn everything unused off. Clocks, regulators, power domains and so on which are used can very well be power managed.
Quoted 5 lines
No they can't, as the clock/regulator/PM domain core cannot know if any of the used ones are also used by a shim driver like simplefb. Clocks and regulators may be shared. PM domains can contain multiple hardware blocks. Without more knowledge, the only safe thing is not disabling anything.
Indeed. That's a shame. In the most common case that probably won't matter all that much, given that the real driver can be expected to load within a reasonable amount of time.
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
Quoted 9 lines
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.Furthermore isn't it a bug for a driver to call
clk_disable()before a precedingclk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.Calling
clk_disable()precedingclk_enable()is a bug.Calling
clk_disable()afterclk_enable()will disable the clock (and its parents)
if the clock subsystem thinks there are no other users, which is what will happen here.
Quoted 4 lines
Quoted 1 line
Right. I'm not sure this is really applicable to this situation, though.
Yes it is: if all users of a clock/regulator/PM domain are gone, it will be disabled. Bad luck for simplefb still needing them.
Hmm... if all users are gone, then aren't the resources unused again and should therefore be ignored?
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/acf79846/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingQuoted 10 lines · Thierry Reding
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.Furthermore isn't it a bug for a driver to call
clk_disable()before a precedingclk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.
Quoted 8 lines
Quoted 6 lines
Calling
clk_disable()precedingclk_enable()is a bug.Calling
clk_disable()afterclk_enable()will disable the clock (and its parents)
if the clock subsystem thinks there are no other users, which is what will happen here.Right. I'm not sure this is really applicable to this situation, though.
It's actually very easy to do. Have a driver that probes, enables its clock, fails to probe for any reason, call clk_disable in its exit path. If there's no other user at that time of this particular clock tree, it will be shut down. Bam. You just lost your framebuffer.
Really, it's just that simple, and relying on the fact that some other user of the same clock tree will always be their is beyond fragile.
Quoted 3 lines
Either way, if there are other users of a clock then they will just as likely want to modify the rate at which point simplefb will break just as badly.
And this can be handled just as well. Register a clock notifier, refuse any rate change, done. But of course, that would require having a clock handle.
Now, how would *you* prevent such a change?
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/a36af406/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 20 lines · Maxime Ripard
Quoted 10 lines · Thierry Reding
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.Furthermore isn't it a bug for a driver to call
clk_disable()before a precedingclk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.Quoted 8 lines
Quoted 6 lines
Calling
clk_disable()precedingclk_enable()is a bug.Calling
clk_disable()afterclk_enable()will disable the clock (and its parents)
if the clock subsystem thinks there are no other users, which is what will happen here.Right. I'm not sure this is really applicable to this situation, though.
Quoted 7 lines
It's actually very easy to do. Have a driver that probes, enables its clock, fails to probe for any reason, call
clk_disablein its exit path. If there's no other user at that time of this particular clock tree, it will be shut down. Bam. You just lost your framebuffer.Really, it's just that simple, and relying on the fact that some other user of the same clock tree will always be their is beyond fragile.
Perhaps the meaning clk_ignore_unused should be revised, then. What you describe isn't at all what I'd expect from such an option. And it does not match the description in Documentation/kernel-parameters.txt either.
Quoted 9 lines
Quoted 3 lines
Either way, if there are other users of a clock then they will just as likely want to modify the rate at which point simplefb will break just as badly.
And this can be handled just as well. Register a clock notifier, refuse any rate change, done. But of course, that would require having a clock handle.
Now, how would *you* prevent such a change?
Like I said in the other thread. If you have two drivers that use the same clock but need different frequencies you've lost anyway.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/1a341b5c/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 26 lines · Thierry Reding
Quoted 25 lines · Maxime Ripard
Quoted 10 lines · Thierry Reding
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.Furthermore isn't it a bug for a driver to call
clk_disable()before a precedingclk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.Quoted 8 lines
Quoted 6 lines
Calling
clk_disable()precedingclk_enable()is a bug.Calling
clk_disable()afterclk_enable()will disable the clock (and its parents)
if the clock subsystem thinks there are no other users, which is what will happen here.Right. I'm not sure this is really applicable to this situation, though.
It's actually very easy to do. Have a driver that probes, enables its clock, fails to probe for any reason, call
clk_disablein its exit path. If there's no other user at that time of this particular clock tree, it will be shut down. Bam. You just lost your framebuffer.
Quoted 6 lines
Quoted 2 lines
Really, it's just that simple, and relying on the fact that some other user of the same clock tree will always be their is beyond fragile.
Perhaps the meaning
clk_ignore_unusedshould be revised, then. What you describe isn't at all what I'd expect from such an option. And it does not match the description inDocumentation/kernel-parameters.txteither.
Well, it never says that it also prevent them from being disabled later on. But it's true it's not very explicit.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Either way, if there are other users of a clock then they will just as likely want to modify the rate at which point simplefb will break just as badly.
Quoted 8 lines
Quoted 5 lines
And this can be handled just as well. Register a clock notifier, refuse any rate change, done. But of course, that would require having a clock handle.
Now, how would *you* prevent such a change?
Like I said in the other thread. If you have two drivers that use the same clock but need different frequencies you've lost anyway.
Except that the driver that has the most logic (ie not simplefb) will have a way to recover and deal with that. You prevented the clock rate *and* your system can react, I guess you actually won.
But sure, you can still try to point new issues, get an obvious and robust solution, and then discard the issue when the solution doesn't go your way...
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/4245fc55/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 30 lines · Maxime Ripard
Quoted 29 lines · Thierry Reding
Quoted 27 lines · Maxime Ripard
Quoted 10 lines · Thierry Reding
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.Furthermore isn't it a bug for a driver to call
clk_disable()before a precedingclk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.Quoted 8 lines
Quoted 6 lines
Calling
clk_disable()precedingclk_enable()is a bug.Calling
clk_disable()afterclk_enable()will disable the clock (and its parents)
if the clock subsystem thinks there are no other users, which is what will happen here.Right. I'm not sure this is really applicable to this situation, though.
It's actually very easy to do. Have a driver that probes, enables its clock, fails to probe for any reason, call
clk_disablein its exit path. If there's no other user at that time of this particular clock tree, it will be shut down. Bam. You just lost your framebuffer.Really, it's just that simple, and relying on the fact that some other user of the same clock tree will always be their is beyond fragile.
Quoted 6 lines
Quoted 3 lines
Perhaps the meaning
clk_ignore_unusedshould be revised, then. What you describe isn't at all what I'd expect from such an option. And it does not match the description inDocumentation/kernel-parameters.txteither.Well, it never says that it also prevent them from being disabled later on. But it's true it's not very explicit.
It says:
Keep all clocks already enabled by bootloader on, even if no driver has claimed them. ...
There's no "until" or anything there, so I interpret that as indefinitely.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Either way, if there are other users of a clock then they will just as likely want to modify the rate at which point simplefb will break just as badly.
And this can be handled just as well. Register a clock notifier, refuse any rate change, done. But of course, that would require having a clock handle.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Now, how would *you* prevent such a change?
Like I said in the other thread. If you have two drivers that use the same clock but need different frequencies you've lost anyway.
Except that the driver that has the most logic (ie not simplefb) will have a way to recover and deal with that.
You're making an assumption here. Why would the driver have such logic if nothing ever prevented it from setting the rate properly before.
Quoted 3 lines
But sure, you can still try to point new issues, get an obvious and robust solution, and then discard the issue when the solution doesn't go your way...
And you've already proven that you're completely unwilling to even consider any other solution than what was originally proposed, so I really don't see how discussing this further with you is going to be productive.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140930/34cb9718/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 38 lines · Thierry Reding
Quoted 30 lines · Maxime Ripard
Quoted 29 lines · Thierry Reding
Quoted 27 lines · Maxime Ripard
Quoted 10 lines · Thierry Reding
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.Furthermore isn't it a bug for a driver to call
clk_disable()before a precedingclk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.Quoted 8 lines
Quoted 6 lines
Calling
clk_disable()precedingclk_enable()is a bug.Calling
clk_disable()afterclk_enable()will disable the clock (and its parents)
if the clock subsystem thinks there are no other users, which is what will happen here.Right. I'm not sure this is really applicable to this situation, though.
It's actually very easy to do. Have a driver that probes, enables its clock, fails to probe for any reason, call
clk_disablein its exit path. If there's no other user at that time of this particular clock tree, it will be shut down. Bam. You just lost your framebuffer.Really, it's just that simple, and relying on the fact that some other user of the same clock tree will always be their is beyond fragile.
Quoted 6 lines
Quoted 3 lines
Perhaps the meaning
clk_ignore_unusedshould be revised, then. What you describe isn't at all what I'd expect from such an option. And it does not match the description inDocumentation/kernel-parameters.txteither.Well, it never says that it also prevent them from being disabled later on. But it's true it's not very explicit.
Quoted 7 lines
It says:
Keep all clocks already enabled by bootloader on, even if no driver has claimed them. ...
There's no "until" or anything there, so I interpret that as indefinitely.
Well, then, sorry, but that's not how it works.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
Either way, if there are other users of a clock then they will just as likely want to modify the rate at which point simplefb will break just as badly.
And this can be handled just as well. Register a clock notifier, refuse any rate change, done. But of course, that would require having a clock handle.
Now, how would *you* prevent such a change?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Like I said in the other thread. If you have two drivers that use the same clock but need different frequencies you've lost anyway.
Except that the driver that has the most logic (ie not simplefb) will have a way to recover and deal with that.
You're making an assumption here. Why would the driver have such logic if nothing ever prevented it from setting the rate properly before.
I'm not saying it has, but it something that can be done. You usually have several strategies, which depending on the device, might or might not be possible, such as reparenting, trying to use an additional divider.
Worst case scenario, you're indeed doomed. But you do have a best case scenario, which isn't the case with your approach. And you didn't screw the framebuffer silently.
Quoted 8 lines
Quoted 3 lines
But sure, you can still try to point new issues, get an obvious and robust solution, and then discard the issue when the solution doesn't go your way...
And you've already proven that you're completely unwilling to even consider any other solution than what was originally proposed, so I really don't see how discussing this further with you is going to be productive.
You haven't express *what* you wanted to achieve for quite some time, but only *how*. And your how has some deficiencies that have already been pointed out numerous times.
However, I do come to the same conclusion. I really don't see how we can be productive. Just like I really don't see how we will ever be able to get any DRM/KMS driver in when the time comes.
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140930/fc2f9893/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingHi,
Quoted 1 line · Thierry Reding
On Mon, Sep 29, 2014 at 05:57:18PM +0200, Maxime Ripard wrote:
<snip>
Quoted 8 lines
Quoted 3 lines
But sure, you can still try to point new issues, get an obvious and robust solution, and then discard the issue when the solution doesn't go your way...
And you've already proven that you're completely unwilling to even consider any other solution than what was originally proposed, so I really don't see how discussing this further with you is going to be productive.
That is not true, we have seriously considered various other alternatives, as you know since you've participated in the discussion about them.
And we've found them all lacking, mostly because they are 10 times as complicated.
You've made your point that you don't like this solution quite loudly already, and we've all heard you. However you seem to be mostly alone in this. Even the clk maintainer has said that what we want to do is exactly how clocks are supposed to be used in dt.
If you don't like this no-one is forcing you to use the clocks property in your own code. If it is not there, simplefb will behave exactly as before.
Now since you're the only one very vocally against this, and a lot of people are in favor of this and have a need for this, can we please just get this merged and get this over with ?
Regards,
Hans
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 27 lines · Hans de Goede
Hi,
Quoted 1 line · Thierry Reding
On Mon, Sep 29, 2014 at 05:57:18PM +0200, Maxime Ripard wrote:
<snip>
Quoted 8 lines
Quoted 3 lines
But sure, you can still try to point new issues, get an obvious and robust solution, and then discard the issue when the solution doesn't go your way...
And you've already proven that you're completely unwilling to even consider any other solution than what was originally proposed, so I really don't see how discussing this further with you is going to be productive.
That is not true, we have seriously considered various other alternatives, as you know since you've participated in the discussion about them.
And we've found them all lacking, mostly because they are 10 times as complicated.
You've made your point that you don't like this solution quite loudly already, and we've all heard you. However you seem to be mostly alone in this. Even the clk maintainer has said that what we want to do is exactly how clocks are supposed to be used in dt.
Quoted 7 lines
If you don't like this no-one is forcing you to use the clocks property in your own code. If it is not there, simplefb will behave exactly as before.
Now since you're the only one very vocally against this, and a lot of people are in favor of this and have a need for this, can we please just get this merged and get this over with ?
Whatever. I no longer care.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140930/201cf473/attachment-0001.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingQuoting Thierry Reding (2014-09-29 06:54:00)
Quoted 26 lines · Maxime Ripard
Quoted 25 lines · Thierry Reding
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.Furthermore isn't it a bug for a driver to call
clk_disable()before a precedingclk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.Quoted 8 lines
Quoted 6 lines
Calling
clk_disable()precedingclk_enable()is a bug.Calling
clk_disable()afterclk_enable()will disable the clock (and its parents)
if the clock subsystem thinks there are no other users, which is what will happen here.Right. I'm not sure this is really applicable to this situation, though.
It's actually very easy to do. Have a driver that probes, enables its clock, fails to probe for any reason, call
clk_disablein its exit path. If there's no other user at that time of this particular clock tree, it will be shut down. Bam. You just lost your framebuffer.
Quoted 8 lines
Quoted 2 lines
Really, it's just that simple, and relying on the fact that some other user of the same clock tree will always be their is beyond fragile.
Perhaps the meaning
clk_ignore_unusedshould be revised, then. What you describe isn't at all what I'd expect from such an option. And it does not match the description inDocumentation/kernel-parameters.txteither.From
e156ee56cbe26c9e8df6619dac1a993245afc1d5Mon Sep 17 00:00:00 2001
From: Mike Turquette <[email protected]>
Date: Tue, 30 Sep 2014 14:24:38 -0700
Subject: [PATCH] doc/kernel-parameters.txt: clarify clk_ignore_unused
Refine the definition around clk_ignore_unused, which caused some confusion recently on the linux-fbdev and linux-arm-kernel mailing lists[0].
[0] http://lkml.kernel.org/r/<20140929135358.GC30998@ulmo>
---
Thierry,
Please let me know if this wording makes the feature more clear.
Documentation/kernel-parameters.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
Documentation/kernel-parameters.txt +9 -5
@@ -605,11 +605,15 @@ bytes respectively. Such letter suffixes can also be entirely omitted. See Documentation/s390/CommonIO for details. clk_ignore_unused [CLK] - Keep all clocks already enabled by bootloader on, - even if no driver has claimed them. This is useful - for debug and development, but should not be - needed on a platform with proper driver support. - For more information, see Documentation/clk.txt. + Prevents the clock framework from automatically gating + clocks that have not been explicitly enabled by a Linux + device driver but are enabled in hardware at reset or + by the bootloader/firmware. Note that this does not + force such clocks to be always-on nor does it reserve + those clocks in any way. This parameter is useful for + debug and development, but should not be needed on a + platform with proper driver support. For more + information, see Documentation/clk.txt. clock= [BUGS=X86-32, HW] gettimeofday clocksource override. [Deprecated]
Signature · 1 line
1.8.3.2
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 43 lines · Mike Turquette
Quoting Thierry Reding (2014-09-29 06:54:00)
Quoted 26 lines · Maxime Ripard
Quoted 25 lines · Thierry Reding
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.Furthermore isn't it a bug for a driver to call
clk_disable()before a precedingclk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.Quoted 8 lines
Quoted 6 lines
Calling
clk_disable()precedingclk_enable()is a bug.Calling
clk_disable()afterclk_enable()will disable the clock (and its parents)
if the clock subsystem thinks there are no other users, which is what will happen here.Right. I'm not sure this is really applicable to this situation, though.
It's actually very easy to do. Have a driver that probes, enables its clock, fails to probe for any reason, call
clk_disablein its exit path. If there's no other user at that time of this particular clock tree, it will be shut down. Bam. You just lost your framebuffer.Quoted 6 lines
Quoted 2 lines
Really, it's just that simple, and relying on the fact that some other user of the same clock tree will always be their is beyond fragile.
Perhaps the meaning
clk_ignore_unusedshould be revised, then. What you describe isn't at all what I'd expect from such an option. And it does not match the description inDocumentation/kernel-parameters.txteither.From
e156ee56cbe26c9e8df6619dac1a993245afc1d5Mon Sep 17 00:00:00 2001
From: Mike Turquette <[email protected]>
Date: Tue, 30 Sep 2014 14:24:38 -0700
Subject: [PATCH]doc/kernel-parameters.txt: clarifyclk_ignore_unusedRefine the definition around
clk_ignore_unused, which caused some confusion recently on the linux-fbdev and linux-arm-kernel mailing lists[0].
Quoted 7 lines
[0] http://lkml.kernel.org/r/<20140929135358.GC30998@ulmo>
Signed-off-by Mike Turquette <[email protected]>---
Thierry,Please let me know if this wording makes the feature more clear.
I think that's better than before, but I don't think it's accurate yet. As pointed out by Maxime unused clock may still be disabled if it's part of a tree and that tree is being disabled because there are no users left.
What I had argued is that it's unexpected behaviour, because the clock is still unused (or becomes unused again), therefore shouldn't be disabled at that point either.
So if you want to keep the current behaviour where an unused clock can still be disabled depending on what other users do, then I think it'd be good to mention that as a potential caveat.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141001/0e90b079/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 50 lines · Thierry Reding
Quoted 49 lines · Mike Turquette
Quoting Thierry Reding (2014-09-29 06:54:00)
Quoted 26 lines · Maxime Ripard
Quoted 25 lines · Thierry Reding
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.Furthermore isn't it a bug for a driver to call
clk_disable()before a precedingclk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.Quoted 8 lines
Quoted 6 lines
Calling
clk_disable()precedingclk_enable()is a bug.Calling
clk_disable()afterclk_enable()will disable the clock (and its parents)
if the clock subsystem thinks there are no other users, which is what will happen here.Right. I'm not sure this is really applicable to this situation, though.
It's actually very easy to do. Have a driver that probes, enables its clock, fails to probe for any reason, call
clk_disablein its exit path. If there's no other user at that time of this particular clock tree, it will be shut down. Bam. You just lost your framebuffer.Quoted 6 lines
Quoted 2 lines
Really, it's just that simple, and relying on the fact that some other user of the same clock tree will always be their is beyond fragile.
Perhaps the meaning
clk_ignore_unusedshould be revised, then. What you describe isn't at all what I'd expect from such an option. And it does not match the description inDocumentation/kernel-parameters.txteither.From
e156ee56cbe26c9e8df6619dac1a993245afc1d5Mon Sep 17 00:00:00 2001
From: Mike Turquette <[email protected]>
Date: Tue, 30 Sep 2014 14:24:38 -0700
Subject: [PATCH]doc/kernel-parameters.txt: clarifyclk_ignore_unusedRefine the definition around
clk_ignore_unused, which caused some confusion recently on the linux-fbdev and linux-arm-kernel mailing lists[0].[0] http://lkml.kernel.org/r/<20140929135358.GC30998@ulmo>
Signed-off-by Mike Turquette <[email protected]>---
Thierry,
Quoted 6 lines
Quoted 1 line
Please let me know if this wording makes the feature more clear.
I think that's better than before, but I don't think it's accurate yet. As pointed out by Maxime unused clock may still be disabled if it's part of a tree and that tree is being disabled because there are no users left.
It is entirely accurate. This feature does in fact "prevent the clock framework from *automatically* gating clock ...".
And it was merged by Olof so that he could use simplefb with the Chromebook!
Quoted 4 lines
What I had argued is that it's unexpected behavior, because the clock is still unused (or becomes unused again), therefore shouldn't be disabled at that point either.
Leaving clocks enabled because nobody claimed them is not an option.
Quoted 4 lines
So if you want to keep the current behaviour where an unused clock can still be disabled depending on what other users do, then I think it'd be good to mention that as a potential caveat.
Do you have a suggestion on the wording?
Thanks,
Mike
Quoted 2 lines
Thierry
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 54 lines · Mike Turquette
Quoted 52 lines · Thierry Reding
Quoted 50 lines · Mike Turquette
Quoting Thierry Reding (2014-09-29 06:54:00)
Quoted 26 lines · Maxime Ripard
Quoted 25 lines · Thierry Reding
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.Furthermore isn't it a bug for a driver to call
clk_disable()before a precedingclk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.Quoted 8 lines
Quoted 6 lines
Calling
clk_disable()precedingclk_enable()is a bug.Calling
clk_disable()afterclk_enable()will disable the clock (and its parents)
if the clock subsystem thinks there are no other users, which is what will happen here.Right. I'm not sure this is really applicable to this situation, though.
It's actually very easy to do. Have a driver that probes, enables its clock, fails to probe for any reason, call
clk_disablein its exit path. If there's no other user at that time of this particular clock tree, it will be shut down. Bam. You just lost your framebuffer.Quoted 6 lines
Quoted 2 lines
Really, it's just that simple, and relying on the fact that some other user of the same clock tree will always be their is beyond fragile.
Perhaps the meaning
clk_ignore_unusedshould be revised, then. What you describe isn't at all what I'd expect from such an option. And it does not match the description inDocumentation/kernel-parameters.txteither.From
e156ee56cbe26c9e8df6619dac1a993245afc1d5Mon Sep 17 00:00:00 2001
From: Mike Turquette <[email protected]>
Date: Tue, 30 Sep 2014 14:24:38 -0700
Subject: [PATCH]doc/kernel-parameters.txt: clarifyclk_ignore_unusedRefine the definition around
clk_ignore_unused, which caused some confusion recently on the linux-fbdev and linux-arm-kernel mailing lists[0].[0] http://lkml.kernel.org/r/<20140929135358.GC30998@ulmo>
Signed-off-by Mike Turquette <[email protected]>---
Thierry,Please let me know if this wording makes the feature more clear.
Quoted 7 lines
Quoted 4 lines
I think that's better than before, but I don't think it's accurate yet. As pointed out by Maxime unused clock may still be disabled if it's part of a tree and that tree is being disabled because there are no users left.
It is entirely accurate. This feature does in fact "prevent the clock framework from *automatically* gating clock ...".
According to what Maxime said if an unused clock is a sibling (has the same parent) of a clock that is used and then gets disabled, then if the parent has no other clocks that are enabled, the unused clock will still be disabled.
That's still counts as "automatically" to me. Not automatically would mean that the clock needs to be disabled explicitly for it to become disabled. Disabling it as a side-effect of its parent getting disabled is still automatic.
Quoted 2 lines
And it was merged by Olof so that he could use simplefb with the Chromebook!
And presumably it does work for that specific Chromebook. It seems, though that for hardware with a somewhat whackier clock tree it doesn't work so well. As far as I can tell that's the reason for this patch and the ensuing discussion in the first place.
Although, perhaps nobody ever really tested whether or not the above scenario was actually a problem for sunxi and maybe clk_ignore_unused would work for them. But as I understand they don't want to use it, so this whole debate about this kernel parameter is a bit moot.
Quoted 5 lines
Quoted 3 lines
What I had argued is that it's unexpected behavior, because the clock is still unused (or becomes unused again), therefore shouldn't be disabled at that point either.
Leaving clocks enabled because nobody claimed them is not an option.
But that's exactly what clk_ignore_unused is, isn't it? I'm now totally confused.
Quoted 5 lines
Quoted 3 lines
So if you want to keep the current behaviour where an unused clock can still be disabled depending on what other users do, then I think it'd be good to mention that as a potential caveat.
Do you have a suggestion on the wording?
Perhaps something like this:
Note that if an unused clock shares a parent with clocks that are used, the unused clock may still become disabled as a side- effect of the parent clock being disabled when none of the children that are used remain enabled.
?
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141002/d26295c7/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingHi Thierry,
Quoted 10 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Mon, Sep 29, 2014 at 10:06:39AM +0200, Thierry Reding wrote:
[...]
Quoted 7 lines
Quoted 6 lines
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
Quoted 6 lines
Quoted 2 lines
Which makes the whole even simpler, since the firmware already knows all about which clocks it had to enable.
It makes things very complicated in the firmware because it now needs to be able to generate DTB content that we would otherwise be able to do much easier with a text editor.
As far as the kernel is concerned, this is a solved problem.
Firmware is going to be doing some dark magic to set up the hardware to be a dumb frame buffer and some other stuff to add the simplefb device node - so by this point, adding the clocks (or whatever) required by the hardware should be fairly uncomplicated - the firmware already knows the hardware intimately. As for the actual device tree manipulations, U-boot (or whatever) will probably just grow some helper functions to make this simple.
Alternatively, it could simply add the relevant data to an existing device node and munge it's compatible property so simplefb picks it up.
Quoted 67 lines
Quoted 23 lines
Quoted 19 lines
If we start extending the binding with board-level details we end up duplicating the device tree node for the proper video device. Also note that it won't stop at clocks. Other setups will require regulators to be listed in this device tree node as well so that they don't get disabled at
late_initcall. And the regulator bindings don't provide a method to list an arbitrary number of clocks in a single property in the way that the clocks property works.There may be also resets involved. Fortunately the reset framework is minimalistic enough not to care about asserting all unused resets at
late_initcall. And other things like power domains may also need to be kept on.Passing in clock information via the device tree already requires a non- trivial amount of code in the firmware. A similar amount of code would be necessary for each type of resource that needs to be kept enabled. In addition to the above some devices may also require resources that have no generic bindings. That just doesn't scale.
Quoted 3 lines
The only reasonable thing for simplefb to do is not deal with any kind of resource at all (except perhaps area that contains the framebuffer memory).
Quoted 6 lines
You should really read that thread:
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-September/284726.htmlIt's quite interesting, because you'll see that:
A) Your approach, even on the platform you're working on, doesn't work. Or at least, isn't reliable.What platform exactly do you think I'm working on? Why do you think what I proposed isn't going to work or be reliable? I don't see any arguments in the thread that would imply that.
Quoted 2 lines
B) Other maintainers, precisely like Mark, came to the same conclusion than Mike.
Well, and others didn't.
Also I think if you read that thread and look at my proposal it matches exactly what was discussed as one of the solutions at one point in the thread.
Quoted 16 lines
Quoted 7 lines
So how about instead of requiring resources to be explicitly claimed we introduce something like the below patch? The intention being to give "firmware device" drivers a way of signalling to the clock framework that they need rely on clocks set up by firmware and when they no longer need them. This implements essentially what Mark (CC'ing again on this subthread) suggested earlier in this thread. Basically, it will allow drivers to determine the time when unused clocks are really unused. It
Quoted 8 lines
will of course only work when used correctly by drivers. For the case of simplefb I'd expect its .probe() implementation to call the new
clk_ignore_unused()function and once it has handed over control of the display hardware to the real driver it can callclk_unignore_unused()to signal that all unused clocks that it cares about have now been claimed. This is "reference counted" and can therefore be used by more than a single driver if necessary. Similar functionality could be added for other resource subsystems as needed.Quoted 3 lines
So, just to be clear, instead of doing a generic
clk_getandclk_prepare_enable, you're willing to do a just as much genericclk_ignore_unusedcall?Yes.
Quoted 1 line
How is that less generic?
Quoted 8 lines
It's more generic. That's the whole point.
The difference is that with the solution I proposed we don't have to keep track of all the resources. We know that firmware has set them up and we know that a real driver will properly take them over at some point, so duplicating what the real driver does within the simplefb driver is just that, duplication. We don't allow duplication anywhere else in the kernel, why should simplefb be an exception?
The various subsystems could just grow some accessor functions (where required) which, with devm, should be as simple as ~10 lines per subsystem. With ~5 subsystems this is ~50 lines of code; Or we can disable the automatic disabling of resources and put the system in a potentially unstable state; Or each subarch could use some shim driver or some arch code to grab the clocks for simplefb, and we end up with each subarch having it's own, slightly different version of what is essentially the same code; Or we have to have every single KMS driver built in and bloat the kernel.
With ~50 lines of generic code added to simplefb, distros get their slim multi-subarch kernels, your driver is still generic, power management works and users get pretty graphics from bootloader to desktop.
Quoted 14 lines
Quoted 5 lines
You know that you are going to call that for regulator, reset, power domains, just as you would have needed to with the proper API, unless that with this kind of solution, you would have to modify *every* framework that might interact with any resource involved in getting simplefb running?
We have to add handling for every kind of resource either way. Also if this evolves into a common pattern we can easily wrap it up in a single function call.
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.
Quoted 8 lines
If we need to prevent that, then that's something that could be fixed, too. But both this and the other thread at least agree on the fact that simplefb is a shim driver that's going to be replaced by something real at some point, so hopefully concurrent users aren't the problem because that would cause the real driver to break too.
Also note that if some other driver could call
clk_disable()it could just as easily callclk_set_rate()and break simplefb.
If simplefb has called clk_get() then nobody can disable the clocks it's depending on.
Quoted 7 lines
Furthermore isn't it a bug for a driver to call
clk_disable()before a precedingclk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.Thierry
Thanks,
Signature · 4 lines
Julian Calaby Email: julian.calaby at gmail.com Profile: http://www.google.com/profiles/julian.calaby/
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 1 line · Julian Calaby
Hi Thierry,
If you address people directly please make sure they are in the To:
line. Or at least Cc.
Quoted 12 lines
Quoted 10 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Mon, Sep 29, 2014 at 10:06:39AM +0200, Thierry Reding wrote:
[...]
Quoted 7 lines
Quoted 6 lines
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Which makes the whole even simpler, since the firmware already knows all about which clocks it had to enable.
It makes things very complicated in the firmware because it now needs to be able to generate DTB content that we would otherwise be able to do much easier with a text editor.
As far as the kernel is concerned, this is a solved problem.
It's not completely solved. There's still the issue of no generic way to specify regulators like you can do for clocks, resets or power domains.
But the kernel isn't the real issue here. The issue is the firmware that now has to go out of its way not only to initialize display hardware but also create device tree content just to make Linux not turn everything off.
Quoted 7 lines
Firmware is going to be doing some dark magic to set up the hardware to be a dumb frame buffer and some other stuff to add the simplefb device node - so by this point, adding the clocks (or whatever) required by the hardware should be fairly uncomplicated - the firmware already knows the hardware intimately. As for the actual device tree manipulations, U-boot (or whatever) will probably just grow some helper functions to make this simple.
Have you looked at the code needed to do this? It's not at all trivial. And the point is really that all this information is there already, so we're completely duplicating this into a dynamically created device tree node and for what reason? Only to have one driver request all these resources and have them forcefully released a few seconds later.
Quoted 3 lines
Alternatively, it could simply add the relevant data to an existing device node and munge it's compatible property so simplefb picks it up.
Yes, I think that'd be a much better solution. Of course it's going to be very difficult to make that work with a generic driver because now that generic driver needs to parse the DT binding for any number of "compatible" devices.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/a6e9e08a/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Hi Thierry,
Quoted 5 lines · Thierry Reding
Quoted 1 line · Julian Calaby
Hi Thierry,
If you address people directly please make sure they are in the To:
line. Or at least Cc.
Sorry about that, the mailing list I received this through (Google Groups based) generally strips to: and CC: lines, so my mail client (Gmail) doesn't do it automatically. I'm still getting used to it.
Quoted 19 lines
Quoted 19 lines
Quoted 16 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Mon, Sep 29, 2014 at 10:06:39AM +0200, Thierry Reding wrote:
[...]
Quoted 9 lines
Quoted 6 lines
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
Which makes the whole even simpler, since the firmware already knows all about which clocks it had to enable.
It makes things very complicated in the firmware because it now needs to be able to generate DTB content that we would otherwise be able to do much easier with a text editor.
Quoted 8 lines
Quoted 1 line
As far as the kernel is concerned, this is a solved problem.
It's not completely solved. There's still the issue of no generic way to specify regulators like you can do for clocks, resets or power domains. But the kernel isn't the real issue here. The issue is the firmware that now has to go out of its way not only to initialize display hardware but also create device tree content just to make Linux not turn everything off.
My point is that the firmware is going to be doing complicated stuff already, adding and using some helpers to configure a device tree node is relatively simple in comparison to dealing with the actual hardware. It wouldn't surprise me if u-boot, for example, ended up with a set of functions to handle this exact case as more graphics hardware gets brought up.
Quoted 14 lines
Quoted 7 lines
Firmware is going to be doing some dark magic to set up the hardware to be a dumb frame buffer and some other stuff to add the simplefb device node - so by this point, adding the clocks (or whatever) required by the hardware should be fairly uncomplicated - the firmware already knows the hardware intimately. As for the actual device tree manipulations, U-boot (or whatever) will probably just grow some helper functions to make this simple.
Have you looked at the code needed to do this? It's not at all trivial. And the point is really that all this information is there already, so we're completely duplicating this into a dynamically created device tree node and for what reason? Only to have one driver request all these resources and have them forcefully released a few seconds later.
Quoted 8 lines
Quoted 3 lines
Alternatively, it could simply add the relevant data to an existing device node and munge it's compatible property so simplefb picks it up.
Yes, I think that'd be a much better solution. Of course it's going to be very difficult to make that work with a generic driver because now that generic driver needs to parse the DT binding for any number of "compatible" devices.
Not necessarily.
The patch that started this discussion can work with any number of clocks specified in a "clocks" property. Therefore all that needs to happen is that the final hardware binding specifies it's clocks that way. This is how, for example, the ahci_platform driver's clock code works.
I'm sure that as hardware diversifies, the other subsystems will grow in similar directions and eventually be dealt with using similarly generic code.
Thanks,
Signature · 4 lines
Julian Calaby Email: julian.calaby at gmail.com Profile: http://www.google.com/profiles/julian.calaby/
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 5 lines · Julian Calaby
Hi Thierry,
Quoted 1 line · Thierry Reding
On Mon, Sep 29, 2014 at 09:00:01PM +1000, Julian Calaby wrote:
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Hi Thierry,
If you address people directly please make sure they are in the To:
line. Or at least Cc.Sorry about that, the mailing list I received this through (Google Groups based) generally strips to: and CC: lines, so my mail client (Gmail) doesn't do it automatically. I'm still getting used to it.
Yeah, I wish mailing lists would stop doing that.
Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
Quoted 16 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Mon, Sep 29, 2014 at 10:06:39AM +0200, Thierry Reding wrote:
[...]
Quoted 9 lines
Quoted 6 lines
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
Which makes the whole even simpler, since the firmware already knows all about which clocks it had to enable.
It makes things very complicated in the firmware because it now needs to be able to generate DTB content that we would otherwise be able to do much easier with a text editor.
Quoted 8 lines
Quoted 1 line
As far as the kernel is concerned, this is a solved problem.
It's not completely solved. There's still the issue of no generic way to specify regulators like you can do for clocks, resets or power domains. But the kernel isn't the real issue here. The issue is the firmware that now has to go out of its way not only to initialize display hardware but also create device tree content just to make Linux not turn everything off.
Quoted 6 lines
My point is that the firmware is going to be doing complicated stuff already, adding and using some helpers to configure a device tree node is relatively simple in comparison to dealing with the actual hardware. It wouldn't surprise me if u-boot, for example, ended up with a set of functions to handle this exact case as more graphics hardware gets brought up.
Not all firmware is based on U-Boot. Essentially whatever binding changes we make will need to be implemented in all firmware. And the complexity isn't so much about writing the actual DT data, but more about figuring out which data to write. Every firmware image needs to know exactly which clocks and other resources to transcribe for a given board. It'll essentially need to contain some sort of "driver" for each device that parses a DTB, correlates the data to what it knows of the device internals and write a subset of that data back into the DTB in a slightly different format. That's just whacky.
DT was meant to simplify things.
Quoted 23 lines
Quoted 14 lines
Quoted 7 lines
Firmware is going to be doing some dark magic to set up the hardware to be a dumb frame buffer and some other stuff to add the simplefb device node - so by this point, adding the clocks (or whatever) required by the hardware should be fairly uncomplicated - the firmware already knows the hardware intimately. As for the actual device tree manipulations, U-boot (or whatever) will probably just grow some helper functions to make this simple.
Have you looked at the code needed to do this? It's not at all trivial. And the point is really that all this information is there already, so we're completely duplicating this into a dynamically created device tree node and for what reason? Only to have one driver request all these resources and have them forcefully released a few seconds later.
Quoted 8 lines
Quoted 3 lines
Alternatively, it could simply add the relevant data to an existing device node and munge it's compatible property so simplefb picks it up.
Yes, I think that'd be a much better solution. Of course it's going to be very difficult to make that work with a generic driver because now that generic driver needs to parse the DT binding for any number of "compatible" devices.
Quoted 6 lines
Not necessarily.
The patch that started this discussion can work with any number of clocks specified in a "clocks" property. Therefore all that needs to happen is that the final hardware binding specifies it's clocks that way.
Are you suggesting that we should be modeling the hardware specific binding to match what the simplefb binding does?
Quoted 3 lines
I'm sure that as hardware diversifies, the other subsystems will grow in similar directions and eventually be dealt with using similarly generic code.
For regulators this already works very differently. As opposed to the clocks/clock-names type of binding it uses one where the consumer name of the regulator comes from the prefix of a -supply property. That is you'd get something like this:
foo-supply = <®1>; bar-supply = <®2>;
And since you don't have enough information in the kernel simplefb driver to attach any meaning to these, the best you can do would be iterating over a range and have:
0-supply = <®0>; 1-supply = <®1>; ... n-supply = <®2>;
This is made more difficult by the fact that these regulators may be required by components not immediately related to the display engine. They could be for an attached panel, a video bridge or the +5V pin on the HDMI connector.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/5aa6ab99/attachment-0001.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 46 lines · Thierry Reding
Quoted 28 lines · Julian Calaby
Quoted 19 lines
Quoted 19 lines
Quoted 16 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Mon, Sep 29, 2014 at 10:06:39AM +0200, Thierry Reding wrote:
[...]
Quoted 9 lines
Quoted 6 lines
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
Which makes the whole even simpler, since the firmware already knows all about which clocks it had to enable.
It makes things very complicated in the firmware because it now needs to be able to generate DTB content that we would otherwise be able to do much easier with a text editor.
Quoted 8 lines
Quoted 1 line
As far as the kernel is concerned, this is a solved problem.
It's not completely solved. There's still the issue of no generic way to specify regulators like you can do for clocks, resets or power domains. But the kernel isn't the real issue here. The issue is the firmware that now has to go out of its way not only to initialize display hardware but also create device tree content just to make Linux not turn everything off.
Quoted 6 lines
My point is that the firmware is going to be doing complicated stuff already, adding and using some helpers to configure a device tree node is relatively simple in comparison to dealing with the actual hardware. It wouldn't surprise me if u-boot, for example, ended up with a set of functions to handle this exact case as more graphics hardware gets brought up.
Not all firmware is based on U-Boot. Essentially whatever binding changes we make will need to be implemented in all firmware. And the complexity isn't so much about writing the actual DT data, but more about figuring out which data to write. Every firmware image needs to know exactly which clocks and other resources to transcribe for a given board. It'll essentially need to contain some sort of "driver" for each device that parses a DTB, correlates the data to what it knows of the device internals and write a subset of that data back into the DTB in a slightly different format. That's just whacky.
Quoted 1 line
DT was meant to simplify things.
The firmware only needs to implement DT parsing and writing if it wants to communicate the configuration it set up to the kernel. If you do not have control over the firmware or do not want to write support for the firmware to generate the DT you can produce a fixed configuration DT and have the firmware load that with the kernel. It is fully backwards compatible with dumb firmware that does not support DT modification during boot. You will just need a different DT for slightly different devices (eg. tablets with different display) or different configurations of same device (eg. different displays connected to the HDMI port of your devboard).
Quoted 21 lines
Quoted 3 lines
I'm sure that as hardware diversifies, the other subsystems will grow in similar directions and eventually be dealt with using similarly generic code.
For regulators this already works very differently. As opposed to the clocks/clock-names type of binding it uses one where the consumer name of the regulator comes from the prefix of a -supply property. That is you'd get something like this:
foo-supply = <®1>; bar-supply = <®2>;And since you don't have enough information in the kernel simplefb driver to attach any meaning to these, the best you can do would be iterating over a range and have:
0-supply = <®0>; 1-supply = <®1>; ... n-supply = <®2>;
Quoted 4 lines
This is made more difficult by the fact that these regulators may be required by components not immediately related to the display engine. They could be for an attached panel, a video bridge or the +5V pin on the HDMI connector.
So you are saying that listing the properties of the simplefb node and filtering foo-supply and bar-supply out of that is too difficult?
I hope kernel development did not get this dumb.
Thanks
Michal
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingHi Thierry,
Quoted 62 lines · Thierry Reding
Quoted 5 lines · Julian Calaby
Hi Thierry,
Quoted 1 line · Thierry Reding
On Mon, Sep 29, 2014 at 09:00:01PM +1000, Julian Calaby wrote:
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Hi Thierry,
If you address people directly please make sure they are in the To:
line. Or at least Cc.Sorry about that, the mailing list I received this through (Google Groups based) generally strips to: and CC: lines, so my mail client (Gmail) doesn't do it automatically. I'm still getting used to it.
Yeah, I wish mailing lists would stop doing that.
Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
Quoted 16 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Mon, Sep 29, 2014 at 10:06:39AM +0200, Thierry Reding wrote:
[...]
Quoted 9 lines
Quoted 6 lines
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
Which makes the whole even simpler, since the firmware already knows all about which clocks it had to enable.
It makes things very complicated in the firmware because it now needs to be able to generate DTB content that we would otherwise be able to do much easier with a text editor.
Quoted 8 lines
Quoted 1 line
As far as the kernel is concerned, this is a solved problem.
It's not completely solved. There's still the issue of no generic way to specify regulators like you can do for clocks, resets or power domains. But the kernel isn't the real issue here. The issue is the firmware that now has to go out of its way not only to initialize display hardware but also create device tree content just to make Linux not turn everything off.
Quoted 6 lines
My point is that the firmware is going to be doing complicated stuff already, adding and using some helpers to configure a device tree node is relatively simple in comparison to dealing with the actual hardware. It wouldn't surprise me if u-boot, for example, ended up with a set of functions to handle this exact case as more graphics hardware gets brought up.
Not all firmware is based on U-Boot. Essentially whatever binding changes we make will need to be implemented in all firmware. And the complexity isn't so much about writing the actual DT data, but more about figuring out which data to write. Every firmware image needs to know exactly which clocks and other resources to transcribe for a given board. It'll essentially need to contain some sort of "driver" for each device that parses a DTB, correlates the data to what it knows of the device internals and write a subset of that data back into the DTB in a slightly different format. That's just whacky.
Quoted 1 line
DT was meant to simplify things.
Ok, fair enough, while it's a tempting solution - it makes the kernel end of things nice and simple, it's probably not completely scalable. U-boot definitely does have "drivers" for the hardware it supports, but we can't expect every bootloader to do that.
Quoted 25 lines
Quoted 25 lines
Quoted 14 lines
Quoted 7 lines
Firmware is going to be doing some dark magic to set up the hardware to be a dumb frame buffer and some other stuff to add the simplefb device node - so by this point, adding the clocks (or whatever) required by the hardware should be fairly uncomplicated - the firmware already knows the hardware intimately. As for the actual device tree manipulations, U-boot (or whatever) will probably just grow some helper functions to make this simple.
Have you looked at the code needed to do this? It's not at all trivial. And the point is really that all this information is there already, so we're completely duplicating this into a dynamically created device tree node and for what reason? Only to have one driver request all these resources and have them forcefully released a few seconds later.
Quoted 8 lines
Quoted 3 lines
Alternatively, it could simply add the relevant data to an existing device node and munge it's compatible property so simplefb picks it up.
Yes, I think that'd be a much better solution. Of course it's going to be very difficult to make that work with a generic driver because now that generic driver needs to parse the DT binding for any number of "compatible" devices.
Not necessarily.
Quoted 7 lines
Quoted 4 lines
The patch that started this discussion can work with any number of clocks specified in a "clocks" property. Therefore all that needs to happen is that the final hardware binding specifies it's clocks that way.
Are you suggesting that we should be modeling the hardware specific binding to match what the simplefb binding does?
I'll admit that this sounded pretty dumb when I thought over it in the morning. Let's call it a strawman and let's call me a hilariously unskilled debater.
I don't have a kernel tree in front of me, so I don't know that all the helpers used below exist or are named like I've shown, but code like this could grab all the resources specified in a tree of nodes:
void simplefb_grab_all_resources(node *root)
{
node *next = root;
node *cur;
while( next ) {
cur = next;
get_all_resources(cur);
if( next = of_get_first_child(cur) )
continue;
if( next = of_get_next_sibling(cur) )
continue;
while( !next && cur != root ) {
cur = of_get_parent_node(cur);
next = of_get_next_sibling(cur);
}
if( cur == root )
break;
}
}If we added in a few tests in get_all_resources() to keep it from doing things which are obviously stupid (e.g. grabbing resources for nodes which have drivers we already have registered) that should work for any binding and could easily be extended to any resource type. We're already using linked lists to hold references to those resources, so there's no problems I can see here, other than adding some code.
Quoted 21 lines
Quoted 3 lines
I'm sure that as hardware diversifies, the other subsystems will grow in similar directions and eventually be dealt with using similarly generic code.
For regulators this already works very differently. As opposed to the clocks/clock-names type of binding it uses one where the consumer name of the regulator comes from the prefix of a -supply property. That is you'd get something like this:
foo-supply = <®1>; bar-supply = <®2>;And since you don't have enough information in the kernel simplefb driver to attach any meaning to these, the best you can do would be iterating over a range and have:
0-supply = <®0>; 1-supply = <®1>; ... n-supply = <®2>;
Quoted 4 lines
This is made more difficult by the fact that these regulators may be required by components not immediately related to the display engine. They could be for an attached panel, a video bridge or the +5V pin on the HDMI connector.
Surely an iterator could be constructed to go through each node and process every one named something like "*-supply"?
As for there being regulators for each separate part of the device, could we read what their current state is then maintain that state?
I'll admit that this is getting rather hairy at this point.
Finally, the clock subsystem has evolved away from "*-clock" bindings towards the current "clocks" and "clock-names" bindings. I'm sure other subsystems will follow.
Thanks,
Signature · 4 lines
Julian Calaby Email: julian.calaby at gmail.com Profile: http://www.google.com/profiles/julian.calaby/
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingQuoted 10 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Mon, Sep 29, 2014 at 10:06:39AM +0200, Thierry Reding wrote:
[...]
Quoted 7 lines
Quoted 6 lines
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
Quoted 6 lines
Quoted 2 lines
Which makes the whole even simpler, since the firmware already knows all about which clocks it had to enable.
It makes things very complicated in the firmware because it now needs to be able to generate DTB content that we would otherwise be able to do much easier with a text editor.
Didn't you just say that it was dynamically generated at runtime? So we can just ignore the "text editor" case.
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
If we start extending the binding with board-level details we end up duplicating the device tree node for the proper video device. Also note that it won't stop at clocks. Other setups will require regulators to be listed in this device tree node as well so that they don't get disabled at
late_initcall. And the regulator bindings don't provide a method to list an arbitrary number of clocks in a single property in the way that the clocks property works.There may be also resets involved. Fortunately the reset framework is minimalistic enough not to care about asserting all unused resets at
late_initcall. And other things like power domains may also need to be kept on.Passing in clock information via the device tree already requires a non- trivial amount of code in the firmware. A similar amount of code would be necessary for each type of resource that needs to be kept enabled. In addition to the above some devices may also require resources that have no generic bindings. That just doesn't scale.
The only reasonable thing for simplefb to do is not deal with any kind of resource at all (except perhaps area that contains the framebuffer memory).
Quoted 8 lines
Quoted 6 lines
You should really read that thread:
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-September/284726.htmlIt's quite interesting, because you'll see that:
A) Your approach, even on the platform you're working on, doesn't work. Or at least, isn't reliable.What platform exactly do you think I'm working on?
My bad, I thought it was a tegra SoC in there. I should have read more carefully obviously.
Quoted 2 lines
Why do you think what I proposed isn't going to work or be reliable? I don't see any arguments in the thread that would imply that.
The fact that it broke in the first place?
Quoted 4 lines
Quoted 2 lines
B) Other maintainers, precisely like Mark, came to the same conclusion than Mike.
Well, and others didn't.
We've been talking about both clocks and regulators up to now. I can see Mike and Mark both suggesting to use the usual clocks and regulators APIs, either in that thread or the one I pointed out.
Quoted 3 lines
Also I think if you read that thread and look at my proposal it matches exactly what was discussed as one of the solutions at one point in the thread.
I've seen it, and replied to that already.
Quoted 22 lines
Quoted 16 lines
Quoted 7 lines
So how about instead of requiring resources to be explicitly claimed we introduce something like the below patch? The intention being to give "firmware device" drivers a way of signalling to the clock framework that they need rely on clocks set up by firmware and when they no longer need them. This implements essentially what Mark (CC'ing again on this subthread) suggested earlier in this thread. Basically, it will allow drivers to determine the time when unused clocks are really unused. It
Quoted 8 lines
will of course only work when used correctly by drivers. For the case of simplefb I'd expect its .probe() implementation to call the new
clk_ignore_unused()function and once it has handed over control of the display hardware to the real driver it can callclk_unignore_unused()to signal that all unused clocks that it cares about have now been claimed. This is "reference counted" and can therefore be used by more than a single driver if necessary. Similar functionality could be added for other resource subsystems as needed.Quoted 3 lines
So, just to be clear, instead of doing a generic
clk_getandclk_prepare_enable, you're willing to do a just as much genericclk_ignore_unusedcall?Yes.
Quoted 8 lines
Quoted 1 line
How is that less generic?
It's more generic. That's the whole point.
The difference is that with the solution I proposed we don't have to keep track of all the resources. We know that firmware has set them up and we know that a real driver will properly take them over at some point
You keep saying that... and you know that you can't make this assumption.
Quoted 3 lines
so duplicating what the real driver does within the simplefb driver is just that, duplication. We don't allow duplication anywhere else in the kernel, why should simplefb be an exception?
Oh come on. Since when a clk_prepare_enable call is duplication?
If so, then we really have a duplication issue, and it's not just for the clock API.
Quoted 9 lines
Quoted 5 lines
You know that you are going to call that for regulator, reset, power domains, just as you would have needed to with the proper API, unless that with this kind of solution, you would have to modify *every* framework that might interact with any resource involved in getting simplefb running?
We have to add handling for every kind of resource either way. Also if this evolves into a common pattern we can easily wrap it up in a single function call.
Unless that in one case, we already have everything needed to handle everything properly, and in another, you keep hacking more and more into the involved frameworks.
Quoted 6 lines
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.If we need to prevent that, then that's something that could be fixed, too.
See, you keep hacking it more...
Quoted 3 lines
But both this and the other thread at least agree on the fact that simplefb is a shim driver that's going to be replaced by something real at some point
I think our definition of "at some point" diverges. Yours seem to be "at some point during the boot process", which might not even happen in some platforms (or at least in the foreseeable kernel releases).
Quoted 5 lines
so hopefully concurrent users aren't the problem because that would cause the real driver to break too.
Also note that if some other driver could call
clk_disable()it could just as easily callclk_set_rate()and break simplefb.
This is not true, see my other reply.
Quoted 5 lines
Furthermore isn't it a bug for a driver to call
clk_disable()before a precedingclk_enable()? There are patches being worked on that will enable per-user clocks and as I understand it they will specifically disallow drivers to disable the hardware clock if other drivers are still keeping them on via their own referenc.
It is, but I was talking about a clk_disable after a clk_enable.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/1cebdefc/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 14 lines · Maxime Ripard
Quoted 13 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Mon, Sep 29, 2014 at 10:06:39AM +0200, Thierry Reding wrote:
[...]
Quoted 9 lines
Quoted 6 lines
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
Which makes the whole even simpler, since the firmware already knows all about which clocks it had to enable.
Quoted 6 lines
Quoted 3 lines
It makes things very complicated in the firmware because it now needs to be able to generate DTB content that we would otherwise be able to do much easier with a text editor.
Didn't you just say that it was dynamically generated at runtime? So we can just ignore the "text editor" case.
Perhaps read the sentence again. I said "that we would *otherwise* be able to do much easier with a text editor.".
My point remains that there shouldn't be a need to generate DTB content of this complexity at all.
Quoted 4 lines
Quoted 2 lines
Why do you think what I proposed isn't going to work or be reliable? I don't see any arguments in the thread that would imply that.
The fact that it broke in the first place?
That's exactly the point. And it's going to break again and again as simplefb is extended with new things. Generally DT bindings should be backwards compatible. When extended they should provide a way to fall back to a reasonable default. There's simply no way you can do that with simplefb.
What happened in the Snow example is that regulators that were previously on would all of a sudden be automatically disabled on boot because there was now a driver that registered them with a generic framework.
The same thing is going to happen with simplefb for your device. If you later realize that you need a regulator to keep the panel going, you'll have to add code to your firmware to populate the corresponding properties, otherwise the regulator will end up unused and will be automatically disabled. At the same time you're going to break upstream for all users of your old firmware because it doesn't add that property yet.
And the same will continue to happen for every new type of resource you're going to add.
Quoted 26 lines
Quoted 26 lines
Quoted 16 lines
Quoted 7 lines
So how about instead of requiring resources to be explicitly claimed we introduce something like the below patch? The intention being to give "firmware device" drivers a way of signalling to the clock framework that they need rely on clocks set up by firmware and when they no longer need them. This implements essentially what Mark (CC'ing again on this subthread) suggested earlier in this thread. Basically, it will allow drivers to determine the time when unused clocks are really unused. It
Quoted 8 lines
will of course only work when used correctly by drivers. For the case of simplefb I'd expect its .probe() implementation to call the new
clk_ignore_unused()function and once it has handed over control of the display hardware to the real driver it can callclk_unignore_unused()to signal that all unused clocks that it cares about have now been claimed. This is "reference counted" and can therefore be used by more than a single driver if necessary. Similar functionality could be added for other resource subsystems as needed.Quoted 3 lines
So, just to be clear, instead of doing a generic
clk_getandclk_prepare_enable, you're willing to do a just as much genericclk_ignore_unusedcall?Yes.
Quoted 1 line
How is that less generic?
It's more generic. That's the whole point.
Quoted 7 lines
Quoted 4 lines
The difference is that with the solution I proposed we don't have to keep track of all the resources. We know that firmware has set them up and we know that a real driver will properly take them over at some point
You keep saying that... and you know that you can't make this assumption.
Why not? Are you really expecting to keep running with simplefb forever? Nobody is going to seriously use an upstream kernel in any product with only simplefb as a framebuffer. I've said before that this is a hack to get you working display. And that's all it is. If you want to do it properly go and write a DRM/KMS driver.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
You know that you are going to call that for regulator, reset, power domains, just as you would have needed to with the proper API, unless that with this kind of solution, you would have to modify *every* framework that might interact with any resource involved in getting simplefb running?
Quoted 7 lines
Quoted 3 lines
We have to add handling for every kind of resource either way. Also if this evolves into a common pattern we can easily wrap it up in a single function call.
Unless that in one case, we already have everything needed to handle everything properly, and in another, you keep hacking more and more into the involved frameworks.
This is a fundamental issue that we are facing and I'm trying to come up with a solution that is future-proof and will work for drivers other than simplefb.
Just because we currently lack this functionality doesn't make it a hack trying to add it.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Plus, speaking more specifically about the clocks, that won't prevent your clock to be shut down as a side effect of a later
clk_disablecall from another driver.If we need to prevent that, then that's something that could be fixed, too.
See, you keep hacking it more...
If you don't see this as a problem that exists beyond simplefb then I would of course not expect you to think that anything needs fixing.
Quoted 7 lines
Quoted 3 lines
But both this and the other thread at least agree on the fact that simplefb is a shim driver that's going to be replaced by something real at some point
I think our definition of "at some point" diverges. Yours seem to be "at some point during the boot process", which might not even happen in some platforms (or at least in the foreseeable kernel releases).
Then instead of hacking existing drivers to work on your particular platform you should start looking into hacking your platform drivers to cope with the lack of a proper display driver. Or alternatively spend the time getting a proper display driver merged.
Whether simplefb is used as primary framebuffer or just during only boot until hand-off to a real driver, it still remains a stop-gap solution.
Quoted 7 lines
Quoted 5 lines
so hopefully concurrent users aren't the problem because that would cause the real driver to break too.
Also note that if some other driver could call
clk_disable()it could just as easily callclk_set_rate()and break simplefb.This is not true, see my other reply.
If you mean that you could register a clock notifier to prevent clock changes, then that's going to lead to other drivers failing since they can now no longer set the rate that they need.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/be42a7b5/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 39 lines · Thierry Reding
Quoted 14 lines · Maxime Ripard
Quoted 13 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Mon, Sep 29, 2014 at 10:06:39AM +0200, Thierry Reding wrote:
[...]
Quoted 9 lines
Quoted 6 lines
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
Which makes the whole even simpler, since the firmware already knows all about which clocks it had to enable.
Quoted 6 lines
Quoted 3 lines
It makes things very complicated in the firmware because it now needs to be able to generate DTB content that we would otherwise be able to do much easier with a text editor.
Didn't you just say that it was dynamically generated at runtime? So we can just ignore the "text editor" case.
Perhaps read the sentence again. I said "that we would *otherwise* be able to do much easier with a text editor.".
My point remains that there shouldn't be a need to generate DTB content of this complexity at all.
Quoted 4 lines
Quoted 2 lines
Why do you think what I proposed isn't going to work or be reliable? I don't see any arguments in the thread that would imply that.
The fact that it broke in the first place?
That's exactly the point. And it's going to break again and again as simplefb is extended with new things. Generally DT bindings should be backwards compatible. When extended they should provide a way to fall back to a reasonable default. There's simply no way you can do that with simplefb.
Quoted 4 lines
What happened in the Snow example is that regulators that were previously on would all of a sudden be automatically disabled on boot because there was now a driver that registered them with a generic framework.
So what? You get a driver for regulators and suddenly find that nothing registered regulators because they were on all the time anyway and everything breaks? What a surprise!
Quoted 8 lines
The same thing is going to happen with simplefb for your device. If you later realize that you need a regulator to keep the panel going, you'll have to add code to your firmware to populate the corresponding properties, otherwise the regulator will end up unused and will be automatically disabled. At the same time you're going to break upstream for all users of your old firmware because it doesn't add that property yet.
Sure. And what can you do about that? It's not like the original Snow firmware writes anything of use to the DT at all. So to run a development kernel you need a development firmware. If you add new features to the kernel that involve intefacing to the firmware you need to update the firmware as well. Once support for Snow platform is stable you can expect that users can use a stable release of firmware indefinitely.
Quoted 3 lines
And the same will continue to happen for every new type of resource you're going to add.
The like 5 resource types, yes. Some of which may not even apply to simplefb.
Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 17 lines
Quoted 16 lines
So how about instead of requiring resources to be explicitly claimed we introduce something like the below patch? The intention being to give "firmware device" drivers a way of signalling to the clock framework that they need rely on clocks set up by firmware and when they no longer need them. This implements essentially what Mark (CC'ing again on this subthread) suggested earlier in this thread. Basically, it will allow drivers to determine the time when unused clocks are really unused. It will of course only work when used correctly by drivers. For the case of simplefb I'd expect its .probe() implementation to call the new
clk_ignore_unused()function and once it has handed over control of the display hardware to the real driver it can callclk_unignore_unused()to signal that all unused clocks that it cares about have now been claimed. This is "reference counted" and can therefore be used by more than a single driver if necessary. Similar functionality could be added for other resource subsystems as needed.Quoted 3 lines
So, just to be clear, instead of doing a generic
clk_getandclk_prepare_enable, you're willing to do a just as much genericclk_ignore_unusedcall?Yes.
Quoted 1 line
How is that less generic?
It's more generic. That's the whole point.
The difference is that with the solution I proposed we don't have to keep track of all the resources. We know that firmware has set them up and we know that a real driver will properly take them over at some point
Quoted 6 lines
Quoted 2 lines
You keep saying that... and you know that you can't make this assumption.
Why not? Are you really expecting to keep running with simplefb forever? Nobody is going to seriously use an upstream kernel in any product with only simplefb as a framebuffer. I've said before that this is a hack to
Why not? You can use shadowfb (software acceleration) with simplefb all right. Shadowfb is hands down the fastest video acceleration we have on anything but hardware that has _very_ slow CPU or that can run Intel UXA drivers. With manufacturers adding more and more superfluous cores to the CPUs shadowfb is actually not too stressing on the system, either.
On hardware like Allwinner A13 (single core) the use of shadowfb over actual video acceleration hardware has its benefits and drawbacks and is neither clearly better nor worse. The same hardware tends to have only one fixed video output - a tablet LCD panel. On such hardware modesetting is needless luxury if u-boot provides the simplfb bindings, at least for some use cases.
And there is still the use of simplefb during development and for generic distribution kernels. I prefer that during development of the KMS driver and during bootup before the KMS module becomes available the system behaves normally, not in special hacked way that is useless for anything but this special system mode. Worse, such special mode will not be regularly tested on well supported hardware and will likely bitrot and lead to mysterious issues at boot time when KMS is not available and this special system mode is in effect.
Quoted 13 lines
get you working display. And that's all it is. If you want to do it properly go and write a DRM/KMS driver.
Quoted 10 lines
Quoted 9 lines
Quoted 5 lines
You know that you are going to call that for regulator, reset, power domains, just as you would have needed to with the proper API, unless that with this kind of solution, you would have to modify *every* framework that might interact with any resource involved in getting simplefb running?
We have to add handling for every kind of resource either way. Also if this evolves into a common pattern we can easily wrap it up in a single function call.
Quoted 7 lines
Quoted 3 lines
Unless that in one case, we already have everything needed to handle everything properly, and in another, you keep hacking more and more into the involved frameworks.
This is a fundamental issue that we are facing and I'm trying to come up with a solution that is future-proof and will work for drivers other than simplefb.
How is proper resource management not going to work for drivers other than simplefb?
Thanks
Michal
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 40 lines · Michal Suchanek
Quoted 39 lines · Thierry Reding
Quoted 14 lines · Maxime Ripard
Quoted 13 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Mon, Sep 29, 2014 at 10:06:39AM +0200, Thierry Reding wrote:
[...]
Quoted 9 lines
Quoted 6 lines
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
Which makes the whole even simpler, since the firmware already knows all about which clocks it had to enable.
Quoted 6 lines
Quoted 3 lines
It makes things very complicated in the firmware because it now needs to be able to generate DTB content that we would otherwise be able to do much easier with a text editor.
Didn't you just say that it was dynamically generated at runtime? So we can just ignore the "text editor" case.
Perhaps read the sentence again. I said "that we would *otherwise* be able to do much easier with a text editor.".
My point remains that there shouldn't be a need to generate DTB content of this complexity at all.
Quoted 4 lines
Quoted 2 lines
Why do you think what I proposed isn't going to work or be reliable? I don't see any arguments in the thread that would imply that.
The fact that it broke in the first place?
That's exactly the point. And it's going to break again and again as simplefb is extended with new things. Generally DT bindings should be backwards compatible. When extended they should provide a way to fall back to a reasonable default. There's simply no way you can do that with simplefb.
Quoted 8 lines
Quoted 4 lines
What happened in the Snow example is that regulators that were previously on would all of a sudden be automatically disabled on boot because there was now a driver that registered them with a generic framework.
So what? You get a driver for regulators and suddenly find that nothing registered regulators because they were on all the time anyway and everything breaks? What a surprise!
I agree, this is not a surprise at all. But like I pointed out this is bound to happen again and again. So how about we learn from it and add the functionality needed to prevent it from happening?
Quoted 8 lines
Quoted 7 lines
The same thing is going to happen with simplefb for your device. If you later realize that you need a regulator to keep the panel going, you'll have to add code to your firmware to populate the corresponding properties, otherwise the regulator will end up unused and will be automatically disabled. At the same time you're going to break upstream for all users of your old firmware because it doesn't add that property yet.
Quoted 7 lines
Sure. And what can you do about that? It's not like the original Snow firmware writes anything of use to the DT at all. So to run a development kernel you need a development firmware. If you add new features to the kernel that involve intefacing to the firmware you need to update the firmware as well. Once support for Snow platform is stable you can expect that users can use a stable release of firmware indefinitely.
Feel free to take that up with the DT ABI stability committee.
Quoted 4 lines
Quoted 2 lines
And the same will continue to happen for every new type of resource you're going to add.
The like 5 resource types, yes. Some of which may not even apply to simplefb.
Today it's 5, tomorrow 6, next year, who knows.
Quoted 45 lines
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
Quoted 16 lines
Quoted 7 lines
So how about instead of requiring resources to be explicitly claimed we introduce something like the below patch? The intention being to give "firmware device" drivers a way of signalling to the clock framework that they need rely on clocks set up by firmware and when they no longer need them. This implements essentially what Mark (CC'ing again on this subthread) suggested earlier in this thread. Basically, it will allow drivers to determine the time when unused clocks are really unused. It
Quoted 8 lines
will of course only work when used correctly by drivers. For the case of simplefb I'd expect its .probe() implementation to call the new
clk_ignore_unused()function and once it has handed over control of the display hardware to the real driver it can callclk_unignore_unused()to signal that all unused clocks that it cares about have now been claimed. This is "reference counted" and can therefore be used by more than a single driver if necessary. Similar functionality could be added for other resource subsystems as needed.Quoted 3 lines
So, just to be clear, instead of doing a generic
clk_getandclk_prepare_enable, you're willing to do a just as much genericclk_ignore_unusedcall?Yes.
Quoted 1 line
How is that less generic?
It's more generic. That's the whole point.
The difference is that with the solution I proposed we don't have to keep track of all the resources. We know that firmware has set them up and we know that a real driver will properly take them over at some point
Quoted 6 lines
Quoted 2 lines
You keep saying that... and you know that you can't make this assumption.
Why not? Are you really expecting to keep running with simplefb forever? Nobody is going to seriously use an upstream kernel in any product with only simplefb as a framebuffer. I've said before that this is a hack to
Why not? You can use shadowfb (software acceleration) with simplefb all right. Shadowfb is hands down the fastest video acceleration we have on anything but hardware that has _very_ slow CPU or that can run Intel UXA drivers. With manufacturers adding more and more superfluous cores to the CPUs shadowfb is actually not too stressing on the system, either.
Quoted 6 lines
On hardware like Allwinner A13 (single core) the use of shadowfb over actual video acceleration hardware has its benefits and drawbacks and is neither clearly better nor worse. The same hardware tends to have only one fixed video output - a tablet LCD panel. On such hardware modesetting is needless luxury if u-boot provides the simplfb bindings, at least for some use cases.
I presume some of those tablets will have HDMI connectors. And surely somebody will eventually put an Allwinner SoC into something that's not a tablet.
Note also that with only simplefb you won't be able to use any kind of hardware acceleration, not even 3D. Perhaps you could even pull it off but certainly not with any kind of double-buffering, so while it might be an easy way to get something to display, please stop pretending that DRM/KMS don't matter.
Also this is all hypothetical since Luc said himself that he's already working on a DRM/KMS driver.
Quoted 2 lines
And there is still the use of simplefb during development and for generic distribution kernels.
Generic distribution kernels can use DRM/KMS just fine. And they also want to use it because it gives them a lot of advanced features using a standard API.
Quoted 7 lines
I prefer that during development of the
KMS driver and during bootup before the KMS module becomes available the system behaves normally, not in special hacked way that is useless for anything but this special system mode. Worse, such special mode will not be regularly tested on well supported hardware and will likely bitrot and lead to mysterious issues at boot time when KMS is not available and this special system mode is in effect.
It's not at all special or hacked. It merely uses a couple of assumptions that differ from what you might expect from a regular driver. And that's really the essence of simplefb.
Quoted 17 lines
Quoted 17 lines
get you working display. And that's all it is. If you want to do it properly go and write a DRM/KMS driver.
Quoted 13 lines
Quoted 9 lines
Quoted 5 lines
You know that you are going to call that for regulator, reset, power domains, just as you would have needed to with the proper API, unless that with this kind of solution, you would have to modify *every* framework that might interact with any resource involved in getting simplefb running?
We have to add handling for every kind of resource either way. Also if this evolves into a common pattern we can easily wrap it up in a single function call.
Unless that in one case, we already have everything needed to handle everything properly, and in another, you keep hacking more and more into the involved frameworks.
Quoted 6 lines
Quoted 3 lines
This is a fundamental issue that we are facing and I'm trying to come up with a solution that is future-proof and will work for drivers other than simplefb.
How is proper resource management not going to work for drivers other than simplefb?
I have no doubt that it's going to work. It already does. But unless we solve this at the core we'll be reiterating this for every new type of resource that we need to support and for every other driver of the same nature (i.e. uses a "virtual" device set up by firmware).
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/d541b228/attachment-0001.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 70 lines · Thierry Reding
Quoted 40 lines · Michal Suchanek
Quoted 39 lines · Thierry Reding
Quoted 14 lines · Maxime Ripard
Quoted 13 lines · Thierry Reding
Quoted 1 line · Maxime Ripard
On Mon, Sep 29, 2014 at 10:06:39AM +0200, Thierry Reding wrote:
[...]
Quoted 9 lines
Quoted 6 lines
simplefb doesn't deal at all with hardware details. It simply uses what firmware has set up, which is the only reason why it will work for many people. What is passed in via its device tree node is the minimum amount of information needed to draw something into the framebuffer. Also note that the simplefb device tree node is not statically added to a DTS file but needs to be dynamically generated by firmware at runtime.
Which makes the whole even simpler, since the firmware already knows all about which clocks it had to enable.
Quoted 6 lines
Quoted 3 lines
It makes things very complicated in the firmware because it now needs to be able to generate DTB content that we would otherwise be able to do much easier with a text editor.
Didn't you just say that it was dynamically generated at runtime? So we can just ignore the "text editor" case.
Perhaps read the sentence again. I said "that we would *otherwise* be able to do much easier with a text editor.".
My point remains that there shouldn't be a need to generate DTB content of this complexity at all.
Quoted 4 lines
Quoted 2 lines
Why do you think what I proposed isn't going to work or be reliable? I don't see any arguments in the thread that would imply that.
The fact that it broke in the first place?
That's exactly the point. And it's going to break again and again as simplefb is extended with new things. Generally DT bindings should be backwards compatible. When extended they should provide a way to fall back to a reasonable default. There's simply no way you can do that with simplefb.
Quoted 8 lines
Quoted 4 lines
What happened in the Snow example is that regulators that were previously on would all of a sudden be automatically disabled on boot because there was now a driver that registered them with a generic framework.
So what? You get a driver for regulators and suddenly find that nothing registered regulators because they were on all the time anyway and everything breaks? What a surprise!
I agree, this is not a surprise at all. But like I pointed out this is bound to happen again and again. So how about we learn from it and add the functionality needed to prevent it from happening?
Quoted 8 lines
Quoted 7 lines
The same thing is going to happen with simplefb for your device. If you later realize that you need a regulator to keep the panel going, you'll have to add code to your firmware to populate the corresponding properties, otherwise the regulator will end up unused and will be automatically disabled. At the same time you're going to break upstream for all users of your old firmware because it doesn't add that property yet.
Quoted 7 lines
Sure. And what can you do about that? It's not like the original Snow firmware writes anything of use to the DT at all. So to run a development kernel you need a development firmware. If you add new features to the kernel that involve intefacing to the firmware you need to update the firmware as well. Once support for Snow platform is stable you can expect that users can use a stable release of firmware indefinitely.
Quoted 1 line
Feel free to take that up with the DT ABI stability committee.
As pointed out you can also generate by hand a DT that exactly describes what the preinstalled firmware sets up - so long as the preinstalled firmware sets upa any usable framebuffer at all and always sets up the same thing. If the preinstalled firmware can set up the framebuffer in different ways and is not willing to communicate to the kernel in what way it set up the framebuffer then it is unusable with simplefb. That sucks but there is no way around that.
Quoted 11 lines
Quoted 11 lines
Quoted 3 lines
Why not? Are you really expecting to keep running with simplefb forever? Nobody is going to seriously use an upstream kernel in any product with only simplefb as a framebuffer. I've said before that this is a hack to
Why not? You can use shadowfb (software acceleration) with simplefb all right. Shadowfb is hands down the fastest video acceleration we have on anything but hardware that has _very_ slow CPU or that can run Intel UXA drivers. With manufacturers adding more and more superfluous cores to the CPUs shadowfb is actually not too stressing on the system, either.
Quoted 8 lines
Quoted 6 lines
On hardware like Allwinner A13 (single core) the use of shadowfb over actual video acceleration hardware has its benefits and drawbacks and is neither clearly better nor worse. The same hardware tends to have only one fixed video output - a tablet LCD panel. On such hardware modesetting is needless luxury if u-boot provides the simplfb bindings, at least for some use cases.
I presume some of those tablets will have HDMI connectors. And surely
Nope. Only 1 output.
Quoted 2 lines
somebody will eventually put an Allwinner SoC into something that's not a tablet.
Sure. And you might want to bother with modesetting then.
Quoted 3 lines
Note also that with only simplefb you won't be able to use any kind of hardware acceleration, not even 3D. Perhaps you could even pull it off
Nope. I won't be able to use that staggering performance of 1 hardware shader.
But my UI will draw really fast unless I want those wobbly windows. Now who cares about wobbliness when you want to run everything fullscreen anyway to get the most of the 480p screen estate.
Quoted 3 lines
but certainly not with any kind of double-buffering, so while it might be an easy way to get something to display, please stop pretending that DRM/KMS don't matter.
Yes, it will matter for 3d and might matter for video acceleration as well.
But will not matter for using a terminal emulator or reading a book.
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
You know that you are going to call that for regulator, reset, power domains, just as you would have needed to with the proper API, unless that with this kind of solution, you would have to modify *every* framework that might interact with any resource involved in getting simplefb running?
Quoted 7 lines
Quoted 3 lines
We have to add handling for every kind of resource either way. Also if this evolves into a common pattern we can easily wrap it up in a single function call.
Unless that in one case, we already have everything needed to handle everything properly, and in another, you keep hacking more and more into the involved frameworks.
This is a fundamental issue that we are facing and I'm trying to come up with a solution that is future-proof and will work for drivers other than simplefb.
Quoted 7 lines
Quoted 2 lines
How is proper resource management not going to work for drivers other than simplefb?
I have no doubt that it's going to work. It already does. But unless we solve this at the core we'll be reiterating this for every new type of resource that we need to support and for every other driver of the same nature (i.e. uses a "virtual" device set up by firmware).
Once it's solved for every resource every 'virtual' driver will work the same way.
I do not see a problem here.
Thanks
Michal
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
In reply to Thierry RedingQuoted 4 lines · Thierry Reding
What happened in the Snow example is that regulators that were previously on would all of a sudden be automatically disabled on boot because there was now a driver that registered them with a generic framework.
Not quite - there was also DT added for them. With just the driver the regulator API shouldn't have touched them, it'd just have exposed them read only.
Quoted 10 lines
The same thing is going to happen with simplefb for your device. If you later realize that you need a regulator to keep the panel going, you'll have to add code to your firmware to populate the corresponding properties, otherwise the regulator will end up unused and will be automatically disabled. At the same time you're going to break upstream for all users of your old firmware because it doesn't add that property yet.
And the same will continue to happen for every new type of resource you're going to add.
So long as we're ensuring that when we don't start supporting resources without DT additions or at least require DT additions to actively manage them (which can then include simplefb hookup) we should be fine.
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
The difference is that with the solution I proposed we don't have to keep track of all the resources. We know that firmware has set them up and we know that a real driver will properly take them over at some point
Quoted 8 lines
Quoted 2 lines
You keep saying that... and you know that you can't make this assumption.
Why not? Are you really expecting to keep running with simplefb forever? Nobody is going to seriously use an upstream kernel in any product with only simplefb as a framebuffer. I've said before that this is a hack to get you working display. And that's all it is. If you want to do it properly go and write a DRM/KMS driver.
Well, for product probably not. But in terms of the runtime of a kernel
I'd not be so sure - people do dogfood and we should be allowing that.
I've used unaccelerated displays with reasonable success for a large
part of my work in the past.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140929/946d1de9/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 1 line · Mark Brown
On Mon, Sep 29, 2014 at 03:47:15PM +0200, Thierry Reding wrote:
[...]
Quoted 8 lines
Quoted 7 lines
The same thing is going to happen with simplefb for your device. If you later realize that you need a regulator to keep the panel going, you'll have to add code to your firmware to populate the corresponding properties, otherwise the regulator will end up unused and will be automatically disabled. At the same time you're going to break upstream for all users of your old firmware because it doesn't add that property yet.
Quoted 6 lines
Quoted 2 lines
And the same will continue to happen for every new type of resource you're going to add.
So long as we're ensuring that when we don't start supporting resources without DT additions or at least require DT additions to actively manage them (which can then include simplefb hookup) we should be fine.
I'm not sure I understand what you mean. If we add a driver for the PMIC that exposes these regulators and then add a DT node for the PMIC, we'd still need to fix the firmware to generate the appropriate DT properties to allow simplefb to enable the regulators.
So unless firmware is updated at the same time, regulators will get disabled because they are unused.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140930/4f9e4be0/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 10 lines · Thierry Reding
Quoted 3 lines · Mark Brown
So long as we're ensuring that when we don't start supporting resources without DT additions or at least require DT additions to actively manage them (which can then include simplefb hookup) we should be fine.
I'm not sure I understand what you mean. If we add a driver for the PMIC that exposes these regulators and then add a DT node for the PMIC, we'd still need to fix the firmware to generate the appropriate DT properties to allow simplefb to enable the regulators.
No, you don't. It's only if you start describing the regulators in the PMIC in DT that you run into problems. Unconfigured regulators won't be touched.
Quoted 2 lines
So unless firmware is updated at the same time, regulators will get disabled because they are unused.
That won't happen unless the regulators are explicitly described, if
they are described as unused then this will of course happen.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140930/a8cd1e73/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 7 lines · Mark Brown
Quoted 5 lines · Thierry Reding
Quoted 3 lines · Mark Brown
So long as we're ensuring that when we don't start supporting resources without DT additions or at least require DT additions to actively manage them (which can then include simplefb hookup) we should be fine.
Quoted 8 lines
Quoted 4 lines
I'm not sure I understand what you mean. If we add a driver for the PMIC that exposes these regulators and then add a DT node for the PMIC, we'd still need to fix the firmware to generate the appropriate DT properties to allow simplefb to enable the regulators.
No, you don't. It's only if you start describing the regulators in the PMIC in DT that you run into problems. Unconfigured regulators won't be touched.
Okay, that's what I meant. It seems rather odd to add a PMIC DT node but omit the description of the regulators that it exposes. Unless the regulators are truly unused, as in not connected to any peripherals.
Quoted 5 lines
Quoted 2 lines
So unless firmware is updated at the same time, regulators will get disabled because they are unused.
That won't happen unless the regulators are explicitly described, if they are described as unused then this will of course happen.
With described as unused you mean they have a node in DT, so constraints are applied and all that, but no driver actually uses them?
The fundamental issue is that if we start describing simplefb nodes with an incomplete set of resources then we're bound to run into problems where it'll break once these new resources are described in the DTS. If the simplefb node was described in the DTS then this would be less of a problem because the resources could be added to the simplefb node at the same time.
However given that simplefb is supposed to be generated by firmware this is no longer possible. It will inevitably break unless you upgrade the DTB and the firmware at the same time. And it was already decided long ago that upgrading the firmware should never be a requirement for keeping things working.
I don't see any way to prevent that other than ignoring the resources in simplefb completely.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141001/fa5ec5f8/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 13 lines · Thierry Reding
Quoted 12 lines · Mark Brown
Quoted 10 lines · Thierry Reding
Quoted 3 lines · Mark Brown
So long as we're ensuring that when we don't start supporting resources without DT additions or at least require DT additions to actively manage them (which can then include simplefb hookup) we should be fine.
I'm not sure I understand what you mean. If we add a driver for the PMIC that exposes these regulators and then add a DT node for the PMIC, we'd still need to fix the firmware to generate the appropriate DT properties to allow simplefb to enable the regulators.
Quoted 8 lines
Quoted 3 lines
No, you don't. It's only if you start describing the regulators in the PMIC in DT that you run into problems. Unconfigured regulators won't be touched.
Okay, that's what I meant. It seems rather odd to add a PMIC DT node but omit the description of the regulators that it exposes. Unless the regulators are truly unused, as in not connected to any peripherals.
Agreed, I added similar PMIC support to other Chromebooks (Peach Pit and Pi) DTS and for me it made totally sense to add nodes for all the regulators that are connected to peripherals according to the board schematic. Specially since the framework is smart enough to disable any regulator that is not used.
After all, a DT is meant to describe the hardware, so how can possibly be an issue to add more details about the hw in a DTS?
If something is working relying on parts of the hw on not being described, then is essentially relying on side-effects and implementation details which are bound to be broken anyways.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
So unless firmware is updated at the same time, regulators will get disabled because they are unused.
That won't happen unless the regulators are explicitly described, if they are described as unused then this will of course happen.
With described as unused you mean they have a node in DT, so constraints are applied and all that, but no driver actually uses them?
Adding your resources (clock, regulators, etc) incrementally and only when the driver for the device that use these resources is available, will only make adding support for a new platform slower IMHO since there will be more patches to be posted, reviewed and merged.
Quoted 7 lines
The fundamental issue is that if we start describing simplefb nodes with an incomplete set of resources then we're bound to run into problems where it'll break once these new resources are described in the DTS. If the simplefb node was described in the DTS then this would be less of a problem because the resources could be added to the simplefb node at the same time.
Agreed, the assumptions made by simplefb are quite fragile so we should either document somewhere that simplefb ignores all the resources and that is a best effort so users should not consider the display breaking a regression or make it robust enough so users can expect that it will always work.
Just adding the clocks is a partial solution which I think will make the situation even worst since it will give a false illusion of robustness but as you said it will break anyways due other resources.
Quoted 6 lines
However given that simplefb is supposed to be generated by firmware this is no longer possible. It will inevitably break unless you upgrade the DTB and the firmware at the same time. And it was already decided long ago that upgrading the firmware should never be a requirement for keeping things working.
AFAICT in practice most platforms' firmware do not generate the simplefb by default. In the case of Chromebooks for example, a custom U-boot needs to be flashed in order to have simplefb support. In fact most people working on mainline support for Chromebooks do not use simplefb and that is why the issue was not spot when adding the support for clocks and regulators.
Personally I didn't even know how simplefb worked before Will reported that his display used to work on Snow before 3.16. So I assume that his reasonable to expect that users using simplefb are able to update their bootloader.
Which brings a more general question about DT and backward compatibility. Should we have backward compatibility only with the official firmware that is ship on a device when is bought or should we maintain backward compatibility against any firmware out there that someone re-built and added logic to mangle the FDT before is passed to the kernel?
Going back to simplefb, I think the fact that the simplefb is not in the DTS is the fundamental issue here. For me, the most reasonable approach to solve this is the one suggested by Doug Anderson. That is to have the simplefb node in the DTS so all the references to the resources it uses can be added in the DTS but keep the simplefb node as status = "disabled".
The bootloader can find the simplefb node and fill all the information about the framebuffer memory region (location and size, width, height, format, etc) and also enable the node by setting the status to "okay" so the simplefb driver will be probed.
If a FDT does not have a simplefb node then the boot loader can create one (like is made for the /choosen node in most bootloaders) and make it a best effort in that case, assuming that all the resources enabled by the bootloader will remain enabled once the kernel boots.
This of course will require users to update their boot-loaders but as stated above I think that is reasonable since anyone using simplefb is using a non-official firmware anyways.
Quoted 5 lines
I don't see any way to prevent that other than ignoring the resources in simplefb completely.
Thierry
Best regards,
Javier
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 12 lines · Javier Martinez Canillas
Quoted 3 lines · Thierry Reding
Okay, that's what I meant. It seems rather odd to add a PMIC DT node but omit the description of the regulators that it exposes. Unless the regulators are truly unused, as in not connected to any peripherals.
Agreed, I added similar PMIC support to other Chromebooks (Peach Pit and Pi) DTS and for me it made totally sense to add nodes for all the regulators that are connected to peripherals according to the board schematic. Specially since the framework is smart enough to disable any regulator that is not used.
Quoted 6 lines
After all, a DT is meant to describe the hardware, so how can possibly be an issue to add more details about the hw in a DTS?
If something is working relying on parts of the hw on not being described, then is essentially relying on side-effects and implementation details which are bound to be broken anyways.
It's not a problem to describe the hardware, it's a problem to describe the hardware inaccurately. If you add something and explicitly tell the kernel that nothing needs it then it shouldn't be a surprise that it gets turned off.
Quoted 7 lines
Quoted 2 lines
With described as unused you mean they have a node in DT, so constraints are applied and all that, but no driver actually uses them?
Adding your resources (clock, regulators, etc) incrementally and only when the driver for the device that use these resources is available, will only make adding support for a new platform slower IMHO since there will be more patches to be posted, reviewed and merged.
So don't do that if you're worried about it then, provide the bits of DT
that hook everything up from the start or otherwise describe things as
being in use.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141001/074750a5/attachment.sig>
[linux-sunxi] Re: [PATCH 4/4] simplefb: add clock handling code
Quoted 1 line · Mark Brown
On Wed, Oct 01, 2014 at 01:10:46PM +0200, Javier Martinez Canillas wrote:
[...]
Quoted 8 lines
Quoted 4 lines
Adding your resources (clock, regulators, etc) incrementally and only when the driver for the device that use these resources is available, will only make adding support for a new platform slower IMHO since there will be more patches to be posted, reviewed and merged.
So don't do that if you're worried about it then, provide the bits of DT that hook everything up from the start or otherwise describe things as being in use.
"Otherwise describe things as being in use" doesn't work for clocks for example. And Mike already said he wasn't willing to add something like an always-on DT property for clocks.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20141001/d3972a47/attachment.sig>