Bug 203249 - [patch] Patch to allow dynamic USB quirks at boot (USB 2 stack)
Summary: [patch] Patch to allow dynamic USB quirks at boot (USB 2 stack)
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: 10.2-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Hans Petter Selasky
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2015-09-21 19:33 UTC by Maxime Soulé
Modified: 2015-10-13 08:10 UTC (History)
2 users (show)

See Also:


Attachments
usb_quirk (3.99 KB, patch)
2015-09-21 19:33 UTC, Maxime Soulé
no flags Details | Diff
usb_quirk.4 patch (1.64 KB, patch)
2015-09-23 21:33 UTC, Maxime Soulé
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maxime Soulé 2015-09-21 19:33:15 UTC
Created attachment 161251 [details]
usb_quirk

The new USB 2 stack allows dynamic additions to the quirk table, but not at boot time.

This patch resurrects the idea of bug #122819 in which Maurice Castro implemented dynamic quirks in 2008 for the USB 1 stack, allowing quirks to be defined through the environment.

It allows the modification of the quirks table through the environment in the USB 2 stack. So the devices plugged in at boot time can be correctly quirk'ed even if they are not statically defined in usb_quirk.c.

One can define several variables in loader.conf, like this one:

  usb.quirk.0="0x04d9 0xfa50 0 0xffff UQ_KBD_IGNORE"

The value format is "VendorId ProductId LowRevision HighRevision Quirk1,...,QuirkN".
Quirk1,...,QuirkN are the quirks names as defined in the usb_quirk_str array, seprated by commas without space.

One can have usb.quirk.1, .2, ..., .99 if there is enough space in the quirks table...

If a matching entry is found in the quirk_usb.c's quirk table, it is replaced by the environment defined one.

If not, a new entry is created (while the table is not full.)

To keep it simple, it iterates over usb.quirk.N (N = 0; N < 100) variables and stop after the first non-existent one.
Comment 1 Hans Petter Selasky freebsd_committer freebsd_triage 2015-09-23 15:36:09 UTC
Do you have a patch for the usb_quirk.3 manual page?
Comment 2 Maxime Soulé 2015-09-23 21:33:37 UTC
Created attachment 161317 [details]
usb_quirk.4 patch

Sure.

usb_quirk.4 patch just added.
Comment 3 commit-hook freebsd_committer freebsd_triage 2015-09-24 17:38:32 UTC
A commit references this bug:

Author: hselasky
Date: Thu Sep 24 17:37:31 UTC 2015
New revision: 288180
URL: https://svnweb.freebsd.org/changeset/base/288180

Log:
  Implement support for reading USB quirks from the kernel environment.
  Refer to the usb_quirk(4) manual page for more details on how to use
  this new feature.

  Submitted by:	Maxime Soule <btik-fbsd@scoubidou.com>
  PR:		203249
  MFC after:	2 weeks

Changes:
  head/share/man/man4/usb_quirk.4
  head/sys/dev/usb/quirk/usb_quirk.c
Comment 4 Hans Petter Selasky freebsd_committer freebsd_triage 2015-09-24 17:39:15 UTC
Hi,

I made some small modifications to your patch before committing. Can you verify they are OK?

"hw.usb.quirk" instead of "usb.quirk" and some minor code and language cleanup in the manual page.

Thank you!

--HPS
Comment 5 Maxime Soulé 2015-09-26 10:29:20 UTC
Hi,

It works, thanks a lot!

In usb_quirk.4, shouldn't we say: ...for all USB devices matching VendorId, ProductId and *have* a hardware... ?

Max.
Comment 6 commit-hook freebsd_committer freebsd_triage 2015-09-26 16:48:39 UTC
A commit references this bug:

Author: hselasky
Date: Sat Sep 26 16:48:25 UTC 2015
New revision: 288273
URL: https://svnweb.freebsd.org/changeset/base/288273

Log:
  Fix spelling.

  Submitted by:	Maxime Soule <btik-fbsd@scoubidou.com>
  PR:		203249
  MFC after:	2 weeks

Changes:
  head/share/man/man4/usb_quirk.4
Comment 7 commit-hook freebsd_committer freebsd_triage 2015-10-08 07:17:56 UTC
A commit references this bug:

Author: hselasky
Date: Thu Oct  8 07:17:36 UTC 2015
New revision: 289007
URL: https://svnweb.freebsd.org/changeset/base/289007

Log:
  MFC r288180:
  Implement support for reading USB quirks from the kernel environment.
  Refer to the usb_quirk(4) manual page for more details on how to use
  this new feature.

  Submitted by:	Maxime Soule <btik-fbsd@scoubidou.com>
  PR:		203249

Changes:
_U  stable/10/
  stable/10/share/man/man4/usb_quirk.4
  stable/10/sys/dev/usb/quirk/usb_quirk.c
Comment 8 commit-hook freebsd_committer freebsd_triage 2015-10-08 07:20:58 UTC
A commit references this bug:

Author: hselasky
Date: Thu Oct  8 07:19:58 UTC 2015
New revision: 289009
URL: https://svnweb.freebsd.org/changeset/base/289009

Log:
  MFC r288180:
  Implement support for reading USB quirks from the kernel environment.
  Refer to the usb_quirk(4) manual page for more details on how to use
  this new feature.

  Submitted by:	Maxime Soule <btik-fbsd@scoubidou.com>
  PR:		203249

Changes:
_U  stable/9/share/
_U  stable/9/share/man/
_U  stable/9/share/man/man4/
  stable/9/share/man/man4/usb_quirk.4
_U  stable/9/sys/
_U  stable/9/sys/dev/
  stable/9/sys/dev/usb/quirk/usb_quirk.c
Comment 9 commit-hook freebsd_committer freebsd_triage 2015-10-13 08:09:31 UTC
A commit references this bug:

Author: hselasky
Date: Tue Oct 13 08:09:17 UTC 2015
New revision: 289213
URL: https://svnweb.freebsd.org/changeset/base/289213

Log:
  MFC r288273:
  Fix spelling.

  PR:		203249

Changes:
_U  stable/10/
  stable/10/share/man/man4/usb_quirk.4
Comment 10 commit-hook freebsd_committer freebsd_triage 2015-10-13 08:10:33 UTC
A commit references this bug:

Author: hselasky
Date: Tue Oct 13 08:10:21 UTC 2015
New revision: 289214
URL: https://svnweb.freebsd.org/changeset/base/289214

Log:
  MFC r288273:
  Fix spelling.

  PR:		203249

Changes:
_U  stable/9/share/
_U  stable/9/share/man/
_U  stable/9/share/man/man4/
  stable/9/share/man/man4/usb_quirk.4