diff options
author | Dmitry Fleytman <dfleytma@redhat.com> | 2015-12-25 08:41:43 +0200 |
---|---|---|
committer | Dmitry Fleytman <dfleytma@redhat.com> | 2015-12-25 08:44:38 +0200 |
commit | 3b1f461d5ccea8168482ea9103c3fb49507c2c4e (patch) | |
tree | b307225924e6187a8051fdc29c78a0cf4ea734cb | |
parent | 51ca12740b03237715bffb576c1d78635590b72e (diff) |
Revert "RedirectorStrategy: Ensure there are no short buffers on read"v1.00-10
This reverts commit 32aadcb4fe2b13fce8df679f729ad24e64c746a7.
Reverting commit because a regression was discovered on some devices.
Signed-off-by: Dmitry Fleytman <dfleytma@redhat.com>
-rw-r--r-- | UsbDk/RedirectorStrategy.cpp | 61 | ||||
-rw-r--r-- | UsbDk/RedirectorStrategy.h | 5 | ||||
-rw-r--r-- | UsbDk/UsbTarget.cpp | 14 | ||||
-rw-r--r-- | UsbDk/UsbTarget.h | 8 |
4 files changed, 4 insertions, 84 deletions
diff --git a/UsbDk/RedirectorStrategy.cpp b/UsbDk/RedirectorStrategy.cpp index 17ef8ec..7530114 100644 --- a/UsbDk/RedirectorStrategy.cpp +++ b/UsbDk/RedirectorStrategy.cpp @@ -189,9 +189,6 @@ typedef struct tag_USBDK_REDIRECTOR_REQUEST_CONTEXT WDFMEMORY LockedIsochronousPacketsArray; WDFMEMORY LockedIsochronousResultsArray; - - WDFMEMORY ShadowBuffer; - PVOID ShadowBufferPtr; } USBDK_REDIRECTOR_REQUEST_CONTEXT, *PUSBDK_REDIRECTOR_REQUEST_CONTEXT; class CRedirectorRequest : public CWdfRequest @@ -611,52 +608,6 @@ void CUsbDkRedirectorStrategy::TraceTransferError(const CRedirectorRequest &WdfR DataBuffer.Size()); } -bool CUsbDkRedirectorStrategy::SupplyMaxPacketSizeShadowBuffer(CRedirectorRequest &WdfRequest, - PUSBDK_REDIRECTOR_REQUEST_CONTEXT RequestContext) -{ - CPreAllocatedWdfMemoryBuffer OrigBuffer(RequestContext->LockedBuffer); - auto MaxPacketSize = m_Target.GetPipeMaxPacketSize(RequestContext->EndpointAddress); - - if (OrigBuffer.Size() < MaxPacketSize) - { - TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_REDIRECTOR, - "%!FUNC! Going to allocate shadow buffer of %llu bytes intead of %llu bytes for pipe %llu", - MaxPacketSize, OrigBuffer.Size(), RequestContext->EndpointAddress); - - auto status = WdfMemoryCreate(WDF_NO_OBJECT_ATTRIBUTES, - NonPagedPool, - 'MBSU', - MaxPacketSize, - &RequestContext->ShadowBuffer, - &RequestContext->ShadowBufferPtr); - if (!NT_SUCCESS(status)) - { - TraceEvents(TRACE_LEVEL_ERROR, TRACE_REDIRECTOR, - "%!FUNC! Failed to allocate shadow buffer of %llu bytes: %!STATUS!", MaxPacketSize, status); - - WdfRequest.SetStatus(status); - return false; - } - } - - return true; -} - -void CUsbDkRedirectorStrategy::RetireMaxPacketSizeShadowBuffer(PUSBDK_REDIRECTOR_REQUEST_CONTEXT RequestContext) -{ - if (RequestContext->ShadowBufferPtr != nullptr) - { - ASSERT(RequestContext->Direction == UsbDkTransferDirection::Read); - - ASSERT((RequestContext->TransferType == BulkTransferType) || - (RequestContext->TransferType == InterruptTransferType)); - - CPreAllocatedWdfMemoryBuffer OrigBuffer(RequestContext->LockedBuffer); - RtlCopyMemory(OrigBuffer.Ptr(), RequestContext->ShadowBufferPtr, OrigBuffer.Size()); - WdfObjectDelete(RequestContext->ShadowBuffer); - } -} - void CUsbDkRedirectorStrategy::ReadPipe(WDFREQUEST Request) { CRedirectorRequest WdfRequest(Request); @@ -680,14 +631,7 @@ void CUsbDkRedirectorStrategy::ReadPipe(WDFREQUEST Request) case BulkTransferType: case InterruptTransferType: { - if (!SupplyMaxPacketSizeShadowBuffer(WdfRequest, Context)) - { - break; - } - - auto DataBuffer = (Context->ShadowBufferPtr != nullptr) ? Context->ShadowBuffer : Context->LockedBuffer; - - m_Target.ReadPipeAsync(WdfRequest.Detach(), Context->EndpointAddress, DataBuffer, + m_Target.ReadPipeAsync(WdfRequest.Detach(), Context->EndpointAddress, Context->LockedBuffer, [](WDFREQUEST Request, WDFIOTARGET, PWDF_REQUEST_COMPLETION_PARAMS Params, WDFCONTEXT) { auto status = Params->IoStatus.Status; @@ -699,11 +643,10 @@ void CUsbDkRedirectorStrategy::ReadPipe(WDFREQUEST Request) TraceTransferError(WdfRequest, status, usbCompletionParams->UsbdStatus); } - RetireMaxPacketSizeShadowBuffer(WdfRequest.Context()); - CompleteTransferRequest(WdfRequest, status, usbCompletionParams->UsbdStatus, usbCompletionParams->Parameters.PipeRead.Length); + }); } break; diff --git a/UsbDk/RedirectorStrategy.h b/UsbDk/RedirectorStrategy.h index a39a33b..908dc40 100644 --- a/UsbDk/RedirectorStrategy.h +++ b/UsbDk/RedirectorStrategy.h @@ -57,7 +57,6 @@ private: }; class CRedirectorRequest; -typedef struct tag_USBDK_REDIRECTOR_REQUEST_CONTEXT *PUSBDK_REDIRECTOR_REQUEST_CONTEXT; class CUsbDkRedirectorStrategy : public CUsbDkFilterStrategy { @@ -117,10 +116,6 @@ private: NTSTATUS Status, USBD_STATUS UsbdStatus); - bool SupplyMaxPacketSizeShadowBuffer(CRedirectorRequest &WdfRequest, - PUSBDK_REDIRECTOR_REQUEST_CONTEXT RequestContext); - static void RetireMaxPacketSizeShadowBuffer(PUSBDK_REDIRECTOR_REQUEST_CONTEXT RequestContext); - CWdfUsbTarget m_Target; CUsbDkRedirectorQueueData m_IncomingDataQueue; diff --git a/UsbDk/UsbTarget.cpp b/UsbDk/UsbTarget.cpp index 38e9d09..7a299e0 100644 --- a/UsbDk/UsbTarget.cpp +++ b/UsbDk/UsbTarget.cpp @@ -110,6 +110,7 @@ void CWdfUsbPipe::Create(WDFUSBDEVICE Device, WDFUSBINTERFACE Interface, UCHAR P m_Pipe = WdfUsbInterfaceGetConfiguredPipe(m_Interface, PipeIndex, &m_Info); ASSERT(m_Pipe != nullptr); + WdfUsbTargetPipeSetNoMaximumPacketSizeCheck(m_Pipe); TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_USBTARGET, "%!FUNC! Created pipe #%d, " @@ -332,19 +333,6 @@ void CWdfUsbTarget::ReadPipeAsync(WDFREQUEST Request, ULONG64 EndpointAddress, W } } -size_t CWdfUsbTarget::GetPipeMaxPacketSize(ULONG64 EndpointAddress) -{ - size_t res; - - if (!DoPipeOperation<CWdfUsbInterface::SharedLock>(EndpointAddress, [&res](CWdfUsbPipe &Pipe) { res = Pipe.MaxPacketSize(); })) - { - TraceEvents(TRACE_LEVEL_ERROR, TRACE_USBTARGET, "%!FUNC! Failed because pipe was not found"); - return 0; - } - - return res; -} - void CWdfUsbTarget::ReadIsochronousPipeAsync(WDFREQUEST Request, ULONG64 EndpointAddress, WDFMEMORY Buffer, PULONG64 PacketSizes, size_t PacketNumber, PFN_WDF_REQUEST_COMPLETION_ROUTINE Completion) diff --git a/UsbDk/UsbTarget.h b/UsbDk/UsbTarget.h index f4f46fa..516bcc8 100644 --- a/UsbDk/UsbTarget.h +++ b/UsbDk/UsbTarget.h @@ -64,11 +64,6 @@ public: return m_Info.EndpointAddress; } - size_t MaxPacketSize() const - { - return m_Info.MaximumPacketSize; - } - private: WDFUSBINTERFACE m_Interface = WDF_NO_HANDLE; WDFUSBDEVICE m_Device = WDF_NO_HANDLE; @@ -81,7 +76,6 @@ private: PULONG64 PacketSizes, size_t PacketNumber, PFN_WDF_REQUEST_COMPLETION_ROUTINE Completion); - CWdfUsbPipe(const CWdfUsbPipe&) = delete; CWdfUsbPipe& operator= (const CWdfUsbPipe&) = delete; }; @@ -164,7 +158,7 @@ public: NTSTATUS AbortPipe(WDFREQUEST Request, ULONG64 EndpointAddress); NTSTATUS ResetPipe(WDFREQUEST Request, ULONG64 EndpointAddress); NTSTATUS ResetDevice(WDFREQUEST Request); - size_t GetPipeMaxPacketSize(ULONG64 EndpointAddress); + private: void TracePipeNotFoundError(ULONG64 EndpointAddress); |