From patchwork Wed Jun 20 04:12:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sinan Kaya X-Patchwork-Id: 10475917 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 73A2F604D3 for ; Wed, 20 Jun 2018 04:14:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 54CF7288F3 for ; Wed, 20 Jun 2018 04:14:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 484AE28909; Wed, 20 Jun 2018 04:14:56 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 D9D59288F3 for ; Wed, 20 Jun 2018 04:14:55 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=EDlxDJRx6ZrEu3qrs9eEM0x9la6HcZyH2OyjZ1hxtoM=; b=EZxd72CQ8w2lcS jRxnEZ4DI0gGhACdslNK8BmuJb+ofhR7eUS0Z/gACsKlhYzPdHIMeR2inqTCDfLNN3Didkg8H8VRS OTFvNFNOotNkxjbdanZ8vl4Bc8GRPuwdgb9cVpWuZ2dKDMwEG0aU9ORAMhRgZg5jg8ip0lJ1vDuZ6 aF2iEKc59q33b9fvFmNq9JtZoVK+6f4jo23EqgOSugKM794zzNNNLpuQmHJyLHfQvn/e/oAipPqJY 6etWYKGIKTlRboRxIDK20+79UVD7Ahs64IH9gnXivUGuJeJjdP3J4JQHl7w70nbD127EHEA/XlOeN CFT/zW9taw5ylys9VTwg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVUW7-0001mx-QY; Wed, 20 Jun 2018 04:14:47 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVUV6-0001BL-CG for linux-arm-kernel@lists.infradead.org; Wed, 20 Jun 2018 04:13:49 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id F340860B68; Wed, 20 Jun 2018 04:13:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1529468019; bh=YyKHY0qznaqhjvQbreep8Cj36qVntjCgCWgjcJPlmHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IgDHnqCNG+bPcBLW3cfJ5oufFhIV9DpqOI9MxzM2dTxR1B/glP9HE7E+//5pnoyuL 2Sd48B3Jbo4sHL7WHGBGHToBQf6PG2RQ01fS23fOmb8EGMX2B1K7Vd+N/6lK3VuH+f QSt70mQ5nIxeyQdhy6pkG8Dd8nhFEGYIutsezoNA= 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 4E2B460B19; Wed, 20 Jun 2018 04:13:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1529468018; bh=YyKHY0qznaqhjvQbreep8Cj36qVntjCgCWgjcJPlmHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EcBtqBEvaax16z/ApxxYAxS3xyYkfNsQDvvzjgixvKcYirKvW6fudYVEA/z1v+jcF 7gU/4mu2e54Zi4C4zbfd/DluFSIxkzY+an4yVLEL1n9FN9chiBTBjkcgkAeG96fI3s mu9dCndxW5omRIUa5BBY7WVYE872tvxsGPSolk2Q= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4E2B460B19 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 V2 5/5] PCI: Unify slot and bus reset API Date: Wed, 20 Jun 2018 00:12:58 -0400 Message-Id: <1529467995-28780-5-git-send-email-okaya@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529467995-28780-1-git-send-email-okaya@codeaurora.org> References: <1529467995-28780-1-git-send-email-okaya@codeaurora.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180619_211344_511258_DEAC6A54 X-CRM114-Status: GOOD ( 11.69 ) 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 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 Drivers are expected to call pci_reset_slot() or pci_reset_bus() by querying if a system supports hotplug or not. A survey showed that most drivers don't do this and we are leaking hotplug capability to the user. Hide pci_slot_reset() from drivers and embed into pci_bus_reset(). Change pci_reset_bus() parameter from struct pci_bus to struct pci_dev. Signed-off-by: Sinan Kaya --- drivers/pci/pci.c | 27 +++++++++++++++++++++++---- include/linux/pci.h | 3 +-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 79a1566..a44b948 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4798,7 +4798,7 @@ EXPORT_SYMBOL_GPL(pci_probe_reset_slot); * * Return 0 on success, non-zero on error. */ -int pci_reset_slot(struct pci_slot *slot) +static int __pci_reset_slot(struct pci_slot *slot) { int rc; @@ -4814,7 +4814,6 @@ int pci_reset_slot(struct pci_slot *slot) return rc; } -EXPORT_SYMBOL_GPL(pci_reset_slot); /** * __pci_try_reset_slot - Try to reset a PCI slot @@ -4878,7 +4877,7 @@ int pci_probe_reset_bus(struct pci_bus *bus) EXPORT_SYMBOL_GPL(pci_probe_reset_bus); /** - * pci_reset_bus - reset a PCI bus + * __pci_reset_bus - reset a PCI bus * @bus: top level PCI bus to reset * * Do a bus reset on the given bus and any subordinate buses, saving @@ -4886,7 +4885,7 @@ EXPORT_SYMBOL_GPL(pci_probe_reset_bus); * * Return 0 on success, non-zero on error. */ -int pci_reset_bus(struct pci_bus *bus) +static int __pci_reset_bus(struct pci_bus *bus) { int rc; @@ -4902,6 +4901,26 @@ int pci_reset_bus(struct pci_bus *bus) return rc; } + +/** + * pci_reset_bus - reset a PCI bus + * @pdev: top level PCI device to reset via slot/bus + * + * Do a slot/bus reset on the given bus and any subordinate buses, saving + * and restoring state of all devices. + * + * Return 0 on success, non-zero on error. + */ +int pci_reset_bus(struct pci_dev *pdev) +{ + bool slot = false; + + if (!pci_probe_reset_slot(pdev->slot)) + slot = true; + + return slot ? __pci_reset_slot(pdev->slot) : + __pci_reset_bus(pdev->bus); +} EXPORT_SYMBOL_GPL(pci_reset_bus); /** diff --git a/include/linux/pci.h b/include/linux/pci.h index f5c85b6..e68ca2e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1095,9 +1095,8 @@ int pci_reset_function(struct pci_dev *dev); int pci_reset_function_locked(struct pci_dev *dev); int pci_try_reset_function(struct pci_dev *dev); int pci_probe_reset_slot(struct pci_slot *slot); -int pci_reset_slot(struct pci_slot *slot); int pci_probe_reset_bus(struct pci_bus *bus); -int pci_reset_bus(struct pci_bus *bus); +int pci_reset_bus(struct pci_dev *dev); int pci_try_reset_bus(struct pci_dev *dev); void pci_reset_secondary_bus(struct pci_dev *dev); void pcibios_reset_secondary_bus(struct pci_dev *dev);