login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
openbsd-tech
»
2010
»
December
»
11
Re: usb_{bulk,interrupt}_transfer() and PCATCH
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Jacob Meuser
Subject:
Re: usb_{bulk,interrupt}_transfer() and PCATCH
Date: Saturday, December 11, 2010 - 1:35 pm
On Sat, Dec 11, 2010 at 08:14:24PM +0100, Mark Kettenis wrote:
quoted text
> > Date: Wed, 8 Dec 2010 06:07:30 +0000 > > From: Jacob Meuser <jakemsr@sdf.lonestar.org> > > > > I recently got a hp officejet 4500. it's a 3-in-1 printer/scanner/fax. > > printing works great with the hplip packages. scanning doesn't work at > > all. > > > > I tracked the problem to read() failing in usb_bulk_read() in libusb. > > errno was EINTR. so I made this function just continue when read() got > > EINTR. I could then scan, but not very reliably. > > > > so I went into the kernel, and tracked it to usbdi_util.c: > > > > @ usbd_bulk_transfer(usbd_xfer_handle xfer, usbd_pipe_ha > > > > error = tsleep((caddr_t)xfer, PZERO | PCATCH, lbl, 0); > > splx(s); > > if (error) { > > DPRINTF(("usbd_bulk_transfer: tsleep=%d\n", error)); > > usbd_abort_pipe(pipe); > > return (USBD_INTERRUPTED); > > } > > > > on a hunch, I changed 'PZERO | PCATCH' to 'PWAIT'. then scanning became > > 100% reliable. even full-page 1200dpi (~525MB of data) worked > > perfectly. > > > > great. but, what if we need to interrupt the transfer. we don't want > > to hang here. > > > > well, this function takes a timeout. so, it's possible to make it > > return, even if the transfer stalls. but is this used? I looked > > at the ports that use libusb. setting 0/infinite timeout for bulk > > transfers is extremely rare, only set in code marked experimental > > or problematic. in the kernel, there are however some callers that > > use USBD_NO_TIMEOUT. > > > > so, I offer the following. if there's no timeout, behave like we do > > now and catch signals, and if there's a timeout, ignore signals. > > > > I did the same for interrupt transfers because the situation seems > > to be the same. > > > > thoughts? > > Sorry, but this very much feels like you're hacking around a bug in > the application you're using. If it installs signal handler without > specifying the SA_RESTART flag, it has to deal with read(2) failing > with EINTR.
that application would be libusb itself. is a library supposed to be messing with signals?
quoted text
> > Index: usbdi_util.c > > =================================================================== > > RCS file: /cvs/src/sys/dev/usb/usbdi_util.c,v > > retrieving revision 1.25 > > diff -u -p usbdi_util.c > > --- usbdi_util.c 26 Jun 2008 05:42:19 -0000 1.25 > > +++ usbdi_util.c 8 Dec 2010 04:58:49 -0000 > > @@ -426,7 +426,7 @@ usbd_bulk_transfer(usbd_xfer_handle xfer, usbd_pipe_ha > > u_int16_t flags, u_int32_t timeout, void *buf, u_int32_t *size, char *lbl) > > { > > usbd_status err; > > - int s, error; > > + int s, error, pri; > > > > usbd_setup_xfer(xfer, pipe, 0, buf, *size, flags, timeout, > > usbd_bulk_transfer_cb); > > @@ -437,7 +437,8 @@ usbd_bulk_transfer(usbd_xfer_handle xfer, usbd_pipe_ha > > splx(s); > > return (err); > > } > > - error = tsleep((caddr_t)xfer, PZERO | PCATCH, lbl, 0); > > + pri = timeout == USBD_NO_TIMEOUT ? (PZERO | PCATCH) : PWAIT; > > + error = tsleep((caddr_t)xfer, pri, lbl, 0); > > splx(s); > > if (error) { > > DPRINTF(("usbd_bulk_transfer: tsleep=%d\n", error)); > > @@ -467,7 +468,7 @@ usbd_intr_transfer(usbd_xfer_handle xfer, usbd_pipe_ha > > u_int16_t flags, u_int32_t timeout, void *buf, u_int32_t *size, char *lbl) > > { > > usbd_status err; > > - int s, error; > > + int s, error, pri; > > > > usbd_setup_xfer(xfer, pipe, 0, buf, *size, flags, timeout, > > usbd_intr_transfer_cb); > > @@ -478,7 +479,8 @@ usbd_intr_transfer(usbd_xfer_handle xfer, usbd_pipe_ha > > splx(s); > > return (err); > > } > > - error = tsleep(xfer, PZERO | PCATCH, lbl, 0); > > + pri = timeout == USBD_NO_TIMEOUT ? (PZERO | PCATCH) : PWAIT; > > + error = tsleep(xfer, pri, lbl, 0); > > splx(s); > > if (error) { > > DPRINTF(("usbd_intr_transfer: tsleep=%d\n", error));
--
jakemsr@sdf.lonestar.org
SDF Public Access UNIX System -
http://sdf.lonestar.org
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
usb_{bulk,interrupt}_transfer() and PCATCH
, Jacob Meuser
, (Tue Dec 7, 11:07 pm)
Re: usb_{bulk,interrupt}_transfer() and PCATCH
, Paul Irofti
, (Thu Dec 9, 8:09 am)
Re: usb_{bulk,interrupt}_transfer() and PCATCH
, Antoine Jacoutot
, (Sat Dec 11, 7:08 am)
Re: usb_{bulk,interrupt}_transfer() and PCATCH
, Mark Kettenis
, (Sat Dec 11, 12:14 pm)
Re: usb_{bulk,interrupt}_transfer() and PCATCH
, Jacob Meuser
, (Sat Dec 11, 1:35 pm)
Re: usb_{bulk,interrupt}_transfer() and PCATCH
, Jacob Meuser
, (Sat Dec 11, 1:56 pm)
Re: usb_{bulk,interrupt}_transfer() and PCATCH
, Jacob Meuser
, (Sun Dec 12, 6:02 am)
Re: usb_{bulk,interrupt}_transfer() and PCATCH
, Jacob Meuser
, (Mon Dec 13, 6:32 pm)
Re: usb_{bulk,interrupt}_transfer() and PCATCH
, Jacob Meuser
, (Fri Dec 17, 3:56 pm)
Navigation
Create content
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Paul Turner
[tg_shares_up rewrite v4 11/11] sched: update tg->shares after cpu.shares write
Mr. James W. Laferriere
Re: Linux 2.6.25-rc1 , syntax error near unexpected token `;'
Chuck Ebbert
Re: PCI: Unable to reserve mem region problem
Linus Torvalds
Linux 2.6.34-rc4
Mingming Cao
Re: [RFC 1/4] Large Blocksize support for Ext2/3/4
git
:
Ralf Wildenhues
[PATCH] Fix typos in the documentation
Len Brown
Re: fatal: unable to create '.git/index': File exists
Adeodato
Bazaar's patience diff as GIT_EXTERNAL_DIFF
Denis Bueno
Git clone error
Johannes Schindelin
Re: [PATCH 2/4] Add functions get_relative_cwd() and is_inside_dir()
git-commits-head
:
Linux Kernel Mailing List
ASoC: fix registration of the SoC card in the Freescale MPC8610 drivers
Linux Kernel Mailing List
drivers/acpi: use kasprintf
Linux Kernel Mailing List
nfsd41: sanity check client drc maxreqs
Linux Kernel Mailing List
bnx2x: Moving includes
Linux Kernel Mailing List
V4L/DVB: gspca - sonixj: Adjust minor values of sensor ov7630. - set the color ga...
openbsd-misc
:
Sevan / Venture37
Re: This is what Linus Torvalds calls openBSD crowd
Netmaffia.hu
Tini Lányok AKCIÓBAN OTTHON
Sam Fourman Jr.
Re: Help with Altell PC6700
Siju George
This is what Linus Torvalds calls openBSD crowd
Darrin Chandler
Re: OT: Python (was Re: vi in /bin)
linux-netdev
:
Kurt Van Dijck
Re: [PATCH net-next-2.6 1/2] can: add driver for Softing card
Eric Dumazet
Re: [PATCH net-next-2.6] net: Introduce skb_orphan_try()
Jamie Lokier
Re: POHMELFS high performance network filesystem. Transactions, failover, performa...
Jarek Poplawski
Re: socket api problem: can't bind an ipv6 socket to ::ffff:0.0.0.0
David Miller
Re: [PATCH v2] net: typos in comments in include/linux/igmp.h
Colocation donated by:
Syndicate