Patchwork [v8,11/22] PCI: correctly detect ACPI PCI host bridge objects

login
register
mail settings
Submitter Yinghai Lu
Date Jan. 11, 2013, 10:40 p.m.
Message ID <1357944049-29620-12-git-send-email-yinghai@kernel.org>
Download mbox | patch
Permalink /patch/211435/
State Superseded
Headers show

Comments

Yinghai Lu - Jan. 11, 2013, 10:40 p.m.
From: Jiang Liu <jiang.liu@huawei.com>

The code in pci_root_hp.c depends on function acpi_is_root_bridge()
to check whether an ACPI object is a PCI host bridge or not.
If an ACPI device hasn't been created for the ACPI object yet,
function acpi_is_root_bridge() will return false even if the object
is a PCI host bridge object. That behavior will cause two issues:
1) No ACPI notification handler installed for PCI host bridges absent
   at startup, so hotplug events for those bridges won't be handled.
2) rescan_root_bridge() can't reenumerate offlined PCI host bridges
   because the ACPI devices have been already destroyed.

So use acpi_match_object_info_ids() to correctly detect PCI host bridges.

-v2: update to use acpi_match_object_info_ids() from Tang Chen  - Yinghai
-v3: drop the PNP0A008, according to Bjorn.

Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
---
 drivers/acpi/pci_root.c |   19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
Rafael J. Wysocki - Jan. 12, 2013, 11:34 p.m.
On Friday, January 11, 2013 02:40:38 PM Yinghai Lu wrote:
> From: Jiang Liu <jiang.liu@huawei.com>
> 
> The code in pci_root_hp.c depends on function acpi_is_root_bridge()
> to check whether an ACPI object is a PCI host bridge or not.
> If an ACPI device hasn't been created for the ACPI object yet,
> function acpi_is_root_bridge() will return false even if the object
> is a PCI host bridge object. That behavior will cause two issues:
> 1) No ACPI notification handler installed for PCI host bridges absent
>    at startup, so hotplug events for those bridges won't be handled.
> 2) rescan_root_bridge() can't reenumerate offlined PCI host bridges
>    because the ACPI devices have been already destroyed.
> 
> So use acpi_match_object_info_ids() to correctly detect PCI host bridges.
> 
> -v2: update to use acpi_match_object_info_ids() from Tang Chen  - Yinghai
> -v3: drop the PNP0A008, according to Bjorn.
> 
> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Len Brown <lenb@kernel.org>
> Cc: linux-acpi@vger.kernel.org
> ---
>  drivers/acpi/pci_root.c |   19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
> index 5ae36d8..d30fb94 100644
> --- a/drivers/acpi/pci_root.c
> +++ b/drivers/acpi/pci_root.c
> @@ -923,6 +923,23 @@ static void handle_hotplug_event_root(acpi_handle handle, u32 type,
>  				_handle_hotplug_event_root);
>  }
>  
> +static bool acpi_is_root_bridge_object(acpi_handle handle)
> +{
> +	struct acpi_device_info *info = NULL;
> +	acpi_status status;
> +	bool ret;
> +
> +	status = acpi_get_object_info(handle, &info);
> +	if (ACPI_FAILURE(status))
> +		return false;
> +
> +	ret = !acpi_match_object_info_ids(info, root_device_ids);
> +

Well, I kind of don't understand why don't we check info->flags
against ACPI_PCI_ROOT_BRIDGE that acpi_get_object_info() sets for us if it
finds a PCI root bridge?

> +	kfree(info);
> +
> +	return ret;
> +}
> +
>  static acpi_status __init
>  find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
>  {
> @@ -931,7 +948,7 @@ find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
>  				      .pointer = objname };
>  	int *count = (int *)context;
>  
> -	if (!acpi_is_root_bridge(handle))
> +	if (!acpi_is_root_bridge_object(handle))
>  		return AE_OK;
>  
>  	(*count)++;
> 

Thanks,
Rafael
Jiang Liu - Jan. 13, 2013, 3:32 p.m.
On 01/13/2013 07:34 AM, Rafael J. Wysocki wrote:
> On Friday, January 11, 2013 02:40:38 PM Yinghai Lu wrote:
>> From: Jiang Liu <jiang.liu@huawei.com>
>>
>> The code in pci_root_hp.c depends on function acpi_is_root_bridge()
>> to check whether an ACPI object is a PCI host bridge or not.
>> If an ACPI device hasn't been created for the ACPI object yet,
>> function acpi_is_root_bridge() will return false even if the object
>> is a PCI host bridge object. That behavior will cause two issues:
>> 1) No ACPI notification handler installed for PCI host bridges absent
>>    at startup, so hotplug events for those bridges won't be handled.
>> 2) rescan_root_bridge() can't reenumerate offlined PCI host bridges
>>    because the ACPI devices have been already destroyed.
>>
>> So use acpi_match_object_info_ids() to correctly detect PCI host bridges.
>>
>> -v2: update to use acpi_match_object_info_ids() from Tang Chen  - Yinghai
>> -v3: drop the PNP0A008, according to Bjorn.
>>
>> Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
>> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
>> Cc: Len Brown <lenb@kernel.org>
>> Cc: linux-acpi@vger.kernel.org
>> ---
>>  drivers/acpi/pci_root.c |   19 ++++++++++++++++++-
>>  1 file changed, 18 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
>> index 5ae36d8..d30fb94 100644
>> --- a/drivers/acpi/pci_root.c
>> +++ b/drivers/acpi/pci_root.c
>> @@ -923,6 +923,23 @@ static void handle_hotplug_event_root(acpi_handle handle, u32 type,
>>  				_handle_hotplug_event_root);
>>  }
>>  
>> +static bool acpi_is_root_bridge_object(acpi_handle handle)
>> +{
>> +	struct acpi_device_info *info = NULL;
>> +	acpi_status status;
>> +	bool ret;
>> +
>> +	status = acpi_get_object_info(handle, &info);
>> +	if (ACPI_FAILURE(status))
>> +		return false;
>> +
>> +	ret = !acpi_match_object_info_ids(info, root_device_ids);
>> +
> 
> Well, I kind of don't understand why don't we check info->flags
> against ACPI_PCI_ROOT_BRIDGE that acpi_get_object_info() sets for us if it
> finds a PCI root bridge?
Hi Rafael,
	Thanks for reminder, we should test ACPI_PCI_ROOT_BRIDGE flag
instead of a redundant calling to acpi_match_object_info_ids(). To be honest,
I don't know the existence of ACPI_PCI_ROOT_BRIDGE flag before:(

> 
>> +	kfree(info);
>> +
>> +	return ret;
>> +}
>> +
>>  static acpi_status __init
>>  find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
>>  {
>> @@ -931,7 +948,7 @@ find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
>>  				      .pointer = objname };
>>  	int *count = (int *)context;
>>  
>> -	if (!acpi_is_root_bridge(handle))
>> +	if (!acpi_is_root_bridge_object(handle))
>>  		return AE_OK;
>>  
>>  	(*count)++;
>>
> 
> Thanks,
> Rafael
> 
> 

--
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

Patch

diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 5ae36d8..d30fb94 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -923,6 +923,23 @@  static void handle_hotplug_event_root(acpi_handle handle, u32 type,
 				_handle_hotplug_event_root);
 }
 
+static bool acpi_is_root_bridge_object(acpi_handle handle)
+{
+	struct acpi_device_info *info = NULL;
+	acpi_status status;
+	bool ret;
+
+	status = acpi_get_object_info(handle, &info);
+	if (ACPI_FAILURE(status))
+		return false;
+
+	ret = !acpi_match_object_info_ids(info, root_device_ids);
+
+	kfree(info);
+
+	return ret;
+}
+
 static acpi_status __init
 find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
 {
@@ -931,7 +948,7 @@  find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
 				      .pointer = objname };
 	int *count = (int *)context;
 
-	if (!acpi_is_root_bridge(handle))
+	if (!acpi_is_root_bridge_object(handle))
 		return AE_OK;
 
 	(*count)++;