linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Armin Wolf <W_Armin@gmx.de>
To: hdegoede@redhat.com, markgross@kernel.org
Cc: jdelvare@suse.com, linux@roeck-us.net,
	platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] platform/x86: dell-ddv: Fix cache invalidation on resume
Date: Tue, 28 Feb 2023 14:21:34 +0100	[thread overview]
Message-ID: <a50ee14a-0181-5237-ddbc-5df85bd2eb6a@gmx.de> (raw)
In-Reply-To: <20230218115318.20662-1-W_Armin@gmx.de>

Am 18.02.23 um 12:53 schrieb Armin Wolf:

> If one or both sensor buffers could not be initialized, either
> due to missing hardware support or due to some error during probing,
> the resume handler will encounter undefined behaviour when
> attempting to lock buffers then protected by an uninitialized or
> destroyed mutex.
> Fix this by introducing a "active" flag which is set during probe,
> and only invalidate buffers which where flaged as "active".
>
> Tested on a Dell Inspiron 3505.

Hello,

what is the status of this series? Both patches are tested on real hardware
and work flawlessly.

Armin Wolf

> Fixes: 3b7eeff93d29 ("platform/x86: dell-ddv: Add hwmon support")
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
> Changes in v2:
> - move checking of the "active" flag inside
>    dell_wmi_ddv_hwmon_cache_invalidate()
> ---
>   drivers/platform/x86/dell/dell-wmi-ddv.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/dell/dell-wmi-ddv.c b/drivers/platform/x86/dell/dell-wmi-ddv.c
> index d547c9d09725..eff4e9649faf 100644
> --- a/drivers/platform/x86/dell/dell-wmi-ddv.c
> +++ b/drivers/platform/x86/dell/dell-wmi-ddv.c
> @@ -96,6 +96,7 @@ struct combined_chip_info {
>   };
>
>   struct dell_wmi_ddv_sensors {
> +	bool active;
>   	struct mutex lock;	/* protect caching */
>   	unsigned long timestamp;
>   	union acpi_object *obj;
> @@ -520,6 +521,9 @@ static struct hwmon_channel_info *dell_wmi_ddv_channel_create(struct device *dev
>
>   static void dell_wmi_ddv_hwmon_cache_invalidate(struct dell_wmi_ddv_sensors *sensors)
>   {
> +	if (!sensors->active)
> +		return;
> +
>   	mutex_lock(&sensors->lock);
>   	kfree(sensors->obj);
>   	sensors->obj = NULL;
> @@ -530,6 +534,7 @@ static void dell_wmi_ddv_hwmon_cache_destroy(void *data)
>   {
>   	struct dell_wmi_ddv_sensors *sensors = data;
>
> +	sensors->active = false;
>   	mutex_destroy(&sensors->lock);
>   	kfree(sensors->obj);
>   }
> @@ -549,6 +554,7 @@ static struct hwmon_channel_info *dell_wmi_ddv_channel_init(struct wmi_device *w
>   		return ERR_PTR(ret);
>
>   	mutex_init(&sensors->lock);
> +	sensors->active = true;
>
>   	ret = devm_add_action_or_reset(&wdev->dev, dell_wmi_ddv_hwmon_cache_destroy, sensors);
>   	if (ret < 0)
> @@ -852,7 +858,7 @@ static int dell_wmi_ddv_resume(struct device *dev)
>   {
>   	struct dell_wmi_ddv_data *data = dev_get_drvdata(dev);
>
> -	/* Force re-reading of all sensors */
> +	/* Force re-reading of all active sensors */
>   	dell_wmi_ddv_hwmon_cache_invalidate(&data->fans);
>   	dell_wmi_ddv_hwmon_cache_invalidate(&data->temps);
>
> --
> 2.30.2
>

  parent reply	other threads:[~2023-02-28 13:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-18 11:53 [PATCH v2 1/2] platform/x86: dell-ddv: Fix cache invalidation on resume Armin Wolf
2023-02-18 11:53 ` [PATCH v2 2/2] platform/x86: dell-ddv: Fix temperature scaling Armin Wolf
2023-03-01 12:19   ` Hans de Goede
2023-02-28 13:21 ` Armin Wolf [this message]
2023-03-01 12:15 ` [PATCH v2 1/2] platform/x86: dell-ddv: Fix cache invalidation on resume Hans de Goede

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=a50ee14a-0181-5237-ddbc-5df85bd2eb6a@gmx.de \
    --to=w_armin@gmx.de \
    --cc=hdegoede@redhat.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=markgross@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).