[PATCH v3 00/11] PS/2 controller related fixes

Volker Rümelin posted 11 patches 2 years, 11 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/d00ea6b1-43c7-78a2-8c0a-35e19efb5e46@t-online.de
There is a newer version of this series
hw/input/pckbd.c | 289 ++++++++++++++++++++++++++++++++++-------------
hw/input/ps2.c   |  11 +-
2 files changed, 221 insertions(+), 79 deletions(-)
[PATCH v3 00/11] PS/2 controller related fixes
Posted by Volker Rümelin 2 years, 11 months ago
This patch series fixes two different PS/2 mouse stream corruptions
and adds a feature that allows some old misbehaving DOS programs to
have a working keyboard. With the last few patches, the PS/2 con-
troller behaves more like a real controller.

v2:
Introduce the function kbd_pending() in a preliminary patch to ease
the review of patch "pckbd: correctly disable PS/2 communication",
as Phillipe suggested.

v3:
Patch "pckbd: correctly disable PS/2 communication" exposed a bug
in SeaBIOS. The updated patch keeps the relevant code. Until
SeaBIOS is fixed, the PS/2 controller command KBD_CCMD_KBD_DISABLE
must disable the keyboard interrupt.

In patch "pckbd: PS/2 keyboard throttle" in function
kbd_throttle_timeout() an unnecessary if statement was removed.
The KBD_STAT_OBF flag is never set when kbd_throttle_timeout()
gets called.

Volker Rümelin (11):
   ps2: fix mouse stream corruption
   ps2: don't raise an interrupt if queue is full
   ps2: don't deassert irq twice if queue is empty
   pckbd: split out interrupt line changing code
   pckbd: don't update OBF flags if KBD_STAT_OBF is set
   pckbd: PS/2 keyboard throttle
   pckbd: add state variable for interrupt source
   pckbd: add controller response queue
   pckbd: add function kbd_pending()
   pckbd: correctly disable PS/2 communication
   pckbd: remove duplicated keyboard and mouse defines

  hw/input/pckbd.c | 289 ++++++++++++++++++++++++++++++++++-------------
  hw/input/ps2.c   |  11 +-
  2 files changed, 221 insertions(+), 79 deletions(-)

-- 
2.26.2


Re: [PATCH v3 00/11] PS/2 controller related fixes
Posted by Philippe Mathieu-Daudé 2 years, 11 months ago
On 5/15/21 1:31 PM, Volker Rümelin wrote:
> This patch series fixes two different PS/2 mouse stream corruptions
> and adds a feature that allows some old misbehaving DOS programs to
> have a working keyboard. With the last few patches, the PS/2 con-
> troller behaves more like a real controller.
> 
> v2:
> Introduce the function kbd_pending() in a preliminary patch to ease
> the review of patch "pckbd: correctly disable PS/2 communication",
> as Phillipe suggested.
> 
> v3:
> Patch "pckbd: correctly disable PS/2 communication" exposed a bug
> in SeaBIOS. The updated patch keeps the relevant code. Until
> SeaBIOS is fixed, the PS/2 controller command KBD_CCMD_KBD_DISABLE
> must disable the keyboard interrupt.
> 
> In patch "pckbd: PS/2 keyboard throttle" in function
> kbd_throttle_timeout() an unnecessary if statement was removed.
> The KBD_STAT_OBF flag is never set when kbd_throttle_timeout()
> gets called.
> 
> Volker Rümelin (11):
>   ps2: fix mouse stream corruption
>   ps2: don't raise an interrupt if queue is full
>   ps2: don't deassert irq twice if queue is empty
>   pckbd: split out interrupt line changing code
>   pckbd: don't update OBF flags if KBD_STAT_OBF is set
>   pckbd: PS/2 keyboard throttle
>   pckbd: add state variable for interrupt source
>   pckbd: add controller response queue
>   pckbd: add function kbd_pending()
>   pckbd: correctly disable PS/2 communication
>   pckbd: remove duplicated keyboard and mouse defines

Zoltan, you might want to test this series with your Pegasos2
machine. It makes the keyboard detected correctly.

There is still a problem with the mouse interaction with the
host. Pressing Ctrl+Alt+G to ungrab the mouse, my host mouse
is still responding to guest events... (unrelated to this series).

Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
(PPC Pegasos2 so far)

Re: [PATCH v3 00/11] PS/2 controller related fixes
Posted by BALATON Zoltan 2 years, 11 months ago
On Sat, 15 May 2021, Philippe Mathieu-Daudé wrote:
> On 5/15/21 1:31 PM, Volker Rümelin wrote:
>> This patch series fixes two different PS/2 mouse stream corruptions
>> and adds a feature that allows some old misbehaving DOS programs to
>> have a working keyboard. With the last few patches, the PS/2 con-
>> troller behaves more like a real controller.
>>
>> v2:
>> Introduce the function kbd_pending() in a preliminary patch to ease
>> the review of patch "pckbd: correctly disable PS/2 communication",
>> as Phillipe suggested.
>>
>> v3:
>> Patch "pckbd: correctly disable PS/2 communication" exposed a bug
>> in SeaBIOS. The updated patch keeps the relevant code. Until
>> SeaBIOS is fixed, the PS/2 controller command KBD_CCMD_KBD_DISABLE
>> must disable the keyboard interrupt.
>>
>> In patch "pckbd: PS/2 keyboard throttle" in function
>> kbd_throttle_timeout() an unnecessary if statement was removed.
>> The KBD_STAT_OBF flag is never set when kbd_throttle_timeout()
>> gets called.
>>
>> Volker Rümelin (11):
>>   ps2: fix mouse stream corruption
>>   ps2: don't raise an interrupt if queue is full
>>   ps2: don't deassert irq twice if queue is empty
>>   pckbd: split out interrupt line changing code
>>   pckbd: don't update OBF flags if KBD_STAT_OBF is set
>>   pckbd: PS/2 keyboard throttle
>>   pckbd: add state variable for interrupt source
>>   pckbd: add controller response queue
>>   pckbd: add function kbd_pending()
>>   pckbd: correctly disable PS/2 communication
>>   pckbd: remove duplicated keyboard and mouse defines
>
> Zoltan, you might want to test this series with your Pegasos2
> machine. It makes the keyboard detected correctly.
>
> There is still a problem with the mouse interaction with the
> host. Pressing Ctrl+Alt+G to ungrab the mouse, my host mouse
> is still responding to guest events... (unrelated to this series).
>
> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> (PPC Pegasos2 so far)

I don't get the errors you reported. Keyboard and mouse seems to work OK 
for me with SDL on Linux and never got errors detecting it so far. What 
config are you using?

Regards,
BALATON Zoltan
Re: [PATCH v3 00/11] PS/2 controller related fixes
Posted by Philippe Mathieu-Daudé 2 years, 11 months ago
On 5/15/21 4:35 PM, BALATON Zoltan wrote:
> On Sat, 15 May 2021, Philippe Mathieu-Daudé wrote:
>> On 5/15/21 1:31 PM, Volker Rümelin wrote:
>>> This patch series fixes two different PS/2 mouse stream corruptions
>>> and adds a feature that allows some old misbehaving DOS programs to
>>> have a working keyboard. With the last few patches, the PS/2 con-
>>> troller behaves more like a real controller.
>>>
>>> v2:
>>> Introduce the function kbd_pending() in a preliminary patch to ease
>>> the review of patch "pckbd: correctly disable PS/2 communication",
>>> as Phillipe suggested.
>>>
>>> v3:
>>> Patch "pckbd: correctly disable PS/2 communication" exposed a bug
>>> in SeaBIOS. The updated patch keeps the relevant code. Until
>>> SeaBIOS is fixed, the PS/2 controller command KBD_CCMD_KBD_DISABLE
>>> must disable the keyboard interrupt.
>>>
>>> In patch "pckbd: PS/2 keyboard throttle" in function
>>> kbd_throttle_timeout() an unnecessary if statement was removed.
>>> The KBD_STAT_OBF flag is never set when kbd_throttle_timeout()
>>> gets called.
>>>
>>> Volker Rümelin (11):
>>>   ps2: fix mouse stream corruption
>>>   ps2: don't raise an interrupt if queue is full
>>>   ps2: don't deassert irq twice if queue is empty
>>>   pckbd: split out interrupt line changing code
>>>   pckbd: don't update OBF flags if KBD_STAT_OBF is set
>>>   pckbd: PS/2 keyboard throttle
>>>   pckbd: add state variable for interrupt source
>>>   pckbd: add controller response queue
>>>   pckbd: add function kbd_pending()
>>>   pckbd: correctly disable PS/2 communication
>>>   pckbd: remove duplicated keyboard and mouse defines
>>
>> Zoltan, you might want to test this series with your Pegasos2
>> machine. It makes the keyboard detected correctly.
>>
>> There is still a problem with the mouse interaction with the
>> host. Pressing Ctrl+Alt+G to ungrab the mouse, my host mouse
>> is still responding to guest events... (unrelated to this series).
>>
>> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> (PPC Pegasos2 so far)
> 
> I don't get the errors you reported. Keyboard and mouse seems to work OK
> for me with SDL on Linux and never got errors detecting it so far. What
> config are you using?

OK, apparently a timing problem related to slow emulation.
I can reproduce simply using "--enable-debug --extra-cflags=-ggdb",
not without it.

Using Volker's series it is harder to reproduce.