summaryrefslogtreecommitdiffstats
path: root/sys/dev/hyperv
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/hyperv')
-rw-r--r--sys/dev/hyperv/include/hyperv.h2
-rw-r--r--sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c9
-rw-r--r--sys/dev/hyperv/vmbus/hv_channel_mgmt.c11
3 files changed, 13 insertions, 9 deletions
diff --git a/sys/dev/hyperv/include/hyperv.h b/sys/dev/hyperv/include/hyperv.h
index 2f82e02..1f93664 100644
--- a/sys/dev/hyperv/include/hyperv.h
+++ b/sys/dev/hyperv/include/hyperv.h
@@ -828,6 +828,8 @@ typedef struct hv_vmbus_channel {
void *per_channel_state;
} hv_vmbus_channel;
+#define HV_VMBUS_CHAN_ISPRIMARY(chan) ((chan)->primary_channel == NULL)
+
static inline void
hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t state)
{
diff --git a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
index c93bd84..9537c84 100644
--- a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
+++ b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
@@ -334,7 +334,7 @@ storvsc_handle_sc_creation(void *context)
int ret = 0;
new_channel = (hv_vmbus_channel *)context;
- device = new_channel->primary_channel->device;
+ device = new_channel->device;
sc = get_stor_device(device, TRUE);
if (sc == NULL)
return;
@@ -837,12 +837,7 @@ hv_storvsc_on_channel_callback(void *context)
struct hv_storvsc_request *request;
struct vstor_packet *vstor_packet;
- if (channel->primary_channel != NULL){
- device = channel->primary_channel->device;
- } else {
- device = channel->device;
- }
-
+ device = channel->device;
KASSERT(device, ("device is NULL"));
sc = get_stor_device(device, FALSE);
diff --git a/sys/dev/hyperv/vmbus/hv_channel_mgmt.c b/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
index df03197..7aa8def 100644
--- a/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
+++ b/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
@@ -211,6 +211,7 @@ vmbus_channel_process_offer(hv_vmbus_channel *new_channel)
* It is a sub channel offer, process it.
*/
new_channel->primary_channel = channel;
+ new_channel->device = channel->device;
mtx_lock(&channel->sc_lock);
TAILQ_INSERT_TAIL(
&channel->sc_list_anchor,
@@ -451,7 +452,10 @@ vmbus_channel_on_offer_rescind_internal(void *context)
hv_vmbus_channel* channel;
channel = (hv_vmbus_channel*)context;
- hv_vmbus_child_device_unregister(channel->device);
+ if (HV_VMBUS_CHAN_ISPRIMARY(channel)) {
+ /* Only primary channel owns the hv_device */
+ hv_vmbus_child_device_unregister(channel->device);
+ }
}
/**
@@ -672,7 +676,10 @@ hv_vmbus_release_unattached_channels(void)
TAILQ_REMOVE(&hv_vmbus_g_connection.channel_anchor,
channel, list_entry);
- hv_vmbus_child_device_unregister(channel->device);
+ if (HV_VMBUS_CHAN_ISPRIMARY(channel)) {
+ /* Only primary channel owns the hv_device */
+ hv_vmbus_child_device_unregister(channel->device);
+ }
hv_vmbus_free_vmbus_channel(channel);
}
bzero(hv_vmbus_g_connection.channels,
OpenPOWER on IntegriCloud