Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Drivers: hv: vmbus: Add timeout to vmbus_wait_for_unload

vmbus_wait_for_unload() looks for a CHANNELMSG_UNLOAD_RESPONSE message
coming from Hyper-V. But if the message isn't found for some reason,
the panic path gets hung forever. Add a timeout of 10 seconds to prevent
this.

Fixes: 415719160de3 ("Drivers: hv: vmbus: avoid scheduling in interrupt context in vmbus_initiate_unload()")
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Reviewed-by: Dexuan Cui <decui@microsoft.com>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Link: https://lore.kernel.org/r/1600026449-23651-1-git-send-email-mikelley@microsoft.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>

authored by

Michael Kelley and committed by
Wei Liu
911e1987 19873eec

+5 -2
+5 -2
drivers/hv/channel_mgmt.c
··· 750 750 void *page_addr; 751 751 struct hv_message *msg; 752 752 struct vmbus_channel_message_header *hdr; 753 - u32 message_type; 753 + u32 message_type, i; 754 754 755 755 /* 756 756 * CHANNELMSG_UNLOAD_RESPONSE is always delivered to the CPU which was ··· 760 760 * functional and vmbus_unload_response() will complete 761 761 * vmbus_connection.unload_event. If not, the last thing we can do is 762 762 * read message pages for all CPUs directly. 763 + * 764 + * Wait no more than 10 seconds so that the panic path can't get 765 + * hung forever in case the response message isn't seen. 763 766 */ 764 - while (1) { 767 + for (i = 0; i < 1000; i++) { 765 768 if (completion_done(&vmbus_connection.unload_event)) 766 769 break; 767 770