From nobody Mon Jan 23 19:11:27 2023 X-Original-To: dev-commits-src-main@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 4P107z2sbQz3b9Ps; Mon, 23 Jan 2023 19:11:27 +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 4P107z231Vz4F5k; Mon, 23 Jan 2023 19:11:27 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674501087; 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=BgeXMJFYykAkBbFdzi8vQ6EkcMJ9u6EZzo9f5rVoLAw=; b=CvQV3vGt6h7utBLt7MaNb8iBHOYy2fk3MKa2zTy9hrCl7F3QbDDCWYsjCY0aiQz0wo2PjK bAIp0yAKVnWCiL74A+IWYM6To2du2w6f+ojvG0Kn3ynzQh3WPfLHxtMo7ajmh5ofmlNoay hS9QkEyiEktVdN/M3iifMQ+Gi3kYFw9wkVkL4I4+87h4t/RtTvBfwWcc5GltzGhW9kJI4C WwDoMjXIk12kd8F+VeEiYyy+1yWmWyiiwr9JXr3qnAOVlQxjj2rXhvFIDYObtNRUjPj494 EiD/0eAJhWnYz7uEtLeJZKaHXSbgW9NTWEv34NVwe89LgyIHg3p3FDwqr5IWSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674501087; 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=BgeXMJFYykAkBbFdzi8vQ6EkcMJ9u6EZzo9f5rVoLAw=; b=AHv1Y1gy58LGw2i0WTWI/N1WwwS76g+FTiXhdH9Bqnfxl9YuAE86WSTGBiTbj6gi9/B8+r NClMv36oVFc3e18PbF7DD7ai5tDqV+lF3IftIgBPRwq60Pjj7WdBpWTnMJMSkohyJRFbZT 5g4HiNgRxkU8psnC7k6mhl3/DRFOyYtcO6/ZA/4AAVAkESw7S4lIXecfBrrci5MzAUMKLc sOTATeOvt7Nd5/XJkC1SH+np0oM2EcjirddDLjZxgY2iZLGcYbaJxBrrRImQpJvZ4pH7zO yv7mRPgt1x+nput0jqu0EvxXigdFy4GB0SEv1aXKlGW88144hMxhdf1zviY/IQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674501087; a=rsa-sha256; cv=none; b=t6q3SWlWKpdNWwKtLkWMlldL5h6WW1C5A9VEtBt9/SlaRTkf2yOigulMfDLG7Pjb8e+1rW 1EAYm8HKoS9+Saml7KFeXQ7xh912w/jwk9l+S2rZW9M4iXEBZwnmX7Encx57hxJKGI71XY gFfXq2NFmVxW380t2pkrIszDp2/1J4FABa7yFZ4WH2t6Pd/Jo+GzV3ap2j17WQOdHsKT3D Wod6ehd2kvLGyBYou4l7LQTUmDvzsGBFSt23SftPTnxTJhdmkid6V9C5anKWSZdZVgYwtd FKIzYchinXIFwxt1Xm7+1sirS+8FibYRh/+2nAKnQHWAmwkY+Um7wM7VTCo8Zw== 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 4P107z11y6zgcl; Mon, 23 Jan 2023 19:11:27 +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 30NJBRUh057047; Mon, 23 Jan 2023 19:11:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30NJBRaE057046; Mon, 23 Jan 2023 19:11:27 GMT (envelope-from git) Date: Mon, 23 Jan 2023 19:11:27 GMT Message-Id: <202301231911.30NJBRaE057046@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mitchell Horne Subject: git: 5644850620ae - main - ddb: have 'reset' command use normal reboot path List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 5644850620aead7c257a4e3040e20201b510f499 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=5644850620aead7c257a4e3040e20201b510f499 commit 5644850620aead7c257a4e3040e20201b510f499 Author: Mitchell Horne AuthorDate: 2023-01-07 18:09:28 +0000 Commit: Mitchell Horne CommitDate: 2023-01-23 19:10:24 +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 --- 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 7d5da91fc684..7173da4eb447 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 0ddbf5f49629..02f79ca949c2 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -745,7 +745,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; @@ -770,6 +770,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(); }