Re: [Libusbx-devel] Generic device support in Windows

2012-08-22 Thread Xiaofan Chen
On Thu, Aug 23, 2012 at 1:55 AM, David Grant wrote: > I don't understand why that would be the case. libusb + libusbK seems like > the perfect solution for us especially when we consider the fact that we are > already using libusb in the Linux (x86 + ARM) environments with great > success. It just

Re: [Libusbx-devel] Generic device support in Windows

2012-08-22 Thread Pete Batard
On 2012.08.22 18:55, David Grant wrote: > It just seems like the driver swapping is the main > issue we need to resolve. Well, if you want to contribute a driver swapping/removal patch to libwdi, I'll be happy to review it. Regards, /Pete ---

Re: [Libusbx-devel] [PATCH 1/2] linux_usbfs: Add support for the new get_capabilities ioctl

2012-08-22 Thread Pete Batard
On 2012.08.22 11:21, Hans de Goede wrote: > I would prefer to stick with the __u32, as that is what is in the kernels > *userspace* headers It's 2012, C99 + stdint.h have been around for more than decade [1], and, unlike what may be the case for kernel developers who may worry about C89 compatib

Re: [Libusbx-devel] libusb segfaults - causes pcscd to crash

2012-08-22 Thread Pete Batard
Well, that was really a one in a billion issue (or more realistically a one in a million, as I doubt one actually gets nanosec level timer resolution during code execution, even on the fastest machine). I have now pushed Peter's patch, amended to fix the other location where we were using a > i

Re: [Libusbx-devel] Generic device support in Windows

2012-08-22 Thread David Grant
On Tue, Aug 21, 2012 at 10:14 PM, Xiaofan Chen wrote: > On Wed, Aug 22, 2012 at 8:04 AM, David Grant wrote: > > Thanks for the detailed response Pete. > > > > So the big missing feature seems to be how to remove libusbK.sys and > replace > > it with the original driver without having to embed th

Re: [Libusbx-devel] [PATCH] usbfs: Add a new disconnect-and-claim ioctl

2012-08-22 Thread Alan Stern
On Wed, 22 Aug 2012, Hans de Goede wrote: > >> + if ((dc.flags & USBDEVFS_DISCONNECT_CLAIM_IF_DRIVER) && > >> + strncmp(dc.driver, intf->dev.driver->name, > >> + sizeof(dc.driver)) != 0) > >> + return -EBUSY; > >> + > >> +

Re: [Libusbx-devel] [PATCH] usbfs: Add a new disconnect-and-claim ioctl

2012-08-22 Thread Hans de Goede
Hi, On 08/22/2012 05:05 PM, Alan Stern wrote: > On Wed, 22 Aug 2012, Hans de Goede wrote: > >> Apps which deal with devices which also have a kernel driver, need to do >> the following: >> 1) Check which driver is attached, so as to not detach the wrong driver >> (ie detaching usbfs while anot

Re: [Libusbx-devel] [PATCH] usbfs: Add a new disconnect-and-claim ioctl

2012-08-22 Thread Alan Stern
On Wed, 22 Aug 2012, Hans de Goede wrote: > Apps which deal with devices which also have a kernel driver, need to do > the following: > 1) Check which driver is attached, so as to not detach the wrong driver >(ie detaching usbfs while another instance of the app is using the device) > 2) Detac

Re: [Libusbx-devel] libusb-win32 and libusbK support has now been pushed to mainline

2012-08-22 Thread Xiaofan Chen
On Mon, Aug 20, 2012 at 8:32 AM, Pete Batard wrote: > Hopefully will help getting more testing before next release. > > I'm closing #11 and #12 as a result (isoc support will be dealt elsewhere). > > I also pushed the patch provided for #41 > (https://github.com/libusbx/libusbx/pull/41). > The te

Re: [Libusbx-devel] [PATCH] usbfs: Add a new disconnect-and-claim ioctl

2012-08-22 Thread Hans de Goede
Hi, Thanks for the review! On 08/22/2012 02:04 PM, Oliver Neukum wrote: > On Wednesday 22 August 2012 13:42:47 Hans de Goede wrote: >> Apps which deal with devices which also have a kernel driver, need to do >> the following: >> 1) Check which driver is attached, so as to not detach the wrong dri

Re: [Libusbx-devel] [PATCH] usbfs: Add a new disconnect-and-claim ioctl

2012-08-22 Thread Oliver Neukum
On Wednesday 22 August 2012 13:42:47 Hans de Goede wrote: > Apps which deal with devices which also have a kernel driver, need to do > the following: > 1) Check which driver is attached, so as to not detach the wrong driver >(ie detaching usbfs while another instance of the app is using the dev

[Libusbx-devel] [PATCH 1/3] Add a new libusb_detach_kernel_driver_and_claim() function

2012-08-22 Thread Hans de Goede
Apps which deal with devices which also have a kernel driver, need to do the following: 1) Check which driver is attached, so as to not detach the wrong driver (ie detaching usbfs while another instance of the app is using the device) 2) Detach the kernel driver 3) Claim the interface Where mov

[Libusbx-devel] [PATCH 0/3] RFC: Add a new libusb_detach_kernel_driver_and_claim() function

2012-08-22 Thread Hans de Goede
As discussed before apps which do driver-check, driver-detach, claim currently all are more or less racy. This patchset 1) Introduces a new libusb function which allows apps to do this kind of thing in a single call. 2) Makes use of a new ioctl to do this in a race free matter, on systems where thi

[Libusbx-devel] [PATCH 2/3] linux_usbfs: Add support for new disconnect-and-claim ioctl

2012-08-22 Thread Hans de Goede
Signed-off-by: Hans de Goede --- libusb/os/linux_usbfs.c | 28 libusb/os/linux_usbfs.h | 10 ++ 2 files changed, 38 insertions(+) diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index b6194ce..9cadca0 100644 --- a/libusb/os/linux_usbfs.c +++ b/

[Libusbx-devel] [PATCH 3/3] linux_usbfs: Work around a driver binding race in reset handling

2012-08-22 Thread Hans de Goede
I've been seeing these intermittent failures to reclaim an interface after a device reset. After much debugging and inserting sleeps in strategic places to make the race window larger I've found the following race: 1) A user is running some software using libusbx which will automatically detect,

[Libusbx-devel] [PATCH] usbfs: Add a new disconnect-and-claim ioctl

2012-08-22 Thread Hans de Goede
Apps which deal with devices which also have a kernel driver, need to do the following: 1) Check which driver is attached, so as to not detach the wrong driver (ie detaching usbfs while another instance of the app is using the device) 2) Detach the kernel driver 3) Claim the interface Where mov

[Libusbx-devel] [PATCH 3/3] detach-kernel-driver: return ERROR_NOT_FOUND if usbfs is already bound (v3)

2012-08-22 Thread Hans de Goede
Currently applications for devices which only are accessed from userspace can use claim / release interface to make sure they don't get in each others way. The same however does not work for applications which first need to detach a "native" / in kernel driver, as this detach will not only detach n

[Libusbx-devel] [PATCH 1/3] linux_usbfs: Add support for the new get_capabilities ioctl

2012-08-22 Thread Hans de Goede
There were a few (new) usbdevfs capabilities which libusbx could not discover in any other way then checking the kernel version. There are 3 problems with this: 1) It is just not very pretty 2) Given the tendency of enterprise distros to backport stuff it is not reliable 3) Some of these feature

[Libusbx-devel] [PATCH 2/3] linux_usbfs: Avoid unnecessary splitting of bulk transfers (v2)

2012-08-22 Thread Hans de Goede
With the latest kernels it is no longer needed to always split large bulk transfers into multiple urbs. This patch takes advantage of this by not splitting when not necessary. Note that the non-split code path is in essence using the old split code path with an urb count which is always 1. This le

[Libusbx-devel] Various linux patches (v2)

2012-08-22 Thread Hans de Goede
Here are my recent Linux patches, with the review comments taken into account, changes in v2: 1) Avoid a divide by 0 on 0 length bulk packets 2) Improve the various commit messages Regards, Hans -- Live Security Virtual

Re: [Libusbx-devel] [PATCH 1/2] linux_usbfs: Add support for the new get_capabilities ioctl

2012-08-22 Thread Hans de Goede
Hi, Thanks for the reviews! On 08/22/2012 01:42 AM, Pete Batard wrote: > Thanks for these patches. Just a couple points so far: > > On 2012.08.20 22:10, Hans de Goede wrote: >> +__u32 caps; > > Are stdint.h and the kernel expected to be potentially out of sync with > regards to what constitut

Re: [Libusbx-devel] [PATCH 2/2] linux_usbfs: Avoid unnecessary splitting of bulk transfers

2012-08-22 Thread Hans de Goede
Hi, On 08/22/2012 11:14 AM, Xiaofan Chen wrote: > On Tue, Aug 21, 2012 at 5:10 AM, Hans de Goede wrote: >> + /* >> +* Older versions of usbfs place a 16kb limit on bulk URBs. We work >> +* around this by splitting large transfers into 16k blocks, and then >> +* submi

Re: [Libusbx-devel] libusb segfaults - causes pcscd to crash

2012-08-22 Thread sebastiank
Hello Peter, On 22.08.2012 10:39, Peter Stuge wrote: > Here's a patch to fix that bug, but I'm not sure if it is enough to > completely solve the problem. thank you for the patch. I hope that it will solve it. = Regards Sebastian =

Re: [Libusbx-devel] [PATCH 2/2] linux_usbfs: Avoid unnecessary splitting of bulk transfers

2012-08-22 Thread Xiaofan Chen
On Tue, Aug 21, 2012 at 5:10 AM, Hans de Goede wrote: > + /* > +* Older versions of usbfs place a 16kb limit on bulk URBs. We work > +* around this by splitting large transfers into 16k blocks, and then > +* submit all urbs at once. it would be simpler to submit one u

Re: [Libusbx-devel] [PATCH] detach-kernel-driver: return ERROR_NOT_FOUND if usbfs is already bound (v3)

2012-08-22 Thread Xiaofan Chen
On Tue, Aug 21, 2012 at 5:12 PM, Hans de Goede wrote: > Signed-off-by: Hans de Goede > --- > libusb/core.c | 4 > libusb/os/linux_usbfs.c | 6 ++ > 2 files changed, 10 insertions(+) > > diff --git a/libusb/core.c b/libusb/core.c > index 7c2f4d7..4c513f7 100644 > --- a/libusb/c

Re: [Libusbx-devel] libusb segfaults - causes pcscd to crash

2012-08-22 Thread Peter Stuge
sebastiank wrote: > libusbx: warning [add_to_flying_list] failed to arm first timerfd (errno 22, > it_value = 259823:10) Here's a patch to fix that bug, but I'm not sure if it is enough to completely solve the problem. //Peter >From 3b821d0a709c6b5b3094a763bb04e48ed0447050 Mon Sep 17 00

Re: [Libusbx-devel] libusb segfaults - causes pcscd to crash

2012-08-22 Thread sebastiank
On 16.08.2012 22:46, Pete Batard wrote: > If you're using the version of libusbx with the latest patches, we > will get the needed inisght about the cause for the error. I'm using the latest git-mainline version of libusbx on all machines, with the extra debugging output you advised me to include.