Bug 175731 - detaching USB keyboard freezes other USB keyboards
Summary: detaching USB keyboard freezes other USB keyboards
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-usb (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-31 14:10 UTC by nkoch
Modified: 2018-05-28 19:40 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nkoch 2013-01-31 14:10:00 UTC
My kernel is compiled without support for atkbd. I only use USB keyboards.

Attaching is fine but when detaching, any of the keyboards - I tried up to three - the other keyboards freeze. If I attach the keyboard again the other keyboards
unfreeze and work as before.

The problem has something to do with devd.
Detaching works without problems in single user mode or with devd not running.
As long as dev does not run *during* detaching things seem to be ok too.

Commenting out usb keyboard related entries in /etc/devd.conf
or /etc/devd/usb.conf does not help.
Commenting out syscons_setkeyboard in /etc/rc.d/syscons does not help either.

How-To-Repeat: Attach two USB keyboards.
Detach any of them.
The still connected keyboards freezes.
Reconnect other keyboard.
Both keyboards work.
Comment 1 Hans Petter Selasky 2013-01-31 14:23:34 UTC
On Thursday 31 January 2013 15:03:03 Norbert Koch wrote:
> >Number:         175731
> >Category:       usb
> >Synopsis:       detaching USB keyboard freezes other USB keyboards
> >Confidential:   no
> >Severity:       non-critical
> >Priority:       low
> >Responsible:    freebsd-usb
> >State:          open
> >Quarter:
> >Keywords:
> >Date-Required:
> >Class:          sw-bug
> >Submitter-Id:   current-users
> >Arrival-Date:   Thu Jan 31 14:10:00 UTC 2013
> >Closed-Date:
> >Last-Modified:
> >Originator:     Norbert Koch
> >Release:        9.0
> >Organization:
> 
> >Environment:
> FreeBSD  9.0-RELEASE-p3 FreeBSD 9.0-RELEASE-p3 #0: Thu Jan 24 16:31:49 CET
> 2013    
> root@entw-pr2.demig.intra:/usr/home/nk/src/kernel/src/sys/EMBEDDED_USBKBD_
> ONLY  i386
> 
> >Description:
> My kernel is compiled without support for atkbd. I only use USB keyboards.
> 
> Attaching is fine but when detaching, any of the keyboards - I tried up to
> three - the other keyboards freeze. If I attach the keyboard again the
> other keyboards unfreeze and work as before.
> 
> The problem has something to do with devd.
> Detaching works without problems in single user mode or with devd not
> running. As long as dev does not run *during* detaching things seem to be
> ok too.
> 
> Commenting out usb keyboard related entries in /etc/devd.conf
> or /etc/devd/usb.conf does not help.
> Commenting out syscons_setkeyboard in /etc/rc.d/syscons does not help
> either.
> 
> >How-To-Repeat:
> Attach two USB keyboards.
> Detach any of them.
> The still connected keyboards freezes.
> Reconnect other keyboard.
> Both keyboards work.

Hi,

Is this with or without X11?

Can you try 9-stable?

--HPS
Comment 2 nkoch 2013-01-31 16:04:03 UTC
It seems to be an X11 only problem.
My xorg.conf is auto-generated. Hald is running.
In xorg.conf I see Driver "kbd".
Does X11 bypass kbdmux?
Comment 3 nkoch 2013-02-07 12:01:01 UTC
Same problem with FreeBSD-9.1-RELEASE.
Comment 4 Hans Petter Selasky 2013-02-07 21:26:17 UTC
On Thursday 07 February 2013 13:10:01 Norbert Koch wrote:
> The following reply was made to PR usb/175731; it has been noted by GNATS.
> 
> From: Norbert Koch <nkoch@demig.de>
> To: bug-followup@FreeBSD.org
> Cc:
> Subject: Re: usb/175731: detaching USB keyboard freezes other USB keyboards
> Date: Thu, 07 Feb 2013 13:01:01 +0100
> 
>  Same problem with FreeBSD-9.1-RELEASE.

Hi,

In /etc/devd.conf there are a few lines of code:

# When a USB keyboard arrives, attach it as the console keyboard.
attach 100 {
        device-name "ukbd0";
        action "/etc/rc.d/syscons setkeyboard /dev/ukbd0";
};
detach 100 {
        device-name "ukbd0";
        action "/etc/rc.d/syscons setkeyboard /dev/kbd0";
};

Can you try to uncomment these?

Then restart devd or reboot and try again and see what happens.

I believe the devd.conf lines above should be removed.

--HPS
Comment 5 Hans Petter Selasky 2013-02-07 21:30:31 UTC
On Thursday 07 February 2013 22:26:17 Hans Petter Selasky wrote:
> Can you try to uncomment these?

I mean en-comment by adding # in front of every line.

--HPS
Comment 6 Hans Petter Selasky 2013-02-11 10:26:08 UTC
On Thursday 07 February 2013 22:40:01 Hans Petter Selasky wrote:
> The following reply was made to PR usb/175731; it has been noted by GNATS.
> 

Hi,

You should look into HAL and xf86-input-keyboard ports. I don't have time to 
debug this currently.

To prevent KBD X11 driver unload by /usr/ports/x11-drivers/xf86-input-keyboard 
change this in the source code:

 {
-    xf86AddInputDriver(&KBD, NULL, 0);
+    xf86AddInputDriver(&KBD, module, 0);
 
     return module;
 }

The problem is deeper. When X11 sees that the keyboard is gone it 
issues some IOCTLs on /dev/console, like the keyboard MODE and then no more 
keys are received. See using ktrace on Xorg. This is a shared device receiving 
key-presses for all keyboards as far as I can see and it should only be 
programmed once. This is currently not handled.

Inside the file referenced below code is present to set "x11_driver" to "kbd". 
Probably changing this will affect the outcome too:

/usr/local/share/hal/fdi/policy/10osvendor/10-x11-input.fdi

How to reproduce:

Plug two USB keyboards using a HAL enabled Xorg server. Unplug one keyboard. 
Input from the other keyboard disappears until some other keyboard device is 
plugged again!

--HPS
Comment 7 nkoch 2013-02-14 09:19:05 UTC
Am 07.02.2013 22:26, schrieb Hans Petter Selasky:
> On Thursday 07 February 2013 13:10:01 Norbert Koch wrote:
>> The following reply was made to PR usb/175731; it has been noted by GNATS.
>>
>> From: Norbert Koch <nkoch@demig.de>
>> To: bug-followup@FreeBSD.org
>> Cc:
>> Subject: Re: usb/175731: detaching USB keyboard freezes other USB keyboards
>> Date: Thu, 07 Feb 2013 13:01:01 +0100
>>
>>  Same problem with FreeBSD-9.1-RELEASE.
> Hi,
>
> In /etc/devd.conf there are a few lines of code:
>
> # When a USB keyboard arrives, attach it as the console keyboard.
> attach 100 {
>         device-name "ukbd0";
>         action "/etc/rc.d/syscons setkeyboard /dev/ukbd0";
> };
> detach 100 {
>         device-name "ukbd0";
>         action "/etc/rc.d/syscons setkeyboard /dev/kbd0";
> };
>
> Can you try to uncomment these?
>
> Then restart devd or reboot and try again and see what happens.
>
> I believe the devd.conf lines above should be removed.
>
> --HPS

I already tried this. Commenting out does not help.

Two choices work for me:
1. devd_enable=NO and hald_enable=YES
2. devd_enable=YES and option "AutoAddDevices" "NO" in xorg.conf
Comment 8 Hans Petter Selasky 2013-02-14 10:20:32 UTC
On Thursday 14 February 2013 10:20:02 Norbert Koch wrote:
> The following reply was made to PR usb/175731; it has been noted by GNATS.
> 
> From: Norbert Koch <nkoch@demig.de>
> To: hselasky@c2i.net
> Cc: freebsd-usb@freebsd.org, bug-followup@freebsd.org, imp@freebsd.org
> Subject: Re: usb/175731: detaching USB keyboard freezes other USB keyboards
> Date: Thu, 14 Feb 2013 10:19:05 +0100
> 
>  Am 07.02.2013 22:26, schrieb Hans Petter Selasky:
>  > On Thursday 07 February 2013 13:10:01 Norbert Koch wrote:
>  >> The following reply was made to PR usb/175731; it has been noted by
>  >> GNATS.
>  >> 
>  >> From: Norbert Koch <nkoch@demig.de>
>  >> To: bug-followup@FreeBSD.org
>  >> Cc:
>  >> Subject: Re: usb/175731: detaching USB keyboard freezes other USB
>  >> keyboards Date: Thu, 07 Feb 2013 13:01:01 +0100
>  >> 
>  >>  Same problem with FreeBSD-9.1-RELEASE.
>  > 
>  > Hi,
>  > 
>  > In /etc/devd.conf there are a few lines of code:
>  > 
>  > # When a USB keyboard arrives, attach it as the console keyboard.
>  > attach 100 {
>  > 
>  >         device-name "ukbd0";
>  >         action "/etc/rc.d/syscons setkeyboard /dev/ukbd0";
>  > 
>  > };
>  > detach 100 {
>  > 
>  >         device-name "ukbd0";
>  >         action "/etc/rc.d/syscons setkeyboard /dev/kbd0";
>  > 
>  > };
>  > 
>  > Can you try to uncomment these?
>  > 
>  > Then restart devd or reboot and try again and see what happens.
>  > 
>  > I believe the devd.conf lines above should be removed.
>  > 
>  > --HPS
> 
>  I already tried this. Commenting out does not help.
> 
>  Two choices work for me:
>  1. devd_enable=NO and hald_enable=YES
>  2. devd_enable=YES and option "AutoAddDevices" "NO" in xorg.conf
> 

Can you edit this file:

/usr/local/share/hal/fdi/policy/10osvendor/10-x11-input.fdi

And change:

<merge key="input.x11_driver" type="string">kbd</merge>

Into:

<merge key="input.x11_driver" type="string">kbd_dummy</merge>


Then restart hal.

Possibly you need a keyboard device entry in /etc/X11/xorg.conf after this 
change.

--HPS
Comment 9 Eitan Adler freebsd_committer freebsd_triage 2018-05-28 19:40:38 UTC
batch change:

For bugs that match the following
-  Status Is In progress 
AND
- Untouched since 2018-01-01.
AND
- Affects Base System OR Documentation

DO:

Reset to open status.


Note:
I did a quick pass but if you are getting this email it might be worthwhile to double check to see if this bug ought to be closed.