From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Keith Busch <kbusch@meta.com>
Cc: <linux-pci@vger.kernel.org>, <bhelgaas@google.com>,
<lukas@wunner.de>, <mika.westerberg@linux.intel.com>,
Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCH RFC 6/8] pci: add helpers for stop and remove bus
Date: Thu, 15 Aug 2024 15:49:06 +0100 [thread overview]
Message-ID: <20240815154906.00006586@Huawei.com> (raw)
In-Reply-To: <20240722151936.1452299-7-kbusch@meta.com>
On Mon, 22 Jul 2024 08:19:34 -0700
Keith Busch <kbusch@meta.com> wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> There are repeated patterns of tearing down pci buses, so combine to
> helper functions and use these.
There are some subtle changes in ordering in here. I'm not
immediately convinced by all of them.
Perhaps this should be broken down further so we get the direct
code replacements that are easy to review, the movement of calls
to different functions (e.g. addition of pci_clear_bus() in
pci_remove_bus() and dropping that call, or the code that it matches
in two other places).
>
> Signed-off-by: Keith Busch <kbusch@kernel.org>
> ---
> drivers/pci/remove.c | 46 +++++++++++++++++++++++---------------------
> 1 file changed, 24 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
> index 8284ab20949c9..288162a11ab19 100644
> --- a/drivers/pci/remove.c
> +++ b/drivers/pci/remove.c
> @@ -4,6 +4,9 @@
> #include <linux/of_platform.h>
> #include "pci.h"
>
> +static void pci_stop_bus(struct pci_bus *bus);
> +static void pci_remove_bus_device(struct pci_dev *dev);
> +
> static void pci_free_resources(struct pci_dev *dev)
> {
> struct resource *res;
> @@ -45,8 +48,17 @@ static void pci_destroy_dev(struct pci_dev *dev)
> put_device(&dev->dev);
> }
>
> +static void pci_clear_bus(struct pci_bus *bus)
> +{
> + struct pci_dev *dev, *next;
> +
> + list_for_each_entry_safe(dev, next, &bus->devices, bus_list)
> + pci_remove_bus_device(dev);
> +}
> +
> void pci_remove_bus(struct pci_bus *bus)
> {
> + pci_clear_bus(bus);
So this is replacing the list_for_each_entry_safe block that
was previously in pci_remove_root_bus / pci_remove_bus_device but there
are other callers of this function such as in xen-pcifront.c which
are going to see this change.
> pci_proc_detach_bus(bus);
>
> down_write(&pci_bus_sem);
> @@ -66,7 +78,15 @@ EXPORT_SYMBOL(pci_remove_bus);
>
> static void pci_remove_bus_device(struct pci_dev *dev)
> {
> struct pci_bus *bus = dev->subordinate;
> - struct pci_dev *child, *tmp;
>
> if (bus) {
> - list_for_each_entry_safe(child, tmp,
> - &bus->devices, bus_list)
> - pci_remove_bus_device(child);
> -
> pci_remove_bus(bus);
> dev->subordinate = NULL;
> }
> -
Grumpy reviewer hat. Unrelated change.
> pci_destroy_dev(dev);
> }
>
> @@ -129,16 +138,13 @@ EXPORT_SYMBOL_GPL(pci_stop_and_remove_bus_device_locked);
>
> void pci_stop_root_bus(struct pci_bus *bus)
> {
> - struct pci_dev *child, *tmp;
> struct pci_host_bridge *host_bridge;
>
> if (!pci_is_root_bus(bus))
> return;
>
> host_bridge = to_pci_host_bridge(bus->bridge);
> - list_for_each_entry_safe_reverse(child, tmp,
> - &bus->devices, bus_list)
> - pci_stop_bus_device(child);
> + pci_stop_bus(bus);
>
> /* stop the host bridge */
> device_release_driver(&host_bridge->dev);
> @@ -147,16 +153,12 @@ EXPORT_SYMBOL_GPL(pci_stop_root_bus);
>
> void pci_remove_root_bus(struct pci_bus *bus)
> {
> - struct pci_dev *child, *tmp;
> struct pci_host_bridge *host_bridge;
>
> if (!pci_is_root_bus(bus))
> return;
>
> host_bridge = to_pci_host_bridge(bus->bridge);
> - list_for_each_entry_safe(child, tmp,
> - &bus->devices, bus_list)
> - pci_remove_bus_device(child);
>
> #ifdef CONFIG_PCI_DOMAINS_GENERIC
> /* Release domain_nr if it was dynamically allocated */
next prev parent reply other threads:[~2024-08-15 14:49 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-22 15:19 [PATCH RFC 0/8] pci: rescan/remove locking rework Keith Busch
2024-07-22 15:19 ` [PATCH RFC 1/8] pci: make pci_stop_dev concurrent safe Keith Busch
2024-08-15 14:17 ` Jonathan Cameron
2024-08-20 15:02 ` Keith Busch
2024-08-21 11:01 ` Jonathan Cameron
2024-07-22 15:19 ` [PATCH RFC 2/8] pci: make pci_destroy_dev " Keith Busch
2024-08-15 14:18 ` Jonathan Cameron
2024-07-22 15:19 ` [PATCH RFC 3/8] pci: move the walk bus lock to where its needed Keith Busch
2024-08-15 14:20 ` Jonathan Cameron
2024-07-22 15:19 ` [PATCH RFC 4/8] pci: walk bus recursively Keith Busch
2024-08-15 14:33 ` Jonathan Cameron
2024-07-22 15:19 ` [PATCH RFC 5/8] pci: unexport pci_walk_bus_locked Keith Busch
2024-08-15 14:36 ` Jonathan Cameron
2024-07-22 15:19 ` [PATCH RFC 6/8] pci: add helpers for stop and remove bus Keith Busch
2024-08-15 14:49 ` Jonathan Cameron [this message]
2024-07-22 15:19 ` [PATCH RFC 7/8] pci: reference count subordinate Keith Busch
2024-08-15 15:10 ` Jonathan Cameron
2024-07-22 15:19 ` [PATCH RFC 8/8] pci: use finer grain locking for bus protection Keith Busch
2024-08-15 15:21 ` Jonathan Cameron
2024-08-15 17:05 ` Keith Busch
2024-08-07 15:40 ` [PATCH RFC 0/8] pci: rescan/remove locking rework Keith Busch
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=20240815154906.00006586@Huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=bhelgaas@google.com \
--cc=kbusch@kernel.org \
--cc=kbusch@meta.com \
--cc=linux-pci@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=mika.westerberg@linux.intel.com \
/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.