From patchwork Fri Oct 19 03:23:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10648587 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-2.web.codeaurora.org (Postfix) with ESMTP id D7FFA1508 for ; Fri, 19 Oct 2018 03:23:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C73D428C52 for ; Fri, 19 Oct 2018 03:23:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAC5428C5A; Fri, 19 Oct 2018 03:23:51 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 2ED0B28C67 for ; Fri, 19 Oct 2018 03:23:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726424AbeJSL15 (ORCPT ); Fri, 19 Oct 2018 07:27:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:52484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726245AbeJSL15 (ORCPT ); Fri, 19 Oct 2018 07:27:57 -0400 Received: from sinanubuntu1604.mkjiurmyylmellclgttazegk5f.bx.internal.cloudapp.net (unknown [40.117.90.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 72DB32145D; Fri, 19 Oct 2018 03:23:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539919428; bh=5nVxZiiFE6JsZvFBHPP1fk+cixpId9J7MuomGsZEm7M=; h=From:To:Cc:Subject:Date:From; b=n5Fjx1/PHOfNPT2DJZ2ZBdlaD+x3lGa/P5GlQ1T0NXl4FeixVnh0fjmNylyA9L8si Q5f2cHIAS16pG7zwzyVsvrk7mCjfEwmYUjmdgS0mDoO+K1MLZoc80qTRvxioTq7x35 oXRcmx4hMxDhFm2PCmb35XZSi5maHwsHoy4IgjVg= From: Sinan Kaya To: linux-pci@vger.kernel.org Cc: Sinan Kaya , Mike Marciniszyn , Dennis Dalessandro , Doug Ledford , Jason Gunthorpe , Derek Chickles , Satanand Burla , Felix Manlunas , Raghu Vatsavayi , "David S. Miller" , Bjorn Helgaas , Boris Ostrovsky , Juergen Gross , Jia-Ju Bai Subject: [RFC PATCH v1 1/3] PCI: Unify pci_reset_function_locked() and __pci_reset_function_locked() Date: Fri, 19 Oct 2018 03:23:41 +0000 Message-Id: <20181019032345.5791-1-okaya@kernel.org> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 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 difference between pci_reset_function_locked() and __pci_reset_function_locked() is the saving and restoring of the registers. Unify these API by adding saverestore argument that caller passes. Signed-off-by: Sinan Kaya --- drivers/infiniband/hw/hfi1/pcie.c | 3 ++- drivers/net/ethernet/cavium/liquidio/lio_main.c | 3 ++- drivers/pci/pci.c | 6 ++++-- drivers/pci/pci.h | 1 + drivers/xen/xen-pciback/pci_stub.c | 9 ++++++--- include/linux/pci.h | 7 +++++-- 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c index 38f96192e5f0..a43cd031bfe4 100644 --- a/drivers/infiniband/hw/hfi1/pcie.c +++ b/drivers/infiniband/hw/hfi1/pcie.c @@ -897,7 +897,8 @@ static int trigger_sbr(struct hfi1_devdata *dd) * to be implemented to have cleaner interface but this fixes the * current brokenness */ - return __pci_reset_function_locked(dev, PCI_RESET_LINK); + return pci_reset_function_locked(dev, PCI_RESET_LINK | + PCI_RESET_NOSAVERESTORE); } /* diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c index 0ff76722734d..4ae3935ff10d 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c @@ -989,7 +989,8 @@ static void octeon_pci_flr(struct octeon_device *oct) pci_write_config_word(oct->pci_dev, PCI_COMMAND, PCI_COMMAND_INTX_DISABLE); - rc = __pci_reset_function_locked(oct->pci_dev, PCI_RESET_ANY); + rc = pci_reset_function_locked(oct->pci_dev, PCI_RESET_ANY | + PCI_RESET_NOSAVERESTORE); if (rc != 0) dev_err(&oct->pci_dev->dev, "Error %d resetting PCI function %d\n", diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 1feecbb7f85d..ccd69f5d01f3 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4856,11 +4856,13 @@ int pci_reset_function_locked(struct pci_dev *dev, u32 reset_type) if (!dev->reset_fn) return -ENOTTY; - pci_dev_save_and_disable(dev); + if (!(reset_type & PCI_RESET_NOSAVERESTORE)) + pci_dev_save_and_disable(dev); rc = __pci_reset_function_locked(dev, reset_type); - pci_dev_restore(dev); + if (!(reset_type & PCI_RESET_NOSAVERESTORE)) + pci_dev_restore(dev); return rc; } diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 0444bfa51b52..fbfb44fb32b7 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -35,6 +35,7 @@ int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vmai, int pci_probe_reset_function(struct pci_dev *dev, u32 reset_type); int pci_bridge_secondary_bus_reset(struct pci_dev *dev); +int __pci_reset_function_locked(struct pci_dev *dev, u32 reset_type); /** * struct pci_platform_pm_ops - Firmware PM callbacks diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c index 6dfb805bcb19..7a27d8fb0528 100644 --- a/drivers/xen/xen-pciback/pci_stub.c +++ b/drivers/xen/xen-pciback/pci_stub.c @@ -105,7 +105,8 @@ static void pcistub_device_release(struct kref *kref) /* Call the reset function which does not take lock as this * is called from "unbind" which takes a device_lock mutex. */ - __pci_reset_function_locked(dev, PCI_RESET_ANY); + pci_reset_function_locked(dev, PCI_RESET_ANY | + PCI_RESET_NOSAVERESTORE); if (pci_load_and_free_saved_state(dev, &dev_data->pci_saved_state)) dev_info(&dev->dev, "Could not reload PCI state\n"); else @@ -283,7 +284,8 @@ void pcistub_put_pci_dev(struct pci_dev *dev) * (so it's ready for the next domain) */ device_lock_assert(&dev->dev); - __pci_reset_function_locked(dev, PCI_RESET_ANY); + pci_reset_function_locked(dev, PCI_RESET_ANY | + PCI_RESET_NOSAVERESTORE); dev_data = pci_get_drvdata(dev); ret = pci_load_saved_state(dev, dev_data->pci_saved_state); @@ -417,7 +419,8 @@ static int pcistub_init_device(struct pci_dev *dev) dev_err(&dev->dev, "Could not store PCI conf saved state!\n"); else { dev_dbg(&dev->dev, "resetting (FLR, D3, etc) the device\n"); - __pci_reset_function_locked(dev, PCI_RESET_ANY); + pci_reset_function_locked(dev, PCI_RESET_ANY | + PCI_RESET_NOSAVERESTORE); pci_restore_state(dev); } /* Now disable the device (this also ensures some private device diff --git a/include/linux/pci.h b/include/linux/pci.h index cfb1018d774e..fedd34a5af77 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -893,17 +893,21 @@ enum { * recovery. Using this option directly and bypassing hotplug driver may * cause a deadlock if platform supports hotplug. Please refer to * PCI_RESET_LINK and let the PCI core do the hotplug detection. + * + * PCI_RESET_NOSAVERESTORE tells the PCI core to not save the card context + * before performing a reset and restore the values after reset. */ #define PCI_RESET_DEV_SPECIFIC (1 << 0) #define PCI_RESET_FLR (1 << 1) #define PCI_RESET_PM (1 << 2) #define PCI_RESET_SLOT (1 << 3) #define PCI_RESET_BUS (1 << 4) +#define PCI_RESET_NOSAVERESTORE (1 << 5) -#define PCI_RESET_ANY (~0) #define PCI_RESET_FUNC (PCI_RESET_DEV_SPECIFIC | \ PCI_RESET_FLR | PCI_RESET_PM) #define PCI_RESET_LINK (PCI_RESET_SLOT | PCI_RESET_BUS) +#define PCI_RESET_ANY (PCI_RESET_FUNC | PCI_RESET_LINK) /* These external functions are only available when PCI support is enabled */ #ifdef CONFIG_PCI @@ -1167,7 +1171,6 @@ u32 pcie_bandwidth_available(struct pci_dev *dev, struct pci_dev **limiting_dev, void pcie_print_link_status(struct pci_dev *dev); bool pcie_has_flr(struct pci_dev *dev); int pcie_flr(struct pci_dev *dev); -int __pci_reset_function_locked(struct pci_dev *dev, u32 reset_type); int pci_reset_function(struct pci_dev *dev, u32 reset_type); int pci_reset_function_locked(struct pci_dev *dev, u32 reset_type); int pci_try_reset_function(struct pci_dev *dev, u32 reset_type); From patchwork Fri Oct 19 03:23:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10648585 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-2.web.codeaurora.org (Postfix) with ESMTP id 83C0F13B0 for ; Fri, 19 Oct 2018 03:23:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62FDE28C52 for ; Fri, 19 Oct 2018 03:23:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B3BC28C6C; Fri, 19 Oct 2018 03:23:51 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 D580628C52 for ; Fri, 19 Oct 2018 03:23:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726542AbeJSL14 (ORCPT ); Fri, 19 Oct 2018 07:27:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:52508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726424AbeJSL14 (ORCPT ); Fri, 19 Oct 2018 07:27:56 -0400 Received: from sinanubuntu1604.mkjiurmyylmellclgttazegk5f.bx.internal.cloudapp.net (unknown [40.117.90.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 17C0E21477; Fri, 19 Oct 2018 03:23:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539919429; bh=iFvklhw9+TTG2ySm/Lmg/biUNaMOqsc4wFsnM+KJvL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tHjlFR1xx3r1BKUgLuNaxcD0sYGL2qH7Jkg5oVSQbxEC716g+WXY8X7DmQ2GhWtUZ QsstNRZ1MzRirebENP/GkKL9EUtq7+sQG47dnOmIi28mBF/NZ3JIs+zNvVsS7urPl2 coZ/9A1gB3yFL4dgagjL/garsPkFxiMDb+qm1vVc= From: Sinan Kaya To: linux-pci@vger.kernel.org Cc: Sinan Kaya , Bjorn Helgaas Subject: [RFC PATCH v1 2/3] PCI: Add options to pci_reset_function Date: Fri, 19 Oct 2018 03:23:42 +0000 Message-Id: <20181019032345.5791-2-okaya@kernel.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181019032345.5791-1-okaya@kernel.org> References: <20181019032345.5791-1-okaya@kernel.org> MIME-Version: 1.0 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 Getting ready to deprecate pci_reset_function_locked(). Add saverestore and locked parameters to pci_reset_function() function and add saverestore = true and locked = false to all existing callers. Signed-off-by: Sinan Kaya --- drivers/pci/pci.c | 14 ++++++++++---- include/linux/pci.h | 4 ++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index ccd69f5d01f3..17b10c33cb53 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4819,13 +4819,19 @@ int pci_reset_function(struct pci_dev *dev, u32 reset_type) if (!dev->reset_fn) return -ENOTTY; - pci_dev_lock(dev); - pci_dev_save_and_disable(dev); + if (!(reset_type & PCI_RESET_ALREADYLOCKED)) + pci_dev_lock(dev); + + if (!(reset_type & PCI_RESET_NOSAVERESTORE)) + pci_dev_save_and_disable(dev); rc = __pci_reset_function_locked(dev, reset_type); - pci_dev_restore(dev); - pci_dev_unlock(dev); + if (!(reset_type & PCI_RESET_NOSAVERESTORE)) + pci_dev_restore(dev); + + if (!(reset_type & PCI_RESET_ALREADYLOCKED)) + pci_dev_unlock(dev); return rc; } diff --git a/include/linux/pci.h b/include/linux/pci.h index fedd34a5af77..ad5996d521eb 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -896,6 +896,9 @@ enum { * * PCI_RESET_NOSAVERESTORE tells the PCI core to not save the card context * before performing a reset and restore the values after reset. + * + * PCI_RESET_ALREADYLOCKED indicates that caller is holding the device lock and + * PCI core should not try to lock again. */ #define PCI_RESET_DEV_SPECIFIC (1 << 0) #define PCI_RESET_FLR (1 << 1) @@ -903,6 +906,7 @@ enum { #define PCI_RESET_SLOT (1 << 3) #define PCI_RESET_BUS (1 << 4) #define PCI_RESET_NOSAVERESTORE (1 << 5) +#define PCI_RESET_ALREADYLOCKED (1 << 6) #define PCI_RESET_FUNC (PCI_RESET_DEV_SPECIFIC | \ PCI_RESET_FLR | PCI_RESET_PM) From patchwork Fri Oct 19 03:23:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10648589 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-2.web.codeaurora.org (Postfix) with ESMTP id BFB1713B0 for ; Fri, 19 Oct 2018 03:23:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF4F128C52 for ; Fri, 19 Oct 2018 03:23:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A34E128C67; Fri, 19 Oct 2018 03:23:55 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 3513228C52 for ; Fri, 19 Oct 2018 03:23:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726245AbeJSL2B (ORCPT ); Fri, 19 Oct 2018 07:28:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:52558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726562AbeJSL2B (ORCPT ); Fri, 19 Oct 2018 07:28:01 -0400 Received: from sinanubuntu1604.mkjiurmyylmellclgttazegk5f.bx.internal.cloudapp.net (unknown [40.117.90.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DB7FC21476; Fri, 19 Oct 2018 03:23:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539919433; bh=HjexDM2dmlW5rnbCXf2ai5vmtZFBrr9V3jSVSqswcGo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h3S0ZGsRPmwg4hC7zigyAGa045obP1ZYH0pyAESgufFq+GF+b4I9kPnqfSfOG0lmo 1VjiKpJz5O8+YWm6u0R/A3itmM0Byyc91V7qkRkVeVHkm+FLIwMA+8ZBDDbcOgt8AZ ExN+ZnIM+6Kpd8VBe9C9NRrKDLtE2eJGxuIdkkF0= From: Sinan Kaya To: linux-pci@vger.kernel.org Cc: Sinan Kaya , Mike Marciniszyn , Dennis Dalessandro , Doug Ledford , Jason Gunthorpe , Derek Chickles , Satanand Burla , Felix Manlunas , Raghu Vatsavayi , "David S. Miller" , Bjorn Helgaas , Boris Ostrovsky , Juergen Gross , Jia-Ju Bai Subject: [RFC PATCH v1 3/3] PCI: Hide pci_reset_function_locked() Date: Fri, 19 Oct 2018 03:23:43 +0000 Message-Id: <20181019032345.5791-3-okaya@kernel.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181019032345.5791-1-okaya@kernel.org> References: <20181019032345.5791-1-okaya@kernel.org> MIME-Version: 1.0 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 It is time to hide pci_reset_function_locked() since pci_reset_function() provides the same functionality. One less API to expose to the users. Signed-off-by: Sinan Kaya --- drivers/infiniband/hw/hfi1/pcie.c | 5 +++-- drivers/net/ethernet/cavium/liquidio/lio_main.c | 6 +++--- drivers/pci/pci.h | 1 + drivers/xen/xen-pciback/pci_stub.c | 13 +++++++------ include/linux/pci.h | 1 - 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c index a43cd031bfe4..298086b7936b 100644 --- a/drivers/infiniband/hw/hfi1/pcie.c +++ b/drivers/infiniband/hw/hfi1/pcie.c @@ -897,8 +897,9 @@ static int trigger_sbr(struct hfi1_devdata *dd) * to be implemented to have cleaner interface but this fixes the * current brokenness */ - return pci_reset_function_locked(dev, PCI_RESET_LINK | - PCI_RESET_NOSAVERESTORE); + return pci_reset_function(dev, PCI_RESET_LINK | + PCI_RESET_NOSAVERESTORE | + PCI_RESET_ALREADY_LOCKED); } /* diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c index 4ae3935ff10d..605061b2ee66 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c @@ -989,9 +989,9 @@ static void octeon_pci_flr(struct octeon_device *oct) pci_write_config_word(oct->pci_dev, PCI_COMMAND, PCI_COMMAND_INTX_DISABLE); - rc = pci_reset_function_locked(oct->pci_dev, PCI_RESET_ANY | - PCI_RESET_NOSAVERESTORE); - + rc = pci_reset_function(oct->pci_dev, PCI_RESET_ANY | + PCI_RESET_NOSAVERESTORE | + PCI_RESET_ALREADYLOCKED); if (rc != 0) dev_err(&oct->pci_dev->dev, "Error %d resetting PCI function %d\n", rc, oct->pf_num); diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index fbfb44fb32b7..e6eefc028ba2 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -36,6 +36,7 @@ int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vmai, int pci_probe_reset_function(struct pci_dev *dev, u32 reset_type); int pci_bridge_secondary_bus_reset(struct pci_dev *dev); int __pci_reset_function_locked(struct pci_dev *dev, u32 reset_type); +int pci_reset_function_locked(struct pci_dev *dev, u32 reset_type); /** * struct pci_platform_pm_ops - Firmware PM callbacks diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c index 7a27d8fb0528..a43476447809 100644 --- a/drivers/xen/xen-pciback/pci_stub.c +++ b/drivers/xen/xen-pciback/pci_stub.c @@ -105,8 +105,8 @@ static void pcistub_device_release(struct kref *kref) /* Call the reset function which does not take lock as this * is called from "unbind" which takes a device_lock mutex. */ - pci_reset_function_locked(dev, PCI_RESET_ANY | - PCI_RESET_NOSAVERESTORE); + pci_reset_function(dev, PCI_RESET_ANY | PCI_RESET_NOSAVERESTORE | + PCI_RESET_ALREADY_LOCKED); if (pci_load_and_free_saved_state(dev, &dev_data->pci_saved_state)) dev_info(&dev->dev, "Could not reload PCI state\n"); else @@ -284,8 +284,8 @@ void pcistub_put_pci_dev(struct pci_dev *dev) * (so it's ready for the next domain) */ device_lock_assert(&dev->dev); - pci_reset_function_locked(dev, PCI_RESET_ANY | - PCI_RESET_NOSAVERESTORE); + pci_reset_function(dev, PCI_RESET_ANY | PCI_RESET_NOSAVERESTORE | + PCI_RESET_ALREADYLOCKED); dev_data = pci_get_drvdata(dev); ret = pci_load_saved_state(dev, dev_data->pci_saved_state); @@ -419,8 +419,9 @@ static int pcistub_init_device(struct pci_dev *dev) dev_err(&dev->dev, "Could not store PCI conf saved state!\n"); else { dev_dbg(&dev->dev, "resetting (FLR, D3, etc) the device\n"); - pci_reset_function_locked(dev, PCI_RESET_ANY | - PCI_RESET_NOSAVERESTORE); + pci_reset_function(dev, PCI_RESET_ANY | + PCI_RESET_NOSAVERESTORE | + PCI_RESET_ALREADYLOCKED); pci_restore_state(dev); } /* Now disable the device (this also ensures some private device diff --git a/include/linux/pci.h b/include/linux/pci.h index ad5996d521eb..f93007f71ed7 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1176,7 +1176,6 @@ void pcie_print_link_status(struct pci_dev *dev); bool pcie_has_flr(struct pci_dev *dev); int pcie_flr(struct pci_dev *dev); int pci_reset_function(struct pci_dev *dev, u32 reset_type); -int pci_reset_function_locked(struct pci_dev *dev, u32 reset_type); int pci_try_reset_function(struct pci_dev *dev, u32 reset_type); int pci_probe_reset_slot(struct pci_slot *slot); int pci_probe_reset_bus(struct pci_bus *bus);