pinctrl: tegra: Move drivers registration to arch_init level
Subsystems (3)
PATCH 1/2 pinctrl: tegra: Move drivers registration to arch_init level
There is a bug in regards to deferred probing within the drivers core that causes GPIO-driver to suspend after its users. The bug appears if GPIO-driver probe is getting deferred, which happens after introducing dependency on PINCTRL-driver for the GPIO-driver by defining "gpio-ranges" property in device-tree. The bug in the drivers core is old (more than 4 years now) and is well known, unfortunately there is no easy fix for it. The good news is that we can workaround the deferred probe issue by changing GPIO / PINCTRL drivers registration order and hence by moving PINCTRL driver registration to the arch_init level and GPIO to the subsys_init.
--- drivers/pinctrl/tegra/pinctrl-tegra114.c | 7 ++++++- drivers/pinctrl/tegra/pinctrl-tegra124.c | 7 ++++++- drivers/pinctrl/tegra/pinctrl-tegra20.c | 7 ++++++- drivers/pinctrl/tegra/pinctrl-tegra210.c | 7 ++++++- drivers/pinctrl/tegra/pinctrl-tegra30.c | 7 ++++++- 5 files changed, 30 insertions(+), 5 deletions(-)
drivers/pinctrl/tegra/pinctrl-tegra114.c +6 -1
@@ -1868,4 +1868,9 @@ static struct platform_driver tegra114_pinctrl_driver = { }, .probe = tegra114_pinctrl_probe, }; -builtin_platform_driver (tegra114_pinctrl_driver); + +static int __init tegra114_pinctrl_init (void ) +{ +return platform_driver_register (&tegra114_pinctrl_driver); +} +arch_initcall (tegra114_pinctrl_init);
drivers/pinctrl/tegra/pinctrl-tegra124.c +6 -1
@@ -2080,4 +2080,9 @@ static struct platform_driver tegra124_pinctrl_driver = { }, .probe = tegra124_pinctrl_probe, }; -builtin_platform_driver (tegra124_pinctrl_driver); + +static int __init tegra124_pinctrl_init (void ) +{ +return platform_driver_register (&tegra124_pinctrl_driver); +} +arch_initcall (tegra124_pinctrl_init);
drivers/pinctrl/tegra/pinctrl-tegra20.c +6 -1
@@ -2277,4 +2277,9 @@ static struct platform_driver tegra20_pinctrl_driver = { }, .probe = tegra20_pinctrl_probe, }; -builtin_platform_driver (tegra20_pinctrl_driver); + +static int __init tegra20_pinctrl_init (void ) +{ +return platform_driver_register (&tegra20_pinctrl_driver); +} +arch_initcall (tegra20_pinctrl_init);
drivers/pinctrl/tegra/pinctrl-tegra210.c +6 -1
@@ -1582,4 +1582,9 @@ static struct platform_driver tegra210_pinctrl_driver = { }, .probe = tegra210_pinctrl_probe, }; -builtin_platform_driver (tegra210_pinctrl_driver); + +static int __init tegra210_pinctrl_init (void ) +{ +return platform_driver_register (&tegra210_pinctrl_driver); +} +arch_initcall (tegra210_pinctrl_init);
drivers/pinctrl/tegra/pinctrl-tegra30.c +6 -1
@@ -2503,4 +2503,9 @@ static struct platform_driver tegra30_pinctrl_driver = { }, .probe = tegra30_pinctrl_probe, }; -builtin_platform_driver (tegra30_pinctrl_driver); + +static int __init tegra30_pinctrl_init (void ) +{ +return platform_driver_register (&tegra30_pinctrl_driver); +} +arch_initcall (tegra30_pinctrl_init);
Signature · 1 line
2.18.0
PATCH 2/2 gpio: tegra: Move driver registration to subsys_init level
There is a bug in regards to deferred probing within the drivers core that causes GPIO-driver to suspend after its users. The bug appears if GPIO-driver probe is getting deferred, which happens after introducing dependency on PINCTRL-driver for the GPIO-driver by defining "gpio-ranges" property in device-tree. The bug in the drivers core is old (more than 4 years now) and is well known, unfortunately there is no easy fix for it. The good news is that we can workaround the deferred probe issue by changing GPIO / PINCTRL drivers registration order and hence by moving PINCTRL driver registration to the arch_init level and GPIO to the subsys_init.
--- drivers/gpio/gpio-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-tegra.c +1 -1
@@ -712,4 +712,4 @@ static int __init tegra_gpio_init(void) {return platform_driver_register (&tegra_gpio_driver); } -postcore_initcall (tegra_gpio_init); +subsys_initcall (tegra_gpio_init);
Signature · 1 line
2.18.0
Quoted 10 lines · Dmitry Osipenko
There is a bug in regards to deferred probing within the drivers core that causes GPIO-driver to suspend after its users. The bug appears if GPIO-driver probe is getting deferred, which happens after introducing dependency on PINCTRL-driver for the GPIO-driver by defining "gpio-ranges" property in device-tree. The bug in the drivers core is old (more than 4 years now) and is well known, unfortunately there is no easy fix for it. The good news is that we can workaround the deferred probe issue by changing GPIO / PINCTRL drivers registration order and hence by moving PINCTRL driver registration to the
arch_initlevel and GPIO to thesubsys_init.
A while back at least using those init lists were not well received even for GPIO/pinctrl drivers:
I still think we should make an exception for GPIO/pinctrl and use earlier initcalls. Platform GPIO/pinctrl drivers provide basic infrastructure often used by many other drivers, we want to have them loaded early. It avoids unnecessary EPROBE_DEFER and hence probably even boots faster.
And in this case it even resolves real world issues.
This should definitely go in, at least as a stop gap solution.
--
Stefan
Quoted 90 lines
Signed-off-by Dmitry Osipenko <[email protected]>--- drivers/pinctrl/tegra/pinctrl-tegra114.c | 7 ++++++- drivers/pinctrl/tegra/pinctrl-tegra124.c | 7 ++++++- drivers/pinctrl/tegra/pinctrl-tegra20.c | 7 ++++++- drivers/pinctrl/tegra/pinctrl-tegra210.c | 7 ++++++- drivers/pinctrl/tegra/pinctrl-tegra30.c | 7 ++++++- 5 files changed, 30 insertions(+), 5 deletions(-)drivers/pinctrl/tegra/pinctrl-tegra114.c +6
-1@@ -1868,4 +1868,9 @@ static struct platform_driver tegra114_pinctrl_driver = { }, .probe = tegra114_pinctrl_probe, }; -builtin_platform_driver (tegra114_pinctrl_driver); + +static int __init tegra114_pinctrl_init (void ) +{ +return platform_driver_register (&tegra114_pinctrl_driver); +} +arch_initcall (tegra114_pinctrl_init);drivers/pinctrl/tegra/pinctrl-tegra124.c +6
-1@@ -2080,4 +2080,9 @@ static struct platform_driver tegra124_pinctrl_driver = { }, .probe = tegra124_pinctrl_probe, }; -builtin_platform_driver (tegra124_pinctrl_driver); + +static int __init tegra124_pinctrl_init (void ) +{ +return platform_driver_register (&tegra124_pinctrl_driver); +} +arch_initcall (tegra124_pinctrl_init);drivers/pinctrl/tegra/pinctrl-tegra20.c +6
-1@@ -2277,4 +2277,9 @@ static struct platform_driver tegra20_pinctrl_driver = { }, .probe = tegra20_pinctrl_probe, }; -builtin_platform_driver (tegra20_pinctrl_driver); + +static int __init tegra20_pinctrl_init (void ) +{ +return platform_driver_register (&tegra20_pinctrl_driver); +} +arch_initcall (tegra20_pinctrl_init);drivers/pinctrl/tegra/pinctrl-tegra210.c +6
-1@@ -1582,4 +1582,9 @@ static struct platform_driver tegra210_pinctrl_driver = { }, .probe = tegra210_pinctrl_probe, }; -builtin_platform_driver (tegra210_pinctrl_driver); + +static int __init tegra210_pinctrl_init (void ) +{ +return platform_driver_register (&tegra210_pinctrl_driver); +} +arch_initcall (tegra210_pinctrl_init);drivers/pinctrl/tegra/pinctrl-tegra30.c +6
-1@@ -2503,4 +2503,9 @@ static struct platform_driver tegra30_pinctrl_driver = { }, .probe = tegra30_pinctrl_probe, }; -builtin_platform_driver (tegra30_pinctrl_driver); + +static int __init tegra30_pinctrl_init (void ) +{ +return platform_driver_register (&tegra30_pinctrl_driver); +} +arch_initcall (tegra30_pinctrl_init);
Quoted 2 lines · On Thursday, 2 August 2018 14:11:43 MSK Dmitry Osipenko wrote:
There is a bug in regards to deferred probing within the drivers core that causes GPIO-driver to suspend after its users. The bug appears if
I meant "before its users", of course. If the rest of the patches is fine, please let me know if re-sending is needed or you'll correct the comment in place while applying.
Quoted 10 lines
GPIO-driver probe is getting deferred, which happens after introducing dependency on PINCTRL-driver for the GPIO-driver by defining "gpio-ranges" property in device-tree. The bug in the drivers core is old (more than 4 years now) and is well known, unfortunately there is no easy fix for it. The good news is that we can workaround the deferred probe issue by changing GPIO / PINCTRL drivers registration order and hence by moving PINCTRL driver registration to the
arch_initlevel and GPIO to thesubsys_init.Signed-off-by Dmitry Osipenko <[email protected]>
Quoted 11 lines · Dmitry Osipenko
There is a bug in regards to deferred probing within the drivers core that causes GPIO-driver to suspend after its users. The bug appears if GPIO-driver probe is getting deferred, which happens after introducing dependency on PINCTRL-driver for the GPIO-driver by defining "gpio-ranges" property in device-tree. The bug in the drivers core is old (more than 4 years now) and is well known, unfortunately there is no easy fix for it. The good news is that we can workaround the deferred probe issue by changing GPIO / PINCTRL drivers registration order and hence by moving PINCTRL driver registration to the
arch_initlevel and GPIO to thesubsys_init.
Quoted 1 line
Signed-off-by Dmitry Osipenko <[email protected]>
Patch applied with Stefan's ACK.
Yours,
Linus Walleij
Quoted 4 lines · Stefan Agner
A while back at least using those init lists were not well received even for GPIO/pinctrl drivers:
You shouldn't listen too much to that guy he's not trustworthy.
Quoted 5 lines
I still think we should make an exception for GPIO/pinctrl and use earlier initcalls. Platform GPIO/pinctrl drivers provide basic infrastructure often used by many other drivers, we want to have them loaded early. It avoids unnecessary
EPROBE_DEFERand hence probably even boots faster.
When we have the pin control and GPIO at different initlevels it makes me uneasy because I feel we have implicit init dependencies that seem more than a little fragile.
My recent thinking has involved the component method used in DRM drivers such as drivers/gpu/drm/vc4/vc4_drv.c where a few different component subdrivers are linked together at bind time (not probe time!) into a master component.
Rob was no big fan of this but the DRM people like it and I was thinking to make a try at it.
This way we could at least probe and bind the pin control and GPIO drivers at the *same* initlevel and express the dependencies between them somewhat.
Quoted 1 line
This should definitely go in, at least as a stop gap solution.
Agreed. (And patch applied.)
Yours,
Linus Walleij
Quoted 14 lines · On Friday, 3 August 2018 20:24:56 MSK Linus Walleij wrote:
Quoted 5 lines · Stefan Agner
A while back at least using those init lists were not well received even for GPIO/pinctrl drivers:
https://lore.kernel.org/lkml/CACRpkdYk0zW12qNXgOstTLmdVDYacu0Un+8quTN+J_az
[email protected]/T/#mf0596982324a6489b5537b0531ac5aed60a316baYou shouldn't listen too much to that guy he's not trustworthy.
Quoted 5 lines
I still think we should make an exception for GPIO/pinctrl and use earlier initcalls. Platform GPIO/pinctrl drivers provide basic infrastructure often used by many other drivers, we want to have them loaded early. It avoids unnecessary
EPROBE_DEFERand hence probably even boots faster.
Quoted 3 lines
When we have the pin control and GPIO at different initlevels it makes me uneasy because I feel we have implicit init dependencies that seem more than a little fragile.
Yes, it is not very good.
Quoted 10 lines
My recent thinking has involved the component method used in DRM drivers such as
drivers/gpu/drm/vc4/vc4_drv.cwhere a few different component subdrivers are linked together at bind time (not probe time!) into a master component.
Rob was no big fan of this but the DRM people like it and I was thinking to make a try at it.This way we could at least probe and bind the pin control and GPIO drivers at the *same* initlevel and express the dependencies between them somewhat.
Sounds interesting, maybe you could help to convert Tegra drivers to a such method and others will follow afterwards.
Quoted 3 lines
Quoted 1 line
This should definitely go in, at least as a stop gap solution.
Agreed. (And patch applied.)
The best solution will be to fix the deferred probing, it's awkward that it could break suspend-resume order. Hopefully somebody with a good knowledge of driver/base will manage to fix it eventually.
Quoted 7 lines · On Thursday, 2 August 2018 16:01:24 MSK Dmitry Osipenko wrote:
Quoted 2 lines · On Thursday, 2 August 2018 14:11:43 MSK Dmitry Osipenko wrote:
There is a bug in regards to deferred probing within the drivers core that causes GPIO-driver to suspend after its users. The bug appears if
I meant "before its users", of course. If the rest of the patches is fine, please let me know if re-sending is needed or you'll correct the comment in place while applying.
Linus, please pick up the v2.
Quoted 10 lines · Dmitry Osipenko
Quoted 7 lines · On Thursday, 2 August 2018 16:01:24 MSK Dmitry Osipenko wrote:
Quoted 2 lines · On Thursday, 2 August 2018 14:11:43 MSK Dmitry Osipenko wrote:
There is a bug in regards to deferred probing within the drivers core that causes GPIO-driver to suspend after its users. The bug appears if
I meant "before its users", of course. If the rest of the patches is fine, please let me know if re-sending is needed or you'll correct the comment in place while applying.
Linus, please pick up the v2.
It's no big deal if the only difference is the commit message.
Yours,
Linus Walleij
Quoted 8 lines · Dmitry Osipenko
Quoted 7 lines · On Friday, 3 August 2018 20:24:56 MSK Linus Walleij wrote:
Quoted 5 lines · Stefan Agner
A while back at least using those init lists were not well received even for GPIO/pinctrl drivers:
https://lore.kernel.org/lkml/CACRpkdYk0zW12qNXgOstTLmdVDYacu0Un+8quTN+J_az
[email protected]/T/#mf0596982324a6489b5537b0531ac5aed60a316baYou shouldn't listen too much to that guy he's not trustworthy.
;-)
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
I still think we should make an exception for GPIO/pinctrl and use earlier initcalls. Platform GPIO/pinctrl drivers provide basic infrastructure often used by many other drivers, we want to have them loaded early. It avoids unnecessary
EPROBE_DEFERand hence probably even boots faster.
Quoted 6 lines
Quoted 3 lines
When we have the pin control and GPIO at different initlevels it makes me uneasy because I feel we have implicit init dependencies that seem more than a little fragile.
Yes, it is not very good.
Btw, just noticed this now:
GPIO driver -> arch_initcall
pinctrl driver -> subsys_initcall
And arch is before subsys. So we initialize GPIO driver first? But isn't pinctrl required for the GPIO range?
Afaik, especially with gpio-ranges enabled, the GPIO probe will return -EPROBE_DEFER (I think due to pinctrl_get_device_gpio_range).
So my intuition would be that it should be the other way around...
--
Stefan
Quoted 21 lines
Quoted 10 lines
My recent thinking has involved the component method used in DRM drivers such as
drivers/gpu/drm/vc4/vc4_drv.cwhere a few different component subdrivers are linked together at bind time (not probe time!) into a master component.
Rob was no big fan of this but the DRM people like it and I was thinking to make a try at it.This way we could at least probe and bind the pin control and GPIO drivers at the *same* initlevel and express the dependencies between them somewhat.
Sounds interesting, maybe you could help to convert Tegra drivers to a such method and others will follow afterwards.
Quoted 3 lines
Quoted 1 line
This should definitely go in, at least as a stop gap solution.
Agreed. (And patch applied.)
The best solution will be to fix the deferred probing, it's awkward that it could break suspend-resume order. Hopefully somebody with a good knowledge of driver/base will manage to fix it eventually.
Quoted 26 lines · On Monday, 6 August 2018 16:03:01 MSK Stefan Agner wrote:
Quoted 11 lines · Dmitry Osipenko
Quoted 10 lines · On Friday, 3 August 2018 20:24:56 MSK Linus Walleij wrote:
Quoted 7 lines · Stefan Agner
A while back at least using those init lists were not well received even
for GPIO/pinctrl drivers:https://lore.kernel.org/lkml/CACRpkdYk0zW12qNXgOstTLmdVDYacu0Un+8quTN+J
_az[email protected]/T/#mf0596982324a6489b5537b0531ac5aed60a316baYou shouldn't listen too much to that guy he's not trustworthy.
;-)
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
I still think we should make an exception for GPIO/pinctrl and use earlier initcalls. Platform GPIO/pinctrl drivers provide basic infrastructure often used by many other drivers, we want to have them loaded early. It avoids unnecessary
EPROBE_DEFERand hence probably even
boots faster.When we have the pin control and GPIO at different initlevels it makes me uneasy because I feel we have implicit init dependencies that seem more than a little fragile.
Quoted 5 lines
Quoted 1 line
Yes, it is not very good.
Btw, just noticed this now:
GPIO driver ->arch_initcall
pinctrl driver ->subsys_initcall
I'm not sure what you're talking about, it's the other way around in the patches.
Quoted 27 lines · Dmitry Osipenko
Quoted 26 lines · On Monday, 6 August 2018 16:03:01 MSK Stefan Agner wrote:
Quoted 11 lines · Dmitry Osipenko
Quoted 10 lines · On Friday, 3 August 2018 20:24:56 MSK Linus Walleij wrote:
Quoted 7 lines · Stefan Agner
A while back at least using those init lists were not well received even
for GPIO/pinctrl drivers:https://lore.kernel.org/lkml/CACRpkdYk0zW12qNXgOstTLmdVDYacu0Un+8quTN+J
_az[email protected]/T/#mf0596982324a6489b5537b0531ac5aed60a316baYou shouldn't listen too much to that guy he's not trustworthy.
;-)
Quoted 11 lines
Quoted 10 lines
Quoted 6 lines
I still think we should make an exception for GPIO/pinctrl and use earlier initcalls. Platform GPIO/pinctrl drivers provide basic infrastructure often used by many other drivers, we want to have them loaded early. It avoids unnecessary
EPROBE_DEFERand hence probably even
boots faster.When we have the pin control and GPIO at different initlevels it makes me uneasy because I feel we have implicit init dependencies that seem more than a little fragile.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Yes, it is not very good.
Btw, just noticed this now:
GPIO driver ->arch_initcall
pinctrl driver ->subsys_initcallI'm not sure what you're talking about, it's the other way around in the patches.
Wow, yeah sorry... That must be the heat in our office ':-)
--
Stefan