Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp2685206ima; Mon, 22 Oct 2018 14:08:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV606nI1FDaZ2aUCG3dJGoo3lBXHFukqTaXi7HhrKMyXHRZLH0Qp4MYyF53PUJA4S6vms1Ieg X-Received: by 2002:a62:d085:: with SMTP id p127-v6mr21161692pfg.202.1540242489974; Mon, 22 Oct 2018 14:08:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540242489; cv=none; d=google.com; s=arc-20160816; b=b4T/fNloC0DwANDSAdK7kQas6l+9Ne+i0hQ7p+z0LphRDYP7kfNkmpbNzL98TLG/rG mcQtjtKtVUDLJ6yzFPWTxH5TLCmscRDirSS+et6h8pe77NncnTi1kYeifp48XnFybupM OTw2skdNt80tBXjcQQk+Fh2v7qR8y5V6989kQzAEBOzq4h3msMZ83l1+ZPCbr1WvV8p1 gLgyJ9J7DHTtZYnNZCo/U7BFNE1KefaPmzuHZty4PkZy7IrX5u8hefxfBJMvnFAvc3ck 1/DmWUQGEKEIbjjSb8IAqtWWxZMGfhUBqdxHm0xdnIOfGt5a3HfB+pkXruEJOK3lgHuI CcDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=qBkcULrk24lGYqTEeJPSqpxDS/GL/T8SH7WD8YBNpus=; b=viXXgvgFiKeN7zR+TKZiB36VFDKvhWYFWlQSsBpl7An1XBv436BxOCz7KTc1QwyvlT 42bjgywVIqqRL7i7MMM/5MGq/MjMU2ZdXpTXcgtf/yEcFUzvEFN2ow3wT+XWY3cRtBpE fZhcQf1Pzgr8iyYO7Fml+bxFvY4Eg+6oA4IDhhUBXyTHtUmTp1SD23wQ0plPwO9OYtyJ k4+KObRQOgdC18pIOQ+d8xQktYL7jNWu3neI1VFLm+QnfVwEk37WmTJApEYBYthQg8/M WxJzjsf6TpTB6iOfKlRjbd2HMMH/tloHapJk4E0GnKvPQH24DdZ01Cz3u59Vye0IYJZ6 mEEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=EI2qS340; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g12-v6si34420006pfi.184.2018.10.22.14.07.54; Mon, 22 Oct 2018 14:08:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=EI2qS340; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728813AbeJWEw2 (ORCPT + 99 others); Tue, 23 Oct 2018 00:52:28 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:36984 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbeJWEw1 (ORCPT ); Tue, 23 Oct 2018 00:52:27 -0400 Received: by mail-qk1-f202.google.com with SMTP id z10-v6so6248908qkl.4 for ; Mon, 22 Oct 2018 13:32:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=qBkcULrk24lGYqTEeJPSqpxDS/GL/T8SH7WD8YBNpus=; b=EI2qS340NBQET5Mg5nPhP4aVB2ya2DI6ZnTdAQBQRROnGzihSXYVl9NGcOp51g+w1Q 16wCHIv1TtcHHFUzffZP0mrcMsomH02bIUPQM4cd4IWH1/EpoyQPCUNYybTQLt9UOtBk WFjhk6o50sbI43ObRR9uS/krPjeQNKJjIV3lAztiDMZYTFP0ofxj/gkG9dy5bZpxdTDT x7BjhrlJpAakuVwUHNXQBkSl2LmRgSrtHnbSg9As62BFNsc9CFbhRq/BIRNKSWKLjpL3 9EwiWk+WKYQVAAuTvbyCt+UTiwAyEsewQ58XZo1+VoYAvVauyHu4uByEqWR6vIpYE2KW BX4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=qBkcULrk24lGYqTEeJPSqpxDS/GL/T8SH7WD8YBNpus=; b=lgJCRqkIizXxTkuoxD4+6LPE4Up0wnYs7akLyaFAEEPHEVTjWtxmUOuKOV05YT9g1m 8hAiaV4GyhQhdwJFtmLx2vGeEXzSWdc/VEqiWoLmA93yHV3VUAFXnbI3howwaWWqdvNw 8vEAgqRJEUuokcypheVav9hwYPXqFwyfBBXU5jUmNYShTh8dzNJa85bFtUa+x8n8GrTA CqJKjEQDaDiQjeObarqlAynXp74zBeMVUwLLG8AtV3bdun4qcecRoA9sRwBHI1Ab1ySv qtKPYlFgc3mHkUf9xuoTxqTQZRvF/dIME6mmvm9zHds4LOOU/1DHD8/NTDwKf/7koOpa 5tJw== X-Gm-Message-State: ABuFfojNizev+xphW+bixmaITtSbxy2P6mCnZaxRa6IfKMrLRAy9NBbk 00wlPscuJvdRN/IoUVOB6c3Ct08A1SNjenO7iSRep6uYMggmKR1qvt2V97vTtvMV/T63QI/+Z6W G8UmGuDZ6JJWBKh0H4zj66omgL4xW9YXX4HUaX1u0X91V4VljEQVeA3udpd20+xhj4Gt3e03O X-Received: by 2002:ac8:6993:: with SMTP id o19-v6mr11319241qtq.35.1540240345255; Mon, 22 Oct 2018 13:32:25 -0700 (PDT) Date: Mon, 22 Oct 2018 14:32:18 -0600 In-Reply-To: <20181022203218.7007-1-zwisler@google.com> Message-Id: <20181022203218.7007-2-zwisler@google.com> Mime-Version: 1.0 References: <20181022203218.7007-1-zwisler@google.com> X-Mailer: git-send-email 2.19.1.568.g152ad8e336-goog Subject: [PATCH 2/2] gsmi: Log event for critical thermal thresholds From: Ross Zwisler To: linux-kernel@vger.kernel.org Cc: Duncan Laurie , Daniel Lezcano , Eduardo Valentin , Zhang Rui , linux-pm@vger.kernel.org, Ross Zwisler Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Duncan Laurie This registers a notifier for the new thermal notifier introduced in a previous commit and logs a kernel shutdown event when the notifier is called for crossing the THERMAL_TRIP_CRITICAL threshold. To test: 1) Modify critical shutdown threshold in the BIOS 2) Generate a load on the system to increase temperature 3) Wait until system powers off 4) Power back on and read the event log: 4 | 2012-07-18 10:47:02 | Kernel Event | Critical Thermal Threshold 5 | 2012-07-18 10:47:06 | Kernel Event | Clean Shutdown 6 | 2012-07-18 10:47:06 | ACPI Enter | S5 Signed-off-by: Duncan Laurie Reviewed-by: Vincent Palatin Reviewed-by: Olof Johansson [ rez: updated changelog for upstream ] Signed-off-by: Ross Zwisler --- drivers/firmware/google/gsmi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c index c8f169bf2e27d..ee0c611b83e99 100644 --- a/drivers/firmware/google/gsmi.c +++ b/drivers/firmware/google/gsmi.c @@ -29,6 +29,7 @@ #include #include #include +#include #define GSMI_SHUTDOWN_CLEAN 0 /* Clean Shutdown */ /* TODO(mikew@google.com): Tie in HARDLOCKUP_DETECTOR with NMIWDT */ @@ -40,6 +41,7 @@ #define GSMI_SHUTDOWN_SOFTWDT 6 /* Software Watchdog */ #define GSMI_SHUTDOWN_MBE 7 /* Uncorrected ECC */ #define GSMI_SHUTDOWN_TRIPLE 8 /* Triple Fault */ +#define GSMI_SHUTDOWN_THERMAL 9 /* Critical Thermal Threshold */ #define DRIVER_VERSION "1.0" #define GSMI_GUID_SIZE 16 @@ -670,6 +672,18 @@ static struct notifier_block gsmi_panic_notifier = { .notifier_call = gsmi_panic_callback, }; +static int gsmi_thermal_callback(struct notifier_block *nb, + unsigned long reason, void *arg) +{ + if (reason == THERMAL_TRIP_CRITICAL) + gsmi_shutdown_reason(GSMI_SHUTDOWN_THERMAL); + return NOTIFY_DONE; +} + +static struct notifier_block gsmi_thermal_notifier = { + .notifier_call = gsmi_thermal_callback +}; + /* * This hash function was blatantly copied from include/linux/hash.h. * It is used by this driver to obfuscate a board name that requires a @@ -892,6 +906,7 @@ static __init int gsmi_init(void) goto out_remove_sysfs_files; } + register_thermal_notifier(&gsmi_thermal_notifier); register_reboot_notifier(&gsmi_reboot_notifier); register_die_notifier(&gsmi_die_notifier); atomic_notifier_chain_register(&panic_notifier_list, @@ -918,6 +933,7 @@ static __init int gsmi_init(void) static void __exit gsmi_exit(void) { + unregister_thermal_notifier(&gsmi_thermal_notifier); unregister_reboot_notifier(&gsmi_reboot_notifier); unregister_die_notifier(&gsmi_die_notifier); atomic_notifier_chain_unregister(&panic_notifier_list, -- 2.19.1.568.g152ad8e336-goog