Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1266847rdh; Mon, 25 Sep 2023 07:52:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFFUJ4K3YJRjL2hNZRn6s+XyCggRG+oSk9LDWd8PVtz/dfuVa59HQyreFNWbY6Zzz6BM22 X-Received: by 2002:a05:6a20:4425:b0:15d:ec88:356e with SMTP id ce37-20020a056a20442500b0015dec88356emr9709275pzb.41.1695653574387; Mon, 25 Sep 2023 07:52:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695653574; cv=none; d=google.com; s=arc-20160816; b=hJPPdVNuR3OtXKcjL6WHm4p7N6B5e1faBT2CLgqM6kBQV1Dt3ZSFa0hqFBAlHZ2khb zCmdWbOxZ2930KwWUIJAxn/wnhB0bpV1BiMK4ppddEOr0ga+WxKtedKbhqsswiBvglQ5 Qi6p7J0/SdcinoSaAcDk8eEynKUUr9jDjqo/5KSTovfXuElXVm+kTwMXhElznrsxjoNo exhLwDGHTWlGa2Wk/pcQbAm9VjHrh+B0wqX2qUob/I6stMUJjFvHPNKLAE3m4BWCiSyM fNA/vG/b9CadhxRmmzS+kzg5CLfZI7Lyvy21L1yQqHMwZaITyVXKMOXlskg1e5nHb5la OOJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=BHtjwLPuNIM982JG8tRGrHl7cHo/0iOH5NWHHo23YQ0=; fh=Yo8BQRXOvHA1DzZPV8FsN5fjFbtiB1/J4PFiW1zk7z4=; b=ELVzPv8seFYCyX6FpJxhvTgt4/CrjIB5FE7otgwZEC3wg7qfYjSCfnxNzdcDNoC/9W lvxTT76we2I1E+9/UjDukEwbstLR5JWn4c2T0mhi3sN6LSY7E/Vxj8vy3De/llbjciFe kSKX0eLWej4IPbWQT3IGBwwTyb8ZaoAsmznBEZbCuuff/McWSb1Gxsi+w/cg6B9f0FV7 Pk7IkXmY272dGz07ECwCtknWwgaUUiHQHzXe2StMoQElH7xHCyZnQq9uzi4CO2m0Porg Ck87fKpZq6OcWJMzU2UiYJD1q5fKEHtx2edtqGVHe4BX0eAEGxBA/bBPTpGPFfYLHJd6 wbMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="kq/BZrKI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id w14-20020a63474e000000b00578e98dec9dsi10228515pgk.160.2023.09.25.07.52.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 07:52:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="kq/BZrKI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id CD167804C1BE; Mon, 25 Sep 2023 03:19:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229705AbjIYKTa (ORCPT + 99 others); Mon, 25 Sep 2023 06:19:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbjIYKT3 (ORCPT ); Mon, 25 Sep 2023 06:19:29 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B1C3A3 for ; Mon, 25 Sep 2023 03:19:22 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-405505b07dfso22396145e9.0 for ; Mon, 25 Sep 2023 03:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695637160; x=1696241960; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=BHtjwLPuNIM982JG8tRGrHl7cHo/0iOH5NWHHo23YQ0=; b=kq/BZrKIniVcrT/riHVdGvJKkbh0cmY0CBflhmr6xg20tqNTd7ktEbnrV16ctca1ZR KnTLjjb2XYwss6REge+2CS0d0fz5nKLd8uQQcWdGlGf6uX6QOYWbiPCfccLAbu08T+U9 2oHEVQ9vk72FOfpo6/TWws9TFVcCnjMuL8xAV8mkMegLU5zKsa6Mqd1Rq51zuoKNYt3h DlpGAxC19mopX8TzfW08oLyDHfY/NOJ4HUmtQSwl5YB7vo2H+zC5t50uRTvzVv7szkCm 5elcVOPQx/hP3gR3zQ0ejcoJ+H9O6jqASaocar98TuXMuSSGkET/OMcTN55s2MLU+lF0 9UzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695637160; x=1696241960; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BHtjwLPuNIM982JG8tRGrHl7cHo/0iOH5NWHHo23YQ0=; b=NKCGozjVLHkfvxkCSLwRqW8Ues/tALYsjEJ9rLo9RIx+u7EKD+VFsp+HZyneimrq/l L8el/KRdnecLdr/qEc66K9TKsNgeVBlM6E9e2uXZtN4V1RJDwMCW/sJ4GM3BfBJvfkPF GKIMhAsQUN+gEFdy/BXPE6gCMNIXO9RYaCrF+TtiPwc9TLEoefnUE0Jsl/27FYPKzADs mJWWuFD9yuibJ7rTdh0Cfl1UHqnxmRSCCg+KeYkHw0JYCfaEJPaDXPZgx8uvkrp14lfO yGoKvBrPStadyNJterbF1iYhbhjxcxYs0ul+C5B+3muHQ7Bu/UtdDupoHtszf1zVqIQH J5YA== X-Gm-Message-State: AOJu0YwEqkmg9XSIOaZI/hvWdP47YC2LdRr06VkYozM+DU0ByGa+FSUN x1Mi7aTYS0PCk+zwDeAncKzel/Henqh6pGxZ5zQ= X-Received: by 2002:a1c:6a1a:0:b0:403:c70b:b688 with SMTP id f26-20020a1c6a1a000000b00403c70bb688mr5207596wmc.6.1695637160370; Mon, 25 Sep 2023 03:19:20 -0700 (PDT) Received: from ?IPV6:2a05:6e02:1041:c10:c0e1:63ab:648b:6287? ([2a05:6e02:1041:c10:c0e1:63ab:648b:6287]) by smtp.googlemail.com with ESMTPSA id v20-20020a05600c215400b00401b242e2e6sm9199319wml.47.2023.09.25.03.19.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Sep 2023 03:19:19 -0700 (PDT) Message-ID: <7558dd96-0d96-9463-9a97-7ea8bac2046e@linaro.org> Date: Mon, 25 Sep 2023 12:19:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] thermal: core: Check correct temperature for thermal trip notification Content-Language: en-US To: =?UTF-8?B?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , "Rafael J . Wysocki" Cc: kernel@collabora.com, AngeloGioacchino Del Regno , Amit Kucheria , Zhang Rui , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org References: <20230922192724.295129-1-nfraprado@collabora.com> From: Daniel Lezcano In-Reply-To: <20230922192724.295129-1-nfraprado@collabora.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 25 Sep 2023 03:19:31 -0700 (PDT) Hi Nicolas, On 22/09/2023 21:27, Nícolas F. R. A. Prado wrote: > The thermal trip down notification should be triggered when the > temperature goes below the trip temperature minus the hysteresis. But > while the temperature is correctly checked against that, the last > temperature is instead compared against the trip point temperature. The > end result is that the notification won't always be triggered, only when > the temperature happens to drop quick enough so that the last > temperature was still above the trip point temperature. > > Fix the incorrect check. > > Fixes: 55cdf0a283b8 ("thermal: core: Add notifications call in the framework") > Signed-off-by: Nícolas F. R. A. Prado > > --- > > drivers/thermal/thermal_core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c > index 58533ea75cd9..120fcf23b8e5 100644 > --- a/drivers/thermal/thermal_core.c > +++ b/drivers/thermal/thermal_core.c > @@ -361,7 +361,7 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip_id) > tz->temperature >= trip.temperature) > thermal_notify_tz_trip_up(tz->id, trip_id, > tz->temperature); > - if (tz->last_temperature >= trip.temperature && > + if (tz->last_temperature >= (trip.temperature - trip.hysteresis) && > tz->temperature < (trip.temperature - trip.hysteresis)) > thermal_notify_tz_trip_down(tz->id, trip_id, > tz->temperature); We already did a try to fix the thermal trip cross notification but this is not sufficient for a full fix. We are receiving multiple notifications from the same event, all this due to the hysteresis. Let's say, we have a trip point T and a hysteresis H. There is a trip point crossed the way up when: last_temperature < T and temperature >= T At this point, we send a notification Now, the temperature decreases but it stays in the hysteresis: last_temperature >= T and temperature > (T - H) And then, the temperature increases again and is greater than T. last_temperature > (T - H) and temperature >= T We send a second notification. With the mitigation kicking in at temp >= T, we end up with multiple events 'temperature crossed the trip point the way up"'. That forces the receiver of the events to detect duplicate events in order to ignore them. More info: https://lore.kernel.org/all/20220718145038.1114379-4-daniel.lezcano@linaro.org/ We have done a lot of cleanups to use the 'generic trip points' and remove those get_trip_* ops. So the trip point structure is a core component being reused by the drivers and registered as an array. Next step is to make sure the trip points are ordered in the array, so we can implement the correct trip point crossing detection. -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog