From nobody Mon Feb 06 19:36:58 2023 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 4P9c2y6r6Nz3n631; Mon, 6 Feb 2023 19:36:58 +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 4P9c2y6B4rz3pcR; Mon, 6 Feb 2023 19:36:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675712218; 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=mU0COFoQcbmVC6F4GxUYVcn22wdYMLF0TnzDLMHjKnY=; b=ksDND9zxU01BmGl/qmIq/p+qkmk6+j+MwuDelaLbwh7TByJ7jbCGZfSYs8geZl4WXm8VwG echnws+asOYK47GdqgVQqFTEYBkCqWZLfdlu8IQCAZ97YITL4/hQxDmDDUTEa2eiKJKnBh uPGsxF9oeEMO+yPGt3y0A6QZZvWB0DMCvptt7cpscGFzNhvdWIkJUvMrgBVQ8qlH+z17Yt GVOvdP6Huc+bU6LHj30RYG062EzEf1E0u9/9QxENVeTGs0+IS5cdfexpzFnDn6BobYzsse DIWRzh7eEwtlbInxfIjuKbcurQ46z2qnJaJbC+873zmjZScEuX2RAFAJ1Q6tIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675712218; 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=mU0COFoQcbmVC6F4GxUYVcn22wdYMLF0TnzDLMHjKnY=; b=Sme/niQZYK529LqFoAPA3EB2swDnmp+nPQsMTf3Tbz5+bX7o/B7o2tHLx1DZff6Y17BkpH FeGO82CvO/0tuWtaMPM1OzTPWpyz7R5cfcWNcLB588fbtHUtzVqSSICGOfAIbnP3YW2yue JimjObyJMhbviqNB/7jt1yXwEfTqX53i1PS+fHAJfZUSI8n/bCdxgSM1AIbMffVz7EU8Hk Fac8h4Lvh7UNsiTmctZtPZAh0D0n1QVqJWgrlPikiGa64sHEXP5e2ttYCqedEHFvTQ4VZF SELa2eb/U6lifXzKQENuk8phEZPtbd+RM1zpDDZUhL42vyB7CwlE+duJZN+u2Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675712218; a=rsa-sha256; cv=none; b=vPMLtZrx2Y2ZNbsohLnyspvxuGDlkmqWN6Pla7PLr0TbieehVwAshJ5D190Umk4AenMF2N zPLOR3EtKCTSu8+r63EiJffqhVWGSbpLJPx4nVUPGyYO+I1OYNuipSBl02dt7cdXZfiTDK U9mS1dm33Tb3uoFI+rbzvuFNcDlfwL7uMAYTEy1aORnY7LKg3jjvkIOSdXqOLJ8hsGungI WNIUqLLphO62ShalSFQD+EBTpd7hk4UYGz9O47kYJgAmWyECMTLe2Zco76Uazj/l7+Bd9H BkT2tEczLxLRYNRajnQwa7tQITvJbcuKzCu0zS12Vxz3iU82mkJt6Gi8aHOHMg== 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 4P9c2y4yjRzn0r; Mon, 6 Feb 2023 19:36:58 +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 316JawiS020463; Mon, 6 Feb 2023 19:36:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 316JawJR020462; Mon, 6 Feb 2023 19:36:58 GMT (envelope-from git) Date: Mon, 6 Feb 2023 19:36:58 GMT Message-Id: <202302061936.316JawJR020462@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: f0e49ab720d3 - stable/13 - ddb: have 'reset' command use normal reboot path 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: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f0e49ab720d3bc71f82dc1e73db4047f3a03defb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=f0e49ab720d3bc71f82dc1e73db4047f3a03defb commit f0e49ab720d3bc71f82dc1e73db4047f3a03defb Author: Mitchell Horne AuthorDate: 2023-01-07 18:09:28 +0000 Commit: Mitchell Horne CommitDate: 2023-02-06 19:34:37 +0000 ddb: have 'reset' command use normal reboot path This conditionally gives all registered shutdown handlers a chance to perform the reboot, with cpu_reset() being the fallback. The '\s' modifier can be used with the command to get the previous behaviour. The motivation is that some platforms may not be able do anything meaningful via cpu_reset(), due to a lack of standardized reset mechanism and/or firmware shortcomings. However, they may have a separate device driver attached that normally performs the reboot. Such is the case for some versions of the Raspberry Pi, where reset via PSCI fails, but the BCM2835 watchdog driver has a shutdown hook. Reported by: bz Reviewed by: markj (slightly earlier version) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D37981 (cherry picked from commit 5644850620aead7c257a4e3040e20201b510f499) --- share/man/man4/ddb.4 | 14 ++++++++++++-- sys/ddb/db_command.c | 14 +++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/share/man/man4/ddb.4 b/share/man/man4/ddb.4 index db5b59f4e8f0..8ef78cc8b156 100644 --- a/share/man/man4/ddb.4 +++ b/share/man/man4/ddb.4 @@ -524,13 +524,23 @@ The optional argument limits the search. .\" .Pp -.It Ic reboot Op Ar seconds -.It Ic reset Op Ar seconds +.It Xo +.Ic Ic reboot Ns Op Li / Ns Cm s +.Op Ar seconds +.Xc +.It Xo +.Ic Ic reset Ns Op Li / Ns Cm s +.Op Ar seconds +.Xc Hard reset the system. If the optional argument .Ar seconds is given, the debugger will wait for this long, at most a week, before rebooting. +When the +.Cm s +modifier is given, the command will skip running any registered shutdown +handlers and attempt the most basic reset. .Pp .It Ic thread Ar addr | tid Switch the debugger to the thread with ID diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index 28c7faee670b..ae983c46df8d 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -729,7 +729,7 @@ out: static void db_reset(db_expr_t addr, bool have_addr, db_expr_t count __unused, - char *modif __unused) + char *modif) { int delay, loop; @@ -754,6 +754,18 @@ db_reset(db_expr_t addr, bool have_addr, db_expr_t count __unused, } } + /* + * Conditionally try the standard reboot path, so any registered + * shutdown/reset handlers have a chance to run first. Some platforms + * may not support the machine-dependent mechanism used by cpu_reset() + * and rely on some other non-standard mechanism to perform the reset. + * For example, the BCM2835 watchdog driver or gpio-poweroff driver. + */ + if (modif[0] != 's') { + kern_reboot(RB_NOSYNC); + /* NOTREACHED */ + } + cpu_reset(); }