qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	Gerd Hoffman <kraxel@redhat.com>
Subject: [Qemu-devel] Re: [PATCH v2] add event queueing to USB HID
Date: Wed, 12 Jan 2011 14:01:50 +0100	[thread overview]
Message-ID: <4D2DA63E.2030506@redhat.com> (raw)
In-Reply-To: <19757.40902.900137.923740@mariner.uk.xensource.com>

On 01/12/2011 01:34 PM, Ian Jackson wrote:
> Paolo Bonzini writes ("[PATCH v2] add event queueing to USB HID"):
>>          For v2 I changed the head/tail implementation of the FIFO buffer
>>          (which was buggy when the queue became full) to head/count.
>>          I then removed "have_data", which is the same as count>0
>>          for pointer devices and the same as "changed" for keyboards.
>>          This made event merging more correct than in Ian's code and
>>          easier to understand than my v1.
>
> Thanks.  Was my code buggy then ?  It's possible; the event merging
> case is not easy to trigger in testing.

It's all pretty academic as in practice it worked well.  The queue-full 
code would never trigger in usb_pointer_event, and instead the queue 
would be instantly emptied when a 17th event arrived.  This is lucky 
actually, because the device would also stop unqueuing from a full queue 
if it had SET_IDLE 0.  Both bugs happened because head==tail could mean 
both "empty queue" and "full queue".  I'm not even sure it's possible to 
fill the queue in practice; even with a very high latency you'd have to 
do 8 clicks in say half a second.  I didn't try with a shorter queue, 
which of course would have made the problems evident.

>>          I left the "changed" member in USBHIDState, rather than moving it
>>          to the keyboard, because it is useful to handle the idle period
>>          (in USB_TOKEN_IN) in a device-independent way.  Without it the
>>          code became more messy.
>
> This leaves the same information recorded in the driver in two places
> and is therefore IMO a bad idea.  I still think the way I did this is
> best: have a common helper function used by the keyboard and pointer
> code to deal with the idle handling.

I don't disagree, but I think this is better left for a separate patch. 
  I see three reasons for this:

1) I would like to understand better the relation between GET_REPORT and 
TOKEN_IN.  If an event occurs between two TOKEN_IN messages, and the OS 
sends a GET_REPORT in between, should the second TOKEN_IN return 
USB_RET_NAK or not?  With your patch it will, with current QEMU and my 
patch it won't.  In this sense, the "changed" flag is recording slightly 
different information at least in my version of the code.

2) if buffering is implemented for the keyboard device (and it probably 
should) most of the differences would go away again.

3) Secondarily, this is the only part of your patch that would need 
adjustments, since finite idle delays are now implemented.

Paolo

  reply	other threads:[~2011-01-12 13:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-12 12:19 [Qemu-devel] [PATCH v2] add event queueing to USB HID Paolo Bonzini
2011-01-12 12:34 ` [Qemu-devel] " Ian Jackson
2011-01-12 13:01   ` Paolo Bonzini [this message]
2011-01-12 13:05     ` Ian Jackson
2011-01-12 16:27     ` Gerd Hoffmann

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=4D2DA63E.2030506@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=Stefano.Stabellini@eu.citrix.com \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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;
as well as URLs for NNTP newsgroup(s).