From nobody Mon Feb 9 00:20:32 2026 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 91B36322B8A for ; Thu, 25 Dec 2025 14:23:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766672619; cv=none; b=EA1NAsBfPA+Uc/jl11lz56igsboYJ7jPfCngDx6GaP1w35njIYyL0SLoIPtEcI1LxAjQ1zETN42LnQjp18gMPmfpexbSZmPQA8tawTya0za2zKFKIvw4VAgnLNnohbCPowSsPsJqvmEMsP3yMC3azq5QazuaejmoSNwpe/EKsvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766672619; c=relaxed/simple; bh=8as6Tg+WQ8IFIRqRkyQHtagnR5iib3TLHnxyF1PKz80=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NXaW8hthITls+VLH5u4xlHFLe3DJutRIkhgSxnVHI2nQDJ8DTp/Ni7lhoyCJ4MFeZ7ylht98cSvlX13EIBCknEiHJ1KZsZZ7AVnvhFuF2OOb2LsoL/E0H4WllnBF7N2/w1Z0vRWFDtjEwJXa6l/5/WgvX0vfqPzedle9kp8OUk0= 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=EV3OUiw0; arc=none smtp.client-ip=209.85.214.181 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="EV3OUiw0" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-2a0a95200e8so60282715ad.0 for ; Thu, 25 Dec 2025 06:23:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766672617; x=1767277417; 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=7sdD19Re9ro0Yav25pXuBH3cxFpqUWhOZekWhN56D70=; b=EV3OUiw0/9Xycj6Kpi5+FEozSbXQNLuquz2WWZkDyz9I79Am6C1aB2k2gcaOE1+Iyn UMFIbS3RZFah4reuB6CQY8K6WrM+NPjZs0PHCBt/oUwyTtFyHlsh8ejktUVlL1omC65v C1YTETcYOfrEEJoV9woSb8nOYJSFqlqWH5bFawIVcO5TuH4M/WVp67Wh4MhI+7yoPoVA AdqGmsc6HTvHX8eZFGYuhSXvTelVcP1I22vnrPjd6jF7pJDzdhRQgNAcsVjrax0cDqNK qtJ8NpbZ4ox74XSOXMNwLpi/YBzWBwXyfRnAONDIZlIKJWThs5UVsMm6gRfery/MfVft oEVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766672617; x=1767277417; 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=7sdD19Re9ro0Yav25pXuBH3cxFpqUWhOZekWhN56D70=; b=eUvt5hb6j1wbVkpWMjggEmr04VKc97QxFoT/JZa7fSNXRPpuba6OYoB02PgzA5JQxe DvRwM1m2SQqGNGYgDmtN/c1wNTcou9uqgPrNU7SBKSjRbl4X7YaSggCaNhCVZPGSYr09 CBr1q7BD3ho1f5J/zNbK0N9csfF2lgku1JUGCsQhKUQIvHUbqiKYUFQtPQk30fii3QDO zbP7kPjGNEeuJaMQtow0VRMaa4osr5FXRXCzishMLzU7pekv/3cf/rOvsuIc4teCCZnH REL2jQcokGFrCub5RXtXuE2PBQAdkA8E7EppHSCOmVTtyvDwGmb3fq+0sYWLx2zW/iKA e31Q== X-Forwarded-Encrypted: i=1; AJvYcCX+1fsnaLMB2CeRAmf/ZHG7S+qZNp26Cefc+A/PyXjFFQUhEivQ9wzlL95WyDFYqMkJRol74prtT7TNGBo=@vger.kernel.org X-Gm-Message-State: AOJu0YwMsklmqNn5gUbSjGv3DFREKOnC35HvIfGQYjkY3mxyFASQtovk lSCGzRRM/fBUXbYvv172WISBYBtCCgIFXQIcFIbQfhWws/gVTwAvhbxo X-Gm-Gg: AY/fxX7h2Yx72P+OUQjCiqg6Ub051+y7TiIMsx1ZdfIMS6hmcGsbL/RxxGR1u3BlLKv QiESkzC7BTQknyD5JNFHLu5s3AUepRKth7qUROjWp5KMIlRml0NCfM2I2v6o4iYAN0ncq0fOHTi XRSqi28ftXGc4UPWYHnwg8iu7ydfLqUA2lg+rimJWS+mhJ99o0cYE0eJE23Cy39+EaNCjgilpC8 UzApti+W7zevybKrsiacJL7MyhZsWfjDq3qPz56Hc+wUrhudSmVTjldQkwl/2QHxuJjWZUgTTKY LJ841pFitKBZ/gM8BHV8cEqGbtKNmGPViw44tpt6C6zwuyD+aHaAAuIEVPy4BcS5ycNcyAgLTwd pZI/afUMgafGYINGdCfs/LPplZUF5YBdJNy8CCNx2/ehRts+bafGdcLqdncnOorUWrZzgk91i+e /BSg8xPIN4NViZ9zbdY4M= X-Google-Smtp-Source: AGHT+IHhLxUJC8jIpI5cCyFf9GFQOizdf8CcwKsNqsRfZMhwDQ1kXzIt0SrXUQnK6EXtUrfYhROXMA== X-Received: by 2002:a17:903:1c8:b0:295:c2e7:7199 with SMTP id d9443c01a7336-2a2f2732890mr201635125ad.29.1766672616760; Thu, 25 Dec 2025 06:23:36 -0800 (PST) Received: from archlinux ([2405:201:1b:225c:eb9d:1fc0:f95c:bd90]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a2f3da7dabsm180892195ad.25.2025.12.25.06.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Dec 2025 06:23:36 -0800 (PST) From: Krishna Chomal To: ilpo.jarvinen@linux.intel.com, hansg@kernel.org, linux@roeck-us.net Cc: platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Krishna Chomal Subject: [PATCH 2/2] platform/x86: hp-wmi: implement fan keep-alive Date: Thu, 25 Dec 2025 19:53:10 +0530 Message-ID: <20251225142310.204831-3-krishna.chomal108@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251225142310.204831-1-krishna.chomal108@gmail.com> References: <20251225142310.204831-1-krishna.chomal108@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" The firmware on some HP laptops automatically reverts the fan speed control to "Auto" mode after a 120 second timeout window. To ensure that the user-selected fan profile (Max/Manual) persists, implement a keep-alive mechanism that periodically refreshes the fan mode trigger before the timeout occurs. - Introduce a delayed workqueue to trigger the fan mode refresh every 90 seconds, ensuring the system maintains the correct fan mode setting. - Integrate the refresh mechanism into hp_wmi_hwmon_enforce_ctx() to start, update or cancel the keep-alive process based on the current fan mode. This ensures that the driver stays in sync with the hardware. Tested on: HP Omen 16-wf1xxx (board ID 8C78) Signed-off-by: Krishna Chomal --- drivers/platform/x86/hp/hp-wmi.c | 52 +++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 9fb956ce809a..fbe012e7a342 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -31,6 +31,7 @@ #include #include #include +#include =20 MODULE_AUTHOR("Matthew Garrett "); MODULE_DESCRIPTION("HP laptop WMI driver"); @@ -365,8 +366,15 @@ struct hp_wmi_hwmon_priv { u8 gpu_delta; u8 mode; u8 pwm; + struct delayed_work keep_alive_dwork; }; =20 +/* + * 90s delay to prevent the firmware from resetting fan mode after fixed + * 120s timeout + */ +#define KEEP_ALIVE_DELAY 90 + #define RPM_TO_PWM(rpm, ctx) fixp_linear_interpolate(0, 0, \ (ctx)->max_rpm, U8_MAX, \ clamp_val((rpm), \ @@ -2073,6 +2081,7 @@ static int __init hp_wmi_bios_setup(struct platform_d= evice *device) static void __exit hp_wmi_bios_remove(struct platform_device *device) { int i; + struct hp_wmi_hwmon_priv *ctx; =20 for (i =3D 0; i < rfkill2_count; i++) { rfkill_unregister(rfkill2[i].rfkill); @@ -2091,6 +2100,10 @@ static void __exit hp_wmi_bios_remove(struct platfor= m_device *device) rfkill_unregister(wwan_rfkill); rfkill_destroy(wwan_rfkill); } + + ctx =3D platform_get_drvdata(device); + if (ctx) + cancel_delayed_work_sync(&ctx->keep_alive_dwork); } =20 static int hp_wmi_resume_handler(struct device *device) @@ -2152,6 +2165,8 @@ static struct platform_driver hp_wmi_driver __refdata= =3D { =20 static int hp_wmi_hwmon_enforce_ctx(struct hp_wmi_hwmon_priv *ctx) { + int ret; + if (!ctx) return -ENODEV; =20 @@ -2159,23 +2174,36 @@ static int hp_wmi_hwmon_enforce_ctx(struct hp_wmi_h= wmon_priv *ctx) case PWM_MODE_MAX: if (is_victus_s_thermal_profile()) hp_wmi_get_fan_count_userdefine_trigger(); - return hp_wmi_fan_speed_max_set(1); + ret =3D hp_wmi_fan_speed_max_set(1); + break; case PWM_MODE_MANUAL: if (!is_victus_s_thermal_profile()) return -EOPNOTSUPP; - return hp_wmi_fan_speed_set(ctx, PWM_TO_RPM(ctx->pwm, ctx)); + ret =3D hp_wmi_fan_speed_set(ctx, PWM_TO_RPM(ctx->pwm, ctx)); + break; case PWM_MODE_AUTO: if (is_victus_s_thermal_profile()) { hp_wmi_get_fan_count_userdefine_trigger(); - return hp_wmi_fan_speed_max_reset(ctx); + ret =3D hp_wmi_fan_speed_max_reset(ctx); } else { - return hp_wmi_fan_speed_max_set(0); + ret =3D hp_wmi_fan_speed_max_set(0); } + break; default: /* shouldn't happen */ return -EINVAL; } =20 + if (ret < 0) + return ret; + + /* Reschedule keep-alive work based on the new state */ + if (ctx->mode =3D=3D PWM_MODE_MAX || ctx->mode =3D=3D PWM_MODE_MANUAL) + schedule_delayed_work(&ctx->keep_alive_dwork, + secs_to_jiffies(KEEP_ALIVE_DELAY)); + else + cancel_delayed_work_sync(&ctx->keep_alive_dwork); + return 0; } =20 @@ -2321,6 +2349,20 @@ static const struct hwmon_chip_info chip_info =3D { .info =3D info, }; =20 +static void hp_wmi_hwmon_keep_alive_handler(struct work_struct *work) +{ + struct delayed_work *dwork; + struct hp_wmi_hwmon_priv *ctx; + + dwork =3D to_delayed_work(work); + ctx =3D container_of(dwork, struct hp_wmi_hwmon_priv, keep_alive_dwork); + /* + * Re-apply the current hwmon context settings. + * NOTE: hp_wmi_hwmon_enforce_ctx will handle the re-scheduling. + */ + hp_wmi_hwmon_enforce_ctx(ctx); +} + static int hp_wmi_hwmon_setup_ctx(struct hp_wmi_hwmon_priv *ctx) { u8 fan_data[128]; @@ -2377,6 +2419,8 @@ static int hp_wmi_hwmon_init(void) return PTR_ERR(hwmon); } =20 + INIT_DELAYED_WORK(&ctx->keep_alive_dwork, hp_wmi_hwmon_keep_alive_handler= ); + platform_set_drvdata(hp_wmi_platform_dev, ctx); hp_wmi_hwmon_enforce_ctx(ctx); =20 return 0; --=20 2.52.0