https://git.reactos.org/?p=reactos.git;a=commitdiff;h=aaa90f698680fb51d27dc870fbe214ffd982bcde

commit aaa90f698680fb51d27dc870fbe214ffd982bcde
Author:     Victor Perevertkin <vic...@perevertkin.ru>
AuthorDate: Wed Apr 10 03:22:03 2019 +0300
Commit:     Victor Perevertkin <vic...@perevertkin.ru>
CommitDate: Tue Jun 11 04:39:43 2019 +0300

    [USBSTOR] Do not try to retry a failed request
    for all cases except receiving a USBD_STATUS_STALL_PID status.
    This decision should be made by higher-level driver (and classpnp drivers 
do it)
---
 drivers/usb/usbstor/error.c   | 18 +-----------------
 drivers/usb/usbstor/queue.c   |  2 +-
 drivers/usb/usbstor/scsi.c    | 11 +++++------
 drivers/usb/usbstor/usbstor.h |  5 ++---
 4 files changed, 9 insertions(+), 27 deletions(-)

diff --git a/drivers/usb/usbstor/error.c b/drivers/usb/usbstor/error.c
index 93090327650..571c89dab42 100644
--- a/drivers/usb/usbstor/error.c
+++ b/drivers/usb/usbstor/error.c
@@ -107,7 +107,7 @@ USBSTOR_HandleTransferError(
     pCDB = (PCDB)Request->Cdb;
     ASSERT(pCDB);
 
-    if (Status != STATUS_SUCCESS || Context->RetryCount >= 1)
+    if (!NT_SUCCESS(Status))
     {
         // Complete the master IRP
         Context->Irp->IoStatus.Status = Status;
@@ -124,22 +124,6 @@ USBSTOR_HandleTransferError(
         // clear timer srb
         Context->FDODeviceExtension->LastTimerActiveSrb = NULL;
     }
-    else
-    {
-        DPRINT1("Retrying Count %lu %p\n", Context->RetryCount, 
Stack->DeviceObject);
-
-        // re-schedule request
-        USBSTOR_HandleExecuteSCSI(Stack->DeviceObject, Context->Irp, 
Context->RetryCount + 1);
-
-        // srb error handling finished
-        Context->FDODeviceExtension->SrbErrorHandlingActive = FALSE;
-
-        // srb error handling finished
-        Context->FDODeviceExtension->TimerWorkQueueEnabled = TRUE;
-
-        // clear timer srb
-        Context->FDODeviceExtension->LastTimerActiveSrb = NULL;
-    }
 
     FreeItem(Context);
 
diff --git a/drivers/usb/usbstor/queue.c b/drivers/usb/usbstor/queue.c
index f4dbe5c63d9..8babc987912 100644
--- a/drivers/usb/usbstor/queue.c
+++ b/drivers/usb/usbstor/queue.c
@@ -355,7 +355,7 @@ USBSTOR_StartIo(
         return;
     }
 
-    USBSTOR_HandleExecuteSCSI(IoStack->DeviceObject, Irp, 0);
+    USBSTOR_HandleExecuteSCSI(IoStack->DeviceObject, Irp);
 
     // FIXME: handle error
 }
diff --git a/drivers/usb/usbstor/scsi.c b/drivers/usb/usbstor/scsi.c
index 05ef1c925c8..002b8f29768 100644
--- a/drivers/usb/usbstor/scsi.c
+++ b/drivers/usb/usbstor/scsi.c
@@ -183,9 +183,9 @@ USBSTOR_CSWCompletionRoutine(
     {
         if (USBD_STATUS(Context->Urb.UrbHeader.Status) == 
USBD_STATUS(USBD_STATUS_STALL_PID))
         {
-            if (Context->RetryCount < 2)
+            if (Context->StallRetryCount < 2)
             {
-                ++Context->RetryCount;
+                ++Context->StallRetryCount;
 
                 // clear stall and resend cbw
                 Context->ErrorIndex = 1;
@@ -345,7 +345,7 @@ USBSTOR_DataCompletionRoutine(
     }
     else if (USBD_STATUS(Context->Urb.UrbHeader.Status) == 
USBD_STATUS(USBD_STATUS_STALL_PID))
     {
-        ++Context->RetryCount;
+        ++Context->StallRetryCount;
 
         Request->SrbStatus = SRB_STATUS_DATA_OVERRUN;
         Request->DataTransferLength = 
Context->Urb.UrbBulkOrInterruptTransfer.TransferBufferLength;
@@ -527,7 +527,7 @@ USBSTOR_SendCBWRequest(
     // initialize rest of context
     Context->Irp = Irp;
     Context->FDODeviceExtension = FDODeviceExtension;
-    Context->RetryCount = 0;
+    Context->StallRetryCount = 0;
 
     return USBSTOR_IssueBulkOrInterruptRequest(
         FDODeviceExtension,
@@ -586,8 +586,7 @@ USBSTOR_IssueRequestSense(
 NTSTATUS
 USBSTOR_HandleExecuteSCSI(
     IN PDEVICE_OBJECT DeviceObject,
-    IN PIRP Irp,
-    IN ULONG RetryCount)
+    IN PIRP Irp)
 {
     PCDB pCDB;
     NTSTATUS Status;
diff --git a/drivers/usb/usbstor/usbstor.h b/drivers/usb/usbstor/usbstor.h
index 25066cc1de7..d2a72eccc96 100644
--- a/drivers/usb/usbstor/usbstor.h
+++ b/drivers/usb/usbstor/usbstor.h
@@ -286,7 +286,7 @@ typedef struct
     PIRP Irp;
     PFDO_DEVICE_EXTENSION FDODeviceExtension;
     ULONG ErrorIndex;
-    ULONG RetryCount;
+    ULONG StallRetryCount;                                            // the 
number of retries after receiving USBD_STATUS_STALL_PID status
     union
     {
         CBW cbw;
@@ -406,8 +406,7 @@ USBSTOR_GetPipeHandles(
 NTSTATUS
 USBSTOR_HandleExecuteSCSI(
     IN PDEVICE_OBJECT DeviceObject,
-    IN PIRP Irp,
-    IN ULONG RetryCount);
+    IN PIRP Irp);
 
 NTSTATUS
 USBSTOR_SendCSWRequest(

Reply via email to