All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Bjorn Helgaas <helgaas@kernel.org>,
	linux-pci@vger.kernel.org, Sinan Kaya <okaya@kernel.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Keith Busch <keith.busch@intel.com>,
	Oza Pawandeep <poza@codeaurora.org>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: [PATCH 1/9] PCI: Simplify disconnected marking
Date: Sun, 19 Aug 2018 16:29:00 +0200	[thread overview]
Message-ID: <10f51ea0e0a29b33a5f87e7eb98fe4cdf8cb681f.1534686485.git.lukas@wunner.de> (raw)
In-Reply-To: <cover.1534686484.git.lukas@wunner.de>

Commit 89ee9f768003 ("PCI: Add device disconnected state") iterates over
the devices on a parent bus, marks each as disconnected, then marks
each device's children as disconnected using pci_walk_bus().

The same can be achieved more succinctly by calling pci_walk_bus() on
the parent bus.  Moreover, this does not need to wait until acquiring
pci_lock_rescan_remove(), so move it out of that critical section.

The critical section in err.c contains a pci_dev_get() / pci_dev_put()
pair which was apparently copy-pasted from pciehp_pci.c.  In the latter
it serves the purpose of holding the struct pci_dev in place until the
Command register is updated.  err.c doesn't do anything like that, hence
the pair is unnecessary.  Remove it.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Oza Pawandeep <poza@codeaurora.org>
Cc: Sinan Kaya <okaya@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/pci/hotplug/pciehp_pci.c | 9 +++------
 drivers/pci/pcie/err.c           | 8 ++------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
index 18f83e554c73..0322bd4f0a7a 100644
--- a/drivers/pci/hotplug/pciehp_pci.c
+++ b/drivers/pci/hotplug/pciehp_pci.c
@@ -91,6 +91,9 @@ void pciehp_unconfigure_device(struct slot *p_slot, bool presence)
 	ctrl_dbg(ctrl, "%s: domain:bus:dev = %04x:%02x:00\n",
 		 __func__, pci_domain_nr(parent), parent->number);
 
+	if (!presence)
+		pci_walk_bus(parent, pci_dev_set_disconnected, NULL);
+
 	pci_lock_rescan_remove();
 
 	/*
@@ -102,12 +105,6 @@ void pciehp_unconfigure_device(struct slot *p_slot, bool presence)
 	list_for_each_entry_safe_reverse(dev, temp, &parent->devices,
 					 bus_list) {
 		pci_dev_get(dev);
-		if (!presence) {
-			pci_dev_set_disconnected(dev, NULL);
-			if (pci_has_subordinate(dev))
-				pci_walk_bus(dev->subordinate,
-					     pci_dev_set_disconnected, NULL);
-		}
 		pci_stop_and_remove_bus_device(dev);
 		/*
 		 * Ensure that no new Requests will be generated from
diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c
index 708fd3a0d646..cac406b6e936 100644
--- a/drivers/pci/pcie/err.c
+++ b/drivers/pci/pcie/err.c
@@ -292,17 +292,13 @@ void pcie_do_fatal_recovery(struct pci_dev *dev, u32 service)
 		udev = dev->bus->self;
 
 	parent = udev->subordinate;
+	pci_walk_bus(parent, pci_dev_set_disconnected, NULL);
+
 	pci_lock_rescan_remove();
 	pci_dev_get(dev);
 	list_for_each_entry_safe_reverse(pdev, temp, &parent->devices,
 					 bus_list) {
-		pci_dev_get(pdev);
-		pci_dev_set_disconnected(pdev, NULL);
-		if (pci_has_subordinate(pdev))
-			pci_walk_bus(pdev->subordinate,
-				     pci_dev_set_disconnected, NULL);
 		pci_stop_and_remove_bus_device(pdev);
-		pci_dev_put(pdev);
 	}
 
 	result = reset_link(udev, service);
-- 
2.18.0

  reply	other threads:[~2018-08-19 14:29 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-19 14:29 [PATCH 0/9] PCI hotplug diet Lukas Wunner
2018-08-19 14:29 ` Lukas Wunner
2018-08-19 14:29 ` Lukas Wunner [this message]
2018-08-19 21:56   ` [PATCH 1/9] PCI: Simplify disconnected marking Sinan Kaya
2018-08-19 14:29 ` [PATCH 7/9] PCI: hotplug: Drop hotplug_slot_info Lukas Wunner
2018-08-19 14:29   ` Lukas Wunner
2018-08-20  8:14   ` Rafael J. Wysocki
2018-08-20  8:14     ` Rafael J. Wysocki
2018-08-21  0:41   ` Tyrel Datwyler
2018-08-21  0:41     ` Tyrel Datwyler
2018-09-03 17:52   ` Sebastian Ott
2018-09-03 17:52     ` Sebastian Ott
2018-08-19 14:29 ` [PATCH 3/9] PCI: pciehp: Drop hotplug_slot_ops wrappers Lukas Wunner
2018-08-19 22:01   ` Sinan Kaya
2018-08-19 14:29 ` [PATCH 8/9] PCI: hotplug: Embed hotplug_slot Lukas Wunner
2018-08-19 14:29   ` Lukas Wunner
2018-08-20  8:17   ` Rafael J. Wysocki
2018-08-20  8:17     ` Rafael J. Wysocki
2018-08-21  0:43   ` Tyrel Datwyler
2018-08-21  0:43     ` Tyrel Datwyler
2018-09-03 17:54   ` Sebastian Ott
2018-09-03 17:54     ` Sebastian Ott
2018-08-19 14:29 ` [PATCH 6/9] PCI: hotplug: Constify hotplug_slot_ops Lukas Wunner
2018-08-19 14:29   ` Lukas Wunner
2018-08-20  8:10   ` Rafael J. Wysocki
2018-08-20  8:10     ` Rafael J. Wysocki
2018-08-21  0:38   ` Tyrel Datwyler
2018-08-21  0:38     ` Tyrel Datwyler
2018-08-19 14:29 ` [PATCH 4/9] PCI: pciehp: Unify controller and slot structs Lukas Wunner
2018-08-19 21:59   ` Sinan Kaya
2018-08-20  9:09     ` Lukas Wunner
2018-08-20 17:34       ` Sinan Kaya
2018-09-05 22:30         ` Bjorn Helgaas
2018-09-06  7:38           ` Lukas Wunner
2018-09-06 18:54             ` Bjorn Helgaas
2018-09-17 22:37             ` Bjorn Helgaas
2018-09-18 19:46               ` Lukas Wunner
2018-08-19 14:29 ` [PATCH 9/9] PCI: hotplug: Document TODOs Lukas Wunner
2018-08-19 14:29 ` [PATCH 2/9] PCI: pciehp: Drop unnecessary includes Lukas Wunner
2018-08-19 14:29 ` [PATCH 5/9] PCI: pciehp: Reshuffle controller struct for clarity Lukas Wunner
2018-08-30  8:50 ` [PATCH 0/9] PCI hotplug diet Andy Shevchenko
2018-08-30  8:50   ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10f51ea0e0a29b33a5f87e7eb98fe4cdf8cb681f.1534686485.git.lukas@wunner.de \
    --to=lukas@wunner.de \
    --cc=benh@kernel.crashing.org \
    --cc=helgaas@kernel.org \
    --cc=keith.busch@intel.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=okaya@kernel.org \
    --cc=poza@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.