I've noticed in 2.6 kernels that HIDIOCGREPORT does not wait for io
completion before returning to the caller. This creates a few unpleasant
issues for userspace:

First, code sequences such as...

        ioctl(fd, HIDIOCGREPORT, &rinfo);
        ioctl(fd, HIDIOCGUSAGE, &uinfo);
        ioctl(fd, HIDIOCGSTRING, &sdesc);

...that used to work in 2.4 now fail in 2.6 if the device takes more
than a few milliseconds to respond to HIDIOCGREPORT. (I'm seeing this
issue on APC UPSes, FWIW.)

Second, userspace code can easily flood the kernel with control messages
since the kernel provides no "backpressure". The result is a lot of
"hid-core.c: control queue full" errors and lost reports.

2.6 hid-core.c appears to submit the request and return immediately.
Although the 2.4 code differs significantly, I traced the call path to
usb-core.c, which seems to block with a timeout, so the code supports my
userspace observation. (Assuming I didn't misread it.)

Finally, my questions...

Is HIDIOCGREPORT in 2.6 intended to be non-blocking? If so, what is the
recommended userspace method for determining when the report has been
retrieved? If not, is the patch below an appropriate fix or should
hid_submit_report() be made to block instead?

Thanks in advance...
--Adam


--- linux-2.6.1/drivers/usb/input/hid.h Tue Jun 17 19:49:55 2003
+++ linux-2.6.1-adk/drivers/usb/input/hid.h     Sat Jan 17 16:16:31 2004
@@ -448,6 +448,7 @@
 void hid_submit_report(struct hid_device *, struct hid_report *, unsigned char dir);
 void hid_init_reports(struct hid_device *hid);
 int hid_find_report_by_usage(struct hid_device *hid, __u32 wanted_usage, struct 
hid_report **report, int type);
+int hid_wait_io(struct hid_device* hid);
 
 
 #ifdef CONFIG_HID_FF
--- linux-2.6.1/drivers/usb/input/hiddev.c      Sun Jan 11 12:05:10 2004
+++ linux-2.6.1-adk/drivers/usb/input/hiddev.c  Sat Jan 17 16:16:50 2004
@@ -509,6 +509,7 @@
                        return -EINVAL;
 
                hid_submit_report(hid, report, USB_DIR_IN);
+               hid_wait_io(hid);
 
                return 0;
 



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to