From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE496C43334 for ; Tue, 12 Jul 2022 12:40:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232599AbiGLMkl (ORCPT ); Tue, 12 Jul 2022 08:40:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbiGLMki (ORCPT ); Tue, 12 Jul 2022 08:40:38 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CCEE653D11; Tue, 12 Jul 2022 05:40:37 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 06F481516; Tue, 12 Jul 2022 05:40:38 -0700 (PDT) Received: from [10.57.13.42] (unknown [10.57.13.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 45F143F70D; Tue, 12 Jul 2022 05:40:36 -0700 (PDT) Message-ID: <5d513646-a917-b969-b2d2-9d5f4e0e6f4d@arm.com> Date: Tue, 12 Jul 2022 13:40:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v2 3/3] thermal/core: Fix thermal trip cross point Content-Language: en-US To: Daniel Lezcano Cc: quic_manafm@quicinc.com, rui.zhang@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Amit Kucheria , rafael@kernel.org References: <20220708183210.1334839-1-daniel.lezcano@linaro.org> <20220708183210.1334839-3-daniel.lezcano@linaro.org> <6ce87fbb-1460-503b-f1f1-8cf53e702cdf@arm.com> <2d680cd9-9e97-e06c-55c2-2a3a1504488e@linaro.org> From: Lukasz Luba In-Reply-To: <2d680cd9-9e97-e06c-55c2-2a3a1504488e@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/12/22 13:30, Daniel Lezcano wrote: > On 12/07/2022 13:29, Lukasz Luba wrote: > > [ ... ] > >>> @@ -511,8 +528,13 @@ void thermal_zone_device_update(struct >>> thermal_zone_device *tz, >>>       tz->notify_event = event; >>> -    for (count = 0; count < tz->trips; count++) >>> -        handle_thermal_trip(tz, count); >>> +    if (tz->last_temperature <= tz->temperature) { >>> +        for (count = 0; count < tz->trips; count++) >>> +            handle_thermal_trip(tz, count); >>> +    } else { >>> +        for (count = tz->prev_trip; count >= 0; count--) >>> +            handle_thermal_trip(tz, count); >>> +    } >> >> In general the code look good. I have one question, though: >> Is it always true that these trip points coming from the DT >> and parsed in thermal_of_build_thermal_zone() populated by >>      for_each_child_of_node(child, gchild) { >>           thermal_of_populate_trip(gchild, &tz->trips[i++]); >> >> are always defined in right order in DT? > > Hmm, that is a good question. Even if the convention is to put the trip > point in the ascending order, I don't find any documentation telling it > is mandatory. Given that I don't feel particularly comfortable to assume > that is the case. > > Perhaps, it would make more sense to build a map of indexes telling the > order in the trip points and work with it instead. > > Sounds a reliable way to move forward. Maybe you could just sort in the right order those trip points in the thermal_of_build_thermal_zone() in an additional patch to this series? Than this patch could stay as is, because it looks good.