From nobody Tue Feb 01 08:12:50 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D19DE19AF506; Tue, 1 Feb 2022 08:12:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JnyNL4fNRz3jZR; Tue, 1 Feb 2022 08:12:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643703170; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AXyVFLZGrgCKMPlpjRjOPyR3699gkFZiT04rBPkFe9c=; b=CXdtZkyBZOzDry2ojtrWqNviSRBaTDGcSkj8nJa12wvq7kvOTBk6adtNepzDKXdbvEmn8R 0jGY6llrn4f+n5ODExWpOAA56VQrHDXEPYu5fJ8UljpJ97rKmIN0nCbY/kc97z4XZZOpVb YoZNjXugVTTXSxM8m5cdHSvFkqd1IrTjKgzGpjS2XooImpFQDtDrfqGOkMJpqLzbz/4e1y gfTCVsl904Hfnr7lWrj4ZX6hfPZNJCw4giSnqexyUCRZwGydSA+JD1JU4DzZNu07mwXGrJ f1y0cJBr3NrUes+S6jTO4yN32JpJXiQ9k7Z4GWaqi9WreYvcWklsNx+Ly8M2Yw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 77EC74D40; Tue, 1 Feb 2022 08:12:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2118CoAD075996; Tue, 1 Feb 2022 08:12:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2118Co5k075994; Tue, 1 Feb 2022 08:12:50 GMT (envelope-from git) Date: Tue, 1 Feb 2022 08:12:50 GMT Message-Id: <202202010812.2118Co5k075994@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andriy Gapon Subject: git: 08bc6b60c354 - stable/13 - dwwdt: make it actually useful List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: avg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 08bc6b60c3547b6a4bf5a812739b8401dabbda16 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643703170; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=AXyVFLZGrgCKMPlpjRjOPyR3699gkFZiT04rBPkFe9c=; b=p8C37z02iROVha9Wnz4wVIG+vAEJArnmBwv5gZvjyTVyNjYLWkNqT14No3D/XWMe8ht+0d JO0RAFeHp6nv9BdBdaVnVTItRHzd6bbZpugu4TwsH5iUCp8VQrUuDCrnBGZlYoVk8vZdaX bm3JnYllfmsBfCCX6AYjnAW4YmFEe4JszDP+0keU0X7QzRyvtTG9pgXcmZUidQaV5z/Rj6 vRxs2o1Qz0DcOKJ4EFlELemR/xbo/G6yp4WNf58fqLH8BzEa8WK8EdkKA3txAfKLNaRmFi BhyapcT+vODTUn2jnyGn28wQC9LXGgH/etJSqfRikeStWxXCyoO3WKKzjlmo1Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643703170; a=rsa-sha256; cv=none; b=cije0KZlu+8uNq3shD74uJj69mqXup4U8t83uLA0mJ1lIFNfw6279MW9i3y3c6YLC4Q+3/ gt9aHavDDprjYaV6fmYb0VKvZ6BbEEtEU0tZAvQWTUF2iqjDvqwIEvhzAfuEOo+9qqgbDx 3sJBaIyTDz0zZNaeUykxu5oNmrfaKjyHKF0c8b/EHO5eT7uzW9IdUrF6iw48ii2Ya8Z4h/ 3t4mfBU8DwxTRKQhAO94+Os+Hoip/0etSSgrmKkHA/g+KjXVBrx5Jbt3CM2qO8MgRbUW3J XJDjqWTfOrx93ULotv4pwe+Z98CPv+CuIINTnPXfJOmdiGDX/k2ppvvCL1pNfA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by avg: URL: https://cgit.FreeBSD.org/src/commit/?id=08bc6b60c3547b6a4bf5a812739b8401dabbda16 commit 08bc6b60c3547b6a4bf5a812739b8401dabbda16 Author: Andriy Gapon AuthorDate: 2022-01-11 13:56:07 +0000 Commit: Andriy Gapon CommitDate: 2022-02-01 08:11:26 +0000 dwwdt: make it actually useful Flip dwwdt_prevent_restart to false. What's the use of a watchdog if it does not restart a hung system? Add a knob for panic-ing on the first timeout, resetting on the second one. This can be useful if interrupts can still work, otherwise a reset recovers a system without any aid for debugging the hang. The change also doubles the timeout that's programmed into the hardware. The previous version of the code always had the interrupt on the first timeout enabled, but it took no action on it. Only the second timeout could be configured to reset the system. So, the hardware timeout was set to a half of the user requested timeout. But now,we can take a corrective action on the first timeout, so we use the user requested timeout. While here, define boolean sysctl-s as such. (cherry picked from commit ee900888c42f12f7ccf73e5a320446da4661a0e9) --- sys/dev/dwwdt/dwwdt.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/sys/dev/dwwdt/dwwdt.c b/sys/dev/dwwdt/dwwdt.c index 4eab26ef2915..5cc20c3c9d2f 100644 --- a/sys/dev/dwwdt/dwwdt.c +++ b/sys/dev/dwwdt/dwwdt.c @@ -93,15 +93,20 @@ static struct ofw_compat_data compat_data[] = { SYSCTL_NODE(_dev, OID_AUTO, dwwdt, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "Synopsys Designware watchdog timer"); -/* Setting this to 0 enables full restart mode. */ -static uint32_t dwwdt_prevent_restart = 1; -SYSCTL_UINT(_dev_dwwdt, OID_AUTO, prevent_restart, CTLFLAG_RW | CTLFLAG_MPSAFE, - &dwwdt_prevent_restart, 1, - "Prevent system restart (0 - Disabled; 1 - Enabled)"); -static uint32_t dwwdt_debug_enabled = 0; -SYSCTL_UINT(_dev_dwwdt, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_MPSAFE, - &dwwdt_debug_enabled, 1, "Debug mode (0 - Disabled; 1 - Enabled)"); +/* Setting this to true disables full restart mode. */ +static bool dwwdt_prevent_restart = false; +SYSCTL_BOOL(_dev_dwwdt, OID_AUTO, prevent_restart, CTLFLAG_RW | CTLFLAG_MPSAFE, + &dwwdt_prevent_restart, 0, "Disable system reset on timeout"); + +static bool dwwdt_debug_enabled = false; +SYSCTL_BOOL(_dev_dwwdt, OID_AUTO, debug, CTLFLAG_RW | CTLFLAG_MPSAFE, + &dwwdt_debug_enabled, 0, "Enable debug mode"); + +static bool dwwdt_panic_first = true; +SYSCTL_BOOL(_dev_dwwdt, OID_AUTO, panic_first, CTLFLAG_RW | CTLFLAG_MPSAFE, + &dwwdt_panic_first, 0, + "Try to panic on timeout, reset on another timeout"); static int dwwdt_probe(device_t); static int dwwdt_attach(device_t); @@ -181,13 +186,17 @@ dwwdt_intr(void *arg) KASSERT((DWWDT_READ4(sc, DWWDT_STAT) & DWWDT_STAT_STATUS) != 0, ("Missing interrupt status bit?")); - if (dwwdt_prevent_restart != 0 || sc->sc_status == DWWDT_STOPPED) { + if (dwwdt_prevent_restart || sc->sc_status == DWWDT_STOPPED) { /* * Confirm interrupt reception. Restart counter. * This also emulates stopping watchdog. */ (void)DWWDT_READ4(sc, DWWDT_EOI); + return; } + + if (dwwdt_panic_first) + panic("dwwdt pre-timeout interrupt"); } static void @@ -199,7 +208,7 @@ dwwdt_event(void *arg, unsigned int cmd, int *error) int val; timeout = cmd & WD_INTERVAL; - val = MAX(0, timeout + exponent - DWWDT_EXP_OFFSET); + val = MAX(0, timeout + exponent - DWWDT_EXP_OFFSET + 1); dwwdt_stop(sc); if (cmd == 0 || val > 0x0f) { @@ -341,7 +350,7 @@ dwwdt_shutdown(device_t dev) sc = device_get_softc(dev); /* Prevent restarts during shutdown. */ - dwwdt_prevent_restart = 1; + dwwdt_prevent_restart = true; dwwdt_stop(sc); return (bus_generic_shutdown(dev)); }