lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <xltamao27utfrsax2pc6mh5tthanmrqszz4k7gyw3knqkm24xp@4tydmhfh6g4j>
Date: Wed, 26 Feb 2025 17:34:50 +0100
From: Uwe Kleine-König <ukleinek@...nel.org>
To: Abel Vesa <abel.vesa@...aro.org>
Cc: Lee Jones <lee@...nel.org>, Daniel Thompson <danielt@...nel.org>, 
	Jingoo Han <jingoohan1@...il.com>, Helge Deller <deller@....de>, 
	Bjorn Andersson <andersson@...nel.org>, Konrad Dybcio <konradybcio@...nel.org>, 
	Johan Hovold <johan@...nel.org>, Sebastian Reichel <sre@...nel.org>, linux-pwm@...r.kernel.org, 
	dri-devel@...ts.freedesktop.org, linux-arm-msm@...r.kernel.org, linux-fbdev@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH RFC] backlight: pwm_bl: Read back PWM period from provider

Hello,

On Wed, Feb 26, 2025 at 05:31:08PM +0200, Abel Vesa wrote:
> The current implementation assumes that the PWM provider will be able to
> meet the requested period, but that is not always the case. Some PWM
> providers have limited HW configuration capabilities and can only
> provide a period that is somewhat close to the requested one. This
> simply means that the duty cycle requested might either be above the
> PWM's maximum value or the 100% duty cycle is never reached.

If you request a state with 100% relative duty cycle you should get 100%
unless the hardware cannot do that. Which PWM hardware are you using?
Which requests are you actually doing that don't match your expectation?
 
> This could be easily fixed if the pwm_apply*() API family would allow
> overriding the period within the PWM state that's used for providing the
> duty cycle. But that is currently not the case.

I don't understand what you mean here.

> So easiest fix here is to read back the period from the PWM provider via
> the provider's ->get_state() op, if implemented, which should provide the
> best matched period. Do this on probe after the first ->pwm_apply() op has
> been done, which will allow the provider to determine the best match
> period based on available configuration knobs. From there on, the
> backlight will use the best matched period, since the driver's internal
> PWM state is now synced up with the one from provider.
> [...]
> diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
> index 237d3d3f3bb1a6d713c5f6ec3198af772bf1268c..71a3e9cd8844095e85c01b194d7466978f1ca78e 100644
> --- a/drivers/video/backlight/pwm_bl.c
> +++ b/drivers/video/backlight/pwm_bl.c
> @@ -525,6 +525,17 @@ static int pwm_backlight_probe(struct platform_device *pdev)
>  		goto err_alloc;
>  	}
>  
> +	/*
> +	 * The actual period might differ from the requested one due to HW
> +	 * limitations, so sync up the period with one determined by the
> +	 * provider driver.
> +	 */
> +	ret = pwm_get_state_hw(pb->pwm, &pb->pwm->state);

As a consumer you're not supposed to write to &pb->pwm->state. That's a
layer violation. Please call pwm_get_state_hw() with a struct pwm_state
that you own and save the relevant parts in your driver data.

> +	if (ret && ret != -EOPNOTSUPP) {
> +		dev_err(&pdev->dev, "failed to get PWM HW state");
> +		goto err_alloc;
> +	}
> +
>  	memset(&props, 0, sizeof(struct backlight_properties));
>  
>  	if (data->levels) {

Best regards
Uwe

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ