* [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using PCIe native hotplug
@ 2011-10-21 22:43 Rafael J. Wysocki
2011-10-22 21:58 ` Yinghai Lu
2011-10-25 13:10 ` Kenji Kaneshige
0 siblings, 2 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2011-10-21 22:43 UTC (permalink / raw)
To: Linux PCI
Cc: Jesse Barnes, LKML, Linux PM list, ACPI Devel Mailing List,
Matthew Garrett
From: Rafael J. Wysocki <rjw@sisk.pl>
If the kernel has requested control of the PCIe native hotplug
feature for a given root complex, the acpiphp driver should not try
to handle that root complex and it should leave it to pciehp.
Failing to do so causes problems to happen if acpiphp is loaded
before pciehp on such systems.
To address this issue make find_root_bridges() ignore PCIe root
complexes with PCIe native hotplug enabled and make add_bridge()
return error code if PCIe native hotplug is enabled for the given
root port. This causes acpiphp to refuse to load if PCIe native
hotplug is enabled for all complexes and to refuse binding to
the root complexes with PCIe native hotplug is enabled.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
drivers/pci/hotplug/acpiphp_glue.c | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
Index: linux/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
--- linux.orig/drivers/pci/hotplug/acpiphp_glue.c
+++ linux/drivers/pci/hotplug/acpiphp_glue.c
@@ -458,8 +458,17 @@ static int add_bridge(acpi_handle handle
{
acpi_status status;
unsigned long long tmp;
+ struct acpi_pci_root *root;
acpi_handle dummy_handle;
+ /*
+ * We shouldn't use this bridge if PCIe native hotplug control has been
+ * granted by the BIOS for it.
+ */
+ root = acpi_pci_find_root(handle);
+ if (root && (root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
+ return -ENODEV;
+
/* if the bridge doesn't have _STA, we assume it is always there */
status = acpi_get_handle(handle, "_STA", &dummy_handle);
if (ACPI_SUCCESS(status)) {
@@ -1297,13 +1306,23 @@ static void handle_hotplug_event_func(ac
static acpi_status
find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
{
+ struct acpi_pci_root *root;
int *count = (int *)context;
- if (acpi_is_root_bridge(handle)) {
- acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
- handle_hotplug_event_bridge, NULL);
- (*count)++;
- }
+ if (!acpi_is_root_bridge(handle))
+ return AE_OK;
+
+ root = acpi_pci_find_root(handle);
+ if (!root)
+ return AE_OK;
+
+ if (root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)
+ return AE_OK;
+
+ (*count)++;
+ acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
+ handle_hotplug_event_bridge, NULL);
+
return AE_OK ;
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using PCIe native hotplug
2011-10-21 22:43 [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using PCIe native hotplug Rafael J. Wysocki
@ 2011-10-22 21:58 ` Yinghai Lu
2011-10-22 22:10 ` Rafael J. Wysocki
2011-10-25 13:10 ` Kenji Kaneshige
1 sibling, 1 reply; 11+ messages in thread
From: Yinghai Lu @ 2011-10-22 21:58 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux PCI, Jesse Barnes, LKML, Linux PM list,
ACPI Devel Mailing List, Matthew Garrett
On Fri, Oct 21, 2011 at 3:43 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> From: Rafael J. Wysocki <rjw@sisk.pl>
>
> If the kernel has requested control of the PCIe native hotplug
> feature for a given root complex, the acpiphp driver should not try
> to handle that root complex and it should leave it to pciehp.
> Failing to do so causes problems to happen if acpiphp is loaded
> before pciehp on such systems.
Should pciehp be built-in kernel instead of as a module?
Yinghai
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using PCIe native hotplug
2011-10-22 21:58 ` Yinghai Lu
@ 2011-10-22 22:10 ` Rafael J. Wysocki
0 siblings, 0 replies; 11+ messages in thread
From: Rafael J. Wysocki @ 2011-10-22 22:10 UTC (permalink / raw)
To: Yinghai Lu
Cc: Linux PCI, Jesse Barnes, LKML, Linux PM list,
ACPI Devel Mailing List, Matthew Garrett
On Saturday, October 22, 2011, Yinghai Lu wrote:
> On Fri, Oct 21, 2011 at 3:43 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > From: Rafael J. Wysocki <rjw@sisk.pl>
> >
> > If the kernel has requested control of the PCIe native hotplug
> > feature for a given root complex, the acpiphp driver should not try
> > to handle that root complex and it should leave it to pciehp.
> > Failing to do so causes problems to happen if acpiphp is loaded
> > before pciehp on such systems.
>
> Should pciehp be built-in kernel instead of as a module?
Well, perhaps. Still, though, if someone doesn't build pciehp and
the control of the native PCIe hotplug is granted for a given root
complex, acpiphp won't work anyway.
Thanks,
Rafael
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using PCIe native hotplug
2011-10-21 22:43 [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using PCIe native hotplug Rafael J. Wysocki
2011-10-22 21:58 ` Yinghai Lu
@ 2011-10-25 13:10 ` Kenji Kaneshige
2011-10-25 13:25 ` Rafael J. Wysocki
1 sibling, 1 reply; 11+ messages in thread
From: Kenji Kaneshige @ 2011-10-25 13:10 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux PCI, Jesse Barnes, LKML, Linux PM list,
ACPI Devel Mailing List, Matthew Garrett
Looks good.
This is also needed for SHPC native hotplug.
Regards,
Kenji Kaneshige
(2011/10/22 7:43), Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki<rjw@sisk.pl>
>
> If the kernel has requested control of the PCIe native hotplug
> feature for a given root complex, the acpiphp driver should not try
> to handle that root complex and it should leave it to pciehp.
> Failing to do so causes problems to happen if acpiphp is loaded
> before pciehp on such systems.
>
> To address this issue make find_root_bridges() ignore PCIe root
> complexes with PCIe native hotplug enabled and make add_bridge()
> return error code if PCIe native hotplug is enabled for the given
> root port. This causes acpiphp to refuse to load if PCIe native
> hotplug is enabled for all complexes and to refuse binding to
> the root complexes with PCIe native hotplug is enabled.
>
> Signed-off-by: Rafael J. Wysocki<rjw@sisk.pl>
> ---
> drivers/pci/hotplug/acpiphp_glue.c | 29 ++++++++++++++++++++++++-----
> 1 file changed, 24 insertions(+), 5 deletions(-)
>
> Index: linux/drivers/pci/hotplug/acpiphp_glue.c
> ===================================================================
> --- linux.orig/drivers/pci/hotplug/acpiphp_glue.c
> +++ linux/drivers/pci/hotplug/acpiphp_glue.c
> @@ -458,8 +458,17 @@ static int add_bridge(acpi_handle handle
> {
> acpi_status status;
> unsigned long long tmp;
> + struct acpi_pci_root *root;
> acpi_handle dummy_handle;
>
> + /*
> + * We shouldn't use this bridge if PCIe native hotplug control has been
> + * granted by the BIOS for it.
> + */
> + root = acpi_pci_find_root(handle);
> + if (root&& (root->osc_control_set& OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
> + return -ENODEV;
> +
> /* if the bridge doesn't have _STA, we assume it is always there */
> status = acpi_get_handle(handle, "_STA",&dummy_handle);
> if (ACPI_SUCCESS(status)) {
> @@ -1297,13 +1306,23 @@ static void handle_hotplug_event_func(ac
> static acpi_status
> find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
> {
> + struct acpi_pci_root *root;
> int *count = (int *)context;
>
> - if (acpi_is_root_bridge(handle)) {
> - acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
> - handle_hotplug_event_bridge, NULL);
> - (*count)++;
> - }
> + if (!acpi_is_root_bridge(handle))
> + return AE_OK;
> +
> + root = acpi_pci_find_root(handle);
> + if (!root)
> + return AE_OK;
> +
> + if (root->osc_control_set& OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)
> + return AE_OK;
> +
> + (*count)++;
> + acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
> + handle_hotplug_event_bridge, NULL);
> +
> return AE_OK ;
> }
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using PCIe native hotplug
2011-10-25 13:10 ` Kenji Kaneshige
@ 2011-10-25 13:25 ` Rafael J. Wysocki
2011-10-26 0:28 ` Kenji Kaneshige
0 siblings, 1 reply; 11+ messages in thread
From: Rafael J. Wysocki @ 2011-10-25 13:25 UTC (permalink / raw)
To: Kenji Kaneshige
Cc: Linux PCI, Jesse Barnes, LKML, Linux PM list,
ACPI Devel Mailing List, Matthew Garrett
On Tuesday, October 25, 2011, Kenji Kaneshige wrote:
> Looks good.
> This is also needed for SHPC native hotplug.
I don't think so, we still leave the SHPC _OSC for the driver to take care
of (which may not be the right thing, but I don't feel confident enough to
decide :-)).
Thanks,
Rafael
> (2011/10/22 7:43), Rafael J. Wysocki wrote:
> > From: Rafael J. Wysocki<rjw@sisk.pl>
> >
> > If the kernel has requested control of the PCIe native hotplug
> > feature for a given root complex, the acpiphp driver should not try
> > to handle that root complex and it should leave it to pciehp.
> > Failing to do so causes problems to happen if acpiphp is loaded
> > before pciehp on such systems.
> >
> > To address this issue make find_root_bridges() ignore PCIe root
> > complexes with PCIe native hotplug enabled and make add_bridge()
> > return error code if PCIe native hotplug is enabled for the given
> > root port. This causes acpiphp to refuse to load if PCIe native
> > hotplug is enabled for all complexes and to refuse binding to
> > the root complexes with PCIe native hotplug is enabled.
> >
> > Signed-off-by: Rafael J. Wysocki<rjw@sisk.pl>
> > ---
> > drivers/pci/hotplug/acpiphp_glue.c | 29 ++++++++++++++++++++++++-----
> > 1 file changed, 24 insertions(+), 5 deletions(-)
> >
> > Index: linux/drivers/pci/hotplug/acpiphp_glue.c
> > ===================================================================
> > --- linux.orig/drivers/pci/hotplug/acpiphp_glue.c
> > +++ linux/drivers/pci/hotplug/acpiphp_glue.c
> > @@ -458,8 +458,17 @@ static int add_bridge(acpi_handle handle
> > {
> > acpi_status status;
> > unsigned long long tmp;
> > + struct acpi_pci_root *root;
> > acpi_handle dummy_handle;
> >
> > + /*
> > + * We shouldn't use this bridge if PCIe native hotplug control has been
> > + * granted by the BIOS for it.
> > + */
> > + root = acpi_pci_find_root(handle);
> > + if (root&& (root->osc_control_set& OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
> > + return -ENODEV;
> > +
> > /* if the bridge doesn't have _STA, we assume it is always there */
> > status = acpi_get_handle(handle, "_STA",&dummy_handle);
> > if (ACPI_SUCCESS(status)) {
> > @@ -1297,13 +1306,23 @@ static void handle_hotplug_event_func(ac
> > static acpi_status
> > find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
> > {
> > + struct acpi_pci_root *root;
> > int *count = (int *)context;
> >
> > - if (acpi_is_root_bridge(handle)) {
> > - acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
> > - handle_hotplug_event_bridge, NULL);
> > - (*count)++;
> > - }
> > + if (!acpi_is_root_bridge(handle))
> > + return AE_OK;
> > +
> > + root = acpi_pci_find_root(handle);
> > + if (!root)
> > + return AE_OK;
> > +
> > + if (root->osc_control_set& OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)
> > + return AE_OK;
> > +
> > + (*count)++;
> > + acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
> > + handle_hotplug_event_bridge, NULL);
> > +
> > return AE_OK ;
> > }
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
>
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using PCIe native hotplug
2011-10-25 13:25 ` Rafael J. Wysocki
@ 2011-10-26 0:28 ` Kenji Kaneshige
2011-10-26 11:42 ` Rafael J. Wysocki
0 siblings, 1 reply; 11+ messages in thread
From: Kenji Kaneshige @ 2011-10-26 0:28 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux PCI, Jesse Barnes, LKML, Linux PM list,
ACPI Devel Mailing List, Matthew Garrett
(2011/10/25 22:25), Rafael J. Wysocki wrote:
> On Tuesday, October 25, 2011, Kenji Kaneshige wrote:
>> Looks good.
>> This is also needed for SHPC native hotplug.
>
> I don't think so, we still leave the SHPC _OSC for the driver to take care
> of (which may not be the right thing, but I don't feel confident enough to
> decide :-)).
I think of the case that acpiphp driver is loaded after shpchp driver is unloaded.
Once native hotplug control is granted to OS, there is no way to return the control
to firmware. So once shpchp gets the native hotplug control on a given root bridge,
acpiphp should not try to handle the hotplug slots under it.
Regards,
Kenji Kaneshige
>
> Thanks,
> Rafael
>
>
>> (2011/10/22 7:43), Rafael J. Wysocki wrote:
>>> From: Rafael J. Wysocki<rjw@sisk.pl>
>>>
>>> If the kernel has requested control of the PCIe native hotplug
>>> feature for a given root complex, the acpiphp driver should not try
>>> to handle that root complex and it should leave it to pciehp.
>>> Failing to do so causes problems to happen if acpiphp is loaded
>>> before pciehp on such systems.
>>>
>>> To address this issue make find_root_bridges() ignore PCIe root
>>> complexes with PCIe native hotplug enabled and make add_bridge()
>>> return error code if PCIe native hotplug is enabled for the given
>>> root port. This causes acpiphp to refuse to load if PCIe native
>>> hotplug is enabled for all complexes and to refuse binding to
>>> the root complexes with PCIe native hotplug is enabled.
>>>
>>> Signed-off-by: Rafael J. Wysocki<rjw@sisk.pl>
>>> ---
>>> drivers/pci/hotplug/acpiphp_glue.c | 29 ++++++++++++++++++++++++-----
>>> 1 file changed, 24 insertions(+), 5 deletions(-)
>>>
>>> Index: linux/drivers/pci/hotplug/acpiphp_glue.c
>>> ===================================================================
>>> --- linux.orig/drivers/pci/hotplug/acpiphp_glue.c
>>> +++ linux/drivers/pci/hotplug/acpiphp_glue.c
>>> @@ -458,8 +458,17 @@ static int add_bridge(acpi_handle handle
>>> {
>>> acpi_status status;
>>> unsigned long long tmp;
>>> + struct acpi_pci_root *root;
>>> acpi_handle dummy_handle;
>>>
>>> + /*
>>> + * We shouldn't use this bridge if PCIe native hotplug control has been
>>> + * granted by the BIOS for it.
>>> + */
>>> + root = acpi_pci_find_root(handle);
>>> + if (root&& (root->osc_control_set& OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
>>> + return -ENODEV;
>>> +
>>> /* if the bridge doesn't have _STA, we assume it is always there */
>>> status = acpi_get_handle(handle, "_STA",&dummy_handle);
>>> if (ACPI_SUCCESS(status)) {
>>> @@ -1297,13 +1306,23 @@ static void handle_hotplug_event_func(ac
>>> static acpi_status
>>> find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
>>> {
>>> + struct acpi_pci_root *root;
>>> int *count = (int *)context;
>>>
>>> - if (acpi_is_root_bridge(handle)) {
>>> - acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
>>> - handle_hotplug_event_bridge, NULL);
>>> - (*count)++;
>>> - }
>>> + if (!acpi_is_root_bridge(handle))
>>> + return AE_OK;
>>> +
>>> + root = acpi_pci_find_root(handle);
>>> + if (!root)
>>> + return AE_OK;
>>> +
>>> + if (root->osc_control_set& OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)
>>> + return AE_OK;
>>> +
>>> + (*count)++;
>>> + acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
>>> + handle_hotplug_event_bridge, NULL);
>>> +
>>> return AE_OK ;
>>> }
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>
>>
>>
>>
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using PCIe native hotplug
2011-10-26 0:28 ` Kenji Kaneshige
@ 2011-10-26 11:42 ` Rafael J. Wysocki
2011-10-28 2:45 ` Kenji Kaneshige
0 siblings, 1 reply; 11+ messages in thread
From: Rafael J. Wysocki @ 2011-10-26 11:42 UTC (permalink / raw)
To: Kenji Kaneshige
Cc: Linux PCI, Jesse Barnes, LKML, Linux PM list,
ACPI Devel Mailing List, Matthew Garrett
On Wednesday, October 26, 2011, Kenji Kaneshige wrote:
> (2011/10/25 22:25), Rafael J. Wysocki wrote:
> > On Tuesday, October 25, 2011, Kenji Kaneshige wrote:
> >> Looks good.
> >> This is also needed for SHPC native hotplug.
> >
> > I don't think so, we still leave the SHPC _OSC for the driver to take care
> > of (which may not be the right thing, but I don't feel confident enough to
> > decide :-)).
>
> I think of the case that acpiphp driver is loaded after shpchp driver is unloaded.
> Once native hotplug control is granted to OS, there is no way to return the control
> to firmware. So once shpchp gets the native hotplug control on a given root bridge,
> acpiphp should not try to handle the hotplug slots under it.
Good point, but that would be a separate patch I think?
Rafael
> >> (2011/10/22 7:43), Rafael J. Wysocki wrote:
> >>> From: Rafael J. Wysocki<rjw@sisk.pl>
> >>>
> >>> If the kernel has requested control of the PCIe native hotplug
> >>> feature for a given root complex, the acpiphp driver should not try
> >>> to handle that root complex and it should leave it to pciehp.
> >>> Failing to do so causes problems to happen if acpiphp is loaded
> >>> before pciehp on such systems.
> >>>
> >>> To address this issue make find_root_bridges() ignore PCIe root
> >>> complexes with PCIe native hotplug enabled and make add_bridge()
> >>> return error code if PCIe native hotplug is enabled for the given
> >>> root port. This causes acpiphp to refuse to load if PCIe native
> >>> hotplug is enabled for all complexes and to refuse binding to
> >>> the root complexes with PCIe native hotplug is enabled.
> >>>
> >>> Signed-off-by: Rafael J. Wysocki<rjw@sisk.pl>
> >>> ---
> >>> drivers/pci/hotplug/acpiphp_glue.c | 29 ++++++++++++++++++++++++-----
> >>> 1 file changed, 24 insertions(+), 5 deletions(-)
> >>>
> >>> Index: linux/drivers/pci/hotplug/acpiphp_glue.c
> >>> ===================================================================
> >>> --- linux.orig/drivers/pci/hotplug/acpiphp_glue.c
> >>> +++ linux/drivers/pci/hotplug/acpiphp_glue.c
> >>> @@ -458,8 +458,17 @@ static int add_bridge(acpi_handle handle
> >>> {
> >>> acpi_status status;
> >>> unsigned long long tmp;
> >>> + struct acpi_pci_root *root;
> >>> acpi_handle dummy_handle;
> >>>
> >>> + /*
> >>> + * We shouldn't use this bridge if PCIe native hotplug control has been
> >>> + * granted by the BIOS for it.
> >>> + */
> >>> + root = acpi_pci_find_root(handle);
> >>> + if (root&& (root->osc_control_set& OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
> >>> + return -ENODEV;
> >>> +
> >>> /* if the bridge doesn't have _STA, we assume it is always there */
> >>> status = acpi_get_handle(handle, "_STA",&dummy_handle);
> >>> if (ACPI_SUCCESS(status)) {
> >>> @@ -1297,13 +1306,23 @@ static void handle_hotplug_event_func(ac
> >>> static acpi_status
> >>> find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
> >>> {
> >>> + struct acpi_pci_root *root;
> >>> int *count = (int *)context;
> >>>
> >>> - if (acpi_is_root_bridge(handle)) {
> >>> - acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
> >>> - handle_hotplug_event_bridge, NULL);
> >>> - (*count)++;
> >>> - }
> >>> + if (!acpi_is_root_bridge(handle))
> >>> + return AE_OK;
> >>> +
> >>> + root = acpi_pci_find_root(handle);
> >>> + if (!root)
> >>> + return AE_OK;
> >>> +
> >>> + if (root->osc_control_set& OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)
> >>> + return AE_OK;
> >>> +
> >>> + (*count)++;
> >>> + acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
> >>> + handle_hotplug_event_bridge, NULL);
> >>> +
> >>> return AE_OK ;
> >>> }
> >>>
> >>> --
> >>> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> >>> the body of a message to majordomo@vger.kernel.org
> >>> More majordomo info at http://vger.kernel.org/majordomo-info.html
> >>>
> >>
> >>
> >>
> >
> >
>
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using PCIe native hotplug
2011-10-26 11:42 ` Rafael J. Wysocki
@ 2011-10-28 2:45 ` Kenji Kaneshige
2011-11-06 22:11 ` [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using SHPC " Rafael J. Wysocki
0 siblings, 1 reply; 11+ messages in thread
From: Kenji Kaneshige @ 2011-10-28 2:45 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Linux PCI, Jesse Barnes, LKML, Linux PM list,
ACPI Devel Mailing List, Matthew Garrett
(2011/10/26 20:42), Rafael J. Wysocki wrote:
> On Wednesday, October 26, 2011, Kenji Kaneshige wrote:
>> (2011/10/25 22:25), Rafael J. Wysocki wrote:
>>> On Tuesday, October 25, 2011, Kenji Kaneshige wrote:
>>>> Looks good.
>>>> This is also needed for SHPC native hotplug.
>>>
>>> I don't think so, we still leave the SHPC _OSC for the driver to take care
>>> of (which may not be the right thing, but I don't feel confident enough to
>>> decide :-)).
>>
>> I think of the case that acpiphp driver is loaded after shpchp driver is unloaded.
>> Once native hotplug control is granted to OS, there is no way to return the control
>> to firmware. So once shpchp gets the native hotplug control on a given root bridge,
>> acpiphp should not try to handle the hotplug slots under it.
>
> Good point, but that would be a separate patch I think?
I think separate patch is ok.
Kenji Kaneshige
>
> Rafael
>
>
>>>> (2011/10/22 7:43), Rafael J. Wysocki wrote:
>>>>> From: Rafael J. Wysocki<rjw@sisk.pl>
>>>>>
>>>>> If the kernel has requested control of the PCIe native hotplug
>>>>> feature for a given root complex, the acpiphp driver should not try
>>>>> to handle that root complex and it should leave it to pciehp.
>>>>> Failing to do so causes problems to happen if acpiphp is loaded
>>>>> before pciehp on such systems.
>>>>>
>>>>> To address this issue make find_root_bridges() ignore PCIe root
>>>>> complexes with PCIe native hotplug enabled and make add_bridge()
>>>>> return error code if PCIe native hotplug is enabled for the given
>>>>> root port. This causes acpiphp to refuse to load if PCIe native
>>>>> hotplug is enabled for all complexes and to refuse binding to
>>>>> the root complexes with PCIe native hotplug is enabled.
>>>>>
>>>>> Signed-off-by: Rafael J. Wysocki<rjw@sisk.pl>
>>>>> ---
>>>>> drivers/pci/hotplug/acpiphp_glue.c | 29 ++++++++++++++++++++++++-----
>>>>> 1 file changed, 24 insertions(+), 5 deletions(-)
>>>>>
>>>>> Index: linux/drivers/pci/hotplug/acpiphp_glue.c
>>>>> ===================================================================
>>>>> --- linux.orig/drivers/pci/hotplug/acpiphp_glue.c
>>>>> +++ linux/drivers/pci/hotplug/acpiphp_glue.c
>>>>> @@ -458,8 +458,17 @@ static int add_bridge(acpi_handle handle
>>>>> {
>>>>> acpi_status status;
>>>>> unsigned long long tmp;
>>>>> + struct acpi_pci_root *root;
>>>>> acpi_handle dummy_handle;
>>>>>
>>>>> + /*
>>>>> + * We shouldn't use this bridge if PCIe native hotplug control has been
>>>>> + * granted by the BIOS for it.
>>>>> + */
>>>>> + root = acpi_pci_find_root(handle);
>>>>> + if (root&& (root->osc_control_set& OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
>>>>> + return -ENODEV;
>>>>> +
>>>>> /* if the bridge doesn't have _STA, we assume it is always there */
>>>>> status = acpi_get_handle(handle, "_STA",&dummy_handle);
>>>>> if (ACPI_SUCCESS(status)) {
>>>>> @@ -1297,13 +1306,23 @@ static void handle_hotplug_event_func(ac
>>>>> static acpi_status
>>>>> find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
>>>>> {
>>>>> + struct acpi_pci_root *root;
>>>>> int *count = (int *)context;
>>>>>
>>>>> - if (acpi_is_root_bridge(handle)) {
>>>>> - acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
>>>>> - handle_hotplug_event_bridge, NULL);
>>>>> - (*count)++;
>>>>> - }
>>>>> + if (!acpi_is_root_bridge(handle))
>>>>> + return AE_OK;
>>>>> +
>>>>> + root = acpi_pci_find_root(handle);
>>>>> + if (!root)
>>>>> + return AE_OK;
>>>>> +
>>>>> + if (root->osc_control_set& OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)
>>>>> + return AE_OK;
>>>>> +
>>>>> + (*count)++;
>>>>> + acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
>>>>> + handle_hotplug_event_bridge, NULL);
>>>>> +
>>>>> return AE_OK ;
>>>>> }
>>>>>
>>>>> --
>>>>> To unsubscribe from this list: send the line "unsubscribe linux-acpi" 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
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using SHPC native hotplug
2011-10-28 2:45 ` Kenji Kaneshige
@ 2011-11-06 22:11 ` Rafael J. Wysocki
2011-11-07 1:43 ` Kenji Kaneshige
0 siblings, 1 reply; 11+ messages in thread
From: Rafael J. Wysocki @ 2011-11-06 22:11 UTC (permalink / raw)
To: Kenji Kaneshige, Jesse Barnes
Cc: Linux PCI, LKML, Linux PM list, ACPI Devel Mailing List,
Matthew Garrett
From: Rafael J. Wysocki <rjw@sisk.pl>
If the kernel has requested control of the SHPC native hotplug
feature for a given root bridge, the acpiphp driver should not try
to handle that root bridge and it should leave it to shpchp.
Failing to do so causes problems to happen if shpchp is loaded
and unloaded before loading acpiphp (ACPI-based hotplug won't work
in that case anyway).
To address this issue make find_root_bridges() ignore PCI root
bridges with SHPC native hotplug enabled and make add_bridge()
return error code if SHPC native hotplug is enabled for the given
root bridge. This causes acpiphp to refuse to load if SHPC native
hotplug is enabled for all root bridges and to refuse binding to
the root bridges with SHPC native hotplug enabled.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
Jesse,
This should apply to your linux-next branch.
Thanks,
Rafael
---
drivers/pci/hotplug/acpiphp_glue.c | 4 ++--
include/linux/acpi.h | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
Index: linux/include/linux/acpi.h
===================================================================
--- linux.orig/include/linux/acpi.h
+++ linux/include/linux/acpi.h
@@ -302,6 +302,10 @@ extern bool osc_sb_apei_support_acked;
OSC_PCI_EXPRESS_PME_CONTROL | \
OSC_PCI_EXPRESS_AER_CONTROL | \
OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL)
+
+#define OSC_PCI_NATIVE_HOTPLUG (OSC_PCI_EXPRESS_NATIVE_HP_CONTROL | \
+ OSC_SHPC_NATIVE_HP_CONTROL)
+
extern acpi_status acpi_pci_osc_control_set(acpi_handle handle,
u32 *mask, u32 req);
extern void acpi_early_init(void);
Index: linux/drivers/pci/hotplug/acpiphp_glue.c
===================================================================
--- linux.orig/drivers/pci/hotplug/acpiphp_glue.c
+++ linux/drivers/pci/hotplug/acpiphp_glue.c
@@ -467,7 +467,7 @@ static int add_bridge(acpi_handle handle
* granted by the BIOS for it.
*/
root = acpi_pci_find_root(handle);
- if (root && (root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
+ if (root && (root->osc_control_set & OSC_PCI_NATIVE_HOTPLUG))
return -ENODEV;
/* if the bridge doesn't have _STA, we assume it is always there */
@@ -1395,7 +1395,7 @@ find_root_bridges(acpi_handle handle, u3
if (!root)
return AE_OK;
- if (root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)
+ if (root->osc_control_set & OSC_PCI_NATIVE_HOTPLUG)
return AE_OK;
(*count)++;
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using SHPC native hotplug
2011-11-06 22:11 ` [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using SHPC " Rafael J. Wysocki
@ 2011-11-07 1:43 ` Kenji Kaneshige
2011-11-11 17:49 ` Jesse Barnes
0 siblings, 1 reply; 11+ messages in thread
From: Kenji Kaneshige @ 2011-11-07 1:43 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Jesse Barnes, Linux PCI, LKML, Linux PM list,
ACPI Devel Mailing List, Matthew Garrett
Thank you for doing this.
Looks good to me.
Reviewed-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Regards,
Kenji Kaneshige
(2011/11/07 7:11), Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki<rjw@sisk.pl>
>
> If the kernel has requested control of the SHPC native hotplug
> feature for a given root bridge, the acpiphp driver should not try
> to handle that root bridge and it should leave it to shpchp.
> Failing to do so causes problems to happen if shpchp is loaded
> and unloaded before loading acpiphp (ACPI-based hotplug won't work
> in that case anyway).
>
> To address this issue make find_root_bridges() ignore PCI root
> bridges with SHPC native hotplug enabled and make add_bridge()
> return error code if SHPC native hotplug is enabled for the given
> root bridge. This causes acpiphp to refuse to load if SHPC native
> hotplug is enabled for all root bridges and to refuse binding to
> the root bridges with SHPC native hotplug enabled.
>
> Signed-off-by: Rafael J. Wysocki<rjw@sisk.pl>
> ---
>
> Jesse,
>
> This should apply to your linux-next branch.
>
> Thanks,
> Rafael
>
> ---
> drivers/pci/hotplug/acpiphp_glue.c | 4 ++--
> include/linux/acpi.h | 4 ++++
> 2 files changed, 6 insertions(+), 2 deletions(-)
>
> Index: linux/include/linux/acpi.h
> ===================================================================
> --- linux.orig/include/linux/acpi.h
> +++ linux/include/linux/acpi.h
> @@ -302,6 +302,10 @@ extern bool osc_sb_apei_support_acked;
> OSC_PCI_EXPRESS_PME_CONTROL | \
> OSC_PCI_EXPRESS_AER_CONTROL | \
> OSC_PCI_EXPRESS_CAP_STRUCTURE_CONTROL)
> +
> +#define OSC_PCI_NATIVE_HOTPLUG (OSC_PCI_EXPRESS_NATIVE_HP_CONTROL | \
> + OSC_SHPC_NATIVE_HP_CONTROL)
> +
> extern acpi_status acpi_pci_osc_control_set(acpi_handle handle,
> u32 *mask, u32 req);
> extern void acpi_early_init(void);
> Index: linux/drivers/pci/hotplug/acpiphp_glue.c
> ===================================================================
> --- linux.orig/drivers/pci/hotplug/acpiphp_glue.c
> +++ linux/drivers/pci/hotplug/acpiphp_glue.c
> @@ -467,7 +467,7 @@ static int add_bridge(acpi_handle handle
> * granted by the BIOS for it.
> */
> root = acpi_pci_find_root(handle);
> - if (root&& (root->osc_control_set& OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
> + if (root&& (root->osc_control_set& OSC_PCI_NATIVE_HOTPLUG))
> return -ENODEV;
>
> /* if the bridge doesn't have _STA, we assume it is always there */
> @@ -1395,7 +1395,7 @@ find_root_bridges(acpi_handle handle, u3
> if (!root)
> return AE_OK;
>
> - if (root->osc_control_set& OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)
> + if (root->osc_control_set& OSC_PCI_NATIVE_HOTPLUG)
> return AE_OK;
>
> (*count)++;
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using SHPC native hotplug
2011-11-07 1:43 ` Kenji Kaneshige
@ 2011-11-11 17:49 ` Jesse Barnes
0 siblings, 0 replies; 11+ messages in thread
From: Jesse Barnes @ 2011-11-11 17:49 UTC (permalink / raw)
To: Kenji Kaneshige
Cc: Rafael J. Wysocki, Linux PCI, LKML, Linux PM list,
ACPI Devel Mailing List, Matthew Garrett
[-- Attachment #1: Type: text/plain, Size: 311 bytes --]
On Mon, 07 Nov 2011 10:43:04 +0900
Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com> wrote:
> Thank you for doing this.
> Looks good to me.
>
> Reviewed-by: Kenji Kaneshige <kaneshige.kenji@jp.fujitsu.com>
Applied to my -next branch, thanks.
--
Jesse Barnes, Intel Open Source Technology Center
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-11-11 17:48 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-21 22:43 [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using PCIe native hotplug Rafael J. Wysocki
2011-10-22 21:58 ` Yinghai Lu
2011-10-22 22:10 ` Rafael J. Wysocki
2011-10-25 13:10 ` Kenji Kaneshige
2011-10-25 13:25 ` Rafael J. Wysocki
2011-10-26 0:28 ` Kenji Kaneshige
2011-10-26 11:42 ` Rafael J. Wysocki
2011-10-28 2:45 ` Kenji Kaneshige
2011-11-06 22:11 ` [PATCH] PCI / ACPI: Make acpiphp ignore root bridges using SHPC " Rafael J. Wysocki
2011-11-07 1:43 ` Kenji Kaneshige
2011-11-11 17:49 ` Jesse Barnes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox