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: <c70c3d26-c2c7-4e5b-b415-8d8c20f922f1@roeck-us.net>
Date: Fri, 4 Jul 2025 06:00:33 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Álvaro Fernández Rojas <noltari@...il.com>
Cc: Krzysztof Kozlowski <krzk@...nel.org>, jdelvare@...e.com,
	robh@...nel.org, krzk+dt@...nel.org, conor+dt@...nel.org,
	corbet@....net, linux-hwmon@...r.kernel.org,
	devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-doc@...r.kernel.org
Subject: Re: [PATCH] drivers: hwmon: add EMC2101 driver

On Fri, Jul 04, 2025 at 09:26:16AM +0200, Álvaro Fernández Rojas wrote:
> Hi Guenter,
> 
> El vie, 4 jul 2025 a las 2:25, Guenter Roeck (<linux@...ck-us.net>) escribió:
> >
> > On Thu, Jul 03, 2025 at 09:23:41AM +0200, Álvaro Fernández Rojas wrote:
> > > >
> > > > Add a comment describing what you are protecting here. It looks so far
> > > > like you could just use regmap and drop the mutex, but I didn't check
> > > > thoroughly.
> > >
> > > The EMC2101 datasheet is explicit about the Look Up Table registers
> > > (REG_FAN_LUT_TEMP and REG_FAN_LUT_SPEED) being RO if FAN_LUT_DISABLE
> > > isn't set, so I believe that we need the mutex even if we switch to
> > > regmap.
> > > I will add an explanation with that in the next version.
> > > Should I still switch the implementation to regmap considering that we
> > > need a mutex?
> > >
> > What does r/w vs. r/o register access have to do with locking ?
> 
> FAN_LUT_DISABLE bit can be set or cleared when pwm_enable is modified,
> but we need it to be set in order to be able to modify
> REG_FAN_LUT_TEMP and REG_FAN_LUT_SPEED registers.
> If FAN_LUT_DISABLE bit isn't set, any attempt to modify
> REG_FAN_LUT_TEMP and REG_FAN_LUT_SPEED registers won't work because
> they would be RO.
> Therefore, we need a lock to ensure that FAN_LUT_DISABLE is kept while
> modifying those registers.
> Please, take a look at emc2101_pwm_enable_write() and
> __pwm_auto_point_temp_store().
> 
Thanks for the clarification. Please add that as comment into the code.

Regmap is still valuable even if local locking is needed. It provides
caching for non-volatile registers, and it provides various useful API
functions (for example for bit value changes) which you otherwise have
to implement by hand.

Guenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ