3 * Copyright (c) 2009, Microsoft Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307 USA.
19 * Haiyang Zhang <haiyangz@microsoft.com>
20 * Hank Janssen <hjanssen@microsoft.com>
25 #include <linux/kernel.h>
27 #include "include/osd.h"
28 #include "include/logging.h"
30 #include "VmbusPrivate.h"
34 typedef void (*PFN_CHANNEL_MESSAGE_HANDLER
)(VMBUS_CHANNEL_MESSAGE_HEADER
* msg
);
36 typedef struct _VMBUS_CHANNEL_MESSAGE_TABLE_ENTRY
{
37 VMBUS_CHANNEL_MESSAGE_TYPE messageType
;
38 PFN_CHANNEL_MESSAGE_HANDLER messageHandler
;
39 } VMBUS_CHANNEL_MESSAGE_TABLE_ENTRY
;
41 /* Internal routines */
45 PVMBUS_CHANNEL_MESSAGE_HEADER hdr
48 VmbusChannelOnOpenResult(
49 PVMBUS_CHANNEL_MESSAGE_HEADER hdr
53 VmbusChannelOnOfferRescind(
54 PVMBUS_CHANNEL_MESSAGE_HEADER hdr
58 VmbusChannelOnGpadlCreated(
59 PVMBUS_CHANNEL_MESSAGE_HEADER hdr
63 VmbusChannelOnGpadlTorndown(
64 PVMBUS_CHANNEL_MESSAGE_HEADER hdr
68 VmbusChannelOnOffersDelivered(
69 PVMBUS_CHANNEL_MESSAGE_HEADER hdr
73 VmbusChannelOnVersionResponse(
74 PVMBUS_CHANNEL_MESSAGE_HEADER hdr
78 VmbusChannelProcessOffer(
83 VmbusChannelProcessRescindOffer(
90 #define MAX_NUM_DEVICE_CLASSES_SUPPORTED 4
92 static const GUID gSupportedDeviceClasses
[MAX_NUM_DEVICE_CLASSES_SUPPORTED
]= {
93 /* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
94 {.Data
= {0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f}},/* Storage - SCSI */
95 /* {F8615163-DF3E-46c5-913F-F2D2F965ED0E} */
96 {.Data
= {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E}}, /* Network */
97 /* {CFA8B69E-5B4A-4cc0-B98B-8BA1A1F3F95A} */
98 {.Data
= {0x9E, 0xB6, 0xA8, 0xCF, 0x4A, 0x5B, 0xc0, 0x4c, 0xB9, 0x8B, 0x8B, 0xA1, 0xA1, 0xF3, 0xF9, 0x5A}}, /* Input */
99 /* {32412632-86cb-44a2-9b5c-50d1417354f5} */
100 {.Data
= {0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5}}, /* IDE */
104 /* Channel message dispatch table */
105 static VMBUS_CHANNEL_MESSAGE_TABLE_ENTRY gChannelMessageTable
[ChannelMessageCount
]= {
106 {ChannelMessageInvalid
, NULL
},
107 {ChannelMessageOfferChannel
, VmbusChannelOnOffer
},
108 {ChannelMessageRescindChannelOffer
, VmbusChannelOnOfferRescind
},
109 {ChannelMessageRequestOffers
, NULL
},
110 {ChannelMessageAllOffersDelivered
, VmbusChannelOnOffersDelivered
},
111 {ChannelMessageOpenChannel
, NULL
},
112 {ChannelMessageOpenChannelResult
, VmbusChannelOnOpenResult
},
113 {ChannelMessageCloseChannel
, NULL
},
114 {ChannelMessageGpadlHeader
, NULL
},
115 {ChannelMessageGpadlBody
, NULL
},
116 {ChannelMessageGpadlCreated
, VmbusChannelOnGpadlCreated
},
117 {ChannelMessageGpadlTeardown
, NULL
},
118 {ChannelMessageGpadlTorndown
, VmbusChannelOnGpadlTorndown
},
119 {ChannelMessageRelIdReleased
, NULL
},
120 {ChannelMessageInitiateContact
, NULL
},
121 {ChannelMessageVersionResponse
, VmbusChannelOnVersionResponse
},
122 {ChannelMessageUnload
, NULL
},
131 Allocate and initialize a vmbus channel object
134 struct vmbus_channel
*AllocVmbusChannel(void)
136 struct vmbus_channel
*channel
;
138 channel
= kzalloc(sizeof(*channel
), GFP_ATOMIC
);
144 spin_lock_init(&channel
->inbound_lock
);
146 init_timer(&channel
->poll_timer
);
147 channel
->poll_timer
.data
= (unsigned long)channel
;
148 channel
->poll_timer
.function
= VmbusChannelOnTimer
;
150 /* channel->dataWorkQueue = WorkQueueCreate("data"); */
151 channel
->ControlWQ
= create_workqueue("hv_vmbus_ctl");
152 if (!channel
->ControlWQ
)
164 ReleaseVmbusChannel()
167 Release the vmbus channel object itself
170 static inline void ReleaseVmbusChannel(void* Context
)
172 struct vmbus_channel
*channel
= Context
;
176 DPRINT_DBG(VMBUS
, "releasing channel (%p)", channel
);
177 destroy_workqueue(channel
->ControlWQ
);
178 DPRINT_DBG(VMBUS
, "channel released (%p)", channel
);
191 Release the resources used by the vmbus channel object
194 void FreeVmbusChannel(struct vmbus_channel
*Channel
)
196 del_timer(&Channel
->poll_timer
);
198 /* We have to release the channel's workqueue/thread in the vmbus's workqueue/thread context */
199 /* ie we can't destroy ourselves. */
200 osd_schedule_callback(gVmbusConnection
.WorkQueue
, ReleaseVmbusChannel
,
208 VmbusChannelProcessOffer()
211 Process the offer by creating a channel/device associated with this offer
215 VmbusChannelProcessOffer(
220 struct vmbus_channel
*newChannel
= context
;
221 struct vmbus_channel
*channel
;
229 /* Make sure this is a new offer */
230 spin_lock_irqsave(&gVmbusConnection
.channel_lock
, flags
);
232 ITERATE_LIST_ENTRIES(anchor
, curr
, &gVmbusConnection
.ChannelList
)
234 channel
= CONTAINING_RECORD(curr
, struct vmbus_channel
, ListEntry
);
236 if (!memcmp(&channel
->OfferMsg
.Offer
.InterfaceType
, &newChannel
->OfferMsg
.Offer
.InterfaceType
,sizeof(GUID
)) &&
237 !memcmp(&channel
->OfferMsg
.Offer
.InterfaceInstance
, &newChannel
->OfferMsg
.Offer
.InterfaceInstance
, sizeof(GUID
)))
246 INSERT_TAIL_LIST(&gVmbusConnection
.ChannelList
, &newChannel
->ListEntry
);
248 spin_unlock_irqrestore(&gVmbusConnection
.channel_lock
, flags
);
252 DPRINT_DBG(VMBUS
, "Ignoring duplicate offer for relid (%d)", newChannel
->OfferMsg
.ChildRelId
);
253 FreeVmbusChannel(newChannel
);
258 /* Start the process of binding this offer to the driver */
259 /* We need to set the DeviceObject field before calling VmbusChildDeviceAdd() */
260 newChannel
->DeviceObject
= VmbusChildDeviceCreate(
261 newChannel
->OfferMsg
.Offer
.InterfaceType
,
262 newChannel
->OfferMsg
.Offer
.InterfaceInstance
,
265 DPRINT_DBG(VMBUS
, "child device object allocated - %p", newChannel
->DeviceObject
);
268 * Add the new device to the bus. This will kick off device-driver
269 * binding which eventually invokes the device driver's AddDevice()
273 ret
= VmbusChildDeviceAdd(newChannel
->DeviceObject
);
276 DPRINT_ERR(VMBUS
, "unable to add child device object (relid %d)",
277 newChannel
->OfferMsg
.ChildRelId
);
279 spin_lock_irqsave(&gVmbusConnection
.channel_lock
, flags
);
280 REMOVE_ENTRY_LIST(&newChannel
->ListEntry
);
281 spin_unlock_irqrestore(&gVmbusConnection
.channel_lock
, flags
);
283 FreeVmbusChannel(newChannel
);
288 * This state is used to indicate a successful open
289 * so that when we do close the channel normally, we
290 * can cleanup properly
292 newChannel
->State
= CHANNEL_OPEN_STATE
;
300 VmbusChannelProcessRescindOffer()
303 Rescind the offer by initiating a device removal
307 VmbusChannelProcessRescindOffer(
311 struct vmbus_channel
*channel
= context
;
315 VmbusChildDeviceRemove(channel
->DeviceObject
);
324 VmbusChannelOnOffer()
327 Handler for channel offers from vmbus in parent partition. We ignore all offers except
328 network and storage offers. For each network and storage offers, we create a channel object
329 and queue a work item to the channel object to process the offer synchronously
334 PVMBUS_CHANNEL_MESSAGE_HEADER hdr
337 VMBUS_CHANNEL_OFFER_CHANNEL
* offer
= (VMBUS_CHANNEL_OFFER_CHANNEL
*)hdr
;
338 struct vmbus_channel
*newChannel
;
347 for (i
=0; i
<MAX_NUM_DEVICE_CLASSES_SUPPORTED
; i
++)
349 if (memcmp(&offer
->Offer
.InterfaceType
, &gSupportedDeviceClasses
[i
], sizeof(GUID
)) == 0)
358 DPRINT_DBG(VMBUS
, "Ignoring channel offer notification for child relid %d", offer
->ChildRelId
);
364 guidType
= &offer
->Offer
.InterfaceType
;
365 guidInstance
= &offer
->Offer
.InterfaceInstance
;
367 DPRINT_INFO(VMBUS
, "Channel offer notification - child relid %d monitor id %d allocated %d, "
368 "type {%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x%02x%02x} "
369 "instance {%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x%02x%02x}",
372 offer
->MonitorAllocated
,
373 guidType
->Data
[3], guidType
->Data
[2], guidType
->Data
[1], guidType
->Data
[0], guidType
->Data
[5], guidType
->Data
[4], guidType
->Data
[7], guidType
->Data
[6], guidType
->Data
[8], guidType
->Data
[9], guidType
->Data
[10], guidType
->Data
[11], guidType
->Data
[12], guidType
->Data
[13], guidType
->Data
[14], guidType
->Data
[15],
374 guidInstance
->Data
[3], guidInstance
->Data
[2], guidInstance
->Data
[1], guidInstance
->Data
[0], guidInstance
->Data
[5], guidInstance
->Data
[4], guidInstance
->Data
[7], guidInstance
->Data
[6], guidInstance
->Data
[8], guidInstance
->Data
[9], guidInstance
->Data
[10], guidInstance
->Data
[11], guidInstance
->Data
[12], guidInstance
->Data
[13], guidInstance
->Data
[14], guidInstance
->Data
[15]);
376 /* Allocate the channel object and save this offer. */
377 newChannel
= AllocVmbusChannel();
380 DPRINT_ERR(VMBUS
, "unable to allocate channel object");
384 DPRINT_DBG(VMBUS
, "channel object allocated - %p", newChannel
);
386 memcpy(&newChannel
->OfferMsg
, offer
, sizeof(VMBUS_CHANNEL_OFFER_CHANNEL
));
387 newChannel
->MonitorGroup
= (u8
)offer
->MonitorId
/ 32;
388 newChannel
->MonitorBit
= (u8
)offer
->MonitorId
% 32;
390 /* TODO: Make sure the offer comes from our parent partition */
391 osd_schedule_callback(newChannel
->ControlWQ
, VmbusChannelProcessOffer
,
401 VmbusChannelOnOfferRescind()
404 Rescind offer handler. We queue a work item to process this offer
409 VmbusChannelOnOfferRescind(
410 PVMBUS_CHANNEL_MESSAGE_HEADER hdr
413 VMBUS_CHANNEL_RESCIND_OFFER
* rescind
= (VMBUS_CHANNEL_RESCIND_OFFER
*)hdr
;
414 struct vmbus_channel
*channel
;
418 channel
= GetChannelFromRelId(rescind
->ChildRelId
);
421 DPRINT_DBG(VMBUS
, "channel not found for relId %d", rescind
->ChildRelId
);
425 osd_schedule_callback(channel
->ControlWQ
,
426 VmbusChannelProcessRescindOffer
,
436 VmbusChannelOnOffersDelivered()
439 This is invoked when all offers have been delivered.
444 VmbusChannelOnOffersDelivered(
445 PVMBUS_CHANNEL_MESSAGE_HEADER hdr
456 VmbusChannelOnOpenResult()
459 Open result handler. This is invoked when we received a response
460 to our channel open request. Find the matching request, copy the
461 response and signal the requesting thread.
465 VmbusChannelOnOpenResult(
466 PVMBUS_CHANNEL_MESSAGE_HEADER hdr
469 VMBUS_CHANNEL_OPEN_RESULT
* result
= (VMBUS_CHANNEL_OPEN_RESULT
*)hdr
;
472 struct vmbus_channel_msginfo
*msgInfo
;
473 VMBUS_CHANNEL_MESSAGE_HEADER
* requestHeader
;
474 VMBUS_CHANNEL_OPEN_CHANNEL
* openMsg
;
479 DPRINT_DBG(VMBUS
, "vmbus open result - %d", result
->Status
);
481 /* Find the open msg, copy the result and signal/unblock the wait event */
482 spin_lock_irqsave(&gVmbusConnection
.channelmsg_lock
, flags
);
484 ITERATE_LIST_ENTRIES(anchor
, curr
, &gVmbusConnection
.ChannelMsgList
)
486 msgInfo
= (struct vmbus_channel_msginfo
*)curr
;
487 requestHeader
= (VMBUS_CHANNEL_MESSAGE_HEADER
*)msgInfo
->Msg
;
489 if (requestHeader
->MessageType
== ChannelMessageOpenChannel
)
491 openMsg
= (VMBUS_CHANNEL_OPEN_CHANNEL
*)msgInfo
->Msg
;
492 if (openMsg
->ChildRelId
== result
->ChildRelId
&&
493 openMsg
->OpenId
== result
->OpenId
)
495 memcpy(&msgInfo
->Response
.OpenResult
, result
, sizeof(VMBUS_CHANNEL_OPEN_RESULT
));
496 osd_WaitEventSet(msgInfo
->WaitEvent
);
501 spin_unlock_irqrestore(&gVmbusConnection
.channelmsg_lock
, flags
);
510 VmbusChannelOnGpadlCreated()
513 GPADL created handler. This is invoked when we received a response
514 to our gpadl create request. Find the matching request, copy the
515 response and signal the requesting thread.
519 VmbusChannelOnGpadlCreated(
520 PVMBUS_CHANNEL_MESSAGE_HEADER hdr
523 VMBUS_CHANNEL_GPADL_CREATED
*gpadlCreated
= (VMBUS_CHANNEL_GPADL_CREATED
*)hdr
;
526 struct vmbus_channel_msginfo
*msgInfo
;
527 VMBUS_CHANNEL_MESSAGE_HEADER
*requestHeader
;
528 VMBUS_CHANNEL_GPADL_HEADER
*gpadlHeader
;
533 DPRINT_DBG(VMBUS
, "vmbus gpadl created result - %d", gpadlCreated
->CreationStatus
);
535 /* Find the establish msg, copy the result and signal/unblock the wait event */
536 spin_lock_irqsave(&gVmbusConnection
.channelmsg_lock
, flags
);
538 ITERATE_LIST_ENTRIES(anchor
, curr
, &gVmbusConnection
.ChannelMsgList
)
540 msgInfo
= (struct vmbus_channel_msginfo
*)curr
;
541 requestHeader
= (VMBUS_CHANNEL_MESSAGE_HEADER
*)msgInfo
->Msg
;
543 if (requestHeader
->MessageType
== ChannelMessageGpadlHeader
)
545 gpadlHeader
= (VMBUS_CHANNEL_GPADL_HEADER
*)requestHeader
;
547 if ((gpadlCreated
->ChildRelId
== gpadlHeader
->ChildRelId
) &&
548 (gpadlCreated
->Gpadl
== gpadlHeader
->Gpadl
))
550 memcpy(&msgInfo
->Response
.GpadlCreated
, gpadlCreated
, sizeof(VMBUS_CHANNEL_GPADL_CREATED
));
551 osd_WaitEventSet(msgInfo
->WaitEvent
);
556 spin_unlock_irqrestore(&gVmbusConnection
.channelmsg_lock
, flags
);
565 VmbusChannelOnGpadlTorndown()
568 GPADL torndown handler. This is invoked when we received a response
569 to our gpadl teardown request. Find the matching request, copy the
570 response and signal the requesting thread.
574 VmbusChannelOnGpadlTorndown(
575 PVMBUS_CHANNEL_MESSAGE_HEADER hdr
578 VMBUS_CHANNEL_GPADL_TORNDOWN
* gpadlTorndown
= (VMBUS_CHANNEL_GPADL_TORNDOWN
*)hdr
;
581 struct vmbus_channel_msginfo
*msgInfo
;
582 VMBUS_CHANNEL_MESSAGE_HEADER
*requestHeader
;
583 VMBUS_CHANNEL_GPADL_TEARDOWN
*gpadlTeardown
;
588 /* Find the open msg, copy the result and signal/unblock the wait event */
589 spin_lock_irqsave(&gVmbusConnection
.channelmsg_lock
, flags
);
591 ITERATE_LIST_ENTRIES(anchor
, curr
, &gVmbusConnection
.ChannelMsgList
)
593 msgInfo
= (struct vmbus_channel_msginfo
*)curr
;
594 requestHeader
= (VMBUS_CHANNEL_MESSAGE_HEADER
*)msgInfo
->Msg
;
596 if (requestHeader
->MessageType
== ChannelMessageGpadlTeardown
)
598 gpadlTeardown
= (VMBUS_CHANNEL_GPADL_TEARDOWN
*)requestHeader
;
600 if (gpadlTorndown
->Gpadl
== gpadlTeardown
->Gpadl
)
602 memcpy(&msgInfo
->Response
.GpadlTorndown
, gpadlTorndown
, sizeof(VMBUS_CHANNEL_GPADL_TORNDOWN
));
603 osd_WaitEventSet(msgInfo
->WaitEvent
);
608 spin_unlock_irqrestore(&gVmbusConnection
.channelmsg_lock
, flags
);
617 VmbusChannelOnVersionResponse()
620 Version response handler. This is invoked when we received a response
621 to our initiate contact request. Find the matching request, copy the
622 response and signal the requesting thread.
626 VmbusChannelOnVersionResponse(
627 PVMBUS_CHANNEL_MESSAGE_HEADER hdr
632 struct vmbus_channel_msginfo
*msgInfo
;
633 VMBUS_CHANNEL_MESSAGE_HEADER
*requestHeader
;
634 VMBUS_CHANNEL_INITIATE_CONTACT
*initiate
;
635 VMBUS_CHANNEL_VERSION_RESPONSE
*versionResponse
= (VMBUS_CHANNEL_VERSION_RESPONSE
*)hdr
;
640 spin_lock_irqsave(&gVmbusConnection
.channelmsg_lock
, flags
);
642 ITERATE_LIST_ENTRIES(anchor
, curr
, &gVmbusConnection
.ChannelMsgList
)
644 msgInfo
= (struct vmbus_channel_msginfo
*)curr
;
645 requestHeader
= (VMBUS_CHANNEL_MESSAGE_HEADER
*)msgInfo
->Msg
;
647 if (requestHeader
->MessageType
== ChannelMessageInitiateContact
)
649 initiate
= (VMBUS_CHANNEL_INITIATE_CONTACT
*)requestHeader
;
650 memcpy(&msgInfo
->Response
.VersionResponse
, versionResponse
, sizeof(VMBUS_CHANNEL_VERSION_RESPONSE
));
651 osd_WaitEventSet(msgInfo
->WaitEvent
);
654 spin_unlock_irqrestore(&gVmbusConnection
.channelmsg_lock
, flags
);
663 VmbusOnChannelMessage()
666 Handler for channel protocol messages.
667 This is invoked in the vmbus worker thread context.
670 void VmbusOnChannelMessage(void *Context
)
672 HV_MESSAGE
*msg
=(HV_MESSAGE
*)Context
;
673 VMBUS_CHANNEL_MESSAGE_HEADER
* hdr
;
678 hdr
= (VMBUS_CHANNEL_MESSAGE_HEADER
*)msg
->u
.Payload
;
679 size
=msg
->Header
.PayloadSize
;
681 DPRINT_DBG(VMBUS
, "message type %d size %d", hdr
->MessageType
, size
);
683 if (hdr
->MessageType
>= ChannelMessageCount
)
685 DPRINT_ERR(VMBUS
, "Received invalid channel message type %d size %d", hdr
->MessageType
, size
);
686 print_hex_dump_bytes("", DUMP_PREFIX_NONE
,
687 (unsigned char *)msg
->u
.Payload
, size
);
692 if (gChannelMessageTable
[hdr
->MessageType
].messageHandler
)
694 gChannelMessageTable
[hdr
->MessageType
].messageHandler(hdr
);
698 DPRINT_ERR(VMBUS
, "Unhandled channel message type %d", hdr
->MessageType
);
701 /* Free the msg that was allocated in VmbusOnMsgDPC() */
710 VmbusChannelRequestOffers()
713 Send a request to get all our pending offers.
716 int VmbusChannelRequestOffers(void)
719 VMBUS_CHANNEL_MESSAGE_HEADER
* msg
;
720 struct vmbus_channel_msginfo
*msgInfo
;
724 msgInfo
= kmalloc(sizeof(*msgInfo
) + sizeof(VMBUS_CHANNEL_MESSAGE_HEADER
), GFP_KERNEL
);
725 ASSERT(msgInfo
!= NULL
);
727 msgInfo
->WaitEvent
= osd_WaitEventCreate();
728 msg
= (VMBUS_CHANNEL_MESSAGE_HEADER
*)msgInfo
->Msg
;
730 msg
->MessageType
= ChannelMessageRequestOffers
;
732 /*SpinlockAcquire(gVmbusConnection.channelMsgLock);
733 INSERT_TAIL_LIST(&gVmbusConnection.channelMsgList, &msgInfo->msgListEntry);
734 SpinlockRelease(gVmbusConnection.channelMsgLock);*/
736 ret
= VmbusPostMessage(msg
, sizeof(VMBUS_CHANNEL_MESSAGE_HEADER
));
739 DPRINT_ERR(VMBUS
, "Unable to request offers - %d", ret
);
741 /*SpinlockAcquire(gVmbusConnection.channelMsgLock);
742 REMOVE_ENTRY_LIST(&msgInfo->msgListEntry);
743 SpinlockRelease(gVmbusConnection.channelMsgLock);*/
747 /* osd_WaitEventWait(msgInfo->waitEvent); */
749 /*SpinlockAcquire(gVmbusConnection.channelMsgLock);
750 REMOVE_ENTRY_LIST(&msgInfo->msgListEntry);
751 SpinlockRelease(gVmbusConnection.channelMsgLock);*/
757 kfree(msgInfo
->WaitEvent
);
769 VmbusChannelReleaseUnattachedChannels()
772 Release channels that are unattached/unconnected ie (no drivers associated)
775 void VmbusChannelReleaseUnattachedChannels(void)
778 struct vmbus_channel
*channel
;
779 struct vmbus_channel
*start
= NULL
;
782 spin_lock_irqsave(&gVmbusConnection
.channel_lock
, flags
);
784 while (!IsListEmpty(&gVmbusConnection
.ChannelList
))
786 entry
= TOP_LIST_ENTRY(&gVmbusConnection
.ChannelList
);
787 channel
= CONTAINING_RECORD(entry
, struct vmbus_channel
, ListEntry
);
789 if (channel
== start
)
792 if (!channel
->DeviceObject
->Driver
)
794 REMOVE_ENTRY_LIST(&channel
->ListEntry
);
795 DPRINT_INFO(VMBUS
, "Releasing unattached device object %p", channel
->DeviceObject
);
797 VmbusChildDeviceRemove(channel
->DeviceObject
);
798 FreeVmbusChannel(channel
);
809 spin_unlock_irqrestore(&gVmbusConnection
.channel_lock
, flags
);