From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH 1 of 5] rombios/keyboard: Don't needlessly poll the status register Date: Tue, 27 Nov 2012 17:08:56 +0000 Message-ID: <50B4F3A8.2000908@citrix.com> References: <1728fb78994054ad3695.1353948092@andrewcoop.uk.xensource.com> <20121127163322.GF51942@ocelot.phlegethon.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20121127163322.GF51942@ocelot.phlegethon.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Tim Deegan Cc: "Keir (Xen.org)" , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On 27/11/12 16:33, Tim Deegan wrote: > At 16:41 +0000 on 26 Nov (1353948092), Andrew Cooper wrote: >> Repeated polling of the status register is not going to change its value, so >> don't needlessly take 8192 traps to Qemu when 1 will do. > AFAICS the purpose of this loop is to handle the case where someone's > actually typing at the time. The 0x2000 is intended to make us wait > long enough for the next keypress or autorepeat. > > Reducing the loop to _2_ outb(0x80)s seems strange -- is there some case > in qemu where another character will be presented after 2 delays but not > immediately? The reduction to 2 instead of 1 is because the while loop uses a pre-decrement on max. The patch was chosen at the time to have minimal change to the code. ~Andrew > > If not, can we dispense with 'max' altogether and just have > while ( (inb(0x64) & 0x01) ) { inb(0x60); outb(0x80, 0x00); } > or even > while ( (inb(0x64) & 0x01) ) inb(0x60); > ? > > Tim. > >> Signed-off-by: Andrew Cooper >> >> diff -r 0049de3827bc -r 1728fb789940 tools/firmware/rombios/rombios.c >> --- a/tools/firmware/rombios/rombios.c >> +++ b/tools/firmware/rombios/rombios.c >> @@ -1805,12 +1805,12 @@ keyboard_init() >> while ( (inb(0x64) & 0x02) && (--max>0)) outb(0x80, 0x00); >> >> /* flush incoming keys */ >> - max=0x2000; >> + max=2; >> while (--max > 0) { >> outb(0x80, 0x00); >> if (inb(0x64) & 0x01) { >> inb(0x60); >> - max = 0x2000; >> + max = 2; >> } >> } >> >> >> _______________________________________________ >> Xen-devel mailing list >> Xen-devel@lists.xen.org >> http://lists.xen.org/xen-devel -- Andrew Cooper - Dom0 Kernel Engineer, Citrix XenServer T: +44 (0)1223 225 900, http://www.citrix.com