Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3851222pxv; Mon, 19 Jul 2021 10:14:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRuirjH8/2BSyWa1qQT95aWhJ56+i78zP3D2rLfFw/sQg06fyjxTCoHR9NUqv4/ibDKj+q X-Received: by 2002:a92:d2ca:: with SMTP id w10mr16795286ilg.38.1626714871868; Mon, 19 Jul 2021 10:14:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626714871; cv=none; d=google.com; s=arc-20160816; b=WJjvolmPi4yCv7WcWsy+ZP/6xPpuhGrj3yqvlqeNfZ9dsyqIe5JhlGvC6qw+Ii1nZ/ Y0gkVmYqmERZ3P4fpOC6i1jL3mikAdoE+xzuh4ySfTXZkJbxwhFwdJFr2nX7zBCV2MhD EdWzUZU2G/nBLM8PSUwrV7rbN2YoG1HpTpSBJOt6y+PCzzMGHysfjf+J4Ym7yIS1XAEP ROsWGI4Y7tR2jPrHlpLss1mkU0L08js/29ksVZaeQogXI45N1z5oJLH1ONXp469uuE3e yF1O61zLLpHjK9a+xqUcFLuoBw71+lBuSIP7sqOm9jiYgRPmWqOPcWZ/BJHxBZQin2fG XxrA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=F6KOlVZFHWC/60D2vD0zRZXAPozAe30OnMIMFQ2169k=; b=k8G6Px7H6d3Q9ZQwTwZpXmiTD4OuFCW32CnKHAlGJ2QH+heBSvp9xMYWNA6r3fl3H8 Or/z4u5f+ZvEA1DFL1yp2X+ROOz6pP28OpRev/PnQLL0la2+s5Ab/v/+Frw7FC5/NqkV XoklIOp/oEoEf/Hv9YWiFMVVAflRH46n3w82hvsp2Fq/Gbqs1C9TwlM37LQEQQTkQ9vQ CMDcVxEAryZCJUJfSeiAqx7zQuUDSZHukn6cAnLldG4ypvrIaPgM5NEJKtvCCV+IqYNc TkTtgp4f4trPSHCJCOZp/H7PSbuV5wgXFqdCp35D5XZn3IZjacrHeR+9N4b/fMwQfEMM 6ULQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=o7FbgtsD; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q11si19693002ilv.18.2021.07.19.10.14.19; Mon, 19 Jul 2021 10:14:31 -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=@linuxfoundation.org header.s=korg header.b=o7FbgtsD; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349481AbhGSQb7 (ORCPT + 99 others); Mon, 19 Jul 2021 12:31:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:57554 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345824AbhGSPQs (ORCPT ); Mon, 19 Jul 2021 11:16:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 53AD56124C; Mon, 19 Jul 2021 15:57:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626710223; bh=QhVqUl8pjetORR/OsaENFqVeoLCVyMoIvyUo2BlxV5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o7FbgtsDkMSKYjWaRCpkMBhNhszsNAU5SjlH2W1MXsTPL1igBePbpVpxvHnXE6JW7 Yn5hW3MVWkQTOF7uEmWTfgCLMonNGelXv9gEAa8813mFNh/ETyKj5suNfuISYeTjYE l/+rvdRMxu2qu9bYlPWLgA392dz6MIkD5hb/Ywso= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kiszka , Guenter Roeck , Wim Van Sebroeck , Sasha Levin Subject: [PATCH 5.10 127/243] watchdog: iTCO_wdt: Account for rebooting on second timeout Date: Mon, 19 Jul 2021 16:52:36 +0200 Message-Id: <20210719144945.012432946@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.904087935@linuxfoundation.org> References: <20210719144940.904087935@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kiszka [ Upstream commit cb011044e34c293e139570ce5c01aed66a34345c ] This was already attempted to fix via 1fccb73011ea: If the BIOS did not enable TCO SMIs, the timer definitely needs to trigger twice in order to cause a reboot. If TCO SMIs are on, as well as SMIs in general, we can continue to assume that the BIOS will perform a reboot on the first timeout. QEMU with its ICH9 and related BIOS falls into the former category, currently taking twice the configured timeout in order to reboot the machine. For iTCO version that fall under turn_SMI_watchdog_clear_off, this is also true and was currently only addressed for v1, irrespective of the turn_SMI_watchdog_clear_off value. Signed-off-by: Jan Kiszka Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/0b8bb307-d08b-41b5-696c-305cdac6789c@siemens.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Sasha Levin --- drivers/watchdog/iTCO_wdt.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c index a370a185a41c..519a539eeb9e 100644 --- a/drivers/watchdog/iTCO_wdt.c +++ b/drivers/watchdog/iTCO_wdt.c @@ -73,6 +73,8 @@ #define TCOBASE(p) ((p)->tco_res->start) /* SMI Control and Enable Register */ #define SMI_EN(p) ((p)->smi_res->start) +#define TCO_EN (1 << 13) +#define GBL_SMI_EN (1 << 0) #define TCO_RLD(p) (TCOBASE(p) + 0x00) /* TCO Timer Reload/Curr. Value */ #define TCOv1_TMR(p) (TCOBASE(p) + 0x01) /* TCOv1 Timer Initial Value*/ @@ -357,8 +359,12 @@ static int iTCO_wdt_set_timeout(struct watchdog_device *wd_dev, unsigned int t) tmrval = seconds_to_ticks(p, t); - /* For TCO v1 the timer counts down twice before rebooting */ - if (p->iTCO_version == 1) + /* + * If TCO SMIs are off, the timer counts down twice before rebooting. + * Otherwise, the BIOS generally reboots when the SMI triggers. + */ + if (p->smi_res && + (SMI_EN(p) & (TCO_EN | GBL_SMI_EN)) != (TCO_EN | GBL_SMI_EN)) tmrval /= 2; /* from the specs: */ @@ -523,7 +529,7 @@ static int iTCO_wdt_probe(struct platform_device *pdev) * Disables TCO logic generating an SMI# */ val32 = inl(SMI_EN(p)); - val32 &= 0xffffdfff; /* Turn off SMI clearing watchdog */ + val32 &= ~TCO_EN; /* Turn off SMI clearing watchdog */ outl(val32, SMI_EN(p)); } -- 2.30.2