From patchwork Mon Jul 31 23:48:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 795994 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=networkplumber-org.20150623.gappssmtp.com header.i=@networkplumber-org.20150623.gappssmtp.com header.b="U/3A5SAj"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xLx3t6THmz9tWg for ; Tue, 1 Aug 2017 09:48:42 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751339AbdGaXsl (ORCPT ); Mon, 31 Jul 2017 19:48:41 -0400 Received: from mail-pg0-f45.google.com ([74.125.83.45]:37714 "EHLO mail-pg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751329AbdGaXsl (ORCPT ); Mon, 31 Jul 2017 19:48:41 -0400 Received: by mail-pg0-f45.google.com with SMTP id y129so434328pgy.4 for ; Mon, 31 Jul 2017 16:48:40 -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; bh=QWUv5zyJGtfsxQcR/J4Yg14s39lI9nQLcoxqJNTZfBw=; b=U/3A5SAjWDf3cC5iu2K3+gJQjYIHRh43J7pROWTBqracomQaId/zEeaG248wbovKnw YGRqLsaaMLhsoZe1LnUgd21GVZxQ9/WdEE1VVnsKvl/FeGMntNCS07+c6Ljoo9GW8lRZ hZwloVT61ffVpHZrzQKAbFgmIDj8BCP81+O0Ai+5mR8vjDwMqUQ+O6TBJ8ymSqocDrUG mICLQAsUUXoWN0DkvINdG/E+DTU1eiVeiQgkVAKP3IedRI9TTOobaXzweI7s868Lg0bc AEj26rte5+0++QSBCPPoh5hwe5HSvYClQXJoFNFOfj9WCP7EiqQRYaGTcg22dOh02zws +14g== 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; bh=QWUv5zyJGtfsxQcR/J4Yg14s39lI9nQLcoxqJNTZfBw=; b=cgCI9Znq+7DhgpUbsdk3juHHNgO+Il+QmAKi2U5G52phT1vSc+KwNe4Z6WhqNoR77J KOWVLU6JunZBjn/XCdz1BDaid6UN+KlBwxGxmcnmCkkki4OP28Fd7ATRqZuv60k2GAE6 ulCkHcGX2nIuevZxlE3WBwzGAoUMB4i+ZOOcUAc3S1IFtlzrnLOQJjMM5k66l5Ob6lu7 +UWZk3JbGwRzTEf+gNijqkfkOrMJ5SxZrpMO+0GYQDqgV9aXAb/AhmI6wVnHFzK6r32x 7kxFgNYcluMRloTuD/0uz+nb0gj7LcKiid6ZYkeq4A+T6D1pWgqU/2XCINgiTY6s1/dJ itkg== X-Gm-Message-State: AIVw111GjWQmW0H4Vrh+t1ONXejYk645FQ3+HVlEzZqn7iRaR5YNIN8w bPBRrKyVWLH4UqGU X-Received: by 10.98.200.152 with SMTP id i24mr16320202pfk.33.1501544920573; Mon, 31 Jul 2017 16:48:40 -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 o186sm49012436pfo.155.2017.07.31.16.48.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Jul 2017 16:48:39 -0700 (PDT) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: bhelgaas@google.com, kys@microsoft.com Cc: linux-pci@vger.kernel.org, Stephen Hemminger Subject: [PATCH] pci-hyperv: do not sleep in compose_msi_msg Date: Mon, 31 Jul 2017 16:48:29 -0700 Message-Id: <20170731234829.2344-1-sthemmin@microsoft.com> X-Mailer: git-send-email 2.11.0 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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,