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] [thread-next>] [day] [month] [year] [list]
Message-ID: <2knipwg44si6rajfcg7e2wxfcjxo625yswkh5v4tsbc4eyvp7r@lhfqj2ngb4rd>
Date: Tue, 5 Aug 2025 15:27:44 +0200
From: Uwe Kleine-König <ukleinek@...nel.org>
To: Biju <biju.das.au@...il.com>
Cc: Biju Das <biju.das.jz@...renesas.com>, linux-pwm@...r.kernel.org, 
	linux-kernel@...r.kernel.org, Geert Uytterhoeven <geert+renesas@...der.be>, 
	Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@...renesas.com>, linux-renesas-soc@...r.kernel.org
Subject: Re: [PATCH] pwm: rzg2l-gpt: Implementation of the waveform callbacks

Hello Biju,

On Tue, Aug 05, 2025 at 07:50:23AM +0100, Biju wrote:
> From: Biju Das <biju.das.jz@...renesas.com>
> 
> Convert the rzg2l-gpt driver to use the new callbacks for hardware
> programming.

You picked a great project!

> +static int rzg2l_gpt_round_waveform_tohw(struct pwm_chip *chip,
> +					 struct pwm_device *pwm,
> +					 const struct pwm_waveform *wf,
> +					 void *_wfhw)
> +
>  {
>  	struct rzg2l_gpt_chip *rzg2l_gpt = to_rzg2l_gpt_chip(chip);
> -	u8 sub_ch = rzg2l_gpt_subchannel(pwm->hwpwm);
> +	struct rzg2l_gpt_waveform *wfhw = _wfhw;
>  	u8 ch = RZG2L_GET_CH(pwm->hwpwm);
>  	u64 period_ticks, duty_ticks;
>  	unsigned long pv, dc;
> -	u8 prescale;
> +
> +	guard(mutex)(&rzg2l_gpt->lock);
> +	if (wf->period_length_ns == 0) {
> +		*wfhw = (struct rzg2l_gpt_waveform){
> +			.gtpr = 0,
> +			.gtccr = 0,
> +		};
> +
> +		if (rzg2l_gpt_is_ch_enabled(rzg2l_gpt, pwm->hwpwm))
> +			rzg2l_gpt_disable(rzg2l_gpt, pwm);

This is wrong. the .round_waveform_tohw() callback isn't supposed to
modify hardware. It's only supposed to tell the caller about the
current possibilities of the corresponding device.

> +		return 0;
> +	}
>  
>  	/* Limit period/duty cycle to max value supported by the HW */
> -	period_ticks = mul_u64_u64_div_u64(state->period, rzg2l_gpt->rate_khz, USEC_PER_SEC);
> +	period_ticks = mul_u64_u64_div_u64(wf->period_length_ns, rzg2l_gpt->rate_khz, USEC_PER_SEC);
>  	if (period_ticks > RZG2L_MAX_TICKS)
>  		period_ticks = RZG2L_MAX_TICKS;
>  	/*

Otherwise it looks good from a quick glance.

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