From: Sasha Levin Date: Tue, 3 Oct 2023 16:44:08 +0000 (-0400) Subject: Fixes for 5.10 X-Git-Tag: v6.5.6~45 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=722069d817037dd3820207452a5dfa211b5cfad3;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.10 Signed-off-by: Sasha Levin --- diff --git a/queue-5.10/series b/queue-5.10/series index dc7d4437b5f..f3fee339c0c 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -137,3 +137,5 @@ acpi-check-storaged3enable-_dsd-property-in-acpi-cod.patch nvme-pci-factor-the-iod-mempool-creation-into-a-help.patch nvme-pci-factor-out-a-nvme_pci_alloc_dev-helper.patch nvme-pci-do-not-set-the-numa-node-of-device-if-it-ha.patch +watchdog-itco_wdt-no-need-to-stop-the-timer-in-probe.patch +watchdog-itco_wdt-set-no_reboot-if-the-watchdog-is-n.patch diff --git a/queue-5.10/watchdog-itco_wdt-no-need-to-stop-the-timer-in-probe.patch b/queue-5.10/watchdog-itco_wdt-no-need-to-stop-the-timer-in-probe.patch new file mode 100644 index 00000000000..05b976bda40 --- /dev/null +++ b/queue-5.10/watchdog-itco_wdt-no-need-to-stop-the-timer-in-probe.patch @@ -0,0 +1,58 @@ +From 6ba535763f018a5c578f60c29ea3841c5e82c708 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 2 Oct 2023 09:05:34 +0200 +Subject: watchdog: iTCO_wdt: No need to stop the timer in probe + +From: Mika Westerberg + +commit 1ae3e78c08209ac657c59f6f7ea21bbbd7f6a1d4 upstream. + +The watchdog core can handle pinging of the watchdog before userspace +opens the device. For this reason instead of stopping the timer, just +mark it as running and let the watchdog core take care of it. + +Cc: Malin Jonsson +Signed-off-by: Mika Westerberg +Reviewed-by: Guenter Roeck +Link: https://lore.kernel.org/r/20210921102900.61586-1-mika.westerberg@linux.intel.com +Signed-off-by: Guenter Roeck +Signed-off-by: Wim Van Sebroeck +Signed-off-by: Sasha Levin +--- + drivers/watchdog/iTCO_wdt.c | 13 +++++++++++-- + 1 file changed, 11 insertions(+), 2 deletions(-) + +diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c +index a370a185a41c4..9048fa44897fc 100644 +--- a/drivers/watchdog/iTCO_wdt.c ++++ b/drivers/watchdog/iTCO_wdt.c +@@ -426,6 +426,16 @@ static unsigned int iTCO_wdt_get_timeleft(struct watchdog_device *wd_dev) + return time_left; + } + ++static void iTCO_wdt_set_running(struct iTCO_wdt_private *p) ++{ ++ u16 val; ++ ++ /* Bit 11: TCO Timer Halt -> 0 = The TCO timer is * enabled */ ++ val = inw(TCO1_CNT(p)); ++ if (!(val & BIT(11))) ++ set_bit(WDOG_HW_RUNNING, &p->wddev.status); ++} ++ + /* + * Kernel Interfaces + */ +@@ -568,8 +578,7 @@ static int iTCO_wdt_probe(struct platform_device *pdev) + watchdog_set_drvdata(&p->wddev, p); + platform_set_drvdata(pdev, p); + +- /* Make sure the watchdog is not running */ +- iTCO_wdt_stop(&p->wddev); ++ iTCO_wdt_set_running(p); + + /* Check that the heartbeat value is within it's range; + if not reset to the default */ +-- +2.40.1 + diff --git a/queue-5.10/watchdog-itco_wdt-set-no_reboot-if-the-watchdog-is-n.patch b/queue-5.10/watchdog-itco_wdt-set-no_reboot-if-the-watchdog-is-n.patch new file mode 100644 index 00000000000..30addcc3a93 --- /dev/null +++ b/queue-5.10/watchdog-itco_wdt-set-no_reboot-if-the-watchdog-is-n.patch @@ -0,0 +1,96 @@ +From 42c98fc174ba04816872ace3fe2c765231e1ade7 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Mon, 2 Oct 2023 09:05:35 +0200 +Subject: watchdog: iTCO_wdt: Set NO_REBOOT if the watchdog is not already + running +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Mika Westerberg + +commit ef9b7bf52c2f47f0a9bf988543c577b92c92d15e upstream. + +Daniel reported that the commit 1ae3e78c0820 ("watchdog: iTCO_wdt: No +need to stop the timer in probe") makes QEMU implementation of the iTCO +watchdog not to trigger reboot anymore when NO_REBOOT flag is initially +cleared using this option (in QEMU command line): + + -global ICH9-LPC.noreboot=false + +The problem with the commit is that it left the unconditional setting of +NO_REBOOT that is not cleared anymore when the kernel keeps pinging the +watchdog (as opposed to the previous code that called iTCO_wdt_stop() +that cleared it). + +Fix this so that we only set NO_REBOOT if the watchdog was not initially +running. + +Fixes: 1ae3e78c0820 ("watchdog: iTCO_wdt: No need to stop the timer in probe") +Reported-by: Daniel P. Berrangé +Signed-off-by: Mika Westerberg +Tested-by: Daniel P. Berrangé +Reviewed-by: Daniel P. Berrangé +Reviewed-by: Guenter Roeck +Link: https://lore.kernel.org/r/20221028062750.45451-1-mika.westerberg@linux.intel.com +Signed-off-by: Guenter Roeck +Signed-off-by: Wim Van Sebroeck +Signed-off-by: Sasha Levin +--- + drivers/watchdog/iTCO_wdt.c | 21 ++++++++++++++------- + 1 file changed, 14 insertions(+), 7 deletions(-) + +diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c +index 9048fa44897fc..50c874d488607 100644 +--- a/drivers/watchdog/iTCO_wdt.c ++++ b/drivers/watchdog/iTCO_wdt.c +@@ -426,14 +426,18 @@ static unsigned int iTCO_wdt_get_timeleft(struct watchdog_device *wd_dev) + return time_left; + } + +-static void iTCO_wdt_set_running(struct iTCO_wdt_private *p) ++/* Returns true if the watchdog was running */ ++static bool iTCO_wdt_set_running(struct iTCO_wdt_private *p) + { + u16 val; + +- /* Bit 11: TCO Timer Halt -> 0 = The TCO timer is * enabled */ ++ /* Bit 11: TCO Timer Halt -> 0 = The TCO timer is enabled */ + val = inw(TCO1_CNT(p)); +- if (!(val & BIT(11))) ++ if (!(val & BIT(11))) { + set_bit(WDOG_HW_RUNNING, &p->wddev.status); ++ return true; ++ } ++ return false; + } + + /* +@@ -524,9 +528,6 @@ static int iTCO_wdt_probe(struct platform_device *pdev) + return -ENODEV; /* Cannot reset NO_REBOOT bit */ + } + +- /* Set the NO_REBOOT bit to prevent later reboots, just for sure */ +- p->update_no_reboot_bit(p->no_reboot_priv, true); +- + if (turn_SMI_watchdog_clear_off >= p->iTCO_version) { + /* + * Bit 13: TCO_EN -> 0 +@@ -578,7 +579,13 @@ static int iTCO_wdt_probe(struct platform_device *pdev) + watchdog_set_drvdata(&p->wddev, p); + platform_set_drvdata(pdev, p); + +- iTCO_wdt_set_running(p); ++ if (!iTCO_wdt_set_running(p)) { ++ /* ++ * If the watchdog was not running set NO_REBOOT now to ++ * prevent later reboots. ++ */ ++ p->update_no_reboot_bit(p->no_reboot_priv, true); ++ } + + /* Check that the heartbeat value is within it's range; + if not reset to the default */ +-- +2.40.1 +