Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3768370pxv; Mon, 19 Jul 2021 08:18:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysEhLltbReurFfj6JVwF5RoVVD1XBJhjButwciB0YMKsp5A/yGo8wX/08k+22HsiRfN/1f X-Received: by 2002:a05:6602:24d8:: with SMTP id h24mr19291487ioe.27.1626707898193; Mon, 19 Jul 2021 08:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626707898; cv=none; d=google.com; s=arc-20160816; b=0cvZSl8ty1sTukox8KoZXQ0AZlGSPhsH37i+0Ug0JmYU9Ia9xDMzdtolK9TDbXtg0+ XpUE9EZpuvBquSNLodKrG/1N9Z+l2dUS1UWb22xxSCLx2HUyAYL45xlqfKAT+xt5XdSC 6Iob4e+DJc0WVPeIonuplONhMB46twm4L9TR+4qtEM6BVOZsx7TFS1NoTVypAV0XKX97 HByqse17RbA0581malX20JnDkl8pbkYer6guT/3ri8/pjqlFgCDw6VHRjoRnJzQ3dsYg k7Ncwh32xBLvNnLzT53lBj7vVZUuVw4XEUY8R4Hlv/vxbg21PA8iWmlYs8VNPrzt28/i VxUg== 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=0VSD4v9h9L1nYn3dBN6w2gwju7u7GFrcO01wLdHcNyk=; b=TSqffnetnxBBLs+wHi8DdsMjofbBAmw9sklpJzRV+HlLAxjhBXDpRoS/2nKY5Gw1F2 8z6x1xeGBlHsjPtIcFxlqCbz5FNYQBqzMOc+AaeS/IzyZm9401tKy0S5bGsKtC+y6GOz ARRwVRJGAOJwt6FdNn4FtRP/cnatiI4m7Ggy60yEbzO7NrxrhtvicPRtz43VbANaomXH Ud5BU9u3eV3dlZmksGMpqwyCpEDVrwjtMDRG5B4eMLnxXuFM66ryK7JCi6+A816U1PHT VuZPyFVwJmTBiHSxpHeNID077U3euoHi+dcmX2GenuvpNRNNauNcbuaOTeDz6df6Mrgv GQWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ApHZTcK4; 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 16si19841571iln.76.2021.07.19.08.18.06; Mon, 19 Jul 2021 08:18:18 -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=ApHZTcK4; 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 S245027AbhGSOg5 (ORCPT + 99 others); Mon, 19 Jul 2021 10:36:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:39078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244999AbhGSOaM (ORCPT ); Mon, 19 Jul 2021 10:30:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D165E6008E; Mon, 19 Jul 2021 15:10:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626707451; bh=DicTgpPqhZr/i6spxuOj5ERWvvj9fiLdAcdUwi3iu88=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ApHZTcK4MWrKtWq84BDWAQpzQw/KK8CsozOIzDEHk8I5byB6QyIVUJCM9Kdi/Kxuo TIDN75DKxmGf5iKSR5QRgU3UF9tpjetujaEGdBJBbccoDRa/Yuh9rB3G1hxHyJqd/3 HrdFB0Fw9MZyKl/s6shA+8y8ITgS144Vabyl/il0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Petr Pavlu , Corey Minyard Subject: [PATCH 4.9 168/245] ipmi/watchdog: Stop watchdog timer when the current action is none Date: Mon, 19 Jul 2021 16:51:50 +0200 Message-Id: <20210719144945.836083769@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144940.288257948@linuxfoundation.org> References: <20210719144940.288257948@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: Petr Pavlu commit 2253042d86f57d90a621ac2513a7a7a13afcf809 upstream. When an IPMI watchdog timer is being stopped in ipmi_close() or ipmi_ioctl(WDIOS_DISABLECARD), the current watchdog action is updated to WDOG_TIMEOUT_NONE and _ipmi_set_timeout(IPMI_SET_TIMEOUT_NO_HB) is called to install this action. The latter function ends up invoking __ipmi_set_timeout() which makes the actual 'Set Watchdog Timer' IPMI request. For IPMI 1.0, this operation results in fully stopping the watchdog timer. For IPMI >= 1.5, function __ipmi_set_timeout() always specifies the "don't stop" flag in the prepared 'Set Watchdog Timer' IPMI request. This causes that the watchdog timer has its action correctly updated to 'none' but the timer continues to run. A problem is that IPMI firmware can then still log an expiration event when the configured timeout is reached, which is unexpected because the watchdog timer was requested to be stopped. The patch fixes this problem by not setting the "don't stop" flag in __ipmi_set_timeout() when the current action is WDOG_TIMEOUT_NONE which results in stopping the watchdog timer. This makes the behaviour for IPMI >= 1.5 consistent with IPMI 1.0. It also matches the logic in __ipmi_heartbeat() which does not allow to reset the watchdog if the current action is WDOG_TIMEOUT_NONE as that would start the timer. Signed-off-by: Petr Pavlu Message-Id: <10a41bdc-9c99-089c-8d89-fa98ce5ea080@suse.com> Cc: stable@vger.kernel.org Signed-off-by: Corey Minyard Signed-off-by: Greg Kroah-Hartman --- drivers/char/ipmi/ipmi_watchdog.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c @@ -393,16 +393,18 @@ static int i_ipmi_set_timeout(struct ipm data[0] = 0; WDOG_SET_TIMER_USE(data[0], WDOG_TIMER_USE_SMS_OS); - if ((ipmi_version_major > 1) - || ((ipmi_version_major == 1) && (ipmi_version_minor >= 5))) { - /* This is an IPMI 1.5-only feature. */ - data[0] |= WDOG_DONT_STOP_ON_SET; - } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) { - /* - * In ipmi 1.0, setting the timer stops the watchdog, we - * need to start it back up again. - */ - hbnow = 1; + if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) { + if ((ipmi_version_major > 1) || + ((ipmi_version_major == 1) && (ipmi_version_minor >= 5))) { + /* This is an IPMI 1.5-only feature. */ + data[0] |= WDOG_DONT_STOP_ON_SET; + } else { + /* + * In ipmi 1.0, setting the timer stops the watchdog, we + * need to start it back up again. + */ + hbnow = 1; + } } data[1] = 0;