From patchwork Tue Jan 2 17:00:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10141045 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 CD1A46034B for ; Tue, 2 Jan 2018 17:01:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDFAF26AE3 for ; Tue, 2 Jan 2018 17:01:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B268128C74; Tue, 2 Jan 2018 17:01:53 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 95E5026AE3 for ; Tue, 2 Jan 2018 17:01:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=7Pp9vadrFJ5W32DKW6UiVQPC4c7MehNKSVSROcoAAE4=; b=slqmGjupKJBT0ENG6FUcEZhNH2 sn1P6DZX2gP0EWM1bvEXmmOUaHz63W44MdhBsZepr8k6y/+1OaxpivbYNmagR2UyW+oyfkS1elsuo FflRTHl0tZYST/6KgfV7TqOWFYMpuExd+AvOQR6bGzG3RdCxQd7XvQax3woABp4pgYx/qXJrHKvam spcq6tWi351IPpEDwk7TJurt0V9l/9dCVLk1xbLtwakJCCqu7H248U0euW6aTKsaVXvbXn7280lMi evw40xCN1gS5zMw8VxIOCejfWd4V2j+6RQzvBwQmqCah5eq0XGfOINtYCLG4eNDnK8O9uNq8ykJQl NZ6YqGxA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eWPwi-0001QP-6Y; Tue, 02 Jan 2018 17:01:48 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eWPvd-0008QJ-FN for linux-arm-kernel@lists.infradead.org; Tue, 02 Jan 2018 17:00:48 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4D845602BD; Tue, 2 Jan 2018 17:00:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1514912432; bh=whYO8FROj019FU23pMDJc+rBoQ/PdZZWIOTNUoRUMKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bznhlluo35mCgIyZVOTCpRfPDUC8zB0Ai9ugoYaz0sHQZJT0skeG7gKMouk6VZ+0U ha0JudqYjr8aiWTlLh+lmV+y+Pw4E4lSvz6dRjh194T5UOrlrSb8QuT4TiF+20uCoj ACCBujNjI+M/Tf6ymJLP2dJOj57kVcH0dhtNCqRU= 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 127296024C; Tue, 2 Jan 2018 17:00:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1514912431; bh=whYO8FROj019FU23pMDJc+rBoQ/PdZZWIOTNUoRUMKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BUgL9UOwerWWcQoa0j2qAbL3V2SxqwM7+mntZ9tuuU/kxK8hb6mzasa8RXT1D2PaK wImrMviZH8IDkzsTZVfNcs0MqvR9bNLyse2wYROgbeZMlD4pHzLFpbRgPUkXbwKksW 8VMZbqaZJ69N1SVvnCbmf4zijCT+7igitpkQffwo= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 127296024C 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 Subject: [PATCH V3 1/6] PCI: Protect restore with device lock to be consistent Date: Tue, 2 Jan 2018 12:00:18 -0500 Message-Id: <1514912423-13341-2-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1514912423-13341-1-git-send-email-okaya@codeaurora.org> References: <1514912423-13341-1-git-send-email-okaya@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180102_090041_803431_D0C4081D X-CRM114-Status: UNSURE ( 9.61 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sinan Kaya , linux-arm-msm@vger.kernel.org, Bjorn Helgaas , open list , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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 Reviewed-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 764ca7b..463b32d 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4448,9 +4448,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); @@ -4658,7 +4658,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); }