mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Aleksa Savic <savicaleksa83@gmail.com>
Cc: linux-hwmon@vger.kernel.org, Jean Delvare <jdelvare@suse.com>,
	Jonathan Corbet <corbet@lwn.net>,
	"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] hwmon: Add driver for Gigabyte AORUS Waterforce AIO coolers
Date: Tue, 5 Dec 2023 06:35:19 -0800	[thread overview]
Message-ID: <34638d1a-55c2-4dfe-ab9b-d8591a32b950@roeck-us.net> (raw)
In-Reply-To: <da9fe05a-a12d-4a2d-a81a-1195d65b1d51@gmail.com>

On 12/5/23 06:22, Aleksa Savic wrote:
> On 2023-12-03 18:36:35 GMT+01:00, Guenter Roeck wrote:
>> On Sun, Dec 03, 2023 at 01:06:48PM +0100, Aleksa Savic wrote:
>>> This driver exposes hardware sensors of the Gigabyte AORUS Waterforce
>>> all-in-one CPU liquid coolers, which communicate through a proprietary
>>> USB HID protocol. Report offsets were initially discovered in [1] and
>>> confirmed by me on a Waterforce X240 by observing the sent reports from
>>> the official software.
>>>
>>> Available sensors are pump and fan speed in RPM, as well as coolant
>>> temperature. Also available through debugfs is the firmware version.
>>>
>>> Attaching a fan is optional and allows it to be controlled from the
>>> device. If it's not connected, the fan-related sensors will report
>>> zeroes.
>>>
>>> The addressable RGB LEDs and LCD screen are not supported in this
>>> driver and should be controlled through userspace tools.
>>>
>>> [1]: https://github.com/liquidctl/liquidctl/issues/167
>>>
>>> Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com>
>>> ---
...
>>> +static int waterforce_get_status(struct waterforce_data *priv)
>>> +{
>>> +	int ret = 0;
>>> +
>>> +	if (!mutex_lock_interruptible(&priv->status_report_request_mutex)) {
>>> +		if (!time_after(jiffies, priv->updated + msecs_to_jiffies(STATUS_VALIDITY))) {
>>> +			/* Data is up to date */
>>> +			goto unlock_and_return;
>>> +		}
>>
>> What is the point of this check ? The calling code already checks it.
>> Checking it twice, once inside and once outside the lock, seems
>> excessive.
>>
> 
> If there are multiple readers here, only the first one should request the status,
> so when others enter the mutex they can exit early if the data is there.
> 

Please change the code to only check once from within the mutex.

Guenter


  reply	other threads:[~2023-12-05 14:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-03 12:06 Aleksa Savic
2023-12-03 14:14 ` Christophe JAILLET
2023-12-03 15:00   ` Aleksa Savic
2023-12-03 15:26     ` Christophe JAILLET
2023-12-04 12:31       ` Aleksa Savic
2023-12-03 17:36 ` Guenter Roeck
2023-12-05 14:22   ` Aleksa Savic
2023-12-05 14:35     ` Guenter Roeck [this message]
2023-12-07 12:21       ` Aleksa Savic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34638d1a-55c2-4dfe-ab9b-d8591a32b950@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=corbet@lwn.net \
    --cc=jdelvare@suse.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=savicaleksa83@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®