freebsd-skq/sys/dev/hyperv/vmbus
delphij 850d0994e4 hyperv: vmbus: run non-blocking message handlers in vmbus_msg_swintr()
We'll remove the per-channel control_work_queue because it can't properly
do serialization of message handling, e.g., when there are 2 NIC devices,
vmbus_channel_on_offer() -> hv_queue_work_item() has a race condition:
for an SMP VM, vmbus_channel_process_offer() can run concurrently on
different CPUs and if the second NIC's
vmbus_channel_process_offer() -> hv_vmbus_child_device_register() runs
first, the second NIC's name will be hn0 and the first NIC's name will
be hn1!

We can fix the race condition by removing the per-channel control_work_queue
and run all the message handlers in the global
hv_vmbus_g_connection.work_queue -- we'll do this in the next patch.

With the coming next patch, we have to run the non-blocking handlers
directly in the kernel thread vmbus_msg_swintr(), because the special
handling of sub-channel: when a sub-channel (e.g., of the storvsc driver)
is received and being handled in vmbus_channel_on_offer() running on the
global hv_vmbus_g_connection.work_queue, vmbus_channel_process_offer()
invokes channel->sc_creation_callback, i.e., storvsc_handle_sc_creation,
and the callback will invoke hv_vmbus_channel_open() -> hv_vmbus_post_message
and expect a further reply from the host, but the handling of the further
messag can't be done because the current message's handling hasn't finished
yet; as result, hv_vmbus_channel_open() -> sema_timedwait() will time out
and th device can't work.

Also renamed the handler type from hv_pfn_channel_msg_handler to
vmbus_msg_handler: the 'pfn' and 'channel' in the old name make no sense.

Submitted by:	Dexuan Cui <decui microsoft com>
Reviewed by:	royger
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D4596
2015-12-29 08:19:43 +00:00
..
hv_channel_mgmt.c hyperv: vmbus: run non-blocking message handlers in vmbus_msg_swintr() 2015-12-29 08:19:43 +00:00
hv_channel.c Microsoft vmbus, storage and other related driver enhancements for HyperV. 2015-04-29 10:12:34 +00:00
hv_connection.c Microsoft vmbus, storage and other related driver enhancements for HyperV. 2015-04-29 10:12:34 +00:00
hv_hv.c Microsoft vmbus, storage and other related driver enhancements for HyperV. 2015-04-29 10:12:34 +00:00
hv_ring_buffer.c Microsoft vmbus, storage and other related driver enhancements for HyperV. 2015-04-29 10:12:34 +00:00
hv_vmbus_drv_freebsd.c hyperv: vmbus: run non-blocking message handlers in vmbus_msg_swintr() 2015-12-29 08:19:43 +00:00
hv_vmbus_priv.h hyperv: vmbus: run non-blocking message handlers in vmbus_msg_swintr() 2015-12-29 08:19:43 +00:00