From patchwork Sun Sep 24 00:16:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 9967689 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 1530860384 for ; Sun, 24 Sep 2017 00:17:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F336128925 for ; Sun, 24 Sep 2017 00:17:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E7C8528929; Sun, 24 Sep 2017 00:17:26 +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=unavailable 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 A885D28927 for ; Sun, 24 Sep 2017 00:17:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751609AbdIXARI (ORCPT ); Sat, 23 Sep 2017 20:17:08 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:52188 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751355AbdIXARH (ORCPT ); Sat, 23 Sep 2017 20:17:07 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B747C6071C; Sun, 24 Sep 2017 00:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1506212226; bh=gGIzE9+CPXxkgzv0zni+8aWouptmQrhysAh7wTTcmHw=; h=From:To:Cc:Subject:Date:From; b=jpp6OuQ+NVtTHIPU8vezkaurKWsZFO8/JaSxgstEX3IkYEugNzb3EfmxC1iFiEyfF J9Ba35Nod4KMjbo4IPmG9+BHHWrVM2Cd/RsV/dEaeqC7Q3ZGh3JfRd+i2n7B3BVWKM P3j6OEtht2bnOBcUaZWa4J3t23Kj3zDIIObqcndo= Received: from drakthul.qualcomm.com (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 5BBAA60618; Sun, 24 Sep 2017 00:17:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1506212226; bh=gGIzE9+CPXxkgzv0zni+8aWouptmQrhysAh7wTTcmHw=; h=From:To:Cc:Subject:Date:From; b=jpp6OuQ+NVtTHIPU8vezkaurKWsZFO8/JaSxgstEX3IkYEugNzb3EfmxC1iFiEyfF J9Ba35Nod4KMjbo4IPmG9+BHHWrVM2Cd/RsV/dEaeqC7Q3ZGh3JfRd+i2n7B3BVWKM P3j6OEtht2bnOBcUaZWa4J3t23Kj3zDIIObqcndo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 5BBAA60618 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org From: Sinan Kaya To: linux-pci@vger.kernel.org, timur@codeaurora.org, alex.williamson@redhat.com Cc: linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sinan Kaya , Bjorn Helgaas , linux-kernel@vger.kernel.org Subject: [PATCH 1/5] PCI: protect restore with device lock to be consistent Date: Sat, 23 Sep 2017 20:16:54 -0400 Message-Id: <1506212218-29103-1-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 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 Commit b014e96d1abb ("PCI: Protect pci_error_handlers->reset_notify() usage with device_lock()") added protection around pci_dev_restore() function so that device specific remove callback does not cause a race condition against hotplug. pci_dev_lock() usage has been forgotten in two different places in the code. Adding locks for pci_slot_restore() and moving pci_dev_restore() inside the locks for pci_try_reset_function(). Signed-off-by: Sinan Kaya --- 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 6078dfc..23681f4 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4344,9 +4344,9 @@ int pci_try_reset_function(struct pci_dev *dev) pci_dev_save_and_disable(dev); rc = __pci_reset_function_locked(dev); + pci_dev_restore(dev); pci_dev_unlock(dev); - pci_dev_restore(dev); return rc; } EXPORT_SYMBOL_GPL(pci_try_reset_function); @@ -4546,7 +4546,9 @@ static void pci_slot_restore(struct pci_slot *slot) list_for_each_entry(dev, &slot->bus->devices, bus_list) { if (!dev->slot || dev->slot != slot) continue; + pci_dev_lock(dev); pci_dev_restore(dev); + pci_dev_unlock(dev); if (dev->subordinate) pci_bus_restore(dev->subordinate); }