Thunderbolt workarounds
PATCH v2 2/8 PCI: acpiphp: do not check for SLOT_ENABLED in enable_device()
In reply to Mika WesterbergFrom: "Kirill A. Shutemov" <[email protected]>
With Thunderbolt you can chain devices: connect a new devices to plugged one. In this case the slot is already enabled, but we still want to look for new devices behind it.
We're going to reuse enable_device() for rescan for new devices on the enabled slot. Let's push the check up by stack.
--- drivers/pci/hotplug/acpiphp_glue.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +2 -3
@@ -688,9 +688,6 @@ static int __ref enable_device(struct acpiphp_slot *slot)int num, max, pass;LIST_HEAD (add_list); -if (slot->flags &SLOT_ENABLED ) - goto err_exit; -list_for_each_entry (func, &slot->funcs, sibling)acpiphp_bus_add (func);
@@ -1242,6 +1239,8 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot) goto err_exit;if (get_slot_status (slot) ==ACPI_STA_ALL ) { +if (slot->flags &SLOT_ENABLED ) + goto err_exit;/* configure all functions */ retval =enable_device (slot);if (retval)
Signature · 1 line
1.8.3.2
v2 cover Thunderbolt workarounds
Here's the next revision of the workarounds for Thunderbolt machines. The previous revision can be found here:
https://lkml.org/lkml/2013/6/25/400
The series fixes problems seen in ACPI hotplug driver and resource re-allocation issue in pcibios_resource_survey_bus(). With these applied we have been able to connect Thunderbolt chain as long as:
PC +--+ eSata Hub #0 +--+ eSata Hub #1 +--+ Apple Thunderbolt display +--+ Apple ethernet dongle
That's all Thunderbolt devices we have for testing. This results the following PCIe tree (output of lspci -tv):
+-1c.4-[06-80]----00.0-[07-80]--+-00.0-[08]-- | +-03.0-[09-7d]----00.0-[0a-7d]--+-03.0-[0b]----00.0 Marvell Technology Group Ltd. Device 9182 | | +-04.0-[0c-7c]----00.0-[0d-7c]--+-03.0-[0e]----00.0 Marvell Technology Group Ltd. Device 9182 | | | +-04.0-[0f-7b]----00.0-[10-7b]--+-00.0-[11-13]----00.0-[12-13]----03.0-[13]--+-00.0 Pericom Semiconductor Device 400e | | | | | +-00.1 Pericom Semiconductor Device 400e | | | | | \-00.2 Pericom Semiconductor Device 400f | | | | +-01.0-[14]----00.0 Broadcom Corporation NetXtreme BCM57761 Gigabit Ethernet PCIe | | | | +-02.0-[15]----00.0 Agere Systems FW643 PCI Express 1394b Controller (PHY/Link) | | | | +-03.0-[16]-- | | | | +-04.0-[17-7a]----00.0-[18-7a]----00.0-[19]----00.0 Broadcom Corporation Device 1682 | | | | \-05.0-[7b]-- | | | \-05.0-[7c]-- | | \-05.0-[7d]-- | +-04.0-[7e]-- | +-05.0-[7f]-- | \-06.0-[80]--
There are still problems with individual device drivers not handling the surprise hotplug nature of Thunderbolt devices correctly but that can be handled per driver later on.
This has been tested on Acer Aspire S5 ultrabook and in addition to that on Intel DZ77RE-75K desktop.
Changes to the previous version:
[1/8] A new patch that fixes pcibios_resource_survey_bus() to handle
re-allocation of resources properly. This patch should be first one in the series because the following patches then enable things that depend on this one.
[3/8] Dropped !dev->subordinate->is_added check. This is handled in [1/6]. [4/8] Removed 'continue' and call directly pci_trim_stale_devices() and
fold the pci_trim_stale_devices() to this patch.
[5/8] A new patch that removes SLOT_ENABLED flag completely from the
acpiphp driver. This is a separate patch to make reverting easy in case there appears regressions but still make Thunderbolt working.
[6/8] Use the original Kirill's workaround for Acer Aspire S5. [7,8/8] New cleanups for acpiphp that were found during development.
The series applies on top of v3.10.
Kirill A. Shutemov (4):
PCI: acpiphp: do not check for SLOT_ENABLED in enable_device()
PCI: acpiphp: enable_device(): rescan even if no new devices on slot
PCI: acpiphp: check for new devices on enabled host
PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
Mika Westerberg (4):
x86/PCI: prevent re-allocation of already existing bridge and ROM
resources
PCI: acpiphp: kill SLOT_ENABLED in favor of always re-enumerating the
devices
PCI: acpiphp: get rid of unused constants in acpiphp.h
PCI: acpiphp: sanitize acpiphp_get_[latch|adapter]_status()
arch/x86/pci/i386.c | 4 ++ drivers/pci/hotplug/acpi_pcihp.c | 13 +++++ drivers/pci/hotplug/acpiphp.h | 5 -- drivers/pci/hotplug/acpiphp_glue.c | 97 ++++++++++++-------------------------- drivers/pci/remove.c | 20 ++++++++ include/linux/pci.h | 1 + 6 files changed, 69 insertions(+), 71 deletions(-)
Signature · 1 line
1.8.3.2
PATCH v2 3/8 PCI: acpiphp: enable_device(): rescan even if no new devices on slot
From: "Kirill A. Shutemov" <[email protected]>
pci_scan_slot() returns number of new devices connected *directly* connected to the slot. Current enable_device() checks the return value and stops if it doesn't see a new device.
In Thunderbolt chaining case the new device can be deeper in hierarchy, so do the rescan anyway.
Because of that we must make sure that pcibios_resource_survey_bus() and check_hotplug_bridge() get called only for a just found bus and not the ones already added to the system. Failure to do so will lead to resource conflicts.
--- drivers/pci/hotplug/acpiphp_glue.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +2 -9
@@ -685,18 +685,13 @@ static int __ref enable_device(struct acpiphp_slot *slot)struct pci_dev *dev;struct pci_bus *bus = slot->bridge->pci_bus;struct acpiphp_func *func; -int num, max, pass; +int max, pass;LIST_HEAD (add_list);list_for_each_entry (func, &slot->funcs, sibling)acpiphp_bus_add (func); - num =pci_scan_slot (bus,PCI_DEVFN (slot->device,0 )); -if (num ==0 ) { -/* Maybe only part of funcs are added. */ -dbg ("No new device found\n" ); - goto err_exit; - } +pci_scan_slot (bus,PCI_DEVFN (slot->device,0 )); max =acpiphp_max_busnr (bus);for (pass =0 ; pass <2 ; pass++) {
@@ -742,8 +737,6 @@ static int __ref enable_device(struct acpiphp_slot *slot) } } - - err_exit:return 0 ; }
Signature · 1 line
1.8.3.2
PATCH v2 5/8 PCI: acpiphp: kill SLOT_ENABLED in favor of always re-enumerating the devices
In reply to Mika WesterbergThe acpiphp driver checks SLOT_ENABLED flag only in aciphp_enable_slot() to prevent re-enumeration of the already enabled slot. Because of that it is not possible to add new devices behind the slot later on (like it is the case with Thunderbolt devices).
Now, there are two places where acpiphp_enable_slot() gets called:
1) On Bus Check event for a function (in case of a dock).
2) When userpace enables a slot by writing '1' to
/sys/bus/pci/slots/*/power.
In the first case it doesn't make sense to do the check because we are ought to re-enumerate the bus anyway and see if there are any new devices added farther in the hierarchy, according the the ACPI specification.
The second case where userspace explicitly enables the device also doesn't need this check as we already check if the slot is powered on or off in power_on_slot() and don't do it twice.
So get rid of the SLOT_ENABLED flag and always re-enumerate devices behind a slot when acpiphp_enable_slot() is called. In addition doing this allows userspace to simulate Bus Check event by writing '1' to the 'power' file under the slot.
--- drivers/pci/hotplug/acpiphp.h | 1 - drivers/pci/hotplug/acpiphp_glue.c | 18 +----------------- 2 files changed, 1 insertion(+), 18 deletions(-)
drivers/pci/hotplug/acpiphp.h +0 -1
@@ -154,7 +154,6 @@ struct acpiphp_attention_info/* slot flags */ #define SLOT_POWEREDON (0x00000001) -#define SLOT_ENABLED (0x00000002)#define SLOT_MULTIFUNCTION (0x00000004)/* function flags */
drivers/pci/hotplug/acpiphp_glue.c +1 -17
@@ -304,7 +304,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)if (pci_bus_read_dev_vendor_id (pbus,PCI_DEVFN (device, function), &val,60 *1000 )) - slot->flags |= (SLOT_ENABLED |SLOT_POWEREDON ); + slot->flags |=SLOT_POWEREDON ;if (is_dock_device (handle)) {/* we don't want to call this device's _EJ0
@@ -725,18 +725,6 @@ static int __ref enable_device(struct acpiphp_slot *slot)pci_bus_add_devices (bus); - slot->flags |=SLOT_ENABLED ; -list_for_each_entry (func, &slot->funcs, sibling) { - dev =pci_get_slot (bus,PCI_DEVFN (slot->device, - func->function)); -if (!dev) { -/* Do not set SLOT_ENABLED flag if some funcs -are not added. */ - slot->flags &= (~SLOT_ENABLED ); -continue ; - } - } -return 0 ; }
@@ -782,8 +770,6 @@ static int disable_device(struct acpiphp_slot *slot)acpiphp_bus_trim (func->handle); } - slot->flags &= (~SLOT_ENABLED ); -return 0 ; }
@@ -1229,8 +1215,6 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot) goto err_exit;if (get_slot_status (slot) ==ACPI_STA_ALL ) { -if (slot->flags &SLOT_ENABLED ) - goto err_exit;/* configure all functions */ retval =enable_device (slot);if (retval)
Signature · 1 line
1.8.3.2
PATCH v2 4/8 PCI: acpiphp: check for new devices on enabled host
In reply to Mika WesterbergFrom: "Kirill A. Shutemov" <[email protected]>
Current acpiphp_check_bridge() implementation is pretty dumb:
- it enables the slot if it's not enabled and the slot status is ACPI_STA_ALL;
- it disables the slot if it's enabled and slot is not in ACPI_STA_ALL state.
This behavior is not enough to handle Thunderbolt chaining case properly. We need to actually rescan for new devices even if a device has already in the slot.
The new implementation disables and stops the slot if it's not in ACPI_STA_ALL state.
For ACPI_STA_ALL state we first trim devices which don't respond. In order to support that we introduce a new function pci_trim_stale_devices() that goes through the child devices of a given bus, check if the device is gone and in that case stop and remove the device.
Once we have trimmed the bus we start looking for any new devices that might have appeared on the bus. We do that even if the slot is already enabled (SLOT_ENABLED).
--- drivers/pci/hotplug/acpiphp_glue.c | 55 ++++++++++++++++++-------------------- drivers/pci/remove.c | 20 ++++++++++++++ include/linux/pci.h | 1 + 3 files changed, 47 insertions(+), 29 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +26 -29
@@ -865,43 +865,40 @@ int acpiphp_eject_slot(struct acpiphp_slot *slot)* Iterate over all slots under this bridge and make sure that if a * card is present they are enabled, and if not they are disabled. */ -static int acpiphp_check_bridge (struct acpiphp_bridge *bridge) +static void acpiphp_check_bridge (struct acpiphp_bridge *bridge) {struct acpiphp_slot *slot; -int retval =0 ; -int enabled, disabled; - - enabled = disabled =0 ;list_for_each_entry (slot, &bridge->slots, node) { -unsigned int status =get_slot_status (slot); -if (slot->flags &SLOT_ENABLED ) { -if (status ==ACPI_STA_ALL ) -continue ; - retval =acpiphp_disable_slot (slot); -if (retval) { -err ("Error occurred in disabling\n" ); - goto err_exit; - }else { -acpiphp_eject_slot (slot); +struct pci_bus *bus = slot->bridge->pci_bus; +struct pci_dev *dev, *tmp; +int retval; + +mutex_lock (&slot->crit_sect); +/* wake up all functions */ + retval =power_on_slot (slot); +if (retval) + goto unlock; + +if (get_slot_status (slot) ==ACPI_STA_ALL ) { +/* remove stale devices if any */ +list_for_each_entry_safe (dev, tmp, &bus->devices, + bus_list) { +if (PCI_SLOT (dev->devfn) == slot->device) +pci_trim_stale_devices (dev); } - disabled++; + +/* configure all functions */ + retval =enable_device (slot); +if (retval) +power_off_slot (slot); }else { -if (status !=ACPI_STA_ALL ) -continue ; - retval =acpiphp_enable_slot (slot); -if (retval) { -err ("Error occurred in enabling\n" ); - goto err_exit; - } - enabled++; +disable_device (slot); +power_off_slot (slot); } +unlock: +mutex_unlock (&slot->crit_sect); } - -dbg ("%s: %d enabled, %d disabled\n" , __func__, enabled, disabled); - - err_exit: -return retval; }static void acpiphp_set_hpp_values (struct pci_bus *bus)
drivers/pci/remove.c +20 -0
@@ -112,6 +112,26 @@ void pci_stop_and_remove_bus_device(struct pci_dev *dev) }EXPORT_SYMBOL (pci_stop_and_remove_bus_device); +/** +* pci_trim_stale_devices - remove stale device or any stale child +*/ +void pci_trim_stale_devices (struct pci_dev *dev) +{ +struct pci_bus *bus = dev->subordinate; +struct pci_dev *child, *tmp; +bool alive; +u32 l; + +/* check if the device responds */ + alive =pci_bus_read_dev_vendor_id (dev->bus, dev->devfn, &l,0 ); +if (!alive) +pci_stop_and_remove_bus_device (dev); + +if (alive && bus) +list_for_each_entry_safe (child, tmp, &bus->devices, bus_list) +pci_trim_stale_devices (child); +} +void pci_stop_root_bus (struct pci_bus *bus) {struct pci_dev *child, *tmp;
include/linux/pci.h +1 -0
@@ -754,6 +754,7 @@ struct pci_dev *pci_dev_get(struct pci_dev *dev);void pci_dev_put (struct pci_dev *dev);void pci_remove_bus (struct pci_bus *b);void pci_stop_and_remove_bus_device (struct pci_dev *dev); +void pci_trim_stale_devices (struct pci_dev *dev);void pci_stop_root_bus (struct pci_bus *bus);void pci_remove_root_bus (struct pci_bus *bus);void pci_setup_cardbus (struct pci_bus *bus);
Signature · 1 line
1.8.3.2
PATCH v2 6/8 PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
In reply to Mika WesterbergFrom: "Kirill A. Shutemov" <[email protected]>
Correct ACPI PCI hotplug imeplementation should have _RMV method in a PCI slot (device under pci bridge). In Acer Aspire S5 case we have it deeper in hierarchy:
Device (RP05)
{
// ...
Device (HRUP)
{
// ...
Device (HRDN)
{
// ...
Device (EPUP)
{
// ...
Method (_RMV, 0, NotSerialized) // _RMV: Removal Status
{
Return (One)
}
}
} }
}
--- drivers/pci/hotplug/acpi_pcihp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/pci/hotplug/acpi_pcihp.c +13 -0
@@ -422,6 +422,19 @@ static int pcihp_is_ejectable(acpi_handle handle) status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable);if (ACPI_SUCCESS (status) && removable)return 1 ; + +/* +* Workaround for Thunderbolt implementation on Acer Aspire S5. +* +* Correct ACPI PCI hotplug imeplementation has _RMV method in a PCI +* slot (device under pci bridge). In Acer Aspire S5 case we have it +* deeper in hierarchy. +*/ + status =acpi_evaluate_integer (handle,"HRDN.EPUP._RMV" ,NULL , + &removable); +if (ACPI_SUCCESS (status) && removable) +return 1 ; +return 0 ; }
Signature · 1 line
1.8.3.2
PATCH v2 8/8 PCI: acpiphp: sanitize acpiphp_get_[latch|adapter]_status()
In reply to Mika WesterbergThere is no need for a temporary variable and all the tricks with ternary operators. Change the functions to be a bit more straightforward.
--- drivers/pci/hotplug/acpiphp_glue.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +2 -10
@@ -1271,11 +1271,7 @@ u8 acpiphp_get_power_status(struct acpiphp_slot *slot)*/ u8 acpiphp_get_latch_status (struct acpiphp_slot *slot) { -unsigned int sta; - - sta =get_slot_status (slot); - -return (sta &ACPI_STA_DEVICE_UI ) ?0 :1 ; +return !(get_slot_status (slot) &ACPI_STA_DEVICE_UI ); }
@@ -1285,9 +1281,5 @@ u8 acpiphp_get_latch_status(struct acpiphp_slot *slot)*/ u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot) { -unsigned int sta; - - sta =get_slot_status (slot); - -return (sta ==0 ) ?0 :1 ; +return !!get_slot_status (slot); }
Signature · 1 line
1.8.3.2
PATCH v2 7/8 PCI: acpiphp: get rid of unused constants in acpiphp.h
In reply to Mika WesterbergThese are not used anywhere so kill them.
--- drivers/pci/hotplug/acpiphp.h | 4 ---- 1 file changed, 4 deletions(-)
drivers/pci/hotplug/acpiphp.h +0 -4
@@ -142,9 +142,6 @@ struct acpiphp_attention_infostruct module *owner; }; -/* PCI bus bridge HID */ -#define ACPI_PCI_HOST_HID "PNP0A03" -/* ACPI _STA method value (ignore bit 4; battery present) */ #define ACPI_STA_ALL (0x0000000f)
@@ -154,7 +151,6 @@ struct acpiphp_attention_info/* slot flags */ #define SLOT_POWEREDON (0x00000001) -#define SLOT_MULTIFUNCTION (0x00000004)/* function flags */
Signature · 1 line
1.8.3.2
PATCH v2 1/8 x86/PCI: prevent re-allocation of already existing bridge and ROM resources
In reply to Mika WesterbergIn hotplug case (especially with Thunderbolt enabled systems) we might need to call pcibios_resource_survey_bus() several times for a bus. The function ends up calling pci_claim_resource() for each bridge resource that then fails claiming that the resource exists already (which it does). Once this happens the resource is invalidated thus preventing devices behind the bridge to allocate their resources.
To fix this we do what has been done in pcibios_allocate_dev_resources() and check 'parent' of the given resource. If it is non-NULL it means that the resource has been allocated already and we can skip it. We do the same for ROM resources as well.
--- arch/x86/pci/i386.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/pci/i386.c +4 -0
@@ -210,6 +210,8 @@ static void pcibios_allocate_bridge_resources(struct pci_dev *dev) r = &dev->resource[idx];if (!r->flags)continue ; +if (r->parent)/* Already allocated */ +continue ;if (!r->start ||pci_claim_resource (dev, idx) <0 ) {/* * Something is wrong with the region.
@@ -318,6 +320,8 @@ static void pcibios_allocate_dev_rom_resource(struct pci_dev *dev) r = &dev->resource[PCI_ROM_RESOURCE ];if (!r->flags || !r->start)return ; +if (r->parent)/* Already allocated */ +return ;if (pci_claim_resource (dev,PCI_ROM_RESOURCE ) <0 ) { r->end -= r->start;
Signature · 1 line
1.8.3.2
Are there any plans to provide native support for the Thunderbolt controller, rather than relying on system management mode?
Signature · 1 line
Matthew Garrett | [email protected]
Quoted 2 lines · Matthew Garrett
Are there any plans to provide native support for the Thunderbolt controller, rather than relying on system management mode?
For what specific hardware platform? For the ones that this patchset controls, the OS doesn't have access to the Thunderbolt controller as far as I can tell, it all happens through the ACPI and PCI hotplug interface.
thanks,
greg k-h
Quoted 2 lines · Matthew Garrett
Are there any plans to provide native support for the Thunderbolt controller, rather than relying on system management mode?
I believe there are some to implement a native Thunderbolt controller driver but I don't know the details.
Bruce Allan and Miles Penner (who are CC'd here) might have a better answer for you.
Quoted 8 lines · Greg Kroah-Hartman
Quoted 2 lines · Matthew Garrett
Are there any plans to provide native support for the Thunderbolt controller, rather than relying on system management mode?
For what specific hardware platform? For the ones that this patchset controls, the OS doesn't have access to the Thunderbolt controller as far as I can tell, it all happens through the ACPI and PCI hotplug interface.
Given that there exist platforms without the SMM implementation, there's presumably either a controller or chipset register that controls whether SMIs are generated in response to Thunderbolt events.
Signature · 1 line
Matthew Garrett | [email protected]
Are you talking about Apple platforms specifically?
Cheers,
John
Quoted 26 lines
-----Original Message-----
From: Matthew Garrett [mailto:[email protected]]
Sent: Wednesday, July 03, 2013 11:45 AM
To: Greg Kroah-Hartman
Cc: Mika Westerberg; Bjorn Helgaas; Wysocki, Rafael J; Jesse Barnes; Yinghai Lu; Ronciak, John; Penner, Miles J; Allan, Bruce W; Heikki Krogerus; Kirill A. Shutemov; [email protected]; linux- [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 0/8] Thunderbolt workaroundsQuoted 8 lines · Greg Kroah-Hartman
Quoted 2 lines · Matthew Garrett
Are there any plans to provide native support for the Thunderbolt controller, rather than relying on system management mode?
For what specific hardware platform? For the ones that this patchset controls, the OS doesn't have access to the Thunderbolt controller as far as I can tell, it all happens through the ACPI and PCI hotplug interface.
Given that there exist platforms without the SMM implementation, there's presumably either a controller or chipset register that controls whether SMIs are generated in response to Thunderbolt events.
--
Matthew Garrett | [email protected]
Quoted 1 line · John
Are you talking about Apple platforms specifically?
Yeah, that's the specific example.
Signature · 1 line
Matthew Garrett | [email protected]
Apple does their own thing and do not talk to Intel about it at all. This includes writing special drivers and user-space components. So we (Intel) don't know so we can't comment about it. Sorry.
Cheers,
John
Quoted 17 lines
-----Original Message-----
From: Matthew Garrett [mailto:[email protected]]
Sent: Wednesday, July 03, 2013 1:36 PM
To: Ronciak, John
Cc: Greg Kroah-Hartman; Mika Westerberg; Bjorn Helgaas; Wysocki, Rafael J; Jesse Barnes; Yinghai Lu; Penner, Miles J; Allan, Bruce W; Heikki Krogerus; Kirill A. Shutemov; [email protected]; linux- [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 0/8] Thunderbolt workaroundsQuoted 1 line · John
Are you talking about Apple platforms specifically?
Yeah, that's the specific example.
--
Matthew Garrett | [email protected]
Quoted 1 line · John
Apple does their own thing and do not talk to Intel about it at all. This includes writing special drivers and user-space components. So we (Intel) don't know so we can't comment about it. Sorry.
The hardware has an Intel part number, so I'm pretty sure someone there has some idea what the register map looks like.
Signature · 1 line
Matthew Garrett | [email protected]
Re: [PATCH v2 6/8] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
In reply to Mika WesterbergQuoted 41 lines · Mika Westerberg
From: "Kirill A. Shutemov" <[email protected]>
Correct ACPI PCI hotplug imeplementation should have
_RMVmethod in a PCI slot (device under pci bridge). In Acer Aspire S5 case we have it deeper in hierarchy:Device (RP05)
{ // ... Device (HRUP) { // ... Device (HRDN) { // ... Device (EPUP) { // ... Method (_RMV, 0, NotSerialized) // _RMV: Removal Status { Return (One) } } } } }Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/pci/hotplug/acpi_pcihp.c +0
-0@@ -422,6 +422,19 @@ static int pcihp_is_ejectable(acpi_handle handle) status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable);if (ACPI_SUCCESS (status) && removable)return 1 ;
drivers/pci/hotplug/acpi_pcihp.c static int pcihp_is_ejectable(acpi_handle handle) · line 434
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+ +/* +* Workaround for Thunderbolt implementation on Acer Aspire S5. +* +* Correct ACPI PCI hotplug imeplementation has _RMV method in a PCI +* slot (device under pci bridge). In Acer Aspire S5 case we have it +* deeper in hierarchy. +*/ + status =acpi_evaluate_integer (handle,"HRDN.EPUP._RMV" ,NULL , + &removable);
Well, calling stuff like this directly from a general function is kind of ugly.
Can we use something like a quirk instead? A DMI check or something?
drivers/pci/hotplug/acpi_pcihp.c static int pcihp_is_ejectable(acpi_handle handle) · line 439
Quoted 5 lines
drivers/pci/hotplug/acpi_pcihp.c +3
-0+if (ACPI_SUCCESS (status) && removable) +return 1 ; +return 0 ; }
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Bjorn Helgaas
maintainerRe: [PATCH v2 6/8] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
In reply to Mika WesterbergQuoted 38 lines · Mika Westerberg
From: "Kirill A. Shutemov" <[email protected]>
Correct ACPI PCI hotplug imeplementation should have
_RMVmethod in a PCI slot (device under pci bridge). In Acer Aspire S5 case we have it deeper in hierarchy:Device (RP05)
{ // ... Device (HRUP) { // ... Device (HRDN) { // ... Device (EPUP) { // ... Method (_RMV, 0, NotSerialized) // _RMV: Removal Status { Return (One) } } } } }Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/pci/hotplug/acpi_pcihp.c +0
-0
drivers/pci/hotplug/acpi_pcihp.c static int pcihp_is_ejectable(acpi_handle handle) · line 431
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +7
-0@@ -422,6 +422,19 @@ static int pcihp_is_ejectable(acpi_handle handle) status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable);if (ACPI_SUCCESS (status) && removable)return 1 ; + +/* +* Workaround for Thunderbolt implementation on Acer Aspire S5. +* +* Correct ACPI PCI hotplug imeplementation has _RMV method in a PCI +* slot (device under pci bridge). In Acer Aspire S5 case we have it +* deeper in hierarchy.
s/imeplementation/implementation/
If you're casting aspersions on Acer for having an incorrect ACPI implementation, you should probably provide a spec reference. I think it's likely that the Acer implementation is actually correct per the spec, but Linux just isn't smart enough to handle it.
Quoted 12 lines
drivers/pci/hotplug/acpi_pcihp.c +6
-1+*/ + status =acpi_evaluate_integer (handle,"HRDN.EPUP._RMV" ,NULL , + &removable); +if (ACPI_SUCCESS (status) && removable) +return 1 ; +return 0 ; } --1.8.3.2
Re: [PATCH v2 6/8] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
Quoted 53 lines · Bjorn Helgaas
Quoted 38 lines · Mika Westerberg
From: "Kirill A. Shutemov" <[email protected]>
Correct ACPI PCI hotplug imeplementation should have
_RMVmethod in a PCI slot (device under pci bridge). In Acer Aspire S5 case we have it deeper in hierarchy:Device (RP05)
{ // ... Device (HRUP) { // ... Device (HRDN) { // ... Device (EPUP) { // ... Method (_RMV, 0, NotSerialized) // _RMV: Removal Status { Return (One) } } } } }Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/pci/hotplug/acpi_pcihp.c +0
-0drivers/pci/hotplug/acpi_pcihp.c static int pcihp_is_ejectable(acpi_handle handle) · line 431
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +7
-0@@ -422,6 +422,19 @@ static int pcihp_is_ejectable(acpi_handle handle) status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable);if (ACPI_SUCCESS (status) && removable)return 1 ; + +/* +* Workaround for Thunderbolt implementation on Acer Aspire S5. +* +* Correct ACPI PCI hotplug imeplementation has _RMV method in a PCI +* slot (device under pci bridge). In Acer Aspire S5 case we have it +* deeper in hierarchy. s/imeplementation/implementation/
Quoted 4 lines
If you're casting aspersions on Acer for having an incorrect ACPI implementation, you should probably provide a spec reference. I think it's likely that the Acer implementation is actually correct per the spec, but Linux just isn't smart enough to handle it.
Agreed.
Quoted 12 lines
Quoted 12 lines
drivers/pci/hotplug/acpi_pcihp.c +6
-1+*/ + status =acpi_evaluate_integer (handle,"HRDN.EPUP._RMV" ,NULL , + &removable); +if (ACPI_SUCCESS (status) && removable) +return 1 ; +return 0 ; } --1.8.3.2
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH v2 6/8] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
In reply to Rafael J. WysockiQuoted 55 lines · Rafael J. Wysocki
Quoted 41 lines · Mika Westerberg
From: "Kirill A. Shutemov" <[email protected]>
Correct ACPI PCI hotplug imeplementation should have
_RMVmethod in a PCI slot (device under pci bridge). In Acer Aspire S5 case we have it deeper in hierarchy:Device (RP05)
{ // ... Device (HRUP) { // ... Device (HRDN) { // ... Device (EPUP) { // ... Method (_RMV, 0, NotSerialized) // _RMV: Removal Status { Return (One) } } } } }Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/pci/hotplug/acpi_pcihp.c +0
-0@@ -422,6 +422,19 @@ static int pcihp_is_ejectable(acpi_handle handle) status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable);if (ACPI_SUCCESS (status) && removable)return 1 ;drivers/pci/hotplug/acpi_pcihp.c static int pcihp_is_ejectable(acpi_handle handle) · line 434
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+ +/* +* Workaround for Thunderbolt implementation on Acer Aspire S5. +* +* Correct ACPI PCI hotplug imeplementation has _RMV method in a PCI +* slot (device under pci bridge). In Acer Aspire S5 case we have it +* deeper in hierarchy. +*/ + status =acpi_evaluate_integer (handle,"HRDN.EPUP._RMV" ,NULL , + &removable);Well, calling stuff like this directly from a general function is kind of ugly.
Quoted 1 line
Can we use something like a quirk instead? A DMI check or something?
Sure we can. How about something like the patch below?
From: Mika Westerberg <[email protected]>
Subject: [PATCH] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
The acpiphp driver finds out whether the device is removable by checking whether it has _RMV method directly behind it (and if it returns 1). However, at least on Acer Aspire S5 with Thunderbolt host router has this method placed behind a device called EPUP (endpoint upstream port?) and not in the usual place expected by the acpiphp driver. The ASL code below shows how this is done on that machine:
Device (RP05)
{
...
Device (HRUP)
{
Name (_ADR, Zero)
Name (_PRW, Package (0x02)
{
0x09,
0x04
})
Device (HRDN)
{
Name (_ADR, 0x00040000)
Name (_PRW, Package (0x02)
{
0x09,
0x04
})
Device (EPUP)
{
Name (_ADR, Zero)
Method (_RMV, 0, NotSerialized)
{
Return (One)
}
}
}
}
...Fix this by adding a DMI quirk for the Acer Aspire S5 machine that gives an alternative path to the _RMV method.
--- drivers/pci/hotplug/acpi_pcihp.c | 57 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-)
drivers/pci/hotplug/acpi_pcihp.c +52 -5
@@ -33,6 +33,7 @@#include <linux/acpi.h> #include <linux/pci-acpi.h> #include <linux/slab.h> +#include <linux/dmi.h> #define MY_NAME "acpi_pcihp"
@@ -408,21 +409,67 @@ got_one: }EXPORT_SYMBOL (acpi_get_hp_hw_control_from_firmware); +/** +* pcihp_is_removable - is the given ACPI device removable +* @handle: ACPI handle of the device +* +* Try to find out whether the given ACPI device is removable by evaluating +* its _RMV and returning the result. If we can't find the _RMV directly +* under the device use system specific quirks to locate it. +*/ +static bool pcihp_is_removable (acpi_handle handle) +{ +static const struct dmi_system_id rmv_paths[] = { + { +/* +* On Acer Aspire S5 the _RMV method for the +* Thunderbolt host router upstream port is not +* located directly under the device but it is +* instead placed a bit deeper in the hierarchy. +*/ + .ident ="Acer Aspire S5" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Acer" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"Aspire S5-391" ), + }, + .driver_data ="HRDN.EPUP._RMV" , + }, + { } + }; +const struct dmi_system_id *id; +unsigned long long removable; +acpi_status status; + + status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable); +if (ACPI_SUCCESS (status)) +return !!removable; + +/* Try system specific quirks */ + id =dmi_first_match (rmv_paths); +if (id && id->driver_data) { +char path[64 ]; + +strlcpy (path, id->driver_data,sizeof (path)); + status =acpi_evaluate_integer (handle, path,NULL , &removable); +if (ACPI_SUCCESS (status)) +return !!removable; + } + +return false; +} +static int pcihp_is_ejectable (acpi_handle handle) {acpi_status status;acpi_handle tmp; -unsigned long long removable; + status =acpi_get_handle (handle,"_ADR" , &tmp);if (ACPI_FAILURE (status))return 0 ; status =acpi_get_handle (handle,"_EJ0" , &tmp);if (ACPI_SUCCESS (status))return 1 ; - status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable); -if (ACPI_SUCCESS (status) && removable) -return 1 ; -return 0 ; +return pcihp_is_removable (handle); }/**
Signature · 1 line
1.8.3.2
Re: [PATCH v2 6/8] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
Quoted 56 lines · Mika Westerberg
Quoted 55 lines · Rafael J. Wysocki
Quoted 41 lines · Mika Westerberg
From: "Kirill A. Shutemov" <[email protected]>
Correct ACPI PCI hotplug imeplementation should have
_RMVmethod in a PCI slot (device under pci bridge). In Acer Aspire S5 case we have it deeper in hierarchy:Device (RP05)
{ // ... Device (HRUP) { // ... Device (HRDN) { // ... Device (EPUP) { // ... Method (_RMV, 0, NotSerialized) // _RMV: Removal Status { Return (One) } } } } }Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/pci/hotplug/acpi_pcihp.c +0
-0@@ -422,6 +422,19 @@ static int pcihp_is_ejectable(acpi_handle handle) status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable);if (ACPI_SUCCESS (status) && removable)return 1 ;drivers/pci/hotplug/acpi_pcihp.c static int pcihp_is_ejectable(acpi_handle handle) · line 434
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+ +/* +* Workaround for Thunderbolt implementation on Acer Aspire S5. +* +* Correct ACPI PCI hotplug imeplementation has _RMV method in a PCI +* slot (device under pci bridge). In Acer Aspire S5 case we have it +* deeper in hierarchy. +*/ + status =acpi_evaluate_integer (handle,"HRDN.EPUP._RMV" ,NULL , + &removable);Well, calling stuff like this directly from a general function is kind of ugly.
Quoted 3 lines
Quoted 1 line
Can we use something like a quirk instead? A DMI check or something?
Sure we can. How about something like the patch below?
Well, it goes into the right (to me) direction. :-)
Some comments below.
Quoted 66 lines
From: Mika Westerberg <[email protected]>
Subject: [PATCH] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5The acpiphp driver finds out whether the device is removable by checking whether it has
_RMVmethod directly behind it (and if it returns 1). However, at least on Acer Aspire S5 with Thunderbolt host router has this method placed behind a device called EPUP (endpoint upstream port?) and not in the usual place expected by the acpiphp driver. The ASL code below shows how this is done on that machine:Device (RP05)
{ ... Device (HRUP) { Name (_ADR, Zero) Name (_PRW, Package (0x02) { 0x09, 0x04 }) Device (HRDN) { Name (_ADR, 0x00040000) Name (_PRW, Package (0x02) { 0x09, 0x04 }) Device (EPUP) { Name (_ADR, Zero) Method (_RMV, 0, NotSerialized) { Return (One) } } } } ...Fix this by adding a DMI quirk for the Acer Aspire S5 machine that gives an alternative path to the
_RMVmethod.Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 57 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-)drivers/pci/hotplug/acpi_pcihp.c +1
-0@@ -33,6 +33,7 @@#include <linux/acpi.h> #include <linux/pci-acpi.h> #include <linux/slab.h> +#include <linux/dmi.h> #define MY_NAME "acpi_pcihp"@@ -408,21 +409,67 @@ got_one: }EXPORT_SYMBOL (acpi_get_hp_hw_control_from_firmware);
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 421
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+/** +* pcihp_is_removable - is the given ACPI device removable +* @handle: ACPI handle of the device +* +* Try to find out whether the given ACPI device is removable by evaluating +* its _RMV and returning the result. If we can't find the _RMV directly +* under the device use system specific quirks to locate it. +*/ +static bool pcihp_is_removable (acpi_handle handle) +{
People are generally used to seeing DMI lists outside of functions.
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c +4
-0+static const struct dmi_system_id rmv_paths[] = { + { +/* +* On Acer Aspire S5 the _RMV method for the
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 435
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+* Thunderbolt host router upstream port is not +* located directly under the device but it is +* instead placed a bit deeper in the hierarchy. +*/ + .ident = "Acer Aspire S5", + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Acer" ), + DMI_MATCH(DMI_PRODUCT_NAME, "Aspire S5-391"), + }, + .driver_data = "HRDN.EPUP._RMV",
Use .callback instead? ->
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c +4
-0+ }, + { } + }; +const struct dmi_system_id *id;
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 449
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+unsigned long long removable; +acpi_status status; + + status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable); +if (ACPI_SUCCESS (status)) +return !!removable; + +/* Try system specific quirks */ + id =dmi_first_match (rmv_paths); +if (id && id->driver_data) {
-> And here do
if (id && id->callback) return id->callback(id);
Quoted 16 lines
drivers/pci/hotplug/acpi_pcihp.c +11
-1+char path[64 ]; + +strlcpy (path, id->driver_data,sizeof (path)); + status =acpi_evaluate_integer (handle, path,NULL , &removable); +if (ACPI_SUCCESS (status)) +return !!removable; + } + +return false; +} +static int pcihp_is_ejectable (acpi_handle handle) {acpi_status status;acpi_handle tmp; -unsigned long long removable;
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 424
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +1
-3+ status =acpi_get_handle (handle,"_ADR" , &tmp);if (ACPI_FAILURE (status))return 0 ; status =acpi_get_handle (handle,"_EJ0" , &tmp);if (ACPI_SUCCESS (status))return 1 ; - status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable); -if (ACPI_SUCCESS (status) && removable) -return 1 ;
I'd keep the above unchanged and simply add a "platform check" function.
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 475
Quoted 5 lines
drivers/pci/hotplug/acpi_pcihp.c +1
-1-return 0 ; +return pcihp_is_removable (handle); }/**
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH v2 6/8] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
Quoted 131 lines · Rafael J. Wysocki
Quoted 56 lines · Mika Westerberg
Quoted 55 lines · Rafael J. Wysocki
Quoted 41 lines · Mika Westerberg
From: "Kirill A. Shutemov" <[email protected]>
Correct ACPI PCI hotplug imeplementation should have
_RMVmethod in a PCI slot (device under pci bridge). In Acer Aspire S5 case we have it deeper in hierarchy:Device (RP05)
{ // ... Device (HRUP) { // ... Device (HRDN) { // ... Device (EPUP) { // ... Method (_RMV, 0, NotSerialized) // _RMV: Removal Status { Return (One) } } } } }Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/pci/hotplug/acpi_pcihp.c +0
-0@@ -422,6 +422,19 @@ static int pcihp_is_ejectable(acpi_handle handle) status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable);if (ACPI_SUCCESS (status) && removable)return 1 ;drivers/pci/hotplug/acpi_pcihp.c static int pcihp_is_ejectable(acpi_handle handle) · line 434
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+ +/* +* Workaround for Thunderbolt implementation on Acer Aspire S5. +* +* Correct ACPI PCI hotplug imeplementation has _RMV method in a PCI +* slot (device under pci bridge). In Acer Aspire S5 case we have it +* deeper in hierarchy. +*/ + status =acpi_evaluate_integer (handle,"HRDN.EPUP._RMV" ,NULL , + &removable);Well, calling stuff like this directly from a general function is kind of ugly.
Quoted 3 lines
Quoted 1 line
Can we use something like a quirk instead? A DMI check or something?
Sure we can. How about something like the patch below?
Well, it goes into the right (to me) direction. :-)
Some comments below.
Quoted 66 lines
From: Mika Westerberg <[email protected]>
Subject: [PATCH] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5The acpiphp driver finds out whether the device is removable by checking whether it has
_RMVmethod directly behind it (and if it returns 1). However, at least on Acer Aspire S5 with Thunderbolt host router has this method placed behind a device called EPUP (endpoint upstream port?) and not in the usual place expected by the acpiphp driver. The ASL code below shows how this is done on that machine:Device (RP05)
{ ... Device (HRUP) { Name (_ADR, Zero) Name (_PRW, Package (0x02) { 0x09, 0x04 }) Device (HRDN) { Name (_ADR, 0x00040000) Name (_PRW, Package (0x02) { 0x09, 0x04 }) Device (EPUP) { Name (_ADR, Zero) Method (_RMV, 0, NotSerialized) { Return (One) } } } } ...Fix this by adding a DMI quirk for the Acer Aspire S5 machine that gives an alternative path to the
_RMVmethod.Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 57 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-)drivers/pci/hotplug/acpi_pcihp.c +1
-0@@ -33,6 +33,7 @@#include <linux/acpi.h> #include <linux/pci-acpi.h> #include <linux/slab.h> +#include <linux/dmi.h> #define MY_NAME "acpi_pcihp"@@ -408,21 +409,67 @@ got_one: }EXPORT_SYMBOL (acpi_get_hp_hw_control_from_firmware);
Quoted 12 lines
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 421
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+/** +* pcihp_is_removable - is the given ACPI device removable +* @handle: ACPI handle of the device +* +* Try to find out whether the given ACPI device is removable by evaluating +* its _RMV and returning the result. If we can't find the _RMV directly +* under the device use system specific quirks to locate it. +*/ +static bool pcihp_is_removable (acpi_handle handle) +{People are generally used to seeing DMI lists outside of functions.
OK.
Quoted 34 lines
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c +4
-0+static const struct dmi_system_id rmv_paths[] = { + { +/* +* On Acer Aspire S5 the _RMV method for the drivers/pci/hotplug/acpi_pcihp.c got_one: · line 435
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+* Thunderbolt host router upstream port is not +* located directly under the device but it is +* instead placed a bit deeper in the hierarchy. +*/ + .ident = "Acer Aspire S5", + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Acer" ), + DMI_MATCH(DMI_PRODUCT_NAME, "Aspire S5-391"), + }, + .driver_data = "HRDN.EPUP._RMV",Use .callback instead? ->
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c +4
-0+ }, + { } + }; +const struct dmi_system_id *id;drivers/pci/hotplug/acpi_pcihp.c got_one: · line 449
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+unsigned long long removable; +acpi_status status; + + status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable); +if (ACPI_SUCCESS (status)) +return !!removable; + +/* Try system specific quirks */ + id =dmi_first_match (rmv_paths); +if (id && id->driver_data) {-> And here do
Quoted 2 lines
if (id && id->callback) return id->callback(id);
There is a problem with the above that we can't pass an ACPI handle to the callback function.
Quoted 21 lines
Quoted 21 lines
drivers/pci/hotplug/acpi_pcihp.c +12
-1+char path[64 ]; + +strlcpy (path, id->driver_data,sizeof (path)); + status =acpi_evaluate_integer (handle, path,NULL , &removable); +if (ACPI_SUCCESS (status)) +return !!removable; + } + +return false; +} +static int pcihp_is_ejectable (acpi_handle handle) {acpi_status status;acpi_handle tmp; -unsigned long long removable; + status =acpi_get_handle (handle,"_ADR" , &tmp);if (ACPI_FAILURE (status))return 0 ;
Quoted 8 lines
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 424
Quoted 6 lines
drivers/pci/hotplug/acpi_pcihp.c +0
-3status =acpi_get_handle (handle,"_EJ0" , &tmp);if (ACPI_SUCCESS (status))return 1 ; - status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable); -if (ACPI_SUCCESS (status) && removable) -return 1 ;I'd keep the above unchanged and simply add a "platform check" function.
OK, thanks.
Re: [PATCH v2 6/8] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
Quoted 181 lines · Mika Westerberg
Quoted 131 lines · Rafael J. Wysocki
Quoted 56 lines · Mika Westerberg
Quoted 55 lines · Rafael J. Wysocki
Quoted 41 lines · Mika Westerberg
From: "Kirill A. Shutemov" <[email protected]>
Correct ACPI PCI hotplug imeplementation should have
_RMVmethod in a PCI slot (device under pci bridge). In Acer Aspire S5 case we have it deeper in hierarchy:Device (RP05)
{ // ... Device (HRUP) { // ... Device (HRDN) { // ... Device (EPUP) { // ... Method (_RMV, 0, NotSerialized) // _RMV: Removal Status { Return (One) } } } } }Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/pci/hotplug/acpi_pcihp.c +0
-0@@ -422,6 +422,19 @@ static int pcihp_is_ejectable(acpi_handle handle) status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable);if (ACPI_SUCCESS (status) && removable)return 1 ;drivers/pci/hotplug/acpi_pcihp.c static int pcihp_is_ejectable(acpi_handle handle) · line 434
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+ +/* +* Workaround for Thunderbolt implementation on Acer Aspire S5. +* +* Correct ACPI PCI hotplug imeplementation has _RMV method in a PCI +* slot (device under pci bridge). In Acer Aspire S5 case we have it +* deeper in hierarchy. +*/ + status =acpi_evaluate_integer (handle,"HRDN.EPUP._RMV" ,NULL , + &removable);Well, calling stuff like this directly from a general function is kind of ugly.
Quoted 3 lines
Quoted 1 line
Can we use something like a quirk instead? A DMI check or something?
Sure we can. How about something like the patch below?
Well, it goes into the right (to me) direction. :-)
Some comments below.
Quoted 66 lines
From: Mika Westerberg <[email protected]>
Subject: [PATCH] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5The acpiphp driver finds out whether the device is removable by checking whether it has
_RMVmethod directly behind it (and if it returns 1). However, at least on Acer Aspire S5 with Thunderbolt host router has this method placed behind a device called EPUP (endpoint upstream port?) and not in the usual place expected by the acpiphp driver. The ASL code below shows how this is done on that machine:Device (RP05)
{ ... Device (HRUP) { Name (_ADR, Zero) Name (_PRW, Package (0x02) { 0x09, 0x04 }) Device (HRDN) { Name (_ADR, 0x00040000) Name (_PRW, Package (0x02) { 0x09, 0x04 }) Device (EPUP) { Name (_ADR, Zero) Method (_RMV, 0, NotSerialized) { Return (One) } } } } ...Fix this by adding a DMI quirk for the Acer Aspire S5 machine that gives an alternative path to the
_RMVmethod.Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 57 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-)drivers/pci/hotplug/acpi_pcihp.c +1
-0@@ -33,6 +33,7 @@#include <linux/acpi.h> #include <linux/pci-acpi.h> #include <linux/slab.h> +#include <linux/dmi.h> #define MY_NAME "acpi_pcihp"@@ -408,21 +409,67 @@ got_one: }EXPORT_SYMBOL (acpi_get_hp_hw_control_from_firmware);Quoted 12 lines
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 421
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+/** +* pcihp_is_removable - is the given ACPI device removable +* @handle: ACPI handle of the device +* +* Try to find out whether the given ACPI device is removable by evaluating +* its _RMV and returning the result. If we can't find the _RMV directly +* under the device use system specific quirks to locate it. +*/ +static bool pcihp_is_removable (acpi_handle handle) +{People are generally used to seeing DMI lists outside of functions.
OK.
Quoted 34 lines
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c +4
-0+static const struct dmi_system_id rmv_paths[] = { + { +/* +* On Acer Aspire S5 the _RMV method for the drivers/pci/hotplug/acpi_pcihp.c got_one: · line 435
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+* Thunderbolt host router upstream port is not +* located directly under the device but it is +* instead placed a bit deeper in the hierarchy. +*/ + .ident = "Acer Aspire S5", + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Acer" ), + DMI_MATCH(DMI_PRODUCT_NAME, "Aspire S5-391"), + }, + .driver_data = "HRDN.EPUP._RMV",Use .callback instead? ->
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c +4
-0+ }, + { } + }; +const struct dmi_system_id *id;drivers/pci/hotplug/acpi_pcihp.c got_one: · line 449
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+unsigned long long removable; +acpi_status status; + + status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable); +if (ACPI_SUCCESS (status)) +return !!removable; + +/* Try system specific quirks */ + id =dmi_first_match (rmv_paths); +if (id && id->driver_data) {-> And here do
Quoted 5 lines
Quoted 2 lines
if (id && id->callback) return id->callback(id);There is a problem with the above that we can't pass an ACPI handle to the callback function.
Ah, right.
Well, you can do
if (id && id->driver_data) {
bool (*callback)(acpi_handle) = id->driver_data;
return callback(handle);
}although it's a bit hackish.
Quoted 4 lines
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 452
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c +3
-0+char path[64 ]; + +strlcpy (path, id->driver_data,sizeof (path));
BTW, why didn't you want to pass id->driver_data directly here?
Quoted 8 lines
Quoted 8 lines
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 460
Quoted 8 lines
drivers/pci/hotplug/acpi_pcihp.c +8
-0+ status =acpi_evaluate_integer (handle, path,NULL , &removable); +if (ACPI_SUCCESS (status)) +return !!removable; + } + +return false; +} +
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH v2 6/8] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
Quoted 192 lines · Rafael J. Wysocki
Quoted 181 lines · Mika Westerberg
Quoted 131 lines · Rafael J. Wysocki
Quoted 56 lines · Mika Westerberg
Quoted 55 lines · Rafael J. Wysocki
Quoted 41 lines · Mika Westerberg
From: "Kirill A. Shutemov" <[email protected]>
Correct ACPI PCI hotplug imeplementation should have
_RMVmethod in a PCI slot (device under pci bridge). In Acer Aspire S5 case we have it deeper in hierarchy:Device (RP05)
{ // ... Device (HRUP) { // ... Device (HRDN) { // ... Device (EPUP) { // ... Method (_RMV, 0, NotSerialized) // _RMV: Removal Status { Return (One) } } } } }Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/pci/hotplug/acpi_pcihp.c +0
-0@@ -422,6 +422,19 @@ static int pcihp_is_ejectable(acpi_handle handle) status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable);if (ACPI_SUCCESS (status) && removable)return 1 ;drivers/pci/hotplug/acpi_pcihp.c static int pcihp_is_ejectable(acpi_handle handle) · line 434
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+ +/* +* Workaround for Thunderbolt implementation on Acer Aspire S5. +* +* Correct ACPI PCI hotplug imeplementation has _RMV method in a PCI +* slot (device under pci bridge). In Acer Aspire S5 case we have it +* deeper in hierarchy. +*/ + status =acpi_evaluate_integer (handle,"HRDN.EPUP._RMV" ,NULL , + &removable);Well, calling stuff like this directly from a general function is kind of ugly.
Quoted 3 lines
Quoted 1 line
Can we use something like a quirk instead? A DMI check or something?
Sure we can. How about something like the patch below?
Well, it goes into the right (to me) direction. :-)
Some comments below.
Quoted 66 lines
From: Mika Westerberg <[email protected]>
Subject: [PATCH] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5The acpiphp driver finds out whether the device is removable by checking whether it has
_RMVmethod directly behind it (and if it returns 1). However, at least on Acer Aspire S5 with Thunderbolt host router has this method placed behind a device called EPUP (endpoint upstream port?) and not in the usual place expected by the acpiphp driver. The ASL code below shows how this is done on that machine:Device (RP05)
{ ... Device (HRUP) { Name (_ADR, Zero) Name (_PRW, Package (0x02) { 0x09, 0x04 }) Device (HRDN) { Name (_ADR, 0x00040000) Name (_PRW, Package (0x02) { 0x09, 0x04 }) Device (EPUP) { Name (_ADR, Zero) Method (_RMV, 0, NotSerialized) { Return (One) } } } } ...Fix this by adding a DMI quirk for the Acer Aspire S5 machine that gives an alternative path to the
_RMVmethod.Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 57 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-)drivers/pci/hotplug/acpi_pcihp.c +1
-0@@ -33,6 +33,7 @@#include <linux/acpi.h> #include <linux/pci-acpi.h> #include <linux/slab.h> +#include <linux/dmi.h> #define MY_NAME "acpi_pcihp"@@ -408,21 +409,67 @@ got_one: }EXPORT_SYMBOL (acpi_get_hp_hw_control_from_firmware);Quoted 12 lines
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 421
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+/** +* pcihp_is_removable - is the given ACPI device removable +* @handle: ACPI handle of the device +* +* Try to find out whether the given ACPI device is removable by evaluating +* its _RMV and returning the result. If we can't find the _RMV directly +* under the device use system specific quirks to locate it. +*/ +static bool pcihp_is_removable (acpi_handle handle) +{People are generally used to seeing DMI lists outside of functions.
OK.
Quoted 34 lines
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c +4
-0+static const struct dmi_system_id rmv_paths[] = { + { +/* +* On Acer Aspire S5 the _RMV method for the drivers/pci/hotplug/acpi_pcihp.c got_one: · line 435
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+* Thunderbolt host router upstream port is not +* located directly under the device but it is +* instead placed a bit deeper in the hierarchy. +*/ + .ident = "Acer Aspire S5", + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Acer" ), + DMI_MATCH(DMI_PRODUCT_NAME, "Aspire S5-391"), + }, + .driver_data = "HRDN.EPUP._RMV",Use .callback instead? ->
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c +4
-0+ }, + { } + }; +const struct dmi_system_id *id;drivers/pci/hotplug/acpi_pcihp.c got_one: · line 449
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+unsigned long long removable; +acpi_status status; + + status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable); +if (ACPI_SUCCESS (status)) +return !!removable; + +/* Try system specific quirks */ + id =dmi_first_match (rmv_paths); +if (id && id->driver_data) {-> And here do
Quoted 5 lines
Quoted 2 lines
if (id && id->callback) return id->callback(id);There is a problem with the above that we can't pass an ACPI handle to the callback function.
Ah, right.
Well, you can do
Quoted 7 lines
if (id && id->driver_data) { bool (*callback)(acpi_handle) = id->driver_data; return callback(handle); }although it's a bit hackish.
I'm thinking that passing just the path from driver_data might be simpler in this case ;-) But I'm fine with changing it to be a callback as well.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 452
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c +3
-0+char path[64 ]; + +strlcpy (path, id->driver_data,sizeof (path));BTW, why didn't you want to pass
id->driver_datadirectly here?
acpi_evaluate_integer() takes acpi_string as parameter which is 'char *', not 'const char *'.
Doing:
.driver_data = "HRDN.EPUP._RMV",
might place that string to a read-only area (as it is constant), if I understand C correctly. So even though I know that acpi_evaluate_interger() doesn't change the parameter, there's no guarantee that it doesn't do that in the future.
Quoted 17 lines
Quoted 9 lines
Quoted 9 lines
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 460
Quoted 9 lines
drivers/pci/hotplug/acpi_pcihp.c +8
-0+ status =acpi_evaluate_integer (handle, path,NULL , &removable); +if (ACPI_SUCCESS (status)) +return !!removable; + } + +return false; +} +Thanks,
RafaelSignature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH v2 6/8] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
Quoted 196 lines · Mika Westerberg
Quoted 195 lines · Rafael J. Wysocki
Quoted 181 lines · Mika Westerberg
Quoted 131 lines · Rafael J. Wysocki
Quoted 56 lines · Mika Westerberg
Quoted 55 lines · Rafael J. Wysocki
Quoted 41 lines · Mika Westerberg
From: "Kirill A. Shutemov" <[email protected]>
Correct ACPI PCI hotplug imeplementation should have
_RMVmethod in a PCI slot (device under pci bridge). In Acer Aspire S5 case we have it deeper in hierarchy:Device (RP05)
{ // ... Device (HRUP) { // ... Device (HRDN) { // ... Device (EPUP) { // ... Method (_RMV, 0, NotSerialized) // _RMV: Removal Status { Return (One) } } } } }Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/pci/hotplug/acpi_pcihp.c +0
-0@@ -422,6 +422,19 @@ static int pcihp_is_ejectable(acpi_handle handle) status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable);if (ACPI_SUCCESS (status) && removable)return 1 ;drivers/pci/hotplug/acpi_pcihp.c static int pcihp_is_ejectable(acpi_handle handle) · line 434
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+ +/* +* Workaround for Thunderbolt implementation on Acer Aspire S5. +* +* Correct ACPI PCI hotplug imeplementation has _RMV method in a PCI +* slot (device under pci bridge). In Acer Aspire S5 case we have it +* deeper in hierarchy. +*/ + status =acpi_evaluate_integer (handle,"HRDN.EPUP._RMV" ,NULL , + &removable);Well, calling stuff like this directly from a general function is kind of ugly.
Quoted 3 lines
Quoted 1 line
Can we use something like a quirk instead? A DMI check or something?
Sure we can. How about something like the patch below?
Well, it goes into the right (to me) direction. :-)
Some comments below.
Quoted 66 lines
From: Mika Westerberg <[email protected]>
Subject: [PATCH] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5The acpiphp driver finds out whether the device is removable by checking whether it has
_RMVmethod directly behind it (and if it returns 1). However, at least on Acer Aspire S5 with Thunderbolt host router has this method placed behind a device called EPUP (endpoint upstream port?) and not in the usual place expected by the acpiphp driver. The ASL code below shows how this is done on that machine:Device (RP05)
{ ... Device (HRUP) { Name (_ADR, Zero) Name (_PRW, Package (0x02) { 0x09, 0x04 }) Device (HRDN) { Name (_ADR, 0x00040000) Name (_PRW, Package (0x02) { 0x09, 0x04 }) Device (EPUP) { Name (_ADR, Zero) Method (_RMV, 0, NotSerialized) { Return (One) } } } } ...Fix this by adding a DMI quirk for the Acer Aspire S5 machine that gives an alternative path to the
_RMVmethod.Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 57 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-)drivers/pci/hotplug/acpi_pcihp.c +1
-0@@ -33,6 +33,7 @@#include <linux/acpi.h> #include <linux/pci-acpi.h> #include <linux/slab.h> +#include <linux/dmi.h> #define MY_NAME "acpi_pcihp"@@ -408,21 +409,67 @@ got_one: }EXPORT_SYMBOL (acpi_get_hp_hw_control_from_firmware);Quoted 12 lines
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 421
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+/** +* pcihp_is_removable - is the given ACPI device removable +* @handle: ACPI handle of the device +* +* Try to find out whether the given ACPI device is removable by evaluating +* its _RMV and returning the result. If we can't find the _RMV directly +* under the device use system specific quirks to locate it. +*/ +static bool pcihp_is_removable (acpi_handle handle) +{People are generally used to seeing DMI lists outside of functions.
OK.
Quoted 34 lines
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c +4
-0+static const struct dmi_system_id rmv_paths[] = { + { +/* +* On Acer Aspire S5 the _RMV method for the drivers/pci/hotplug/acpi_pcihp.c got_one: · line 435
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+* Thunderbolt host router upstream port is not +* located directly under the device but it is +* instead placed a bit deeper in the hierarchy. +*/ + .ident = "Acer Aspire S5", + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Acer" ), + DMI_MATCH(DMI_PRODUCT_NAME, "Aspire S5-391"), + }, + .driver_data = "HRDN.EPUP._RMV",Use .callback instead? ->
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c +4
-0+ }, + { } + }; +const struct dmi_system_id *id;drivers/pci/hotplug/acpi_pcihp.c got_one: · line 449
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+unsigned long long removable; +acpi_status status; + + status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable); +if (ACPI_SUCCESS (status)) +return !!removable; + +/* Try system specific quirks */ + id =dmi_first_match (rmv_paths); +if (id && id->driver_data) {-> And here do
Quoted 5 lines
Quoted 2 lines
if (id && id->callback) return id->callback(id);There is a problem with the above that we can't pass an ACPI handle to the callback function.
Ah, right.
Well, you can do
if (id && id->driver_data) { bool (*callback)(acpi_handle) = id->driver_data;
Quoted 7 lines
Quoted 4 lines
return callback(handle); }although it's a bit hackish.
I'm thinking that passing just the path from
driver_datamight be simpler in this case ;-) But I'm fine with changing it to be a callback as well.
No, it probably isn't worth the effort for just one system.
Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 452
Quoted 4 lines
drivers/pci/hotplug/acpi_pcihp.c +3
-0+char path[64 ]; + +strlcpy (path, id->driver_data,sizeof (path));BTW, why didn't you want to pass
id->driver_datadirectly here?
acpi_evaluate_integer()takesacpi_stringas parameter which is 'char *', not 'const char *'.
Quoted 8 lines
Doing:
.driver_data = "HRDN.EPUP._RMV",might place that string to a read-only area (as it is constant), if I understand C correctly. So even though I know that
acpi_evaluate_interger()doesn't change the parameter, there's no guarantee that it doesn't do that in the future.
I think you can safely assume that acpi_evaluate_integer() won't try to modify path (there are too many places where string literals are passed to it).
IOW, please just pass id->driver_data to it.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c got_one: · line 460
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +8
-0+ status =acpi_evaluate_integer (handle, path,NULL , &removable); +if (ACPI_SUCCESS (status)) +return !!removable; + } + +return false; +} +
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
PATCH v2 6/8 PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
The acpiphp driver finds out whether the device is removable by checking whether it has _RMV method directly behind it (and if it returns 1). However, at least on Acer Aspire S5 with Thunderbolt host router has this method placed behind a device called EPUP (endpoint upstream port?) and not in the usual place expected by the acpiphp driver. The ASL code below shows how this is done on that machine:
Device (RP05)
{
...
Device (HRUP)
{
Name (_ADR, Zero)
Name (_PRW, Package (0x02)
{
0x09,
0x04
})
Device (HRDN)
{
Name (_ADR, 0x00040000)
Name (_PRW, Package (0x02)
{
0x09,
0x04
})
Device (EPUP)
{
Name (_ADR, Zero)
Method (_RMV, 0, NotSerialized)
{
Return (One)
}
}
}
}
...Fix this by adding a DMI quirk for the Acer Aspire S5 machine that gives an alternative path to the _RMV method.
--- drivers/pci/hotplug/acpi_pcihp.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
drivers/pci/hotplug/acpi_pcihp.c +34 -0
@@ -33,6 +33,7 @@#include <linux/acpi.h> #include <linux/pci-acpi.h> #include <linux/slab.h> +#include <linux/dmi.h> #define MY_NAME "acpi_pcihp"
@@ -408,11 +409,31 @@ got_one: }EXPORT_SYMBOL (acpi_get_hp_hw_control_from_firmware); +static const struct dmi_system_id pcihp_platform_quirks[] = { + { +/* +* On Acer Aspire S5 the _RMV method for the +* Thunderbolt host router upstream port is not +* located directly under the device but it is +* instead placed a bit deeper in the hierarchy. +*/ + .ident ="Acer Aspire S5" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Acer" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"Aspire S5-391" ), + }, + .driver_data ="HRDN.EPUP._RMV" , + }, + { } +}; +static int pcihp_is_ejectable (acpi_handle handle) {acpi_status status;acpi_handle tmp;unsigned long long removable; +const struct dmi_system_id *id; + status =acpi_get_handle (handle,"_ADR" , &tmp);if (ACPI_FAILURE (status))return 0 ;
@@ -422,6 +443,19 @@ static int pcihp_is_ejectable(acpi_handle handle) status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable);if (ACPI_SUCCESS (status) && removable)return 1 ; + +/* +* Try to look if there is a platform specific method that we can +* use to determine if the device is removable or not. +*/ + id =dmi_first_match (pcihp_platform_quirks); +if (id && id->driver_data) { + status =acpi_evaluate_integer (handle, id->driver_data,NULL , + &removable); +if (ACPI_SUCCESS (status) && removable) +return 1 ; + } +return 0 ; }
Signature · 1 line
1.8.3.2
Re: [PATCH v2.1 6/8] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
Quoted 38 lines · Mika Westerberg
The acpiphp driver finds out whether the device is removable by checking whether it has
_RMVmethod directly behind it (and if it returns 1). However, at least on Acer Aspire S5 with Thunderbolt host router has this method placed behind a device called EPUP (endpoint upstream port?) and not in the usual place expected by the acpiphp driver. The ASL code below shows how this is done on that machine:Device (RP05)
{ ... Device (HRUP) { Name (_ADR, Zero) Name (_PRW, Package (0x02) { 0x09, 0x04 }) Device (HRDN) { Name (_ADR, 0x00040000) Name (_PRW, Package (0x02) { 0x09, 0x04 }) Device (EPUP) { Name (_ADR, Zero) Method (_RMV, 0, NotSerialized) { Return (One) } } } } ...
Quoted 5 lines
Fix this by adding a DMI quirk for the Acer Aspire S5 machine that gives an alternative path to the
_RMVmethod.Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>
This is fine by me and same for the other patches in the series.
Quoted 69 lines
--- drivers/pci/hotplug/acpi_pcihp.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)drivers/pci/hotplug/acpi_pcihp.c +34
-0@@ -33,6 +33,7 @@#include <linux/acpi.h> #include <linux/pci-acpi.h> #include <linux/slab.h> +#include <linux/dmi.h> #define MY_NAME "acpi_pcihp"@@ -408,11 +409,31 @@ got_one: }EXPORT_SYMBOL (acpi_get_hp_hw_control_from_firmware); +static const struct dmi_system_id pcihp_platform_quirks[] = { + { +/* +* On Acer Aspire S5 the _RMV method for the +* Thunderbolt host router upstream port is not +* located directly under the device but it is +* instead placed a bit deeper in the hierarchy. +*/ + .ident ="Acer Aspire S5" , + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Acer" ), +DMI_MATCH (DMI_PRODUCT_NAME ,"Aspire S5-391" ), + }, + .driver_data ="HRDN.EPUP._RMV" , + }, + { } +}; +static int pcihp_is_ejectable (acpi_handle handle) {acpi_status status;acpi_handle tmp;unsigned long long removable; +const struct dmi_system_id *id; + status =acpi_get_handle (handle,"_ADR" , &tmp);if (ACPI_FAILURE (status))return 0 ;@@ -422,6 +443,19 @@ static int pcihp_is_ejectable(acpi_handle handle) status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable);if (ACPI_SUCCESS (status) && removable)return 1 ; + +/* +* Try to look if there is a platform specific method that we can +* use to determine if the device is removable or not. +*/ + id =dmi_first_match (pcihp_platform_quirks); +if (id && id->driver_data) { + status =acpi_evaluate_integer (handle, id->driver_data,NULL , + &removable); +if (ACPI_SUCCESS (status) && removable) +return 1 ; + } +return 0 ; }
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH v2.1 6/8] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
Quoted 3 lines · Rafael J. Wysocki
This is fine by me and same for the other patches in the series.
Thanks!
Re: [PATCH v2 3/8] PCI: acpiphp: enable_device(): rescan even if no new devices on slot
In reply to Mika WesterbergQuoted 6 lines · Mika Westerberg
From: "Kirill A. Shutemov" <[email protected]>
pci_scan_slot()returns number of new devices connected *directly* connected to the slot. Currentenable_device()checks the return value and stops if it doesn't see a new device.
Quoted 7 lines
In Thunderbolt chaining case the new device can be deeper in hierarchy, so do the rescan anyway.
Because of that we must make sure that
pcibios_resource_survey_bus()andcheck_hotplug_bridge()get called only for a just found bus and not the ones already added to the system. Failure to do so will lead to resource conflicts.
Well, I wonder what we're doing to this end, because there's nothing in that area in the patch?
Quoted 40 lines
Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpiphp_glue.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)drivers/pci/hotplug/acpiphp_glue.c +2
-9@@ -685,18 +685,13 @@ static int __ref enable_device(struct acpiphp_slot *slot)struct pci_dev *dev;struct pci_bus *bus = slot->bridge->pci_bus;struct acpiphp_func *func; -int num, max, pass; +int max, pass;LIST_HEAD (add_list);list_for_each_entry (func, &slot->funcs, sibling)acpiphp_bus_add (func); - num =pci_scan_slot (bus,PCI_DEVFN (slot->device,0 )); -if (num ==0 ) { -/* Maybe only part of funcs are added. */ -dbg ("No new device found\n" ); - goto err_exit; - } +pci_scan_slot (bus,PCI_DEVFN (slot->device,0 )); max =acpiphp_max_busnr (bus);for (pass =0 ; pass <2 ; pass++) {@@ -742,8 +737,6 @@ static int __ref enable_device(struct acpiphp_slot *slot) } } - - err_exit:return 0 ; }
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH v2 3/8] PCI: acpiphp: enable_device(): rescan even if no new devices on slot
Quoted 10 lines · Rafael J. Wysocki
Quoted 9 lines · Mika Westerberg
From: "Kirill A. Shutemov" <[email protected]>
pci_scan_slot()returns number of new devices connected *directly* connected to the slot. Currentenable_device()checks the return value and stops if it doesn't see a new device.In Thunderbolt chaining case the new device can be deeper in hierarchy, so do the rescan anyway.
Quoted 7 lines
Quoted 4 lines
Because of that we must make sure that
pcibios_resource_survey_bus()andcheck_hotplug_bridge()get called only for a just found bus and not the ones already added to the system. Failure to do so will lead to resource conflicts.Well, I wonder what we're doing to this end, because there's nothing in that area in the patch?
We forgot to update the changelog of this patch. The last paragraph should not be there.
Re: [PATCH v2 3/8] PCI: acpiphp: enable_device(): rescan even if no new devices on slot
Quoted 16 lines · Mika Westerberg
Quoted 15 lines · Rafael J. Wysocki
Quoted 13 lines · Mika Westerberg
From: "Kirill A. Shutemov" <[email protected]>
pci_scan_slot()returns number of new devices connected *directly* connected to the slot. Currentenable_device()checks the return value and stops if it doesn't see a new device.In Thunderbolt chaining case the new device can be deeper in hierarchy, so do the rescan anyway.
Because of that we must make sure that
pcibios_resource_survey_bus()andcheck_hotplug_bridge()get called only for a just found bus and not the ones already added to the system. Failure to do so will lead to resource conflicts.
Quoted 5 lines
Quoted 2 lines
Well, I wonder what we're doing to this end, because there's nothing in that area in the patch?
We forgot to update the changelog of this patch. The last paragraph should not be there.
Yeah, I noticed that later. Never mind. :-)
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH v2 6/8] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
In reply to Rafael J. WysockiQuoted 55 lines · Rafael J. Wysocki
Quoted 41 lines · Mika Westerberg
From: "Kirill A. Shutemov" <[email protected]>
Correct ACPI PCI hotplug imeplementation should have
_RMVmethod in a PCI slot (device under pci bridge). In Acer Aspire S5 case we have it deeper in hierarchy:Device (RP05)
{ // ... Device (HRUP) { // ... Device (HRDN) { // ... Device (EPUP) { // ... Method (_RMV, 0, NotSerialized) // _RMV: Removal Status { Return (One) } } } } }Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/pci/hotplug/acpi_pcihp.c +0
-0@@ -422,6 +422,19 @@ static int pcihp_is_ejectable(acpi_handle handle) status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable);if (ACPI_SUCCESS (status) && removable)return 1 ;drivers/pci/hotplug/acpi_pcihp.c static int pcihp_is_ejectable(acpi_handle handle) · line 434
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+ +/* +* Workaround for Thunderbolt implementation on Acer Aspire S5. +* +* Correct ACPI PCI hotplug imeplementation has _RMV method in a PCI +* slot (device under pci bridge). In Acer Aspire S5 case we have it +* deeper in hierarchy. +*/ + status =acpi_evaluate_integer (handle,"HRDN.EPUP._RMV" ,NULL , + &removable);Well, calling stuff like this directly from a general function is kind of ugly.
Quoted 1 line
Can we use something like a quirk instead? A DMI check or something?
Presumably this device functions under Windows so clearly Windows is capable of dealing with this case, so we should too.
There are way too many of these silly DMI checks in the kernel - we should be way more hesitant to add more of them. They're almost guaranteed to be incomplete. I would say they should be avoided whenever possible unless there's some reason why a general workaround can't be used.
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c static int pcihp_is_ejectable(acpi_handle handle) · line 439
Quoted 6 lines
drivers/pci/hotplug/acpi_pcihp.c +3
-0+if (ACPI_SUCCESS (status) && removable) +return 1 ; +return 0 ; }Rafael
Re: [PATCH v2 6/8] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5
Quoted 58 lines · Robert Hancock
Quoted 55 lines · Rafael J. Wysocki
Quoted 41 lines · Mika Westerberg
From: "Kirill A. Shutemov" <[email protected]>
Correct ACPI PCI hotplug imeplementation should have
_RMVmethod in a PCI slot (device under pci bridge). In Acer Aspire S5 case we have it deeper in hierarchy:Device (RP05)
{ // ... Device (HRUP) { // ... Device (HRDN) { // ... Device (EPUP) { // ... Method (_RMV, 0, NotSerialized) // _RMV: Removal Status { Return (One) } } } } }Signed-off-by Kirill A. Shutemov <[email protected]>Signed-off-by Mika Westerberg <[email protected]>--- drivers/pci/hotplug/acpi_pcihp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)drivers/pci/hotplug/acpi_pcihp.c +0
-0@@ -422,6 +422,19 @@ static int pcihp_is_ejectable(acpi_handle handle) status =acpi_evaluate_integer (handle,"_RMV" ,NULL , &removable);if (ACPI_SUCCESS (status) && removable)return 1 ;drivers/pci/hotplug/acpi_pcihp.c static int pcihp_is_ejectable(acpi_handle handle) · line 434
Quoted 10 lines
drivers/pci/hotplug/acpi_pcihp.c +10
-0+ +/* +* Workaround for Thunderbolt implementation on Acer Aspire S5. +* +* Correct ACPI PCI hotplug imeplementation has _RMV method in a PCI +* slot (device under pci bridge). In Acer Aspire S5 case we have it +* deeper in hierarchy. +*/ + status =acpi_evaluate_integer (handle,"HRDN.EPUP._RMV" ,NULL , + &removable);Well, calling stuff like this directly from a general function is kind of ugly.
Quoted 1 line
Can we use something like a quirk instead? A DMI check or something?
Quoted 7 lines
Presumably this device functions under Windows so clearly Windows is capable of dealing with this case, so we should too.
There are way too many of these silly DMI checks in the kernel - we should be way more hesitant to add more of them. They're almost guaranteed to be incomplete. I would say they should be avoided whenever possible unless there's some reason why a general workaround can't be used.
This horse is already dead. :-)
Please check the series I posted the day before yesterday.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Bjorn Helgaas
maintainerRe: [PATCH v2 1/8] x86/PCI: prevent re-allocation of already existing bridge and ROM resources
In reply to Mika WesterbergQuoted 7 lines · Mika Westerberg
In hotplug case (especially with Thunderbolt enabled systems) we might need to call
pcibios_resource_survey_bus()several times for a bus. The function ends up callingpci_claim_resource()for each bridge resource that then fails claiming that the resource exists already (which it does). Once this happens the resource is invalidated thus preventing devices behind the bridge to allocate their resources.
Quoted 6 lines
To fix this we do what has been done in
pcibios_allocate_dev_resources()and check 'parent' of the given resource. If it is non-NULL it means that the resource has been allocated already and we can skip it. We do the same for ROM resources as well.Signed-off-by Mika Westerberg <[email protected]>
This looks reasonable to me.
However, the use of "r->parent" to determine whether the resource is already allocated is nothing specific to x86. So I think we might be missing an opportunity to make this more consistent across architectures. I looked at other callers of pci_claim_resource() for bridge and ROM resources, and it looks like we might be able to make similar changes in:
frv pcibios_allocate_bus_resources()
ia64 pcibios_fixup_resources() (via pcibios_fixup_bridge_resources()) mn10300 pcibios_allocate_bus_resources()
mn10300 pcibios_assign_resources() (ROM)
mn10300 pcibios_fixup_device_resources()
parisc lba_fixup_bus()
I really hate the idea of fixing something for x86 but not for other arches, so maybe somebody could take a deeper look at this and see if it would make sense to change the other arches, too.
Bjorn
Quoted 29 lines
--- arch/x86/pci/i386.c | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/pci/i386.c +4
-1@@ -210,6 +210,8 @@ static void pcibios_allocate_bridge_resources(struct pci_dev *dev) r = &dev->resource[idx];if (!r->flags)continue ; +if (r->parent)/* Already allocated */ +continue ;if (!r->start ||pci_claim_resource (dev, idx) <0 ) {/* * Something is wrong with the region. @@ -318,6 +320,8 @@ static void pcibios_allocate_dev_rom_resource(struct pci_dev *dev) r = &dev->resource[PCI_ROM_RESOURCE ];if (!r->flags || !r->start)return ; +if (r->parent)/* Already allocated */ +return ;if (pci_claim_resource (dev,PCI_ROM_RESOURCE ) <0 ) { r->end -= r->start; --1.8.3.2
Re: [PATCH v2 1/8] x86/PCI: prevent re-allocation of already existing bridge and ROM resources
Quoted 9 lines · Bjorn Helgaas
Quoted 7 lines · Mika Westerberg
In hotplug case (especially with Thunderbolt enabled systems) we might need to call
pcibios_resource_survey_bus()several times for a bus. The function ends up callingpci_claim_resource()for each bridge resource that then fails claiming that the resource exists already (which it does). Once this happens the resource is invalidated thus preventing devices behind the bridge to allocate their resources.
Quoted 8 lines
Quoted 6 lines
To fix this we do what has been done in
pcibios_allocate_dev_resources()and check 'parent' of the given resource. If it is non-NULL it means that the resource has been allocated already and we can skip it. We do the same for ROM resources as well.Signed-off-by Mika Westerberg <[email protected]>This looks reasonable to me.
Quoted 49 lines
However, the use of "
r->parent" to determine whether the resource is already allocated is nothing specific to x86. So I think we might be missing an opportunity to make this more consistent across architectures. I looked at other callers ofpci_claim_resource()for bridge and ROM resources, and it looks like we might be able to make similar changes in:frv
pcibios_allocate_bus_resources()
ia64pcibios_fixup_resources()(viapcibios_fixup_bridge_resources()) mn10300pcibios_allocate_bus_resources()
mn10300pcibios_assign_resources()(ROM)
mn10300pcibios_fixup_device_resources()
parisclba_fixup_bus()I really hate the idea of fixing something for x86 but not for other arches, so maybe somebody could take a deeper look at this and see if it would make sense to change the other arches, too.
Bjorn
Quoted 29 lines
--- arch/x86/pci/i386.c | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/pci/i386.c +4
-1@@ -210,6 +210,8 @@ static void pcibios_allocate_bridge_resources(struct pci_dev *dev) r = &dev->resource[idx];if (!r->flags)continue ; +if (r->parent)/* Already allocated */ +continue ;if (!r->start ||pci_claim_resource (dev, idx) <0 ) {/* * Something is wrong with the region. @@ -318,6 +320,8 @@ static void pcibios_allocate_dev_rom_resource(struct pci_dev *dev) r = &dev->resource[PCI_ROM_RESOURCE ];if (!r->flags || !r->start)return ; +if (r->parent)/* Already allocated */ +return ;if (pci_claim_resource (dev,PCI_ROM_RESOURCE ) <0 ) { r->end -= r->start; --1.8.3.2
Bjorn Helgaas
maintainerRe: [PATCH v2 1/8] x86/PCI: prevent re-allocation of already existing bridge and ROM resources
Quoted 15 lines · Bjorn Helgaas
Quoted 14 lines · Bjorn Helgaas
Quoted 12 lines · Mika Westerberg
In hotplug case (especially with Thunderbolt enabled systems) we might need to call
pcibios_resource_survey_bus()several times for a bus. The function ends up callingpci_claim_resource()for each bridge resource that then fails claiming that the resource exists already (which it does). Once this happens the resource is invalidated thus preventing devices behind the bridge to allocate their resources.To fix this we do what has been done in
pcibios_allocate_dev_resources()and check 'parent' of the given resource. If it is non-NULL it means that the resource has been allocated already and we can skip it. We do the same for ROM resources as well.
Quoted 23 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Mika Westerberg <[email protected]>This looks reasonable to me.
Acked-by Bjorn Helgaas <[email protected]>Quoted 17 lines
However, the use of "
r->parent" to determine whether the resource is already allocated is nothing specific to x86. So I think we might be missing an opportunity to make this more consistent across architectures. I looked at other callers ofpci_claim_resource()for bridge and ROM resources, and it looks like we might be able to make similar changes in:frv
pcibios_allocate_bus_resources()
ia64pcibios_fixup_resources()(viapcibios_fixup_bridge_resources()) mn10300pcibios_allocate_bus_resources()
mn10300pcibios_assign_resources()(ROM)
mn10300pcibios_fixup_device_resources()
parisclba_fixup_bus()I really hate the idea of fixing something for x86 but not for other arches, so maybe somebody could take a deeper look at this and see if it would make sense to change the other arches, too.
I misspoke here. The change below helps fix an issue on x86. It's only an issue on x86 because only x86 has acpiphp and pcibios_resource_survey_bus(). Other arches *do* call pci_claim_resource(), but making similar changes on other arches does not fix similar issues there, so it's not really a matter of "fixing only x86."
My motivation is to move toward unification of how we claim resources.
There's nothing inherently arch-specific about callingpci_claim_resource(), but arches use a variety of tests involving "r->flags", "r->parent", and "r->start" to decide whether to do so. Ideally we would call pci_claim_resource() from the core, not from arch code, and we would use a set of tests that work for all arches and situations.
We can always do the minimum of changing only what's absolutely required, but the result is divergence and increased maintenance work in the long term. I'm trying to counter that a little bit by encouraging people to consider refactorings that fix the current issue while reducing maintenance effort.
Bjorn
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
--- arch/x86/pci/i386.c | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/pci/i386.c +4
-1@@ -210,6 +210,8 @@ static void pcibios_allocate_bridge_resources(struct pci_dev *dev) r = &dev->resource[idx];if (!r->flags)continue ; +if (r->parent)/* Already allocated */ +continue ;if (!r->start ||pci_claim_resource (dev, idx) <0 ) {/* * Something is wrong with the region. @@ -318,6 +320,8 @@ static void pcibios_allocate_dev_rom_resource(struct pci_dev *dev) r = &dev->resource[PCI_ROM_RESOURCE ];if (!r->flags || !r->start)return ; +if (r->parent)/* Already allocated */ +return ;if (pci_claim_resource (dev,PCI_ROM_RESOURCE ) <0 ) { r->end -= r->start; --1.8.3.2
Re: [PATCH v2 1/8] x86/PCI: prevent re-allocation of already existing bridge and ROM resources
In reply to Bjorn HelgaasQuoted 15 lines · Bjorn Helgaas
Quoted 14 lines · Bjorn Helgaas
Quoted 12 lines · Mika Westerberg
In hotplug case (especially with Thunderbolt enabled systems) we might need to call
pcibios_resource_survey_bus()several times for a bus. The function ends up callingpci_claim_resource()for each bridge resource that then fails claiming that the resource exists already (which it does). Once this happens the resource is invalidated thus preventing devices behind the bridge to allocate their resources.To fix this we do what has been done in
pcibios_allocate_dev_resources()and check 'parent' of the given resource. If it is non-NULL it means that the resource has been allocated already and we can skip it. We do the same for ROM resources as well.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Mika Westerberg <[email protected]>This looks reasonable to me.
Acked-by Bjorn Helgaas <[email protected]>
Thanks a lot!
Quoted 54 lines
Quoted 44 lines
However, the use of "
r->parent" to determine whether the resource is already allocated is nothing specific to x86. So I think we might be missing an opportunity to make this more consistent across architectures. I looked at other callers ofpci_claim_resource()for bridge and ROM resources, and it looks like we might be able to make similar changes in:frv
pcibios_allocate_bus_resources()
ia64pcibios_fixup_resources()(viapcibios_fixup_bridge_resources()) mn10300pcibios_allocate_bus_resources()
mn10300pcibios_assign_resources()(ROM)
mn10300pcibios_fixup_device_resources()
parisclba_fixup_bus()I really hate the idea of fixing something for x86 but not for other arches, so maybe somebody could take a deeper look at this and see if it would make sense to change the other arches, too.
Bjorn
Quoted 24 lines
--- arch/x86/pci/i386.c | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/pci/i386.c +4
-0@@ -210,6 +210,8 @@ static void pcibios_allocate_bridge_resources(struct pci_dev *dev) r = &dev->resource[idx];if (!r->flags)continue ; +if (r->parent)/* Already allocated */ +continue ;if (!r->start ||pci_claim_resource (dev, idx) <0 ) {/* * Something is wrong with the region. @@ -318,6 +320,8 @@ static void pcibios_allocate_dev_rom_resource(struct pci_dev *dev) r = &dev->resource[PCI_ROM_RESOURCE ];if (!r->flags || !r->start)return ; +if (r->parent)/* Already allocated */ +return ;Quoted 5 lines
Quoted 5 lines
arch/x86/pci/i386.c +0
-1if (pci_claim_resource (dev,PCI_ROM_RESOURCE ) <0 ) { r->end -= r->start; --1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [PATCH v2 1/8] x86/PCI: prevent re-allocation of already existing bridge and ROM resources
In reply to Bjorn HelgaasQuoted 47 lines · Bjorn Helgaas
Quoted 15 lines · Bjorn Helgaas
Quoted 14 lines · Bjorn Helgaas
Quoted 12 lines · Mika Westerberg
In hotplug case (especially with Thunderbolt enabled systems) we might need to call
pcibios_resource_survey_bus()several times for a bus. The function ends up callingpci_claim_resource()for each bridge resource that then fails claiming that the resource exists already (which it does). Once this happens the resource is invalidated thus preventing devices behind the bridge to allocate their resources.To fix this we do what has been done in
pcibios_allocate_dev_resources()and check 'parent' of the given resource. If it is non-NULL it means that the resource has been allocated already and we can skip it. We do the same for ROM resources as well.Quoted 23 lines
Quoted 3 lines
Quoted 1 line
Signed-off-by Mika Westerberg <[email protected]>This looks reasonable to me.
Acked-by Bjorn Helgaas <[email protected]>Quoted 17 lines
However, the use of "
r->parent" to determine whether the resource is already allocated is nothing specific to x86. So I think we might be missing an opportunity to make this more consistent across architectures. I looked at other callers ofpci_claim_resource()for bridge and ROM resources, and it looks like we might be able to make similar changes in:frv
pcibios_allocate_bus_resources()
ia64pcibios_fixup_resources()(viapcibios_fixup_bridge_resources()) mn10300pcibios_allocate_bus_resources()
mn10300pcibios_assign_resources()(ROM)
mn10300pcibios_fixup_device_resources()
parisclba_fixup_bus()I really hate the idea of fixing something for x86 but not for other arches, so maybe somebody could take a deeper look at this and see if it would make sense to change the other arches, too.
I misspoke here. The change below helps fix an issue on x86. It's only an issue on x86 because only x86 has acpiphp and
pcibios_resource_survey_bus(). Other arches *do* callpci_claim_resource(), but making similar changes on other arches does not fix similar issues there, so it's not really a matter of "fixing only x86."
Quoted 7 lines
My motivation is to move toward unification of how we claim resources.
There's nothing inherently arch-specific about callingpci_claim_resource(), but arches use a variety of tests involving "r->flags", "r->parent", and "r->start" to decide whether to do so. Ideally we would callpci_claim_resource()from the core, not from arch code, and we would use a set of tests that work for all arches and situations.
Agreed.
Do you think we can discuss that at the miniconf during the LPC? We have resources handling on our agenda anyway.
Quoted 5 lines
We can always do the minimum of changing only what's absolutely required, but the result is divergence and increased maintenance work in the long term. I'm trying to counter that a little bit by encouraging people to consider refactorings that fix the current issue while reducing maintenance effort.
I understand the motivation, but I also think that such changes should be coordinated, for example so that we know that they have been tested on all architectures in question before they go to the mainline for good.
Thanks,
Rafael
Quoted 34 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
--- arch/x86/pci/i386.c | 4 ++++ 1 file changed, 4 insertions(+)arch/x86/pci/i386.c +4
-0@@ -210,6 +210,8 @@ static void pcibios_allocate_bridge_resources(struct pci_dev *dev) r = &dev->resource[idx];if (!r->flags)continue ; +if (r->parent)/* Already allocated */ +continue ;if (!r->start ||pci_claim_resource (dev, idx) <0 ) {/* * Something is wrong with the region. @@ -318,6 +320,8 @@ static void pcibios_allocate_dev_rom_resource(struct pci_dev *dev) r = &dev->resource[PCI_ROM_RESOURCE ];if (!r->flags || !r->start)return ; +if (r->parent)/* Already allocated */ +return ;Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
arch/x86/pci/i386.c +0
-1if (pci_claim_resource (dev,PCI_ROM_RESOURCE ) <0 ) { r->end -= r->start; --1.8.3.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.