From nobody Thu Mar 28 13:38:40 2024 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=1621015420; cv=none; d=zohomail.com; s=zohoarc; b=ARR7D13KJN1xzLUEhM1QSwQPJk+EARFRKCJGQOYWXQtPAjSMWirRD/Nw/+UVSdXwNyFv202ymQJZy6yQPXcAac/XGkkvMdUtvtmFxqOcvmIeg3bS2YnI6WFBjbAOoCrsEiRbV+fIXvGSmCmgyFDMXbG2pMUt9FMsdqftDYcebmg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1621015420; h=Content-Type:Content-Transfer-Encoding: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=tnljSC6uisKvuuHysaJDxSt2LDHXYfUlnAe1VOQWDv4=; b=Fk1gxc5YeMv05+j800Jsrc2bqW3zKx3V454sBvzHvsTyfYkJmTOHbArH8ELqOcEaWuFk1SyZIJjECrKnmLEVXb9Trhs3fMGg+tD4NOqjG82h0lnAruAR8dNEp+DhdOycpzkfM4tJPD2WEEK9l3Wi5dAFpc0det0qYSEmI8RBXCE= 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 1621015420445328.86999285116303; Fri, 14 May 2021 11:03:40 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTPA id E9AAF16A09D3; Fri, 14 May 2021 18:03:35 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by coreboot.org (Postfix) with ESMTP id C563116A09C0 for ; Fri, 14 May 2021 18:03:23 +0000 (UTC) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by mailout01.t-online.de (Postfix) with SMTP id 16EE68F124 for ; Fri, 14 May 2021 20:03:23 +0200 (CEST) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1lhc9g-1z7miW0; Fri, 14 May 2021 20:03:20 +0200 Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) id 755222000A1; Fri, 14 May 2021 20:03:20 +0200 (CEST) From: =?UTF-8?q?Volker=20R=C3=BCmelin?= To: seabios@seabios.org Date: Fri, 14 May 2021 20:03:20 +0200 Message-Id: <20210514180320.15848-1-vr_qemu@t-online.de> In-Reply-To: References: MIME-Version: 1.0 X-ID: VsjegcZlwhB8b7oSdgyXFKZxdvtm-agLcz1tj2MNslFTo70d8QkmKuu0ZjG1mA0ZnO X-TOI-EXPURGATEID: 150726::1621015401-00000BA7-B895E1AA/0/0 CLEAN NORMAL X-TOI-MSGID: f061e677-0d62-44d3-9d2b-c78972cb1719 Message-ID-Hash: 7MRRXS3C76EMF7N7435I4GRR7XLCLOSV X-Message-ID-Hash: 7MRRXS3C76EMF7N7435I4GRR7XLCLOSV 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 X-Mailman-Version: 3.3.4b1 Precedence: list Subject: [SeaBIOS] [PATCH] stacks: always call check_irqs() in yield() 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. Currently this is only true if seabios was built without CONFIG_THREADS or if yield() is called from the main thread. Change the code to always call check_irqs() in yield(). 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_KBD_DISABLE, NULL); # 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 | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/stacks.c b/src/stacks.c index 2fe1bfb..70e8283 100644 --- a/src/stacks.c +++ b/src/stacks.c @@ -623,9 +623,25 @@ yield(void) return; } struct thread_info *cur =3D getCurThread(); - if (cur =3D=3D &MainThread) - // Permit irqs to fire + struct thread_info *mt =3D &MainThread; + + // Permit irqs to fire + if (cur =3D=3D mt) { check_irqs(); + } else { + asm volatile( + " pushl %%ebp\n" // backup %ebp + " movl %%esp, %%esi\n" + " movl (%%eax), %%esp\n" // switch to MainThread stack + " pushl %%esi\n" // backup current thread stack poi= nter + " calll %1\n" // check_irqs(); + " popl %%esi\n" + " movl %%esi, %%esp\n" // switch back to current thread s= tack + " popl %%ebp\n" // restore %ebp + : "+a"(mt) + : "m"(check_irqs) + : "ebx", "ecx", "edx", "esi", "edi", "cc", "memory"); + } =20 // Switch to the next thread switch_next(cur); --=20 2.26.2 _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-leave@seabios.org