From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.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 EC0C113B2B8 for ; Thu, 9 Jan 2025 21:36:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736458572; cv=none; b=C4ZEa3Z1GyBgSiQ08/EWftvkvjja5109OIrRyhGDfRp55kVKQuyhqw6yxkhmN5dveJTJEWCgg0Zq5GwxuRkXRHZ66NqzrVHHMvoCkYMSwTLXQEr/SG9noyGyPJuIo0i60fcE9tbi8m41L5/Vs1FrT1EWmn+3ye/9hper57K0k1M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736458572; c=relaxed/simple; bh=nbxjV6qH6DUpf33ktiDfaWFETdM3EiHJyKTeJVx0V54=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=oOaItekBQnUIYVjH5xg0ACCdQ/ca0kD0JzeG+0KA5jyZcsroWnGyVrY6pnMYfRkewU9JLh/nYWf37/0JX18vP2vH66MSFq1Vwbs3sE2WnvnekAmiu4i39ySc08edJr4PJXcKfX48qFYOMVUNr7u141h9kXnuS1XEbHL2fpbh3Bs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=qXAqpExJ; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qXAqpExJ" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4362bae4d7dso10910815e9.1 for ; Thu, 09 Jan 2025 13:36:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736458569; x=1737063369; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=+9HPQZCVUAnZ7shlzpjc+vwRiCC2uUgOzI+dVfgh5t0=; b=qXAqpExJbMxlHiQiayDWaVGxG6w3ALvCr+w65mAIMPqeM5pOeQ3WtmN7pb7fy8ucL0 OnLMUSK5sW1ZxT2cF9og3ZIIn+Xt3tFFHWd4nkl0jYsQw2cY6V2m3GBL89pQZtT1as4K q8Ehdtc2KSgvTHGpLBS8AtUIaULFmpl/wwCrgtHItjhNzVlt/yDhJtltDg7qYWGucRuE +tzb54JIN4QowCcTEV0HuSb1ZGbihh1el4AvhJFycgt2bSF8Fgv/vTEIx0W6RjpkQAnm aumxc3UOx9fhr263SspdGLzoy2swZtWblV5jmWphmu8k8396PAIg7ec+bAKZNlHpZJbz 76JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736458569; x=1737063369; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+9HPQZCVUAnZ7shlzpjc+vwRiCC2uUgOzI+dVfgh5t0=; b=h2IzoEOXOdoTQuDwn4h/ACCGe0xlwEoh6nbiNVVkEWK7BraqD7wLMV5oOKcC/8BOTz t9haItjYd0Y/TtefTjTH45gwKDN1NotShF2t4Qv60b7qAJz12pe3ndbsCRy2HD5uAzi+ e0OI/AyZ3FFclqUZpctESWqgFHi5FxMozgZvaPFxU8Yz839GNzRLo07tv8KM/kjdefDn 3Y0KkE6sk84t7nFvxmx7IDzgd6glFpqrCc0NB28/gcwUd6hApJX0WEJxAbCYkyNBoQ44 VXgxS6gcgafrHzTXcL5hGJxZ2JvcPvYsPixBz5U+/nGRESFVGpbxrcz4wc9Wq+PcK7kW Es8g== X-Forwarded-Encrypted: i=1; AJvYcCU86EMJW+kTtMcrc/nETYpxlRivM16qy7NavmB1NuThVhDq/fuiSAQ6bwJOSfp/D4t9XQKcAeZgcqxoK4M=@vger.kernel.org X-Gm-Message-State: AOJu0Yzqle+9VPQ7tpXviVMM4H6Qw80U0wLj0ZRSNrzZe2aOQMyvFYGM nkN0haMq4An0GpuEtbXo6kIuXuPq0iLcZoexBWDF6SpTngUw7/jcj/W+srX2iIU= X-Gm-Gg: ASbGncum9blWpAJJSLH/eS+NGpOiLZ2wLhEUrFrhMhf8ujbcM5C+izFQxSqXFGA2BG5 8lVD8bhc87TMz7vMpefqwbwsz2zdPK84zwrG6GT9+uyzyTyvC5Bd/ow3fkb0qZz0uZsqeE0raFG EKY8mpEYNXKcbq+yAH7P1sxqyGbEu7G1CxI4/4hMfFMJKz61IzuaPS0hL0/wy8XGPTu5ygM0E8F Bc8/Ea+DH514+4dPlpLwr7N+Xc/Ov/nlSM+Vbk6uZE9mwHGVMYDyKV76J0VqiSW3XhefJfdGmaS J7rfdFXjZsteD6TYSyit X-Google-Smtp-Source: AGHT+IHX1eZQUCDD13aWYdJo9a1TwhTHPCfOsRihU3pob2ooEDoyXQhIkgJP+CnttpbBtjp0u3RDiQ== X-Received: by 2002:a05:600c:4e92:b0:434:fdbc:5ce5 with SMTP id 5b1f17b1804b1-436e2707f4amr75406735e9.29.1736458569346; Thu, 09 Jan 2025 13:36:09 -0800 (PST) Received: from [192.168.10.46] (146725694.box.freepro.com. [130.180.211.218]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-38a8e38ef6asm2845178f8f.60.2025.01.09.13.36.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Jan 2025 13:36:08 -0800 (PST) Message-ID: <6ed0eb0c-c31b-41b0-93ca-c6581249c7b7@linaro.org> Date: Thu, 9 Jan 2025 22:36:07 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Thermal driver with safeguards To: Werner Sembach , "linux-acpi@vger.kernel.org" , "Rafael J . Wysocki" Cc: rui.zhang@intel.com, Hans de Goede , Armin Wolf , =?UTF-8?Q?Ilpo_J=C3=A4rvinen?= , "linux-kernel@vger.kernel.org" , platform-driver-x86@vger.kernel.org References: <41483e2b-361b-4b84-88a7-24fc1eaae745@tuxedocomputers.com> Content-Language: en-US From: Daniel Lezcano In-Reply-To: <41483e2b-361b-4b84-88a7-24fc1eaae745@tuxedocomputers.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 02/12/2024 15:52, Werner Sembach wrote: > Hi, > > given a pair of a temperature sensor and a fan, I want to implement a > driver. that allows userspace to directly control the fan if it wants > to. But have a minimum fan speed when certain high temperatures are > reached to avoid crashes or hardware damage. From the userspace, use directly the thermal-engine which is currently under development [1]. You can add your platform specific code in a plugin while the thermal engine will catch all the thermal events and pass them to it [2]. The thermal engine has a configuration file which will setup the thermal framework to be woken up at different temperatures. The thermal engine will be proposed for a distro package, so the platform support will be automatically supported. Beside the trip points can be setup in the device to act on higher temperature. What is unclear is how the fan is managed. I suggest to have a look at pwm-fan.c in drivers/hwmon > e.g. > > - temperature of target die is 80°C -> fan speed must be at least 30% > > - temperature of target die is 90°C -> fan speed must be at least 40% > > - temperature of target die is 105°C -> fan speed must be 100% > > - temperature of target die is 110°C -> device shuts off to protect the > hardware > > Would the thermal subsystem be the right place for this to implement > this protection in driver? > > It already has functions around periodic temperature polling and trip > points. [1] https://github.com/Linaro/libpm/tree/master [2] https://github.com/Linaro/libpm/blob/master/thermal-engine/plugins/te-plugin-example-game.c -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog