Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2086127rdf; Mon, 6 Nov 2023 04:32:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHLBZDRbPoFKdZzVM9jCoXeJRACx50ADbWc/wbP+BaHB7GH7DyqMhcobnHWok7r+h6uPabe X-Received: by 2002:a05:6359:600c:b0:168:e78c:e3a7 with SMTP id rw12-20020a056359600c00b00168e78ce3a7mr14170773rwb.18.1699273930712; Mon, 06 Nov 2023 04:32:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699273930; cv=none; d=google.com; s=arc-20160816; b=BMsjQgEiZWgEkWheCN+RZS9DWbV2jsr6xdO9YguomZuYVgsc+UUkD8dCLMoeLI6O/5 YenOyRGKtvYC7syTWVrtwRQ14tErjmEbrniJk/ci7Uem+1orsMEcZtzKLjf+LJ7cybPk J89rWAY+/yhnsPu333kM45+JX7xpAaW6mdnwCGAkGXkjA7auiUuVCkDkiZ1mxk8gTrd0 TPAtMRLFgeA8xy6d5uQXeDIbsSxDvPYp5nTaNTHRzenOUIBh+Bg0ZwHP6RIspa3oxyog N/MvAp4SpAkdzczaV1yQFZn+ykcgtDUy6PIY+72fzuDFULJV1qKGq6Y7/3ZfyNmx10QU c9aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=qadQhVXhylyBcz2dR6JBm7NKudiALHHXyHBhpZfpPuQ=; fh=satdYwRR85z0axSaI9xV11TYjNPLDEovk7u+3zJQvuk=; b=cDHcJDhR0b1hChO7QrPYzvthDrRQl6xah/WyGpsfsUAtlvN9E0r9k4SbPsu2VbPJDq oRYz7TtxKlfE6dM+Tz7YhhRuaqopEbYgs7WDzd3Edj4b3P8jzkpELdCaTsSwTbRDM5Gf tVl2YUSE4pxE0CAloC428F132Xk09hxBWHKVLhd6iCxzmewjsIsUWe/WJkiL7m6T43KG QpU8iPyDLy5//5AkDoyQDLu2IlxrXjUh68+xdb9RiwMV4Dc/lMYMlUj+/KqjW/4vlcvd t+JEpGX58G3hDralQYN9Zul97Xbi8eRrnajLE8mn8YmR7W9VbH31SldpHldpsUAzW+VP 35yQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l196-20020a633ecd000000b005acf0458523si7537387pga.612.2023.11.06.04.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 04:32:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 3D6C1805F9CB; Mon, 6 Nov 2023 04:32:09 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231626AbjKFMcE convert rfc822-to-8bit (ORCPT + 99 others); Mon, 6 Nov 2023 07:32:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231594AbjKFMcD (ORCPT ); Mon, 6 Nov 2023 07:32:03 -0500 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D1C8A6; Mon, 6 Nov 2023 04:32:00 -0800 (PST) Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-6d3099818c0so844715a34.1; Mon, 06 Nov 2023 04:32:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699273920; x=1699878720; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7CLVxleqpC3jykHoWGx0Ji2wnYrlU1c1ECpgQ5J60lY=; b=SlE0L7/5utAhSVPh5TTvmmhNce6lbAo5O+ObBHZ2ES1F3kgjDMZnjwV+AErtHYwiAs ST7jKDJj7zw8s8WH4xJi8yNXM2sHBDdBgxLre8NMSRZdo6ZB+CFD4vc+A0mll+jRACl0 1vmXLAj5nfCJG+hO6blws3PpTnVa1hl7vRZGLYmzTBrp5LHfJrjTH4zMTUbPeRAuSfFH jjFv4TG3e62C1LuoAQjrdjIjalnM6UREjl8NDuCN047wSWar5ZprOcGvzAPU5E0qDlNt LJulLZcMMMUFKyUvsbsDiLiGX++occLjv5tPjU4tfOlY3tZ2Sc6r5XqtWxJ0HwINxD9g QAng== X-Gm-Message-State: AOJu0YxMY1xfrNu+TvEaCmUKxIT5AhjhVDwkFn8QlyhZkaDzBYrl+GsS GLHriOebtcSOiqJ5iv1eNn6IxncB1qPDyWhlU98= X-Received: by 2002:a05:6820:1899:b0:581:e7b8:dd77 with SMTP id bm25-20020a056820189900b00581e7b8dd77mr33128497oob.1.1699273919708; Mon, 06 Nov 2023 04:31:59 -0800 (PST) MIME-Version: 1.0 References: <12317335.O9o76ZdvQC@kreacher> <283d4abe-885b-415d-a24d-681408a23845@linaro.org> In-Reply-To: <283d4abe-885b-415d-a24d-681408a23845@linaro.org> From: "Rafael J. Wysocki" Date: Mon, 6 Nov 2023 13:31:41 +0100 Message-ID: Subject: Re: [PATCH v2] thermal: core: Add trip thresholds for trip crossing detection To: Daniel Lezcano Cc: "Rafael J. Wysocki" , Linux PM , LKML , "Rafael J. Wysocki" , Zhang Rui , Srinivas Pandruvada , Lukasz Luba Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Mon, 06 Nov 2023 04:32:09 -0800 (PST) Hi Daniel, On Mon, Nov 6, 2023 at 1:02 AM Daniel Lezcano wrote: > > > Hi Rafael, > > > On 03/11/2023 15:56, Rafael J. Wysocki wrote: > > From: Rafael J. Wysocki > > > > The trip crossing detection in handle_thermal_trip() does not work > > correctly in the cases when a trip point is crossed on the way up and > > then the zone temperature stays above its low temperature (that is, its > > temperature decreased by its hysteresis). The trip temperature may > > be passed by the zone temperature subsequently in that case, even > > multiple times, but that does not count as the trip crossing as long as > > the zone temperature does not fall below the trip's low temperature or, > > in other words, until the trip is crossed on the way down. > > > > |-----------low--------high------------| > > |<--------->| > > | hyst | > > | | > > | -|--> crossed on the way up > > | > > <---|-- crossed on the way down > > > > However, handle_thermal_trip() will invoke thermal_notify_tz_trip_up() > > every time the trip temperature is passed by the zone temperature on > > the way up regardless of whether or not the trip has been crossed on > > the way down yet. Moreover, it will not call thermal_notify_tz_trip_down() > > if the last zone temperature was between the trip's temperature and its > > low temperature, so some "trip crossed on the way down" events may not > > be reported. > > > > To address this issue, introduce trip thresholds equal to either the > > temperature of the given trip, or its low temperature, such that if > > the trip's threshold is passed by the zone temperature on the way up, > > its value will be set to the trip's low temperature and > > thermal_notify_tz_trip_up() will be called, and if the trip's threshold > > is passed by the zone temperature on the way down, its value will be set > > to the trip's temperature (high) and thermal_notify_tz_trip_down() will > > be called. Accordingly, if the threshold is passed on the way up, it > > cannot be passed on the way up again until its passed on the way down > > and if it is passed on the way down, it cannot be passed on the way down > > again until it is passed on the way up which guarantees correct > > triggering of trip crossing notifications. > > > > If the last temperature of the zone is invalid, the trip's threshold > > will be set depending of the zone's current temperature: If that > > temperature is above the trip's temperature, its threshold will be > > set to its low temperature or otherwise its threshold will be set to > > its (high) temperature. Because the zone temperature is initially > > set to invalid and tz->last_temperature is only updated by > > update_temperature(), this is sufficient to set the correct initial > > threshold values for all trips. > > > > Link: https://lore.kernel.org/all/20220718145038.1114379-4-daniel.lezcano@linaro.org > > Signed-off-by: Rafael J. Wysocki > > --- > > > > v1 (RFC) -> v2: Add missing description of a new struct thermal_trip field. > > > > And because no comments have been sent for a week, this is not an RFC > > any more. > > Can you give me a few days to review this patch and test it with some > debugfs code planned to be submitted? Sure, I'm not going to do anything with it until 6.7-rc1 is out anyway. Thanks!