ACPI, PMICs and probing cameras
Subsystems (5)
Sakari Ailus
maintainercover ACPI, PMICs and probing cameras
Hi all,
The intel_skl_int3472 driver is required for some of the ACPI power state transitions to function. This driver may be compiled as a module and thus may probe after a sensor driver that depends on it (e.g. imx258).
Make the sensor driver return -EPROBE_DEFER if the sensor cannot be found. This way the sensor driver will be probed when both the intel_skl_int3472 and the gpio-tps68470 drivers have successfully probed while also the gpio-tps68470 driver may be built as a module.
The drawback of the approach is needless probing of the imx258 driver but everything can be built as modules.
I'm posting this as RFC since the approach would require effectively all ACPI based sensor drivers to have the same check. This would be a non-issue to add. I wouldn't mind but...
Is there a way to figure out whether the PMIC opregion callbacks actually succeed? At least the imx258 driver is happily probed even if the driver implementing the opregion callback is not there, and thus the device remains powered off --- and probe fails.
Sakari Ailus (3):
imx258: Defer probing on ident register read fail (on ACPI)
gpio-tps68470: Allow building as module
gpio-tps68470: Add modalias
drivers/gpio/Kconfig | 2 +- drivers/gpio/gpio-tps68470.c | 5 ++++- drivers/media/i2c/imx258.c | 8 ++++++++ 3 files changed, 13 insertions(+), 2 deletions(-)
Signature · 1 line
2.30.2
Sakari Ailus
maintainerRFC 1/3 imx258: Defer probing on ident register read fail (on ACPI)
Return -EPROBE_DEFER if probing the device fails because of the I²C transaction (-EIO only). This generally happens when the power on sequence of the device has not been fully performed yet due to later probing of other drivers.
--- drivers/media/i2c/imx258.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/media/i2c/imx258.c +8 -0
@@ -1109,6 +1109,14 @@ static int imx258_identify_module(struct imx258 *imx258) ret =imx258_read_reg (imx258,IMX258_REG_CHIP_ID ,IMX258_REG_VALUE_16BIT , &val); +if (ret == -EIO &&is_acpi_device_node (dev_fwnode (&client->dev))) { +/* +* If we get -EIO here and it's an ACPI device, there's a fair +* likelihood it's because the drivers required to power this +* device on have not probed yet. Thus return -EPROBE_DEFER. +*/ +return -EPROBE_DEFER ; + }if (ret) {dev_err (&client->dev,"failed to read chip id %x\n" ,IMX258_CHIP_ID );
Signature · 1 line
2.30.2
Re: [RFC 1/3] imx258: Defer probing on ident register read fail (on ACPI)
Hi Sakari,
Thank you for the patch.
Quoted 15 lines · Sakari Ailus
Return -EPROBE_DEFER if probing the device fails because of the I²C transaction (
-EIOonly). This generally happens when the power on sequence of the device has not been fully performed yet due to later probing of other drivers.Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/imx258.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/media/i2c/imx258.c +0
-0
drivers/media/i2c/imx258.c static int imx258_identify_module(struct imx258 *imx258) · line 1118
Quoted 10 lines
drivers/media/i2c/imx258.c +7
-0@@ -1109,6 +1109,14 @@ static int imx258_identify_module(struct imx258 *imx258) ret =imx258_read_reg (imx258,IMX258_REG_CHIP_ID ,IMX258_REG_VALUE_16BIT , &val); +if (ret == -EIO &&is_acpi_device_node (dev_fwnode (&client->dev))) { +/* +* If we get -EIO here and it's an ACPI device, there's a fair +* likelihood it's because the drivers required to power this +* device on have not probed yet. Thus return -EPROBE_DEFER. +*/ +return -EPROBE_DEFER ;
That's really a hack :-( The driver shouldn't have to deal with this. If power management is handled transparently for the driver, which is what's meant to happen with ACPI, then it should be fully transparent. An -EIO error may mean a real communication issue, turning it into infinite probe deferring isn't right. The ACPI subsystem should figure this out and not probe the driver until all the required resources that are managed transparently for the driver are available.
If this was a one-off hack I may be able to pretend I haven't noticed, but this would need to be copied to every single sensor driver, even every single I2C device driver. It should be fixed properly in the ACPI subsystem instead.
Quoted 4 lines
drivers/media/i2c/imx258.c +1
-0+ }if (ret) {dev_err (&client->dev,"failed to read chip id %x\n" ,IMX258_CHIP_ID );
Signature · 3 lines
Regards, Laurent Pinchart
Sakari Ailus
maintainerRe: [RFC 1/3] imx258: Defer probing on ident register read fail (on ACPI)
Hi Laurent,
Quoted 39 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Quoted 15 lines · Sakari Ailus
Return -EPROBE_DEFER if probing the device fails because of the I²C transaction (
-EIOonly). This generally happens when the power on sequence of the device has not been fully performed yet due to later probing of other drivers.Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/imx258.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/media/i2c/imx258.c +0
-0drivers/media/i2c/imx258.c static int imx258_identify_module(struct imx258 *imx258) · line 1118
Quoted 10 lines
drivers/media/i2c/imx258.c +7
-0@@ -1109,6 +1109,14 @@ static int imx258_identify_module(struct imx258 *imx258) ret =imx258_read_reg (imx258,IMX258_REG_CHIP_ID ,IMX258_REG_VALUE_16BIT , &val); +if (ret == -EIO &&is_acpi_device_node (dev_fwnode (&client->dev))) { +/* +* If we get -EIO here and it's an ACPI device, there's a fair +* likelihood it's because the drivers required to power this +* device on have not probed yet. Thus return -EPROBE_DEFER. +*/ +return -EPROBE_DEFER ;That's really a hack :-( The driver shouldn't have to deal with this. If power management is handled transparently for the driver, which is what's meant to happen with ACPI, then it should be fully transparent. An
-EIOerror may mean a real communication issue, turning it into infinite probe deferring isn't right. The ACPI subsystem should figure this out and not probe the driver until all the required resources that are managed transparently for the driver are available.
Quoted 4 lines
If this was a one-off hack I may be able to pretend I haven't noticed, but this would need to be copied to every single sensor driver, even every single I2C device driver. It should be fixed properly in the ACPI subsystem instead.
In practice such communication issues are rare and trying an I²C access isn't expensive. The patch does solve two practical issues, namely correctly probing a driver and making it possible to build more things as modules.
That said, I agree with with you that ideally a driver would know whether a device has been fully powered up or not. There could also be adverse side effects as there have been no such checks previously.
Signature · 3 lines
Regards, Sakari Ailus
Re: [RFC 1/3] imx258: Defer probing on ident register read fail (on ACPI)
In reply to Sakari AilusQuoted 4 lines · Sakari Ailus
Return -EPROBE_DEFER if probing the device fails because of the I²C transaction (
-EIOonly). This generally happens when the power on sequence of the device has not been fully performed yet due to later probing of other drivers.
...
drivers/media/i2c/imx258.c static int imx258_identify_module(struct imx258 *imx258) · line 1112
Quoted 1 line
drivers/media/i2c/imx258.c +1
-0+if (ret == -EIO &&is_acpi_device_node (dev_fwnode (&client->dev))) {
has_acpi_companion() is better to have here, no?
Quoted 7 lines
drivers/media/i2c/imx258.c +7
-0+/* +* If we get -EIO here and it's an ACPI device, there's a fair +* likelihood it's because the drivers required to power this +* device on have not probed yet. Thus return -EPROBE_DEFER. +*/ +return -EPROBE_DEFER ; + }
Signature · 2 lines
With Best Regards, Andy Shevchenko
Sakari Ailus
maintainerRe: [RFC 1/3] imx258: Defer probing on ident register read fail (on ACPI)
Quoted 11 lines · Andy Shevchenko
Quoted 4 lines · Sakari Ailus
Return -EPROBE_DEFER if probing the device fails because of the I²C transaction (
-EIOonly). This generally happens when the power on sequence of the device has not been fully performed yet due to later probing of other drivers....
drivers/media/i2c/imx258.c static int imx258_identify_module(struct imx258 *imx258) · line 1112
Quoted 1 line
drivers/media/i2c/imx258.c +1
-0+if (ret == -EIO &&is_acpi_device_node (dev_fwnode (&client->dev))) {
has_acpi_companion()is better to have here, no?
Agreed.
Signature · 1 line
Sakari Ailus
Sakari Ailus
maintainerRFC 2/3 gpio-tps68470: Allow building as module
In reply to Sakari AilusAllow building gpio-tps68470 driver as a module. The intel_skl_int3472 is a module anyway, so making this a builtin does not really help setting up this one before a dependent module probes.
--- drivers/gpio/Kconfig | 2 +- drivers/gpio/gpio-tps68470.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpio/Kconfig +1 -1
@@ -1378,7 +1378,7 @@ config GPIO_TPS65912 This driver supports TPS65912 gpio chip config GPIO_TPS68470 - bool "TPS68470 GPIO" + tristate "TPS68470 GPIO" depends on INTEL_SKL_INT3472 help Select this option to enable GPIO driver for the TPS68470
drivers/gpio/gpio-tps68470.c +3 -1
@@ -155,4 +155,6 @@ static struct platform_driver tps68470_gpio_driver = { .probe = tps68470_gpio_probe, }; -builtin_platform_driver (tps68470_gpio_driver) +module_platform_driver (tps68470_gpio_driver); + +MODULE_LICENSE ("GPL" );
Signature · 1 line
2.30.2
Re: [RFC 2/3] gpio-tps68470: Allow building as module
Quoted 3 lines · Sakari Ailus
Allow building gpio-tps68470 driver as a module. The
intel_skl_int3472is a module anyway, so making this a builtin does not really help setting up this one before a dependent module probes.
Fine with me,
Quoted 34 lines
Signed-off-by Sakari Ailus <[email protected]>--- drivers/gpio/Kconfig | 2 +- drivers/gpio/gpio-tps68470.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-)drivers/gpio/Kconfig +1
-1@@ -1378,7 +1378,7 @@ config GPIO_TPS65912 This driver supports TPS65912 gpio chip config GPIO_TPS68470 - bool "TPS68470 GPIO" + tristate "TPS68470 GPIO" depends on INTEL_SKL_INT3472 help Select this option to enable GPIO driver for the TPS68470drivers/gpio/gpio-tps68470.c +3
-1@@ -155,4 +155,6 @@ static struct platform_driver tps68470_gpio_driver = { .probe = tps68470_gpio_probe, }; -builtin_platform_driver (tps68470_gpio_driver) +module_platform_driver (tps68470_gpio_driver); + +MODULE_LICENSE ("GPL" );Signature · 1 line
2.30.2
Signature · 2 lines
With Best Regards, Andy Shevchenko
Sakari Ailus
maintainerRFC 3/3 gpio-tps68470: Add modalias
In reply to Sakari AilusAdd modalias for this driver, so that it is loaded automatically once the devices pop up.
--- drivers/gpio/gpio-tps68470.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/gpio-tps68470.c +1 -0
@@ -158,3 +158,4 @@ static struct platform_driver tps68470_gpio_driver = {module_platform_driver (tps68470_gpio_driver);MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:tps68470-gpio" );
Signature · 1 line
2.30.2
Re: [RFC 3/3] gpio-tps68470: Add modalias
Quoted 2 lines · Sakari Ailus
Add modalias for this driver, so that it is loaded automatically once the devices pop up.
Not sure if it should be a separate patch, nevertheless
Quoted 17 lines
Signed-off-by Sakari Ailus <[email protected]>--- drivers/gpio/gpio-tps68470.c | 1 + 1 file changed, 1 insertion(+)drivers/gpio/gpio-tps68470.c +1
-0@@ -158,3 +158,4 @@ static struct platform_driver tps68470_gpio_driver = {module_platform_driver (tps68470_gpio_driver);MODULE_LICENSE ("GPL" ); +MODULE_ALIAS ("platform:tps68470-gpio" );Signature · 1 line
2.30.2
Signature · 2 lines
With Best Regards, Andy Shevchenko