linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Helgaas <bhelgaas@google.com>
To: Yinghai Lu <yinghai@kernel.org>
Cc: Len Brown <lenb@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-acpi@vger.kernel.org
Subject: Re: [PATCH 0/4] ACPI: kill acpi_pci_root_start
Date: Thu, 4 Oct 2012 11:47:46 -0600	[thread overview]
Message-ID: <20121004174746.GA24119@google.com> (raw)
In-Reply-To: <1349305214-3241-1-git-send-email-yinghai@kernel.org>

On Wed, Oct 03, 2012 at 04:00:10PM -0700, Yinghai Lu wrote:
> Now acpi_pci_root_driver has two ops: .add and .start, aka acpi_pci_root_add
> and acpi_pci_root_start.
> 
> That is for hotplug handling: .add need to return early to make sure all
> acpi device could be created and added early. So .start could device_add
> pci device that are found in acpi_pci_root_add/pci_acpi_scan_root().
> 
> That is holding pci devics to be out of devices for while.
> 
> We could use bus notifier to handle hotplug case.
> 	CONFIG_HOTPLUG is enabled always now.
> Need to add drivers_autoprobe bit in acpi_device to hold attaching drivers
> for acpi_devices, so could make sure all acpi_devices get created at first.
> Then acpi_bus_attach() that is called from acpi_bus_add will attach driver
> for all acpi_devices that are just created.
> 
> That make the logic more simple: hotplug path handling just like booting path
> that drivers are attached after all acpi device get created.
> 
> At last we could remove all acpi_bus_start workaround.

I think we should get rid of ACPI .start() methods, but I'm opposed to this
approach of fiddling with driver binding order.

At hot-plug time, the pci_root.c driver is already loaded, then we enumerate
the new host bridge.  Since pci_root.c is already loaded, we bind the driver
before descending the ACPI tree below the host bridge.  We need to make that
same ordering work at boot-time.

At boot-time, we currently enumerate ALL ACPI devices before registering
the pci_root.c driver:

    acpi_init				# subsys_initcall
	acpi_scan_init
	    acpi_bus_scan		# enumerate ACPI devices

    acpi_pci_root_init			# subsys_initcall for pci_root.c
	acpi_bus_register_driver
	    ...
		acpi_pci_root_add	# pci_root.c add method

This is a fundamental difference: at boot-time, all the ACPI devices below the
host bridge already exist before the pci_root.c driver claims the bridge,
while at hot-add time, pci_root.c claims the bridge *before* those ACPI
devices exist.

I think this is wrong.  The hot-plug case (where the driver is already
loaded and binds to the device as soon as it's discovered, before the
ACPI hierarchy below it is enumerated) seems like the obviously correct
order.  I think we should change the boot-time order to match that, i.e.,
we should register pci_root.c *before* enumerating ACPI devices.

I realize that this will require changes in the way we bind PCI and ACPI
devices.  I pointed that out in a previous response, appended below for
convenience:

On Tue, Oct 2, 2012 at 4:38 PM, Bjorn Helgaas <bhelgaas@google.com> wrote:

>> We enumerate ACPI devices by doing a depth-first traversal of the
>> namespace.  We should be able to bind a driver to a device as soon as
>> we discover it.  For PNP0A03/08 host bridges, that will be the
>> pci_root.c driver.  That driver's .add() method enumerates all the PCI
>> devices behind the host bridge, which is another depth-first
>> traversal, this time of the PCI hierarchy.  Similarly, we ought to be
>> able to bind drivers to the PCI devices as we discover them.
>
>> But the PCI/ACPI binding is an issue here, because the ACPI
>> enumeration hasn't descended below the host bridge yet, so we have the
>> pci_dev structs but the acpi_device structs don't exist yet.  I think
>> this is part of the reason for the .add()/.start() split.  But I don't
>> think the split is the correct solution.  I think we need to think
>> about the binding in a different way.  Maybe we don't bind at all and
>> instead search the namespace every time we need the association.  Or
>> maybe we do the binding but base it on the acpi_handle (which exists
>> before the ACPI subtree has been enumerated) rather than the
>> acpi_device (which doesn't exist until we enumerate the subtree).
>> It's not even clear to me that we should build acpi_device structs for
>> things that already have pci_dev structs.

  parent reply	other threads:[~2012-10-04 17:47 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-02  6:32 [PATCH 00/10] PCI, ACPI: Use bus type notifier for root bus hotplug Yinghai Lu
2012-10-02  6:32 ` [PATCH 01/10] device: add drivers_autoprobe in struct device Yinghai Lu
2012-10-02 13:33   ` Greg Kroah-Hartman
2012-10-02 17:39     ` Yinghai Lu
2012-10-02 17:47       ` Greg Kroah-Hartman
2012-10-02 18:00         ` Bjorn Helgaas
2012-10-02 20:20         ` Yinghai Lu
2012-10-02 20:45           ` Greg Kroah-Hartman
2012-10-02 21:47             ` Yinghai Lu
2012-10-02 22:38               ` Bjorn Helgaas
2012-10-02 23:20                 ` Yinghai Lu
2012-10-03  0:00                 ` Yinghai Lu
2012-10-03  2:07                   ` Yinghai Lu
2012-10-03  2:08                     ` Yinghai Lu
2012-10-03 19:48                   ` Bjorn Helgaas
2012-10-03 20:50                     ` Yinghai Lu
2012-10-03 23:00                       ` [PATCH 0/4] ACPI: kill acpi_pci_root_start Yinghai Lu
2012-10-03 23:00                         ` [PATCH 1/4] ACPI: add drivers_autoprobe in struct acpi_device Yinghai Lu
2012-10-04 13:03                           ` Konrad Rzeszutek Wilk
2012-10-04 15:15                             ` Yinghai Lu
2012-10-09 16:38                               ` Konrad Rzeszutek Wilk
2012-10-03 23:00                         ` [PATCH 2/4] ACPI: use device drivers_autoprobe to delay loading acpi drivers Yinghai Lu
2012-10-03 23:00                         ` [PATCH 3/4] PCI, ACPI: Remove not used acpi_pci_root_start() Yinghai Lu
2012-10-03 23:00                         ` [PATCH 4/4] ACPI: remove acpi_op_start workaround Yinghai Lu
2012-10-04 12:57                           ` Konrad Rzeszutek Wilk
2012-10-04 17:47                         ` Bjorn Helgaas [this message]
2012-10-04 18:36                           ` [PATCH 0/4] ACPI: kill acpi_pci_root_start Yinghai Lu
2012-10-04 19:44                             ` Bjorn Helgaas
2012-10-04 19:54                               ` Rafael J. Wysocki
2012-10-04 20:14                               ` Yinghai Lu
2012-10-04 20:47                                 ` Bjorn Helgaas
2012-10-04 19:53                           ` Rafael J. Wysocki
2012-10-04 21:23                         ` Rafael J. Wysocki
2012-10-04 21:31                           ` Yinghai Lu
2012-10-04 21:53                             ` Rafael J. Wysocki
2012-10-04 22:01                               ` Yinghai Lu
2012-10-04 22:36                                 ` Rafael J. Wysocki
2012-10-04 22:46                                   ` Yinghai Lu
2012-10-05 23:01                                     ` Rafael J. Wysocki
2012-10-05 23:10                                       ` Yinghai Lu
2012-10-08 20:12                                         ` Rafael J. Wysocki
2012-10-02  6:33 ` [PATCH 02/10] ACPI: use device drivers_autoprobe to delay loading acpi drivers Yinghai Lu
2012-10-02  6:33 ` [PATCH 03/10] PCI: prepare to use device drivers_autoprobe to delay attach drivers Yinghai Lu
2012-10-02  6:33 ` [PATCH 04/10] PCI: Use device_add for device and bus early Yinghai Lu
2012-10-02  6:33 ` [PATCH 05/10] PCI, ACPI: Separate out acpi_pci_root_osc_contorl_set Yinghai Lu
2012-10-02  6:33 ` [PATCH 06/10] PCI, ACPI: Move hot add root bus conf code to acpi_pci_root_add Yinghai Lu
2012-10-02  6:33 ` [PATCH 07/10] PCI, ACPI: Remove not used acpi_pci_root_start() Yinghai Lu
2012-10-02  6:33 ` [PATCH 08/10] PCI: Add dev_is_pci_host_bridge() helper Yinghai Lu
2012-10-02  6:33 ` [PATCH 09/10] PCI, ACPI: using acpi/pci bind path for pci_host_bridge Yinghai Lu
2012-10-02  6:33 ` [PATCH 10/10] PCI, ACPI: use bus_type notifier for acpi_pci_bind_notify Yinghai Lu
2012-10-06  2:57 ` [PATCH 00/10] PCI, ACPI: Use bus type notifier for root bus hotplug Jiang Liu
2012-10-06  7:25   ` Yinghai Lu
2012-10-07 15:17     ` Jiang Liu
2012-10-07 22:33       ` Yinghai Lu
2012-10-08 15:23         ` Jiang Liu

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=20121004174746.GA24119@google.com \
    --to=bhelgaas@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=torvalds@linux-foundation.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).