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:
 <TY3PR01MB113462E5CA7107FBC2EA962B386D7A@TY3PR01MB11346.jpnprd01.prod.outlook.com>
Date: Wed, 19 Nov 2025 16:07:17 +0000
From: Biju Das <biju.das.jz@...renesas.com>
To: Uwe Kleine-König <ukleinek@...nel.org>
CC: biju.das.au <biju.das.au@...il.com>, "linux-pwm@...r.kernel.org"
	<linux-pwm@...r.kernel.org>, "linux-kernel@...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" <linux-renesas-soc@...r.kernel.org>,
	"stable@...nel.org" <stable@...nel.org>
Subject: RE: [PATCH v4] pwm: rzg2l-gpt: Reinitialize the cache value in
 rzg2l_gpt_disable()

Hi Uwe,

Thanks for the feedback.

> -----Original Message-----
> From: Uwe Kleine-König <ukleinek@...nel.org>
> Sent: 18 November 2025 22:24
> Subject: Re: [PATCH v4] pwm: rzg2l-gpt: Reinitialize the cache value in rzg2l_gpt_disable()
> 
> Hello Biju,
> 
> On Tue, Nov 18, 2025 at 05:03:34PM +0000, Biju Das wrote:
> > > On Fri, Nov 14, 2025 at 02:56:01PM +0000, Biju wrote:
> > > > diff --git a/drivers/pwm/pwm-rzg2l-gpt.c
> > > > b/drivers/pwm/pwm-rzg2l-gpt.c index 360c8bf3b190..ab91bfd7da48
> > > > 100644
> > > > --- a/drivers/pwm/pwm-rzg2l-gpt.c
> > > > +++ b/drivers/pwm/pwm-rzg2l-gpt.c
> > > > @@ -190,8 +190,17 @@ static void rzg2l_gpt_disable(struct rzg2l_gpt_chip *rzg2l_gpt,
> > > >  	/* Stop count, Output low on GTIOCx pin when counting stops */
> > > >  	rzg2l_gpt->channel_enable_count[ch]--;
> > > >
> > > > -	if (!rzg2l_gpt->channel_enable_count[ch])
> > > > +	if (!rzg2l_gpt->channel_enable_count[ch]) {
> > > >  		rzg2l_gpt_modify(rzg2l_gpt, RZG2L_GTCR(ch), RZG2L_GTCR_CST, 0);
> > > > +		/*
> > > > +		 * The rzg2l_gpt_config() test the rzg2l_gpt->period_tick
> > > > +		 * variable. This check is not valid, if enabling of a channel
> > > > +		 * happens after disabling all the channels as it test against
> > > > +		 * the cached value. Therefore, reinitialize the variable
> > > > +		 * rzg2l_gpt->period_tick to 0.
> > > > +		 */
> > > > +		rzg2l_gpt->period_ticks[ch] = 0;
> > > > +	}
> > >
> > > I think this is wrong. rzg2l_gpt_config() has:
> > >
> > >         if (rzg2l_gpt->channel_request_count[ch] > 1) {
> > >                 if (period_ticks < rzg2l_gpt->period_ticks[ch])
> > >                         return -EBUSY;
> > >                 else
> > >                         period_ticks = rzg2l_gpt->period_ticks[ch];
> > >         }
> > >
> > > So if both PWMs of channel `ch` are requested but disabled,
> > > rzg2l_gpt->period_ticks[ch] is 0 so you assign
> > >
> > > 	period_ticks = rzg2l_gpt->period_ticks[ch];
> > >
> > > . In that case however you don't want to change period_ticks, right?
> >
> >
> > Yes, what about adding the check that won't allow to set 0 period in this case.
> >
> > if ((rzg2l_gpt->channel_request_count[ch] > 1) &&
> > rzg2l_gpt->period_ticks[ch])
> 
> I think the easy to understand and obviously correct™ check would be:
> 
> 	if (rzg2l_gpt->enabled[ch][othersubchannel]) {
> 		if (period_ticks < rzg2l_gpt->period_ticks[ch])
> 			return -EBUSY;
> 		else
> 			period_ticks = rzg2l_gpt->period_ticks[ch];
> 	}
> 
> (Instead of tracking enabled[ch][subchannel], reading the respective register is another option.)

OK, will add the code like below.

+               u8 other_sub_ch = sub_ch ? (pwm->hwpwm - 1) : (pwm->hwpwm + 1);
+
+               if (rzg2l_gpt_is_ch_enabled(rzg2l_gpt, other_sub_ch)) {
+                       if (period_ticks < rzg2l_gpt->period_ticks[ch])
+                               return -EBUSY;
+                       else
+                               period_ticks = rzg2l_gpt->period_ticks[ch];
+               }
        }

Cheers,
Biju

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ