From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.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 7BBE716C86C for ; Mon, 1 Jul 2024 15:13:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719846833; cv=none; b=ZrS3cemD83GVJb/+r4nZEn9lzr92Njzm+tM8Psb5GFiDeg7+RAmNnoM0WkHRalKSjj0OnSiCIVHBf7P8vtWvvZx4zyl8ICqrFL+2VDZsf3AWloOq+eBfL4ah06NiF08AGUj2VDAXAlyPj7ZQsBPsbnNHoCWquFTC7NjhfGhrbJY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719846833; c=relaxed/simple; bh=8XOLp81OzlTJJHbaW9uPIcZnR43qb3BjCtlX+MMfPp4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=dGw8hJkl6GtLwvEObEPt1/9tNS7bZYV6/968c10r3DFCyTJp1fBGoyVc7GXwACx3aTgMENOszIKsoQJo537mSzgUv8hnyL2QU6CUL8GBQGkg1eBcLFslXbujMTNaszN2cCMbDkxDHWMqQXrNTMG3dd75c3yKJVWmpa2MwZ+R790= 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=xvnNdvzZ; arc=none smtp.client-ip=209.85.221.45 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="xvnNdvzZ" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3676447928bso1801702f8f.0 for ; Mon, 01 Jul 2024 08:13:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719846829; x=1720451629; 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=UzPODOkiRF+Ul7AAMGg53DSYXK0WfpNzUmVPE/Vi3NU=; b=xvnNdvzZ1brqwjI5SbjG8Ee2sSTO3TjZ59oyGyDuLg1lyy1dLvNxv7f4AgSsGEKUXH DZ9C+t9MFaSPFe07YAWNy3rqTvFUu+pNW4fZ3XtLMj9HCxoZbRQo4suDLFaXpNSwu/yg +LHrsozqYv/Z0qD7a+gXnVQD/m65SKNr3uW8oLsnMJlO7jZDWmRWf1nBTVQ33QGPRikD tu+3ZUbDCZoE56RvnnRrqqsyZBsOzB3bOCpEAM4wMHUI1UeFso4Ox0ElHMTeF1ijQwST 8/y24B50RYRpKQH0BQDovrlicF2D2J2ux2mr4rUwg5AMnlnFZZ1LXlcXMKRcXebva5vr oQHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719846829; x=1720451629; 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=UzPODOkiRF+Ul7AAMGg53DSYXK0WfpNzUmVPE/Vi3NU=; b=QVJeCPeOq5rL+kQXbbi5jSEfdA+OP+m0qNmLqK06R05ej0474l/Vc1rTUeXriNaShJ MAzecNtaloMd2lYb9QwzKpCq1IHarPGUyVzYiqnH5/QRWvB/AoL9IxHalBwQ3kSha8ZK s8zQ+qacJWiiEOqgYzJKLckqCpRQhsl/PS2YUdymjRVK+F9FZ6Cdis1joojVlAxcySxg PKOU00Km+NNCwXhyvnBQeA5bq4lltrAKNnvNe1oGXvpsmiMuggSRYSaD5k5cLfGUgGTu NkztOsvtGoCWuM47CS4oOYHSjzf6d56YtyV78I8JpGeoszk+3Cj2/TUb0L8bc/8/gZlM UuPQ== X-Forwarded-Encrypted: i=1; AJvYcCX4Ox+h7AKmiKXmRXbWb5XSNHLXXCsR86z6+AZdA78sgI8TNZHyXzVZwTW89FazKsQRNQiFTOKHjxP0oU+nslh6a2zz23SZqt8uaQib X-Gm-Message-State: AOJu0YxaSsc4MaepnIvehcaZyeEHI+TmJa6Mo7snkuF8gsyNEsw0T+bY ymQfrJBqLKpT9igekCyAGxrn83gTkSV/3iaCjR0LVRkKqmGPyJgdxRlWf/9ZE0qi9xrY3NDCcnZ U X-Google-Smtp-Source: AGHT+IEsfAsS6Jxp21mX/YsiTZnspNYFLFuMLgII2hZwYP9owd+AsAgpuZ/N9pdlEdXMkZ38EzJ5Jw== X-Received: by 2002:adf:f48e:0:b0:360:8537:ce27 with SMTP id ffacd0b85a97d-367756e5165mr4212418f8f.42.1719846828847; Mon, 01 Jul 2024 08:13:48 -0700 (PDT) Received: from ?IPV6:2a05:6e02:1041:c10:d5d7:31af:53ed:6dbc? ([2a05:6e02:1041:c10:d5d7:31af:53ed:6dbc]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3675a1030dfsm10272616f8f.100.2024.07.01.08.13.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Jul 2024 08:13:48 -0700 (PDT) Message-ID: <9c2971dd-2f2d-426f-9107-eae93d5dd554@linaro.org> Date: Mon, 1 Jul 2024 17:13:47 +0200 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: [PATCH] thermal/core: Introduce user trip points To: "Rafael J. Wysocki" Cc: linux-pm@vger.kernel.org, Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , open list References: <20240627085451.3813989-1-daniel.lezcano@linaro.org> Content-Language: en-US From: Daniel Lezcano In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 28/06/2024 15:56, Rafael J. Wysocki wrote: > On Thu, Jun 27, 2024 at 10:55 AM Daniel Lezcano > wrote: >> >> Currently the thermal framework has 4 trip point types: >> >> - active : basically for fans (or anything requiring energy to cool >> down) >> >> - passive : a performance limiter >> >> - hot : for a last action before reaching critical >> >> - critical : a without return threshold leading to a system shutdown >> >> A thermal zone monitors the temperature regarding these trip >> points. The old way to do that is actively polling the temperature >> which is very bad for embedded systems, especially mobile and it is >> even worse today as we can have more than fifty thermal zones. The >> modern way is to rely on the driver to send an interrupt when the trip >> points are crossed, so the system can sleep while the temperature >> monitoring is offloaded to a dedicated hardware. >> >> However, the thermal aspect is also managed from userspace to protect >> the user, especially tracking down the skin temperature sensor. The >> logic is more complex than what we found in the kernel because it >> needs multiple sources indicating the thermal situation of the entire >> system. >> >> For this reason it needs to setup trip points at different levels in >> order to get informed about what is going on with some thermal zones >> when running some specific application. >> >> For instance, the skin temperature must be limited to 43°C on a long >> run but can go to 48°C for 10 minutes, or 60°C for 1 minute. >> >> The thermal engine must then rely on trip points to monitor those >> temperatures. Unfortunately, today there is only 'active' and >> 'passive' trip points which has a specific meaning for the kernel, not >> the userspace. That leads to hacks in different platforms for mobile >> and embedded systems where 'active' trip points are used to send >> notification to the userspace. This is obviously not right because >> these trip are handled by the kernel. >> >> This patch introduces the 'user' trip point type where its semantic is >> simple: do nothing at the kernel level, just send a notification to >> the user space. >> >> Signed-off-by: Daniel Lezcano >> --- >> .../devicetree/bindings/thermal/thermal-zones.yaml | 1 + >> drivers/thermal/thermal_core.c | 8 ++++++++ >> drivers/thermal/thermal_of.c | 1 + >> drivers/thermal/thermal_trace.h | 4 +++- >> drivers/thermal/thermal_trip.c | 1 + >> include/uapi/linux/thermal.h | 1 + >> 6 files changed, 15 insertions(+), 1 deletion(-) >> >> diff --git a/Documentation/devicetree/bindings/thermal/thermal-zones.yaml b/Documentation/devicetree/bindings/thermal/thermal-zones.yaml >> index 68398e7e8655..cb9ea54a192e 100644 >> --- a/Documentation/devicetree/bindings/thermal/thermal-zones.yaml >> +++ b/Documentation/devicetree/bindings/thermal/thermal-zones.yaml >> @@ -153,6 +153,7 @@ patternProperties: >> type: >> $ref: /schemas/types.yaml#/definitions/string >> enum: >> + - user # enable user notification >> - active # enable active cooling e.g. fans >> - passive # enable passive cooling e.g. throttling cpu >> - hot # send notification to driver >> diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c >> index 2aa04c46a425..506f880d9aa9 100644 >> --- a/drivers/thermal/thermal_core.c >> +++ b/drivers/thermal/thermal_core.c >> @@ -734,6 +734,14 @@ int thermal_bind_cdev_to_trip(struct thermal_zone_device *tz, >> if (tz != pos1 || cdev != pos2) >> return -EINVAL; >> >> + /* >> + * It is not allowed to bind a cooling device with a trip >> + * point user type because no mitigation should happen from >> + * the kernel with these trip points >> + */ >> + if (trip->type == THERMAL_TRIP_USER) >> + return -EINVAL; > > Maybe print a debug message when bailing out here? After thinking a bit about the message, it sounds to me that is a really an error in the firmware if we end up binding an 'user' trip point. What about the following message: dev_err(tz->device, "Trying to bind the cooling device '%s' with an 'user' trip point id=%d", cdev->type, trip->id); -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog