From nobody Thu May 25 04:34:02 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 4QRZvH0LjDz4CclV; Thu, 25 May 2023 04:34:03 +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 4QRZvG6nZRz49LH; Thu, 25 May 2023 04:34:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684989243; 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=SG/ZIMfYKZP8gM5cKvdMN4GA3CIHEiF581qCibJ4yQo=; b=kjA7Fjv1Xhf484sfgR9j/e0sezDf2y/n8rcAbS03GMJk7PcjG3owMv8a9FYpJOVfWJFmwV 8Xe5j04wlS4K3wfQTvmSxbaFzW9BulHeTQpiHFS91035zQnasAYvw5PEGkC8/M208WJGEn xcWlkgYRKy7MsSX3kzR4GpZZL9qddj8WwLvh/rz01aJZtNhsccZ/tj9srcee5E5yKn4PSY AHcCVkNYj/Kz1JpvTNWuUkOQHsUNy5+HAIdVL6Gv2fCSEEMM3Q1yViPm3m9VnTv6Ytj+WP J6un93dhYmxegnkiO5Lj4fb3lm1BBgVA/6E+1lu4vlNlhCghhj+ZhPkvkkcV0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1684989242; 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=SG/ZIMfYKZP8gM5cKvdMN4GA3CIHEiF581qCibJ4yQo=; b=oo6Sx0n9x0g6ZIreznd1M3O9at191MEa5GhfJBXSszXUoLcawPx3NvyAGx42NGw/Jf4Nv0 Fub4a+eJOlWvGJcDaBQzgxA/DH9VtCJIE/1wBM4OnXEgU7JfGVG1D2svQXLNlFmo/hM6t3 6Av1d0GT+oUh+ITvY6vfaUkvvaY9XzMnJorg90yibQoiJT0OHHzGSSWRHhvcnAFuiK3zQr Xqi3RoQH3hl/8ln6KFMM37jZ/epktAXcOP0PPSLc1Zm/iVp/dhg2ECGI/aZ5AifxVXZG0L FnhRSKo4ugQZDNyeI/H4AlBWDkhDWzz1Ul4Bec9K08B7m9U0Tc8n9vAyV4+OfA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1684989243; a=rsa-sha256; cv=none; b=J0eZJ4Anz8jO8Fx0w4LK6MvNShojpHtE2Vfb1TQiO3JQtZbALDctv28VtCk8Oyg+29lMEz DX+alFza+OS+rCkWIYR+wY8a9wbRE4RbS7wlwTakln5aA+HgYPMjVJb8iWg/RkHOfb8ivs 55SZ8LsQlH3B8IzbN1uqHh0TcVI5Yp8NBu6h73Q8sD3Ripp1HfBsJucLtABvpqTBuYxGid ErAHMcluvmeALOL0dconGFfI1eOAG9/aC+Vn6N2qTenX6TLmu6b7d+js2r3ytsEg3eYx22 J11tBae8TvpEjX51X4fBwvQZskgb6ZliKtyPJuVmSaZ+LvNXDvSOy7EPbmf5ow== 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 4QRZvG5NWPz19X7; Thu, 25 May 2023 04:34:02 +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 34P4Y22j089279; Thu, 25 May 2023 04:34:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34P4Y2On089278; Thu, 25 May 2023 04:34:02 GMT (envelope-from git) Date: Thu, 25 May 2023 04:34:02 GMT Message-Id: <202305250434.34P4Y2On089278@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: f28dff43ad62 - main - stand/efi/eficom: better handling of absent device 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: f28dff43ad62ee7396abde1f8449ead1ece98053 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=f28dff43ad62ee7396abde1f8449ead1ece98053 commit f28dff43ad62ee7396abde1f8449ead1ece98053 Author: Warner Losh AuthorDate: 2023-05-24 22:34:31 +0000 Commit: Warner Losh CommitDate: 2023-05-25 04:33:53 +0000 stand/efi/eficom: better handling of absent device Don't even have a comc_port when the port doesn't exist: always free it if we probe that it's not there. Also, when it's not present, clear the flags indicating presence to avoid disturbing other flags. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D40220 --- stand/efi/libefi/eficom.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/stand/efi/libefi/eficom.c b/stand/efi/libefi/eficom.c index b1c84399a05d..ca08458c2ca2 100644 --- a/stand/efi/libefi/eficom.c +++ b/stand/efi/libefi/eficom.c @@ -332,9 +332,12 @@ comc_probe(struct console *sc) env_setenv("efi_com_speed", EV_VOLATILE, value, comc_speed_set, env_nounset); - eficom.c_flags = 0; if (comc_setup()) { sc->c_flags = C_PRESENTIN | C_PRESENTOUT; + } else { + sc->c_flags &= ~(C_PRESENTIN | C_PRESENTOUT); + free(comc_port); + comc_port = NULL; } } @@ -349,14 +352,20 @@ comc_probe_compat(struct console *sc) } #endif +/* + * Called when the console is selected in cons_change. If we didn't detect the + * device, comc_port will be NULL, and comc_setup will fail. It may be called + * even when the device isn't present as a 'fallback' console or when listed + * specifically in console env, so we have to reset the c_flags in those case to + * say it's not present. + */ static int comc_init(int arg __unused) { - if (comc_setup()) return (CMD_OK); - eficom.c_flags = 0; + eficom.c_flags &= ~(C_ACTIVEIN | C_ACTIVEOUT); return (CMD_ERROR); } @@ -516,8 +525,10 @@ comc_setup(void) EFI_STATUS status; char *ev; - /* port is not usable */ - if (comc_port->sio == NULL) + /* + * If the device isn't active, or there's no port present. + */ + if ((eficom.c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) == 0 || comc_port == NULL) return (false); if (comc_port->sio->Reset != NULL) {