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)