acpiphp: configure _PRT
RFC PATCH 1/1 acpiphp: configure _PRT
Hi,
Current acpiphp does not free acpi_device structs when the PCI devices are removed. When the PCI device is added, acpi_bus_add() fails because acpi_device struct has already exists. So, _PRT method does not evaluate.
This patch fixes this issue.
This patch is against 2.6.16-rc5-mm1 plus following patches.
o Kristen's latest patch set
o Kenji's acpiphp: Scan slots under the nested P2P bridge
I tested this patch on my tiger4 box except for dock eject case, because I don't have any pc which has _DCK method.
--
But, if the devices do not have the _STA method, this patch makes strange conditions. If the PCI device is hotplugged once, there is no acpi_device struct. But if the PCI device is not hotplugged yet, there is acpi_device struct.
I want to know this strange conditions are allowed or not. Any comments are welcomed.
Thanks,
MUNE
--
Current acpiphp does not free acpi_device structs when the PCI devices are removed. When the PCI device is added, acpi_bus_add() fails because acpi_device struct has already exists. So, _PRT method does not evaluate.
This patch fixes this issue.
drivers/pci/hotplug/acpiphp_dock.c | 1 drivers/pci/hotplug/acpiphp_glue.c | 70 ++++++++++++++++--------------------- 2 files changed, 33 insertions(+), 38 deletions(-)
drivers/pci/hotplug/acpiphp_glue.c +32 -38
@@ -841,36 +841,6 @@ static unsigned char acpiphp_max_busnr(s } - -/** -* get_func - get a pointer to acpiphp_func given a slot, device -* @slot: slot to search -* @dev: pci_dev struct to match. -* -* This function will increase the reference count of pci_dev, -* so callers should call pci_dev_put when complete. -* -*/ -static struct acpiphp_func * -get_func (struct acpiphp_slot *slot,struct pci_dev *dev) -{ -struct acpiphp_func *func =NULL ; -struct pci_bus *bus = slot->bridge->pci_bus; -struct pci_dev *pdev; - -list_for_each_entry (func, &slot->funcs, sibling) { - pdev =pci_get_slot (bus,PCI_DEVFN (slot->device, - func->function)); -if (pdev) { -if (pdev == dev) -break ; -pci_dev_put (pdev); - } - } -return func; -} - -/** * acpiphp_bus_add - add a new bus to acpi subsystem * @func: acpiphp_func of the bridge
@@ -917,6 +887,28 @@ acpiphp_bus_add_out: } +/** +* acpiphp_bus_trim - trim a bus from acpi subsystem +* @handle: handle to acpi namespace +* +*/ +int acpiphp_bus_trim (acpi_handle handle) +{ +struct acpi_device *device; +int retval; + + retval =acpi_bus_get_device (handle, &device); +if (retval) { +dbg ("acpi_device not found\n" ); +return retval; + } + + retval =acpi_bus_trim (device,1 ); +if (retval) +err ("cannot remove from acpi list\n" ); + +return 0 ; +}/** * enable_device - enable, configure a slot
@@ -963,19 +955,17 @@ static int enable_device(struct acpiphp_if (dev->hdr_type ==PCI_HEADER_TYPE_BRIDGE || dev->hdr_type ==PCI_HEADER_TYPE_CARDBUS ) { max =pci_scan_bridge (bus, dev, max, pass); -if (pass && dev->subordinate) { +if (pass && dev->subordinate)pci_bus_size_bridges (dev->subordinate); - func =get_func (slot, dev); -if (func) { -acpiphp_bus_add (func); -/* side effect of get_func */ -pci_dev_put (dev); - } - } } } } + list_for_each (l, &slot->funcs) { + func = list_entry(l, struct acpiphp_func, sibling); +acpiphp_bus_add (func); + } +pci_bus_assign_resources (bus);acpiphp_sanitize_bus (bus);pci_enable_bridges (bus);
@@ -1012,6 +1002,10 @@ static int disable_device(struct acpiphp list_for_each (l, &slot->funcs) { func = list_entry(l, struct acpiphp_func, sibling); + +if (acpiphp_bus_trim (func->handle)) +continue ; +if (!func->pci_dev)continue ;
drivers/pci/hotplug/acpiphp_dock.c +1 -0
@@ -290,6 +290,7 @@ handle_hotplug_event_dock(acpi_handle hadbg ("EJECT request\n" );if (!dock_in_progress () &&dock_present ()) {hotplug_pci (type); +acpiphp_bus_trim (handle);undock ();eject_dock ();if (dock_present ())
Quoted 9 lines · MUNEDA Takahiro
Hi,
Current acpiphp does not free
acpi_devicestructs when the PCI devices are removed. When the PCI device is added,acpi_bus_add()fails becauseacpi_devicestruct has already exists. So,_PRTmethod does not evaluate.This patch fixes this issue.
Quoted 8 lines
This patch is against 2.6.16-rc5-mm1 plus following patches.
o Kristen's latest patch set
o Kenji's acpiphp: Scan slots under the nested P2P bridgeI tested this patch on my tiger4 box except for dock eject case, because I don't have any pc which has
_DCKmethod.
I tested this on a couple laptops that have _DCK methods - It seems to work fine, however, see comment below:
<snip>
drivers/pci/hotplug/acpiphp_dock.c handle_hotplug_event_dock(acpi_handle ha · line 293
Quoted 9 lines
Index:
linux-2.6.16-rc5-mm1/drivers/pci/hotplug/acpiphp_dock.c
===================================================================drivers/pci/hotplug/acpiphp_dock.c +1
-0@@ -290,6 +290,7 @@ handle_hotplug_event_dock(acpi_handle hadbg ("EJECT request\n" );if (!dock_in_progress () &&dock_present ()) {hotplug_pci (type); +acpiphp_bus_trim (handle);
This is not necessary. hotplug_pci() will pass the eject event down to the acpiphp handle_hotplug_event_func() routine, which will call disable_device() and remove the bus that way as part of your new patch.
Quoted 3 lines
drivers/pci/hotplug/acpiphp_dock.c +0
-0undock ();eject_dock ();if (dock_present ())
At Thu, 02 Mar 2006 15:34:09 -0800,
Quoted 3 lines · Kristen Accardi
I tested this on a couple laptops that have
_DCKmethods - It seems to work fine, however, see comment below:
Thanks for testing my patch and for feedback.
Quoted 15 lines
<snip>
drivers/pci/hotplug/acpiphp_dock.c handle_hotplug_event_dock(acpi_handle ha · line 293
Quoted 9 lines
Index:
linux-2.6.16-rc5-mm1/drivers/pci/hotplug/acpiphp_dock.c
===================================================================drivers/pci/hotplug/acpiphp_dock.c +1
-0@@ -290,6 +290,7 @@ handle_hotplug_event_dock(acpi_handle hadbg ("EJECT request\n" );if (!dock_in_progress () &&dock_present ()) {hotplug_pci (type); +acpiphp_bus_trim (handle);This is not necessary.
hotplug_pci()will pass the eject event down to the acpiphphandle_hotplug_event_func()routine, which will calldisable_device()and remove the bus that way as part of your new patch.
OK, I mis-understood the dock eject routine.
I'll remove it.
Quoted 3 lines
drivers/pci/hotplug/acpiphp_dock.c handle_hotplug_event_dock(acpi_handle ha · line 296
Quoted 3 lines
drivers/pci/hotplug/acpiphp_dock.c +0
-0undock ();eject_dock ();if (dock_present ())
Thanks,
MUNE
At Thu, 02 Mar 2006 22:58:03 +0900,
Quoted 8 lines · MUNEDA Takahiro
But, if the devices do not have the
_STAmethod, this patch makes strange conditions. If the PCI device is hotplugged once, there is noacpi_devicestruct. But if the PCI device is not hotplugged yet, there isacpi_devicestruct.I want to know this strange conditions are allowed or not. Any comments are welcomed.
Hi,
I pondered about this idea after I got up. I think this idea is strange and might be wrong. So, please ignore this patch. I'll resend the patch later.
I'm sorry to confuse you.
Thanks,
MUNE