From patchwork Mon Jul 31 23:37:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 9873337 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B0444603B4 for ; Mon, 31 Jul 2017 23:38:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C56A28563 for ; Mon, 31 Jul 2017 23:38:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90C92285DE; Mon, 31 Jul 2017 23:38:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40B04285D3 for ; Mon, 31 Jul 2017 23:38:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751816AbdGaXhi (ORCPT ); Mon, 31 Jul 2017 19:37:38 -0400 Received: from mail-pg0-f53.google.com ([74.125.83.53]:35565 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751615AbdGaXhV (ORCPT ); Mon, 31 Jul 2017 19:37:21 -0400 Received: by mail-pg0-f53.google.com with SMTP id v189so374152pgd.2 for ; Mon, 31 Jul 2017 16:37:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QWUv5zyJGtfsxQcR/J4Yg14s39lI9nQLcoxqJNTZfBw=; b=GuB1StQGm+rpkcOGnAqOCCdMn+nm6kEWqudQN+ZtUojZP0xCaF6P/6gQSVkqcHexl+ EqRywsoPNnsw/LZ6NkTkkJf3wQePN/plshtw1x5Iu0z0boXLN5mdmzRBhmiFCMSKsmAL mUdrOWVdeer+5isC20AasgH6LgJxCJdA6Pu/GE2kBGyojQu9Od7MjRAHTjhtehxYM6O2 ehkxLUFRjrhgPqaLmQon1aUaM/a227kBKvog0lBjns73EjTZ5SM4umbJoZ2O3vMcgW/W k6URX7LWiNSQwi63CM9JPEUFHx65BqUFPqhFXGS9xCfst3/wUX4BZs42asTxMenPB/nC 0+vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QWUv5zyJGtfsxQcR/J4Yg14s39lI9nQLcoxqJNTZfBw=; b=rspzMmuBXL+2rA1uoiqeLpAYGERndRfG6GXbNuSIkRbMrDqD2gtGqhKQAL1laRgzPx OQGejpkdz44VZ1ziV3kao9o/0g0ZuXP71qygUkN1hJ5rXva7hto2IUNuneNIoiJKjPN5 5xjF1ij1yGUnsimDfslblEM3tOUrfVTn7Eu+xGdWFA294GX7xuqmUccqPl6GQHhEKBzo Pk8d1EcygbsmUR2aEV00uv9FltOQ7UDgvLlzpBAhY+TRvJoN3duAgbCKQrXzEc0gJtsN XtDaBnKSXoKR7FVjslvKWgw3Zldb0OW8Oz3SPwNXmX0tzIAOyG437Y9dWKlnMuW+XIDT YR0A== X-Gm-Message-State: AIVw110a3DdsSgIa7SnqGeZd4UiGnTkAWIDbOXMNJ/gyRBnmTQw2EC6W D45PrF6D4/q/X7nl X-Received: by 10.99.66.130 with SMTP id p124mr17282832pga.53.1501544241194; Mon, 31 Jul 2017 16:37:21 -0700 (PDT) Received: from xeon-e3.lan (76-14-207-240.or.wavecable.com. [76.14.207.240]) by smtp.gmail.com with ESMTPSA id e6sm36872919pgf.56.2017.07.31.16.37.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Jul 2017 16:37:20 -0700 (PDT) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, corbet@lwn.net Cc: devel@linuxdriverproject.org, linux-doc@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH net-next 4/4] pci-hyperv: do not sleep in compose_msi_msg Date: Mon, 31 Jul 2017 16:37:12 -0700 Message-Id: <20170731233712.12087-5-sthemmin@microsoft.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170731233712.12087-1-sthemmin@microsoft.com> References: <20170731233712.12087-1-sthemmin@microsoft.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The setup of MSI with Hyper-V host was sleeping with locks held. This error is reported when doing SR-IOV hotplug with kernel built with lockdep. BUG: sleeping function called from invalid context at kernel/sched/completion.c:93 in_atomic(): 1, irqs_disabled(): 1, pid: 1405, name: ip 3 locks held by ip/1405: #0: (rtnl_mutex){+.+.+.}, at: [] rtnetlink_rcv+0x1b/0x40 #1: (&desc->request_mutex){+.+...}, at: [] __setup_irq+0xb3/0x720 #2: (&irq_desc_lock_class){-.-...}, at: [] __setup_irq+0xe5/0x720 irq event stamp: 3476 hardirqs last enabled at (3475): [] get_page_from_freelist+0x225/0xc90 hardirqs last disabled at (3476): [] _raw_spin_lock_irqsave+0x27/0x90 softirqs last enabled at (2446): [] ixgbevf_configure+0x380/0x7c0 [ixgbevf] softirqs last disabled at (2444): [] ixgbevf_configure+0x35d/0x7c0 [ixgbevf] The workaround is to poll for host response instead of blocking on completion. Signed-off-by: Stephen Hemminger --- drivers/pci/host/pci-hyperv.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 415dcc69a502..334c9a7b8991 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -1159,7 +1160,12 @@ static void hv_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) goto free_int_desc; } - wait_for_completion(&comp.comp_pkt.host_event); + /* + * Since this function is called with IRQ locks held, can't + * do normal wait for completion; instead poll. + */ + while (!try_wait_for_completion(&comp.comp_pkt.host_event)) + udelay(100); if (comp.comp_pkt.completion_status < 0) { dev_err(&hbus->hdev->device,