From patchwork Tue May 23 05:42:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9741937 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 EAEF76032B for ; Tue, 23 May 2017 05:42:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF29C2877B for ; Tue, 23 May 2017 05:42:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D357E28784; Tue, 23 May 2017 05:42:13 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 E96F82878B for ; Tue, 23 May 2017 05:42:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933504AbdEWFmM (ORCPT ); Tue, 23 May 2017 01:42:12 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:33038 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933266AbdEWFmL (ORCPT ); Tue, 23 May 2017 01:42:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EnKr0kpw9J+OM2NUDqwJqmtYTDuYzzxOcY4nT72dYSo=; b=uRn4G1c/lx2HcbNF43h+BgVa6 nGOKla19Ju2KAQoR1UOyqft3wc9kloRHOOQ538Jm4tLn2YjHIICM6O02sQPwPSPFQnqh8OPMNcxfs UzJpVu1G9O2Z3kG1T5fTF2y51WjzubWQs178O/Djwkhwb06ps1GPa+6xZVOJS5uRtjkhnJ9NaQM6F z3Cl48ZiRJVU8RYgbc1/eN6nUIvRWAw5rETtVw2ArPWA5nkyB1pLNM/HU59BKfMnk3l9izBpNysex Zh2KoOWQ7yqKeXAbWdZAavyfEPb4H/bwHEfmCnZUtOmQwlylxXgJeeudDr05YVhvlDKJtpsBYWEGo 2pEX3c7og==; Received: from clnet-p099-196.ikbnet.co.at ([83.175.99.196] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1dD2a9-0002Uo-Uv; Tue, 23 May 2017 05:42:10 +0000 From: Christoph Hellwig To: helgaas@kernel.org Cc: rakesh@tuxera.com, linux-pci@vger.kernel.org, linux-nvme@lists.infradead.org Subject: [PATCH] PCI: ensure the PCI device is locked over ->reset_notify calls Date: Tue, 23 May 2017 07:42:02 +0200 Message-Id: <20170523054202.7985-2-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170523054202.7985-1-hch@lst.de> References: <20170523054202.7985-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 Without this ->notify_reset instance may race with ->remove calls, which can be easily triggered in NVMe. Reported-by: Rakesh Pandit Tested-by: Rakesh Pandit Signed-off-by: Christoph Hellwig --- drivers/pci/pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b01bd5bba8e6..b61ad77dc322 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4275,11 +4275,13 @@ int pci_reset_function(struct pci_dev *dev) if (rc) return rc; + pci_dev_lock(dev); pci_dev_save_and_disable(dev); - rc = pci_dev_reset(dev, 0); + rc = __pci_dev_reset(dev, 0); pci_dev_restore(dev); + pci_dev_unlock(dev); return rc; }