From patchwork Mon Sep 21 16:27:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "gregkh@linuxfoundation.org" X-Patchwork-Id: 263677 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E438C43465 for ; Mon, 21 Sep 2020 16:46:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62501238A1 for ; Mon, 21 Sep 2020 16:46:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706798; bh=eWCOIoW7uLgq7QZezx0n3yQs8ZcUiDT2ro+oDmpUx5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=qqAx9ddKzJecWrLLwc5qvfaeFSjow6WGtJqDE0HOByy96CBfLZyEEwXKAdMqL07kQ bhTHJqnI4TPQ3RFDGAIzxBPgw4Jq473d6mxgWc3n0CQrm6Ak8iDWOqr8P0SIt19bsK vjgnKj4iJ11RyfcuyNGykykMbW+OtPTyb8bqzmvU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727858AbgIUQqa (ORCPT ); Mon, 21 Sep 2020 12:46:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:52726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728749AbgIUQq2 (ORCPT ); Mon, 21 Sep 2020 12:46:28 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 78F422223E; Mon, 21 Sep 2020 16:46:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706787; bh=eWCOIoW7uLgq7QZezx0n3yQs8ZcUiDT2ro+oDmpUx5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0yn1tJR0DBFy3AtEhu+L3BWrYN3R6pHbkxlYBDfAkrQnHRI7YMLQ75TDOIz7y2r9H XYDVxWWqBTrMcyKju5MsdAvvrIcCMfWarYckYqhWnrJnPUsJBiEFXNtC/U76Pq57tE pBDoD/e7lrGLml+EuPo+xAtnBrkTVUFe9UeznJ7s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Kelley , Dexuan Cui , Vitaly Kuznetsov , Wei Liu , Sasha Levin Subject: [PATCH 5.8 055/118] Drivers: hv: vmbus: Add timeout to vmbus_wait_for_unload Date: Mon, 21 Sep 2020 18:27:47 +0200 Message-Id: <20200921162038.899037678@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162036.324813383@linuxfoundation.org> References: <20200921162036.324813383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Michael Kelley [ Upstream commit 911e1987efc8f3e6445955fbae7f54b428b92bd3 ] 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 Reviewed-by: Dexuan Cui Reviewed-by: Vitaly Kuznetsov Link: https://lore.kernel.org/r/1600026449-23651-1-git-send-email-mikelley@microsoft.com Signed-off-by: Wei Liu Signed-off-by: Sasha Levin --- drivers/hv/channel_mgmt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 417a95e5094dd..af7832e131674 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -750,7 +750,7 @@ static void vmbus_wait_for_unload(void) void *page_addr; struct hv_message *msg; struct vmbus_channel_message_header *hdr; - u32 message_type; + u32 message_type, i; /* * CHANNELMSG_UNLOAD_RESPONSE is always delivered to the CPU which was @@ -760,8 +760,11 @@ static void vmbus_wait_for_unload(void) * functional and vmbus_unload_response() will complete * vmbus_connection.unload_event. If not, the last thing we can do is * read message pages for all CPUs directly. + * + * Wait no more than 10 seconds so that the panic path can't get + * hung forever in case the response message isn't seen. */ - while (1) { + for (i = 0; i < 1000; i++) { if (completion_done(&vmbus_connection.unload_event)) break;