Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp711589pxv; Thu, 15 Jul 2021 14:09:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjeZooUXXWc8q3gMS2YoO3vABuWLzUdIlSw9yWTXemh4gLEpIrgbM+z/Ly4m6/xEWrST5I X-Received: by 2002:a17:906:859a:: with SMTP id v26mr7690262ejx.336.1626383370462; Thu, 15 Jul 2021 14:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626383370; cv=none; d=google.com; s=arc-20160816; b=kQWi/1SpS25XRcO5BH5lpPResSnRwnko2mdNkRTA3OXb8wvJF1ayq12wWsMfYRvIVz BiuPakfYSukqSLymwieDGLL+ULFIp6jWrfmMn8KvF+c8Q2PecZUxoJ9lV8vTS80avkL6 BAAx4BNN8IPcC+wvTQDibehqI0npv0T9AA+bwbH5UYdTHmnVdzE00ixuCqlP1vAh2e5L H4frGtUGvn+B1bHMg/42Pbu126OHVmf1Yj8ZILMMhocqVnmnFs5RPUgoYIpMGO6mLTu/ TrcVNs0FQE4vnUDnh45jVWume7Bt8VpM7v6BoZwKzTJolTgc7gBHAe+9jppojJGwnXwC GraQ== 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=bpFcJJ/hU9WObCORE1XVIZHvr2MYEKvxxb2vd4nLFWA=; b=RyF9qQAba34r7sKdCVfbNBaPbMk8pUXGOP/hdOm4HM6Jg4uUctJEQTC7DSGNCdlzPT wXG94LH2G5iDa5TS7Fym07oG4AmOnn4azPlUnTiz6NMaXgBsLXBTju7KZMwCtp05d8a0 u4FhxbTddrryggM98ASkYkR5l04Dhjr/coHfVR56xavIMV3huAMqMvGnW+uddA4thlHy wCApvZQeDMcbRd45ycV9vcmT9CVd4wjqYW6bjcqSLuI/RUrz0ykKAKibC0M33lV/L3Bq QtMsippsnPvKtHjp2cVvaYjuIDt8TXorPo51dcAimpiG7W2DQyPqLukdBSjdmnFQWccw lKXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hizRh1jP; 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 i22si8302984ejh.547.2021.07.15.14.09.07; Thu, 15 Jul 2021 14:09:30 -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=hizRh1jP; 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 S239944AbhGOTUm (ORCPT + 99 others); Thu, 15 Jul 2021 15:20:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:38862 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242690AbhGOTFO (ORCPT ); Thu, 15 Jul 2021 15:05:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 89DB9613C4; Thu, 15 Jul 2021 19:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375699; bh=lujL2cvlgyfZDifBxwWYnoklm+/o68G+SorLx8OaS6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hizRh1jPZ0RuwffvqtSubK/93BuhLb5fcdi3p6dEcmz+AQYEq9akc386YqEIrnoXR Jndkv/WF29tygetu7SRxGuR9TnMJ+atg1SumgYOa2fvKYhns2659WIDNRUZImM2YP+ Anz/IgeDyy55shHu9WonNtHih4TAXmJ/CiOR5jXk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Petr Pavlu , Corey Minyard Subject: [PATCH 5.12 197/242] ipmi/watchdog: Stop watchdog timer when the current action is none Date: Thu, 15 Jul 2021 20:39:19 +0200 Message-Id: <20210715182627.908812353@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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 @@ -371,16 +371,18 @@ static int __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;