Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp21320925rwd; Thu, 29 Jun 2023 14:23:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ51FSG6GIg4ASennMZC/56g/1jumw//2UeTaWWyw50ve7Sew0Ohh2ctw2q7/lLWHEMb4mJh X-Received: by 2002:aca:2b04:0:b0:3a1:ef57:5959 with SMTP id i4-20020aca2b04000000b003a1ef575959mr510010oik.45.1688073818202; Thu, 29 Jun 2023 14:23:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688073818; cv=none; d=google.com; s=arc-20160816; b=cC/IjDxgl6c/rNnFzCOmpqFSk2errSCEcDfch8f7DxxZt90ONXgJXNzRpvqVhVhbbF EaeyoSTNoYOofFXAQ7Qg+oVgwCgabTbwZbh+NHV+OcVMeF3MEZDylxFhfitalt13V2W6 I1V20PJpVv8azAbIhsBokjGUFtKLXU28ZxPU3x3k5l0MHi4irzLmuA7wd2Gv9fXBuhtb PNM+hGUhwr9gxZRb3Vu9nldrS8SxdX11avakwQlcjf+NXrRoGiUuAUuKZwvfdP1s3hdr UiC1QElgXM5+Z/lhRcVccvXWklapu4sG5BfVEHTDWrDD0l9z74IaiEqSp7yM8Ko/1BZ+ n6Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ciuF2i24mdJZzXK1MpnULzZ5uIH5tKK1goU1NOO22mQ=; fh=WFyc1SVORq7HFZ8on4Q1E++zIpFTRbW7JtLPPWlNQfQ=; b=HPCpQ3Q7AGxvhYjFxmJ2cKVx9ginkZg8uj3ZItQbJHcsPd85t4Inc7kMQUEYXn4KQ8 3Tg1fNxsH/FutnO35WJCCDiucRn2pCxruF2dO4p+WZ45HBZGBZ6N6+8sU+6+xlm3lo1V KzJ5e09F9a9q3s/nWP5FjVmE9n+oc5LIqdcyxqn3DBmsb69liDhkvU02rQMFfTWCGlH8 zY9kOi8VwlvY4GtIOzveOS6f2NPZefMEga0dXeIhTJ+E3rICodRhCi06krYLtxOjH5fs Tr3wlpIt9YUWxGcjgHJlWdtBMHOjygUF7Rq2/Tg+VgMmte0tlrbWNMmQkMR/NFXOxX4P Rzug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=awtycltu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o21-20020a635d55000000b00557807d78e2si10826505pgm.555.2023.06.29.14.23.23; Thu, 29 Jun 2023 14:23:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=awtycltu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231766AbjF2VKy (ORCPT + 99 others); Thu, 29 Jun 2023 17:10:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231497AbjF2VKp (ORCPT ); Thu, 29 Jun 2023 17:10:45 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F00202D4C; Thu, 29 Jun 2023 14:10:43 -0700 (PDT) Received: from notapiano (zone.collabora.co.uk [167.235.23.81]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nfraprado) by madras.collabora.co.uk (Postfix) with ESMTPSA id CBDD066070D1; Thu, 29 Jun 2023 22:10:38 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1688073041; bh=JCh8QNgbheBN9vzum2hXOH+Xccw6yemZ2xjeKair+aY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=awtycltug4rEIpIWPHSmCJ0Ar7z77OoWwDGCry2DH+yxVYb/zvGXFn4MY6+0VYWHz KsjdF6RlG839AVnwTUXG5EhlfY57qurBilxeD4c48tgwS66/uibtEDaER8NzfwVG5S JHXvf7vP2vcIQKryhP7Nc2aPRt+dbb+oXgMTCIsXDUC66CsEfWU9LrVu+nJyGWIw83 BSZf9ksQr+YcWLUt9cu1rx4wlaf479EvT0yP1Jab0CD+ftjnz/ZU+t4SXMd1MUetTU H2jTI5x4AB+Dy+grt0C/nvXBZA132sNpsVnx645CtNY3W9M2+wrzL+iw7ra+tbJehg JGugr9zpCYcOQ== Date: Thu, 29 Jun 2023 17:10:34 -0400 From: =?utf-8?B?TsOtY29sYXMgRi4gUi4gQS4=?= Prado To: Daniel Lezcano Cc: kernel@collabora.com, Alexandre Mergnat , Balsam CHIHI , Chen-Yu Tsai , Alexandre Bailon , AngeloGioacchino Del Regno , Amit Kucheria , Matthias Brugger , "Rafael J. Wysocki" , Zhang Rui , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org Subject: Re: [PATCH v2 5/6] thermal/drivers/mediatek/lvts_thermal: Don't leave threshold zeroed Message-ID: <819b9c10-044c-4a2b-b8f2-6ddd633bbf8d@notapiano> References: <20230504004852.627049-1-nfraprado@collabora.com> <20230504004852.627049-6-nfraprado@collabora.com> <5d810151-3a3b-51af-bbc1-0ee45668bcc4@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5d810151-3a3b-51af-bbc1-0ee45668bcc4@linaro.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Fri, Jun 02, 2023 at 11:17:27AM +0200, Daniel Lezcano wrote: > On 04/05/2023 02:48, N?colas F. R. A. Prado wrote: > > The thermal framework might leave the low threshold unset if there > > aren't any lower trip points. This leaves the register zeroed, which > > translates to a very high temperature for the low threshold. The > > interrupt for this threshold is then immediately triggered, and the > > state machine gets stuck, preventing any other temperature monitoring > > interrupts to ever trigger. > > > > (The same happens by not setting the Cold or Hot to Normal thresholds > > when using those) > > > > Set the unused threshold to a valid low value. This value was chosen so > > that for any valid golden temperature read from the efuse, when the > > value is converted to raw and back again to milliCelsius, the result > > doesn't underflow. > > > > Fixes: f5f633b18234 ("thermal/drivers/mediatek: Add the Low Voltage Thermal Sensor driver") > > Signed-off-by: N?colas F. R. A. Prado > > > > --- > > > > Changes in v2: > > - Added this commit > > > > drivers/thermal/mediatek/lvts_thermal.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c > > index efd1e938e1c2..951a4cb75ef6 100644 > > --- a/drivers/thermal/mediatek/lvts_thermal.c > > +++ b/drivers/thermal/mediatek/lvts_thermal.c > > @@ -82,6 +82,8 @@ > > #define LVTS_HW_SHUTDOWN_MT8195 105000 > > #define LVTS_HW_SHUTDOWN_MT8192 105000 > > +#define LVTS_MINIUM_THRESHOLD 20000 > > MINIMUM > > So if the thermal zone reaches 20?C, the interrupt fires, the set_trips sets > again 20?C but the interrupt won't fire until the temperature goes above > 20?C and then crosses the temperature low threshold the way down again? Well, actually, set_trips won't even be called since from the thermal framework's perspective we haven't crossed trip points, ie in __thermal_zone_set_trips(): /* No need to change trip points */ if (tz->prev_low_trip == low && tz->prev_high_trip == high) return; But in any case, yes, the interrupt will fire, the temperature will get updated in the framework, and that's it. It will only fire again when a threshold is crossed again (either by the temperature rising and falling again below this minimum, or rising beyond the high treshold). So basically at most this will cause a spurious interrupt when the temperature gets low enough. I do get 34-36C on all sensors when idling though, so I doubt that temperature is even reachable. Besides, we don't really have another option here if we want working interrupts, the threshold needs to be set to a valid value, and this is the lowest I've found. And thanks for all the feedback! I'll prepare a v3 based on your comments. Thanks, N?colas