Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp775283rwb; Tue, 27 Sep 2022 04:39:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5+m/1c9QMhnKsqmiDOa1XHXly7+agbK5h5s+I6zrnx/jfc5DSv1c0XLlYHN5v//+GGrGST X-Received: by 2002:a63:f917:0:b0:439:1c07:d1da with SMTP id h23-20020a63f917000000b004391c07d1damr24173625pgi.13.1664278762598; Tue, 27 Sep 2022 04:39:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664278762; cv=none; d=google.com; s=arc-20160816; b=yc7bSnneKypcQxilpULriQblda7Fx8WiYYmIkGsyz8f/nzC02aPiJN1Bo+lshR68Mh ils9QUzLKX42r4CjmzdWXmZ5MnojSpVM7pubEHMCGz4IBLKcMcUJzA5sGIzcs1wKUatu FaPZVBaTHHnma0RhZdRig5LX/x/B4DLA97CUvISLuJlLPpzgfX6lIbQCktQ0GmlbBBH8 y5Z3Z6S/uiLRswk3j6a6EtDuvIHlgRb5uNFvit0zuJ/O5DsUV8ixk1fc5tqARbDujWCr 5EOi13GMGWY6xGU0uBfbLQMrR3zEp0IWqTvn1jDh2kAwXotOoktCg0O+J2LJs9jM4K3k v4og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=fgbzzrwFzK76UVC6zcQ2bGACHn1NP4bULsk7xBLan/Y=; b=WmuCVQ+7zbZolyp578ah+gwc9Hb7VwGhHoth9ZbKtHnxwxIVgBRhilMACtRwuaGawb SqnxoJ8rE9KAYVB0ymJwNUHT/SieuniNd7UVM6+1LD1FLIW3kXNQP98+QEmktT6lWIv+ oO2uygCJUVCGB44htwReV7H4XsWeE5JMagFBFUVuPGtfs+NXUD4xq53v38QzDZk/iLJG RA6FvEMkEWyRjhq+HYuPvEJB4fAiueYZY2mFGJPNyeSvV2njzCWBJau3KN+c9nHqUUCt bHqPo4GKEwkXtBhWuVGyNCqjH4SQ8pnaTpDDcoaYrg/x5Few5af/tKRs+kDrIXm0V2fg QQug== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id li12-20020a17090b48cc00b001fa55447988si1627293pjb.40.2022.09.27.04.39.09; Tue, 27 Sep 2022 04:39:22 -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; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231902AbiI0LKu (ORCPT + 99 others); Tue, 27 Sep 2022 07:10:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230354AbiI0LKP (ORCPT ); Tue, 27 Sep 2022 07:10:15 -0400 Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41CA24A108; Tue, 27 Sep 2022 04:08:13 -0700 (PDT) Received: by mail-qv1-f44.google.com with SMTP id u8so360280qvv.9; Tue, 27 Sep 2022 04:08:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=fgbzzrwFzK76UVC6zcQ2bGACHn1NP4bULsk7xBLan/Y=; b=vc4ed+jWn8eOevOuzN+23Mvcg0x7mAfdyYBfWd3mFm7DpXhnSKixUejupYX6JHJYtA AMGWjMuq3L/r1vYosYf9N7oe0UQGflDD3WaLuhNN+UFQJ9NN4aX6VmUSijmiLOH3BtMf umux+Xrj/PGV7CW8P+co/jwDUayAVWAvWycXPrLZwnvz1n5Ij78eeIk4o8vcoxNlBUsH xAMhpx1ZZqOyhJJhFhJK9PsajrLAF+eyDX9eL64gMJ4da7osjKFLnm/gfVnAwWfPhMci otpteNkwZg4spMeTD7JiQrNqMI5HsScOBo1iqVfCSsNeHZXTfGHytlILX8GVq5hP5JQe 1OIA== X-Gm-Message-State: ACrzQf0C6mG+I/f7vkjNIntJnYCfr3SSHdUWEF4LyAzdLUHA8qIJ5cfU fwdONQbvE2c0mKHlOHs/BBUVu0ErxRJESGudbLI= X-Received: by 2002:a0c:da14:0:b0:4aa:aad9:e450 with SMTP id x20-20020a0cda14000000b004aaaad9e450mr21087440qvj.130.1664276892157; Tue, 27 Sep 2022 04:08:12 -0700 (PDT) MIME-Version: 1.0 References: <20220926140604.4173723-1-daniel.lezcano@linaro.org> <20220926140604.4173723-6-daniel.lezcano@linaro.org> <657008be-34e3-e2de-a9bd-41d2dc804e51@linaro.org> In-Reply-To: <657008be-34e3-e2de-a9bd-41d2dc804e51@linaro.org> From: "Rafael J. Wysocki" Date: Tue, 27 Sep 2022 13:08:00 +0200 Message-ID: Subject: Re: [PATCH v5 05/30] thermal/core/governors: Use thermal_zone_get_trip() instead of ops functions To: Daniel Lezcano Cc: "Rafael J. Wysocki" , Linux Kernel Mailing List , Linux PM , "Zhang, Rui" , Lukasz Luba , Amit Kucheria Content-Type: text/plain; charset="UTF-8" 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_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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 On Tue, Sep 27, 2022 at 12:15 AM Daniel Lezcano wrote: > > On 26/09/2022 21:34, Rafael J. Wysocki wrote: > > On Mon, Sep 26, 2022 at 4:06 PM Daniel Lezcano > > wrote: > >> > >> The governors are using the ops->get_trip_* functions, Replace these > >> calls with thermal_zone_get_trip(). > >> > >> Signed-off-by: Daniel Lezcano > >> Reviewed-by: Zhang Rui > >> Reviewed-by: Lukasz Luba # IPA > >> --- > >> drivers/thermal/gov_bang_bang.c | 29 ++++++++------- > >> drivers/thermal/gov_fair_share.c | 18 ++++------ > >> drivers/thermal/gov_power_allocator.c | 51 ++++++++++++--------------- > >> drivers/thermal/gov_step_wise.c | 22 ++++++------ > >> 4 files changed, 53 insertions(+), 67 deletions(-) > >> > >> diff --git a/drivers/thermal/gov_bang_bang.c b/drivers/thermal/gov_bang_bang.c > >> index a08bbe33be96..f5b85e5ea707 100644 > >> --- a/drivers/thermal/gov_bang_bang.c > >> +++ b/drivers/thermal/gov_bang_bang.c > >> @@ -13,26 +13,25 @@ > >> > >> #include "thermal_core.h" > >> > >> -static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip) > >> +static void thermal_zone_trip_update(struct thermal_zone_device *tz, int trip_id) > >> { > >> - int trip_temp, trip_hyst; > >> + struct thermal_trip trip; > >> struct thermal_instance *instance; > >> + int ret; > >> > >> - tz->ops->get_trip_temp(tz, trip, &trip_temp); > >> - > >> - if (!tz->ops->get_trip_hyst) { > >> - pr_warn_once("Undefined get_trip_hyst for thermal zone %s - " > >> - "running with default hysteresis zero\n", tz->type); > >> - trip_hyst = 0; > >> - } else > >> - tz->ops->get_trip_hyst(tz, trip, &trip_hyst); > >> + ret = __thermal_zone_get_trip(tz, trip_id, &trip); > >> + if (ret) > >> + pr_warn_once("Failed to retrieve trip point %d\n", trip_id); > > > > Does it even make sense to continue beyond this point if ret is nonzero? > > No, I think we can bail out from here > > > All of the contents of trip can be garbage then AFAICS. > > > >> + > >> + if (!trip.hysteresis) > >> + pr_warn_once("Zero hysteresis value for thermal zone %s\n", tz->type); > > > > Why do you want to warn about this? Haven't we declared already that > > zero hysteresis is valid and normal? > > Apparently the bang-bang governor is expecting a hysteresis value as the > check is expecting: > > >> - if (!tz->ops->get_trip_hyst) { > >> - pr_warn_once("Undefined get_trip_hyst for thermal > zone %s - " > >> - "running with default hysteresis > zero\n", tz->type); > >> - trip_hyst = 0; > > It is just to keep a warning as before. The new message will be different, though. I think it should be per-tz and the "info" level should be sufficient, and because thermal_zone_device is based on struct device, dev_info_once(&tz->dev, ...) should work.