NetBSD Problem Report #31884
From www@netbsd.org Fri Oct 21 22:32:49 2005
Return-Path: <www@netbsd.org>
Received: by narn.netbsd.org (Postfix, from userid 31301)
id 3D54763B8A6; Fri, 21 Oct 2005 22:32:49 +0000 (UTC)
Message-Id: <20051021223249.3D54763B8A6@narn.netbsd.org>
Date: Fri, 21 Oct 2005 22:32:49 +0000 (UTC)
From: akropel1@rochester.rr.com
Reply-To: akropel1@rochester.rr.com
To: gnats-bugs@netbsd.org
Subject: [PATCH] Add quirk for uhid to ignore certain usb devices (blacklist)
X-Send-Pr-Version: www-1.0
>Number: 31884
>Category: kern
>Synopsis: [PATCH] Add quirk for uhid to ignore certain usb devices (blacklist)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Oct 21 22:33:00 +0000 2005
>Closed-Date: Wed Oct 03 15:04:10 +0000 2007
>Last-Modified: Wed Oct 03 15:05:01 +0000 2007
>Originator: Adam Kropelin
>Release: 2.0
>Organization:
apcupsd maintainer
>Environment:
NetBSD p3.kroptech.com 2.0 NetBSD 2.0 (GENERIC.adk) #3: Sun Mar 27 15:43:05 EST 2005 adk0212@p3.kroptech.com:/usr/src/sys/arch/i386/compile/GENERIC.adk i386
>Description:
The uhid driver claims HID devices including power devices such as
UPSes. The apcupsd and NUT tools both control USB UPSes via ugen. As a
workaround, users are required to recompile their kernel, disabling
uhid support along with usb kbd and mouse support.
>How-To-Repeat:
>Fix:
The FreeBSD PR database has patches implementing a UQ_HID_IGNORE quirk
which allows UPSes and other devices to avoid being claimed by uhid.
FreeBSD has not merged the patch in over a year, but I'm hoping OpenBSD
is more receptive. (Or at least more responsive...if the patch is the
wrong way to solve the problem, I can accept that.)
The FreeBSD patch is below. It includes quirks for several devices as
submitted by individuals who need them. (If the form whitespace mangles this, feel free to email me for a clean copy.)
The original patch was by Lonnie Mendez <lmendez19@austin.rr.com>. Thierry Thomas <thierry@FreeBSD.org> added MGE UPS quirks, and I added
APC UPS quirks.
diff -urN src/sys/dev/usb.orig/uhid.c src/sys/dev/usb/uhid.c
--- src/sys/dev/usb.orig/uhid.c Sun Jan 30 02:00:10 2005
+++ src/sys/dev/usb/uhid.c Sun May 22 10:35:28 2005
@@ -91,6 +91,9 @@
/* Report descriptor for broken Wacom Graphire */
#include <dev/usb/ugraphire_rdesc.h>
+/* For hid blacklist quirk */
+#include <dev/usb/usb_quirks.h>
+
#ifdef USB_DEBUG
#define DPRINTF(x) if (uhiddebug) logprintf x
#define DPRINTFN(n,x) if (uhiddebug>(n)) logprintf x
@@ -190,6 +193,8 @@
return (UMATCH_NONE);
id = usbd_get_interface_descriptor(uaa->iface);
if (id == NULL || id->bInterfaceClass != UICLASS_HID)
+ return (UMATCH_NONE);
+ if (usbd_get_quirks(uaa->device)->uq_flags & UQ_HID_IGNORE)
return (UMATCH_NONE);
#if 0
if (uaa->matchlvl)
diff -urN src/sys/dev/usb.orig/usb_quirks.c src/sys/dev/usb/usb_quirks.c
--- src/sys/dev/usb.orig/usb_quirks.c Sun Jan 30 02:00:10 2005
+++ src/sys/dev/usb/usb_quirks.c Sun May 22 10:31:55 2005
@@ -101,6 +101,15 @@
ANY, { UQ_ASSUME_CM_OVER_DATA }},
{ USB_VENDOR_SUNTAC, USB_PRODUCT_SUNTAC_AS64LX,
0x100, { UQ_ASSUME_CM_OVER_DATA }},
+ /* Devices which should be ignored by uhid */
+ { USB_VENDOR_APC, USB_PRODUCT_APC_UPS,
+ ANY, { UQ_HID_IGNORE }},
+ { USB_VENDOR_DELORME, USB_PRODUCT_DELORME_EARTHMATE,
+ ANY, { UQ_HID_IGNORE }},
+ { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS1,
+ ANY, { UQ_HID_IGNORE }},
+ { USB_VENDOR_MGE, USB_PRODUCT_MGE_UPS2,
+ ANY, { UQ_HID_IGNORE }},
{ 0, 0, 0, { 0 } }
};
diff -urN src/sys/dev/usb.orig/usb_quirks.h src/sys/dev/usb/usb_quirks.h
--- src/sys/dev/usb.orig/usb_quirks.h Sun Jan 30 02:00:10 2005
+++ src/sys/dev/usb/usb_quirks.h Sun May 22 10:37:18 2005
@@ -54,6 +54,7 @@
#define UQ_AU_INP_ASYNC 0x0800 /* input is async despite claim of adaptive */
#define UQ_ASSUME_CM_OVER_DATA 0x1000 /* modem device breaks on cm over data */
#define UQ_BROKEN_BIDIR 0x2000 /* printer has broken bidir mode */
+#define UQ_HID_IGNORE 0x4000 /* device should be ignored by hid class */
};
extern const struct usbd_quirks usbd_no_quirk;
diff -urN src/sys/dev/usb.orig/usbdevs src/sys/dev/usb/usbdevs
--- src/sys/dev/usb.orig/usbdevs Wed May 18 21:45:23 2005
+++ src/sys/dev/usb/usbdevs Sun May 22 10:42:35 2005
@@ -90,6 +90,7 @@
vendor DIAMOND2 0x045a Diamond (Supra)
vendor MICROSOFT 0x045e Microsoft
vendor PRIMAX 0x0461 Primax Electronics
+vendor MGE 0x0463 MGE UPS Systems
vendor AMP 0x0464 AMP
vendor CHERRY 0x046a Cherry Mikroschalter
vendor MEGATRENDS 0x046b American Megatrends
@@ -470,7 +471,7 @@
product ALTEC ASC495 0xff05 ASC495 Speakers
/* American Power Conversion products */
-product APC UPSPRO500 0x0002 Back-UPS Pro 500
+product APC UPS 0x0002 Uninterruptible Power Supply
/* Anchor products */
product ANCHOR EZUSB 0x2131 EZUSB
@@ -962,6 +963,10 @@
/* Metricom products */
product METRICOM RICOCHET_GS 0x0001 Ricochet GS
+
+/* MGE UPS Systems */
+product MGE UPS1 0x0001 MGE UPS SYSTEMS PROTECTIONCENTER 1
+product MGE UPS2 0xffff MGE UPS SYSTEMS PROTECTIONCENTER 2
/* Microsoft products */
product MICROSOFT SIDEPREC 0x0008 SideWinder Precision Pro
>Release-Note:
>Audit-Trail:
From: Nick Hudson <nick.hudson@dsl.pipex.com>
To: gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org
Subject: Re: kern/31884: [PATCH] Add quirk for uhid to ignore certain usb devices (blacklist)
Date: Sat, 29 Oct 2005 08:10:16 +0000
On Friday 21 October 2005 22:33, akropel1@rochester.rr.com wrote:
> + { USB_VENDOR_DELORME, USB_PRODUCT_DELORME_EARTHMATE,
> + ANY, { UQ_HID_IGNORE }},
Why do you think this should have a quirk?
It is supported by ucycom(4)
Nick
From: "Adam Kropelin" <akropel1@rochester.rr.com>
To: <gnats-bugs@NetBSD.org>
Cc: <lmendez19@austin.rr.com>, <nick.hudson@dsl.pipex.com>
Subject: Re: kern/31884: [PATCH] Add quirk for uhid to ignore certain usb devices (blacklist)
Date: Sun, 30 Oct 2005 18:25:19 -0500
On Sat, 29 Oct 2005 08:10:16, Nick Hudson wrote:
> On Friday 21 October 2005 22:33, akropel1@rochester.rr.com wrote:
>
>> + { USB_VENDOR_DELORME, USB_PRODUCT_DELORME_EARTHMATE,
>> + ANY, { UQ_HID_IGNORE }},
>
> Why do you think this should have a quirk?
>
> It is supported by ucycom(4)
Perhaps the Delorme quirk is not necessary on NetBSD. It was part of
Lonnie's original patch for FreeBSD so I assumed it was applicable to
NetBSD as well.
--Adam
From: Nick Hudson <skrll@netbsd.org>
To: "Adam Kropelin" <akropel1@rochester.rr.com>
Cc: gnats-bugs@netbsd.org, lmendez19@austin.rr.com
Subject: Re: kern/31884: [PATCH] Add quirk for uhid to ignore certain usb devices (blacklist)
Date: Mon, 31 Oct 2005 08:13:31 +0000
On Sunday 30 October 2005 23:25, Adam Kropelin wrote:
> On Sat, 29 Oct 2005 08:10:16, Nick Hudson wrote:
> > On Friday 21 October 2005 22:33, akropel1@rochester.rr.com wrote:
> >> + { USB_VENDOR_DELORME, USB_PRODUCT_DELORME_EARTHMATE,
> >>
> >> + ANY, { UQ_HID_IGNORE }},
> >
> > Why do you think this should have a quirk?
> >
> > It is supported by ucycom(4)
>
> Perhaps the Delorme quirk is not necessary on NetBSD. It was part of
> Lonnie's original patch for FreeBSD so I assumed it was applicable to
> NetBSD as well.
I think its because FreeBSD doesn't/didn't have uhidev(4) and support for
optional interrupt output pipes.
Nick
From: Lonnie Mendez <lmendez19@austin.rr.com>
To: Nick Hudson <skrll@netbsd.org>
Cc: Adam Kropelin <akropel1@rochester.rr.com>, gnats-bugs@netbsd.org
Subject: Re: kern/31884: [PATCH] Add quirk for uhid to ignore certain usb devices (blacklist)
Date: Mon, 31 Oct 2005 13:00:38 -0600
On Monday 31 October 2005 2:13 am, Nick Hudson wrote:
> On Sunday 30 October 2005 23:25, Adam Kropelin wrote:
> > On Sat, 29 Oct 2005 08:10:16, Nick Hudson wrote:
> > > On Friday 21 October 2005 22:33, akropel1@rochester.rr.com wrote:
> > >> + { USB_VENDOR_DELORME, USB_PRODUCT_DELORME_EARTHMATE,
> > >>
> > >> + ANY, { UQ_HID_IGNORE }},
> > >
> > > Why do you think this should have a quirk?
> > >
> > > It is supported by ucycom(4)
> >
> > Perhaps the Delorme quirk is not necessary on NetBSD. It was part of
> > Lonnie's original patch for FreeBSD so I assumed it was applicable to
> > NetBSD as well.
>
> I think its because FreeBSD doesn't/didn't have uhidev(4) and support for
> optional interrupt output pipes.
Hm. I'll have to try NetBSD with libemul (emul.berlios.de) sometime soon.
A while back I wasn't able to get it to work with OpenBSD,NetBSD,FreeBSD
in regards to communication on the interrupt out pipe with libusb; so I settled
for making the library read-only on the BSDs.
The patch was meant to block uhid from claiming the earthmate interface.
You can't have a userspace application communicating with the earthmate
unless uhid releases it's control of the interface, which is what the patch does.
http://mail-index.netbsd.org/tech-kern/2005/05/12/0001.html
Of course, because of this implementation, the patch indeed conflicts with the
method of going through uhid for communication on NetBSD.
From: Sergey Svishchev <svs@ropnet.ru>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: kern/31884
Date: Sun, 2 Jul 2006 01:42:58 +0400
The patch does not apply cleanly to -current, here's an updated one:
--- sys/dev/usb/uhidev.c 12 Jun 2006 21:01:58 -0000 1.32
+++ sys/dev/usb/uhidev.c 20 Jun 2006 21:07:51 -0000
@@ -97,6 +97,8 @@
id = usbd_get_interface_descriptor(uaa->iface);
if (id == NULL || id->bInterfaceClass != UICLASS_HID)
return (UMATCH_NONE);
+ if (usbd_get_quirks(uaa->device)->uq_flags & UQ_HID_IGNORE)
+ return (UMATCH_NONE);
return (UMATCH_IFACECLASS_GENERIC);
}
--- sys/dev/usb/usb_quirks.c 28 Nov 2005 19:37:18 -0000 1.53
+++ sys/dev/usb/usb_quirks.c 1 Jul 2006 21:35:40 -0000
@@ -112,6 +112,7 @@
{ USB_VENDOR_NEC, USB_PRODUCT_NEC_PICTY800, ANY, { UQ_BROKEN_BIDIR }},
{ USB_VENDOR_HP, USB_PRODUCT_HP_1220C, ANY, { UQ_BROKEN_BIDIR }},
+ { USB_VENDOR_APC, USB_PRODUCT_APC_UPSPRO500, ANY, { UQ_HID_IGNORE }},
{ 0, 0, 0, { 0 } }
};
--- sys/dev/usb/usb_quirks.h 15 Apr 2001 09:38:01 -0000 1.20
+++ sys/dev/usb/usb_quirks.h 2 Jan 2006 23:25:56 -0000
@@ -54,6 +54,7 @@
#define UQ_AU_INP_ASYNC 0x0800 /* input is async despite claim of adaptive */
#define UQ_ASSUME_CM_OVER_DATA 0x1000 /* modem device breaks on cm over data */
#define UQ_BROKEN_BIDIR 0x2000 /* printer has broken bidir mode */
+#define UQ_HID_IGNORE 0x4000 /* device should be ignored by hid class */
};
extern const struct usbd_quirks usbd_no_quirk;
--
Sergey Svishchev
From: Bernd Ernesti <veego@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: PR/31884 CVS commit: src/sys/dev/usb
Date: Sun, 24 Jun 2007 10:02:46 +0000 (UTC)
Module Name: src
Committed By: veego
Date: Sun Jun 24 10:02:46 UTC 2007
Modified Files:
src/sys/dev/usb: usbdevs
Log Message:
- Add the MGE vendor and two entries.
- Change the APC entry, because it is not Back-UPS Pro 500 specific, it
is used for more UPS's
Based on a patch from PR kern/31884
To generate a diff of this commit:
cvs rdiff -r1.474 -r1.475 src/sys/dev/usb/usbdevs
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: veego@netbsd.org
State-Changed-When: Wed, 03 Oct 2007 15:04:10 +0000
State-Changed-Why:
Patch applied. Thank you for the pr.
From: Bernd Ernesti <veego@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: PR/31884 CVS commit: src/sys/dev/usb
Date: Wed, 3 Oct 2007 15:01:29 +0000 (UTC)
Module Name: src
Committed By: veego
Date: Wed Oct 3 15:01:29 UTC 2007
Modified Files:
src/sys/dev/usb: uhidev.c usb_quirks.c usb_quirks.h
Log Message:
Add support to ignore hid attachments for some devices, right now MGE and
APC UPS devices.
No objections on tech-kern at the end of June 2007
Patch is from PR kern/31884
To generate a diff of this commit:
cvs rdiff -r1.35 -r1.36 src/sys/dev/usb/uhidev.c
cvs rdiff -r1.56 -r1.57 src/sys/dev/usb/usb_quirks.c
cvs rdiff -r1.21 -r1.22 src/sys/dev/usb/usb_quirks.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.