This patch fixes 2 issues from Bugzilla:
1. BZ#1136908 - Windows XP launches "Found New Hardware" dialog
when the device gets redirected after plugging
2. BZ#1101593 - Windows reports unsuccessful driver installation
after USB redirection
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
It is basically forbidden to send arbitrary requests to device
directly via PDO while device driver is present in device stack.
This may lead to unexpected behaviour because device may be
in many different states e.g. low power, processing other
requests etc.
In order to avoid sending descriptor requests to devices with
active functional driver we're caching all descriptors we need
on QDR post-processing while we're on top of device stack for
sure.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
WDF request completion information must always be
sizeof(USBDK_TRANSFER_REQUEST) because this is what
user mode passes to Read/Write syscalls.
The length of transfered data must be always returned via
USB_DK_TRANSFER_RESULT structure.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
The problem revealed while testing with driver verifier.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
In some cases driver sends IOCTLS to the underlying devices.
It uses IoBuildDeviceIoControlRequest() function to allocate
IOCTL IRP.
This function allocates threaded IRP which has a number of
limitations for contexts it may be sent from.
In particular it must be sent from PASSIVE_LEVEL
and non-arbitrary thread context to complete successfully.
Since this is not always true for contexts driver sends IRPs from,
never completed IOCTLs were observed on load tests.
This patch fixes the problem by using IoAllocateIrp()
function to allocate IOCTL IRPs.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
During stop redirection process driver signals
redirection stopped event before adding corresponding
device back to childen list.
In case of unfortunate timing client code that
enumerates devices right after stoppng redirection
may not get device for which redirection was stopped
in devices list.
This patch fixes the issue by changing order of
corresponding operations.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Move redirection stopped event signalling from DeviceAdd
callback to QDR post-processing callback.
DeviceAdd callback is not (usually) called for non-redirected devices.
Without this patch stop redirection process fails to
complete because corresponing event never set.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This is a refactoring commit to make code more simple.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Some transfers may be pended for a long time, especially
on input pipes. In order to avoid deadlocks cancel pending
transfers instead of waiting for completion.
Replace WdfIoQueueStopSynchronously() by WdfIoQueueDrain()
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
According to spec control transfer may have no data buffer.
Make driver process cases like this properly.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
During user mode redirector handle creation we wait for
device to appear. During this process we may take a few
unsuccessfull attempts to open device handle.
Do not print error messages for this attempts.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Editorconfig is a nice tool that simplifies
maintenance of consistent coding style.
See http://editorconfig.org for details.
Signed-off-by: Pavel Aronsky <pavel.aronsky@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
CWdfUrb class and CWdfUsbTarget::ConfigurationDescriptor()
are not used anymore.
Signed-off-by: Pavel Aronsky <pavel.aronsky@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
Symlinks not needed anymore since we create redirector handles
in kernel.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This commit contains user mode adaptations for
driver interface changes introduced by previous commit.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
This commit makes redirection creation atomic operation
from user mode client point of view.
This ensures redirection will be stopped automatically
in case of unexpected user mode client termination.
Signed-off-by: Pavel Gurvich <pavel@daynix.com>
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>