diff mbox

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

Message ID 1350037890-5899-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, 10:31 a.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>
---
 drivers/acpi/pci_root.c |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)

Comments

Jiang Liu Oct. 12, 2012, 10:36 a.m. UTC | #1
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)


--
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
tangchen Oct. 12, 2012, 10:42 a.m. UTC | #2
On 10/12/2012 06:36 PM, Jiang Liu wrote:
> 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.

Hum, I must have missed it. :)
Using acpi_match_object_info_ids() directly seems good. I'm just worry
about if it could cause any other problem. :)

So now, is this bug fixed ? And we don't need these patches, right ?

Thanks. :)

> Thanks!
> Gerry
>
>>
>>   	ret = acpi_match_device_ids(device, root_device_ids);
>>   	if (ret)
>
>
> --
> 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
>

--
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
Jiang Liu Oct. 12, 2012, 10:54 a.m. UTC | #3
On 2012-10-12 18:42, Tang Chen wrote:
> On 10/12/2012 06:36 PM, Jiang Liu wrote:
>> 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.
> 
> Hum, I must have missed it. :)
> Using acpi_match_object_info_ids() directly seems good. I'm just worry
> about if it could cause any other problem. :)
> 
> So now, is this bug fixed ? And we don't need these patches, right ?
> 
> Thanks. :)
I think Yinghai has missed my patch too, so just suggest to use 
acpi_match_object_info_ids() directly.

--Gerry

> 
>> Thanks!
>> Gerry
>>
>>>
>>>       ret = acpi_match_device_ids(device, root_device_ids);
>>>       if (ret)
>>
>>
>> -- 
>> 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
>>
> 
> 
> .
> 


--
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
tangchen Oct. 12, 2012, 10:58 a.m. UTC | #4
On 10/12/2012 06:54 PM, Jiang Liu wrote:
>>> 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.
>>
>> Hum, I must have missed it. :)
>> Using acpi_match_object_info_ids() directly seems good. I'm just worry
>> about if it could cause any other problem. :)
>>
>> So now, is this bug fixed ? And we don't need these patches, right ?
>>
>> Thanks. :)
> I think Yinghai has missed my patch too, so just suggest to use
> acpi_match_object_info_ids() directly.

OK. :)

I will resend a new patch set soon. Thanks for your advice. :)

>
> --Gerry
>
>>
>>> Thanks!
>>> Gerry
>>>
>>>>
>>>>        ret = acpi_match_device_ids(device, root_device_ids);
>>>>        if (ret)
>>>
>>>
>>> --
>>> 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
>>>
>>
>>
>> .
>>
>
>
> --
> 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/
>

--
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
Yinghai Lu Oct. 12, 2012, 6:34 p.m. UTC | #5
On Fri, Oct 12, 2012 at 3:54 AM, Jiang Liu <jiang.liu@huawei.com> wrote:
> On 2012-10-12 18:42, Tang Chen wrote:
>> On 10/12/2012 06:36 PM, Jiang Liu wrote:
>>> 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.
>>
>> Hum, I must have missed it. :)
>> Using acpi_match_object_info_ids() directly seems good. I'm just worry
>> about if it could cause any other problem. :)
>>
>> So now, is this bug fixed ? And we don't need these patches, right ?
>>
>> Thanks. :)
> I think Yinghai has missed my patch too, so just suggest to use
> acpi_match_object_info_ids() directly.

i put that patch from Jiang in my branch for while, and later found it
cause pci_root_bus notifying
do not work anymore, so i dropped that.

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
Yinghai Lu Oct. 12, 2012, 10 p.m. UTC | #6
On Fri, Oct 12, 2012 at 11:34 AM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Fri, Oct 12, 2012 at 3:54 AM, Jiang Liu <jiang.liu@huawei.com> wrote:
>> On 2012-10-12 18:42, Tang Chen wrote:
>>> On 10/12/2012 06:36 PM, Jiang Liu wrote:
>>>> 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.
>>>
>>> Hum, I must have missed it. :)
>>> Using acpi_match_object_info_ids() directly seems good. I'm just worry
>>> about if it could cause any other problem. :)
>>>
>>> So now, is this bug fixed ? And we don't need these patches, right ?
>>>
>>> Thanks. :)
>> I think Yinghai has missed my patch too, so just suggest to use
>> acpi_match_object_info_ids() directly.
>
> i put that patch from Jiang in my branch for while, and later found it
> cause pci_root_bus notifying
> do not work anymore, so i dropped that.

I updated three patches and put them into my for-pci-split-pci-root-hp-2 branch.

http://git.kernel.org/?p=linux/kernel/git/yinghai/linux-yinghai.git;a=shortlog;h=refs/heads/for-pci-split-pci-root-hp-2

	git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git
for-pci-split-pci-root-hp-2

Thanks

Yinghai
diff mbox

Patch

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;
+	}
 
 	ret = acpi_match_device_ids(device, root_device_ids);
 	if (ret)