Bug 250711 - atkbdc: No Keyboard on System76 lemur Pro laptop with 12.1 (11.4 Ok)
Summary: atkbdc: No Keyboard on System76 lemur Pro laptop with 12.1 (11.4 Ok)
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 12.1-RELEASE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Vladimir Kondratyev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-10-29 04:53 UTC by nick.lott
Modified: 2020-12-16 09:31 UTC (History)
6 users (show)

See Also:


Attachments
dmesg output from 12.1 memstick image, verbose boot. (57.60 KB, text/plain)
2020-10-29 04:53 UTC, nick.lott
no flags Details
dmesg output from 13-CURRENT c253915 memstick image, verbose boot. (54.03 KB, text/plain)
2020-10-29 07:50 UTC, nick.lott
no flags Details
dmesg output from 12.2 with coreboot atkbdc quirks removed. (90.70 KB, text/plain)
2020-10-30 22:32 UTC, nick.lott
no flags Details
kenv output from 12.2 with atkbdc quirks removed. (2.24 KB, text/plain)
2020-11-01 00:13 UTC, nick.lott
no flags Details
atkbdc_quirks.patch (445 bytes, patch)
2020-11-02 20:44 UTC, Vladimir Kondratyev
no flags Details | Diff
Example patch how to fix quirks processing bug introduced in r367349 (705 bytes, patch)
2020-12-04 12:32 UTC, Michael Gmelin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description nick.lott 2020-10-29 04:53:05 UTC
Created attachment 219189 [details]
dmesg output from 12.1 memstick image, verbose boot.

Hi All,

I'm trying to bring up FreeBSD 12 on my new Lemur Pro laptop, but the keyboard is not working beyond the boot menu with 12.1.
* The keyboard works fine with 11.4-RELEASE.
* I believe it is internally wired as a PS/2 keyboard.
* A USB keyboard works fine when connected.
* I 'm currently only trying to get the keyboard working in console mode not X11 at this point.

HW probes of both releases are at the following links which includes dmesg output.
https://bsd-hardware.info/index.php?probe=0163d0f084
https://bsd-hardware.info/index.php?probe=30b32ece8f

A probe under linux https://linux-hardware.org/index.php?probe=c2619f1014 is also available if that helps.

It looks to me when going over the dmesg output that the keyboard is detected successfully both times, and I cannot see any obvious errors or warnings.

I'm happy to recompile the kernel or the keyboard firmware if needed, just not sure where to look for the next clue. 

output of 'dmesg | grep kbd' shown below for each version 

FreeBSD 11.4-STABLE #0 r366441
Code:

[...] atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
[...] atkbd0: <AT Keyboard> irq 1 on atkbdc0
[...] atkbd: the current kbd controller command byte 0067
[...] atkbd: keyboard ID 0x83ab (2)
[...] kbdc: RESET_KBD return code:00fa
[...] kbdc: RESET_KBD status:00aa
[...] kbd0 at atkbd0
[...] kbd0: atkbd0, AT 101/102 (2), config:0x0, flags:0x1d0000
...
[...] atkbd0: [GIANT-LOCKED]
...
[...] random: harvesting attach, 8 bytes (4 bits) from atkbd0
...
[...] kbdc: TEST_AUX_PORT status:0000
[...] kbdc: RESET_AUX return code:00fa
[...] kbdc: RESET_AUX status:ffffffff
[...] kbdc: DIAGNOSE status:0055
[...] kbdc: TEST_KBD_PORT status:0000
...
atkbdc: atkbdc0 already exists; skipping it



12.1-RELEASE r354233 GENERIC amd64
Code:

atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
atkbd0: <AT Keyboard> irq 1 on atkbdc0
atkbd: the current kbd controller command byte 0067
kbdc: RESET_KBD return code:00fa
kbdc: RESET_KBD status:00aa
atkbd: keyboard ID 0x83ab (2)
kbd0 at atkbd0
kbd0: atkbd0, AT 101/102 (2), config:0x0, flags:0x1d0000
ioapic0: routing intpin 1 (ISA IRQ 1) to lapic 6 vector 52
atkbd0: [GIANT-LOCKED]
...
kbdc: TEST_AUX_PORT status:0000
kbdc: RESET_AUX return code:00fa
kbdc: RESET_AUX status:ffffffff
kbdc: DIAGNOSE status:0055
kbdc: TEST_KBD_PORT status:0000
...
atkbdc: atkbdc0 already exists; skipping it
Comment 1 Li-Wen Hsu freebsd_committer 2020-10-29 06:49:09 UTC
Is it possible for you also check 12.2 and even -current? Thanks!
Comment 2 nick.lott 2020-10-29 07:48:17 UTC
No problem,

FreeBSD 13.0-CURRENT #0 0035a6c7bb7-c253915(main): Thu Oct 22 06:40:55 UTC 2020¬

 202 kbd: new array size 4¬
 203 WARNING: Device "kbd" is Giant locked and may be deleted before FreeBSD 13.0.¬
 204 kbd1 at kbdmux0¬
 ...
 580 atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0¬
 581 atkbd0: <AT Keyboard> irq 1 on atkbdc0¬
 582 atkbd: the current kbd controller command byte 0067¬
 583 kbdc: RESET_KBD return code:00fa¬
 584 kbdc: RESET_KBD status:00aa¬
 585 atkbd: keyboard ID 0x83ab (2)¬
 586 kbd0 at atkbd0¬
 587 kbd0: atkbd0, AT 101/102 (2), config:0x0, flags:0x1d0000¬
 588 ioapic0: routing intpin 1 (ISA IRQ 1) to lapic 4 vector 51¬
 589 atkbd0: [GIANT-LOCKED]¬
 590 psm0: unable to allocate IRQ¬
 591 psmcpnp0: <PS/2 mouse port> irq 12 on acpi0¬
 592 psm0: current command byte:0067¬
 593 kbdc: TEST_AUX_PORT status:0000¬
 594 kbdc: RESET_AUX return code:00fa¬
 595 kbdc: RESET_AUX status:ffffffff¬
 596 kbdc: DIAGNOSE status:0055¬
 597 kbdc: TEST_KBD_PORT status:0000¬
 ...
 807 atkbdc: atkbdc0 already exists; skipping it
Comment 3 nick.lott 2020-10-29 07:50:50 UTC
Created attachment 219192 [details]
dmesg output from 13-CURRENT c253915 memstick image, verbose boot.
Comment 4 nick.lott 2020-10-29 08:55:38 UTC
(In reply to nick.lott from comment #2)
I realize my previous comment was unclear.

To be clear the issue still exists on 12.2 and 13-current.
Comment 5 Vladimir Kondratyev freebsd_committer 2020-10-29 09:16:19 UTC
(In reply to nick.lott from comment #4)
Could you try to recompile 12.1+ or 13 with r307468 reverted:
https://svnweb.freebsd.org/base?view=revision&revision=307468
Comment 6 nick.lott 2020-10-30 22:30:56 UTC
I compiled 12.2 kernel with r307468 reverted and the keyboard now functions correctly.
Comment 7 nick.lott 2020-10-30 22:32:55 UTC
Created attachment 219226 [details]
dmesg output from 12.2 with coreboot atkbdc quirks removed.
Comment 8 Vladimir Kondratyev freebsd_committer 2020-10-31 13:33:30 UTC
(In reply to nick.lott from comment #6)
> I compiled 12.2 kernel with r307468 reverted and the
> keyboard now functions correctly.
Great! Could you attach kenv(1) output here?
Also it would be nice to find out exactly which quirk in unmodified kernel made your keyboard broken.
Comment 9 nick.lott 2020-11-01 00:13:10 UTC
Created attachment 219267 [details]
kenv output from 12.2 with atkbdc quirks removed.
Comment 10 nick.lott 2020-11-01 02:58:16 UTC
It turns out the KBDC_QUIRK_KEEP_ACTIVATED is the problem. The keyboard works fine with the other quirks on.
Comment 11 Vladimir Kondratyev freebsd_committer 2020-11-01 19:30:45 UTC
FYI. If drm-kmod on 12-stable supports video card located on your laptop, you may want to add CometLake PCI IDs to I2C driver to get touchpad working under X.
See r367230 (https://svnweb.freebsd.org/base?view=revision&revision=367230). Or wait for couple of weeks for MFC.
If STABLE's drm-kmod version (4.16) is too old, then only choice is install current (or use scfb driver which does not support any acceleration)
Comment 12 Vladimir Kondratyev freebsd_committer 2020-11-02 20:44:52 UTC
Created attachment 219311 [details]
atkbdc_quirks.patch

Try attached patch (on unmodified sources of 12+ or 13)
Comment 13 nick.lott 2020-11-04 05:36:55 UTC
(In reply to Vladimir Kondratyev from comment #12)
Patch works correctly on 12.2.0 r367155

Now switching to current and will check there
Comment 14 nick.lott 2020-11-04 08:28:15 UTC
(In reply to nick.lott from comment #13)
Works in 13.0-CURRENT r367315M
Comment 15 commit-hook freebsd_committer 2020-11-04 21:52:14 UTC
A commit references this bug:

Author: wulf
Date: Wed Nov  4 21:52:10 UTC 2020
New revision: 367349
URL: https://svnweb.freebsd.org/changeset/base/367349

Log:
  atkbdc(4): Add quirk for "System76 lemur Pro" laptops.

  Currently atkbdc(4) assumes all coreboot BIOSes belonging to Chromebooks
  and unconditionally sets a number of quirks to workaround known issues.

  Exclude "System76" laptops from this set as they appeared to be a
  traditional hardware ("lemur Pro" is a rebranded Clevo chassis) with
  coreboot firmware on board. KBDC_QUIRK_KEEP_ACTIVATED quirk activated for
  Chromebook platform makes keyboard on this devices inoperable.

  "Purism Librem" laptops may require the same exclusion too.

  PR:		250711
  Reported by:	nick.lott@gmail.com
  MFC after:	2 weeks

Changes:
  head/sys/dev/atkbdc/atkbdc.c
Comment 16 Vladimir Kondratyev freebsd_committer 2020-11-04 22:04:12 UTC
(In reply to nick.lott from comment #13)
> Patch works correctly on 12.2.0 r367155
> Works in 13.0-CURRENT r367315M

Thank you. I'll MFC commit to 12-STABLE in couple of weeks.
Comment 17 Michael Gmelin freebsd_committer 2020-12-04 11:26:23 UTC
(In reply to Vladimir Kondratyev from comment #16)

I got a report of a chromebook user who lost their keyboard, which I think was caused by this patch, as it breaks quirks for all systems by setting "quirk" to 0, which acts as an end-of-list marker when processing the quirk table (see is atkbdc_getquirks in atkbdc.c[0]):

    for (i=0; quirks[i].quirk != 0; ++i)
        if (QUIRK_STR_MATCH(quirks[i].bios_vendor, bios_vendor) &&
            QUIRK_STR_MATCH(quirks[i].maker, maker) &&
            QUIRK_STR_MATCH(quirks[i].product, product))
                return (quirks[i].quirk);

There are multiple (obvious) ways to fix this, can the creator of the original patch/committer work on this, or do you need assistance?

[0]https://svnweb.freebsd.org/base/head/sys/dev/atkbdc/atkbdc.c?revision=367854&view=markup#l136
Comment 18 Michael Gmelin freebsd_committer 2020-12-04 12:32:04 UTC
Created attachment 220245 [details]
Example patch how to fix quirks processing bug introduced in r367349

Please see this (completely untested) patch for an example how to correct the issue.
Comment 19 Vladimir Kondratyev freebsd_committer 2020-12-04 13:19:51 UTC
(In reply to Michael Gmelin from comment #17)

> for (i=0; quirks[i].quirk != 0; ++i)

Indeed, somehow I missed this check. I'll commit your fix.

Thank you.
Comment 20 Matthias Apitz 2020-12-04 13:36:06 UTC
It was my system Acer C720 which after updating to r368166 had no local console anymore. This small change (thanks to Michael) made it working again:

# diff -c sys/dev/atkbdc/atkbdc.c.orig sys/dev/atkbdc/atkbdc.c
*** sys/dev/atkbdc/atkbdc.c.orig	Mon Nov 30 05:56:25 2020
--- sys/dev/atkbdc/atkbdc.c	Fri Dec  4 13:32:16 2020
***************
*** 113,119 ****
  };
  
  static struct atkbdc_quirks quirks[] = {
!     {"coreboot", "System76", NULL, 0},
      {"coreboot", NULL, NULL,
  	KBDC_QUIRK_KEEP_ACTIVATED | KBDC_QUIRK_IGNORE_PROBE_RESULT |
  	KBDC_QUIRK_RESET_AFTER_PROBE | KBDC_QUIRK_SETLEDS_ON_INIT},
--- 113,119 ----
  };
  
  static struct atkbdc_quirks quirks[] = {
!     /* {"coreboot", "System76", NULL, 0}, */
      {"coreboot", NULL, NULL,
  	KBDC_QUIRK_KEEP_ACTIVATED | KBDC_QUIRK_IGNORE_PROBE_RESULT |
  	KBDC_QUIRK_RESET_AFTER_PROBE | KBDC_QUIRK_SETLEDS_ON_INIT},
Comment 21 commit-hook freebsd_committer 2020-12-05 10:55:41 UTC
A commit references this bug:

Author: wulf
Date: Sat Dec  5 10:55:14 UTC 2020
New revision: 368365
URL: https://svnweb.freebsd.org/changeset/base/368365

Log:
  atkbd(4): Change quirk table end-of-list marker to NULL vendor/maker/product

  This fixes regression introduced in r367349 which effectively resulted in
  truncation of quirk table.

  PR:		250711
  Submitted by:	grembo
  Reported by:	Matthias Apitz <guru@unixarea.de>
  X-MFC with:	r367349

Changes:
  head/sys/dev/atkbdc/atkbdc.c
Comment 22 Michael Gmelin freebsd_committer 2020-12-07 10:57:36 UTC
(In reply to Vladimir Kondratyev from comment #19)

Thanks for committing (also to @cem for changing it to nitems).
Comment 23 nick.lott 2020-12-14 07:42:20 UTC
System76 Lemur Pro is still fixed with 13.0-CURRENT r368627
Comment 24 commit-hook freebsd_committer 2020-12-16 08:00:18 UTC
A commit references this bug:

Author: wulf
Date: Wed Dec 16 07:59:48 UTC 2020
New revision: 368689
URL: https://svnweb.freebsd.org/changeset/base/368689

Log:
  MFC: r367349, r367854, r368365, r368374(by cem)

  r367349:

  atkbdc(4): Add quirk for "System76 lemur Pro" laptops.

  Currently atkbdc(4) assumes all coreboot BIOSes belonging to Chromebooks
  and unconditionally sets a number of quirks to workaround known issues.

  Exclude "System76" laptops from this set as they appeared to be a
  traditional hardware ("lemur Pro" is a rebranded Clevo chassis) with
  coreboot firmware on board. KBDC_QUIRK_KEEP_ACTIVATED quirk activated for
  Chromebook platform makes keyboard on this devices inoperable.

  "Purism Librem" laptops may require the same exclusion too.

  PR:		250711
  Reported by:	nick.lott@gmail.com

  r367854:

  psm(4): Disable AUX multiplexer probing on all Lenovo laptops.

  Rudimentary AUX multiplexing support was added to kernel to make possible
  touchpad initialization on some HP EliteBook laptops with trackpoint.

  Disable multiplexer probing on all Lenovo laptops now as they use touchpad
  pass-through port rather than AUX multiplexer to connect trackpoint and
  at least two model (X120e and X121e) is known for getting PS/2 AUX port
  dysfunctional after switching back to hidden multiplexing mode.

  AUX MUX probing can be reenabled with setting of hw.psm.mux_disabled loader
  tunable to 0.

  PR:		249987
  Reported by:	jwb

  r368365:

  atkbd(4): Change quirk table end-of-list marker to NULL vendor/maker/product

  This fixes regression introduced in r367349 which effectively resulted in
  truncation of quirk table.

  PR:		250711
  Submitted by:	grembo
  Reported by:	Matthias Apitz <guru@unixarea.de>

  r368374 (by cem):

  atkbd(4): Just use nitems() for quirk enumeration

  Reviewed by:    imp, wulf
  Differential Revision:  https://reviews.freebsd.org/D27489

Changes:
_U  stable/12/
  stable/12/sys/dev/atkbdc/atkbdc.c
  stable/12/sys/dev/atkbdc/atkbdcreg.h
  stable/12/sys/dev/atkbdc/psm.c
Comment 25 commit-hook freebsd_committer 2020-12-16 08:00:20 UTC
A commit references this bug:

Author: wulf
Date: Wed Dec 16 07:59:48 UTC 2020
New revision: 368689
URL: https://svnweb.freebsd.org/changeset/base/368689

Log:
  MFC: r367349, r367854, r368365, r368374(by cem)

  r367349:

  atkbdc(4): Add quirk for "System76 lemur Pro" laptops.

  Currently atkbdc(4) assumes all coreboot BIOSes belonging to Chromebooks
  and unconditionally sets a number of quirks to workaround known issues.

  Exclude "System76" laptops from this set as they appeared to be a
  traditional hardware ("lemur Pro" is a rebranded Clevo chassis) with
  coreboot firmware on board. KBDC_QUIRK_KEEP_ACTIVATED quirk activated for
  Chromebook platform makes keyboard on this devices inoperable.

  "Purism Librem" laptops may require the same exclusion too.

  PR:		250711
  Reported by:	nick.lott@gmail.com

  r367854:

  psm(4): Disable AUX multiplexer probing on all Lenovo laptops.

  Rudimentary AUX multiplexing support was added to kernel to make possible
  touchpad initialization on some HP EliteBook laptops with trackpoint.

  Disable multiplexer probing on all Lenovo laptops now as they use touchpad
  pass-through port rather than AUX multiplexer to connect trackpoint and
  at least two model (X120e and X121e) is known for getting PS/2 AUX port
  dysfunctional after switching back to hidden multiplexing mode.

  AUX MUX probing can be reenabled with setting of hw.psm.mux_disabled loader
  tunable to 0.

  PR:		249987
  Reported by:	jwb

  r368365:

  atkbd(4): Change quirk table end-of-list marker to NULL vendor/maker/product

  This fixes regression introduced in r367349 which effectively resulted in
  truncation of quirk table.

  PR:		250711
  Submitted by:	grembo
  Reported by:	Matthias Apitz <guru@unixarea.de>

  r368374 (by cem):

  atkbd(4): Just use nitems() for quirk enumeration

  Reviewed by:    imp, wulf
  Differential Revision:  https://reviews.freebsd.org/D27489

Changes:
_U  stable/12/
  stable/12/sys/dev/atkbdc/atkbdc.c
  stable/12/sys/dev/atkbdc/atkbdcreg.h
  stable/12/sys/dev/atkbdc/psm.c