linux-pwm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] backlight: pwm_bl: apply the initial backlight state with sane defaults
@ 2025-07-31  8:47 Michael Grzeschik
  2025-08-01  6:32 ` Uwe Kleine-König
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Michael Grzeschik @ 2025-07-31  8:47 UTC (permalink / raw)
  To: Uwe Kleine-König, Lee Jones, Daniel Thompson, Jingoo Han,
	Helge Deller
  Cc: Pengutronix, linux-pwm, dri-devel, linux-fbdev, linux-kernel,
	Michael Grzeschik

Currently when calling pwm_apply_might_sleep in the probe routine
the pwm will be configured with an not fully defined state.

The duty_cycle is not yet set in that moment. There is a final
backlight_update_status call that will have a properly setup state.
However this change in the backlight can create a short flicker if the
backlight was already preinitialised.

We fix the flicker by moving the pwm_apply after the default duty_cycle
can be calculated.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
---
 drivers/video/backlight/pwm_bl.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 237d3d3f3bb1a..5924e0b9f01e7 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -518,13 +518,6 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 	if (!state.period && (data->pwm_period_ns > 0))
 		state.period = data->pwm_period_ns;
 
-	ret = pwm_apply_might_sleep(pb->pwm, &state);
-	if (ret) {
-		dev_err_probe(&pdev->dev, ret,
-			      "failed to apply initial PWM state");
-		goto err_alloc;
-	}
-
 	memset(&props, 0, sizeof(struct backlight_properties));
 
 	if (data->levels) {
@@ -582,6 +575,15 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 	pb->lth_brightness = data->lth_brightness * (div_u64(state.period,
 				pb->scale));
 
+	state.duty_cycle = compute_duty_cycle(pb, data->dft_brightness, &state);
+
+	ret = pwm_apply_might_sleep(pb->pwm, &state);
+	if (ret) {
+		dev_err_probe(&pdev->dev, ret,
+			      "failed to apply initial PWM state");
+		goto err_alloc;
+	}
+
 	props.type = BACKLIGHT_RAW;
 	props.max_brightness = data->max_brightness;
 	bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb,

---
base-commit: 739a6c93cc755c0daf3a7e57e018a8c61047cd90
change-id: 20250731-blpwm-598ecad93c4d

Best regards,
-- 
Michael Grzeschik <m.grzeschik@pengutronix.de>


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] backlight: pwm_bl: apply the initial backlight state with sane defaults
  2025-07-31  8:47 [PATCH] backlight: pwm_bl: apply the initial backlight state with sane defaults Michael Grzeschik
@ 2025-08-01  6:32 ` Uwe Kleine-König
  2025-09-09 13:49   ` Uwe Kleine-König
  2025-10-30 11:51 ` Daniel Thompson
  2025-11-06 16:59 ` (subset) " Lee Jones
  2 siblings, 1 reply; 9+ messages in thread
From: Uwe Kleine-König @ 2025-08-01  6:32 UTC (permalink / raw)
  To: Michael Grzeschik
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller, Pengutronix,
	linux-pwm, dri-devel, linux-fbdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2619 bytes --]

Hallo Michael,

On Thu, Jul 31, 2025 at 10:47:18AM +0200, Michael Grzeschik wrote:
> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index 237d3d3f3bb1a..5924e0b9f01e7 100644
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> @@ -518,13 +518,6 @@ static int pwm_backlight_probe(struct platform_device *pdev)
>  	if (!state.period && (data->pwm_period_ns > 0))
>  		state.period = data->pwm_period_ns;
>  
> -	ret = pwm_apply_might_sleep(pb->pwm, &state);
> -	if (ret) {
> -		dev_err_probe(&pdev->dev, ret,
> -			      "failed to apply initial PWM state");
> -		goto err_alloc;
> -	}
> -
>  	memset(&props, 0, sizeof(struct backlight_properties));
>  
>  	if (data->levels) {
> @@ -582,6 +575,15 @@ static int pwm_backlight_probe(struct platform_device *pdev)
>  	pb->lth_brightness = data->lth_brightness * (div_u64(state.period,
>  				pb->scale));
>  
> +	state.duty_cycle = compute_duty_cycle(pb, data->dft_brightness, &state);
> +
> +	ret = pwm_apply_might_sleep(pb->pwm, &state);
> +	if (ret) {
> +		dev_err_probe(&pdev->dev, ret,
> +			      "failed to apply initial PWM state");
> +		goto err_alloc;
> +	}
> +

I wonder why the PWM is updated at all in .probe(). Wouldn't it be the
natural thing to keep the PWM configured as it was (in its reset default
state or how the bootloader set it up)?

Orthogonal to your change, while looking at the driver I wondered about:

        bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb,
                                       &pwm_backlight_ops, &props);
        if (IS_ERR(bl)) {
                ret = dev_err_probe(&pdev->dev, PTR_ERR(bl),
                                    "failed to register backlight\n");
                goto err_alloc;
        }

        if (data->dft_brightness > data->max_brightness) {
                dev_warn(&pdev->dev,
                         "invalid default brightness level: %u, using %u\n",
                         data->dft_brightness, data->max_brightness);
                data->dft_brightness = data->max_brightness;
        }

        bl->props.brightness = data->dft_brightness;
        bl->props.power = pwm_backlight_initial_power_state(pb);
        backlight_update_status(bl);

Shoudn't setting data->dft_brightness, bl->props.brightness and
bl->props.power better happen before backlight_device_register()? Also
calling backlight_update_status() after backlight_device_register()
seems wrong to me, I'd claim the backend driver shouldn't call that.

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] backlight: pwm_bl: apply the initial backlight state with sane defaults
  2025-08-01  6:32 ` Uwe Kleine-König
@ 2025-09-09 13:49   ` Uwe Kleine-König
  2025-09-10  7:33     ` Michael Grzeschik
  0 siblings, 1 reply; 9+ messages in thread
From: Uwe Kleine-König @ 2025-09-09 13:49 UTC (permalink / raw)
  To: Michael Grzeschik
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller, Pengutronix,
	linux-pwm, dri-devel, linux-fbdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2924 bytes --]

Hello Michael,

On Fri, Aug 01, 2025 at 08:32:20AM +0200, Uwe Kleine-König wrote:
> Hallo Michael,
> 
> On Thu, Jul 31, 2025 at 10:47:18AM +0200, Michael Grzeschik wrote:
> > diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> > index 237d3d3f3bb1a..5924e0b9f01e7 100644
> > --- a/drivers/video/backlight/pwm_bl.c
> > +++ b/drivers/video/backlight/pwm_bl.c
> > @@ -518,13 +518,6 @@ static int pwm_backlight_probe(struct platform_device *pdev)
> >  	if (!state.period && (data->pwm_period_ns > 0))
> >  		state.period = data->pwm_period_ns;
> >  
> > -	ret = pwm_apply_might_sleep(pb->pwm, &state);
> > -	if (ret) {
> > -		dev_err_probe(&pdev->dev, ret,
> > -			      "failed to apply initial PWM state");
> > -		goto err_alloc;
> > -	}
> > -
> >  	memset(&props, 0, sizeof(struct backlight_properties));
> >  
> >  	if (data->levels) {
> > @@ -582,6 +575,15 @@ static int pwm_backlight_probe(struct platform_device *pdev)
> >  	pb->lth_brightness = data->lth_brightness * (div_u64(state.period,
> >  				pb->scale));
> >  
> > +	state.duty_cycle = compute_duty_cycle(pb, data->dft_brightness, &state);
> > +
> > +	ret = pwm_apply_might_sleep(pb->pwm, &state);
> > +	if (ret) {
> > +		dev_err_probe(&pdev->dev, ret,
> > +			      "failed to apply initial PWM state");
> > +		goto err_alloc;
> > +	}
> > +
> 
> I wonder why the PWM is updated at all in .probe(). Wouldn't it be the
> natural thing to keep the PWM configured as it was (in its reset default
> state or how the bootloader set it up)?
> 
> Orthogonal to your change, while looking at the driver I wondered about:
> 
>         bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb,
>                                        &pwm_backlight_ops, &props);
>         if (IS_ERR(bl)) {
>                 ret = dev_err_probe(&pdev->dev, PTR_ERR(bl),
>                                     "failed to register backlight\n");
>                 goto err_alloc;
>         }
> 
>         if (data->dft_brightness > data->max_brightness) {
>                 dev_warn(&pdev->dev,
>                          "invalid default brightness level: %u, using %u\n",
>                          data->dft_brightness, data->max_brightness);
>                 data->dft_brightness = data->max_brightness;
>         }
> 
>         bl->props.brightness = data->dft_brightness;
>         bl->props.power = pwm_backlight_initial_power_state(pb);
>         backlight_update_status(bl);
> 
> Shoudn't setting data->dft_brightness, bl->props.brightness and
> bl->props.power better happen before backlight_device_register()? Also
> calling backlight_update_status() after backlight_device_register()
> seems wrong to me, I'd claim the backend driver shouldn't call that.

Do you intend to work on this orthogonal feedback? If not, I'll put it
on my todo list.

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] backlight: pwm_bl: apply the initial backlight state with sane defaults
  2025-09-09 13:49   ` Uwe Kleine-König
@ 2025-09-10  7:33     ` Michael Grzeschik
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Grzeschik @ 2025-09-10  7:33 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller, Pengutronix,
	linux-pwm, dri-devel, linux-fbdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3533 bytes --]

Hi Uwe

On Tue, Sep 09, 2025 at 03:49:22PM +0200, Uwe Kleine-König wrote:
>On Fri, Aug 01, 2025 at 08:32:20AM +0200, Uwe Kleine-König wrote:
>> On Thu, Jul 31, 2025 at 10:47:18AM +0200, Michael Grzeschik wrote:
>> > diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
>> > index 237d3d3f3bb1a..5924e0b9f01e7 100644
>> > --- a/drivers/video/backlight/pwm_bl.c
>> > +++ b/drivers/video/backlight/pwm_bl.c
>> > @@ -518,13 +518,6 @@ static int pwm_backlight_probe(struct platform_device *pdev)
>> >  	if (!state.period && (data->pwm_period_ns > 0))
>> >  		state.period = data->pwm_period_ns;
>> >
>> > -	ret = pwm_apply_might_sleep(pb->pwm, &state);
>> > -	if (ret) {
>> > -		dev_err_probe(&pdev->dev, ret,
>> > -			      "failed to apply initial PWM state");
>> > -		goto err_alloc;
>> > -	}
>> > -
>> >  	memset(&props, 0, sizeof(struct backlight_properties));
>> >
>> >  	if (data->levels) {
>> > @@ -582,6 +575,15 @@ static int pwm_backlight_probe(struct platform_device *pdev)
>> >  	pb->lth_brightness = data->lth_brightness * (div_u64(state.period,
>> >  				pb->scale));
>> >
>> > +	state.duty_cycle = compute_duty_cycle(pb, data->dft_brightness, &state);
>> > +
>> > +	ret = pwm_apply_might_sleep(pb->pwm, &state);
>> > +	if (ret) {
>> > +		dev_err_probe(&pdev->dev, ret,
>> > +			      "failed to apply initial PWM state");
>> > +		goto err_alloc;
>> > +	}
>> > +
>>
>> I wonder why the PWM is updated at all in .probe(). Wouldn't it be the
>> natural thing to keep the PWM configured as it was (in its reset default
>> state or how the bootloader set it up)?
>>
>> Orthogonal to your change, while looking at the driver I wondered about:
>>
>>         bl = backlight_device_register(dev_name(&pdev->dev), &pdev->dev, pb,
>>                                        &pwm_backlight_ops, &props);
>>         if (IS_ERR(bl)) {
>>                 ret = dev_err_probe(&pdev->dev, PTR_ERR(bl),
>>                                     "failed to register backlight\n");
>>                 goto err_alloc;
>>         }
>>
>>         if (data->dft_brightness > data->max_brightness) {
>>                 dev_warn(&pdev->dev,
>>                          "invalid default brightness level: %u, using %u\n",
>>                          data->dft_brightness, data->max_brightness);
>>                 data->dft_brightness = data->max_brightness;
>>         }
>>
>>         bl->props.brightness = data->dft_brightness;
>>         bl->props.power = pwm_backlight_initial_power_state(pb);
>>         backlight_update_status(bl);
>>
>> Shoudn't setting data->dft_brightness, bl->props.brightness and
>> bl->props.power better happen before backlight_device_register()? Also
>> calling backlight_update_status() after backlight_device_register()
>> seems wrong to me, I'd claim the backend driver shouldn't call that.
>
>Do you intend to work on this orthogonal feedback? If not, I'll put it
>on my todo list.

Oh, yes, the orthogonal feedback. Thanks for the reminder of this
actually intended patch not being ready. I will work on this first. If you
like, please take the opurtunity to fix the issue you found.

Regards,
Michael

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] backlight: pwm_bl: apply the initial backlight state with sane defaults
  2025-07-31  8:47 [PATCH] backlight: pwm_bl: apply the initial backlight state with sane defaults Michael Grzeschik
  2025-08-01  6:32 ` Uwe Kleine-König
@ 2025-10-30 11:51 ` Daniel Thompson
  2025-11-07  8:00   ` Uwe Kleine-König
  2025-11-06 16:59 ` (subset) " Lee Jones
  2 siblings, 1 reply; 9+ messages in thread
From: Daniel Thompson @ 2025-10-30 11:51 UTC (permalink / raw)
  To: Michael Grzeschik
  Cc: Uwe Kleine-König, Lee Jones, Jingoo Han, Helge Deller,
	Pengutronix, linux-pwm, dri-devel, linux-fbdev, linux-kernel

On Thu, Jul 31, 2025 at 10:47:18AM +0200, Michael Grzeschik wrote:
> Currently when calling pwm_apply_might_sleep in the probe routine
> the pwm will be configured with an not fully defined state.
>
> The duty_cycle is not yet set in that moment. There is a final
> backlight_update_status call that will have a properly setup state.
> However this change in the backlight can create a short flicker if the
> backlight was already preinitialised.
>
> We fix the flicker by moving the pwm_apply after the default duty_cycle
> can be calculated.
>
> Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>

Reviewed-by: Daniel Thompson (RISCstar) <danielt@kernel.org>


Daniel.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: (subset) [PATCH] backlight: pwm_bl: apply the initial backlight state with sane defaults
  2025-07-31  8:47 [PATCH] backlight: pwm_bl: apply the initial backlight state with sane defaults Michael Grzeschik
  2025-08-01  6:32 ` Uwe Kleine-König
  2025-10-30 11:51 ` Daniel Thompson
@ 2025-11-06 16:59 ` Lee Jones
  2 siblings, 0 replies; 9+ messages in thread
From: Lee Jones @ 2025-11-06 16:59 UTC (permalink / raw)
  To: Uwe Kleine-König, Lee Jones, Daniel Thompson, Jingoo Han,
	Helge Deller, Michael Grzeschik
  Cc: Pengutronix, linux-pwm, dri-devel, linux-fbdev, linux-kernel

On Thu, 31 Jul 2025 10:47:18 +0200, Michael Grzeschik wrote:
> Currently when calling pwm_apply_might_sleep in the probe routine
> the pwm will be configured with an not fully defined state.
> 
> The duty_cycle is not yet set in that moment. There is a final
> backlight_update_status call that will have a properly setup state.
> However this change in the backlight can create a short flicker if the
> backlight was already preinitialised.
> 
> [...]

Applied, thanks!

[1/1] backlight: pwm_bl: apply the initial backlight state with sane defaults
      commit: c596a53cb0c607ccff34aac30ada774aa28b7dc0

--
Lee Jones [李琼斯]


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] backlight: pwm_bl: apply the initial backlight state with sane defaults
  2025-10-30 11:51 ` Daniel Thompson
@ 2025-11-07  8:00   ` Uwe Kleine-König
  2025-11-07 14:51     ` Daniel Thompson
  0 siblings, 1 reply; 9+ messages in thread
From: Uwe Kleine-König @ 2025-11-07  8:00 UTC (permalink / raw)
  To: Daniel Thompson, Lee Jones
  Cc: Michael Grzeschik, Jingoo Han, Helge Deller, Pengutronix,
	linux-pwm, dri-devel, linux-fbdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 947 bytes --]

On Thu, Oct 30, 2025 at 11:51:07AM +0000, Daniel Thompson wrote:
> On Thu, Jul 31, 2025 at 10:47:18AM +0200, Michael Grzeschik wrote:
> > Currently when calling pwm_apply_might_sleep in the probe routine
> > the pwm will be configured with an not fully defined state.
> >
> > The duty_cycle is not yet set in that moment. There is a final
> > backlight_update_status call that will have a properly setup state.
> > However this change in the backlight can create a short flicker if the
> > backlight was already preinitialised.
> >
> > We fix the flicker by moving the pwm_apply after the default duty_cycle
> > can be calculated.
> >
> > Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> 
> Reviewed-by: Daniel Thompson (RISCstar) <danielt@kernel.org>

I guess this tag resulted in Lee picking up the change. I wonder if you
share my concern and who's responsibility it is now to address it.

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] backlight: pwm_bl: apply the initial backlight state with sane defaults
  2025-11-07  8:00   ` Uwe Kleine-König
@ 2025-11-07 14:51     ` Daniel Thompson
  2025-11-07 15:48       ` Michael Grzeschik
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Thompson @ 2025-11-07 14:51 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Daniel Thompson, Lee Jones, Michael Grzeschik, Jingoo Han,
	Helge Deller, Pengutronix, linux-pwm, dri-devel, linux-fbdev,
	linux-kernel

On Fri, Nov 07, 2025 at 09:00:33AM +0100, Uwe Kleine-König wrote:
> On Thu, Oct 30, 2025 at 11:51:07AM +0000, Daniel Thompson wrote:
> > On Thu, Jul 31, 2025 at 10:47:18AM +0200, Michael Grzeschik wrote:
> > > Currently when calling pwm_apply_might_sleep in the probe routine
> > > the pwm will be configured with an not fully defined state.
> > >
> > > The duty_cycle is not yet set in that moment. There is a final
> > > backlight_update_status call that will have a properly setup state.
> > > However this change in the backlight can create a short flicker if the
> > > backlight was already preinitialised.
> > >
> > > We fix the flicker by moving the pwm_apply after the default duty_cycle
> > > can be calculated.
> > >
> > > Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
> >
> > Reviewed-by: Daniel Thompson (RISCstar) <danielt@kernel.org>
>
> I guess this tag resulted in Lee picking up the change. I wonder if you
> share my concern and who's responsibility it is now to address it.

You mean the ordering the backlight registration versus setting the
properties in the probe method?

I definitely share the concern that there's a short window where
something could request a brightness via sysfs and then have it
overwritten by the remains of the probe method. Likewise I can't see
why there would be any problem moving the call to
pwm_backlight_initial_power_state() before the backlight is registered.
Thus I'd be happy to see the backlight registered later in the probe
method.

On the other hand I don't see any problem calling
backlight_update_status() from the probe method. This is a relatively
common approach in backlight drivers to impose the initial brightness
on the hardware without needing extra code paths.
backlight_update_status() is guarded with a mutex and should be
idempotent for most drivers. Therefore it is OK even if something gets
in via sysfs and provokes an update before the probe method has started
it's own update.

In terms of who should follow up I've got no strong opinions on that.
It's worth noting that I don't own any hardware that uses a PWM
backlight so I'm not in a position to test it!


Daniel.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] backlight: pwm_bl: apply the initial backlight state with sane defaults
  2025-11-07 14:51     ` Daniel Thompson
@ 2025-11-07 15:48       ` Michael Grzeschik
  0 siblings, 0 replies; 9+ messages in thread
From: Michael Grzeschik @ 2025-11-07 15:48 UTC (permalink / raw)
  To: Daniel Thompson
  Cc: Uwe Kleine-König, Daniel Thompson, Lee Jones, Jingoo Han,
	Helge Deller, Pengutronix, linux-pwm, dri-devel, linux-fbdev,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2866 bytes --]

On Fri, Nov 07, 2025 at 02:51:15PM +0000, Daniel Thompson wrote:
>On Fri, Nov 07, 2025 at 09:00:33AM +0100, Uwe Kleine-König wrote:
>> On Thu, Oct 30, 2025 at 11:51:07AM +0000, Daniel Thompson wrote:
>> > On Thu, Jul 31, 2025 at 10:47:18AM +0200, Michael Grzeschik wrote:
>> > > Currently when calling pwm_apply_might_sleep in the probe routine
>> > > the pwm will be configured with an not fully defined state.
>> > >
>> > > The duty_cycle is not yet set in that moment. There is a final
>> > > backlight_update_status call that will have a properly setup state.
>> > > However this change in the backlight can create a short flicker if the
>> > > backlight was already preinitialised.
>> > >
>> > > We fix the flicker by moving the pwm_apply after the default duty_cycle
>> > > can be calculated.
>> > >
>> > > Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
>> >
>> > Reviewed-by: Daniel Thompson (RISCstar) <danielt@kernel.org>
>>
>> I guess this tag resulted in Lee picking up the change. I wonder if you
>> share my concern and who's responsibility it is now to address it.
>
>You mean the ordering the backlight registration versus setting the
>properties in the probe method?
>
>I definitely share the concern that there's a short window where
>something could request a brightness via sysfs and then have it
>overwritten by the remains of the probe method. Likewise I can't see
>why there would be any problem moving the call to
>pwm_backlight_initial_power_state() before the backlight is registered.
>Thus I'd be happy to see the backlight registered later in the probe
>method.
>
>On the other hand I don't see any problem calling
>backlight_update_status() from the probe method. This is a relatively
>common approach in backlight drivers to impose the initial brightness
>on the hardware without needing extra code paths.
>backlight_update_status() is guarded with a mutex and should be
>idempotent for most drivers. Therefore it is OK even if something gets
>in via sysfs and provokes an update before the probe method has started
>it's own update.
>
>In terms of who should follow up I've got no strong opinions on that.
>It's worth noting that I don't own any hardware that uses a PWM
>backlight so I'm not in a position to test it!

Depending on the setup of the hardware, calling pwm_apply_might_sleep
inbetween before having a fixed definition of how the pwm should be
setup, makes the backlight flicker. Therefor it is better to touch
it as late as possible.

Michael

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-11-07 15:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-31  8:47 [PATCH] backlight: pwm_bl: apply the initial backlight state with sane defaults Michael Grzeschik
2025-08-01  6:32 ` Uwe Kleine-König
2025-09-09 13:49   ` Uwe Kleine-König
2025-09-10  7:33     ` Michael Grzeschik
2025-10-30 11:51 ` Daniel Thompson
2025-11-07  8:00   ` Uwe Kleine-König
2025-11-07 14:51     ` Daniel Thompson
2025-11-07 15:48       ` Michael Grzeschik
2025-11-06 16:59 ` (subset) " Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).