public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jaco Kroon <jaco@kroon.co.za>
To: Linus Torvalds <torvalds@osdl.org>
Cc: sebekpi@poczta.onet.pl, Vojtech Pavlik <vojtech@suse.cz>,
	Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org
Subject: Re: i8042 access timings
Date: Thu, 27 Jan 2005 22:51:38 +0200	[thread overview]
Message-ID: <41F9545A.4080803@kroon.co.za> (raw)
In-Reply-To: <Pine.LNX.4.58.0501270948280.2362@ppc970.osdl.org>

Linus Torvalds wrote:
> 
> On Thu, 27 Jan 2005, Jaco Kroon wrote:
> 
>>Which indicates (as far as my understanding goes) that the command times 
>>out, as such the param value stays the same (ready for re-use in the 
>>second command).  The second commands succeeds but does not return one 
>>of the expected (0x00, 0xff, 0xfa) values, instead it returns the value 
>>as expected by the first command (0xa5).  The last value on both lines 
>>is the return value.  From the second snippet:
> 
> 
> No, I think the 0x5a you see is the 0x5a that is _still_ there, because we 
> never got any reply at all from the i8042_command(I8042_CMD_AUX_LOOP) 
> case, nor did the I8042_CMD_AUX_TEST thing do anything at all.

I suspect I didn't explain clearly.  Note that the outer test expects a 
0xa5 (we pass 0x5a in).  That is what made me suspect that the second 
request gets the first ones return value.

> 
> I have a suspicion: these commands are also one of the few ones that write 
> a data byte to the data port immediately after writing the command byte to 
> the status port.
Yes.  The commands that write something is:

CTL_WCTR
KBD_LOOP (I quess this is what breaks if no USB1.1 present in kernel)
AUX_SEND (obviously)
AUX_LOOP (the one that we think is breaking)
MIX_SEND (obviously).

All of them send exactly one byte.

> 
> It so happens that if the hardware is slow to reach to the command byte,
> we might read the status word _before_ the hardware has had time to even
> say "ok, my input port is now full". We have a "udelay()" there in
> i8042_wait_write(), but we have it _after_ we've done the 
> i8042_read_status(), so effectively the i8042_read_status() happens 
> immediately after the i8042_write_command().
Hmm, just an idea, shouldn't the i8042_write_command be waiting until 
the device has asserted the pin to indicate that the buffer is busy? 
Ie, some nice and tight loop.  This has the downside that if we check 
_just before_ the pin gets asserted, then delay and check again _after_ 
it has been cleared we will deadlock.  So the udelay() before the loop 
(or rewriting the loop to do{}while(...)) is probably a better solution, 
although this will cause us to _always_ wait at least 50 microseconds 
(not that that is a long time).

> So what _might_ happen is that we write the command, and then 
> i8042_wait_write() thinks that there is space to write the data 
> immediately, and writes the data, but now the data got lost because the 
> buffer was busy.
This makes a lot of sense.

> 
> The IO delay should be _before_ the read of the status, not after it.
> 
> So how about adding an extra "udelay(50)" to either the top of 
> i8042_wait_write(), or to the bottom of "i8042_write_command()"? Does that 
> make any difference?
No.  No difference, still the same result.

> 
> (50 usec is probably overkill, and an alternative is to just make the
> write_data/write_command inline functions in i8042-io.h use the
> "inb_p/outb_p" versions that put a serializing IO instruction in between,
> which should give you a nice 1us delay even on modern hardware.)
ok, how would I try this?  Where can I find an example to code it from? 
  Sorry, I should probably be grepping ...

Jaco
-- 
There are only 10 kinds of people in this world,
   those that understand binary and those that don't.
http://www.kroon.co.za/

  parent reply	other threads:[~2005-01-27 20:58 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200501260040.46288.sebekpi@poczta.onet.pl>
2005-01-27  6:23 ` i8042 access timings Jaco Kroon
2005-01-27 10:25   ` Vojtech Pavlik
2005-01-27 11:12     ` Sebastian Piechocki
2005-01-27 11:31       ` Vojtech Pavlik
2005-01-27 17:33         ` Jaco Kroon
2005-01-27 18:09   ` Linus Torvalds
2005-01-27 20:29     ` Andries Brouwer
2005-01-27 20:41       ` Dmitry Torokhov
2005-01-27 23:11         ` Andries Brouwer
2005-01-28 13:17       ` Vojtech Pavlik
2005-01-28 14:20         ` Jaco Kroon
2005-01-28 18:39           ` Vojtech Pavlik
2005-01-29 19:59             ` Jaco Kroon
2005-01-29 23:21               ` Dmitry Torokhov
2005-01-29 20:02             ` Randy.Dunlap
2005-01-27 20:51     ` Jaco Kroon [this message]
2005-01-27 21:17       ` Linus Torvalds
2005-01-27 22:12         ` Jaco Kroon
2005-01-27 22:36           ` Linus Torvalds
2005-01-27 23:40             ` Dmitry Torokhov
2005-01-28  5:52             ` Jaco Kroon
2005-02-04 19:54             ` Bukie Mabayoje
2005-01-28 11:04           ` Vojtech Pavlik
2005-01-27 20:23   ` Andries Brouwer
2005-01-25  7:41 Dmitry Torokhov
2005-01-25 10:51 ` Andries Brouwer
2005-01-25 19:17   ` Dmitry Torokhov
2005-01-25 19:25     ` Vojtech Pavlik
2005-01-25 19:41       ` Dmitry Torokhov
2005-01-25 19:46     ` Andries Brouwer
2005-01-25 20:37       ` Lee Revell
2005-01-27 15:14         ` Alan Cox
2005-01-27 16:24           ` Vojtech Pavlik
2005-01-27 16:34           ` Bill Rugolsky Jr.
2005-01-27 16:37             ` Vojtech Pavlik
2005-02-13  0:16               ` Bill Rugolsky Jr.
2005-02-13  8:22                 ` Vojtech Pavlik
2005-02-13 16:17                   ` Bill Rugolsky Jr.
2005-01-27 17:45           ` Andries Brouwer
2005-01-28 14:55             ` Vojtech Pavlik
2005-01-25 12:44 ` Alan Cox
2005-01-25 12:44 ` Alan Cox
2005-01-26 15:43 ` Vojtech Pavlik
2005-01-26 16:36   ` Dmitry Torokhov
2005-01-26 17:05     ` linux-os
2005-01-26 18:30       ` Dmitry Torokhov
2005-01-27 10:19     ` Vojtech Pavlik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41F9545A.4080803@kroon.co.za \
    --to=jaco@kroon.co.za \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sebekpi@poczta.onet.pl \
    --cc=torvalds@osdl.org \
    --cc=vojtech@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox