From nobody Fri Jun 12 11:28:09 2026 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 C71113B9607 for ; Tue, 7 Apr 2026 14:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775571940; cv=none; b=di6BjfjaT8qFeiL3FkqnU3HzgeCq87Y3ZwLtuLi1sBUFyQ2P4lFmbApB/dUfMocszpY3P3hJsEiwqOKa7KX8XzZCqs+4i+L7aWDRhxp9FWs//6aHGtl5LZaBCqVICL+7rXDIAYPqCvTDQiHCzj48vmghroSOviOPhWJ+EzkMHbk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775571940; c=relaxed/simple; bh=44Okvn52N6xqTGEytJH/Z5j9cTiQ194ocVa3p4+mz6A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nkq5tGXmVLHoCO7wSoydvmxOtucdYQla/Y2BqZeHkbwMZRqj3qQKk3gwvyNgN6CQ0NSKb6X4ODwG16ig1iz7dxl9VCDtyzn27inVHPFpnpU4WBBehD7U/AY3YRs9sGkrqjgrYHcRdF/11ZdSwf38PwMJ/3e5/eqLBsKviZhQ0d8= 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=czu2Gu3R; arc=none smtp.client-ip=209.85.221.52 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="czu2Gu3R" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-43cf7258875so313583f8f.2 for ; Tue, 07 Apr 2026 07:25:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775571937; x=1776176737; 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=czu2Gu3R3ENoCfcYvOH1uAqTnD+XJXD/2+tReHe3xSprwR6g8W3xBOP/EvnhGeaQuL upeLoWyk1vkEnVa5JAeJ6D7grntN+kp+aafYxwFV0xuWrGQfeYBqqYwN4uyoYUz2rqil 7InYHy+9QC5Va8AghJ6hqT0jFhQc8VMWmPBLS1Qu1JH6V0fXBtbWReAd1EfxlxHmzccE BhoVZCuTQex06B6ARhJfPKapUVm/fif/b1PjsvhtdXfhKkrJOA6gNmCv9Mz1DLoEtUVZ bRf+ShxnMNx8tN7iSTanF9up7wjmMvgaJO3Q9pKqyUarzxY51qguJNivRWUruLo8RK3m cXVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775571937; x=1776176737; 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=JKk3k3yJDuv4o9qBzeCoLDfONKeGZy9qinDCGRFPejDbaK50Y8EsnASsqCr163AyBV 2998uSyWaeOPfUpU/kmlIXOjzHznLGP+XdLc0ahmSJzd0AHTlqtihA6h/E3rpDZ8p4uW 7fNf/KVS6X+QlcVSDMF7bAAlA3it/7ICu+Gs/QVGgeXwQfkRRbhQ3LYfPpMeAiNWh7G+ E+wL4fk8EpqZYQVsSg5ACXiXOhyWfvEcP3Cl6McL5aNMOkOrWDkC2otDZtOYx2bFVeIB J5qbZDbf27s78EdmSsN7K17LZDGiOCNoihI273hZX8a9/8tI0AFAIJnLGSMCoc9Hz9nd Lz9g== X-Forwarded-Encrypted: i=1; AJvYcCXB7SDX8+sKFagzJTp3wMCpgi+K/kFXzLHeYD7+Bmp68FyJJjni+ktP4HkpMYnoxKrFKN3jpL/D3tP6RC0=@vger.kernel.org X-Gm-Message-State: AOJu0YzlMRiI4wAmmhQjGrji3emUhlVTA24LDe4cgZ+Sua/MPc0pt3u+ anWcW6gJabD3/ZtjziaASU/YH5tQw6EGtXbqH6WfSW8C/Zw6cvv4LSWc X-Gm-Gg: AeBDietypEZk04wOBItqsanrMNo0CmCOaNZvW7PiJvTSil8gqDruswiibo5VgheIoBS K08UpLEVZT1hxBVJw2E0MTqZ8XeAFitX5JJKpcNqJKNU4UwjMA+m2byncKh7GrwtcfCVqIkB0Gk G6nB6acgQq3dl/KTE+0FQyaGDwPMRmhQaFIfFYAz6/YDJk85qI9kwZ9JhfUKrLiShpvkYlYh3+2 KhcrGKYHZaoX7/P+enx5IAWtLC8ptJSYWlFojEYB4gw7z6o5Bry/c1YXZE0z+MuVRxybq5mYLNZ XHE8JBpkguPfwagEV+TRvYXGdfFvhEh9c4kCzzP/Myo4fiA5wO9k0iadST+VUtgVLQ9uMuJkPKU nOEcCaXoZyKnh/+Ek80PILjcZRdMn6hJDtf6PKpdnfhCiccKOckQ88/eQThl+rjCm085wXRBWG2 26RWa4SYC5FXO7JWCUyD7OReuxLcG2GHqy89dMCEjvVwI9ibRIZ3c2lDpSPJM9XQ== X-Received: by 2002:a05:6000:25e3:b0:439:c24b:ec13 with SMTP id ffacd0b85a97d-43d292f5563mr11046699f8f.7.1775571937114; Tue, 07 Apr 2026 07:25:37 -0700 (PDT) Received: from localhost.localdomain ([31.7.38.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e4f1a99sm53489990f8f.32.2026.04.07.07.25.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 07:25:36 -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 v4 1/5] platform/x86: hp-wmi: fix ignored return values in fan settings Date: Tue, 7 Apr 2026 17:25:10 +0300 Message-ID: <20260407142515.20683-2-emreleno@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260407142515.20683-1-emreleno@gmail.com> References: <20260407142515.20683-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 Fri Jun 12 11:28:09 2026 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 D32273BD22D for ; Tue, 7 Apr 2026 14:25:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775571942; cv=none; b=tZNURajnmqvi2lmStbKQaHUSpm6p6kxod77PaLvnWGsAXBTCxLNZM0jp+L7dF+MFlPpnFgha2e69Omk8kc9WCw7nDyOwGdX25fCLDPAWvcLDmIbFN2WLRSSl2GD5fvfhqTsMDzqq8WwkOAstfJhRn1VQslpxrh0+tAXgLYmF1Mw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775571942; c=relaxed/simple; bh=TfNxeGb9nt4qVFEDy3vSP2vU6t/UvG2YByCxEcAn8sI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SCi72PuE/e6vOHeSZalj27ZcZK0MoSpu+w6I25NSWW0Qtlx/yk+sOQop4m34RHCgQvP9qCJwS6Hwkdh9UZ+ScNiEsoOzOKKeVFBexwMVbH/+tVX/5thJoZrxAdLA7e47TVx5q8gqsAEZD7B7avYltNhJtbZ20sRsJtyR/Yx971M= 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=QjAWmBzV; arc=none smtp.client-ip=209.85.221.44 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="QjAWmBzV" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-43b8cb81bc0so271803f8f.2 for ; Tue, 07 Apr 2026 07:25:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775571939; x=1776176739; 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=QjAWmBzVzs2ez7jWQUrLqzEWHpl8yx5qG8Sq0j05/QWL9X6gMr/GCHeVHeGRY8JsFl FAtJnsMZOFaO7CqgU2b/8qNerctEgOZzyECGHyR52AQiDGnLyDDsI9laokvGYxabRDvf OVvU8Vj8jxJzB6ObNYf+9lWE8gdnS3cP9jEeQkhnB9GIlXn1GLb2PPfel7Fu4cku6pwn nu1x2Kma/8h5iiICWYcsiAQEpbpeU0NiMKTU4/Ke8MH9pnXytHwZ7/bVSBmrejiZ+bLa NJX5q+PpzGK3wLVRErXGvU410tH5IPgOAdnB1XDbKnKcYwce8evyQmQeruPAC0zSDezm wBZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775571939; x=1776176739; 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=m7pnk9JBtfmRTJ5lzlXU0iNQyf98d/m8hipIpAQEhIkfqEffPQ3D8XnIbDo90KDwtx 2isXRXg37fKTIQ8FEvWhvuJkhiB9GkUl0ckCq+tvJyMyG3Ar6YDeIvPCIQnypaoUKfBR eAEEJa/RPOfXpwy19a/CxCskHMy9jAL8c+Ix1GLBniW+EKjdgFxwjR9okS9hNCDzubt0 TxL4zoRvkXxrn+SWURUWwW7YtwFRcXtFo1C8NsZA8yFQAcIQxcwoP5hIT8MnoujNSvYQ zECa2NVg0M+SjZH7I4/m52r8cy+V/XWkHM/zQ9Nt0KgUuP91+grTjISL9VFORbDIieA5 C4LQ== X-Forwarded-Encrypted: i=1; AJvYcCWLRhbaBSzS/f/3QXIc9o0bqP0Qu0pymmbN8kH2qfOKwAxQTzyEpXDS1AMLI1C/vix/YBkk/QDScCwAlnU=@vger.kernel.org X-Gm-Message-State: AOJu0YwQDn2/to1qLpQBkgoryl/lt1Z2JgDflW5fxheDqOyaEm9gmoqi 93UcBV+j7u219ryW8rQ9P5r7RXqg3XIM0lIII4yWGryq3D7W23MK1SJQ X-Gm-Gg: AeBDieswHcf94LWABsxWtpDE1Vyd3ThHIJHTqRcwKg0hqwgbemwCY/gSLd9U91AaoPx 0ceqddwpSJ0XpVbaEjBGNeV983a6k8DR4F4sy9vGPF6yKTXwfDeTZVGJ/764pUhjTPjjEz5EmzT UFL0vJ+Ky5nAQ0FD+lVGdFhcu3H7Q793bhKiZXHaWS47E+gDHEnf7xv0t+gkx76LRp84VGGFOyc HZ5Ghas2k8mLvd5rKrS1S6k3osTL8RRCZOGyYTDC4adxSa17gbDpNhJZT/hgnC5NYbFGwVswVbn T6SxCEdjC6xcCh3K/aJme4Lq26LH21rhJJ38K41/+eoI53zmKJU9Kvdzy7ya0GbRcfaiWmsGxQb v04ZplydAthCej1VhCQCzoCOMnLDmczjbZML3hqkkKsD4NLZEkOfNcaO6ci2rijGhqNLDKdvkBs OK01dtl/4/81CnpH6172kdhEk0l1I3EgxLw51+cd/Gt2XoGV4heBWmm/UkqlgPOA== X-Received: by 2002:a05:6000:186f:b0:43d:4c34:6668 with SMTP id ffacd0b85a97d-43d4c346772mr1883002f8f.0.1775571939138; Tue, 07 Apr 2026 07:25:39 -0700 (PDT) Received: from localhost.localdomain ([31.7.38.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e4f1a99sm53489990f8f.32.2026.04.07.07.25.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 07:25:38 -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 v4 2/5] platform/x86: hp-wmi: avoid cancel_delayed_work_sync from work handler Date: Tue, 7 Apr 2026 17:25:11 +0300 Message-ID: <20260407142515.20683-3-emreleno@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260407142515.20683-1-emreleno@gmail.com> References: <20260407142515.20683-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 Fri Jun 12 11:28:09 2026 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 26AF83BE16E for ; Tue, 7 Apr 2026 14:25:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775571944; cv=none; b=H0VJvFLMjOp8JBzwfw2lfDIyJjgzNpQA0UskFUtEfKUmozQ/LywHNWTyXyzOm7FxQPR4saeR5yy8qYH6BN7v/7tB7jVb9YXO7ARy+DFKNXQng7+RFkdQnCvM33Bed1I8+P/fDueuYJ/TcTgAXy6E9m0odFGxY9gRQO4VcxXdHj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775571944; c=relaxed/simple; bh=YxZ/d8hWc5Dojxq2+WQ8y//zQ0MV75jV5AaZq1iu/u8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RIVnmDzQ7wpmXzPxKT2s0b3tHkFgD8vLN07tDYvscGnMdA0Fn27O69fsC84jpmLHksY7No7fJPdud94mqr477ClVd4AmKqXAgoySlY9AKlZCZSXvj0oJvisubODWr9IukzaBgU06cwF5RqQbZuf8aPPGcJB12WDNeZPNYP0zVAs= 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=jIbURaW+; arc=none smtp.client-ip=209.85.128.48 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="jIbURaW+" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-483708b697cso7713325e9.3 for ; Tue, 07 Apr 2026 07:25:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775571941; x=1776176741; 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=jIbURaW+ukOGuQQctJEoairvOPQeByCUvvxUD+PGkWm6bdyaiWI0ltQPinY65dB0QY ua5efzQYPoCVt3wl1z9nD7vLnIC3gtnCxv+9QQguRXpkAI8wx/qvDbEn4HDBYJ2y8vNj SW/DBlfFCR0Sr2SdbmGq/N+TlKgS3+J3daqp+zDDwXfwiHW6uXnFDx7ENxrEQ4oNueqc /8JozC6SehqasCorKIalQkCfSha4F2jFxa+ScdFfj+XRwQEikNce2d5zA+BvL93yBKUZ HJ4zTMAja1OOuwcJSkVFCQKTNRtHb0QIudmcR3S6bTdkKkniRYehBdOpX2IxP1zjVosz 9r1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775571941; x=1776176741; 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=adniE1MNvBgAIaFD6Fqc5DHI/kl22xV5NBFucDAfSYFImnR//fuCMWVEbibYJWZPxK I4KCbq75K9ooI7kUVqsYlsXwSf+0DB5JGOdpW3DBkVDIVoMs0UngtmO+OLL5xn7z7lTN 7R8kvqQw6nHxnKC9WwNbUht9dEFzHBUOnQJu3o8a1gaGbV+2HYKL/gxvtu9HoFR7AFZ5 RwEx+InKCBtf+XWHwQJsu+WV036w/OrsmraLetb+f6FaQiDVAizslkPTwZslbIMgBrft Z8eOBRydbdzQIup9WzkQ3bpm4zo+0bNUX0pmnJy+EaeS2OhJOBB8H0OEJNKoQAOPSkgp DkQQ== X-Forwarded-Encrypted: i=1; AJvYcCUEISwVP/MSnVVzl21ExNE99TvrwO4FsSv32JsrdYlL5wAbOBu8++idE+NhcR/miuyxAzwSvlQCrQuANFM=@vger.kernel.org X-Gm-Message-State: AOJu0Ywl2atHIYIevBMJUJ085gyRJpXa87GOzLQeprSqIn3SZJSa4YU9 gl64Z2q7GpNNw0LrqB+djCvdg8luBr5cTx0rH/fLz2oyenpC2idFwEkx X-Gm-Gg: AeBDiev+ssX87peXgpW5PYqjnaCUXXCtx7gL5GVdNuqdk7P9JgKF5DoDjqvWk7/2jxj i7pSGWHlYEDyp7qqzVKcqKwDYFLxH7bpUU21jMgL50UHhZeDXnKHXRjHm9PuixCzOK9orST3KKr 1gWotPAV61pFq+riqcsYQ8f7IpMurUbtq9CH11kPv84Fztcxp1GfYEMtv1ZvNVmFOdRXSk747/8 krxFVEgX5BMTODc+ddyRilGiY0iNaEjpiwJJHEHlY8Eo5Xq27H22nFrS1oy3+rxM7W6oSN6LTg4 YrNJ96TIyVcmC4jDHcFmFsY3JueapDO84FogsAjTbOEep/pGNiwnuaasxfIUArKiMAA5n+iQ5Ju w8nsVDqRLKT80vbRodlp9g8GddEzqi2h5ytJUPlpXfZox6ojsA8nRZlDpjSWhTRExAKxq6gYhRG ehPJb/bkZn+7eu9t4wb0cDr3znon/kgakailNUJvrO55litGx3hb6rtbUX9u/AYw== X-Received: by 2002:a05:600c:3152:b0:486:b967:5c9b with SMTP id 5b1f17b1804b1-48899e90690mr135036095e9.3.1775571941416; Tue, 07 Apr 2026 07:25:41 -0700 (PDT) Received: from localhost.localdomain ([31.7.38.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e4f1a99sm53489990f8f.32.2026.04.07.07.25.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 07:25:40 -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 v4 3/5] platform/x86: hp-wmi: use mod_delayed_work to reset keep-alive timer Date: Tue, 7 Apr 2026 17:25:12 +0300 Message-ID: <20260407142515.20683-4-emreleno@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260407142515.20683-1-emreleno@gmail.com> References: <20260407142515.20683-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 Fri Jun 12 11:28:09 2026 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 DB0823BE634 for ; Tue, 7 Apr 2026 14:25:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775571946; cv=none; b=MeB2ytJgc+jrAo25WgouAN0jdPGvzh0KUasI6I5H+Ew905KA8AivXJOp3vMX/t5xeJObY1hAmYo9jjuKoqTlW9U+VT3TXK6XuktWZO9UVLiUciNKo0SB+GsOeJZhVZSsYNENzY9wNjqD2WZ4FX5r1RSBfLLustmqJ7NCsbjyFaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775571946; c=relaxed/simple; bh=0xtk6l9zXJ52xBcCS8Er3MVuVDFKl38JCXDoxR2HnAA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QMu8izsGcwrCRfr7vrpyaavt6tkmBOPQHBmSo00q8iqJMjFarE2j4lwzb/qDFdrJh395R4JtQ5aRv0ir0olDhJGLPVbcUGnLbp24c9MADH1H44JPIEEBrDhvqnOTXgRWVDjUB3/ZepZzb+brtK8s21XYMfaapm5WTDptK10kPJQ= 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=B81cm8t6; arc=none smtp.client-ip=209.85.221.54 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="B81cm8t6" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-43cf5ba9b93so599862f8f.2 for ; Tue, 07 Apr 2026 07:25:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775571943; x=1776176743; 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=TqshKVQ1S707dYaNTrTbQfEtf4ZgIgsOHm40TNLvX7s=; b=B81cm8t6tAuDgvt4vsjLA8gm/w8+/3PFg3TAuR0xKcqCBDU6eGJzPdIRop0grEne3J 5pK7iCZnVcoxRNJ7h8Qrp0PFofkLqMcImqwRy7A4NmhJVFxRTnh7/EgXAu7MdzjFEm91 7yTBX/K/Ws/bA+JfnfOH21Mvjpr9pqpmLedxMSxEgd6qq3DJQ71vMR/QzP9DkKLgxeIi v63QczegJfTKiWd46DuQWpDJjFmAIpMNTQdkj0RsnyZc/09uwXenGn7CwD6O3OC9UyDQ I3j/fmUlRT60oCKrIo4fR3bxKjKJvfEZKkhPAyIoQSGwXQOYDhFjEWyXa6N7dSa48+s5 khoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775571943; x=1776176743; 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=TqshKVQ1S707dYaNTrTbQfEtf4ZgIgsOHm40TNLvX7s=; b=se0qZ6gvLLmrf2VnqyfAcZoNR+kS35c9j5VOBX+fy0nC4m8wciiLwTKpOaK/u2ow8A R047MYkjh73I8JN5DzMcZ3ADNdFrwKFnkMHQuoSJsuNFbuoyh7dxdahCCk0HqUkpJih1 c5KVYrp0WQXImcFSSCSg5iqJk6ItQOZnP1FCJJ60QQwqHr1kd4mnLjy0ZdTZCvJH9nWc cW54Ks4qZBfW3whMomJY803uP+1Yp1NBNxAEaC7ZMfeiPhGLExoqckHI09Oec91QEhw+ 39/lFhX3ufPbK1SwwB6BHC8Xuw9zFfCboGbzMSZHWMCCzU+Qig1DfjQ1+/pI9TUuJv+2 JqRw== X-Forwarded-Encrypted: i=1; AJvYcCWn2e5mU06ifD5UbxIPFC+yQZph63CAxIhGM25oT4Nnr89l+1flafEl/J9JwrB3fysPgMvboqgrorNZFgk=@vger.kernel.org X-Gm-Message-State: AOJu0YwLCknMSQU2M40rI7bNbRXUJhTRSflkv3doHXni+edzS8mL9j66 RPv8pfvsJoH6qnxmdeV55m1FdwlpUPpdmS96N8PM2+S0ZJPBRx0EwXSQ X-Gm-Gg: AeBDieunlz8tQtyDKkBQEwi0tyHuKnABhoFLW0bJDlLV7DSysM9QeNHp1roA3QJtnK6 kbMudhYmc6MLW+whpYf8MiiC2f/e9bLu/NSfuiIYjqe/zn4wlwvXrttRqM9D2FBGef93i04Bauu TndFFGHMzCHbXGI4JUMGpICNSu33539ATbrZAcss/vSAg2dRr+wjKr1s/BR0od8zd9qgJvZ4yOC 49IHPs5svMCRgHjZJXdjd4mTGh4buIwvkzEaiPUnS4VX0C1KfR7+zOB2iGVz2R8UQfQVdmrunVE aU5f7rQBbOXm9AaPyP6xLcCjWKkEE4N02aZUC2ePalYD4DUwJEiClLozQdo5udW4bIjo7JpQDE6 PuIbJfh8Oul5tIT4Fk4dZmXC5nMG7XW8W1Dg38UhV06lzWS1OC4MJeZmlwuPWcyVFLO0HW0uapF l7cqxwbpqmZk9fcshMcfgvnAwSeZqTBsqNuQSar7Z3a27ows96pkk/leAVFj9thA== X-Received: by 2002:a05:6000:18a8:b0:43d:4cc6:77dc with SMTP id ffacd0b85a97d-43d4cc6781dmr1948333f8f.2.1775571943194; Tue, 07 Apr 2026 07:25:43 -0700 (PDT) Received: from localhost.localdomain ([31.7.38.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e4f1a99sm53489990f8f.32.2026.04.07.07.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 07:25:42 -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 v4 4/5] platform/x86: hp-wmi: fix u8 underflow in gpu_delta calculation Date: Tue, 7 Apr 2026 17:25:13 +0300 Message-ID: <20260407142515.20683-5-emreleno@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260407142515.20683-1-emreleno@gmail.com> References: <20260407142515.20683-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 v4: - Restore gpu_delta assignment to a single line to avoid unrelated style no= ise. - This results in the assignment being identical to the base branch, effect= ively removing that hunk from the patch while keeping the type change. Changes in v3: - Remove unnecessary casting. - Add Fixes: tag. Changes in v2: - Change gpu_delta type to int to handle potential negative values. drivers/platform/x86/hp/hp-wmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 2932cab9aa78..4f49861d3fbe 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; /* Default behaviour on hwmon init is automatic mode */ priv->mode =3D PWM_MODE_AUTO; -- 2.53.0 From nobody Fri Jun 12 11:28:09 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 7D9973BE654 for ; Tue, 7 Apr 2026 14:25:46 +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=1775571947; cv=none; b=Eg3XD8pJO1sdT0SDN0SUoU9ZXjZZ0iQgAz2bHISMUFKq3Y5K1Ni4V5I3aW2x87pXX19wKavvi/nhbOx3c6P4jTczZTFGq7O8y+VSbVImh87wlWw0Rigskg6csDVlfbEvVqUuif2Oy+DNQ7ckXM8Y+klrc3+WjcUC0T2oQ3goNpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775571947; c=relaxed/simple; bh=oagBiGn9yap490aPu+qNXgOoV9AQzMDW831Ks4zUb1I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ASW+bANWVCoGqLZ+HnkGv3EzCeY2qzkAkeDEo3iP1ma+rVWKYHdFNak1pW9cq5M2RVTWvsD1HRHKEFaaeEn3BorT/jP2s2U0hQzfcoT/Yjme8/wEGBXHuH3DIygkfilZ+HGNg6Ktsgg3p5KPG5X76SyruVn1Ey4lEt9SI3Tq+Q4= 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=lC7BsgYN; 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="lC7BsgYN" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-43cf5f6d2eeso196511f8f.0 for ; Tue, 07 Apr 2026 07:25:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775571945; x=1776176745; 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=XuC322jDmAgsELlQ3uSNloCGDfnK1HdiuXq+p7r0feg=; b=lC7BsgYNcy4+JBJWiS0eBoyzoUctNxNl2xV+NfJdYwnbbsossStaA4yBr64c767fEO 3AJeaHx61dZGAbmmab3gub+7PEiXpWDC5Ae53cBMK/60Ahq4WSi0Qz7Lx5/Kbp2iX2IX Z1idOF31vHYbkKwSVMDlg3/vB4DTQmP7e5V8n7sQi2Rz6ZLRz/5cbbdVcHAS5A8Ldu18 ArHR7bw7ZPegsv6SGB2PiJxgsgvztq0+X1x0v9HjUwRJI1Gad8t1B/PNYYuJqO+emPZh YjwX+jHQ31VII6HgW5T06MFMZ5wPM2NORAIsS2PustKfEt0iSM+Y44O5I9Rwv89IFcOI ibKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775571945; x=1776176745; 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=XuC322jDmAgsELlQ3uSNloCGDfnK1HdiuXq+p7r0feg=; b=OUgzbC2qdBDFVqRIuU/Xg3tmt3EgHKT7sZG9efqNcMa5FkzaxxhUSg1eP7irK5lXRN hfZCMDB+KZnAzRIp5KWQfFiadog1heG8YzS1sSn+QUpdd7PayQveqGo+gboqkrkGkpgu 4PU257mlyvYlAmTHYOWd7Xd1kYdRwUx2XM8WTagA28jqJGIfN0jIyMouEsQXZDn1/wyY K5fHDoBjYiNO6PtBqVN5GAXOnHLARv7c4CC6f0JWmJlCYoDwqmZgr+fKBOFXuuGQky9D dm0+1NZqDkHIMtKlci5xzYYOl6v1lIIkSqLqjNnDxGUK9wtN2gA2ejPWEodGu/anM0yD 0UKw== X-Forwarded-Encrypted: i=1; AJvYcCWfH1YbgjK88dLAB+VbKbO8m/7J5XuMGeMTu/rYo5xnXFpDLQnMW6cus46XpjMjJTlWzyX28Eq0COde3nA=@vger.kernel.org X-Gm-Message-State: AOJu0YxH06uwXjIkaG00SqwPqPCkNjCGNdDyE/fDKFYpHRBgIIGKq1P+ s6c2akqModFRQtmPQfVvEJUBlBAWq3FLUNlTTmuOLsl7V9hP7pN6gImN X-Gm-Gg: AeBDieub9udbQMi3oU5p8GWPN7kc9DMu1Pxb8rGFS4AgGuNPqbSrE0FyMMdKrBAFAHq gCilWcBG9dtrN/TZhDJnIb+4KP1gEsQlEiHoVTtHjNYSHY6BBy2+rSHeaPRglU8Yq8qHdrM7pO6 vKQ83fr85PPjySbd26migD3pD+9Zh9k624c9bQs6Ymm3wdnZ20rW6Y0gr0gprtzSXqppa7yq5Ji +GLX62oSyW+9cvJNjxVvkAvpP7bEwxg3YpzinxW56B7pZnELGaKGxYmWjfjbD5BDJKA/5eblUFA mH4R73qS4+adQWeWNjzY1M7CGpsIMmzukjNi7ckWVO9g4RnrujotEUVmUQrYGnClB80Ew4vP6P+ kQ/vKhrYXNWfaXRAQdqNvbxptFD23YkMuz/VHq0nialgDIbVORuemOeNSSZQqoZFjvKhUbECImV 76JhllaK3vjbxk54Cmqc4AywMy/yl/KWUsu/8tlskK7nPmfIs5zG1EAd4aOJEutQ== X-Received: by 2002:a05:6000:645:b0:43d:284d:28c with SMTP id ffacd0b85a97d-43d292f53a6mr8996744f8f.7.1775571944791; Tue, 07 Apr 2026 07:25:44 -0700 (PDT) Received: from localhost.localdomain ([31.7.38.28]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e4f1a99sm53489990f8f.32.2026.04.07.07.25.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 07:25:44 -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 v4 5/5] platform/x86: hp-wmi: add locking for concurrent hwmon access Date: Tue, 7 Apr 2026 17:25:14 +0300 Message-ID: <20260407142515.20683-6-emreleno@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260407142515.20683-1-emreleno@gmail.com> References: <20260407142515.20683-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 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") Suggested-by: Ilpo J=C3=A4rvinen Signed-off-by: Emre Cecanpunar --- Changes in v4: - Use devm_mutex_init() and handle init errors. drivers/platform/x86/hp/hp-wmi.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 4f49861d3fbe..470c6e48f8e9 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -453,6 +453,7 @@ enum pwm_modes { }; 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; 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; 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) 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. @@ -2591,6 +2598,10 @@ static int hp_wmi_hwmon_init(void) if (!priv) return -ENOMEM; + ret =3D devm_mutex_init(dev, &priv->lock); + if (ret) + return ret; + ret =3D hp_wmi_setup_fan_settings(priv); if (ret) return ret; -- 2.53.0