From: Guenter Roeck <linux@roeck-us.net>
To: Aleksa Savic <savicaleksa83@gmail.com>
Cc: linux-hwmon@vger.kernel.org, Jean Delvare <jdelvare@suse.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hwmon: (gigabyte_waterforce) Mark status report as received under a spinlock
Date: Mon, 8 Jan 2024 07:29:03 -0800 [thread overview]
Message-ID: <1eb8323b-6c5e-4646-8288-1e58ca7516e7@roeck-us.net> (raw)
In-Reply-To: <20231219143620.22179-1-savicaleksa83@gmail.com>
On Tue, Dec 19, 2023 at 03:36:19PM +0100, Aleksa Savic wrote:
> Through hidraw, userspace can cause a status report to be sent
> from the device. The parsing in waterforce_raw_event() may happen in
> parallel to a waterforce_get_status() call (which resets the completion
> for tracking the report) if it's running on a different CPU where
> bottom half interrupts are not disabled.
>
> Add a spinlock around the complete_all() call in waterforce_raw_event()
> to prevent race issues.
>
> Fixes: d5939a793693 ("hwmon: Add driver for Gigabyte AORUS Waterforce AIO coolers")
> Signed-off-by: Aleksa Savic <savicaleksa83@gmail.com>
> ---
> Does the above make sense? The raw event parsing is a softirq AFAIK and
> presumably could run on a different CPU in parallel to a waterforce_get_status()
> call.
>
> Appreciate thoughts on this.
I think it does. Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/gigabyte_waterforce.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/hwmon/gigabyte_waterforce.c b/drivers/hwmon/gigabyte_waterforce.c
> index 1799377fc2f1..85e523775714 100644
> --- a/drivers/hwmon/gigabyte_waterforce.c
> +++ b/drivers/hwmon/gigabyte_waterforce.c
> @@ -276,8 +276,10 @@ static int waterforce_raw_event(struct hid_device *hdev, struct hid_report *repo
> priv->duty_input[0] = data[WATERFORCE_FAN_DUTY];
> priv->duty_input[1] = data[WATERFORCE_PUMP_DUTY];
>
> + spin_lock(&priv->status_report_request_lock);
> if (!completion_done(&priv->status_report_received))
> complete_all(&priv->status_report_received);
> + spin_unlock(&priv->status_report_request_lock);
>
> priv->updated = jiffies;
>
prev parent reply other threads:[~2024-01-08 15:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 14:36 Aleksa Savic
2024-01-08 15:29 ` Guenter Roeck [this message]
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=1eb8323b-6c5e-4646-8288-1e58ca7516e7@roeck-us.net \
--to=linux@roeck-us.net \
--cc=jdelvare@suse.com \
--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®