From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4E65239E7F; Tue, 28 Oct 2025 13:50:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761659442; cv=none; b=Ko4XqK06Qix5tpm6qkRXEkiZePXA18GfcpXK8Ny//+HOh5z785YFPHiv06fmyYjERRdFZT7QjDM1Jgos2BuRl3IEWhH2MqAfLGM4TFdbONT4BWxH97RT8fjr2Xk6TxNlfegKPsYdPBISMfuDIR5KvrNtB1+HQzeqZ8Youpmhyj4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761659442; c=relaxed/simple; bh=ySfNUEYZFTZtSMSTyokNPrSh/iK/zSDPvSK3qQV6dMg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=QJZqTZrSwcRRf7z2EFnl+ibDGefpfqh4PJNFhWPAYfueB57kk8qJw6T2j1EfBH9w0up76NXZ6OjsifBkJD6hxDyuWBDXYLfcfVEZ7wKeG1S8xE8KD31rPtklIiZW9xDm4pGJXSUhqXLORP39BOiA4Yrs84HjQJQxBsbmVz0yIiQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b=DSM94YZR; arc=none smtp.client-ip=212.227.15.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b="DSM94YZR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1761659417; x=1762264217; i=w_armin@gmx.de; bh=tBkx+8DTLrJvtTVeMjGiq62hn5aLnHPRB5Uk8324rGY=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To:Cc: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=DSM94YZRmCVRuEnZ6513+RccaRUKrOcza+SWBXdo4Nl1MouPJ/SZhTuhyhhOxXGp lu2AILxGPbRRJd3HHN11gA88Q0K8WF67SmogcYCKfoYLk8ffSDxrIjPLBinrBlZMa yWWamv0BjPZa9OuaFdBNLZF4cLyhpK/3nxkvZ6PKQwzHDm/hcVY/iLl0ThVv9EBFh xNLJAixop3lwuzgN6XNzbPXiMpx6rHWCZ3RnB3x+hC9BHnURI88mvjNKCFLtd/TRP RADJlyivbOOoTr5bOlbJeSGkEs7BF3OoAvx8yeDJuz1RTq+qJxE3hTTuBJYiCdplc 7vW7Y6sPXvo4mHp70A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [172.16.127.102] ([141.76.8.166]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MXp5a-1vloqD1niO-00Mgc3; Tue, 28 Oct 2025 14:50:17 +0100 Message-ID: Date: Tue, 28 Oct 2025 14:50:15 +0100 Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 6/6] platform/x86: ayaneo-ec: Add suspend hook To: Antheas Kapenekakis Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Hans de Goede , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , Derek John Clark , =?UTF-8?Q?Joaqu=C3=ADn_Ignacio_Aramend=C3=ADa?= , Jean Delvare , Guenter Roeck References: <20251015084414.1391595-1-lkml@antheas.dev> <20251015084414.1391595-7-lkml@antheas.dev> <63f0221d-4436-4d1e-a933-8b12f392cac6@gmx.de> Content-Language: en-US From: Armin Wolf In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:gT1rqQH9Pc3f6CEkk7zr9rt+saEXpn8tTq+QpO4iPeMt6WUtNqx xvtSH3b1kZAyfk02h2OiKh9qG8U9fuOT2K40TJxaix4A7SZk5o5odHkLtg6wms1Yl8psthU T9DvFgs7GEha7fkHeAAqcbF+wUdjR2h7TLg/egsln66Zvue3fW1RB0954Kd97bfhmMlCYZ7 srj67lpMUx8glERV9+ASA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:6v0LoKwU2KI=;Ex9h5l/qeJ6IERYU/OHA9CbeXBs 61x3K4TGIVlfoqwKFYEL1f0qlITld3zdjbe4eHeXd8Hf4c5Hn8Vj2UItxKvKeIbCQ5n23xaPF NaJMr4TkZJsxubEvplKsH01AcfacOd4uTvn6l/LSTXHEQJ5P7jA+3Prz2h8cEk49iaFqpFc1l 3IQJQrgF6jT3pAfPeyIMyesxt1lvx0U+E9l9blL1RxE5ee809hgj7pGlyytZAdfI9qNdntVcL /KKCnrmUs41x8qSu/1f/blqgzP9X7Jz8p05ZLUXu4QyD+imhupY5Y9ZMIeKusAuJri4e79xpT 3dH1LQX1ABWJJWnWXz6RNsRF5ifeyiXi4tnzBqO5eNi+E8GSGYmQKGq3aGo2ZF8zjGlPq0e+3 lhIafb1ULzLS19ST4YM0hjgBMnX/JagwWvavXndd3tQQM/42E+9BoD9tmwrT/6b3IX9tCeRVI 4DEPzm5S9KzcYeZR9bCrifIhpPIaEllWDX+jxACWLcuF89XkMJ/M300rFN61vTEe1X64Ojmj6 hKgWq81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eAJhQIOQpCCRljtd gatXbBy+wkhTQreD/I1juPMZ3rgGiJgMispmZUV9dhGJaCBdeg++AF+lISty/pGk/y++6Xgbg 3sIHTzQ2Ev6NvXr01yK/GvS/+c92z2gqV4rnfiwtXTYXOerUok4NvwpBqtt8IwU7A+hH4cKrz 24Gs4X3Bis6B/iUdd4sRZvg/wRhtYyUCY2J2I3I9/HAUGMbB8ew3y/0r8RULDnQO5G3iq7uva BgR6tnPZJuWos6ts0DvfevyIB9chiHnv+z+DyEK9lmQagL7Rnu2GyNsHFM7MYXFJijR4zEu4A vfzxbiHEBLZL298i16H5AHJaik= Am 27.10.25 um 00:17 schrieb Antheas Kapenekakis: > On Sun, 26 Oct 2025 at 23:50, Armin Wolf wrote: >> Am 15.10.25 um 10:44 schrieb Antheas Kapenekakis: >> >>> The Ayaneo EC resets after hibernation, losing the charge control state. >>> Add a small PM hook to restore this state on hibernation resume. >>> >>> The fan speed is also lost during hibernation, but since hibernation >>> failures are common with this class of devices, setting a low fan speed >>> when the userspace program controlling the fan will potentially not >>> take over could cause the device to overheat, so it is not restored. >> I am still not happy with potentially breaking fancontrol on this device. >> Most users expect fancontrol to continue working after hibernation, so not >> restoring the fan speed configuration seems risky to me. Would it be enough >> to warn users about his inside the documentation? > This device features two modes of operation: a factory fan curve > managed by the EC and a fixed speed set via override of the EC. > > The factory curve is tuned by the manufacturer to result in safe > operation in all conditions by monitoring the CPU temperature and is > not adjustable. > > The fixed speed, on its own when set manually, is not use-able, > because this device has a fluctuating temperature based on workload. > So to meet the varying conditions, its speed would either have to be > set too high, leading to excess noise, or too low, potentially > overheating. Therefore, users of this interface control it via a > userspace program, e.g., hhd, coolercontrol, which allows creating a > custom fan curve based on measurements of temperature sensors. > > When entering hibernation, the userspace program that controls the fan > speed is frozen, so the fan remains at its previous speed regardless > of temperature readings and there are no safety checks. > > When resuming from hibernation, the EC takes over and monitors the > temperature, so it is safe until the userspace program is thawed. If > we introduce a resume hook, we take over from the EC before the > program is ready, introducing a gap where the device can potentially > overheat. If anything, the freeze hook should remove the fan speed > override instead, because suspend-then-hibernate is more of a > liability for overheating if hibernation hangs. Understandable, how about introducing a module_param_unsafe() for enabling write access to the fan settings? The fan settings would be read-only by default, so no suspend handling would be necessary. Said suspend handling would only be necessary when the user _explicitly_ requests write access to the fan settings. What i am trying to say is that we should either expose a fully working feature (fan control with suspend support) or none at all (fan speed monitoring only). What do you thing about that? Thanks, Armin Wolf > > Other devices feature adjustable EC fan curves (e.g., Lenovo, Asus, > AYN, MSI). Since the EC monitors the temperature there, it is fine to > restore the fan curve. Speaking of, I am having quite a few issues > with MSI Claws, so that series is a bit on the back burner, so I plan > to push these series first. > > I will try to tend to this series in the next days. I wanted to push > the Asus stuff first though. > > > Antheas > >>> Signed-off-by: Antheas Kapenekakis >>> --- >>> drivers/platform/x86/ayaneo-ec.c | 42 ++++++++++++++++++++++++++++++++ >>> 1 file changed, 42 insertions(+) >>> >>> diff --git a/drivers/platform/x86/ayaneo-ec.c b/drivers/platform/x86/ayaneo-ec.c >>> index 73e9dd39c703..8529f6f8dc69 100644 >>> --- a/drivers/platform/x86/ayaneo-ec.c >>> +++ b/drivers/platform/x86/ayaneo-ec.c >>> @@ -37,6 +37,8 @@ >>> #define AYANEO_MODULE_LEFT BIT(0) >>> #define AYANEO_MODULE_RIGHT BIT(1) >>> >>> +#define AYANEO_CACHE_LEN 1 >>> + >>> struct ayaneo_ec_quirk { >>> bool has_fan_control; >>> bool has_charge_control; >>> @@ -47,6 +49,8 @@ struct ayaneo_ec_platform_data { >>> struct platform_device *pdev; >>> struct ayaneo_ec_quirk *quirks; >>> struct acpi_battery_hook battery_hook; >>> + >>> + u8 cache[AYANEO_CACHE_LEN]; >>> }; >>> >>> static const struct ayaneo_ec_quirk quirk_fan = { >>> @@ -464,10 +468,48 @@ static int ayaneo_ec_probe(struct platform_device *pdev) >>> return 0; >>> } >>> >>> +static int ayaneo_freeze(struct device *dev) >>> +{ >>> + struct platform_device *pdev = to_platform_device(dev); >>> + struct ayaneo_ec_platform_data *data = platform_get_drvdata(pdev); >>> + int ret, i = 0; >>> + >>> + if (data->quirks->has_charge_control) { >>> + ret = ec_read(AYANEO_CHARGE_REG, &data->cache[i]); >>> + if (ret) >>> + return ret; >>> + i++; >>> + } >>> + >>> + return 0; >>> +} >>> + >>> +static int ayaneo_thaw(struct device *dev) >>> +{ >>> + struct platform_device *pdev = to_platform_device(dev); >>> + struct ayaneo_ec_platform_data *data = platform_get_drvdata(pdev); >>> + int ret, i = 0; >>> + >>> + if (data->quirks->has_charge_control) { >>> + ret = ec_write(AYANEO_CHARGE_REG, data->cache[i]); >>> + if (ret) >>> + return ret; >>> + i++; >>> + } >>> + >>> + return 0; >>> +} >>> + >>> +static const struct dev_pm_ops ayaneo_pm_ops = { >>> + .freeze = ayaneo_freeze, >>> + .thaw = ayaneo_thaw, >>> +}; >>> + >>> static struct platform_driver ayaneo_platform_driver = { >>> .driver = { >>> .name = "ayaneo-ec", >>> .dev_groups = ayaneo_ec_groups, >>> + .pm = &ayaneo_pm_ops, >> Please use pm_sleep_ptr() here. >> >> Thanks, >> Armin Wolf >> >>> }, >>> .probe = ayaneo_ec_probe, >>> }; >