win-pvdrivers

changeset 947:a05b13795cb2

storport calls StartIo even when the adapter fails to initialise. Make sure this doesn't crash.
author James Harper <james.harper@bendigoit.com.au>
date Mon Aug 22 23:14:01 2011 +1000 (2011-08-22)
parents 88bae0c1735f
children 12145457bd45
files xenvbd/xenvbd_scsiport.c xenvbd/xenvbd_storport.c
line diff
     1.1 --- a/xenvbd/xenvbd_scsiport.c	Mon Aug 22 22:05:03 2011 +1000
     1.2 +++ b/xenvbd/xenvbd_scsiport.c	Mon Aug 22 23:14:01 2011 +1000
     1.3 @@ -992,6 +992,8 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
     1.4          shadow = &xvdd->shadows[rep->id & SHADOW_ID_ID_MASK];
     1.5          if (shadow->reset)
     1.6          {
     1.7 +          shadow->srb->SrbStatus = SRB_STATUS_BUS_RESET;
     1.8 +          ScsiPortNotification(RequestComplete, xvdd, shadow->srb);
     1.9            KdPrint((__DRIVER_NAME "     discarding reset shadow\n"));
    1.10            for (j = 0; j < shadow->req.nr_segments; j++)
    1.11            {
    1.12 @@ -1540,13 +1542,9 @@ XenVbd_HwScsiResetBus(PVOID DeviceExtens
    1.13      {
    1.14        if (xvdd->shadows[i].srb)
    1.15        {
    1.16 -        KdPrint((__DRIVER_NAME "     Completing in-flight srb %p with status SRB_STATUS_BUS_RESET\n", xvdd->shadows[i].srb));
    1.17 -        /* set reset here so that the interrupt won't do anything with the srb but will dispose of the shadow entry correctly */
    1.18 +        //KdPrint((__DRIVER_NAME "     Completing in-flight srb %p with status SRB_STATUS_BUS_RESET\n", xvdd->shadows[i].srb));
    1.19 +        /* set reset here so that the interrupt will return it with SRB_STATUS_BUS_RESET */
    1.20          xvdd->shadows[i].reset = TRUE;
    1.21 -        xvdd->shadows[i].srb->SrbStatus = SRB_STATUS_BUS_RESET;
    1.22 -        ScsiPortNotification(RequestComplete, xvdd, xvdd->shadows[i].srb);
    1.23 -        xvdd->shadows[i].srb = NULL;
    1.24 -        xvdd->shadows[i].aligned_buffer_in_use = FALSE;
    1.25        }
    1.26      }
    1.27  
     2.1 --- a/xenvbd/xenvbd_storport.c	Mon Aug 22 22:05:03 2011 +1000
     2.2 +++ b/xenvbd/xenvbd_storport.c	Mon Aug 22 23:14:01 2011 +1000
     2.3 @@ -179,6 +179,7 @@ XenVbd_InitConfig(PXENVBD_DEVICE_DATA xv
     2.4    status = xvdd->vectors.XenPci_XenConfigDevice(xvdd->vectors.context);
     2.5    if (!NT_SUCCESS(status))
     2.6    {
     2.7 +    xvdd->inactive = TRUE;
     2.8      KdPrint(("Failed to complete device configuration (%08x)\n", status));
     2.9      FUNCTION_EXIT();
    2.10      return SP_RETURN_BAD_CONFIG;
    2.11 @@ -718,6 +719,8 @@ XenVbd_VirtualHwStorFindAdapter(PVOID De
    2.12      status = XenVbd_InitConfig(xvdd);
    2.13      if (status != SP_RETURN_FOUND)
    2.14      {
    2.15 +      /* set inactive here so StartIo is harmless - we still get called with a PNP remove (or similar) */
    2.16 +      xvdd->inactive = TRUE;
    2.17        FUNCTION_EXIT();
    2.18        return status;
    2.19      }
    2.20 @@ -733,6 +736,8 @@ XenVbd_VirtualHwStorFindAdapter(PVOID De
    2.21    status = XenVbd_InitFromConfig(xvdd);
    2.22    if (status != SP_RETURN_FOUND)
    2.23    {
    2.24 +    /* set inactive here so StartIo is harmless - we still get called with a PNP remove (or similar) */
    2.25 +    xvdd->inactive = TRUE;
    2.26      FUNCTION_EXIT();
    2.27      return status;
    2.28    }