Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1547786rwd; Thu, 25 May 2023 14:24:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5FEIGE6hCQpd/M0Ls+lL1hLR4wGbovAr0jrf48seqXLY7wK9JmNqYLaoevvVanujlcHj/+ X-Received: by 2002:a05:6a21:3391:b0:10b:3b0d:b05c with SMTP id yy17-20020a056a21339100b0010b3b0db05cmr18113850pzb.28.1685049863031; Thu, 25 May 2023 14:24:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685049863; cv=none; d=google.com; s=arc-20160816; b=hQ9WtEXiACDd3iNIILOdCCi1BAjA/ZPTWzxsDAKaJFEP6K+XiLIGg2ukygBCVS42ZN ivSpTuC7va6iSsNeRVLcdqigWV2QGEjroZdfI7eqwJHa6c8HLDAzqnOlJuN+DKoZ2Zak 7x74Chb4r37ZoSxJi9I5PXh5snKTeE9DQ/dnhNL6bCJlU+3UNTuGVX/wunLYIsLc8GG4 hYcgvRZhQTt5Z176WljD3ByksEEu56KLVO9ayFZBNz1fTS/nE7zMrzaccA5/1YW6xiua PG6Yf9sNj1IndiaaycETLSrolW+wNR01r6+d3rLiUNgsemEtrTyE6fvcs40X7Bjkj7CH RkcA== 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=fUyBMmLZxCtJHs8yswqj3rQC+zYZsUQz0HGjSH1utOI=; b=fRWq2wZO/I1WQuFe9oy7lU3UTOnA87V8ZVjc5un2pFu/lUqnv5Db7o8AXIDSLcq72k iOwuQxwqmjArZ8TMBxy3IGHrUmq5ClrjRBD6CWDiI4YaQMfMTSphOOj+0wg3LjT0op5I 4g9HYChhyKjuEzPwvGxJS6FmbDC/iDNVMmc7OMg0TpUKe8lDc/rJ94o8gRUAkFYCCyCp +WR+IHhOImHxg9JNCwZm0L6WMvQBDoShf46MEcLwSAQ0AvxdYtxYpI15XBTCnPv07uN7 6M8vsh2M6EDE9sH9G5NlHCJQ8InyKwWGAKOA0tVWDOrNGojoEqDfbAAN5t8FEzRFwQkk qoTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OOYzQrWx; 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 201-20020a6306d2000000b0053b8f80c656si355370pgg.781.2023.05.25.14.24.11; Thu, 25 May 2023 14:24:23 -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=OOYzQrWx; 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 S240994AbjEYVRX (ORCPT + 99 others); Thu, 25 May 2023 17:17:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236434AbjEYVRT (ORCPT ); Thu, 25 May 2023 17:17:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8327AA7; Thu, 25 May 2023 14:17:18 -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 11BCC64B30; Thu, 25 May 2023 21:17:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31806C433D2; Thu, 25 May 2023 21:17:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685049437; bh=vEe5IMrxvZ6zjp9aBXSVRXJpxdUpiaH0SmaBoWt1Nqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OOYzQrWxDyfJoP/3gDvkOTQNTcpl0mwqfLpe6KQap1/xPJQeBfJUO7RYyGvzhmOuc sPgFSRVBY8DV4AVO1YTcpbX0qw3yi5Js+zc/+dZaGt4wV37xEIipDxHW06FlMFjuJS vhwWXp7UusKlHg90Qnuj1QarpO195cnncgjbU6BeqloOqBAoQV2p2+pCfuYxEZ4DfS wuG4o0VNtGWIVVCvYlVEABI3tHoB6YJIm6aqZlu77Zk+HmElPGWrUGTaOsPEwe2T7i DhLUlRD2XTYi++pHyS0dkxF9zfYKKk60w69dvm63WpZqEam/N/P0avkG7br2V5agBS wHmG0E80/2V2Q== From: Eduardo Valentin To: daniel.lezcano@linaro.org, rafael@kernel.org, linux-pm@vger.kernel.org Cc: Eduardo Valentin , Amit Kucheria , Zhang Rui , Jonathan Corbet , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] thermal: core: register a crash callback Date: Thu, 25 May 2023 14:16:55 -0700 Message-Id: <20230525211655.627415-4-evalenti@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230525211655.627415-1-evalenti@kernel.org> References: <20230525211655.627415-1-evalenti@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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 This commit will register a crash callback for the thermal subsystem, this way the thermal core can tear down the thermal zones and ask governors to leave the hardware in a known safe state prior upon the event of a crash. 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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 66a255fb650b..38b168b9245e 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -20,6 +20,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include "thermal_trace.h" @@ -1525,6 +1526,14 @@ static void thermal_reboot_prepare(void) } } +static int thermal_crash_notify(struct notifier_block *nb, + unsigned long mode, void *_unused) +{ + thermal_reboot_prepare(); + + return 0; +} + static int thermal_reboot_notify(struct notifier_block *nb, unsigned long mode, void *_unused) { @@ -1569,6 +1578,10 @@ static struct notifier_block thermal_pm_nb = { .notifier_call = thermal_pm_notify, }; +static struct notifier_block thermal_crash_nb = { + .notifier_call = thermal_crash_notify, +}; + static struct notifier_block thermal_reboot_nb = { .notifier_call = thermal_reboot_notify, }; @@ -1611,6 +1624,8 @@ static int __init thermal_init(void) pr_warn("Thermal: Can not register reboot notifier, return %d\n", result); + atomic_notifier_chain_register(&panic_notifier_list, + &thermal_crash_nb); return 0; unregister_governors: -- 2.34.1