public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiang Liu <jiang.liu@huawei.com>
To: Tang Chen <tangchen@cn.fujitsu.com>
Cc: <yinghai@kernel.org>, <lenb@kernel.org>, <bhelgaas@google.com>,
	<izumi.taku@jp.fujitsu.com>, <linux-acpi@vger.kernel.org>,
	<linux-pci@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/3] Do not use acpi_device to find pci root bridge in _init code.
Date: Fri, 12 Oct 2012 18:36:50 +0800	[thread overview]
Message-ID: <5077F2C2.1010300@huawei.com> (raw)
In-Reply-To: <1350037890-5899-3-git-send-email-tangchen@cn.fujitsu.com>

On 2012-10-12 18:31, Tang Chen wrote:
> When the kernel is being initialized, and some hardwares are not added
> to system, there won't be acpi_device structs for these devices. But
> acpi_is_root_bridge() depends on acpi_device struct. As a result, all
> the not-added root bridge will not be judged as a root bridge in
> find_root_bridges(). And further more, no handle_hotplug_event_root()
> notifier will be installed for them.
> 
> This patch introduces a new api to find all root bridges in system by
> getting HID directly from ACPI namespace, not depending on acpi_device
> struct.
> 
> Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
> ---
>  drivers/acpi/pci_root.c |   27 ++++++++++++++++++++++-----
>  1 files changed, 22 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
> index 7d0fb03..3819bee 100644
> --- a/drivers/acpi/pci_root.c
> +++ b/drivers/acpi/pci_root.c
> @@ -128,9 +128,6 @@ EXPORT_SYMBOL_GPL(acpi_get_pci_rootbridge_handle);
>  /**
>   * acpi_is_root_bridge - determine whether an ACPI CA node is a PCI root bridge
>   * @handle - the ACPI CA node in question.
> - *
> - * Note: we could make this API take a struct acpi_device * instead, but
> - * for now, it's more convenient to operate on an acpi_handle.
>   */
>  int acpi_is_root_bridge(acpi_handle handle)
>  {
> @@ -138,8 +135,28 @@ int acpi_is_root_bridge(acpi_handle handle)
>  	struct acpi_device *device;
>  
>  	ret = acpi_bus_get_device(handle, &device);
> -	if (ret)
> -		return 0;
> +	if (ret) {
> +		/**
> +		 * If a device is not added to the system yet, there won't be
> +		 * an acpi_device struct for it. But it doesn't mean it is not
> +		 * a PCI root bridge. In this case we need to get HID and CID
> +		 * from ACPI namespace directly.
> +		 */
> +		struct acpi_device_info *info;
> +		acpi_status status;
> +		status = acpi_get_object_info(handle, &info);
> +		if (ACPI_FAILURE(status)) {
> +			printk(KERN_ERR PREFIX "%s: Error reading"
> +					       "device info\n", __func__);
> +			return 0;
> +		}
> +
> +		ret = acpi_match_object_info_ids(info, root_device_ids);
> +		if (ret)
> +			return 0;
> +		else
> +			return 1;
> +	}
I have sent a similar patch to Yinghai before. For simplicity, we could
use acpi_match_object_info_ids() instead of acpi_match_device_ids()
directly.
Thanks!
Gerry

>  
>  	ret = acpi_match_device_ids(device, root_device_ids);
>  	if (ret)



  reply	other threads:[~2012-10-12 10:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-12 10:31 [PATCH 0/3] Find pci root bridges by comparing HID from acpi_device_info, not acpi_device Tang Chen
2012-10-12 10:31 ` [PATCH 1/3] Introduce a new acpi to determine HID match Tang Chen
2012-10-12 10:31 ` [PATCH 2/3] Do not use acpi_device to find pci root bridge in _init code Tang Chen
2012-10-12 10:36   ` Jiang Liu [this message]
2012-10-12 10:42     ` Tang Chen
2012-10-12 10:54       ` Jiang Liu
2012-10-12 10:58         ` Tang Chen
2012-10-12 18:34         ` Yinghai Lu
2012-10-12 22:00           ` Yinghai Lu
2012-10-12 10:31 ` [PATCH 3/3] Check exit status of acpi_install_notify_handler() in find_root_bridges() Tang Chen

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=5077F2C2.1010300@huawei.com \
    --to=jiang.liu@huawei.com \
    --cc=bhelgaas@google.com \
    --cc=izumi.taku@jp.fujitsu.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=tangchen@cn.fujitsu.com \
    --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