From nobody Tue Apr 7 11:15:22 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A51D82D73B8 for ; Sun, 5 Apr 2026 14:45:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775400317; cv=none; b=WoVyrJcNhr6SyTRp+FiMgOrwrk/XT9fIL/GnRp2iM3qaxEnq/W7Oe2Y1/MO4RVupPAyI6eXXT9+0ftlwmCCCOAem5squl9KHe45EDIMxDKfL63UU1YR5ctMWERPvotLR4rXAbhwoDETDeMQ7KSzGyb5Z9TIDuzDPK4FGZTAaEAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775400317; c=relaxed/simple; bh=44Okvn52N6xqTGEytJH/Z5j9cTiQ194ocVa3p4+mz6A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PbdnnBo4T86/JQFr/zjbFmXe+SJEIwVDR02cf1SP95Ngmubw5IkDg2gUuqZ8NyotxF2icmckpLnGnzUNUGFs/5Hz/GV5VSBWlL+AoFyKQzRUdyMHw0RDgQR7s8kLXqLX5lS9D4T6pxDpGYjMxr/j/2mr8A7evM1JMyk8vIT6asA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LJH55jzW; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LJH55jzW" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4836cd6e0d4so4590045e9.3 for ; Sun, 05 Apr 2026 07:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775400314; x=1776005114; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=stAMSWyB4mZAS8H9YKj1ITgLlFTm/EJVMUZqWjHkvfo=; b=LJH55jzWfzBvquZInislSJH0UIqq++kNB9MUbdytZy0BladaiuoM0N0T1Oo9T51Aeb EX3328wO0sNdtoEnOx+ejM5tAB3HZI3ZRXxgMTyXJtI0JZlVO574WC4tZOfgNgMacqeh PgDZ2qipo1BW1tXu4ywUA1Za7JrZY8Bt7n6liKvE+BCUN6/irCZKDPmQwjg7jJvnhP21 WbTYIyPRA3BjhmFi0U9vXhopAdHjgzoVm5BSRMLkdLLey72IqALx37Lhe4jBqoVktrdR mzZlMXTFm9p4nQWElSxk1xfZ2uNgwC4RZynx/LDEfRLTG5JmdmBnhEAPw8A9kcp4g02v Z58Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775400314; x=1776005114; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=stAMSWyB4mZAS8H9YKj1ITgLlFTm/EJVMUZqWjHkvfo=; b=KKtrpUggxMZxuVh3zKz0nJXLupnkglPI/IxKLPWt3F0+DlKb3tOuHxIvBuCC9RZV65 3WdZSLyco16lxpNqhGw8DYyOhxJoI/wuJhqAyzZzsmnCx7/zI8vLyTJiWhM4Se3Pbv38 pnpfLrWk4TllPas0LPO9/4+MmUrGrD2qPc8lAkc9vnk0m78ZqBgvK4ot7aynT1lzO2N7 Nxy+zx0ZiJqmETwmbyJkY/vIspV2FElJvalT0IvToEuSd+8iEwDIewvF/5Lz9l+IztYb NQfQF3Atwr9XCd1wjJEZewKn3u0LKIk3rkuCy1z+gx4unUdsZr6IfvOqTjdsWnxmrcGX z8yw== X-Forwarded-Encrypted: i=1; AJvYcCU0MYu+myasHNTCNmsNt2nVATyhR64iTpJ+HtdLJuCeUJpGxTYc3ztPPWq6EgD9Voo0rOpzyNNg+QP6TUc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy606LcvMB0F9Z5zljSF5YfoxBttxoik/pHj7sXLQN7MNqTRiVY yvA8k/oE6JyNNIjedQwziyy5vpMIUIKgYqUBMPpp/Gzi/Gd0pb9DVufo X-Gm-Gg: AeBDietUW3C3SnsPSVIF7WbKR+1C0BfDE0Fem1mXyi04mBgg+nmrg9L8waerSu1vFr/ XPRGM3K4QAmB9q9eb5Ze51goJ2v6umhhO5D/IPrOdCrl7P5hEMRJHYgopKjO4ccntq2UPRxzzFB j+CUzD+7WnFTlqcj4B9jhofTMCk9RVHINiq3vMjOUZ+kpe6cWyFKACOFnnIMp2k58K4jRuRINmp Sxokyus6yhOnoD+QG/DGQKI2XNs4ZLlICWTuxRzm0ppd0vOjDhImyZxxz2afUIzbqRP9rUY0rHO AMjCdJqpfBJQTSZwFsKrOAo+hnG9WE3tCz27yjZkLaX+EUsS/gPKTFKIQsk/i6WWuH/kWHolC0y kFN5Su1MR+1r7Zou0QSQMNLGgamPeT1LF+b214/4Il3XLHlCIX27QX3NSfXekxJi3U0c6abm+px T1VytWjGZkd+TqRNrF79z0f4qR7D3jPzu+2Zr7bIN1BcZ4QY95NTs0HuTUB1g= X-Received: by 2002:a05:600c:1f8f:b0:485:f1d6:2b1d with SMTP id 5b1f17b1804b1-488995d1535mr75603005e9.0.1775400313974; Sun, 05 Apr 2026 07:45:13 -0700 (PDT) Received: from fridge.local ([2a00:1d35:c836:5700:77d9:f36f:3748:d642]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e4f1a99sm35698799f8f.32.2026.04.05.07.45.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Apr 2026 07:45:13 -0700 (PDT) From: Emre Cecanpunar To: platform-driver-x86@vger.kernel.org Cc: hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, krishna.chomal108@gmail.com, edip@medip.dev, emreleno@gmail.com Subject: [PATCH v3 1/5] platform/x86: hp-wmi: fix ignored return values in fan settings Date: Sun, 5 Apr 2026 17:44:56 +0300 Message-ID: <20260405144502.24944-2-emreleno@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260405144502.24944-1-emreleno@gmail.com> References: <20260405144502.24944-1-emreleno@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" hp_wmi_get_fan_count_userdefine_trigger() can fail, but its return value was silently ignored in hp_wmi_apply_fan_settings() for PWM_MODE_MAX/AUTO. Propagate these errors consistently. Additionally, handle the return value of hp_wmi_apply_fan_settings() in its callers by adding appropriate warnings on failure, and remove an unreachable "return 0" at the end of the function. Fixes: 46be1453e6e6 ("platform/x86: hp-wmi: add manual fan control for Vict= us S models") Signed-off-by: Emre Cecanpunar --- drivers/platform/x86/hp/hp-wmi.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 988a0acc9622..eac39f68d762 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -2353,8 +2353,11 @@ static int hp_wmi_apply_fan_settings(struct hp_wmi_h= wmon_priv *priv) =20 switch (priv->mode) { case PWM_MODE_MAX: - if (is_victus_s_thermal_profile()) - hp_wmi_get_fan_count_userdefine_trigger(); + if (is_victus_s_thermal_profile()) { + ret =3D hp_wmi_get_fan_count_userdefine_trigger(); + if (ret < 0) + return ret; + } ret =3D hp_wmi_fan_speed_max_set(1); if (ret < 0) return ret; @@ -2372,7 +2375,9 @@ static int hp_wmi_apply_fan_settings(struct hp_wmi_hw= mon_priv *priv) return 0; case PWM_MODE_AUTO: if (is_victus_s_thermal_profile()) { - hp_wmi_get_fan_count_userdefine_trigger(); + ret =3D hp_wmi_get_fan_count_userdefine_trigger(); + if (ret < 0) + return ret; ret =3D hp_wmi_fan_speed_max_reset(priv); } else { ret =3D hp_wmi_fan_speed_max_set(0); @@ -2385,8 +2390,6 @@ static int hp_wmi_apply_fan_settings(struct hp_wmi_hw= mon_priv *priv) /* shouldn't happen */ return -EINVAL; } - - return 0; } =20 static umode_t hp_wmi_hwmon_is_visible(const void *data, @@ -2528,6 +2531,7 @@ static void hp_wmi_hwmon_keep_alive_handler(struct wo= rk_struct *work) { struct delayed_work *dwork; struct hp_wmi_hwmon_priv *priv; + int ret; =20 dwork =3D to_delayed_work(work); priv =3D container_of(dwork, struct hp_wmi_hwmon_priv, keep_alive_dwork); @@ -2535,7 +2539,10 @@ static void hp_wmi_hwmon_keep_alive_handler(struct w= ork_struct *work) * Re-apply the current hwmon context settings. * NOTE: hp_wmi_apply_fan_settings will handle the re-scheduling. */ - hp_wmi_apply_fan_settings(priv); + ret =3D hp_wmi_apply_fan_settings(priv); + if (ret) + pr_warn_ratelimited("keep-alive failed to refresh fan settings: %d\n", + ret); } =20 static int hp_wmi_setup_fan_settings(struct hp_wmi_hwmon_priv *priv) @@ -2597,7 +2604,9 @@ static int hp_wmi_hwmon_init(void) =20 INIT_DELAYED_WORK(&priv->keep_alive_dwork, hp_wmi_hwmon_keep_alive_handle= r); platform_set_drvdata(hp_wmi_platform_dev, priv); - hp_wmi_apply_fan_settings(priv); + ret =3D hp_wmi_apply_fan_settings(priv); + if (ret) + dev_warn(dev, "Failed to apply initial fan settings: %d\n", ret); =20 return 0; } --=20 2.53.0 From nobody Tue Apr 7 11:15:22 2026 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C232D2FD7C3 for ; Sun, 5 Apr 2026 14:45:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775400319; cv=none; b=XLNaaUWgxcE3gtIxHoNkEyhbglgUXs41RU+INKPzCl3QPYsB6QAJ5NFSULEMZ833AJ7/feseFdIfh/g4lZwZ8qgXJCek2SwjoKmpKwcfZDEm+izxju/bJMshnRZYxL1ktYLF1bs0YJ6LkU1Xl4DCUWbGUE00k4p3k9+l2qiB4Uo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775400319; c=relaxed/simple; bh=TfNxeGb9nt4qVFEDy3vSP2vU6t/UvG2YByCxEcAn8sI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LpVvTmtQJxiz0HOr9vDebDmI9DSmbWiuGINDY/ekOCGj4weI2viY5gQF5A13OEb1TBSir6P7+8GydefRBkX61Wje04vY32L0oBxjDVCrI3yJWcuDJc98jnl6GcMlV6EB652rVcUrRduCEYaKCd0/wlQPr465X7yNzSMWcjJMzpE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JtRV55V8; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JtRV55V8" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4836cd6e0d4so4590085e9.3 for ; Sun, 05 Apr 2026 07:45:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775400316; x=1776005116; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8kTb1nxrmvzDufvOzlr6MJ8Yqsu0pkzDYB5uLfxFM34=; b=JtRV55V8iPJvVB/MFRJyhJjdxpC6ujhglGTdA1bpj/3L3QwsTV9kNNTYABmAhez0dd pNXJsPgvfpdqPkY7VDzM3xP+cBrvYwQruyhhlxT8RzZzMkr9GtXCbiPVKHFYK97mg5PR iTYmaqXsep/vRq3lcKeZJfzOeiheGAlo6sGFOVNCi8FF5DLqs89majE/fZNH35srOiUX hUbDj1NYYEp7QKPgugyqiCMJkO1sHa6YkYi6rBq4IkBK/S61f3H59Pt7nG8VsScoIc3t hZy7EcSsDKkUY+loQDNzP15+5HH1jKkmK6xwTcMi5JUSh2D+aQgo/9Hw2ui5dS5nqd05 XHow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775400316; x=1776005116; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8kTb1nxrmvzDufvOzlr6MJ8Yqsu0pkzDYB5uLfxFM34=; b=GxyNfTgpYLSxmrR/yKsXstmOPQwx998FE4Bd1HjARKHRzQdTKLBUiDqkVM1Ts3ooZM LIHPBrJosISgTbCX4CQFFfe9ODBnVqMSRpjDWGKlxXcEocmxu8/zIKlcXsQvFvkCvZZN FgMSC/WtodQ0V3+2tC4zK3B8nUcZxU0paReJpWJiBqRlQtNUCkq6zq1FS/+BnM2dyhpd 3G4BcZunCie1afr3XLCscy+2BY8iz8PP1W+J2IDuFiYfWY+oFUsjmk2NPm0zVIAZ6EeK 6X8VOOcL4IU8BdVRINb/25Mgkj1HzFsMd0ntEa5SSccVFHoQMpbyPUMOkkA/gusLLexz D8qQ== X-Forwarded-Encrypted: i=1; AJvYcCUNWecKnOInCQYybwhESm86Yyz/uEPtU6eib84K1AoGCdBhWHb+dW1ihFDV5F7bUNIMslakx9q/ekVqX6g=@vger.kernel.org X-Gm-Message-State: AOJu0YzcanZm1ZU8ehIpy3sQL8dxrZq8o7ZL9u6j8MxwRQp0VK9iM6p6 lUBccy6SJl/bHntIt1j2O/PJ3WLDdkAbTerCvZW0XS5ZrXs6amFL1V79 X-Gm-Gg: AeBDiesEQXv9NKpoqkxu+xvRmuCynImPzZ7xU187TCx2ZPeND8/HQTrteaVJMps4Fd0 TiRCayKMytjiQ2VfarsQY7RVLfcfEzFJoy6H6xUn2kGiwx9XUN+8N8FkzVsvR/R/sZPVWBoFrsn /qDNiA9uip415DlfVIH1ukZTMdjZH6esoXDfJAwA2IzFA4d7TyQfHRRpjaYEs6PNUIE7PO+svbC p3u4stBA4hZU/BQXwZEpm5/4VCxi9URzEZtCPJ/3qU+T5FX0piPfiXmCV+COtIydmdoegkFWEjB f4b1A/KdYMfKFGOQt1k5DX4fDmM+IvGUyBLIwyzPq9WNjQb+BV8Y8h6xwaJ8HNpFFhT4qq8NeyM 4zodZ8gxbt2PkoqTXf5Mb9mrnfOEg2DJPYvwImBNQvJFy0fsXoQOBGMnRIHRYyhi2SgAUovJPwO HGWY3q2MolRG/4Br6rf+wJhFfxOLpYdvtKMagQ+nHiSRyZYLK1dghQfYC59JbM6qZkm+RRZQ== X-Received: by 2002:a05:600c:1d05:b0:486:fdc0:4504 with SMTP id 5b1f17b1804b1-488997c3124mr80125075e9.4.1775400316011; Sun, 05 Apr 2026 07:45:16 -0700 (PDT) Received: from fridge.local ([2a00:1d35:c836:5700:77d9:f36f:3748:d642]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e4f1a99sm35698799f8f.32.2026.04.05.07.45.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Apr 2026 07:45:15 -0700 (PDT) From: Emre Cecanpunar To: platform-driver-x86@vger.kernel.org Cc: hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, krishna.chomal108@gmail.com, edip@medip.dev, emreleno@gmail.com Subject: [PATCH v3 2/5] platform/x86: hp-wmi: avoid cancel_delayed_work_sync from work handler Date: Sun, 5 Apr 2026 17:44:57 +0300 Message-ID: <20260405144502.24944-3-emreleno@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260405144502.24944-1-emreleno@gmail.com> References: <20260405144502.24944-1-emreleno@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" hp_wmi_apply_fan_settings() uses cancel_delayed_work_sync() to stop the keep-alive timer in AUTO mode. However, since hp_wmi_apply_fan_settings() is also called from the keep-alive handler, a race condition with a sysfs write can cause the handler to wait on itself, leading to a deadlock. Replace cancel_delayed_work_sync() with cancel_delayed_work() in hp_wmi_apply_fan_settings() to avoid the self-flush deadlock. Fixes: c203c59fb5de ("platform/x86: hp-wmi: implement fan keep-alive") Signed-off-by: Emre Cecanpunar --- drivers/platform/x86/hp/hp-wmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index eac39f68d762..79d6bc3cd223 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -2384,7 +2384,7 @@ static int hp_wmi_apply_fan_settings(struct hp_wmi_hw= mon_priv *priv) } if (ret < 0) return ret; - cancel_delayed_work_sync(&priv->keep_alive_dwork); + cancel_delayed_work(&priv->keep_alive_dwork); return 0; default: /* shouldn't happen */ --=20 2.53.0 From nobody Tue Apr 7 11:15:22 2026 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C95C2FE075 for ; Sun, 5 Apr 2026 14:45:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775400322; cv=none; b=K+alVFatHUw/ZuHpY+5yLj+lt8t3yzG1gGQzx4R1vmmm/x8PixoSokN0SSf7RjHVH5Kge1+dFVH6Egktvoj1I4RlifcXu9oTJiNJgRC6oboqLa6E6oLtjpb3HQeCPbhnz6E3KotpCYVvALGxEghol3xUBXFbpggzhGZ0zIzVpAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775400322; c=relaxed/simple; bh=YxZ/d8hWc5Dojxq2+WQ8y//zQ0MV75jV5AaZq1iu/u8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QDQGGDi9X7i6/EDMNc2lVO0PqnyFrsJVOYnWtq3NNG/oM5ovO9x+GguTf9OpZuBCuQ+6Zj1bYGdKFN77qdoWom5fbYhZEN0xRdp6ILvsnWs/pen1XTrAkPQFZitnB6d96W7VeXeHP7je3ZDC3MKFT4VgzblWzIJkXdHS6do8qTs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LcUd8vkn; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LcUd8vkn" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-43b9974ac31so430158f8f.1 for ; Sun, 05 Apr 2026 07:45:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775400318; x=1776005118; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dxSRimATBcfYurd5oZ/SGQyL2ML4iFG/Nsr5i0TaWFg=; b=LcUd8vkn1h/cW/r43Vu80VhpuS1TwPrHnLcORHnFyyogIJ5iB1CF4zAs3kjXkUAC9G wbT62Yy0v2MMF2OjPnu5/rtedEjsAfWUQxodzlqj0AvluKJpwqpgNUp1E4IrvJbmEDzr 6r91ovLnSR4icYEquVTn8sNqLP92iC+iqq/lD7MqTzArjdWfwIBE7P4DlXGoDryMjEWS 1CmTV9+ro9Xho2dknUUA/oBtt43M7C97zhworUsJOZRp5a5Ig2uw37QcywpWqO7x3rTT GNduL6tOLj/ppZIyyzkxJ/AF0FXOR+1Mhe7xHOx7JXJf23v3rJ0UfgW0dfydv964ASSg U2Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775400318; x=1776005118; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=dxSRimATBcfYurd5oZ/SGQyL2ML4iFG/Nsr5i0TaWFg=; b=iYHTX55omUI7/K/2jPiceDQ4DbSwcV6jnmfBxKjWS9KdcEgfXi/qTWfBh74SkgdllA //3QdGgXozrmN9O0FYDFfHwC3J8HveKd3GiJSU15JPAzilQWLgdlBSM361J454xS1FJ1 JBLUGo93i/4vYk1JaCwQfny5C0I7IzAyT8iFolE/rrvQqiJt76aykeMlm2C5SNM+yT8A l8qqc/2ZiIDpRSgQ5OL7DipzG6kOE7Znmh5lXCFyhvLaZ2Vf1GBWclVtRxwXba6sCaHG KtQG02owCWo1qiPC0pIfTGK7aJzQrpLgXsu0SWOVF+RdoaS6YrHKipSD0OkNi2aYxx3j 8fjg== X-Forwarded-Encrypted: i=1; AJvYcCXBtGgTcZcJ+9fo6DeCixz7gUk4JofvgzUs1PE6R9i8oeOWumYVSpLCo2YT6gm/dfsI5w0SzUhEmlq5PpU=@vger.kernel.org X-Gm-Message-State: AOJu0YxYxWqvfUm/loCLRcYhHkVFSBSdFEe26uJyoFewR3T0hll09GTM dzEosFEj7Owjjb+QeNjO0x5yi1bDjY2kj8ds9G5h+9VJvo9JVQfTgwzU X-Gm-Gg: AeBDiesmwKMgN66SVat14pQdLl8NjIJaTIYZ1dz38co2WgQXsvsyvolmGLNJVXfJ92M jNbBDk+JuTl6VlLi2Ba9uTwUdBtDEOtw58zSH7pPkeTuYHaN4APVBqZCCs6KPQQfp1RJjr3JEjb ymOqgYMirZn8XKura2oXyqlvjwQBgjxfEsf/0h2yLE3iTgs3+HISYH30xALkwhUlZFSqrAoXZev w7Vo2vTU7+/2b5qznl7cDl5LLnRP2n5897G5XuTiXpBRh4s4dEPjge2ea04xCY89SHE2GOvw404 BfzOYMGALnlDvPy4mWBz5jBnBOIJmRrD9+RPlZwltI+AblZzCuo5YZICUHVIDlEp3GKbyem9+ZK 4XErF8KXDecBXRNoTIWHxxfBdZwY571SO0ysSitOvmqA9LRQFzScFyjHdzjm/otf2/9rtPaBR6f Q0Ge6bNkmSYRpCI8fCPh6laave3E0g5TXGyUbcJDBggLSmGhhXEp5zdbysZtc= X-Received: by 2002:a05:6000:2308:b0:43d:3141:77d8 with SMTP id ffacd0b85a97d-43d31417991mr4516340f8f.2.1775400317649; Sun, 05 Apr 2026 07:45:17 -0700 (PDT) Received: from fridge.local ([2a00:1d35:c836:5700:77d9:f36f:3748:d642]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e4f1a99sm35698799f8f.32.2026.04.05.07.45.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Apr 2026 07:45:17 -0700 (PDT) From: Emre Cecanpunar To: platform-driver-x86@vger.kernel.org Cc: hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, krishna.chomal108@gmail.com, edip@medip.dev, emreleno@gmail.com Subject: [PATCH v3 3/5] platform/x86: hp-wmi: use mod_delayed_work to reset keep-alive timer Date: Sun, 5 Apr 2026 17:44:58 +0300 Message-ID: <20260405144502.24944-4-emreleno@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260405144502.24944-1-emreleno@gmail.com> References: <20260405144502.24944-1-emreleno@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, schedule_delayed_work() is used to queue the 90s keep-alive timer. If a user manually changes the fan speed at T=3D85s, schedule_delayed_work() leaves the existing timer in place as it is a no-op if the work is already pending. This results in the keep-alive timer firing unnecessarily at T=3D90s, just 5 seconds after the user action. Replace schedule_delayed_work() with mod_delayed_work() to reset the 90s timer whenever fan settings are applied. This guarantees a full 90s delay after every user interaction, preventing redundant keep-alive executions and improving efficiency. Fixes: c203c59fb5de ("platform/x86: hp-wmi: implement fan keep-alive") Signed-off-by: Emre Cecanpunar --- Changes in v3: - Reworded commit message to clarify this is an inefficiency fix, not a functional bug. drivers/platform/x86/hp/hp-wmi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 79d6bc3cd223..2932cab9aa78 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -2361,8 +2361,8 @@ static int hp_wmi_apply_fan_settings(struct hp_wmi_hw= mon_priv *priv) ret =3D hp_wmi_fan_speed_max_set(1); if (ret < 0) return ret; - schedule_delayed_work(&priv->keep_alive_dwork, - secs_to_jiffies(KEEP_ALIVE_DELAY_SECS)); + mod_delayed_work(system_wq, &priv->keep_alive_dwork, + secs_to_jiffies(KEEP_ALIVE_DELAY_SECS)); return 0; case PWM_MODE_MANUAL: if (!is_victus_s_thermal_profile()) @@ -2370,8 +2370,8 @@ static int hp_wmi_apply_fan_settings(struct hp_wmi_hw= mon_priv *priv) ret =3D hp_wmi_fan_speed_set(priv, pwm_to_rpm(priv->pwm, priv)); if (ret < 0) return ret; - schedule_delayed_work(&priv->keep_alive_dwork, - secs_to_jiffies(KEEP_ALIVE_DELAY_SECS)); + mod_delayed_work(system_wq, &priv->keep_alive_dwork, + secs_to_jiffies(KEEP_ALIVE_DELAY_SECS)); return 0; case PWM_MODE_AUTO: if (is_victus_s_thermal_profile()) { --=20 2.53.0 From nobody Tue Apr 7 11:15:22 2026 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 221022FB97B for ; Sun, 5 Apr 2026 14:45:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775400323; cv=none; b=YukyXXH4Z1GZNadqAnDLwHz6PZfH2Uu2FlQEAze8xS0xd2BhTBDFmAWk/WJm0S+CgtuWFG5FHgIlF8bO+oPMr/i1YD+ngwzmC5OgD5Cc2H96bIaEgZMAJy3LOyiY7/iE8hhaWta6ida8Rc4Hm1hb7qvKQ9X6il7Np3qsBKuF5pg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775400323; c=relaxed/simple; bh=U9Ed+suttjno51XBUYSnT0699GezdZBqktDkjIeo3Ls=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=USkpOeN1//Wcy3uDd/FWvNeT9pYpuQeV8mes5KXggXuW61+hOmDYzga9jh0A0QSMylkqIxTwT71XPTr4Im7VD35dhpL9PddJsntaqd6Jky0ZxsF6D7V+sfzRUBASE6LGLc0IJsBho11dbhzN7PfVFIRZYP0GuWSsMOJIrIzvMeY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kkqaPUnF; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kkqaPUnF" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-43b8822fc05so197240f8f.1 for ; Sun, 05 Apr 2026 07:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775400319; x=1776005119; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qcDE+lrXl8P386IFXCKLCz+1una+WdqnP+gxsxxcZkI=; b=kkqaPUnFO9pZBUkfbwn5y5r2nTOYT/hFh2q4EbcJwfYeDz/WP9xeu757OaMf+x9vTA VNtwxOywwWs/eaPNykjaX7O8C4+4gRk08ZaKNihPfi+4/qpY0sf7l0+DpbunJ80vEroo ZShhFAgIHnIXUZNB5jibrY8n2+nW3QA52sStqkgwxYKuEBftfEQCk1LWSN88mbmkOkKv st/tEr9jA5Iwvl0LjE+U48rvrNpID+wTnUywT3kW5zgu4keovt4WNDzf4IGrrquMqgy+ eAW/ovaGT7gesA4KabUsl2uCZWXNsBGphaklIKQYvchFtvhY4QoylSVR54C9AvG2Kt6z q5wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775400319; x=1776005119; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=qcDE+lrXl8P386IFXCKLCz+1una+WdqnP+gxsxxcZkI=; b=m3HF5iQFvMAxF7oSpcJpdeD2ZgpKb6S350ycI/ep0TM4WSFd1JTum2prO1NwdV9yG1 dyx9RlyCm7byrxm8BCe9XMzemF2v5+iv+2b66XIkiwK055UwmAKxOVgHSowHIjHtxAbf pKZsobhlElJNd3NYVHjmHVVwg64Qe3NoP8rOAGYQItdES5Ir6gcIRzGbpk44ObmMqTpC aU6pg5zUrRxuki94gyQHl/hrbeU7nsevue405u/nMme165qhlvJBa8U5wttud0nhFsf8 oFp5axGwquckmnUq0q5c33g6o2QPUjoy0FwYfWSQSSsUTOQ62HfcM6c67MzaZl1KcPHk 8WBg== X-Forwarded-Encrypted: i=1; AJvYcCVPXf063ommeVLSFISNBxIHc/wkq4QWmXx1vE44k5/XdsCy6TfKBlR74YFAYAzcghuJs4ZdkMCE9FItRvU=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4OYuBiWIcJlIuLW53BoVy1xn1aJvgb3b3sHZiRabwmbiZEwIy A5fEyu27nDZJfywoMkEeyQ0wJFn5L6bk82+k5/gOMpE87iz/394qm1Ak X-Gm-Gg: AeBDies1/wek0MR8q4agk/tc+5juCKWJIdKZcuSgdbh7/hoYJvpnI/pgGMb163aCQMc gr0wvveYM5WXpzV1eg/ZCWY3gpOrOP0rVk+5tV6xtUlTC12QAR63qKbwpL2C/b+WiMPI6uYjtIn UMDPkD61mX+B0LixtMNAgTAIJfMFIHlxVePMi9XA32CN2Ihxm1Is4hEmFF5dMEmAtpvuoiKEj4E YmZ29Hi/g58rpb2fxyYD6MbUUupbfYpIsgFXtYryzGsQ8VZdZr3E03CvWd9OqtR6MQratdG5h0D eKbgFiAztHDQAKyUC0YyGYCeAoBqooChN4dT3m0k2FyAljPY5VMMIjv7VylpMnoCFqqbi7OXuKr 9XSLkE7rsfkJh6AXgCih+pq3OzvP9sh0nyfPMXpMIj4w5nhAtVl8fkBg+lV1rP+e14HFeb9WfGv kj07Eww6D++/lcseQ9kepRN1dfZnxEATTFF1gJeCf/2nCHHrX7hoX4kMng+UKDil1T8vX07w== X-Received: by 2002:a05:6000:2995:20b0:43d:deb:79b7 with SMTP id ffacd0b85a97d-43d292d35bbmr4818846f8f.6.1775400319380; Sun, 05 Apr 2026 07:45:19 -0700 (PDT) Received: from fridge.local ([2a00:1d35:c836:5700:77d9:f36f:3748:d642]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e4f1a99sm35698799f8f.32.2026.04.05.07.45.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Apr 2026 07:45:19 -0700 (PDT) From: Emre Cecanpunar To: platform-driver-x86@vger.kernel.org Cc: hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, krishna.chomal108@gmail.com, edip@medip.dev, emreleno@gmail.com Subject: [PATCH v3 4/5] platform/x86: hp-wmi: fix u8 underflow in gpu_delta calculation Date: Sun, 5 Apr 2026 17:44:59 +0300 Message-ID: <20260405144502.24944-5-emreleno@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260405144502.24944-1-emreleno@gmail.com> References: <20260405144502.24944-1-emreleno@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable gpu_delta was declared as u8. If the firmware specifies a GPU RPM lower than the CPU RPM, subtracting them causes an underflow (e.g. 10 - 20 =3D 246), which forces the GPU fan to remain clamped at U8_MAX (100% speed) during operation. Change gpu_delta to int and use signed arithmetic. Existing signed logic in hp_wmi_fan_speed_set() correctly handles negative deltas. Fixes: 46be1453e6e6 ("platform/x86: hp-wmi: add manual fan control for Vict= us S models") Suggested-by: Ilpo J=C3=A4rvinen Signed-off-by: Emre Cecanpunar --- Changes in v2: - Drop the if (gpu_delta < 0) guard and pr_warn. A negative delta is valid firmware behavior on boards where CPU_RPM > GPU_RPM. Store gpu_delta as int in struct hp_wmi_hwmon_priv so the existing signed arithmetic and clamp_val() in hp_wmi_fan_speed_set() handle the negative case correctly without saturating at U8_MAX. Changes in v3: - Removed unnecessary explicit (int) casts. C's integer promotion rules already convert u8 operands to int for arithmetic; the fix only requires storing the result in an int variable. drivers/platform/x86/hp/hp-wmi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 2932cab9aa78..db72ad9da0a5 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -455,7 +455,7 @@ enum pwm_modes { struct hp_wmi_hwmon_priv { u8 min_rpm; u8 max_rpm; - u8 gpu_delta; + int gpu_delta; u8 mode; u8 pwm; struct delayed_work keep_alive_dwork; @@ -2549,8 +2549,8 @@ static int hp_wmi_setup_fan_settings(struct hp_wmi_hw= mon_priv *priv) { u8 fan_data[128] =3D { 0 }; struct victus_s_fan_table *fan_table; - u8 min_rpm, max_rpm, gpu_delta; - int ret; + u8 min_rpm, max_rpm; + int gpu_delta, ret; =20 /* Default behaviour on hwmon init is automatic mode */ priv->mode =3D PWM_MODE_AUTO; @@ -2572,7 +2572,8 @@ static int hp_wmi_setup_fan_settings(struct hp_wmi_hw= mon_priv *priv) =20 min_rpm =3D fan_table->entries[0].cpu_rpm; max_rpm =3D fan_table->entries[fan_table->header.num_entries - 1].cpu_rpm; - gpu_delta =3D fan_table->entries[0].gpu_rpm - fan_table->entries[0].cpu_r= pm; + gpu_delta =3D fan_table->entries[0].gpu_rpm - + fan_table->entries[0].cpu_rpm; priv->min_rpm =3D min_rpm; priv->max_rpm =3D max_rpm; priv->gpu_delta =3D gpu_delta; --=20 2.53.0 From nobody Tue Apr 7 11:15:22 2026 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C763C2DC334 for ; Sun, 5 Apr 2026 14:45:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775400324; cv=none; b=jcfChhiMvx00JEOoB5YrvoI2wklQEDpL5Hr50Ahbt0GCJgbaI/sy2kd3NNPs8wdbBq1RcWMLKolBl9XN4NghVPcfYXWYfBn34jVCqXbbBByV3yaBgqqkEk2PzLAvaprtIGz2l/J8XKLKHdvVdMGksLLlpdcdMxt4w/OnRPRyzIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775400324; c=relaxed/simple; bh=iw6oCMMoh6LCJVfNJArbuy/OF13vutR+b+pJP5DPEhM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dq4BzL89VuMAl/BKeUTgwSMxENZNPPSHcNHdQmonjQrGrq1CbTYkC/UPnQdw4D0dYdHzycWCEeUn60W8qFgRFmFvZf2p73vK1uDJ2X2O8txPKTvFsyDLbyGbOqt60yX1leGPpABzJ5b8ar2d3sMjz/Pfd7HT54HCeAwZE9JCkgI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fPlolnwP; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fPlolnwP" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-43cf7190580so377761f8f.0 for ; Sun, 05 Apr 2026 07:45:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775400321; x=1776005121; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3XlY1tHjRVA8K5Aytp5TG9QNprv6BjZAraUQpx4lOx8=; b=fPlolnwPL8+QBP+hu3M4FVex0xATAow/xW8AZnYzgf76eFA0S7fSCm6w4zeCPre+dD ITbqb4wdCUR6gvZYSGSXPC0SsFDRyd3o3omOUF1JUVHsmbEaL692h6IODZzczH7+N0cp asl/OH46DyehaubCcyeN6NGhmHNhGpR0TEwFNLEKGOlZ6j+PT/51NGW2sJlVyaLrtB4D oO7xpd1fSojn28E7i3Ajw1w2XObWgBElcUywNiY1mnIvwv4xeSUqekHNGg067P4CkrUU lvV4blKMpoB+/YmhqopcUf2eCZ/70tIxI+ZG1PuSwKYm00pe+H+zvfECtqfg6SkeLXzJ IMKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775400321; x=1776005121; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=3XlY1tHjRVA8K5Aytp5TG9QNprv6BjZAraUQpx4lOx8=; b=Bs5mb6rgXS6i69oB/sAMPqHJxYuIl+/UQQ8LjKwZiaFtfV0JHf+Unxwc62R5e5xU0M jxu5yaUDIQu1niOsI983Sx6MTSJut040QkVhb/04/AysSLEAt/q6Mmv6t4WhSGtbhqu4 DRP+VunWTTCwOkTyfC61KfLsixUid/ncdFJB4Fug9TI/K3x5RoRoW1t/70PiMIlzQ70e 5AtOHaBYgmRBF3dWN2PQrOLBiRTN9wWTS6+B5ST/pztsv0Eq3vZkgO+qxatfbhAbp3BQ KuD98fCDHFu2ybqRoS5eNlqp1/EGM4UwaKoCsnMYhLSldiiqSfAKbNdkg0D6xnn9LkB6 T70w== X-Forwarded-Encrypted: i=1; AJvYcCWwgqoKT+gbZj8z3t07RcQiXS9h/S5rHPIDd7GHjp2j74RCTmvlFEENhtegcVw3Pf63LDD4WtwpYzcp81k=@vger.kernel.org X-Gm-Message-State: AOJu0Yyt/9OEkvubKiRN2+38eIlwYWHFwP+Z3WoVGaBTOy7ogmNuHrua DID+c1j01Z1m9+JoKtFCv0RuJ9phNCumMpmfK9PDsuzg+x0T1CHsolEygEDDTEARFj8NmA== X-Gm-Gg: AeBDieteT6HQlno9DCBfP+0YHKJ/WRVKpqSQFIHS2SonPUlL6/36isj8uzm7ryciL5c mDZnDUQXdRVnOMA5eUVoMoK3EcssoiPs0Sok9rO+dkbP7laJ7LgJ9Rm3r4cmYbWffi0GHYkNk6i DdNtI4VMI/r9Pnza9G5+DUu4ebyuZUEMV4TOOPVY1yVnXcDFcaVPNsWrnI8VnUi2McsilFxc3BZ W7Gf1Bc4iwACPe4ScWsK5bx+LckjQWiRt6uVl+oBDuUn0yhrbzOlMC49qVcDU+U/SGNXMel8a2F Mr2kgeT45n3bJs9YAUGw0xk3BgvXpW5oIuAcwlwYRJd1lCxomJCcH8u1kedVXQ7Y0qZreJCX581 e3Rb7LW477nR2G7x7ybKJSqAmkrj9zBEOdIUzdW3jwA+2vbmYJYkLJHnw30gMV2kyaWRSY3y8X6 9iFrcWpcQj+kIj3oNc0DkpvBLwOP+wqIsb4wGdvDy6268OPCu91ArIjykGSx4= X-Received: by 2002:a05:6000:25ee:b0:43c:fd0b:c5c5 with SMTP id ffacd0b85a97d-43d292e12bamr5915140f8f.6.1775400321157; Sun, 05 Apr 2026 07:45:21 -0700 (PDT) Received: from fridge.local ([2a00:1d35:c836:5700:77d9:f36f:3748:d642]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e4f1a99sm35698799f8f.32.2026.04.05.07.45.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Apr 2026 07:45:20 -0700 (PDT) From: Emre Cecanpunar To: platform-driver-x86@vger.kernel.org Cc: hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, krishna.chomal108@gmail.com, edip@medip.dev, emreleno@gmail.com Subject: [PATCH v3 5/5] platform/x86: hp-wmi: add locking for concurrent hwmon access Date: Sun, 5 Apr 2026 17:45:00 +0300 Message-ID: <20260405144502.24944-6-emreleno@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260405144502.24944-1-emreleno@gmail.com> References: <20260405144502.24944-1-emreleno@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" hp_wmi_hwmon_priv.mode and .pwm are written by hp_wmi_hwmon_write() in sysfs context and read by hp_wmi_hwmon_keep_alive_handler() in a workqueue. A concurrent write and keep-alive expiry can observe an inconsistent mode/pwm pair (e.g. mode=3DMANUAL with a stale pwm). Add a mutex to hp_wmi_hwmon_priv protecting mode and pwm. Hold it in hp_wmi_hwmon_write() across the field update and apply call, and in hp_wmi_hwmon_keep_alive_handler() before calling apply. In hp_wmi_hwmon_read(), only the pwm_enable path reads priv->mode; use scoped_guard() there to avoid holding the lock across unrelated WMI calls. Fixes: c203c59fb5de ("platform/x86: hp-wmi: implement fan keep-alive") Signed-off-by: Emre Cecanpunar --- drivers/platform/x86/hp/hp-wmi.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index db72ad9da0a5..1096fb46cbcd 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -453,6 +453,7 @@ enum pwm_modes { }; =20 struct hp_wmi_hwmon_priv { + struct mutex lock; /* protects mode, pwm */ u8 min_rpm; u8 max_rpm; int gpu_delta; @@ -2422,6 +2423,7 @@ static int hp_wmi_hwmon_read(struct device *dev, enum= hwmon_sensor_types type, { struct hp_wmi_hwmon_priv *priv; int rpm, ret; + u8 mode; =20 priv =3D dev_get_drvdata(dev); switch (type) { @@ -2445,11 +2447,13 @@ static int hp_wmi_hwmon_read(struct device *dev, en= um hwmon_sensor_types type, *val =3D rpm_to_pwm(rpm / 100, priv); return 0; } - switch (priv->mode) { + scoped_guard(mutex, &priv->lock) + mode =3D priv->mode; + switch (mode) { case PWM_MODE_MAX: case PWM_MODE_MANUAL: case PWM_MODE_AUTO: - *val =3D priv->mode; + *val =3D mode; return 0; default: /* shouldn't happen */ @@ -2467,6 +2471,7 @@ static int hp_wmi_hwmon_write(struct device *dev, enu= m hwmon_sensor_types type, int rpm; =20 priv =3D dev_get_drvdata(dev); + guard(mutex)(&priv->lock); switch (type) { case hwmon_pwm: if (attr =3D=3D hwmon_pwm_input) { @@ -2535,6 +2540,8 @@ static void hp_wmi_hwmon_keep_alive_handler(struct wo= rk_struct *work) =20 dwork =3D to_delayed_work(work); priv =3D container_of(dwork, struct hp_wmi_hwmon_priv, keep_alive_dwork); + + guard(mutex)(&priv->lock); /* * Re-apply the current hwmon context settings. * NOTE: hp_wmi_apply_fan_settings will handle the re-scheduling. @@ -2592,6 +2599,8 @@ static int hp_wmi_hwmon_init(void) if (!priv) return -ENOMEM; =20 + mutex_init(&priv->lock); + ret =3D hp_wmi_setup_fan_settings(priv); if (ret) return ret; --=20 2.53.0