From: Bjorn Helgaas <bhelgaas@google.com>
To: Yinghai Lu <yinghai@kernel.org>
Cc: Len Brown <lenb@kernel.org>,
Taku Izumi <izumi.taku@jp.fujitsu.com>,
Jiang Liu <jiang.liu@huawei.com>,
linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org
Subject: Re: [PATCH 5/8] PCI: Add pci_stop_and_remove_root_bus()
Date: Fri, 28 Sep 2012 17:46:17 -0600 [thread overview]
Message-ID: <CAErSpo5_gBQwPYSm3oMeQmqTxqRPB_r0-HVv88LD2mR72QafDQ@mail.gmail.com> (raw)
In-Reply-To: <1348733519-24684-6-git-send-email-yinghai@kernel.org>
On Thu, Sep 27, 2012 at 2:11 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> It supports both pci root bus and pci bus under pci bridge.
>
> -v2: clear pci_bridge's subordinate.
> -v3: only handle root bus. and also put Jiang's get/put pair in
> -v4: fold pci_stop/remove_bus_devices in... reducing confusing.
> -v5: split device_register/unregister to avoid extra get...
> also remove extra blank line.
>
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> ---
> drivers/pci/remove.c | 36 ++++++++++++++++++++++++++++++++++++
> include/linux/pci.h | 2 ++
> 2 files changed, 38 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
> index 513972f..7c0fd92 100644
> --- a/drivers/pci/remove.c
> +++ b/drivers/pci/remove.c
> @@ -111,3 +111,39 @@ void pci_stop_and_remove_bus_device(struct pci_dev *dev)
> pci_remove_bus_device(dev);
> }
> EXPORT_SYMBOL(pci_stop_and_remove_bus_device);
> +
> +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);
What if we made these functions just take a "struct pci_host_bridge *"
directly instead of a "struct pci_bus *"? Then the caller
(acpi_pci_root_remove()) could just look up the pci_host_bridge
pointer itself, or even keep that pointer in struct acpi_pci_root
instead of keeping the pci_bus pointer.
> + list_for_each_entry_safe_reverse(child, tmp,
> + &bus->devices, bus_list)
> + pci_stop_bus_device(child);
> +
> + /* stop the host bridge */
> + device_del(&host_bridge->dev);
> +}
> +
> +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);
> + pci_remove_bus(bus);
> + host_bridge->bus = NULL;
> +
> + /* remove the host bridge */
> + put_device(&host_bridge->dev);
> +}
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 505c05a..a5cd03b 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -734,6 +734,8 @@ extern struct pci_dev *pci_dev_get(struct pci_dev *dev);
> extern void pci_dev_put(struct pci_dev *dev);
> extern void pci_remove_bus(struct pci_bus *b);
> extern void pci_stop_and_remove_bus_device(struct pci_dev *dev);
> +void pci_stop_root_bus(struct pci_bus *bus);
> +void pci_remove_root_bus(struct pci_bus *bus);
> void pci_setup_cardbus(struct pci_bus *bus);
> extern void pci_sort_breadthfirst(void);
> #define dev_is_pci(d) ((d)->bus == &pci_bus_type)
> --
> 1.7.7
>
next prev parent reply other threads:[~2012-09-28 23:46 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-27 8:11 [PATCH 0/8] PCI, ACPI, x86: pci root bus hotplug support pci_root.c related core changes Yinghai Lu
2012-09-27 8:11 ` [PATCH 1/8] PCI: Separate out pci_assign_unassigned_bus_resources() Yinghai Lu
2012-09-27 8:11 ` [PATCH 2/8] PCI: Move pci_rescan_bus() back to probe.c Yinghai Lu
2012-09-27 8:11 ` [PATCH 3/8] PCI: Move out pci_enable_bridges out of assign_unsigned_bus_res Yinghai Lu
2012-09-28 23:46 ` Bjorn Helgaas
2012-09-29 1:48 ` Yinghai Lu
2012-09-29 1:52 ` Yinghai Lu
2012-09-29 3:27 ` Bjorn Helgaas
2012-09-29 4:04 ` Yinghai Lu
2012-10-01 18:01 ` Bjorn Helgaas
2012-09-29 4:13 ` Yinghai Lu
2012-09-27 8:11 ` [PATCH 4/8] PCI, ACPI: assign unassigned resource for hot add root bus Yinghai Lu
2012-09-28 23:46 ` Bjorn Helgaas
2012-09-29 1:56 ` Yinghai Lu
2012-09-29 3:31 ` Bjorn Helgaas
2012-09-29 3:37 ` Jiang Liu
2012-09-29 4:19 ` Yinghai Lu
2012-09-29 4:08 ` Yinghai Lu
2012-09-27 8:11 ` [PATCH 5/8] PCI: Add pci_stop_and_remove_root_bus() Yinghai Lu
2012-09-28 23:46 ` Bjorn Helgaas [this message]
2012-09-29 2:05 ` Yinghai Lu
2012-09-27 8:11 ` [PATCH 6/8] PCI, ACPI: Make acpi_pci_root_remove stop/remove pci root bus Yinghai Lu
2012-09-27 8:11 ` [PATCH 7/8] PCI, ACPI: delete root bus prt during hot remove path Yinghai Lu
2012-09-27 8:11 ` [PATCH 8/8] PCI, ACPI: remove acpi_root_driver in reserse order Yinghai Lu
2012-09-28 23:46 ` Bjorn Helgaas
2012-09-29 2:09 ` Yinghai Lu
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=CAErSpo5_gBQwPYSm3oMeQmqTxqRPB_r0-HVv88LD2mR72QafDQ@mail.gmail.com \
--to=bhelgaas@google.com \
--cc=izumi.taku@jp.fujitsu.com \
--cc=jiang.liu@huawei.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=yinghai@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).