From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nDPfg-0001Z4-8X for mharc-grub-devel@gnu.org; Fri, 28 Jan 2022 06:44:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDPfe-0001Xz-4m for grub-devel@gnu.org; Fri, 28 Jan 2022 06:44:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44394) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDPfb-0002Kc-Lc for grub-devel@gnu.org; Fri, 28 Jan 2022 06:44:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643370238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hynciIgpBpxik0Ghzy7nSAuuWrBYJ7cTj1LIqPvkvNE=; b=bNZ6BuqTW3y5VhX65YFfFJU1ZfiquU8z0BtXXxpC1sAys371e5oqBKs9JBE4goS5Afa/eU qRFmSakNG40XfWkRWDXYjHm4e4dFLYzK+Qd6ftwMIDWJ7L+SJEdxQNRVslzkumwLM43Nx8 +xU9804ZKb9aLFd+0Nl2evNoDxGJDlI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-344-tHzSPCqbMfSOAJkCTH8LkQ-1; Fri, 28 Jan 2022 06:43:57 -0500 X-MC-Unique: tHzSPCqbMfSOAJkCTH8LkQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B6A983DD20 for ; Fri, 28 Jan 2022 11:43:56 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.193.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 891BC67849; Fri, 28 Jan 2022 11:43:55 +0000 (UTC) From: Hans de Goede To: grub-devel@gnu.org Cc: Robbie Harwood , Hans de Goede Subject: [PATCH 2/2] EFI: console: Do not set cursor until the first text output Date: Fri, 28 Jan 2022 12:43:49 +0100 Message-Id: <20220128114349.87480-2-hdegoede@redhat.com> In-Reply-To: <20220128114349.87480-1-hdegoede@redhat.com> References: <20220128114349.87480-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hdegoede@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Received-SPF: pass client-ip=170.10.133.124; envelope-from=hdegoede@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Jan 2022 11:44:02 -0000 To allow flickerfree boot the EFI console code does not call grub_efi_set_text_mode (1) until some text is actually output. Depending on if the output text is because of an error loading e.g. the .cfg file; or because of showing the menu the cursor needs to be on or off when the first text is shown. So far the cursor was hardcoded to being on, but this is causing drawing artifacts + slow drawing of the menu as reported here: https://bugzilla.redhat.com/show_bug.cgi?id=1946969 Handle the cursorstate in the same way as the colorstate to fix this, when no text has been output yet, just cache the cursorstate and then use the last set value when the first text is output. Fixes: 2d7c3abd871f ("efi/console: Do not set text-mode until we actually need it") Signed-off-by: Hans de Goede --- grub-core/term/efi/console.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c index c44b2ac31..a3622e4fe 100644 --- a/grub-core/term/efi/console.c +++ b/grub-core/term/efi/console.c @@ -31,7 +31,15 @@ typedef enum { } grub_text_mode; +typedef enum { + GRUB_CURSOR_MODE_UNDEFINED = -1, + GRUB_CURSOR_MODE_OFF = 0, + GRUB_CURSUR_MODE_ON +} +grub_cursor_mode; + static grub_text_mode text_mode = GRUB_TEXT_MODE_UNDEFINED; +static grub_cursor_mode cursor_mode = GRUB_CURSOR_MODE_UNDEFINED; static grub_term_color_state text_colorstate = GRUB_TERM_COLOR_UNDEFINED; static grub_uint32_t @@ -119,8 +127,12 @@ grub_console_setcursor (struct grub_term_output *term __attribute__ ((unused)), { grub_efi_simple_text_output_interface_t *o; - if (grub_efi_is_finished) - return; + if (grub_efi_is_finished || text_mode != GRUB_TEXT_MODE_AVAILABLE) + { + /* Cache cursor changes before the first text-output */ + cursor_mode = on; + return; + } o = grub_efi_system_table->con_out; efi_call_2 (o->enable_cursor, o, on); @@ -143,7 +155,8 @@ grub_prepare_for_text_output (struct grub_term_output *term) return GRUB_ERR_BAD_DEVICE; } - grub_console_setcursor (term, 1); + if (cursor_mode != GRUB_CURSOR_MODE_UNDEFINED) + grub_console_setcursor (term, cursor_mode); if (text_colorstate != GRUB_TERM_COLOR_UNDEFINED) grub_console_setcolorstate (term, text_colorstate); text_mode = GRUB_TEXT_MODE_AVAILABLE; -- 2.33.1