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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <p322xo44wkcrmaewbz6pf2jn4zxw2wzzwikc3xkdl6mh4yc7od@rnxc4qdj6vxx>
Date: Thu, 13 Jun 2024 08:07:15 +0200
From: Uwe Kleine-König <u.kleine-koenig@...libre.com>
To: Tzung-Bi Shih <tzungbi@...nel.org>
Cc: Benson Leung <bleung@...omium.org>, 
	Guenter Roeck <groeck@...omium.org>, linux-pwm@...r.kernel.org, chrome-platform@...ts.linux.dev, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] pwm: cros-ec: Don't care about consumers in
 .get_state()

Hello,

On Wed, Jun 12, 2024 at 06:27:14AM +0000, Tzung-Bi Shih wrote:
> On Tue, Jun 11, 2024 at 12:39:44PM +0200, Uwe Kleine-König wrote:
> > On Tue, Jun 11, 2024 at 08:50:44AM +0000, Tzung-Bi Shih wrote:
> > > On Fri, Jun 07, 2024 at 10:44:15AM +0200, Uwe Kleine-König wrote:
> > > > The get_state() callback is never called (in a visible way) after there
> > > > is a consumer for a pwm device. The core handles loosing the information
> > > > about duty_cycle just fine.
> > > 
> > > ChromeOS EC has no separated "enabled" state, it sees `duty == 0` as
> > > "disabled"[1].  1db37f9561b2 ("pwm: cros-ec: Cache duty cycle value")
> > > caches the value in kernel side so that it can retrieve the original duty
> > > value even if (struct pwm_state *)->enabled is false.
> > 
> > There is no need to cache, so the following would work:
> 
> Ack.
> 
> > > To make sure I understand, did you mean the original duty value could be less
> > > important because:
> > > - We are less caring as it is in a debug context at [2]?
> > > - At [3], the PWM device is still initializing.
> > 
> > It doesn't really matter that this is about debug or initialisation. The
> > key here is that the core can handle the PWM using duty_cycle 0 (or
> > anything else) when it was requested to be disabled.
> > 
> > 
> > > [1]: https://crrev.com/0e16954460a08133b2557150e0897014ea2b9672/common/pwm.c#66
> > > [2]: https://elixir.bootlin.com/linux/v6.10-rc3/source/drivers/pwm/core.c#L52
> > > [3]: https://elixir.bootlin.com/linux/v6.10-rc3/source/drivers/pwm/core.c#L371
> 
> I was trying to understand the description in the commit message:
> : The get_state() callback is never called (in a visible way) after there
> : is a consumer for a pwm device.
> 
> I guess I understood; the core reads the duty value via get_state() when:
> - Initializing the device for the intial value.

Yes, that a consumer cannot do any assumptions about a PWM just aquired,
so there is no danger for confusion.

> - Debugging for checking if apply() really takes effect.

Right, and the read pwm_state is only used in the core. The core won't
be confused about disabled vs. duty=0. Consumers never see the result of
the .get_state callback.

> What 1db37f9561b2 worried about is already addressed by the core[4].
> [4]: https://elixir.bootlin.com/linux/v6.10-rc3/source/drivers/pwm/core.c#L495

What 1db37f9561b2 worried about is bogus, because pwm_get_state()
doesn't call the .get_state() callback:

	$ git show 1db37f9561b2:include/linux/pwm.h | awk '/void pwm_get_state/,/^$/'
	static inline void pwm_get_state(const struct pwm_device *pwm,
					 struct pwm_state *state)
	{
		*state = pwm->state;
	}

> Reviewed-by: Tzung-Bi Shih <tzungbi@...nel.org>

I'll apply the patch under discussion and create a proper patch for the
ad-hoc change from my previous mail.

Thanks
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