Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4259847pxj; Wed, 12 May 2021 01:21:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+Q5oTX7bkkDQQXc863mfWqEGxY+Z/7j6+EE1b7iMZiJepIKh+EUWGp428gWYaySXGdh+A X-Received: by 2002:a92:6b05:: with SMTP id g5mr29937442ilc.40.1620807672060; Wed, 12 May 2021 01:21:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620807672; cv=none; d=google.com; s=arc-20160816; b=Nj2ald++tCc7xccbsT+zN82X0YWpjRe0ffsqbJQLx9Iu/TulfRuNoqTW/g/utTaylr 9P9HkkctilBHoZEv2Bc8xlqHSFAP8A2sBH1qG0mjDxjKm4fdpHbqwj00T7/ZeRZ1afvP GVTwRxHZANhFHTxfhDc5WVO719nIZTBhH7+vWDDV4hrD2Hq8C5dewvUVtLOKVzp6IFDS gZ2pEJRPggChw7DKp04U6WsqjrNpL9p3PxFlBt3dAYw3NLdRJ1y5mXXmwlHiNQtdbg70 aOdrkLTuDCHRivNQCSymjsIx6H+pvCHUO+0LOaJ9zG/DnrqZu/BQPxjk7bEqsE9U0Ink 8ZBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Vza9DD+KUbiRtLfI0mIL3ImF5EprHsvwKgA+ti787LI=; b=IkYwOolq7COu4PPtvaMXKD8oRaTHxKFWDXmnsDoUfEydvE4AcMFHIVyEFzXdeyB8rN ZUH2M71bRCoe/mYpFi0n74CltEtqGDL020Xlr7VhLFJB0Khs8LJkBoijFyMFSJVj3zaT dpavqKG5zstT0V+NpzLVg75Sk0PL5UfC+k8ginLJ6d75c708WpNnKldLhQMj51azmf1t CvWssq2fip7NhhNzqY5VwwKjnuQMHnzdn7hwIhm7Jd17bUfG66mE5CmZQdGxn3WjxI/8 oeH7uhhCS8oQjv8IZ0arTujfAKbBsycr1kz6IzHD6OGC6fMPI1ExRdAGxEodb7UZjcwv KdPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=SEUCFz0z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y21si23416428jao.90.2021.05.12.01.20.59; Wed, 12 May 2021 01:21:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=SEUCFz0z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230134AbhELIV1 (ORCPT + 99 others); Wed, 12 May 2021 04:21:27 -0400 Received: from mx2.suse.de ([195.135.220.15]:50322 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229968AbhELIV0 (ORCPT ); Wed, 12 May 2021 04:21:26 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1620807617; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Vza9DD+KUbiRtLfI0mIL3ImF5EprHsvwKgA+ti787LI=; b=SEUCFz0zu0Zp1BQ9xz1mNFPtDYhbTNwQhQo77/WPTDUSYSs9YYUUH3rHkmMfCEgx7RVIJp dwIeahyOWnteniGqdd3VuYtW/CarKwLYLktS4+AtvvPlDD3WewhKIPFriqz5n56j3P2hbq S4D13UGTFc3ksE8v03AOtcpvvI1r4nc= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 28C1BAF2C; Wed, 12 May 2021 08:20:17 +0000 (UTC) Date: Wed, 12 May 2021 10:20:16 +0200 From: Petr Mladek To: Matti Vaittinen Cc: Matti Vaittinen , Mark Brown , Kees Cook , Andy Shevchenko , Zhang Rui , Guenter Roeck , "agross@kernel.org" , "devicetree@vger.kernel.org" , linux-power , "linux-kernel@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" , "linux-arm-msm@vger.kernel.org" , "bjorn.andersson@linaro.org" , "lgirdwood@gmail.com" , "robh+dt@kernel.org" , Daniel Lezcano , Amit Kucheria , Matteo Croce , Andrew Morton , "Rafael J. Wysocki" , Mike Rapoport , Josef Bacik , Kai-Heng Feng , linux-pm@vger.kernel.org Subject: Re: [PATCH v9 02/10] reboot: Add hardware protection power-off Message-ID: References: <97260f8e150abb898a262fade25860609b460912.1620645507.git.matti.vaittinen@fi.rohmeurope.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <97260f8e150abb898a262fade25860609b460912.1620645507.git.matti.vaittinen@fi.rohmeurope.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 2021-05-10 14:28:30, Matti Vaittinen wrote: > There can be few cases when we need to shut-down the system in order to > protect the hardware. Currently this is done at east by the thermal core > when temperature raises over certain limit. > > Some PMICs can also generate interrupts for example for over-current or > over-voltage, voltage drops, short-circuit, ... etc. On some systems > these are a sign of hardware failure and only thing to do is try to > protect the rest of the hardware by shutting down the system. > > Add shut-down logic which can be used by all subsystems instead of > implementing the shutdown in each subsystem. The logic is stolen from > thermal_core with difference of using atomic_t instead of a mutex in > order to allow calls directly from IRQ context. > > Signed-off-by: Matti Vaittinen > > diff --git a/kernel/reboot.c b/kernel/reboot.c > index a6ad5eb2fa73..5da8c80a2647 100644 > --- a/kernel/reboot.c > +++ b/kernel/reboot.c > @@ -518,6 +519,85 @@ void orderly_reboot(void) > } > EXPORT_SYMBOL_GPL(orderly_reboot); > > +/** > + * hw_failure_emergency_poweroff_func - emergency poweroff work after a known delay > + * @work: work_struct associated with the emergency poweroff function > + * > + * This function is called in very critical situations to force > + * a kernel poweroff after a configurable timeout value. > + */ > +static void hw_failure_emergency_poweroff_func(struct work_struct *work) > +{ > + /* > + * We have reached here after the emergency shutdown waiting period has > + * expired. This means orderly_poweroff has not been able to shut off > + * the system for some reason. > + * > + * Try to shut down the system immediately using kernel_power_off > + * if populated > + */ > + WARN(1, "Hardware protection timed-out. Trying forced poweroff\n"); > + kernel_power_off(); WARN() look like an overkill here. It prints many lines that are not much useful in this case. The function is called from well-known context (workqueue worker). Also be aware that "panic_on_warn" commandline option will trigger panic() here. > + /* > + * Worst of the worst case trigger emergency restart > + */ > + WARN(1, > + "Hardware protection shutdown failed. Trying emergency restart\n"); > + emergency_restart(); Two consecutive WARN() calls are even less useful. They are eye catching but it is hard to find the only useful line with the custom message. Best Regards, Petr