diff mbox

[2/3,v2] Do not use acpi_device to find pci root bridge in _init code.

Message ID 1350045261-7344-3-git-send-email-tangchen@cn.fujitsu.com (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

tangchen Oct. 12, 2012, 12:34 p.m. UTC
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>
Signed-off-by: Liu Jiang <jiang.liu@huawei.com>
---
 drivers/acpi/pci_root.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

Comments

Yinghai Lu Oct. 12, 2012, 6:32 p.m. UTC | #1
On Fri, Oct 12, 2012 at 5:34 AM, Tang Chen <tangchen@cn.fujitsu.com> 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>
> Signed-off-by: Liu Jiang <jiang.liu@huawei.com>
> ---
>  drivers/acpi/pci_root.c |   19 +++++++++++--------
>  1 files changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
> index 6151d83..582eb11 100644
> --- a/drivers/acpi/pci_root.c
> +++ b/drivers/acpi/pci_root.c
> @@ -129,20 +129,23 @@ 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.
> + * Note: If a device is not added to the system yet, there won't be an
> + * acpi_device struct for it. So do not get HID and CID from acpi_device,
> + * get them from ACPI namespace directly.
>   */
>  int acpi_is_root_bridge(acpi_handle handle)
>  {
> -       int ret;
> -       struct acpi_device *device;
> +       struct acpi_device_info *info;
> +       acpi_status status;
>
> -       ret = acpi_bus_get_device(handle, &device);
> -       if (ret)
> +       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_device_ids(device, root_device_ids);
> -       if (ret)
> +       if (acpi_match_object_info_ids(info, root_device_ids))
>                 return 0;
>         else
>                 return 1;

there are some other users for acpi_is_root_bridge.

drivers/acpi/pci_root.c:        while (!acpi_is_root_bridge(phandle)) {
drivers/pci/hotplug/acpi_pcihp.c:               if (acpi_is_root_bridge(handle))
drivers/pci/hotplug/acpi_pcihp.c:               if (acpi_is_root_bridge(handle))

and they are ok to have acpi_device ready.

so we could have another separated static version for those not added ones?

Thanks

Yinghai
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Taku Izumi Oct. 15, 2012, 5:41 a.m. UTC | #2
On Fri, 12 Oct 2012 20:34:20 +0800
Tang Chen <tangchen@cn.fujitsu.com> 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.

  How about squashing patch #2 into patch #1 ?
  The caller and callee should be the same place in my mind.

  Best regards,
  Taku Izumi

> Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
> Signed-off-by: Liu Jiang <jiang.liu@huawei.com>
> ---
>  drivers/acpi/pci_root.c |   19 +++++++++++--------
>  1 files changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
> index 6151d83..582eb11 100644
> --- a/drivers/acpi/pci_root.c
> +++ b/drivers/acpi/pci_root.c
> @@ -129,20 +129,23 @@ 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.
> + * Note: If a device is not added to the system yet, there won't be an
> + * acpi_device struct for it. So do not get HID and CID from acpi_device,
> + * get them from ACPI namespace directly.
>   */
>  int acpi_is_root_bridge(acpi_handle handle)
>  {
> -	int ret;
> -	struct acpi_device *device;
> +	struct acpi_device_info *info;
> +	acpi_status status;
>  
> -	ret = acpi_bus_get_device(handle, &device);
> -	if (ret)
> +	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_device_ids(device, root_device_ids);
> -	if (ret)
> +	if (acpi_match_object_info_ids(info, root_device_ids))
>  		return 0;
>  	else
>  		return 1;
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>
diff mbox

Patch

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 6151d83..582eb11 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -129,20 +129,23 @@  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.
+ * Note: If a device is not added to the system yet, there won't be an
+ * acpi_device struct for it. So do not get HID and CID from acpi_device,
+ * get them from ACPI namespace directly.
  */
 int acpi_is_root_bridge(acpi_handle handle)
 {
-	int ret;
-	struct acpi_device *device;
+	struct acpi_device_info *info;
+	acpi_status status;
 
-	ret = acpi_bus_get_device(handle, &device);
-	if (ret)
+	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_device_ids(device, root_device_ids);
-	if (ret)
+	if (acpi_match_object_info_ids(info, root_device_ids))
 		return 0;
 	else
 		return 1;