driver: core: Allow subsystems to continue deferring probe
Subsystems (3)
PATCH v3 1/1 driver: core: Allow subsystems to continue deferring probe
From: Thierry Reding <[email protected]>
Some subsystems, such as pinctrl, allow continuing to defer probe indefinitely. This is useful for devices that depend on resources provided by devices that are only probed after the init stage.
One example of this can be seen on Tegra, where the DPAUX hardware contains pinmuxing controls for pins that it shares with an I2C controller. The I2C controller is typically used for communication with a monitor over HDMI (DDC). However, other instances of the I2C controller are used to access system critical components, such as a PMIC. The I2C controller driver will therefore usually be a builtin driver, whereas the DPAUX driver is part of the display driver that is loaded from a module to avoid bloating the kernel image with all of the DRM/KMS subsystem.
In this particular case the pins used by this I2C/DDC controller become accessible very late in the boot process. However, since the controller is only used in conjunction with display, that's not an issue.
Unfortunately the driver core currently outputs a warning message when a device fails to get the pinctrl before the end of the init stage. That can be confusing for the user because it may sound like an unwanted error occurred, whereas it's really an expected and harmless situation.
In order to eliminate this warning, this patch allows callers of the driver_deferred_probe_check_state() helper to specify that they want to continue deferring probe, regardless of whether we're past the init stage or not. All of the callers of that function are updated for the new signature, but only the pinctrl subsystem passes a true value in the new persist parameter if appropriate.
---
Changes in v3:
- add new function rather than extend the existing function with flags
Changes in v2:
- pass persist flag via flags parameter to make the function call easier to understand
drivers/base/dd.c | 55 ++++++++++++++++++++++++++++++------ drivers/pinctrl/devicetree.c | 7 ++--- include/linux/device.h | 1 + 3 files changed, 51 insertions(+), 12 deletions(-)
drivers/base/dd.c +47 -8
@@ -235,6 +235,19 @@ static int __init deferred_probe_timeout_setup(char *str) }__setup ("deferred_probe_timeout=" , deferred_probe_timeout_setup); +static int __driver_deferred_probe_check_state (struct device *dev) +{ +if (!initcalls_done) +return -EPROBE_DEFER ; + +if (!deferred_probe_timeout) { +dev_WARN (dev,"deferred probe timeout, ignoring dependency" ); +return -ETIMEDOUT ; + } + +return 0 ; +} +/** * driver_deferred_probe_check_state() - Check deferred probe state * @dev: device to check
@@ -248,14 +261,40 @@ __setup("deferred_probe_timeout=", deferred_probe_timeout_setup);*/ int driver_deferred_probe_check_state (struct device *dev) { -if (initcalls_done) { -if (!deferred_probe_timeout) { -dev_WARN (dev,"deferred probe timeout, ignoring dependency" ); -return -ETIMEDOUT ; - } -dev_warn (dev,"ignoring dependency for device, assuming no driver" ); -return -ENODEV ; - } +int ret; + + ret =__driver_deferred_probe_check_state (dev); +if (ret <0 ) +return ret; + +dev_warn (dev,"ignoring dependency for device, assuming no driver" ); + +return -ENODEV ; +} + +/** +* driver_deferred_probe_check_state_continue() - check deferred probe state +* @dev: device to check +* +* Returns -ETIMEDOUT if deferred probe debug timeout has expired, or +* -EPROBE_DEFER otherwise. +* +* Drivers or subsystems can opt-in to calling this function instead of +* directly returning -EPROBE_DEFER. +* +* This is similar to driver_deferred_probe_check_state(), but it allows the +* subsystem to keep deferring probe after built-in drivers have had a chance +* to probe. One scenario where that is useful is if built-in drivers rely on +* resources that are provided by modular drivers. +*/ +int driver_deferred_probe_check_state_continue (struct device *dev) +{ +int ret; + + ret =__driver_deferred_probe_check_state (dev); +if (ret <0 ) +return ret; +return -EPROBE_DEFER ; }
drivers/pinctrl/devicetree.c +3 -4
@@ -112,12 +112,11 @@ static int dt_to_map_one_config(struct pinctrl *p, np_pctldev =of_get_next_parent (np_pctldev);if (!np_pctldev ||of_node_is_root (np_pctldev)) {of_node_put (np_pctldev); - ret =driver_deferred_probe_check_state (p->dev);/* keep deferring if modules are enabled unless we've timed out */ -if (IS_ENABLED (CONFIG_MODULES ) && !allow_default && ret == -ENODEV ) - ret = -EPROBE_DEFER ; +if (IS_ENABLED (CONFIG_MODULES ) && !allow_default) +return driver_deferred_probe_check_state_continue (p->dev); -return ret; +return driver_deferred_probe_check_state (p->dev); }/* If we're creating a hog we can use the passed pctldev */ if (hog_pctldev && (np_pctldev == p->dev->of_node)) {
include/linux/device.h +1 -0
@@ -342,6 +342,7 @@ struct device *driver_find_device(struct device_driver *drv,void driver_deferred_probe_add (struct device *dev);int driver_deferred_probe_check_state (struct device *dev); +int driver_deferred_probe_check_state_continue (struct device *dev);/** * struct subsys_interface - interfaces to device functions
Signature · 1 line
2.21.0
Quoted 28 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Some subsystems, such as pinctrl, allow continuing to defer probe indefinitely. This is useful for devices that depend on resources provided by devices that are only probed after the init stage.
One example of this can be seen on Tegra, where the DPAUX hardware contains pinmuxing controls for pins that it shares with an I2C controller. The I2C controller is typically used for communication with a monitor over HDMI (DDC). However, other instances of the I2C controller are used to access system critical components, such as a PMIC. The I2C controller driver will therefore usually be a builtin driver, whereas the DPAUX driver is part of the display driver that is loaded from a module to avoid bloating the kernel image with all of the DRM/KMS subsystem.
In this particular case the pins used by this I2C/DDC controller become accessible very late in the boot process. However, since the controller is only used in conjunction with display, that's not an issue.
Unfortunately the driver core currently outputs a warning message when a device fails to get the pinctrl before the end of the init stage. That can be confusing for the user because it may sound like an unwanted error occurred, whereas it's really an expected and harmless situation.
Quoted 8 lines
In order to eliminate this warning, this patch allows callers of the
driver_deferred_probe_check_state()helper to specify that they want to continue deferring probe, regardless of whether we're past the init stage or not. All of the callers of that function are updated for the new signature, but only the pinctrl subsystem passes a true value in the new persist parameter if appropriate.Signed-off-by Thierry Reding <[email protected]>
Overall
with one nit below.
Quoted 43 lines
---
Changes in v3:
- add new function rather than extend the existing function with flagsChanges in v2:
- pass persist flag via flags parameter to make the function call easier to understanddrivers/base/dd.c | 55 ++++++++++++++++++++++++++++++------ drivers/pinctrl/devicetree.c | 7 ++--- include/linux/device.h | 1 + 3 files changed, 51 insertions(+), 12 deletions(-)drivers/base/dd.c +13
-2@@ -235,6 +235,19 @@ static int __init deferred_probe_timeout_setup(char *str) }__setup ("deferred_probe_timeout=" , deferred_probe_timeout_setup); +static int __driver_deferred_probe_check_state (struct device *dev) +{ +if (!initcalls_done) +return -EPROBE_DEFER ; + +if (!deferred_probe_timeout) { +dev_WARN (dev,"deferred probe timeout, ignoring dependency" ); +return -ETIMEDOUT ; + } + +return 0 ; +} +/** * driver_deferred_probe_check_state() - Check deferred probe state * @dev: device to check @@ -248,14 +261,40 @@ __setup("deferred_probe_timeout=", deferred_probe_timeout_setup);*/ int driver_deferred_probe_check_state (struct device *dev) { -if (initcalls_done) { -if (!deferred_probe_timeout) {
drivers/base/dd.c __setup("deferred_probe_timeout=", deferred_probe_timeout_setup); · line 267
Quoted 10 lines
drivers/base/dd.c +4
-6-dev_WARN (dev,"deferred probe timeout, ignoring dependency" ); -return -ETIMEDOUT ; - } -dev_warn (dev,"ignoring dependency for device, assuming no driver" ); -return -ENODEV ; - } +int ret; + + ret =__driver_deferred_probe_check_state (dev); +if (ret <0 )
The function returning this valie doesn't return positive numbers, so it "if (ret)" would be sufficient here (and below).
Quoted 32 lines
drivers/base/dd.c +30
-0+return ret; + +dev_warn (dev,"ignoring dependency for device, assuming no driver" ); + +return -ENODEV ; +} + +/** +* driver_deferred_probe_check_state_continue() - check deferred probe state +* @dev: device to check +* +* Returns -ETIMEDOUT if deferred probe debug timeout has expired, or +* -EPROBE_DEFER otherwise. +* +* Drivers or subsystems can opt-in to calling this function instead of +* directly returning -EPROBE_DEFER. +* +* This is similar to driver_deferred_probe_check_state(), but it allows the +* subsystem to keep deferring probe after built-in drivers have had a chance +* to probe. One scenario where that is useful is if built-in drivers rely on +* resources that are provided by modular drivers. +*/ +int driver_deferred_probe_check_state_continue (struct device *dev) +{ +int ret; + + ret =__driver_deferred_probe_check_state (dev); +if (ret <0 ) +return ret; +return -EPROBE_DEFER ; }
Quoted 34 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Some subsystems, such as pinctrl, allow continuing to defer probe indefinitely. This is useful for devices that depend on resources provided by devices that are only probed after the init stage.
One example of this can be seen on Tegra, where the DPAUX hardware contains pinmuxing controls for pins that it shares with an I2C controller. The I2C controller is typically used for communication with a monitor over HDMI (DDC). However, other instances of the I2C controller are used to access system critical components, such as a PMIC. The I2C controller driver will therefore usually be a builtin driver, whereas the DPAUX driver is part of the display driver that is loaded from a module to avoid bloating the kernel image with all of the DRM/KMS subsystem.
In this particular case the pins used by this I2C/DDC controller become accessible very late in the boot process. However, since the controller is only used in conjunction with display, that's not an issue.
Unfortunately the driver core currently outputs a warning message when a device fails to get the pinctrl before the end of the init stage. That can be confusing for the user because it may sound like an unwanted error occurred, whereas it's really an expected and harmless situation.
In order to eliminate this warning, this patch allows callers of the
driver_deferred_probe_check_state()helper to specify that they want to continue deferring probe, regardless of whether we're past the init stage or not. All of the callers of that function are updated for the new signature, but only the pinctrl subsystem passes a true value in the new persist parameter if appropriate.
Quoted 4 lines
Signed-off-by Thierry Reding <[email protected]>---
Changes in v3:
- add new function rather than extend the existing function with flags
I see you need something like this and I can't think of anything better so:
Yours,
Linus Walleij
Greg Kroah-Hartman
maintainerQuoted 34 lines · Thierry Reding
From: Thierry Reding <[email protected]>
Some subsystems, such as pinctrl, allow continuing to defer probe indefinitely. This is useful for devices that depend on resources provided by devices that are only probed after the init stage.
One example of this can be seen on Tegra, where the DPAUX hardware contains pinmuxing controls for pins that it shares with an I2C controller. The I2C controller is typically used for communication with a monitor over HDMI (DDC). However, other instances of the I2C controller are used to access system critical components, such as a PMIC. The I2C controller driver will therefore usually be a builtin driver, whereas the DPAUX driver is part of the display driver that is loaded from a module to avoid bloating the kernel image with all of the DRM/KMS subsystem.
In this particular case the pins used by this I2C/DDC controller become accessible very late in the boot process. However, since the controller is only used in conjunction with display, that's not an issue.
Unfortunately the driver core currently outputs a warning message when a device fails to get the pinctrl before the end of the init stage. That can be confusing for the user because it may sound like an unwanted error occurred, whereas it's really an expected and harmless situation.
In order to eliminate this warning, this patch allows callers of the
driver_deferred_probe_check_state()helper to specify that they want to continue deferring probe, regardless of whether we're past the init stage or not. All of the callers of that function are updated for the new signature, but only the pinctrl subsystem passes a true value in the new persist parameter if appropriate.
Quoted 6 lines
Signed-off-by Thierry Reding <[email protected]>Reviewed-by Rafael J. Wysocki <[email protected]>Reviewed-by Linus Walleij <[email protected]>---
Changes in v3:
- add new function rather than extend the existing function with flags
Much nicer, thanks for making the changes!
greg k-h