Skip to contentSkip to conversation

media: dw9768: activate runtime PM and turn off device

PATCH In review Bingbu Cao 4 participants 15 messages Oct 15, 2021 – Jul 20, 2022

Subsystems (3)
lore
Share & tools
lore

Bingbu Cao

author
#0 lore raw

PATCH 1/1 media: dw9768: activate runtime PM and turn off device

When dw9768 working with ACPI systems, the dw9768 was turned by i2c-core during probe, driver need activate the PM runtime and ask runtime PM to turn off the device.

---
 drivers/media/i2c/dw9768.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/dw9768.c +6 -0
index c086580efac7..65c6acf3ced9 100644
@@ -469,6 +469,11 @@ static int dw9768_probe(struct i2c_client *client)
 
 	dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
 
+	/*
+	 * Device is already turned on by i2c-core with ACPI domain PM.
+	 * Attempt to turn off the device to satisfy the privacy LED concerns.
+	 */
+	pm_runtime_set_active(dev);
 	pm_runtime_enable(dev);
 	if (!pm_runtime_enabled(dev)) {
 		ret = dw9768_runtime_resume(dev);
@@ -483,6 +488,7 @@ static int dw9768_probe(struct i2c_client *client)
 		dev_err(dev, "failed to register V4L2 subdev: %d", ret);
 		goto err_power_off;
 	}
+	pm_runtime_idle(dev);
 
 	return 0;
 
Signature · 1 line
2.7.4
#1 lore raw
Quoted 15 lines · Bingbu Cao

When dw9768 working with ACPI systems, the dw9768 was turned by i2c-core during probe, driver need activate the PM runtime and ask runtime PM to turn off the device.

---
 drivers/media/i2c/dw9768.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/dw9768.c +0 -0
index c086580efac7..65c6acf3ced9 100644

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client *client) · line 476

Quoted 8 lines
drivers/media/i2c/dw9768.c +5 -0
@@ -469,6 +469,11 @@ static int dw9768_probe(struct i2c_client *client)
 
        dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
 
+       /*
+        * Device is already turned on by i2c-core with ACPI domain PM.
+        * Attempt to turn off the device to satisfy the privacy LED concerns.
+        */
+       pm_runtime_set_active(dev);

This driver is used by non-ACPI systems as well. This change will make the PM core not call the runtime_resume() callback provided by the driver and the power would never be turned on on such systems.

Wasn't the intention of Sakari's ACPI patches to allow bypassing the ACPI domain power on at boot up and eliminate the need for this change?

Best regards,
Tomasz

Quoted 15 lines
drivers/media/i2c/dw9768.c +1 -1
        pm_runtime_enable(dev);
        if (!pm_runtime_enabled(dev)) {
                ret = dw9768_runtime_resume(dev);
@@ -483,6 +488,7 @@ static int dw9768_probe(struct i2c_client *client)
                dev_err(dev, "failed to register V4L2 subdev: %d", ret);
                goto err_power_off;
        }
+       pm_runtime_idle(dev);
 
        return 0;
 
--

2.7.4

#2 lore raw
Quoted 37 lines

-----Original Message-----
From: Tomasz Figa <[email protected]>
Sent: Friday, November 5, 2021 2:55 PM
To: Cao, Bingbu <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Qiu, Tian Shu <[email protected]>; [email protected]
Subject: Re: [PATCH] media: dw9768: activate runtime PM and turn off device

Quoted 15 lines · Bingbu Cao

When dw9768 working with ACPI systems, the dw9768 was turned by i2c-core during probe, driver need activate the PM runtime and ask runtime PM to turn off the device.

---
 drivers/media/i2c/dw9768.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/dw9768.c +0 -0
index c086580efac7..65c6acf3ced9 100644

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 475

Quoted 7 lines
drivers/media/i2c/dw9768.c +3 -0
@@ -469,6 +469,11 @@ static int dw9768_probe(struct i2c_client
 *client)
 
        dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
 
+       /*
+        * Device is already turned on by i2c-core with ACPI domain PM.
+        * Attempt to turn off the device to satisfy the privacy LED

concerns.

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client *client) · line 476

Quoted 2 lines
drivers/media/i2c/dw9768.c +2 -0
+        */
+       pm_runtime_set_active(dev);
Quoted 7 lines

This driver is used by non-ACPI systems as well. This change will make the PM core not call the runtime_resume() callback provided by the driver and the power would never be turned on on such systems.

Wasn't the intention of Sakari's ACPI patches to allow bypassing the ACPI domain power on at boot up and eliminate the need for this change?

Tomasz, thanks for your review.

The comment here is invalid, it should not be strongly related to the privacy LED concern. Anyway, the device should be turned off on ACPI and non-ACPI systems even without Sakari's changes.

I am wondering how the driver work with PM core on non-ACPI system.

Quoted 20 lines

Best regards,
Tomasz

Quoted 6 lines
drivers/media/i2c/dw9768.c +0 -0
        pm_runtime_enable(dev);
        if (!pm_runtime_enabled(dev)) {
                ret = dw9768_runtime_resume(dev); @@ -483,6 +488,7 @@

static int dw9768_probe(struct i2c_client *client)
dev_err(dev, "failed to register V4L2 subdev: %d",

ret);

Quoted 9 lines
                goto err_power_off;
        }

+ pm_runtime_idle(dev);

        return 0;

--
2.7.4

#3 lore raw
Quoted 46 lines · Bingbu
Quoted 38 lines

-----Original Message-----
From: Tomasz Figa <[email protected]>
Sent: Friday, November 5, 2021 2:55 PM
To: Cao, Bingbu <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Qiu, Tian Shu <[email protected]>; [email protected]
Subject: Re: [PATCH] media: dw9768: activate runtime PM and turn off device

Quoted 15 lines · Bingbu Cao

When dw9768 working with ACPI systems, the dw9768 was turned by i2c-core during probe, driver need activate the PM runtime and ask runtime PM to turn off the device.

---
 drivers/media/i2c/dw9768.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/dw9768.c +0 -0
index c086580efac7..65c6acf3ced9 100644

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 475

Quoted 7 lines
drivers/media/i2c/dw9768.c +3 -0
@@ -469,6 +469,11 @@ static int dw9768_probe(struct i2c_client
 *client)
 
        dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
 
+       /*
+        * Device is already turned on by i2c-core with ACPI domain PM.
+        * Attempt to turn off the device to satisfy the privacy LED

concerns.

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client *client) · line 476

Quoted 2 lines
drivers/media/i2c/dw9768.c +2 -0
+        */
+       pm_runtime_set_active(dev);
Quoted 7 lines

This driver is used by non-ACPI systems as well. This change will make the PM core not call the runtime_resume() callback provided by the driver and the power would never be turned on on such systems.

Wasn't the intention of Sakari's ACPI patches to allow bypassing the ACPI domain power on at boot up and eliminate the need for this change?

Quoted 8 lines

Tomasz, thanks for your review.

The comment here is invalid, it should not be strongly related to the privacy LED concern. Anyway, the device should be turned off on ACPI and non-ACPI systems even without Sakari's changes.

I am wondering how the driver work with PM core on non-ACPI system.

On non-ACPI systems it's the driver which handles the power sequencing of the chip so the regulators wouldn't be implicitly enabled by the subsystem before (unless they're shared with some other device and the corresponding driver enabled them).

Quoted 20 lines
Quoted 20 lines

Best regards,
Tomasz

Quoted 6 lines
drivers/media/i2c/dw9768.c +0 -0
        pm_runtime_enable(dev);
        if (!pm_runtime_enabled(dev)) {
                ret = dw9768_runtime_resume(dev); @@ -483,6 +488,7 @@

static int dw9768_probe(struct i2c_client *client)
dev_err(dev, "failed to register V4L2 subdev: %d",

ret);

Quoted 9 lines
                goto err_power_off;
        }

+ pm_runtime_idle(dev);

        return 0;

--
2.7.4

#4 lore raw
Quoted 54 lines · Tomasz Figa
Quoted 52 lines · Bingbu
Quoted 38 lines

-----Original Message-----
From: Tomasz Figa <[email protected]>
Sent: Friday, November 5, 2021 2:55 PM
To: Cao, Bingbu <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Qiu, Tian Shu <[email protected]>; [email protected]
Subject: Re: [PATCH] media: dw9768: activate runtime PM and turn off device

Quoted 15 lines · Bingbu Cao

When dw9768 working with ACPI systems, the dw9768 was turned by i2c-core during probe, driver need activate the PM runtime and ask runtime PM to turn off the device.

---
 drivers/media/i2c/dw9768.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/dw9768.c +0 -0
index c086580efac7..65c6acf3ced9 100644

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 475

Quoted 7 lines
drivers/media/i2c/dw9768.c +3 -0
@@ -469,6 +469,11 @@ static int dw9768_probe(struct i2c_client
 *client)
 
        dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
 
+       /*
+        * Device is already turned on by i2c-core with ACPI domain PM.
+        * Attempt to turn off the device to satisfy the privacy LED

concerns.

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client *client) · line 476

Quoted 2 lines
drivers/media/i2c/dw9768.c +2 -0
+        */
+       pm_runtime_set_active(dev);
Quoted 7 lines

This driver is used by non-ACPI systems as well. This change will make the PM core not call the runtime_resume() callback provided by the driver and the power would never be turned on on such systems.

Wasn't the intention of Sakari's ACPI patches to allow bypassing the ACPI domain power on at boot up and eliminate the need for this change?

Tomasz, thanks for your review.

The comment here is invalid, it should not be strongly related to the privacy LED concern. Anyway, the device should be turned off on ACPI and non-ACPI systems even without Sakari's changes.

Quoted 7 lines
Quoted 2 lines

I am wondering how the driver work with PM core on non-ACPI system.

On non-ACPI systems it's the driver which handles the power sequencing of the chip so the regulators wouldn't be implicitly enabled by the subsystem before (unless they're shared with some other device and the corresponding driver enabled them).

It looks like this patch made into Linus' tree and broke the driver on ARM devices. Could we please revert it?

Best regards,
Tomasz

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

Best regards,
Tomasz

Quoted 6 lines
drivers/media/i2c/dw9768.c +0 -0
        pm_runtime_enable(dev);
        if (!pm_runtime_enabled(dev)) {
                ret = dw9768_runtime_resume(dev); @@ -483,6 +488,7 @@

static int dw9768_probe(struct i2c_client *client)
dev_err(dev, "failed to register V4L2 subdev: %d",

ret);

Quoted 9 lines
                goto err_power_off;
        }

+ pm_runtime_idle(dev);

        return 0;

--
2.7.4

#5 lore raw
Quoted 58 lines · Tomasz Figa
Quoted 57 lines · Tomasz Figa
Quoted 54 lines · Bingbu
Quoted 38 lines

-----Original Message-----
From: Tomasz Figa <[email protected]>
Sent: Friday, November 5, 2021 2:55 PM
To: Cao, Bingbu <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Qiu, Tian Shu <[email protected]>; [email protected]
Subject: Re: [PATCH] media: dw9768: activate runtime PM and turn off device

Quoted 15 lines · Bingbu Cao

When dw9768 working with ACPI systems, the dw9768 was turned by i2c-core during probe, driver need activate the PM runtime and ask runtime PM to turn off the device.

---
 drivers/media/i2c/dw9768.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/dw9768.c +0 -0
index c086580efac7..65c6acf3ced9 100644

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 475

Quoted 7 lines
drivers/media/i2c/dw9768.c +3 -0
@@ -469,6 +469,11 @@ static int dw9768_probe(struct i2c_client
 *client)
 
        dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
 
+       /*
+        * Device is already turned on by i2c-core with ACPI domain PM.
+        * Attempt to turn off the device to satisfy the privacy LED

concerns.

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client *client) · line 476

Quoted 2 lines
drivers/media/i2c/dw9768.c +2 -0
+        */
+       pm_runtime_set_active(dev);
Quoted 7 lines

This driver is used by non-ACPI systems as well. This change will make the PM core not call the runtime_resume() callback provided by the driver and the power would never be turned on on such systems.

Wasn't the intention of Sakari's ACPI patches to allow bypassing the ACPI domain power on at boot up and eliminate the need for this change?

Tomasz, thanks for your review.

The comment here is invalid, it should not be strongly related to the privacy LED concern. Anyway, the device should be turned off on ACPI and non-ACPI systems even without Sakari's changes.

I am wondering how the driver work with PM core on non-ACPI system.

Quoted 7 lines
Quoted 4 lines

On non-ACPI systems it's the driver which handles the power sequencing of the chip so the regulators wouldn't be implicitly enabled by the subsystem before (unless they're shared with some other device and the corresponding driver enabled them).

It looks like this patch made into Linus' tree and broke the driver on ARM devices. Could we please revert it?

If revert the patch, the device will not work on ACPI system, is there some other solution? Have no details about the failure on ARM device.

Quoted 25 lines

Best regards,
Tomasz

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

Best regards,
Tomasz

Quoted 6 lines
drivers/media/i2c/dw9768.c +0 -0
        pm_runtime_enable(dev);
        if (!pm_runtime_enabled(dev)) {
                ret = dw9768_runtime_resume(dev); @@ -483,6 +488,7 @@

static int dw9768_probe(struct i2c_client *client)
dev_err(dev, "failed to register V4L2 subdev: %d",

ret);

Quoted 9 lines
                goto err_power_off;
        }

+ pm_runtime_idle(dev);

        return 0;

--
2.7.4

Signature · 2 lines
Best regards,
Bingbu Cao
#6 lore raw
Quoted 67 lines · Bingbu Cao
Quoted 63 lines · Tomasz Figa
Quoted 61 lines · Tomasz Figa
Quoted 46 lines · Bingbu
Quoted 38 lines

-----Original Message-----
From: Tomasz Figa <[email protected]>
Sent: Friday, November 5, 2021 2:55 PM
To: Cao, Bingbu <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Qiu, Tian Shu <[email protected]>; [email protected]
Subject: Re: [PATCH] media: dw9768: activate runtime PM and turn off device

Quoted 15 lines · Bingbu Cao

When dw9768 working with ACPI systems, the dw9768 was turned by i2c-core during probe, driver need activate the PM runtime and ask runtime PM to turn off the device.

---
 drivers/media/i2c/dw9768.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/dw9768.c +0 -0
index c086580efac7..65c6acf3ced9 100644

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 475

Quoted 7 lines
drivers/media/i2c/dw9768.c +3 -0
@@ -469,6 +469,11 @@ static int dw9768_probe(struct i2c_client
 *client)
 
        dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
 
+       /*
+        * Device is already turned on by i2c-core with ACPI domain PM.
+        * Attempt to turn off the device to satisfy the privacy LED

concerns.

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client *client) · line 476

Quoted 2 lines
drivers/media/i2c/dw9768.c +2 -0
+        */
+       pm_runtime_set_active(dev);
Quoted 7 lines

This driver is used by non-ACPI systems as well. This change will make the PM core not call the runtime_resume() callback provided by the driver and the power would never be turned on on such systems.

Wasn't the intention of Sakari's ACPI patches to allow bypassing the ACPI domain power on at boot up and eliminate the need for this change?

Quoted 8 lines

Tomasz, thanks for your review.

The comment here is invalid, it should not be strongly related to the privacy LED concern. Anyway, the device should be turned off on ACPI and non-ACPI systems even without Sakari's changes.

I am wondering how the driver work with PM core on non-ACPI system.

On non-ACPI systems it's the driver which handles the power sequencing of the chip so the regulators wouldn't be implicitly enabled by the subsystem before (unless they're shared with some other device and the corresponding driver enabled them).

Quoted 6 lines
Quoted 2 lines

It looks like this patch made into Linus' tree and broke the driver on ARM devices. Could we please revert it?

If revert the patch, the device will not work on ACPI system, is there some other solution? Have no details about the failure on ARM device.

I believe it worked on ACPI systems, just runtime PM wasn't suspending the device.

That said, if my comment above was addressed instead of being ignored, this regression wouldn't have happened. The problem is described in my previous messages, please get back to them and address the issue I pointed out.

Best regards,
Tomasz

Quoted 29 lines
Quoted 25 lines

Best regards,
Tomasz

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines

Best regards,
Tomasz

Quoted 6 lines
drivers/media/i2c/dw9768.c +0 -0
        pm_runtime_enable(dev);
        if (!pm_runtime_enabled(dev)) {
                ret = dw9768_runtime_resume(dev); @@ -483,6 +488,7 @@

static int dw9768_probe(struct i2c_client *client)
dev_err(dev, "failed to register V4L2 subdev: %d",

ret);

Quoted 9 lines
                goto err_power_off;
        }

+ pm_runtime_idle(dev);

        return 0;

--
2.7.4

--
Best regards,
Bingbu Cao

#7 lore raw

Hi Tomasz, Bingbu,

Quoted 75 lines · Tomasz Figa
Quoted 67 lines · Bingbu Cao
Quoted 63 lines · Tomasz Figa
Quoted 61 lines · Tomasz Figa
Quoted 46 lines · Bingbu
Quoted 38 lines

-----Original Message-----
From: Tomasz Figa <[email protected]>
Sent: Friday, November 5, 2021 2:55 PM
To: Cao, Bingbu <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Qiu, Tian Shu <[email protected]>; [email protected]
Subject: Re: [PATCH] media: dw9768: activate runtime PM and turn off device

Quoted 15 lines · Bingbu Cao

When dw9768 working with ACPI systems, the dw9768 was turned by i2c-core during probe, driver need activate the PM runtime and ask runtime PM to turn off the device.

---
 drivers/media/i2c/dw9768.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/dw9768.c +0 -0
index c086580efac7..65c6acf3ced9 100644

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 475

Quoted 7 lines
drivers/media/i2c/dw9768.c +3 -0
@@ -469,6 +469,11 @@ static int dw9768_probe(struct i2c_client
 *client)
 
        dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
 
+       /*
+        * Device is already turned on by i2c-core with ACPI domain PM.
+        * Attempt to turn off the device to satisfy the privacy LED

concerns.

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 477

Quoted 2 lines
drivers/media/i2c/dw9768.c +2 -0
+        */
+       pm_runtime_set_active(dev);
Quoted 7 lines

This driver is used by non-ACPI systems as well. This change will make the PM core not call the runtime_resume() callback provided by the driver and the power would never be turned on on such systems.

Wasn't the intention of Sakari's ACPI patches to allow bypassing the ACPI domain power on at boot up and eliminate the need for this change?

Quoted 8 lines

Tomasz, thanks for your review.

The comment here is invalid, it should not be strongly related to the privacy LED concern. Anyway, the device should be turned off on ACPI and non-ACPI systems even without Sakari's changes.

I am wondering how the driver work with PM core on non-ACPI system.

On non-ACPI systems it's the driver which handles the power sequencing of the chip so the regulators wouldn't be implicitly enabled by the subsystem before (unless they're shared with some other device and the corresponding driver enabled them).

Quoted 6 lines
Quoted 2 lines

It looks like this patch made into Linus' tree and broke the driver on ARM devices. Could we please revert it?

If revert the patch, the device will not work on ACPI system, is there some other solution? Have no details about the failure on ARM device.

Quoted 7 lines

I believe it worked on ACPI systems, just runtime PM wasn't suspending the device.

That said, if my comment above was addressed instead of being ignored, this regression wouldn't have happened. The problem is described in my previous messages, please get back to them and address the issue I pointed out.

First of all, thanks for catching this.

What I believe happened was that the patch was merged to my tree before you commented on it and then I missed the related follow-up discussion.

Looking at the patch itself, it seems fine as such but there's a problem with the driver to begin with: the device isn't powered on in probe on DT systems but still its runtime suspend callback is called through pm_runtime_idle().

Normally calling the RT suspend callback is what we want, but in this case disabling a regulator that wasn't enabled is a problem.

There also seems to be a problem in error handling... and the driver does not support probing while powered off on ACPI. Oh well.

Let's revert the patch now but it seems there's something to fix afterwards.

Signature · 3 lines
Regards,

Sakari Ailus
#8 lore raw
Quoted 97 lines · On Wed, Apr 13, 2022 at 8:40 PM [email protected]…

Hi Tomasz, Bingbu,

Quoted 75 lines · Tomasz Figa
Quoted 67 lines · Bingbu Cao
Quoted 63 lines · Tomasz Figa
Quoted 61 lines · Tomasz Figa
Quoted 46 lines · Bingbu
Quoted 38 lines

-----Original Message-----
From: Tomasz Figa <[email protected]>
Sent: Friday, November 5, 2021 2:55 PM
To: Cao, Bingbu <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Qiu, Tian Shu <[email protected]>; [email protected]
Subject: Re: [PATCH] media: dw9768: activate runtime PM and turn off device

Quoted 15 lines · Bingbu Cao

When dw9768 working with ACPI systems, the dw9768 was turned by i2c-core during probe, driver need activate the PM runtime and ask runtime PM to turn off the device.

---
 drivers/media/i2c/dw9768.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/dw9768.c +0 -0
index c086580efac7..65c6acf3ced9 100644

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 475

Quoted 7 lines
drivers/media/i2c/dw9768.c +3 -0
@@ -469,6 +469,11 @@ static int dw9768_probe(struct i2c_client
 *client)
 
        dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
 
+       /*
+        * Device is already turned on by i2c-core with ACPI domain PM.
+        * Attempt to turn off the device to satisfy the privacy LED

concerns.

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 477

Quoted 2 lines
drivers/media/i2c/dw9768.c +2 -0
+        */
+       pm_runtime_set_active(dev);
Quoted 7 lines

This driver is used by non-ACPI systems as well. This change will make the PM core not call the runtime_resume() callback provided by the driver and the power would never be turned on on such systems.

Wasn't the intention of Sakari's ACPI patches to allow bypassing the ACPI domain power on at boot up and eliminate the need for this change?

Quoted 8 lines

Tomasz, thanks for your review.

The comment here is invalid, it should not be strongly related to the privacy LED concern. Anyway, the device should be turned off on ACPI and non-ACPI systems even without Sakari's changes.

I am wondering how the driver work with PM core on non-ACPI system.

On non-ACPI systems it's the driver which handles the power sequencing of the chip so the regulators wouldn't be implicitly enabled by the subsystem before (unless they're shared with some other device and the corresponding driver enabled them).

Quoted 6 lines
Quoted 2 lines

It looks like this patch made into Linus' tree and broke the driver on ARM devices. Could we please revert it?

If revert the patch, the device will not work on ACPI system, is there some other solution? Have no details about the failure on ARM device.

Quoted 7 lines

I believe it worked on ACPI systems, just runtime PM wasn't suspending the device.

That said, if my comment above was addressed instead of being ignored, this regression wouldn't have happened. The problem is described in my previous messages, please get back to them and address the issue I pointed out.

First of all, thanks for catching this.

What I believe happened was that the patch was merged to my tree before you commented on it and then I missed the related follow-up discussion.

Looking at the patch itself, it seems fine as such but there's a problem with the driver to begin with: the device isn't powered on in probe on DT systems but still its runtime suspend callback is called through pm_runtime_idle().

Quoted 8 lines

Normally calling the RT suspend callback is what we want, but in this case disabling a regulator that wasn't enabled is a problem.

There also seems to be a problem in error handling... and the driver does not support probing while powered off on ACPI. Oh well.

Let's revert the patch now but it seems there's something to fix afterwards.

Thanks Sakari.

One of possible ways to fix this would be to always turn on the regulators in the probe, although it would result in the privacy LED blinking issue on our ARM systems.

I wonder if we're missing something in how the ACPI runtime PM works on Linux. It sounds strange to me that the driver needs to be aware of the ACPI internals and know that the default boot-up state is powered on. Maybe there is another function that we could call instead of pm_runtime_set_active()+pm_runtime_idle() that would only shut down the PM domain, while leaving the device itself alone?

Best regards,
Tomasz

Quoted 5 lines

--
Regards,

Sakari Ailus

#9 lore raw

Hi Tomasz,

Quoted 110 lines · Tomasz Figa
Quoted 97 lines · On Wed, Apr 13, 2022 at 8:40 PM [email protected]…

Hi Tomasz, Bingbu,

Quoted 75 lines · Tomasz Figa
Quoted 67 lines · Bingbu Cao
Quoted 63 lines · Tomasz Figa
Quoted 61 lines · Tomasz Figa
Quoted 46 lines · Bingbu
Quoted 38 lines

-----Original Message-----
From: Tomasz Figa <[email protected]>
Sent: Friday, November 5, 2021 2:55 PM
To: Cao, Bingbu <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Qiu, Tian Shu <[email protected]>; [email protected]
Subject: Re: [PATCH] media: dw9768: activate runtime PM and turn off device

Quoted 15 lines · Bingbu Cao

When dw9768 working with ACPI systems, the dw9768 was turned by i2c-core during probe, driver need activate the PM runtime and ask runtime PM to turn off the device.

---
 drivers/media/i2c/dw9768.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/dw9768.c +0 -0
index c086580efac7..65c6acf3ced9 100644

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 475

Quoted 7 lines
drivers/media/i2c/dw9768.c +3 -0
@@ -469,6 +469,11 @@ static int dw9768_probe(struct i2c_client
 *client)
 
        dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
 
+       /*
+        * Device is already turned on by i2c-core with ACPI domain PM.
+        * Attempt to turn off the device to satisfy the privacy LED

concerns.

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 477

Quoted 2 lines
drivers/media/i2c/dw9768.c +2 -0
+        */
+       pm_runtime_set_active(dev);
Quoted 7 lines

This driver is used by non-ACPI systems as well. This change will make the PM core not call the runtime_resume() callback provided by the driver and the power would never be turned on on such systems.

Wasn't the intention of Sakari's ACPI patches to allow bypassing the ACPI domain power on at boot up and eliminate the need for this change?

Quoted 8 lines

Tomasz, thanks for your review.

The comment here is invalid, it should not be strongly related to the privacy LED concern. Anyway, the device should be turned off on ACPI and non-ACPI systems even without Sakari's changes.

I am wondering how the driver work with PM core on non-ACPI system.

On non-ACPI systems it's the driver which handles the power sequencing of the chip so the regulators wouldn't be implicitly enabled by the subsystem before (unless they're shared with some other device and the corresponding driver enabled them).

Quoted 6 lines
Quoted 2 lines

It looks like this patch made into Linus' tree and broke the driver on ARM devices. Could we please revert it?

If revert the patch, the device will not work on ACPI system, is there some other solution? Have no details about the failure on ARM device.

Quoted 7 lines

I believe it worked on ACPI systems, just runtime PM wasn't suspending the device.

That said, if my comment above was addressed instead of being ignored, this regression wouldn't have happened. The problem is described in my previous messages, please get back to them and address the issue I pointed out.

First of all, thanks for catching this.

What I believe happened was that the patch was merged to my tree before you commented on it and then I missed the related follow-up discussion.

Looking at the patch itself, it seems fine as such but there's a problem with the driver to begin with: the device isn't powered on in probe on DT systems but still its runtime suspend callback is called through pm_runtime_idle().

Quoted 8 lines

Normally calling the RT suspend callback is what we want, but in this case disabling a regulator that wasn't enabled is a problem.

There also seems to be a problem in error handling... and the driver does not support probing while powered off on ACPI. Oh well.

Let's revert the patch now but it seems there's something to fix afterwards.

Thanks Sakari.

Quoted 7 lines

One of possible ways to fix this would be to always turn on the regulators in the probe, although it would result in the privacy LED blinking issue on our ARM systems.

I wonder if we're missing something in how the ACPI runtime PM works on Linux. It sounds strange to me that the driver needs to be aware of the ACPI internals and know that the default boot-up state is powered

Not really ACPI internals, just that the I²C devices are powered on for probe.

Quoted 3 lines

on. Maybe there is another function that we could call instead of pm_runtime_set_active()+pm_runtime_idle() that would only shut down the PM domain, while leaving the device itself alone?

Laurent recently complained about the complexities of supporting runtime PM on drivers with both OF and ACPI support. I was planning to reply, will include you.

Signature · 3 lines
Regards,

Sakari Ailus
#10 lore raw
Quoted 118 lines · On Wed, Apr 13, 2022 at 10:36 PM [email protected]…

Hi Tomasz,

Quoted 114 lines · Tomasz Figa
Quoted 97 lines · On Wed, Apr 13, 2022 at 8:40 PM [email protected]…

Hi Tomasz, Bingbu,

Quoted 75 lines · Tomasz Figa
Quoted 67 lines · Bingbu Cao
Quoted 63 lines · Tomasz Figa
Quoted 61 lines · Tomasz Figa
Quoted 46 lines · Bingbu
Quoted 38 lines

-----Original Message-----
From: Tomasz Figa <[email protected]>
Sent: Friday, November 5, 2021 2:55 PM
To: Cao, Bingbu <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Qiu, Tian Shu <[email protected]>; [email protected]
Subject: Re: [PATCH] media: dw9768: activate runtime PM and turn off device

Quoted 15 lines · Bingbu Cao

When dw9768 working with ACPI systems, the dw9768 was turned by i2c-core during probe, driver need activate the PM runtime and ask runtime PM to turn off the device.

---
 drivers/media/i2c/dw9768.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/dw9768.c +0 -0
index c086580efac7..65c6acf3ced9 100644

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 475

Quoted 7 lines
drivers/media/i2c/dw9768.c +3 -0
@@ -469,6 +469,11 @@ static int dw9768_probe(struct i2c_client
 *client)
 
        dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
 
+       /*
+        * Device is already turned on by i2c-core with ACPI domain PM.
+        * Attempt to turn off the device to satisfy the privacy LED

concerns.

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 477

Quoted 2 lines
drivers/media/i2c/dw9768.c +2 -0
+        */
+       pm_runtime_set_active(dev);
Quoted 7 lines

This driver is used by non-ACPI systems as well. This change will make the PM core not call the runtime_resume() callback provided by the driver and the power would never be turned on on such systems.

Wasn't the intention of Sakari's ACPI patches to allow bypassing the ACPI domain power on at boot up and eliminate the need for this change?

Quoted 8 lines

Tomasz, thanks for your review.

The comment here is invalid, it should not be strongly related to the privacy LED concern. Anyway, the device should be turned off on ACPI and non-ACPI systems even without Sakari's changes.

I am wondering how the driver work with PM core on non-ACPI system.

On non-ACPI systems it's the driver which handles the power sequencing of the chip so the regulators wouldn't be implicitly enabled by the subsystem before (unless they're shared with some other device and the corresponding driver enabled them).

Quoted 6 lines
Quoted 2 lines

It looks like this patch made into Linus' tree and broke the driver on ARM devices. Could we please revert it?

If revert the patch, the device will not work on ACPI system, is there some other solution? Have no details about the failure on ARM device.

Quoted 7 lines

I believe it worked on ACPI systems, just runtime PM wasn't suspending the device.

That said, if my comment above was addressed instead of being ignored, this regression wouldn't have happened. The problem is described in my previous messages, please get back to them and address the issue I pointed out.

First of all, thanks for catching this.

What I believe happened was that the patch was merged to my tree before you commented on it and then I missed the related follow-up discussion.

Looking at the patch itself, it seems fine as such but there's a problem with the driver to begin with: the device isn't powered on in probe on DT systems but still its runtime suspend callback is called through pm_runtime_idle().

Quoted 8 lines

Normally calling the RT suspend callback is what we want, but in this case disabling a regulator that wasn't enabled is a problem.

There also seems to be a problem in error handling... and the driver does not support probing while powered off on ACPI. Oh well.

Let's revert the patch now but it seems there's something to fix afterwards.

Thanks Sakari.

One of possible ways to fix this would be to always turn on the regulators in the probe, although it would result in the privacy LED blinking issue on our ARM systems.

Quoted 6 lines
Quoted 3 lines

I wonder if we're missing something in how the ACPI runtime PM works on Linux. It sounds strange to me that the driver needs to be aware of the ACPI internals and know that the default boot-up state is powered

Not really ACPI internals, just that the I涎 devices are powered on for probe.

Do you mean the dev_pm_domain_attach() call at [1]?
I suspect that it wouldn't have any effect on anything other than ACPI. That said, I guess it's indeed a design decision in the I2C subsystem...

One thing that could help here would be adding a .sync callback to acpi_general_pm_domain, which would turn off the ACPI companion device if dev is suspended.

[1] https://elixir.bootlin.com/linux/latest/source/drivers/i2c/i2c-core-base.c#L544

Quoted 8 lines
Quoted 4 lines

on. Maybe there is another function that we could call instead of pm_runtime_set_active()+pm_runtime_idle() that would only shut down the PM domain, while leaving the device itself alone?

Laurent recently complained about the complexities of supporting runtime PM on drivers with both OF and ACPI support. I was planning to reply, will include you.

That would be great, thanks!

Best regards,
Tomasz

#11 lore raw

Tomasz and Sakari,

Is there any conclusion of this support for both OF and ACPI platform?

Quoted 151 lines · Tomasz Figa
Quoted 118 lines · On Wed, Apr 13, 2022 at 10:36 PM [email protected]…

Hi Tomasz,

Quoted 114 lines · Tomasz Figa
Quoted 97 lines · On Wed, Apr 13, 2022 at 8:40 PM [email protected]…

Hi Tomasz, Bingbu,

Quoted 75 lines · Tomasz Figa
Quoted 67 lines · Bingbu Cao
Quoted 63 lines · Tomasz Figa
Quoted 61 lines · Tomasz Figa
Quoted 46 lines · Bingbu
Quoted 38 lines

-----Original Message-----
From: Tomasz Figa <[email protected]>
Sent: Friday, November 5, 2021 2:55 PM
To: Cao, Bingbu <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Qiu, Tian Shu <[email protected]>; [email protected]
Subject: Re: [PATCH] media: dw9768: activate runtime PM and turn off device

Quoted 15 lines · Bingbu Cao

When dw9768 working with ACPI systems, the dw9768 was turned by i2c-core during probe, driver need activate the PM runtime and ask runtime PM to turn off the device.

---
 drivers/media/i2c/dw9768.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/dw9768.c +0 -0
index c086580efac7..65c6acf3ced9 100644

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 475

Quoted 7 lines
drivers/media/i2c/dw9768.c +3 -0
@@ -469,6 +469,11 @@ static int dw9768_probe(struct i2c_client
 *client)
 
        dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
 
+       /*
+        * Device is already turned on by i2c-core with ACPI domain PM.
+        * Attempt to turn off the device to satisfy the privacy LED

concerns.

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 477

Quoted 2 lines
drivers/media/i2c/dw9768.c +2 -0
+        */
+       pm_runtime_set_active(dev);
Quoted 7 lines

This driver is used by non-ACPI systems as well. This change will make the PM core not call the runtime_resume() callback provided by the driver and the power would never be turned on on such systems.

Wasn't the intention of Sakari's ACPI patches to allow bypassing the ACPI domain power on at boot up and eliminate the need for this change?

Quoted 8 lines

Tomasz, thanks for your review.

The comment here is invalid, it should not be strongly related to the privacy LED concern. Anyway, the device should be turned off on ACPI and non-ACPI systems even without Sakari's changes.

I am wondering how the driver work with PM core on non-ACPI system.

On non-ACPI systems it's the driver which handles the power sequencing of the chip so the regulators wouldn't be implicitly enabled by the subsystem before (unless they're shared with some other device and the corresponding driver enabled them).

Quoted 6 lines
Quoted 2 lines

It looks like this patch made into Linus' tree and broke the driver on ARM devices. Could we please revert it?

If revert the patch, the device will not work on ACPI system, is there some other solution? Have no details about the failure on ARM device.

Quoted 7 lines

I believe it worked on ACPI systems, just runtime PM wasn't suspending the device.

That said, if my comment above was addressed instead of being ignored, this regression wouldn't have happened. The problem is described in my previous messages, please get back to them and address the issue I pointed out.

First of all, thanks for catching this.

What I believe happened was that the patch was merged to my tree before you commented on it and then I missed the related follow-up discussion.

Looking at the patch itself, it seems fine as such but there's a problem with the driver to begin with: the device isn't powered on in probe on DT systems but still its runtime suspend callback is called through pm_runtime_idle().

Quoted 8 lines

Normally calling the RT suspend callback is what we want, but in this case disabling a regulator that wasn't enabled is a problem.

There also seems to be a problem in error handling... and the driver does not support probing while powered off on ACPI. Oh well.

Let's revert the patch now but it seems there's something to fix afterwards.

Thanks Sakari.

One of possible ways to fix this would be to always turn on the regulators in the probe, although it would result in the privacy LED blinking issue on our ARM systems.

Quoted 6 lines
Quoted 3 lines

I wonder if we're missing something in how the ACPI runtime PM works on Linux. It sounds strange to me that the driver needs to be aware of the ACPI internals and know that the default boot-up state is powered

Not really ACPI internals, just that the I涎 devices are powered on for probe.

Do you mean the dev_pm_domain_attach() call at [1]?
I suspect that it wouldn't have any effect on anything other than ACPI. That said, I guess it's indeed a design decision in the I2C subsystem...

One thing that could help here would be adding a .sync callback to acpi_general_pm_domain, which would turn off the ACPI companion device if dev is suspended.

[1] https://elixir.bootlin.com/linux/latest/source/drivers/i2c/i2c-core-base.c#L544

Quoted 8 lines
Quoted 4 lines

on. Maybe there is another function that we could call instead of pm_runtime_set_active()+pm_runtime_idle() that would only shut down the PM domain, while leaving the device itself alone?

Laurent recently complained about the complexities of supporting runtime PM on drivers with both OF and ACPI support. I was planning to reply, will include you.

That would be great, thanks!

Best regards,
Tomasz

Signature · 2 lines
Best regards,
Bingbu Cao
#12 lore raw

Hi Bingbu,

Quoted 6 lines · Bingbu Cao

Tomasz and Sakari,

Is there any conclusion of this support for both OF and ACPI platform?

Sakari did indeed reply and add me to the thread, but I somehow missed it, sorry. I just took a look at it and need some time to think about how we could solve this in a general way.

For the time being, I'd just make this driver behave as other drivers
- power the regulators on in probe and let the runtime PM suspend callback power them down. WDYT?

Best regards,
Tomasz

Quoted 157 lines · Tomasz Figa
Quoted 142 lines
Quoted 118 lines · On Wed, Apr 13, 2022 at 10:36 PM [email protected]…

Hi Tomasz,

Quoted 114 lines · Tomasz Figa
Quoted 97 lines · On Wed, Apr 13, 2022 at 8:40 PM [email protected]…

Hi Tomasz, Bingbu,

Quoted 75 lines · Tomasz Figa
Quoted 67 lines · Bingbu Cao
Quoted 63 lines · Tomasz Figa
Quoted 61 lines · Tomasz Figa
Quoted 46 lines · Bingbu
Quoted 38 lines

-----Original Message-----
From: Tomasz Figa <[email protected]>
Sent: Friday, November 5, 2021 2:55 PM
To: Cao, Bingbu <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; Qiu, Tian Shu <[email protected]>; [email protected]
Subject: Re: [PATCH] media: dw9768: activate runtime PM and turn off device

Quoted 15 lines · Bingbu Cao

When dw9768 working with ACPI systems, the dw9768 was turned by i2c-core during probe, driver need activate the PM runtime and ask runtime PM to turn off the device.

---
 drivers/media/i2c/dw9768.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/dw9768.c +0 -0
index c086580efac7..65c6acf3ced9 100644

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 475

Quoted 7 lines
drivers/media/i2c/dw9768.c +3 -0
@@ -469,6 +469,11 @@ static int dw9768_probe(struct i2c_client
 *client)
 
        dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
 
+       /*
+        * Device is already turned on by i2c-core with ACPI domain PM.
+        * Attempt to turn off the device to satisfy the privacy LED

concerns.

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client · line 477

Quoted 2 lines
drivers/media/i2c/dw9768.c +2 -0
+        */
+       pm_runtime_set_active(dev);
Quoted 7 lines

This driver is used by non-ACPI systems as well. This change will make the PM core not call the runtime_resume() callback provided by the driver and the power would never be turned on on such systems.

Wasn't the intention of Sakari's ACPI patches to allow bypassing the ACPI domain power on at boot up and eliminate the need for this change?

Quoted 8 lines

Tomasz, thanks for your review.

The comment here is invalid, it should not be strongly related to the privacy LED concern. Anyway, the device should be turned off on ACPI and non-ACPI systems even without Sakari's changes.

I am wondering how the driver work with PM core on non-ACPI system.

On non-ACPI systems it's the driver which handles the power sequencing of the chip so the regulators wouldn't be implicitly enabled by the subsystem before (unless they're shared with some other device and the corresponding driver enabled them).

Quoted 6 lines
Quoted 2 lines

It looks like this patch made into Linus' tree and broke the driver on ARM devices. Could we please revert it?

If revert the patch, the device will not work on ACPI system, is there some other solution? Have no details about the failure on ARM device.

Quoted 7 lines

I believe it worked on ACPI systems, just runtime PM wasn't suspending the device.

That said, if my comment above was addressed instead of being ignored, this regression wouldn't have happened. The problem is described in my previous messages, please get back to them and address the issue I pointed out.

First of all, thanks for catching this.

What I believe happened was that the patch was merged to my tree before you commented on it and then I missed the related follow-up discussion.

Looking at the patch itself, it seems fine as such but there's a problem with the driver to begin with: the device isn't powered on in probe on DT systems but still its runtime suspend callback is called through pm_runtime_idle().

Quoted 8 lines

Normally calling the RT suspend callback is what we want, but in this case disabling a regulator that wasn't enabled is a problem.

There also seems to be a problem in error handling... and the driver does not support probing while powered off on ACPI. Oh well.

Let's revert the patch now but it seems there's something to fix afterwards.

Thanks Sakari.

One of possible ways to fix this would be to always turn on the regulators in the probe, although it would result in the privacy LED blinking issue on our ARM systems.

Quoted 6 lines
Quoted 3 lines

I wonder if we're missing something in how the ACPI runtime PM works on Linux. It sounds strange to me that the driver needs to be aware of the ACPI internals and know that the default boot-up state is powered

Not really ACPI internals, just that the I涎 devices are powered on for probe.

Do you mean the dev_pm_domain_attach() call at [1]?
I suspect that it wouldn't have any effect on anything other than ACPI. That said, I guess it's indeed a design decision in the I2C subsystem...

One thing that could help here would be adding a .sync callback to acpi_general_pm_domain, which would turn off the ACPI companion device if dev is suspended.

[1] https://elixir.bootlin.com/linux/latest/source/drivers/i2c/i2c-core-base.c#L544

Quoted 5 lines
Quoted 4 lines

on. Maybe there is another function that we could call instead of pm_runtime_set_active()+pm_runtime_idle() that would only shut down the PM domain, while leaving the device itself alone?

Quoted 9 lines
Quoted 3 lines

Laurent recently complained about the complexities of supporting runtime PM on drivers with both OF and ACPI support. I was planning to reply, will include you.

That would be great, thanks!

Best regards,
Tomasz

--
Best regards,
Bingbu Cao

#13 lore raw
In reply to Tomasz Figa
Quoted 19 lines · Tomasz Figa
Quoted 18 lines · Bingbu Cao

When dw9768 working with ACPI systems, the dw9768 was turned by i2c-core during probe, driver need activate the PM runtime and ask runtime PM to turn off the device.

---
 drivers/media/i2c/dw9768.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/dw9768.c +0 -0
index c086580efac7..65c6acf3ced9 100644
@@ -469,6 +469,11 @@ static int dw9768_probe(struct i2c_client *client)
 
        dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
 
Quoted 9 lines

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client *client) · line 476

Quoted 5 lines
drivers/media/i2c/dw9768.c +5 -0
+       /*
+        * Device is already turned on by i2c-core with ACPI domain PM.
+        * Attempt to turn off the device to satisfy the privacy LED concerns.
+        */
+       pm_runtime_set_active(dev);

This driver is used by non-ACPI systems as well. This change will make the PM core not call the runtime_resume() callback provided by the driver and the power would never be turned on on such systems.

Tomasz,

Why the runtime_set_active() and runtime_idle() break the runtime PM on non-ACPI systems? Did it cause the PM runtime enable failure or incorrect PM usage count?

Quoted 23 lines

Wasn't the intention of Sakari's ACPI patches to allow bypassing the ACPI domain power on at boot up and eliminate the need for this change?

Best regards,
Tomasz

Quoted 15 lines
drivers/media/i2c/dw9768.c +1 -1
        pm_runtime_enable(dev);
        if (!pm_runtime_enabled(dev)) {
                ret = dw9768_runtime_resume(dev);
@@ -483,6 +488,7 @@ static int dw9768_probe(struct i2c_client *client)
                dev_err(dev, "failed to register V4L2 subdev: %d", ret);
                goto err_power_off;
        }
+       pm_runtime_idle(dev);
 
        return 0;
 
--

2.7.4

Signature · 2 lines
Best regards,
Bingbu Cao
#14 lore raw
Quoted 32 lines · Bingbu Cao
Quoted 19 lines · Tomasz Figa
Quoted 18 lines · Bingbu Cao

When dw9768 working with ACPI systems, the dw9768 was turned by i2c-core during probe, driver need activate the PM runtime and ask runtime PM to turn off the device.

---
 drivers/media/i2c/dw9768.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/i2c/dw9768.c +0 -0
index c086580efac7..65c6acf3ced9 100644
@@ -469,6 +469,11 @@ static int dw9768_probe(struct i2c_client *client)
 
        dw9768->sd.entity.function = MEDIA_ENT_F_LENS;
 
Quoted 9 lines

drivers/media/i2c/dw9768.c static int dw9768_probe(struct i2c_client *client) · line 476

Quoted 5 lines
drivers/media/i2c/dw9768.c +5 -0
+       /*
+        * Device is already turned on by i2c-core with ACPI domain PM.
+        * Attempt to turn off the device to satisfy the privacy LED concerns.
+        */
+       pm_runtime_set_active(dev);

This driver is used by non-ACPI systems as well. This change will make the PM core not call the runtime_resume() callback provided by the driver and the power would never be turned on on such systems.

Quoted 5 lines

Tomasz,

Why the runtime_set_active() and runtime_idle() break the runtime PM on non-ACPI systems? Did it cause the PM runtime enable failure or incorrect PM usage count?

Neither. It tells the runtime PM subsystem that the device was manually brought into the active state, but the driver doesn't power on the voltage regulators. Then there are 2 paths to failure:

1) pm_runtime_idle() triggers a runtime PM suspend and driver callback tries to power off the already powered off regulators, leading to a negative regulator usage count.

OR

2) userspace opens the device, runtime PM resume doesn't happen (because the device is still active) and then a communication failure would happen because the chip is not powered on.

Best regards,
Tomasz

Quoted 28 lines
Quoted 19 lines

Wasn't the intention of Sakari's ACPI patches to allow bypassing the ACPI domain power on at boot up and eliminate the need for this change?

Best regards,
Tomasz

Quoted 10 lines
drivers/media/i2c/dw9768.c +1 -0
        pm_runtime_enable(dev);
        if (!pm_runtime_enabled(dev)) {
                ret = dw9768_runtime_resume(dev);
@@ -483,6 +488,7 @@ static int dw9768_probe(struct i2c_client *client)
                dev_err(dev, "failed to register V4L2 subdev: %d", ret);
                goto err_power_off;
        }
+       pm_runtime_idle(dev);
 
Quoted 5 lines
Quoted 5 lines
drivers/media/i2c/dw9768.c +0 -1
        return 0;
 
--

2.7.4

--
Best regards,
Bingbu Cao