From nobody Tue Mar 3 09:53:14 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) client-ip=78.46.105.101; envelope-from=seabios-bounces@seabios.org; helo=coreboot.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org ARC-Seal: i=1; a=rsa-sha256; t=1622574437; cv=none; d=zohomail.com; s=zohoarc; b=iOcvkvPm1lTVLcNMPqzV57eZjp3yT9FCPGBETnz3TUTXRfYGLjGuXeQbYFpT91cF5dk8sX7skED6hFDFhqXZv4Hin0tuOgH+M6f28wqdEavDz0C1Q0cJfF1cc/nkxPgl5b8Z0QsAIfXZk/37BJCHjcENru8HwJhp7cVSCYBtucI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622574437; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Subject:To; bh=5mvVSY4J7WGMDlrY8fI4bpvsizbaVq0qVBJHV9d75uY=; b=kfDRyOYAWFTPUcXqU3GppGpGJ5I8/ncQB1GR/nte4R1goz6YgG58d8HX/UMgyQ8NhScr4UooY6wvg/wgqQEBCkcOWxYzyiiRmE9Em8bzuK7D4QjdhYRp5f/0RZQaiKttYT3USwKUm/mB8eg9hIv2oPMqt+fezYEqzfGhgqiy8Yc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of seabios.org designates 78.46.105.101 as permitted sender) smtp.mailfrom=seabios-bounces@seabios.org Return-Path: Received: from coreboot.org (coreboot.org [78.46.105.101]) by mx.zohomail.com with SMTPS id 1622574437669115.13117809241305; Tue, 1 Jun 2021 12:07:17 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id 19F3510619E5; Tue, 1 Jun 2021 19:07:14 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id 6394910619D6 for ; Tue, 1 Jun 2021 19:07:00 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by mailout08.t-online.de (Postfix) with SMTP id 1B9F870377; Tue, 1 Jun 2021 21:07:00 +0200 (CEST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1lo9j9-1JY6G80; Tue, 1 Jun 2021 21:06:59 +0200 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id 3C0932000A1; Tue, 1 Jun 2021 21:06:56 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: Kevin O'Connor Date: Tue, 1 Jun 2021 21:06:55 +0200 Message-Id: <20210601190656.7162-2-vr_qemu@t-online.de> In-Reply-To: <6bff0709-f229-c180-e91f-52c7c3fea5ac@t-online.de> References: <6bff0709-f229-c180-e91f-52c7c3fea5ac@t-online.de> MIME-Version: 1.0 X-ID: V+DXMaZQ8hvXlIp7BvpFQ+75mzVrxRkEgJSNMtd72dlfGcuAms4kxAp+Rdmq1UHQKi X-TOI-EXPURGATEID: 150726::1622574419-0001611E-4CBD5E0E/0/0 CLEAN NORMAL X-TOI-MSGID: cad4af00-f878-4f50-895e-cd46bb0ffddf Message-ID-Hash: OAVPB7IJ56TFDQ5WBGJQZFRQW74WNLO5 X-Message-ID-Hash: OAVPB7IJ56TFDQ5WBGJQZFRQW74WNLO5 X-MailFrom: volker.ruemelin@t-online.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-seabios.seabios.org-0; header-match-seabios.seabios.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: seabios@seabios.org X-Mailman-Version: 3.3.4 Precedence: list Subject: [SeaBIOS] [PATCH v3 2/3] stacks: call check_irqs() in run_thread() List-Id: SeaBIOS mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Authentication-Results: coreboot.org; auth=pass smtp.auth=mailman@coreboot.org smtp.mailfrom=seabios-bounces@seabios.org X-Spamd-Bar: --- The comment above the yield() function suggests that yield() allows interrupts for a short time. But yield() only briefly enables interrupts if seabios was built without CONFIG_THREADS or if yield() is called from the main thread. In order to guarantee that the interrupts were enabled once before yield() returns in a background thread, the main thread must call check_irqs() before or after every thread switch. The function run_thread() also switches threads, but the call to check_irqs() was forgotten. Add the missing check_irqs() call. This fixes PS/2 keyboard initialization failures. The code in src/hw/ps2port.c relies on yield() to briefly enable interrupts. There is a comment above the yield() function in __ps2_command(), where the author left a remark why the call to yield() is actually needed. Here is one of the call sequences leading to a PS/2 keyboard initialization failure. ps2_keyboard_setup() | ret =3D i8042_command(I8042_CMD_CTL_TEST, param); # This command will register an interrupt if the PS/2 device # controller raises interrupts for replies to a controller # command. | ret =3D ps2_kbd_command(ATKBD_CMD_RESET_BAT, param); | ps2_command(0, command, param); | ret =3D __ps2_command(aux, command, param); | // Flush any interrupts already pending. yield(); # yield() doesn't flush interrupts if the main thread # hasn't reached wait_threads(). | ret =3D ps2_sendbyte(aux, command, 1000); # Reset the PS/2 keyboard controller and wait for # PS2_RET_ACK. | ret =3D ps2_recvbyte(aux, 0, 4000); | for (;;) { | status =3D inb(PORT_PS2_STATUS); # I8042_STR_OBF isn't set because the keyboard self # test reply is still on wire. | yield(); # After a few yield()s the keyboard interrupt fires # and clears the I8042_STR_OBF status bit. If the # keyboard self test reply arrives before the # interrupt fires the keyboard reply is lost and # ps2_recvbyte() returns after the timeout. } Signed-off-by: Volker R=C3=BCmelin --- src/stacks.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/stacks.c b/src/stacks.c index ef0aba1..58c0317 100644 --- a/src/stacks.c +++ b/src/stacks.c @@ -549,6 +549,8 @@ __end_thread(struct thread_info *old) dprintf(1, "All threads complete.\n"); } =20 +void VISIBLE16 check_irqs(void); + // Create a new thread and start executing 'func' in it. void run_thread(void (*func)(void*), void *data) @@ -587,6 +589,9 @@ run_thread(void (*func)(void*), void *data) : "0"(data), "1"(func), "2"(thread), "3"(cur), "m"(*(u8*)__end_thread), "m"(MainThread) : "esi", "edi", "cc", "memory"); + if (cur =3D=3D &MainThread) + // Permit irqs to fire + check_irqs(); return; =20 fail: --=20 2.26.2 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org