Dmitry, Jiri, and Pete: Considering all the discussion whirling around about HID changes, it seemed like a good idea to let you know about some proposed patches coming up.
They are below. The first addresses a problem that Pete has mentioned in the past: Some keyboards sometimes send more data than a single report in a packet, leading to EOVERFLOW errors. The patch tries to fix things by using a transfer length at least as large as the maxpacket size. I'm not sure if this will fully fix the problem, though -- if the device actually does stick more than one report in a single packet then the driver will need to parse them all, and the patch doesn't try to do that. The second patch addresses a problem caused by some KVM switches: They disrupt the data path between the host and the device (even when not switched away). The patch adds a module parameter to usbhid, telling it that a KVM is present so it should ignore certain types of errors. This essentially restores the behavior we had back in 2.6.16. Any comments? Alan Stern ----------------------------------------------------------------------- Some HID devices stick more than one report in a single packet. This patch (as828) uses a transfer size at least as big as the interrupt endpoint's maxpacket value, to avoid EOVERFLOW errors. Signed-off-by: Alan Stern <[EMAIL PROTECTED]> --- Index: usb-2.6/drivers/usb/input/hid-core.c =================================================================== --- usb-2.6.orig/drivers/usb/input/hid-core.c +++ usb-2.6/drivers/usb/input/hid-core.c @@ -1987,9 +1987,6 @@ static struct hid_device *usb_hid_config hid_find_max_report(hid, HID_INPUT_REPORT, &insize); - if (insize > HID_MAX_BUFFER_SIZE) - insize = HID_MAX_BUFFER_SIZE; - if (hid_alloc_buffers(dev, hid)) { hid_free_buffers(dev, hid); goto fail; @@ -2017,6 +2014,8 @@ static struct hid_device *usb_hid_config if (!(hid->urbin = usb_alloc_urb(0, GFP_KERNEL))) goto fail; pipe = usb_rcvintpipe(dev, endpoint->bEndpointAddress); + insize = min(max((int) endpoint->wMaxPacketSize, + insize), HID_MAX_BUFFER_SIZE); usb_fill_int_urb(hid->urbin, dev, pipe, hid->inbuf, insize, hid_irq_in, hid, interval); hid->urbin->transfer_dma = hid->inbuf_dma; ----------------------------------------------------------------------- A lot of KVM switches break or degrade the USB data path between the computer and the keyboard. This is to be expected when the keyboard is switched to a different machine, but some also do it when the device is supposedly connected. If we pay attention to the resulting I/O errors, we will end up trying to reset the keyboard, disconnecting it, and generally facing all sorts of difficulties. So this patch (as827) adds a new module parameter (kvm=y) to the usbhid driver, which will cause it to ignore the errors. Note that many keyboards (those with extension USB ports) contain an internal hub. This patch won't be sufficient to help them; the hub driver would need to be changed as well. Signed-off-by: Alan Stern <[EMAIL PROTECTED]> --- Index: usb-2.6/drivers/usb/input/hid-core.c =================================================================== --- usb-2.6.orig/drivers/usb/input/hid-core.c +++ usb-2.6/drivers/usb/input/hid-core.c @@ -54,6 +54,10 @@ static unsigned int hid_mousepoll_interv module_param_named(mousepoll, hid_mousepoll_interval, uint, 0644); MODULE_PARM_DESC(mousepoll, "Polling interval of mice"); +static int hid_kvm_present; +module_param_named(kvm, hid_kvm_present, bool, 0444); +MODULE_PARM_DESC(kvm, "Ignore errors caused by a KVM"); + /* * Register a new report for a device. */ @@ -1070,6 +1074,15 @@ static void hid_irq_in(struct urb *urb) case -EILSEQ: /* protocol error or unplug */ case -EPROTO: /* protocol error or unplug */ case -ETIME: /* protocol error or unplug */ + /* + * Many KVMs break the data pathway between the + * host and the device at various times (some do so + * even when the switch is set to connect the host + * to the device). If one of these things is being + * used then we need to ignore transmission errors. + */ + if (hid_kvm_present) + break; case -ETIMEDOUT: /* Should never happen, but... */ clear_bit(HID_IN_RUNNING, &hid->iofl); hid_io_error(hid); Index: usb-2.6/Documentation/kernel-parameters.txt =================================================================== --- usb-2.6.orig/Documentation/kernel-parameters.txt +++ usb-2.6/Documentation/kernel-parameters.txt @@ -1684,6 +1684,10 @@ and is between 256 and 4096 characters. Note that genuine overcurrent events won't be reported either. + usbhid.kvm= [USBHID] (default N) A KVM switch is present, so the + driver should ignore certain types of I/O errors + commonly caused by these switches. + usbhid.mousepoll= [USBHID] The interval which mice are to be polled at. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel