From: Paul Durrant Date: Wed, 7 Feb 2024 17:41:45 +0000 (+0000) Subject: Don't prematurely fake transmit responses X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5f5614353471d3815e06135bcccf44ffd16720c8;p=pvdrivers%2Fwin%2Fxenvif.git Don't prematurely fake transmit responses If the device is being ejected then the backend state will transition from XenbusStateConnected to XenbusStateClosing. This is done by the toolstack and should have no effect on the backend's ability to complete requests. Therefore, when we fake responses in __TransmitterRingDisable() we could be racing with an active backend. Hence amend the test in the loop to consider a backend in either XenbusStateConnected or XenbusStateClosing to be worth waiting for. Signed-off-by: Paul Durrant --- diff --git a/src/xenvif/transmitter.c b/src/xenvif/transmitter.c index fefa712..9736d81 100644 --- a/src/xenvif/transmitter.c +++ b/src/xenvif/transmitter.c @@ -3933,6 +3933,7 @@ __TransmitterRingDisable( PCHAR Buffer; XenbusState State; ULONG Attempt; + BOOLEAN WaitForBackend; NTSTATUS status; Transmitter = Ring->Transmitter; @@ -3985,6 +3986,13 @@ __TransmitterRingDisable( Buffer); } + // + // If the we are disabling during an eject then the backend will still be + // be there, but it will be in XenbusStateClosing state, not + // XenbusStateConnected. + // + WaitForBackend = (State == XenbusStateConnected) || (State == XenbusStateClosing); + Attempt = 0; ASSERT3U(Ring->RequestsPushed, ==, Ring->RequestsPosted); while (Ring->ResponsesProcessed != Ring->RequestsPushed) { @@ -3996,7 +4004,7 @@ __TransmitterRingDisable( __TransmitterRingSend(Ring); (VOID) TransmitterRingPoll(Ring); - if ((Attempt >= 100) || (State != XenbusStateConnected)) + if ((Attempt >= 100) || !WaitForBackend) break; // We are waiting for a watch event at DISPATCH_LEVEL so