Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1925130rwd; Thu, 18 May 2023 20:55:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4IzSdm4yiSzhA1cgT+OAj4PRrjv+xYZHtv8GeW73wNLkgqNySAlRwUal/CnZkECDml3jaA X-Received: by 2002:a05:6a00:15c9:b0:643:59ed:5dc9 with SMTP id o9-20020a056a0015c900b0064359ed5dc9mr1683213pfu.12.1684468543163; Thu, 18 May 2023 20:55:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684468543; cv=none; d=google.com; s=arc-20160816; b=LE1hkRlgSXKCqhqH5MbKRcIxQewJkt6+6mc5SS0iFdnZ1lIS1K60OMZV3JF/jWmmjO xNdIcL56yPz0nF0hskO5iwatErilAsjimWjjqcmiEHqjnA/dLbWt42pQQmTKJfEhEWgz wGyHvu+zl74eCGdoZuPsy/C5glJnjx41DkeE5LYidoHru2PsKtD3/lHjlkBJqGNfMBsi QHQsY9NRweZgHKomiUSqncyyXRHNbOiKEI6C9mLlm0Rm72BiMiz6Rjyi2ej0eIQuJ+aS uX1X8K84HfV0jVPCD7bEs9iQ80oBtn4xUBQ5EPOW31d35Ijg1wy9mBXFSCUZYUui0iA/ Pteg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ljw7vbS8LvkmSYHETIv3IOKWRlC+AlaCNdCglU9yy5Y=; b=pulB7f0tVzijuMgaGRNpVo2hC8WiPzrE44GbFiOsWmpxmiFWZyR63fNUgoogHlbk+I XzYYLHJpNyTpTuUNzvrlmQsLbQL9VYftzXb0ny6KFeRCEiEjmHbJ5+0w4uz7YJEuctuX Ow97KU7O0sPAC7OKDbpmn0RPNe7CrVFv2RDwSRyiwUsw4lcVvwOlRagIShswRPylhyaJ 3wqUXg2Ka98iHZRyRX1DF9nlSYTckFBRoCDgxh3Uft2WFEnWFke5g0OT5n7HQBAtkv7G 4tWlR0s+1J7412DWzGB0uLdo4e7w6nifvWaCvt9gW0Vhjj860Tywd31GFReSaytBftWq HyjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mGLvwm9S; 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 a9-20020aa78e89000000b00648019bae38si1025091pfr.277.2023.05.18.20.55.31; Thu, 18 May 2023 20:55:43 -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=@kernel.org header.s=k20201202 header.b=mGLvwm9S; 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 S230151AbjESD2L (ORCPT + 99 others); Thu, 18 May 2023 23:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229789AbjESD1p (ORCPT ); Thu, 18 May 2023 23:27:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CF5910D8; Thu, 18 May 2023 20:27:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9F457653CA; Fri, 19 May 2023 03:27:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A83B9C433D2; Fri, 19 May 2023 03:27:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684466863; bh=HdWlDRXipx3TpYgWVO+5t2tBpNikk3svror7f2vLIJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mGLvwm9S2HUt+CyrnOTyMXhDZ/Kdo5rDHzNg4qkW5J5/oGt/tQrUYdoBYyOxtBTQc aBDFlWd+aur0KEkcIBs+4nXKSS9bM8EusrvgClZO+eSf1MCff/rAZaYgR8igZiSgyR pn9siByJIJb1lzgUOWkefklJkdkWPNoPZ/zOAyhLGfY0JP2mHYM2OKoci/Wgp296or FEoL1lk7+KOyo2T3qKAXZF7wqOBGRa0Mn9s13j10kf6GVwZnAvf1sYzu5nrFhDtUw7 bhTFTL074RdcEgnewdfe2qTST91YUXtfbn7i/pVTIZ9EpBglvFuLdHXWX0Vez92rzK iH5oZnht9Fshg== From: Eduardo Valentin To: eduval@amazon.com, linux-pm@vger.kernel.org Cc: "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/7] ythermal: core: report errors to governors Date: Thu, 18 May 2023 20:27:18 -0700 Message-Id: <20230519032719.2581689-7-evalenti@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230519032719.2581689-1-evalenti@kernel.org> References: <20230519032719.2581689-1-evalenti@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Eduardo Valentin Currently the thermal governors are not allowed to react on temperature error events as the thermal core skips the handling and logs an error on kernel buffer. This patch adds the opportunity to report the errors when they happen to governors. Now, if a governor wants to react on temperature read errors, they can implement the .check_error() callback. Cc: "Rafael J. Wysocki" (supporter:THERMAL) Cc: Daniel Lezcano (supporter:THERMAL) Cc: Amit Kucheria (reviewer:THERMAL) Cc: Zhang Rui (reviewer:THERMAL) Cc: Jonathan Corbet (maintainer:DOCUMENTATION) Cc: linux-pm@vger.kernel.org (open list:THERMAL) Cc: linux-doc@vger.kernel.org (open list:DOCUMENTATION) Cc: linux-kernel@vger.kernel.org (open list) Signed-off-by: Eduardo Valentin --- drivers/thermal/thermal_core.c | 9 +++++++++ include/linux/thermal.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 3ba970c0744f..2ff7d9c7c973 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -313,6 +313,12 @@ static void handle_non_critical_trips(struct thermal_zone_device *tz, int trip) def_governor->throttle(tz, trip); } +static void handle_error_temperature(struct thermal_zone_device *tz, int error) +{ + if (tz->governor && tz->governor->check_error) + tz->governor->check_error(tz, error); +} + void thermal_zone_device_critical(struct thermal_zone_device *tz) { /* @@ -380,6 +386,9 @@ static void update_temperature(struct thermal_zone_device *tz) dev_warn(&tz->device, "failed to read out thermal zone (%d)\n", ret); + /* tell the governor its source is hosed */ + handle_error_temperature(tz, ret); + return; } diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 9dc8292f0314..82c8e09a63e0 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -199,6 +199,8 @@ struct thermal_zone_device { * thermal zone. * @throttle: callback called for every trip point even if temperature is * below the trip point temperature + * @check_error: callback called whenever temperature updates fail. + * Opportunity for the governor to react on errors. * @governor_list: node in thermal_governor_list (in thermal_core.c) */ struct thermal_governor { @@ -206,6 +208,7 @@ struct thermal_governor { int (*bind_to_tz)(struct thermal_zone_device *tz); void (*unbind_from_tz)(struct thermal_zone_device *tz); int (*throttle)(struct thermal_zone_device *tz, int trip); + void (*check_error)(struct thermal_zone_device *tz, int error); struct list_head governor_list; }; -- 2.34.1