acpi,pci: hostbridge hotplug support
Subsystems (4)
v3 cover acpi,pci: hostbridge hotplug support
Hi all,
This patchset is 3rd version of the following:
http://marc.info/?l=linux-pci&m=134457928913775&w=2 http://marc.info/?l=linux-pci&m=134665909321684&w=2
v2 -> v3:
- change acpi_pci_drivers' add/remove interface according to Bjorn's suggestion
- abandon RCU for protecting acpi_pci_roots list according to Bjorn's suggestion
- change acpi_pci_find_root implementation to avoid potential deadlock
* [PATCH v3 1/8] ACPI, PCI: Use normal list for struct acpi_pci_driver
* [PATCH v3 2/8] ACPI, PCI: Notify acpi_pci_drivers when hot-plugging PCI root bridges
* [PATCH v3 3/8] ACPI, PCI: add acpi_pci_drivers protection
* [PATCH v3 4/8] ACPI, PCI: change acpi_pci_drivers' add/remove interface
* [PATCH v3 5/8] ACPI, PCI: change acpi_pci_find_root implementation
* [PATCH v3 6/8] ACPI, PCI: add acpi_pci_roots protection
* [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
* [PATCH v3 8/8] ACPI, PCI: add resoruce-assign code for devices under hot-added hostbridge
Signature · 2 lines
Best regards, Taku Izumi <[email protected]>
PATCH v3 1/8 ACPI, PCI: Use normal list for struct acpi_pci_driver
From: Jiang Liu <[email protected]>
ACPI, PCI: Use normal list for struct acpi_pci_driver
Use normal list for struct acpi_pci_driver to simplify code.
--- drivers/acpi/pci_root.c | 16 +++------------- include/linux/acpi.h | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-)
drivers/acpi/pci_root.c +3 -13
@@ -72,8 +72,8 @@ static struct acpi_driver acpi_pci_root_ };static LIST_HEAD (acpi_pci_roots); +static LIST_HEAD (acpi_pci_drivers); -static struct acpi_pci_driver *sub_driver;static DEFINE_MUTEX (osc_lock);int acpi_pci_register_driver (struct acpi_pci_driver *driver)
@@ -81,10 +81,7 @@ int acpi_pci_register_driver(struct acpiint n =0 ;struct acpi_pci_root *root; -struct acpi_pci_driver **pptr = &sub_driver; -while (*pptr) - pptr = &(*pptr)->next; - *pptr = driver; +list_add_tail (&driver->node, &acpi_pci_drivers);if (!driver->add)return 0 ;
@@ -103,14 +100,7 @@ void acpi_pci_unregister_driver(struct a {struct acpi_pci_root *root; -struct acpi_pci_driver **pptr = &sub_driver; -while (*pptr) { -if (*pptr == driver) -break ; - pptr = &(*pptr)->next; - } -BUG_ON (!*pptr); - *pptr = (*pptr)->next; +list_del (&driver->node);if (!driver->remove)return ;
include/linux/acpi.h +1 -1
@@ -138,7 +138,7 @@ void acpi_penalize_isa_irq(int irq, intvoid acpi_pci_irq_disable (struct pci_dev *dev);struct acpi_pci_driver { -struct acpi_pci_driver *next; +struct list_head node;int (*add)(acpi_handle handle);void (*remove)(acpi_handle handle); };
PATCH v3 2/8 ACPI, PCI: Notify acpi_pci_drivers when hot-plugging PCI root bridges
In reply to Taku IzumiFrom: Jiang Liu <[email protected]>
ACPI, PCI: Notify acpi_pci_drivers when hot-plugging PCI root bridges
When hot-plugging PCI root bridge, acpi_pci_drivers' add()/remove() methods should be invoked to notify registered drivers.
-v2: Move add calling to acpi_pci_root_start by Yinghai
--- drivers/acpi/pci_root.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/acpi/pci_root.c +11 -0
@@ -626,14 +626,25 @@ end:static int acpi_pci_root_start (struct acpi_device *device) {struct acpi_pci_root *root =acpi_driver_data (device); +struct acpi_pci_driver *driver; + +list_for_each_entry (driver, &acpi_pci_drivers, node) +if (driver->add) + driver->add (device->handle);pci_bus_add_devices (root->bus); +return 0 ; }static int acpi_pci_root_remove (struct acpi_device *device,int type) {struct acpi_pci_root *root =acpi_driver_data (device); +struct acpi_pci_driver *driver; + +list_for_each_entry (driver, &acpi_pci_drivers, node) +if (driver->remove) + driver->remove (root->device->handle);device_set_run_wake (root->bus->bridge, false);pci_acpi_remove_bus_pm_notifier (device);
PATCH v3 3/8 ACPI, PCI: add acpi_pci_drivers protection
In reply to Taku IzumiUse mutex to protect global acpi_pci_drivers list against PCI host bridge hotplug operations.
--- drivers/acpi/pci_root.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-)
drivers/acpi/pci_root.c +19 -17
@@ -27,7 +27,7 @@#include <linux/module.h> #include <linux/init.h> #include <linux/types.h> -#include <linux/spinlock.h> +#include <linux/mutex.h> #include <linux/pm.h> #include <linux/pm_runtime.h> #include <linux/pci.h>
@@ -71,6 +71,8 @@ static struct acpi_driver acpi_pci_root_ }, }; +/* Lock to protect both acpi_pci_roots and acpi_pci_drivers lists */ +static DEFINE_MUTEX (acpi_pci_root_lock);static LIST_HEAD (acpi_pci_roots);static LIST_HEAD (acpi_pci_drivers);
@@ -81,34 +83,30 @@ int acpi_pci_register_driver(struct acpiint n =0 ;struct acpi_pci_root *root; +mutex_lock (&acpi_pci_root_lock);list_add_tail (&driver->node, &acpi_pci_drivers); - -if (!driver->add) -return 0 ; - -list_for_each_entry (root, &acpi_pci_roots, node) { - driver->add (root->device->handle); - n++; - } +if (driver->add) +list_for_each_entry (root, &acpi_pci_roots, node) { + driver->add (root->device->handle); + n++; + } +mutex_unlock (&acpi_pci_root_lock);return n; } -EXPORT_SYMBOL (acpi_pci_register_driver);void acpi_pci_unregister_driver (struct acpi_pci_driver *driver) {struct acpi_pci_root *root; +mutex_lock (&acpi_pci_root_lock);list_del (&driver->node); - -if (!driver->remove) -return ; - -list_for_each_entry (root, &acpi_pci_roots, node) - driver->remove (root->device->handle); +if (driver->remove) +list_for_each_entry (root, &acpi_pci_roots, node) + driver->remove (root->device->handle); +mutex_unlock (&acpi_pci_root_lock); } -EXPORT_SYMBOL (acpi_pci_unregister_driver);acpi_handle acpi_get_pci_rootbridge_handle (unsigned int seg,unsigned int bus)
@@ -628,9 +626,11 @@ static int acpi_pci_root_start(struct acstruct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +mutex_lock (&acpi_pci_root_lock);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->add) driver->add (device->handle); +mutex_unlock (&acpi_pci_root_lock);pci_bus_add_devices (root->bus);
@@ -642,9 +642,11 @@ static int acpi_pci_root_remove(struct astruct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +mutex_lock (&acpi_pci_root_lock);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->remove) driver->remove (root->device->handle); +mutex_unlock (&acpi_pci_root_lock);device_set_run_wake (root->bus->bridge, false);pci_acpi_remove_bus_pm_notifier (device);
PATCH v3 4/8 ACPI, PCI: change acpi_pci_drivers' add/remove interface
In reply to Taku IzumiThis patch changes .add/.remove interfaces of acpi_pci_driver. In the current implementation acpi_handle is passed as a parameter of .add/.remove interface. However acpi_pci_root structure other than acpi_handle is more usefull. This enables us to avoid useless procedure in each acpi_pci_driver.
--- drivers/acpi/pci_root.c | 8 ++++---- drivers/acpi/pci_slot.c | 11 ++++++----- drivers/pci/hotplug/acpiphp_glue.c | 12 +++++++----- include/linux/acpi.h | 4 ++-- 4 files changed, 19 insertions(+), 16 deletions(-)
include/linux/acpi.h +2 -2
@@ -139,8 +139,8 @@ void acpi_pci_irq_disable (struct pci_destruct acpi_pci_driver {struct list_head node; -int (*add)(acpi_handle handle); -void (*remove)(acpi_handle handle); +int (*add)(struct acpi_pci_root *root); +void (*remove)(struct acpi_pci_root *root); };int acpi_pci_register_driver (struct acpi_pci_driver *driver);
drivers/pci/hotplug/acpiphp_glue.c +7 -5
@@ -382,10 +382,10 @@ static inline void config_p2p_bridge_fla/* allocate and initialize host bridge data structure */ -static void add_host_bridge (acpi_handle *handle) +static void add_host_bridge (struct acpi_pci_root *root) {struct acpiphp_bridge *bridge; -struct acpi_pci_root *root =acpi_pci_find_root (handle); +acpi_handle handle = root->device->handle; bridge =kzalloc (sizeof (struct acpiphp_bridge ),GFP_KERNEL );if (bridge ==NULL )
@@ -468,11 +468,12 @@ find_p2p_bridge(acpi_handle handle, u32/* find hot-pluggable slots, and then find P2P bridge */ -static int add_bridge (acpi_handle handle) +static int add_bridge (struct acpi_pci_root *root) {acpi_status status;unsigned long long tmp;acpi_handle dummy_handle; +acpi_handle handle = root->device->handle;/* if the bridge doesn't have _STA, we assume it is always there */ status =acpi_get_handle (handle,"_STA" , &dummy_handle);
@@ -490,7 +491,7 @@ static int add_bridge(acpi_handle handle/* check if this bridge has ejectable slots */ if (detect_ejectable_slots (handle) >0 ) {dbg ("found PCI host-bus bridge with hot-pluggable slots\n" ); -add_host_bridge (handle); +add_host_bridge (root); }/* search P2P bridges under this host bridge */
@@ -588,9 +589,10 @@ cleanup_p2p_bridge(acpi_handle handle, ureturn AE_OK ; } -static void remove_bridge (acpi_handle handle) +static void remove_bridge (struct acpi_pci_root *root) {struct acpiphp_bridge *bridge; +acpi_handle handle = root->device->handle;/* cleanup p2p bridges under this host bridge in a depth-first manner */
drivers/acpi/pci_slot.c +6 -5
@@ -67,8 +67,8 @@ struct acpi_pci_slot {struct list_head list;/* node in the list of slots */ }; -static int acpi_pci_slot_add (acpi_handle handle); -static void acpi_pci_slot_remove (acpi_handle handle); +static int acpi_pci_slot_add (struct acpi_pci_root *root); +static void acpi_pci_slot_remove (struct acpi_pci_root *root);static LIST_HEAD (slot_list);static DEFINE_MUTEX (slot_list_lock);
@@ -295,11 +295,11 @@ walk_root_bridge(acpi_handle handle, acp* @handle: points to an acpi_pci_root */ static int -acpi_pci_slot_add (acpi_handle handle) +acpi_pci_slot_add (struct acpi_pci_root *root) {acpi_status status; - status =walk_root_bridge (handle, register_slot); + status =walk_root_bridge (root->device->handle, register_slot);if (ACPI_FAILURE (status))err ("%s: register_slot failure - %d\n" , __func__, status);
@@ -311,10 +311,11 @@ acpi_pci_slot_add(acpi_handle handle)* @handle: points to an acpi_pci_root */ static void -acpi_pci_slot_remove (acpi_handle handle) +acpi_pci_slot_remove (struct acpi_pci_root *root) {struct acpi_pci_slot *slot, *tmp;struct pci_bus *pbus; +acpi_handle handle = root->device->handle;mutex_lock (&slot_list_lock);list_for_each_entry_safe (slot, tmp, &slot_list, list) {
drivers/acpi/pci_root.c +4 -4
@@ -87,7 +87,7 @@ int acpi_pci_register_driver(struct acpilist_add_tail (&driver->node, &acpi_pci_drivers);if (driver->add)list_for_each_entry (root, &acpi_pci_roots, node) { - driver->add (root->device->handle); + driver->add (root); n++; }mutex_unlock (&acpi_pci_root_lock);
@@ -104,7 +104,7 @@ void acpi_pci_unregister_driver(struct alist_del (&driver->node);if (driver->remove)list_for_each_entry (root, &acpi_pci_roots, node) - driver->remove (root->device->handle); + driver->remove (root);mutex_unlock (&acpi_pci_root_lock); }EXPORT_SYMBOL (acpi_pci_unregister_driver);
@@ -629,7 +629,7 @@ static int acpi_pci_root_start(struct acmutex_lock (&acpi_pci_root_lock);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->add) - driver->add (device->handle); + driver->add (root);mutex_unlock (&acpi_pci_root_lock);pci_bus_add_devices (root->bus);
@@ -645,7 +645,7 @@ static int acpi_pci_root_remove(struct amutex_lock (&acpi_pci_root_lock);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->remove) - driver->remove (root->device->handle); + driver->remove (root);mutex_unlock (&acpi_pci_root_lock);device_set_run_wake (root->bus->bridge, false);
Bjorn Helgaas
maintainerRe: [PATCH v3 4/8] ACPI, PCI: change acpi_pci_drivers' add/remove interface
Quoted 6 lines · Taku Izumi
This patch changes .add/.remove interfaces of
acpi_pci_driver. In the current implementationacpi_handleis passed as a parameter of .add/.remove interface. Howeveracpi_pci_rootstructure other thanacpi_handleis more usefull. This enables us to avoid useless procedure in eachacpi_pci_driver.
Now that .add() gets the struct acpi_pci_root, would you like to clean up walk_root_bridge()? I think we could remove the _SEG and _BBN evaluations as well as the pci_find_bus(), since that information is all in the struct acpi_pci_root.
This should be a separate patch, if you choose to do it :)
Quoted 158 lines
Signed-off-by Taku Izumi <[email protected]>--- drivers/acpi/pci_root.c | 8 ++++---- drivers/acpi/pci_slot.c | 11 ++++++----- drivers/pci/hotplug/acpiphp_glue.c | 12 +++++++----- include/linux/acpi.h | 4 ++-- 4 files changed, 19 insertions(+), 16 deletions(-)Index:
Bjorn-next-0903/include/linux/acpi.h
===================================================================include/linux/acpi.h +2
-2@@ -139,8 +139,8 @@ void acpi_pci_irq_disable (struct pci_destruct acpi_pci_driver {struct list_head node; -int (*add)(acpi_handle handle); -void (*remove)(acpi_handle handle); +int (*add)(struct acpi_pci_root *root); +void (*remove)(struct acpi_pci_root *root); };int acpi_pci_register_driver (struct acpi_pci_driver *driver);Index:
Bjorn-next-0903/drivers/pci/hotplug/acpiphp_glue.c
===================================================================drivers/pci/hotplug/acpiphp_glue.c +7
-5@@ -382,10 +382,10 @@ static inline void config_p2p_bridge_fla/* allocate and initialize host bridge data structure */ -static void add_host_bridge (acpi_handle *handle) +static void add_host_bridge (struct acpi_pci_root *root) {struct acpiphp_bridge *bridge; -struct acpi_pci_root *root =acpi_pci_find_root (handle); +acpi_handle handle = root->device->handle; bridge =kzalloc (sizeof (struct acpiphp_bridge ),GFP_KERNEL );if (bridge ==NULL )@@ -468,11 +468,12 @@ find_p2p_bridge(acpi_handle handle, u32/* find hot-pluggable slots, and then find P2P bridge */ -static int add_bridge (acpi_handle handle) +static int add_bridge (struct acpi_pci_root *root) {acpi_status status;unsigned long long tmp;acpi_handle dummy_handle; +acpi_handle handle = root->device->handle;/* if the bridge doesn't have _STA, we assume it is always there */ status =acpi_get_handle (handle,"_STA" , &dummy_handle);@@ -490,7 +491,7 @@ static int add_bridge(acpi_handle handle/* check if this bridge has ejectable slots */ if (detect_ejectable_slots (handle) >0 ) {dbg ("found PCI host-bus bridge with hot-pluggable slots\n" ); -add_host_bridge (handle); +add_host_bridge (root); }/* search P2P bridges under this host bridge */ @@ -588,9 +589,10 @@ cleanup_p2p_bridge(acpi_handle handle, ureturn AE_OK ; } -static void remove_bridge (acpi_handle handle) +static void remove_bridge (struct acpi_pci_root *root) {struct acpiphp_bridge *bridge; +acpi_handle handle = root->device->handle;/* cleanup p2p bridges under this host bridge in a depth-first manner */ Index:
Bjorn-next-0903/drivers/acpi/pci_slot.c
===================================================================drivers/acpi/pci_slot.c +6
-5@@ -67,8 +67,8 @@ struct acpi_pci_slot {struct list_head list;/* node in the list of slots */ }; -static int acpi_pci_slot_add (acpi_handle handle); -static void acpi_pci_slot_remove (acpi_handle handle); +static int acpi_pci_slot_add (struct acpi_pci_root *root); +static void acpi_pci_slot_remove (struct acpi_pci_root *root);static LIST_HEAD (slot_list);static DEFINE_MUTEX (slot_list_lock);@@ -295,11 +295,11 @@ walk_root_bridge(acpi_handle handle, acp* @handle: points to an acpi_pci_root */ static int -acpi_pci_slot_add (acpi_handle handle) +acpi_pci_slot_add (struct acpi_pci_root *root) {acpi_status status; - status =walk_root_bridge (handle, register_slot); + status =walk_root_bridge (root->device->handle, register_slot);if (ACPI_FAILURE (status))err ("%s: register_slot failure - %d\n" , __func__, status);@@ -311,10 +311,11 @@ acpi_pci_slot_add(acpi_handle handle)* @handle: points to an acpi_pci_root */ static void -acpi_pci_slot_remove (acpi_handle handle) +acpi_pci_slot_remove (struct acpi_pci_root *root) {struct acpi_pci_slot *slot, *tmp;struct pci_bus *pbus; +acpi_handle handle = root->device->handle;mutex_lock (&slot_list_lock);list_for_each_entry_safe (slot, tmp, &slot_list, list) {Index:
Bjorn-next-0903/drivers/acpi/pci_root.c
===================================================================drivers/acpi/pci_root.c +4
-4@@ -87,7 +87,7 @@ int acpi_pci_register_driver(struct acpilist_add_tail (&driver->node, &acpi_pci_drivers);if (driver->add)list_for_each_entry (root, &acpi_pci_roots, node) { - driver->add (root->device->handle); + driver->add (root); n++; }mutex_unlock (&acpi_pci_root_lock);@@ -104,7 +104,7 @@ void acpi_pci_unregister_driver(struct alist_del (&driver->node);if (driver->remove)list_for_each_entry (root, &acpi_pci_roots, node) - driver->remove (root->device->handle); + driver->remove (root);mutex_unlock (&acpi_pci_root_lock); }EXPORT_SYMBOL (acpi_pci_unregister_driver);@@ -629,7 +629,7 @@ static int acpi_pci_root_start(struct acmutex_lock (&acpi_pci_root_lock);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->add) - driver->add (device->handle); + driver->add (root);mutex_unlock (&acpi_pci_root_lock);pci_bus_add_devices (root->bus);@@ -645,7 +645,7 @@ static int acpi_pci_root_remove(struct amutex_lock (&acpi_pci_root_lock);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->remove) - driver->remove (root->device->handle); + driver->remove (root);mutex_unlock (&acpi_pci_root_lock);device_set_run_wake (root->bus->bridge, false);
Re: [PATCH v3 4/8] ACPI, PCI: change acpi_pci_drivers' add/remove interface
Quoted 1 line · On Wed, 19 Sep 2012 16:46:57 -0600 Bjorn Helgaas <[email protected]> wrote:
This should be a separate patch, if you choose to do it :)
OK. I'll do this later.
Signature · 1 line
Taku Izumi <[email protected]>
PATCH 1/1 change signature of walk_root_bridge() function
This patch changes the function signature of walk_root_bridge().
We can omit _STA, _SEG, and _BBN evaluation by passing not acpi_handle but acpi_pci_root. Now that acpi_pci_slot_add() which is the only caller of walk_root_bridge() gets acpi_pci_root structure, changing signature of walk_root_bridge() is reasonable.
--- drivers/acpi/pci_slot.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-)
drivers/acpi/pci_slot.c +5 -30
@@ -233,45 +233,20 @@ out:/* * walk_root_bridge - generic root bridge walker -* @handle: points to an acpi_pci_root +* @root: poiner of an acpi_pci_root * @user_function: user callback for slot objects * * Call user_function for all objects underneath this root bridge. * Walk p2p bridges underneath us and call user_function on those too. */ static int -walk_root_bridge (acpi_handle handle,acpi_walk_callback user_function) +walk_root_bridge (struct acpi_pci_root *root,acpi_walk_callback user_function) { -int seg, bus; -unsigned long long tmp;acpi_status status; -acpi_handle dummy_handle; -struct pci_bus *pci_bus; +acpi_handle handle = root->device->handle; +struct pci_bus *pci_bus = root->bus;struct callback_args context; -/* If the bridge doesn't have _STA, we assume it is always there */ - status =acpi_get_handle (handle,"_STA" , &dummy_handle); -if (ACPI_SUCCESS (status)) { - status =acpi_evaluate_integer (handle,"_STA" ,NULL , &tmp); -if (ACPI_FAILURE (status)) { -info ("%s: _STA evaluation failure\n" , __func__); -return 0 ; - } -if ((tmp &ACPI_STA_DEVICE_FUNCTIONING ) ==0 ) -/* don't register this object */ -return 0 ; - } - - status =acpi_evaluate_integer (handle,"_SEG" ,NULL , &tmp); - seg =ACPI_SUCCESS (status) ? tmp :0 ; - - status =acpi_evaluate_integer (handle,"_BBN" ,NULL , &tmp); - bus =ACPI_SUCCESS (status) ? tmp :0 ; - - pci_bus =pci_find_bus (seg, bus); -if (!pci_bus) -return 0 ; - context.pci_bus = pci_bus; context.user_function = user_function; context.root_handle = handle;
@@ -299,7 +274,7 @@ acpi_pci_slot_add(struct acpi_pci_root * {acpi_status status; - status =walk_root_bridge (root->device->handle, register_slot); + status =walk_root_bridge (root, register_slot);if (ACPI_FAILURE (status))err ("%s: register_slot failure - %d\n" , __func__, status);
Bjorn Helgaas
maintainerRe: [PATCH] change signature of walk_root_bridge() function
Quoted 9 lines · Taku Izumi
This patch changes the function signature of
walk_root_bridge().We can omit
_STA,_SEG, and_BBNevaluation by passing notacpi_handlebutacpi_pci_root. Now thatacpi_pci_slot_add()which is the only caller ofwalk_root_bridge()getsacpi_pci_rootstructure, changing signature ofwalk_root_bridge()is reasonable.
Quoted 4 lines
Signed-off-by Taku Izumi <[email protected]>--- drivers/acpi/pci_slot.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-)
This is beautiful!
Quoted 64 lines
Index:
Bjorn-next-0903/drivers/acpi/pci_slot.c
===================================================================drivers/acpi/pci_slot.c +5
-30@@ -233,45 +233,20 @@ out:/* * walk_root_bridge - generic root bridge walker -* @handle: points to an acpi_pci_root +* @root: poiner of an acpi_pci_root * @user_function: user callback for slot objects * * Call user_function for all objects underneath this root bridge. * Walk p2p bridges underneath us and call user_function on those too. */ static int -walk_root_bridge (acpi_handle handle,acpi_walk_callback user_function) +walk_root_bridge (struct acpi_pci_root *root,acpi_walk_callback user_function) { -int seg, bus; -unsigned long long tmp;acpi_status status; -acpi_handle dummy_handle; -struct pci_bus *pci_bus; +acpi_handle handle = root->device->handle; +struct pci_bus *pci_bus = root->bus;struct callback_args context; -/* If the bridge doesn't have _STA, we assume it is always there */ - status =acpi_get_handle (handle,"_STA" , &dummy_handle); -if (ACPI_SUCCESS (status)) { - status =acpi_evaluate_integer (handle,"_STA" ,NULL , &tmp); -if (ACPI_FAILURE (status)) { -info ("%s: _STA evaluation failure\n" , __func__); -return 0 ; - } -if ((tmp &ACPI_STA_DEVICE_FUNCTIONING ) ==0 ) -/* don't register this object */ -return 0 ; - } - - status =acpi_evaluate_integer (handle,"_SEG" ,NULL , &tmp); - seg =ACPI_SUCCESS (status) ? tmp :0 ; - - status =acpi_evaluate_integer (handle,"_BBN" ,NULL , &tmp); - bus =ACPI_SUCCESS (status) ? tmp :0 ; - - pci_bus =pci_find_bus (seg, bus); -if (!pci_bus) -return 0 ; - context.pci_bus = pci_bus; context.user_function = user_function; context.root_handle = handle;@@ -299,7 +274,7 @@ acpi_pci_slot_add(struct acpi_pci_root * {acpi_status status; - status =walk_root_bridge (root->device->handle, register_slot); + status =walk_root_bridge (root, register_slot);if (ACPI_FAILURE (status))err ("%s: register_slot failure - %d\n" , __func__, status);
PATCH v3 5/8 ACPI, PCI: change acpi_pci_find_root implementation
In reply to Taku IzumiThis patch changes the implementation of acpi_pci_find_root().
We can access acpi_pci_root without scanning acpi_pci_roots list. If hostbridge hotplug is supported, acpi_pci_roots list will be protected by mutex. We should not access acpi_pci_roots list if preventable to lessen deadlock risk.
--- drivers/acpi/pci_root.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/acpi/pci_root.c +8 -5
@@ -265,12 +265,15 @@ static acpi_status acpi_pci_osc_support(struct acpi_pci_root *acpi_pci_find_root (acpi_handle handle) {struct acpi_pci_root *root; +struct acpi_device *device; -list_for_each_entry (root, &acpi_pci_roots, node) { -if (root->device->handle == handle) -return root; - } -return NULL ; +if (acpi_bus_get_device (handle, &device) || +acpi_match_device_ids (device, root_device_ids)) +return NULL ; + + root =acpi_driver_data (device); + +return root; }EXPORT_SYMBOL_GPL (acpi_pci_find_root);
Bjorn Helgaas
maintainerRe: [PATCH v3 5/8] ACPI, PCI: change acpi_pci_find_root implementation
Quoted 20 lines · Taku Izumi
This patch changes the implementation of
acpi_pci_find_root().We can access
acpi_pci_rootwithout scanningacpi_pci_rootslist. If hostbridge hotplug is supported,acpi_pci_rootslist will be protected by mutex. We should not accessacpi_pci_rootslist if preventable to lessen deadlock risk.Signed-off-by Taku Izumi <[email protected]>--- drivers/acpi/pci_root.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)Index:
Bjorn-next-0903/drivers/acpi/pci_root.c
===================================================================drivers/acpi/pci_root.c +0
-0@@ -265,12 +265,15 @@ static acpi_status acpi_pci_osc_support(struct acpi_pci_root *acpi_pci_find_root (acpi_handle handle) {
drivers/acpi/pci_root.c static acpi_status acpi_pci_osc_support( · line 271
Quoted 10 lines
drivers/acpi/pci_root.c +3
-5struct acpi_pci_root *root; +struct acpi_device *device; -list_for_each_entry (root, &acpi_pci_roots, node) { -if (root->device->handle == handle) -return root; - } -return NULL ; +if (acpi_bus_get_device (handle, &device) || +acpi_match_device_ids (device, root_device_ids))
What's the purpose of the acpi_match_device_ids() check? It's not obvious, so worth calling it out in the changelog, and maybe even a comment in the code.
Nice to get rid of the list traversal.
Quoted 9 lines
drivers/acpi/pci_root.c +5
-0+return NULL ; + + root =acpi_driver_data (device); + +return root; }EXPORT_SYMBOL_GPL (acpi_pci_find_root);
Re: [PATCH v3 5/8] ACPI, PCI: change acpi_pci_find_root implementation
Quoted 24 lines · On Wed, 19 Sep 2012 16:03:27 -0600 Bjorn Helgaas <[email protected]> wrote:
Quoted 23 lines · Taku Izumi
This patch changes the implementation of
acpi_pci_find_root().We can access
acpi_pci_rootwithout scanningacpi_pci_rootslist. If hostbridge hotplug is supported,acpi_pci_rootslist will be protected by mutex. We should not accessacpi_pci_rootslist if preventable to lessen deadlock risk.Signed-off-by Taku Izumi <[email protected]>--- drivers/acpi/pci_root.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)Index:
Bjorn-next-0903/drivers/acpi/pci_root.c
===================================================================drivers/acpi/pci_root.c +1
-0@@ -265,12 +265,15 @@ static acpi_status acpi_pci_osc_support(struct acpi_pci_root *acpi_pci_find_root (acpi_handle handle) {struct acpi_pci_root *root; +struct acpi_device *device;
Quoted 11 lines
drivers/acpi/pci_root.c static acpi_status acpi_pci_osc_support( · line 271
Quoted 7 lines
drivers/acpi/pci_root.c +2
-5-list_for_each_entry (root, &acpi_pci_roots, node) { -if (root->device->handle == handle) -return root; - } -return NULL ; +if (acpi_bus_get_device (handle, &device) || +acpi_match_device_ids (device, root_device_ids))What's the purpose of the
acpi_match_device_ids()check? It's not obvious, so worth calling it out in the changelog, and maybe even a comment in the code.
My intention is to reject acpi_handle which doesn't represent hostbrige. I think this is reasonable...
Best regards,
Taku Izumi
Quoted 13 lines
Nice to get rid of the list traversal.
Quoted 9 lines
drivers/acpi/pci_root.c +5
-0+return NULL ; + + root =acpi_driver_data (device); + +return root; }EXPORT_SYMBOL_GPL (acpi_pci_find_root);
Signature · 1 line
Taku Izumi <[email protected]>
Bjorn Helgaas
maintainerRe: [PATCH v3 5/8] ACPI, PCI: change acpi_pci_find_root implementation
Quoted 39 lines · Taku Izumi
Quoted 24 lines · On Wed, 19 Sep 2012 16:03:27 -0600 Bjorn Helgaas <[email protected]> wrote:
Quoted 23 lines · Taku Izumi
This patch changes the implementation of
acpi_pci_find_root().We can access
acpi_pci_rootwithout scanningacpi_pci_rootslist. If hostbridge hotplug is supported,acpi_pci_rootslist will be protected by mutex. We should not accessacpi_pci_rootslist if preventable to lessen deadlock risk.Signed-off-by Taku Izumi <[email protected]>--- drivers/acpi/pci_root.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)Index:
Bjorn-next-0903/drivers/acpi/pci_root.c
===================================================================drivers/acpi/pci_root.c +1
-0@@ -265,12 +265,15 @@ static acpi_status acpi_pci_osc_support(struct acpi_pci_root *acpi_pci_find_root (acpi_handle handle) {struct acpi_pci_root *root; +struct acpi_device *device;Quoted 11 lines
drivers/acpi/pci_root.c static acpi_status acpi_pci_osc_support( · line 271
Quoted 7 lines
drivers/acpi/pci_root.c +2
-5-list_for_each_entry (root, &acpi_pci_roots, node) { -if (root->device->handle == handle) -return root; - } -return NULL ; +if (acpi_bus_get_device (handle, &device) || +acpi_match_device_ids (device, root_device_ids))What's the purpose of the
acpi_match_device_ids()check? It's not obvious, so worth calling it out in the changelog, and maybe even a comment in the code.
Quoted 2 lines
My intention is to reject
acpi_handlewhich doesn't represent hostbrige. I think this is reasonable...
Yes, I understand that part. I was just trying to figure out why that check is needed. Is there a path where we can call acpi_pci_find_root() with a handle that is *not* a PNP0A03 device? I looked at all the callers, and as far as I can tell, the supplied handle is always for a host bridge device.
But I guess I don't object to the check. This is just another case of a lookup that in many cases is unnecessary because we should have the struct acpi_pci_root * available already.
Quoted 17 lines
Quoted 12 lines
Nice to get rid of the list traversal.
drivers/acpi/pci_root.c static acpi_status acpi_pci_osc_support( · line 279
Quoted 9 lines
drivers/acpi/pci_root.c +5
-0+return NULL ; + + root =acpi_driver_data (device); + +return root; }EXPORT_SYMBOL_GPL (acpi_pci_find_root);--
Taku Izumi <[email protected]>
PATCH v3 6/8 ACPI, PCI: add acpi_pci_roots protection
In reply to Taku IzumiUse mutex to protect acpi_pci_roots list against PCI host bridge hotplug operations.
--- drivers/acpi/pci_root.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/acpi/pci_root.c +18 -9
@@ -112,12 +112,17 @@ EXPORT_SYMBOL(acpi_pci_unregister_driveracpi_handle acpi_get_pci_rootbridge_handle (unsigned int seg,unsigned int bus) {struct acpi_pci_root *root; +struct acpi_handle *handle =NULL ; +mutex_lock (&acpi_pci_root_lock);list_for_each_entry (root, &acpi_pci_roots, node)if ((root->segment == (u16 ) seg) && - (root->secondary.start == (u16 ) bus)) -return root->device->handle; -return NULL ; + (root->secondary.start == (u16 ) bus)) { + handle = root->device->handle; +break ; + } +mutex_unlock (&acpi_pci_root_lock); +return handle; }EXPORT_SYMBOL_GPL (acpi_get_pci_rootbridge_handle);
@@ -509,8 +514,9 @@ static int __devinit acpi_pci_root_add(s* TBD: Need PCI interface for enumeration/configuration of roots. */ -/* TBD: Locking */ +mutex_lock (&acpi_pci_root_lock);list_add_tail (&root->node, &acpi_pci_roots); +mutex_unlock (&acpi_pci_root_lock); printk(KERN_INFO PREFIX "%s [%s] (domain %04x %pR)\n", acpi_device_name(device), acpi_device_bid(device),
@@ -529,7 +535,7 @@ static int __devinit acpi_pci_root_add(s"Bus %04x:%02x not present in PCI namespace\n" , root->segment, (unsigned int)root->secondary.start); result = -ENODEV ; - goto end; + goto out_del_root; }/*
@@ -539,7 +545,7 @@ static int __devinit acpi_pci_root_add(s*/ result =acpi_pci_bind_root (device);if (result) - goto end; + goto out_del_root;/* * PCI Routing Table
@@ -617,9 +623,11 @@ static int __devinit acpi_pci_root_add(sreturn 0 ; +out_del_root: +mutex_lock (&acpi_pci_root_lock); +list_del (&root->node); +mutex_unlock (&acpi_pci_root_lock); end: -if (!list_empty (&root->node)) -list_del (&root->node);kfree (root);return result; }
@@ -649,11 +657,12 @@ static int acpi_pci_root_remove(struct alist_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->remove) driver->remove (root); -mutex_unlock (&acpi_pci_root_lock);device_set_run_wake (root->bus->bridge, false);pci_acpi_remove_bus_pm_notifier (device); +list_del (&root->node); +mutex_unlock (&acpi_pci_root_lock);kfree (root);return 0 ; }
Bjorn Helgaas
maintainerRe: [PATCH v3 6/8] ACPI, PCI: add acpi_pci_roots protection
Quoted 14 lines · Taku Izumi
Use mutex to protect
acpi_pci_rootslist against PCI host bridge hotplug operations.Signed-off-by Taku Izumi <[email protected]>--- drivers/acpi/pci_root.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)Index:
Bjorn-next-0903/drivers/acpi/pci_root.c
===================================================================
drivers/acpi/pci_root.c EXPORT_SYMBOL(acpi_pci_unregister_driver · line 115
Quoted 4 lines
drivers/acpi/pci_root.c +1
-0@@ -112,12 +112,17 @@ EXPORT_SYMBOL(acpi_pci_unregister_driveracpi_handle acpi_get_pci_rootbridge_handle (unsigned int seg,unsigned int bus) {struct acpi_pci_root *root; +struct acpi_handle *handle =NULL ;
This should be "acpi_handle handle", not "struct acpi_handle *handle".
Quoted 13 lines
drivers/acpi/pci_root.c +7
-3+mutex_lock (&acpi_pci_root_lock);list_for_each_entry (root, &acpi_pci_roots, node)if ((root->segment == (u16 ) seg) && - (root->secondary.start == (u16 ) bus)) -return root->device->handle; -return NULL ; + (root->secondary.start == (u16 ) bus)) { + handle = root->device->handle; +break ; + } +mutex_unlock (&acpi_pci_root_lock); +return handle; }
PATCH v3 7/8 ACPI, PCI: add hostbridge removal function
In reply to Taku IzumiCurrently there's no PCI-related clean-up code in acpi_pci_root_remove() function.
This patch introduces function for hostbridge removal, and brings back pci_stop_bus_devices() function.
--- drivers/acpi/pci_bind.c | 7 +++++++ drivers/acpi/pci_root.c | 7 +++++++ drivers/pci/remove.c | 27 +++++++++++++++++++++++++++ include/acpi/acpi_drivers.h | 1 + include/linux/pci.h | 2 ++ 5 files changed, 44 insertions(+)
drivers/pci/remove.c +27 -0
@@ -92,3 +92,30 @@ void pci_stop_and_remove_bus_device(strupci_destroy_dev (dev); }EXPORT_SYMBOL (pci_stop_and_remove_bus_device); + +void pci_stop_bus_devices (struct pci_bus *bus) +{ +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, &bus->devices, bus_list) { +if (dev->subordinate) +pci_stop_bus_devices (dev->subordinate); +pci_stop_dev (dev); + } + +} +EXPORT_SYMBOL (pci_stop_bus_devices); + +void pci_remove_host_bridge (struct pci_host_bridge *bridge) +{ +struct pci_bus *root = bridge->bus; +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, &root->devices, bus_list) +pci_stop_and_remove_bus_device (dev); + +pci_remove_bus (root); + +device_unregister (&bridge->dev); +} +EXPORT_SYMBOL (pci_remove_host_bridge);
drivers/acpi/pci_root.c +7 -0
@@ -652,8 +652,10 @@ static int acpi_pci_root_remove(struct a {struct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +struct pci_host_bridge *bridge =to_pci_host_bridge (root->bus->bridge);mutex_lock (&acpi_pci_root_lock); +pci_stop_bus_devices (root->bus);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->remove) driver->remove (root);
@@ -661,6 +663,11 @@ static int acpi_pci_root_remove(struct adevice_set_run_wake (root->bus->bridge, false);pci_acpi_remove_bus_pm_notifier (device); +acpi_pci_irq_del_prt (root->bus); +acpi_pci_unbind_root (device); + +pci_remove_host_bridge (bridge); +list_del (&root->node);mutex_unlock (&acpi_pci_root_lock);kfree (root);
include/linux/pci.h +2 -0
@@ -734,6 +734,8 @@ extern struct pci_dev *pci_dev_get(strucextern void pci_dev_put (struct pci_dev *dev);extern void pci_remove_bus (struct pci_bus *b);extern void pci_stop_and_remove_bus_device (struct pci_dev *dev); +extern void pci_stop_bus_devices (struct pci_bus *bus); +extern void pci_remove_host_bridge (struct pci_host_bridge *bridge);void pci_setup_cardbus (struct pci_bus *bus);extern void pci_sort_breadthfirst (void );#define dev_is_pci (d) ((d)->bus == &pci_bus_type)
drivers/acpi/pci_bind.c +7 -0
@@ -118,3 +118,10 @@ int acpi_pci_bind_root(struct acpi_devicreturn 0 ; } + +void acpi_pci_unbind_root (struct acpi_device *device) +{ + device->ops.bind =NULL ; + device->ops.unbind =NULL ; +} +
include/acpi/acpi_drivers.h +1 -0
@@ -101,6 +101,7 @@ struct pci_bus;struct pci_dev *acpi_get_pci_dev (acpi_handle );int acpi_pci_bind_root (struct acpi_device *device); +void acpi_pci_unbind_root (struct acpi_device *device);/* Arch-defined function to add a bus to the system */
Bjorn Helgaas
maintainerRe: [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
Quoted 66 lines · Taku Izumi
Currently there's no PCI-related clean-up code in
acpi_pci_root_remove()function.
This patch introduces function for hostbridge removal, and brings backpci_stop_bus_devices()function.Signed-off-by Taku Izumi <[email protected]>--- drivers/acpi/pci_bind.c | 7 +++++++ drivers/acpi/pci_root.c | 7 +++++++ drivers/pci/remove.c | 27 +++++++++++++++++++++++++++ include/acpi/acpi_drivers.h | 1 + include/linux/pci.h | 2 ++ 5 files changed, 44 insertions(+)Index:
Bjorn-next-0903/drivers/pci/remove.c
===================================================================drivers/pci/remove.c +27
-0@@ -92,3 +92,30 @@ void pci_stop_and_remove_bus_device(strupci_destroy_dev (dev); }EXPORT_SYMBOL (pci_stop_and_remove_bus_device); + +void pci_stop_bus_devices (struct pci_bus *bus) +{ +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, &bus->devices, bus_list) { +if (dev->subordinate) +pci_stop_bus_devices (dev->subordinate); +pci_stop_dev (dev); + } + +} +EXPORT_SYMBOL (pci_stop_bus_devices); + +void pci_remove_host_bridge (struct pci_host_bridge *bridge) +{ +struct pci_bus *root = bridge->bus; +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, &root->devices, bus_list) +pci_stop_and_remove_bus_device (dev); + +pci_remove_bus (root); + +device_unregister (&bridge->dev); +} +EXPORT_SYMBOL (pci_remove_host_bridge);Index:
Bjorn-next-0903/drivers/acpi/pci_root.c
===================================================================drivers/acpi/pci_root.c +2
-0@@ -652,8 +652,10 @@ static int acpi_pci_root_remove(struct a {struct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +struct pci_host_bridge *bridge =to_pci_host_bridge (root->bus->bridge);mutex_lock (&acpi_pci_root_lock); +pci_stop_bus_devices (root->bus);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->remove) driver->remove (root);
drivers/acpi/pci_root.c static int acpi_pci_root_remove(struct a · line 666
Quoted 4 lines
drivers/acpi/pci_root.c +1
-0@@ -661,6 +663,11 @@ static int acpi_pci_root_remove(struct adevice_set_run_wake (root->bus->bridge, false);pci_acpi_remove_bus_pm_notifier (device); +acpi_pci_irq_del_prt (root->bus);
acpi_pci_irq_del_prt() does not actually have a dependency on the struct pci_bus, so I think its interface should be changed so it takes a segment number and a bus number instead of the "struct pci_bus *". The same applies to acpi_pci_irq_add_prt().
This basically boils down to reverting 859a3f86ca8 and d9efae3688a. I acked those changes at the time, but I think they were a mistake. The reason is that passing in the struct pci_bus * ties them into the host bridge add/remove flow in a way that's not necessary.
If we get rid of the struct pci_bus * dependency, then we can easily add the _PRT before doing PCI enumeration behind the bridge, and we can remove the _PRT after removing the PCI devices. I think this is one small step toward getting rid of the add/start and stop/remove split.
Quoted 48 lines
drivers/acpi/pci_root.c +4
-0+acpi_pci_unbind_root (device); + +pci_remove_host_bridge (bridge); +list_del (&root->node);mutex_unlock (&acpi_pci_root_lock);kfree (root);Index:
Bjorn-next-0903/include/linux/pci.h
===================================================================include/linux/pci.h +2
-0@@ -734,6 +734,8 @@ extern struct pci_dev *pci_dev_get(strucextern void pci_dev_put (struct pci_dev *dev);extern void pci_remove_bus (struct pci_bus *b);extern void pci_stop_and_remove_bus_device (struct pci_dev *dev); +extern void pci_stop_bus_devices (struct pci_bus *bus); +extern void pci_remove_host_bridge (struct pci_host_bridge *bridge);void pci_setup_cardbus (struct pci_bus *bus);extern void pci_sort_breadthfirst (void );#define dev_is_pci (d) ((d)->bus == &pci_bus_type)Index:
Bjorn-next-0903/drivers/acpi/pci_bind.c
===================================================================drivers/acpi/pci_bind.c +7
-0@@ -118,3 +118,10 @@ int acpi_pci_bind_root(struct acpi_devicreturn 0 ; } + +void acpi_pci_unbind_root (struct acpi_device *device) +{ + device->ops.bind =NULL ; + device->ops.unbind =NULL ; +} +Index:
Bjorn-next-0903/include/acpi/acpi_drivers.h
===================================================================include/acpi/acpi_drivers.h +1
-0@@ -101,6 +101,7 @@ struct pci_bus;struct pci_dev *acpi_get_pci_dev (acpi_handle );int acpi_pci_bind_root (struct acpi_device *device); +void acpi_pci_unbind_root (struct acpi_device *device);/* Arch-defined function to add a bus to the system */
Bjorn Helgaas
maintainerRe: [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
Quoted 82 lines · Bjorn Helgaas
Quoted 66 lines · Taku Izumi
Currently there's no PCI-related clean-up code in
acpi_pci_root_remove()function.
This patch introduces function for hostbridge removal, and brings backpci_stop_bus_devices()function.Signed-off-by Taku Izumi <[email protected]>--- drivers/acpi/pci_bind.c | 7 +++++++ drivers/acpi/pci_root.c | 7 +++++++ drivers/pci/remove.c | 27 +++++++++++++++++++++++++++ include/acpi/acpi_drivers.h | 1 + include/linux/pci.h | 2 ++ 5 files changed, 44 insertions(+)Index:
Bjorn-next-0903/drivers/pci/remove.c
===================================================================drivers/pci/remove.c +27
-0@@ -92,3 +92,30 @@ void pci_stop_and_remove_bus_device(strupci_destroy_dev (dev); }EXPORT_SYMBOL (pci_stop_and_remove_bus_device); + +void pci_stop_bus_devices (struct pci_bus *bus) +{ +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, &bus->devices, bus_list) { +if (dev->subordinate) +pci_stop_bus_devices (dev->subordinate); +pci_stop_dev (dev); + } + +} +EXPORT_SYMBOL (pci_stop_bus_devices); + +void pci_remove_host_bridge (struct pci_host_bridge *bridge) +{ +struct pci_bus *root = bridge->bus; +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, &root->devices, bus_list) +pci_stop_and_remove_bus_device (dev); + +pci_remove_bus (root); + +device_unregister (&bridge->dev); +} +EXPORT_SYMBOL (pci_remove_host_bridge);Index:
Bjorn-next-0903/drivers/acpi/pci_root.c
===================================================================drivers/acpi/pci_root.c +2
-0@@ -652,8 +652,10 @@ static int acpi_pci_root_remove(struct a {struct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +struct pci_host_bridge *bridge =to_pci_host_bridge (root->bus->bridge);mutex_lock (&acpi_pci_root_lock); +pci_stop_bus_devices (root->bus);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->remove) driver->remove (root);drivers/acpi/pci_root.c static int acpi_pci_root_remove(struct a · line 666
Quoted 4 lines
drivers/acpi/pci_root.c +1
-0@@ -661,6 +663,11 @@ static int acpi_pci_root_remove(struct adevice_set_run_wake (root->bus->bridge, false);pci_acpi_remove_bus_pm_notifier (device); +acpi_pci_irq_del_prt (root->bus);
acpi_pci_irq_del_prt()does not actually have a dependency on the structpci_bus, so I think its interface should be changed so it takes a segment number and a bus number instead of the "structpci_bus*". The same applies toacpi_pci_irq_add_prt().This basically boils down to reverting
859a3f86ca8andd9efae3688a. I acked those changes at the time, but I think they were a mistake. The reason is that passing in the structpci_bus* ties them into the host bridge add/remove flow in a way that's not necessary.
Quoted 5 lines
If we get rid of the struct
pci_bus* dependency, then we can easily add the_PRTbefore doing PCI enumeration behind the bridge, and we can remove the_PRTafter removing the PCI devices. I think this is one small step toward getting rid of the add/start and stop/remove split.
I'm going to work on doing this if nobody else is interested.
Quoted 48 lines
Quoted 48 lines
drivers/acpi/pci_root.c +4
-0+acpi_pci_unbind_root (device); + +pci_remove_host_bridge (bridge); +list_del (&root->node);mutex_unlock (&acpi_pci_root_lock);kfree (root);Index:
Bjorn-next-0903/include/linux/pci.h
===================================================================include/linux/pci.h +2
-0@@ -734,6 +734,8 @@ extern struct pci_dev *pci_dev_get(strucextern void pci_dev_put (struct pci_dev *dev);extern void pci_remove_bus (struct pci_bus *b);extern void pci_stop_and_remove_bus_device (struct pci_dev *dev); +extern void pci_stop_bus_devices (struct pci_bus *bus); +extern void pci_remove_host_bridge (struct pci_host_bridge *bridge);void pci_setup_cardbus (struct pci_bus *bus);extern void pci_sort_breadthfirst (void );#define dev_is_pci (d) ((d)->bus == &pci_bus_type)Index:
Bjorn-next-0903/drivers/acpi/pci_bind.c
===================================================================drivers/acpi/pci_bind.c +7
-0@@ -118,3 +118,10 @@ int acpi_pci_bind_root(struct acpi_devicreturn 0 ; } + +void acpi_pci_unbind_root (struct acpi_device *device) +{ + device->ops.bind =NULL ; + device->ops.unbind =NULL ; +} +Index:
Bjorn-next-0903/include/acpi/acpi_drivers.h
===================================================================include/acpi/acpi_drivers.h +1
-0@@ -101,6 +101,7 @@ struct pci_bus;struct pci_dev *acpi_get_pci_dev (acpi_handle );int acpi_pci_bind_root (struct acpi_device *device); +void acpi_pci_unbind_root (struct acpi_device *device);/* Arch-defined function to add a bus to the system */
Re: [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
Quoted 8 lines · Bjorn Helgaas
Quoted 5 lines · Bjorn Helgaas
If we get rid of the struct
pci_bus* dependency, then we can easily add the_PRTbefore doing PCI enumeration behind the bridge, and we can remove the_PRTafter removing the PCI devices. I think this is one small step toward getting rid of the add/start and stop/remove split.I'm going to work on doing this if nobody else is interested.
I'm not sure if that is needed.
-Yinghai
Re: [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
Quoted 11 lines · Yinghai Lu
Quoted 8 lines · Bjorn Helgaas
Quoted 5 lines · Bjorn Helgaas
If we get rid of the struct
pci_bus* dependency, then we can easily add the_PRTbefore doing PCI enumeration behind the bridge, and we can remove the_PRTafter removing the PCI devices. I think this is one small step toward getting rid of the add/start and stop/remove split.I'm going to work on doing this if nobody else is interested.
I'm not sure if that is needed.
After patches that is using pci_host_bridge_bus_type and pci_bus_type notification, we can removeacpi_pci_root_start.
please check patches in my for-pci-next branch: it include jiang's 7 patches about notifier, and my kill pci_root_buses and etc.
git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git
for-pci-next
-Yinghai
Bjorn Helgaas
maintainerRe: [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
In reply to Yinghai LuQuoted 11 lines · Yinghai Lu
Quoted 8 lines · Bjorn Helgaas
Quoted 5 lines · Bjorn Helgaas
If we get rid of the struct
pci_bus* dependency, then we can easily add the_PRTbefore doing PCI enumeration behind the bridge, and we can remove the_PRTafter removing the PCI devices. I think this is one small step toward getting rid of the add/start and stop/remove split.I'm going to work on doing this if nobody else is interested.
I'm not sure if that is needed.
That's a useless response. Do you want to elaborate on *why* you think this is a bad idea?
I explained the reasons why I think it's a good idea above, but just to expand on it, we currently have to create the struct pci_bus before
we can add _PRT information. But adding the _PRT info doesn't
actually depend on the struct pci_bus; it only requires the segment number and the bus number. We have that information before we scan the bus .
I think it's useful to disentangle _PRT interface from the specifics of PCI (in this case, the struct pci_bus). We're currently using the struct pci_bus here just as a convenient way to pass around the segment/bus number, but I don't think it's the appropriate abstraction for that.
Do you see a technical problem with it? Even if it's not *necessary* in order to make host bridge hotplug work, I think it's worth doing to make the code more understandable.
Do you see a problem with adding the _PRT info before scanning the bus or with removing it after deleting the bus? I'd like the bus scan code to be able to scan/add/bind drivers all at once in the PCI core. Today I think we have scan/add _PRT/device_add, where we have to do this _PRT stuff in the middle, so we have to use two PCI interfaces rather than one.
It's great if you see a way to remove acpi_pci_root_start() -- that will be tremendous. I think the current PCI stop/remove split is a similar issue, and I hope you can dream up a way to consolidate those, too.
Bjorn
Re: [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
Quoted 5 lines · Bjorn Helgaas
Quoted 2 lines
I'm not sure if that is needed.
That's a useless response. Do you want to elaborate on *why* you think this is a bad idea?
I did not say that is bad idea.
it is just not needed to waste your time.
Quoted 14 lines
I explained the reasons why I think it's a good idea above, but just to expand on it, we currently have to create the struct
pci_busbefore
we can add_PRTinformation. But adding the_PRTinfo doesn't
actually depend on the structpci_bus; it only requires the segment number and the bus number. We have that information before we scan the bus .I think it's useful to disentangle
_PRTinterface from the specifics of PCI (in this case, the structpci_bus). We're currently using the structpci_bushere just as a convenient way to pass around the segment/bus number, but I don't think it's the appropriate abstraction for that.
Quoted 6 lines
Do you see a technical problem with it? Even if it's not *necessary* in order to make host bridge hotplug work, I think it's worth doing to make the code more understandable.
Do you see a problem with adding the
_PRTinfo before scanning the bus or with removing it after deleting the bus?
If the bus is not there, do not need that prt.
So if you find the prt and add it to the list before, later if scanning fail etc failing path
you will need to clean that prt in the list.
Quoted 5 lines
I'd like the bus scan
code to be able to scan/add/bind drivers all at once in the PCI core. Today I think we have scan/add _PRT/device_add, where we have to do this_PRTstuff in the middle, so we have to use two PCI interfaces rather than one.
looks like we handle _PRT in pci_host_bridge add/remove notification, just like Jiang's put that for pci device bus notifier.
Quoted 3 lines
It's great if you see a way to remove
acpi_pci_root_start()-- that will be tremendous.
that will need to more test.
Quoted 3 lines
I think the current PCI stop/remove split is a
similar issue, and I hope you can dream up a way to consolidate those, too.
that is SRIOV handling resign.
I would suggest following way:
use pf as parent for one new domain. and put all VFs on that domain. and the domain could have 256 buses for those VFs.
and we have 16 bits domain number that could be used.
current got too many patches in my quilt... hate to keep rebasing again.
after pci root bus hotplug and for_each_res topic, will work on that SRIOV one.
-Yinghai
Bjorn Helgaas
maintainerRe: [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
Quoted 19 lines · Yinghai Lu
Quoted 17 lines · Bjorn Helgaas
I explained the reasons why I think it's a good idea above, but just to expand on it, we currently have to create the struct
pci_busbefore
we can add_PRTinformation. But adding the_PRTinfo doesn't
actually depend on the structpci_bus; it only requires the segment number and the bus number. We have that information before we scan the bus .I think it's useful to disentangle
_PRTinterface from the specifics of PCI (in this case, the structpci_bus). We're currently using the structpci_bushere just as a convenient way to pass around the segment/bus number, but I don't think it's the appropriate abstraction for that.Do you see a technical problem with it? Even if it's not *necessary* in order to make host bridge hotplug work, I think it's worth doing to make the code more understandable.
Quoted 8 lines
Quoted 2 lines
Do you see a problem with adding the
_PRTinfo before scanning the bus or with removing it after deleting the bus?If the bus is not there, do not need that prt.
So if you find the prt and add it to the list before, later if scanning fail etc failing path
you will need to clean that prt in the list.
That's true. It will add a little bit to the failure paths in acpi_pci_root_add(), but I don't think that's much of an issue.
Quoted 5 lines
Quoted 5 lines
I'd like the bus scan
code to be able to scan/add/bind drivers all at once in the PCI core. Today I think we have scan/add _PRT/device_add, where we have to do this_PRTstuff in the middle, so we have to use two PCI interfaces rather than one.
This is the more important bit. My longer-term goal is to separate out the ACPI parts from the PCI parts. Then we can use more generic code for the PCI part, which will help unify the architectures.
Today we have this, which is more complicated than it should be. Note how we do some ACPI stuff, some PCI stuff, some more ACPI stuff, then more PCI stuff:
acpi_pci_root_add
pci_acpi_scan_root
pci_scan_child_bus
acpi_pci_irq_add_prt
acpi_pci_osc_control_set
acpi_pci_root_start
pci_bus_add_devices
I don't think the ACPI/PCI mixture is anything essential dictated by the way the hardware or firmware works. I think it's just an artifact of the current design, and it could be changed. It would be better to have this:
acpi_pci_root_add
acpi_pci_irq_add_prt
acpi_pci_osc_control_set
pci_acpi_scan_root
pci_scan_root_bus
pci_scan_child_bus
pci_bus_add_devices
We can't get to this latter strategy as long as the ACPI interfaces depend on the struct pci_bus. So the _PRT change is a small thing in itself, but I do think it helps enable significant improvements in the future.
Bjorn
Re: [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
Quoted 26 lines · Bjorn Helgaas
On Thu, Sep 27, 2012 at 2:17 PM, Yinghai Lu <[email protected]> wrote:
Today we have this, which is more complicated than it should be. Note how we do some ACPI stuff, some PCI stuff, some more ACPI stuff, then more PCI stuff:
acpi_pci_root_add
pci_acpi_scan_root
pci_scan_child_bus
acpi_pci_irq_add_prt
acpi_pci_osc_control_set
acpi_pci_root_start
pci_bus_add_devicesI don't think the ACPI/PCI mixture is anything essential dictated by the way the hardware or firmware works. I think it's just an artifact of the current design, and it could be changed. It would be better to have this:
acpi_pci_root_add
acpi_pci_irq_add_prt
acpi_pci_osc_control_set
pci_acpi_scan_root
pci_scan_root_bus
pci_scan_child_bus
pci_bus_add_devices
Quoted 4 lines
We can't get to this latter strategy as long as the ACPI interfaces depend on the struct
pci_bus. So the_PRTchange is a small thing in itself, but I do think it helps enable significant improvements in the future.
still to handle to those fallback path like create_bus and scan bus failure.
in my for-pci-next branch, with Jiang's patches and mine, now we achieved at
acpi_pci_root_add
pci_acpi_scan_root
pci_scan_root_bus
pci_scan_child_bus
acpi_pci_osc_control_set
pci_bus_add_devices
acpi_pci_irq_add_prt is called later during acpi binding that is triggered by adding to device tree.
thought os_control set via pci_host_bridge add interface..
with those BUS ADD notification, we can pass bus safely, and without considering about cleanup PRT and OSC setting.
Bjorn Helgaas
maintainerRe: [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
Quoted 43 lines · Yinghai Lu
Quoted 26 lines · Bjorn Helgaas
On Thu, Sep 27, 2012 at 2:17 PM, Yinghai Lu <[email protected]> wrote:
Today we have this, which is more complicated than it should be. Note how we do some ACPI stuff, some PCI stuff, some more ACPI stuff, then more PCI stuff:
acpi_pci_root_add
pci_acpi_scan_root
pci_scan_child_bus
acpi_pci_irq_add_prt
acpi_pci_osc_control_set
acpi_pci_root_start
pci_bus_add_devicesI don't think the ACPI/PCI mixture is anything essential dictated by the way the hardware or firmware works. I think it's just an artifact of the current design, and it could be changed. It would be better to have this:
acpi_pci_root_add
acpi_pci_irq_add_prt
acpi_pci_osc_control_set
pci_acpi_scan_root
pci_scan_root_bus
pci_scan_child_bus
pci_bus_add_devicesQuoted 4 lines
We can't get to this latter strategy as long as the ACPI interfaces depend on the struct
pci_bus. So the_PRTchange is a small thing in itself, but I do think it helps enable significant improvements in the future.still to handle to those fallback path like
create_busand scan bus failure.in my for-pci-next branch, with Jiang's patches and mine, now we achieved at
acpi_pci_root_add
pci_acpi_scan_root
pci_scan_root_bus
pci_scan_child_bus
acpi_pci_osc_control_set
pci_bus_add_devices
Quoted 6 lines
acpi_pci_irq_add_prtis called later during acpi binding that is triggered by adding to device tree.
thoughtos_controlset viapci_host_bridgeadd interface..with those BUS ADD notification, we can pass bus safely, and without considering about cleanup PRT and OSC setting.
I haven't looked at those patches yet.
Is there a reason why acpi_pci_osc_control_set() needs to be done after pci_scan_child_bus()? The argument that it might make the error path somewhat simpler is not very convincing to me. Having the arch code call both pci_scan_child_bus() and pci_bus_add_devices() is a much more fundamental complexity -- it makes x86 and ia64 different from many architectures, and it exposes the intermediate state where "devices have been enumerated but not added" to a lot more code.
It doesn't sound like an improvement to call acpi_pci_irq_add_prt() using a bus add notifier. At least for the host bridge case, it's clear, simple, and straightforward to call it in acpi_pci_root_add(). Notifiers are useful in some cases, but they definitely make the code harder to follow.
Re: [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
In reply to Bjorn HelgaasQuoted 83 lines · On Thu, 27 Sep 2012 10:48:09 -0600 Bjorn Helgaas <[email protected]> wrote:
Quoted 82 lines · Bjorn Helgaas
Quoted 66 lines · Taku Izumi
Currently there's no PCI-related clean-up code in
acpi_pci_root_remove()function.
This patch introduces function for hostbridge removal, and brings backpci_stop_bus_devices()function.Signed-off-by Taku Izumi <[email protected]>--- drivers/acpi/pci_bind.c | 7 +++++++ drivers/acpi/pci_root.c | 7 +++++++ drivers/pci/remove.c | 27 +++++++++++++++++++++++++++ include/acpi/acpi_drivers.h | 1 + include/linux/pci.h | 2 ++ 5 files changed, 44 insertions(+)Index:
Bjorn-next-0903/drivers/pci/remove.c
===================================================================drivers/pci/remove.c +27
-0@@ -92,3 +92,30 @@ void pci_stop_and_remove_bus_device(strupci_destroy_dev (dev); }EXPORT_SYMBOL (pci_stop_and_remove_bus_device); + +void pci_stop_bus_devices (struct pci_bus *bus) +{ +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, &bus->devices, bus_list) { +if (dev->subordinate) +pci_stop_bus_devices (dev->subordinate); +pci_stop_dev (dev); + } + +} +EXPORT_SYMBOL (pci_stop_bus_devices); + +void pci_remove_host_bridge (struct pci_host_bridge *bridge) +{ +struct pci_bus *root = bridge->bus; +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, &root->devices, bus_list) +pci_stop_and_remove_bus_device (dev); + +pci_remove_bus (root); + +device_unregister (&bridge->dev); +} +EXPORT_SYMBOL (pci_remove_host_bridge);Index:
Bjorn-next-0903/drivers/acpi/pci_root.c
===================================================================drivers/acpi/pci_root.c +2
-0@@ -652,8 +652,10 @@ static int acpi_pci_root_remove(struct a {struct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +struct pci_host_bridge *bridge =to_pci_host_bridge (root->bus->bridge);mutex_lock (&acpi_pci_root_lock); +pci_stop_bus_devices (root->bus);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->remove) driver->remove (root);drivers/acpi/pci_root.c static int acpi_pci_root_remove(struct a · line 666
Quoted 4 lines
drivers/acpi/pci_root.c +1
-0@@ -661,6 +663,11 @@ static int acpi_pci_root_remove(struct adevice_set_run_wake (root->bus->bridge, false);pci_acpi_remove_bus_pm_notifier (device); +acpi_pci_irq_del_prt (root->bus);
acpi_pci_irq_del_prt()does not actually have a dependency on the structpci_bus, so I think its interface should be changed so it takes a segment number and a bus number instead of the "structpci_bus*". The same applies toacpi_pci_irq_add_prt().This basically boils down to reverting
859a3f86ca8andd9efae3688a. I acked those changes at the time, but I think they were a mistake. The reason is that passing in the structpci_bus* ties them into the host bridge add/remove flow in a way that's not necessary.
Quoted 7 lines
Quoted 5 lines
If we get rid of the struct
pci_bus* dependency, then we can easily add the_PRTbefore doing PCI enumeration behind the bridge, and we can remove the_PRTafter removing the PCI devices. I think this is one small step toward getting rid of the add/start and stop/remove split.I'm going to work on doing this if nobody else is interested.
I'll do that. Maybee that is separeted from this patchset.
Best regards,
Taku Izumi
Quoted 50 lines
Quoted 49 lines
Quoted 49 lines
drivers/acpi/pci_root.c +4
-0+acpi_pci_unbind_root (device); + +pci_remove_host_bridge (bridge); +list_del (&root->node);mutex_unlock (&acpi_pci_root_lock);kfree (root);Index:
Bjorn-next-0903/include/linux/pci.h
===================================================================include/linux/pci.h +2
-0@@ -734,6 +734,8 @@ extern struct pci_dev *pci_dev_get(strucextern void pci_dev_put (struct pci_dev *dev);extern void pci_remove_bus (struct pci_bus *b);extern void pci_stop_and_remove_bus_device (struct pci_dev *dev); +extern void pci_stop_bus_devices (struct pci_bus *bus); +extern void pci_remove_host_bridge (struct pci_host_bridge *bridge);void pci_setup_cardbus (struct pci_bus *bus);extern void pci_sort_breadthfirst (void );#define dev_is_pci (d) ((d)->bus == &pci_bus_type)Index:
Bjorn-next-0903/drivers/acpi/pci_bind.c
===================================================================drivers/acpi/pci_bind.c +7
-0@@ -118,3 +118,10 @@ int acpi_pci_bind_root(struct acpi_devicreturn 0 ; } + +void acpi_pci_unbind_root (struct acpi_device *device) +{ + device->ops.bind =NULL ; + device->ops.unbind =NULL ; +} +Index:
Bjorn-next-0903/include/acpi/acpi_drivers.h
===================================================================include/acpi/acpi_drivers.h +1
-0@@ -101,6 +101,7 @@ struct pci_bus;struct pci_dev *acpi_get_pci_dev (acpi_handle );int acpi_pci_bind_root (struct acpi_device *device); +void acpi_pci_unbind_root (struct acpi_device *device);/* Arch-defined function to add a bus to the system */
Signature · 1 line
Taku Izumi <[email protected]>
Bjorn Helgaas
maintainerRe: [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
Quoted 92 lines · Taku Izumi
Quoted 89 lines · On Thu, 27 Sep 2012 10:48:09 -0600 Bjorn Helgaas <[email protected]> wrote:
Quoted 87 lines · Bjorn Helgaas
Quoted 66 lines · Taku Izumi
Currently there's no PCI-related clean-up code in
acpi_pci_root_remove()function.
This patch introduces function for hostbridge removal, and brings backpci_stop_bus_devices()function.Signed-off-by Taku Izumi <[email protected]>--- drivers/acpi/pci_bind.c | 7 +++++++ drivers/acpi/pci_root.c | 7 +++++++ drivers/pci/remove.c | 27 +++++++++++++++++++++++++++ include/acpi/acpi_drivers.h | 1 + include/linux/pci.h | 2 ++ 5 files changed, 44 insertions(+)Index:
Bjorn-next-0903/drivers/pci/remove.c
===================================================================drivers/pci/remove.c +27
-0@@ -92,3 +92,30 @@ void pci_stop_and_remove_bus_device(strupci_destroy_dev (dev); }EXPORT_SYMBOL (pci_stop_and_remove_bus_device); + +void pci_stop_bus_devices (struct pci_bus *bus) +{ +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, &bus->devices, bus_list) { +if (dev->subordinate) +pci_stop_bus_devices (dev->subordinate); +pci_stop_dev (dev); + } + +} +EXPORT_SYMBOL (pci_stop_bus_devices); + +void pci_remove_host_bridge (struct pci_host_bridge *bridge) +{ +struct pci_bus *root = bridge->bus; +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, &root->devices, bus_list) +pci_stop_and_remove_bus_device (dev); + +pci_remove_bus (root); + +device_unregister (&bridge->dev); +} +EXPORT_SYMBOL (pci_remove_host_bridge);Index:
Bjorn-next-0903/drivers/acpi/pci_root.c
===================================================================drivers/acpi/pci_root.c +2
-0@@ -652,8 +652,10 @@ static int acpi_pci_root_remove(struct a {struct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +struct pci_host_bridge *bridge =to_pci_host_bridge (root->bus->bridge);mutex_lock (&acpi_pci_root_lock); +pci_stop_bus_devices (root->bus);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->remove) driver->remove (root);drivers/acpi/pci_root.c static int acpi_pci_root_remove(struct a · line 666
Quoted 4 lines
drivers/acpi/pci_root.c +1
-0@@ -661,6 +663,11 @@ static int acpi_pci_root_remove(struct adevice_set_run_wake (root->bus->bridge, false);pci_acpi_remove_bus_pm_notifier (device); +acpi_pci_irq_del_prt (root->bus);
acpi_pci_irq_del_prt()does not actually have a dependency on the structpci_bus, so I think its interface should be changed so it takes a segment number and a bus number instead of the "structpci_bus*". The same applies toacpi_pci_irq_add_prt().This basically boils down to reverting
859a3f86ca8andd9efae3688a. I acked those changes at the time, but I think they were a mistake. The reason is that passing in the structpci_bus* ties them into the host bridge add/remove flow in a way that's not necessary.If we get rid of the struct
pci_bus* dependency, then we can easily add the_PRTbefore doing PCI enumeration behind the bridge, and we can remove the_PRTafter removing the PCI devices. I think this is one small step toward getting rid of the add/start and stop/remove split.
Quoted 3 lines
Quoted 1 line
I'm going to work on doing this if nobody else is interested.
I'll do that. Maybee that is separeted from this patchset.
Great, thanks! A separate patchset is definitely fine.
Quoted 54 lines
Quoted 41 lines
Quoted 41 lines
Quoted 41 lines
drivers/acpi/pci_root.c +4
-0+acpi_pci_unbind_root (device); + +pci_remove_host_bridge (bridge); +list_del (&root->node);mutex_unlock (&acpi_pci_root_lock);kfree (root);Index:
Bjorn-next-0903/include/linux/pci.h
===================================================================include/linux/pci.h +2
-0@@ -734,6 +734,8 @@ extern struct pci_dev *pci_dev_get(strucextern void pci_dev_put (struct pci_dev *dev);extern void pci_remove_bus (struct pci_bus *b);extern void pci_stop_and_remove_bus_device (struct pci_dev *dev); +extern void pci_stop_bus_devices (struct pci_bus *bus); +extern void pci_remove_host_bridge (struct pci_host_bridge *bridge);void pci_setup_cardbus (struct pci_bus *bus);extern void pci_sort_breadthfirst (void );#define dev_is_pci (d) ((d)->bus == &pci_bus_type)Index:
Bjorn-next-0903/drivers/acpi/pci_bind.c
===================================================================drivers/acpi/pci_bind.c +7
-0@@ -118,3 +118,10 @@ int acpi_pci_bind_root(struct acpi_devicreturn 0 ; } + +void acpi_pci_unbind_root (struct acpi_device *device) +{ + device->ops.bind =NULL ; + device->ops.unbind =NULL ; +} +Index:
Bjorn-next-0903/include/acpi/acpi_drivers.h
===================================================================include/acpi/acpi_drivers.h +0
-0@@ -101,6 +101,7 @@ struct pci_bus;Quoted 8 lines
Quoted 7 lines
include/acpi/acpi_drivers.h struct pci_bus; · line 107
Quoted 7 lines
include/acpi/acpi_drivers.h +1
-0struct pci_dev *acpi_get_pci_dev (acpi_handle );int acpi_pci_bind_root (struct acpi_device *device); +void acpi_pci_unbind_root (struct acpi_device *device);/* Arch-defined function to add a bus to the system */ --
Taku Izumi <[email protected]>
Bjorn Helgaas
maintainerRe: [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
Quoted 29 lines · Bjorn Helgaas
Quoted 28 lines · Taku Izumi
Quoted 25 lines · On Thu, 27 Sep 2012 10:48:09 -0600 Bjorn Helgaas <[email protected]> wrote:
Quoted 23 lines · Bjorn Helgaas
drivers/acpi/pci_root.c static int acpi_pci_root_remove(struct a · line 666
Quoted 5 lines · Taku Izumi
drivers/acpi/pci_root.c +1
-0@@ -661,6 +663,11 @@ static int acpi_pci_root_remove(struct adevice_set_run_wake (root->bus->bridge, false);pci_acpi_remove_bus_pm_notifier (device); +acpi_pci_irq_del_prt (root->bus);
acpi_pci_irq_del_prt()does not actually have a dependency on the structpci_bus, so I think its interface should be changed so it takes a segment number and a bus number instead of the "structpci_bus*". The same applies toacpi_pci_irq_add_prt().This basically boils down to reverting
859a3f86ca8andd9efae3688a. I acked those changes at the time, but I think they were a mistake. The reason is that passing in the structpci_bus* ties them into the host bridge add/remove flow in a way that's not necessary.If we get rid of the struct
pci_bus* dependency, then we can easily add the_PRTbefore doing PCI enumeration behind the bridge, and we can remove the_PRTafter removing the PCI devices. I think this is one small step toward getting rid of the add/start and stop/remove split.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
I'm going to work on doing this if nobody else is interested.
I'll do that. Maybee that is separeted from this patchset.
Great, thanks! A separate patchset is definitely fine.
Whether this is a waste of time or not, I don't know. But I did a little bit of work on this before you volunteered, Taku. Sorry, I should have pointed you at the work-in-progress patches; maybe they could have saved you a bit of time. Anyway, here they are:
http://git.kernel.org/?p=linux/kernel/git/helgaas/pci.git;a=shortlog;h=refs/heads/pci/bjorn-misc
Re: [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
In reply to Bjorn HelgaasCurrently there's no PCI-related clean-up code in acpi_pci_root_remove() function.
This patch introduces function for hostbridge removal, and brings back pci_stop_bus_devices() function.
diff: rebased against current next
updated according to Bjorn's comment
--- drivers/acpi/pci_bind.c | 7 +++++++ drivers/acpi/pci_root.c | 6 ++++++ drivers/pci/remove.c | 28 ++++++++++++++++++++++++++++ include/acpi/acpi_drivers.h | 1 + include/linux/pci.h | 2 ++ 5 files changed, 44 insertions(+)
drivers/pci/remove.c +28 -0
@@ -111,3 +111,31 @@ void pci_stop_and_remove_bus_device(strupci_remove_bus_device (dev); }EXPORT_SYMBOL (pci_stop_and_remove_bus_device); + +void pci_stop_bus_devices (struct pci_bus *bus) +{ +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, + &bus->devices, bus_list) { +pci_stop_bus_device (dev); + } + +} +EXPORT_SYMBOL (pci_stop_bus_devices); + +void pci_remove_host_bridge (struct pci_host_bridge *bridge) +{ +struct pci_bus *root = bridge->bus; +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, + &root->devices, bus_list) { +pci_remove_bus_device (dev); + } + +pci_remove_bus (root); + +device_unregister (&bridge->dev); +} +EXPORT_SYMBOL (pci_remove_host_bridge);
drivers/acpi/pci_root.c +6 -0
@@ -659,8 +659,10 @@ static int acpi_pci_root_remove(struct a {struct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +struct pci_host_bridge *bridge =to_pci_host_bridge (root->bus->bridge);mutex_lock (&acpi_pci_root_lock); +pci_stop_bus_devices (root->bus);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->remove) driver->remove (root);
@@ -668,6 +670,10 @@ static int acpi_pci_root_remove(struct adevice_set_run_wake (root->bus->bridge, false);pci_acpi_remove_bus_pm_notifier (device); +acpi_pci_unbind_root (device); + +pci_remove_host_bridge (bridge); +list_del (&root->node);mutex_unlock (&acpi_pci_root_lock);kfree (root);
include/linux/pci.h +2 -0
@@ -734,6 +734,8 @@ extern struct pci_dev *pci_dev_get(strucextern void pci_dev_put (struct pci_dev *dev);extern void pci_remove_bus (struct pci_bus *b);extern void pci_stop_and_remove_bus_device (struct pci_dev *dev); +extern void pci_stop_bus_devices (struct pci_bus *bus); +extern void pci_remove_host_bridge (struct pci_host_bridge *bridge);void pci_setup_cardbus (struct pci_bus *bus);extern void pci_sort_breadthfirst (void );#define dev_is_pci (d) ((d)->bus == &pci_bus_type)
drivers/acpi/pci_bind.c +7 -0
@@ -118,3 +118,10 @@ int acpi_pci_bind_root(struct acpi_devicreturn 0 ; } + +void acpi_pci_unbind_root (struct acpi_device *device) +{ + device->ops.bind =NULL ; + device->ops.unbind =NULL ; +} +
include/acpi/acpi_drivers.h +1 -0
@@ -101,6 +101,7 @@ struct pci_bus;struct pci_dev *acpi_get_pci_dev (acpi_handle );int acpi_pci_bind_root (struct acpi_device *device); +void acpi_pci_unbind_root (struct acpi_device *device);/* Arch-defined function to add a bus to the system */
Bjorn Helgaas
maintainerRe: [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
I think I'm missing patches 7/8 and 8/8 from this series. Can you repost them to make sure I have the latest versions?
Note the comments below:
Quoted 28 lines · Taku Izumi
Currently there's no PCI-related clean-up code in
acpi_pci_root_remove()function.
This patch introduces function for hostbridge removal, and brings backpci_stop_bus_devices()function.diff: rebased against current next
updated according to Bjorn's commentSigned-off-by Taku Izumi <[email protected]>--- drivers/acpi/pci_bind.c | 7 +++++++ drivers/acpi/pci_root.c | 6 ++++++ drivers/pci/remove.c | 28 ++++++++++++++++++++++++++++ include/acpi/acpi_drivers.h | 1 + include/linux/pci.h | 2 ++ 5 files changed, 44 insertions(+)Index:
Bjorn-next-0925-configchange/drivers/pci/remove.c
===================================================================drivers/pci/remove.c +2
-0@@ -111,3 +111,31 @@ void pci_stop_and_remove_bus_device(strupci_remove_bus_device (dev); }EXPORT_SYMBOL (pci_stop_and_remove_bus_device); + +void pci_stop_bus_devices (struct pci_bus *bus)
drivers/pci/remove.c void pci_stop_and_remove_bus_device(stru · line 125
Quoted 10 lines
drivers/pci/remove.c +10
-0+{ +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, + &bus->devices, bus_list) { +pci_stop_bus_device (dev); + } + +} +EXPORT_SYMBOL (pci_stop_bus_devices);
I'm hesitant to introduce pci_stop_bus_devices() again, particularly when it is exported. The stop/remove split introduces the state where devices are "stopped" but haven't been "removed" yet.
In this state, the driver .remove() method has been called, sysfs has been cleaned up, and the struct device has been unregistered, but the struct pci_dev itself still exists. Obviously, this state *must* exist internally in the PCI core as we remove the PCI device.
The problem is that we have non-core code that *depends* on being run while in this transitory state. I think this is a design mistake.
The code that depends on this state is basically just the stuff in the acpi_pci_drivers list, namely, acpi_pci_hp_driver and acpi_pci_slot_driver. I suspect that the main reason we have the acpi_pci_drivers list and the whole acpi_pci_register_driver() infrastructure is so that these PCI host bridge "sub-drivers" can be built as modules.
I don't think there's really any value in having these sub-drivers as modules, and it leads to a lot of complication in the code. I'm pretty sure that forcing them to be selected at build-time will let us make things much simpler.
If we have to have pci_stop_bus_devices() as an interim measure, I can live with it, but it doesn't need to be exported, does it?
Quoted 82 lines
drivers/pci/remove.c +15
-0+void pci_remove_host_bridge (struct pci_host_bridge *bridge) +{ +struct pci_bus *root = bridge->bus; +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, + &root->devices, bus_list) { +pci_remove_bus_device (dev); + } + +pci_remove_bus (root); + +device_unregister (&bridge->dev); +} +EXPORT_SYMBOL (pci_remove_host_bridge);Index:
Bjorn-next-0925-configchange/drivers/acpi/pci_root.c
===================================================================drivers/acpi/pci_root.c +6
-0@@ -659,8 +659,10 @@ static int acpi_pci_root_remove(struct a {struct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +struct pci_host_bridge *bridge =to_pci_host_bridge (root->bus->bridge);mutex_lock (&acpi_pci_root_lock); +pci_stop_bus_devices (root->bus);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->remove) driver->remove (root);@@ -668,6 +670,10 @@ static int acpi_pci_root_remove(struct adevice_set_run_wake (root->bus->bridge, false);pci_acpi_remove_bus_pm_notifier (device); +acpi_pci_unbind_root (device); + +pci_remove_host_bridge (bridge); +list_del (&root->node);mutex_unlock (&acpi_pci_root_lock);kfree (root);Index:
Bjorn-next-0925-configchange/include/linux/pci.h
===================================================================include/linux/pci.h +2
-0@@ -734,6 +734,8 @@ extern struct pci_dev *pci_dev_get(strucextern void pci_dev_put (struct pci_dev *dev);extern void pci_remove_bus (struct pci_bus *b);extern void pci_stop_and_remove_bus_device (struct pci_dev *dev); +extern void pci_stop_bus_devices (struct pci_bus *bus); +extern void pci_remove_host_bridge (struct pci_host_bridge *bridge);void pci_setup_cardbus (struct pci_bus *bus);extern void pci_sort_breadthfirst (void );#define dev_is_pci (d) ((d)->bus == &pci_bus_type)Index:
Bjorn-next-0925-configchange/drivers/acpi/pci_bind.c
===================================================================drivers/acpi/pci_bind.c +7
-0@@ -118,3 +118,10 @@ int acpi_pci_bind_root(struct acpi_devicreturn 0 ; } + +void acpi_pci_unbind_root (struct acpi_device *device) +{ + device->ops.bind =NULL ; + device->ops.unbind =NULL ; +} +Index:
Bjorn-next-0925-configchange/include/acpi/acpi_drivers.h
===================================================================include/acpi/acpi_drivers.h +1
-0@@ -101,6 +101,7 @@ struct pci_bus;struct pci_dev *acpi_get_pci_dev (acpi_handle );int acpi_pci_bind_root (struct acpi_device *device); +void acpi_pci_unbind_root (struct acpi_device *device);/* Arch-defined function to add a bus to the system */
(unknown)
Subject: [PATCH resend 0/8] PCI, ACPI, x86: pci root bus hotplug support resources assign and remove path
1. add support for assign resource for hot add path.
2. stop and remove root bus during acpi root remove.
could get from
git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-root-bus-hotplug
Yinghai Lu (8):
PCI: Separate out pci_assign_unassigned_bus_resources()
PCI: Move pci_rescan_bus() back to probe.c
PCI: Move out pci_enable_bridges out of assign_unsigned_bus_res PCI, ACPI: assign unassigned resource for hot add root bus
PCI: Add pci_stop/remove_root_bus()
PCI, ACPI: Make acpi_pci_root_remove stop/remove pci root bus PCI, ACPI: delete root bus prt during hot remove path PCI, ACPI: remove acpi_root_driver in reserse order
drivers/acpi/pci_root.c | 21 ++++++++++++++++++++- drivers/pci/probe.c | 22 ++++++++++++++++++++++ drivers/pci/remove.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/pci/setup-bus.c | 22 +--------------------- include/linux/pci.h | 3 +++ 5 files changed, 82 insertions(+), 22 deletions(-)
Signature · 1 line
1.7.7
PATCH 1/8 PCI: Separate out pci_assign_unassigned_bus_resources()
It is main portion of pci_rescan_bus().
Separate it out and prepare to use it for pci root bus hot add later.
--- drivers/pci/setup-bus.c | 32 ++++++++++++++++++-------------- include/linux/pci.h | 1 + 2 files changed, 19 insertions(+), 14 deletions(-)
drivers/pci/setup-bus.c +18 -14
@@ -1550,25 +1550,12 @@ enable_all: }EXPORT_SYMBOL_GPL (pci_assign_unassigned_bridge_resources); -#ifdef CONFIG_HOTPLUG -/** -* pci_rescan_bus - scan a PCI bus for devices. -* @bus: PCI bus to scan -* -* Scan a PCI bus and child buses for new devices, adds them, -* and enables them. -* -* Returns the max number of subordinate bus discovered. -*/ -unsigned int __ref pci_rescan_bus (struct pci_bus *bus) +void pci_assign_unassigned_bus_resources (struct pci_bus *bus) { -unsigned int max;struct pci_dev *dev;LIST_HEAD (add_list);/* list of resources that want additional resources */ - max =pci_scan_child_bus (bus); -down_read (&pci_bus_sem);list_for_each_entry (dev, &bus->devices, bus_list) if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
@@ -1581,6 +1568,23 @@ unsigned int __ref pci_rescan_bus(struct pci_bus *bus)BUG_ON (!list_empty (&add_list));pci_enable_bridges (bus); +} +#ifdef CONFIG_HOTPLUG +/** +* pci_rescan_bus - scan a PCI bus for devices. +* @bus: PCI bus to scan +* +* Scan a PCI bus and child buses for new devices, adds them, +* and enables them. +* +* Returns the max number of subordinate bus discovered. +*/ +unsigned int __ref pci_rescan_bus (struct pci_bus *bus) +{ +unsigned int max; + + max =pci_scan_child_bus (bus); +pci_assign_unassigned_bus_resources (bus);pci_bus_add_devices (bus);return max;
include/linux/pci.h +1 -0
@@ -980,6 +980,7 @@ void pci_bus_size_bridges(struct pci_bus *bus);int pci_claim_resource (struct pci_dev *,int );void pci_assign_unassigned_resources (void );void pci_assign_unassigned_bridge_resources (struct pci_dev *bridge); +void pci_assign_unassigned_bus_resources (struct pci_bus *bus);void pdev_enable_device (struct pci_dev *);int pci_enable_resources (struct pci_dev *,int mask); void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *),
Signature · 1 line
1.7.7
PATCH 2/8 PCI: Move pci_rescan_bus() back to probe.c
In reply to Yinghai LuWe have pci_assign_unassigned_bus_resources() in as global function now.
Move back pci_rescan_bus to probe.c where it should be.
--- drivers/pci/probe.c | 21 +++++++++++++++++++++ drivers/pci/setup-bus.c | 22 ---------------------- 2 files changed, 21 insertions(+), 22 deletions(-)
drivers/pci/probe.c +21 -0
@@ -1890,6 +1890,27 @@ unsigned int __ref pci_rescan_bus_bridge_resize(struct pci_dev *bridge)return max; } +/** +* pci_rescan_bus - scan a PCI bus for devices. +* @bus: PCI bus to scan +* +* Scan a PCI bus and child buses for new devices, adds them, +* and enables them. +* +* Returns the max number of subordinate bus discovered. +*/ +unsigned int __ref pci_rescan_bus (struct pci_bus *bus) +{ +unsigned int max; + + max =pci_scan_child_bus (bus); +pci_assign_unassigned_bus_resources (bus); +pci_bus_add_devices (bus); + +return max; +} +EXPORT_SYMBOL_GPL (pci_rescan_bus); +EXPORT_SYMBOL (pci_add_new_bus);EXPORT_SYMBOL (pci_scan_slot);EXPORT_SYMBOL (pci_scan_bridge);
drivers/pci/setup-bus.c +0 -22
@@ -1569,25 +1569,3 @@ void pci_assign_unassigned_bus_resources(struct pci_bus *bus)pci_enable_bridges (bus); } -#ifdef CONFIG_HOTPLUG -/** -* pci_rescan_bus - scan a PCI bus for devices. -* @bus: PCI bus to scan -* -* Scan a PCI bus and child buses for new devices, adds them, -* and enables them. -* -* Returns the max number of subordinate bus discovered. -*/ -unsigned int __ref pci_rescan_bus (struct pci_bus *bus) -{ -unsigned int max; - - max =pci_scan_child_bus (bus); -pci_assign_unassigned_bus_resources (bus); -pci_bus_add_devices (bus); - -return max; -} -EXPORT_SYMBOL_GPL (pci_rescan_bus); -#endif
Signature · 1 line
1.7.7
PATCH 3/8 PCI: Move out pci_enable_bridges out of assign_unsigned_bus_res
In reply to Yinghai LuSo could use assign_unassigned_bus_res pci root bus add
--- drivers/pci/probe.c | 1 + drivers/pci/setup-bus.c | 2 -- 2 files changed, 1 insertions(+), 2 deletions(-)
drivers/pci/probe.c +1 -0
@@ -1905,6 +1905,7 @@ unsigned int __ref pci_rescan_bus(struct pci_bus *bus) max =pci_scan_child_bus (bus);pci_assign_unassigned_bus_resources (bus); +pci_enable_bridges (bus);pci_bus_add_devices (bus);return max;
drivers/pci/setup-bus.c +0 -2
@@ -1566,6 +1566,4 @@ void pci_assign_unassigned_bus_resources(struct pci_bus *bus)up_read (&pci_bus_sem);__pci_bus_assign_resources (bus, &add_list,NULL );BUG_ON (!list_empty (&add_list)); - -pci_enable_bridges (bus); }
Signature · 1 line
1.7.7
Re: [PATCH 3/8] PCI: Move out pci_enable_bridges out of assign_unsigned_bus_res
Quoted 1 line · On Tue, 30 Oct 2012 10:42:40 -0700 Yinghai Lu <[email protected]> wrote:
So could use
assign_unassigned_bus_respci root bus add
This description doesn't match the following patch... This is for 4/8?
Quoted 37 lines
Signed-off-by Yinghai Lu <[email protected]>--- drivers/pci/probe.c | 1 + drivers/pci/setup-bus.c | 2 -- 2 files changed, 1 insertions(+), 2 deletions(-)drivers/pci/probe.c +1
-0@@ -1905,6 +1905,7 @@ unsigned int __ref pci_rescan_bus(struct pci_bus *bus) max =pci_scan_child_bus (bus);pci_assign_unassigned_bus_resources (bus); +pci_enable_bridges (bus);pci_bus_add_devices (bus);return max;drivers/pci/setup-bus.c +0
-2@@ -1566,6 +1566,4 @@ void pci_assign_unassigned_bus_resources(struct pci_bus *bus)up_read (&pci_bus_sem);__pci_bus_assign_resources (bus, &add_list,NULL );BUG_ON (!list_empty (&add_list)); - -pci_enable_bridges (bus); }Signature · 6 lines
1.7.7 -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Taku Izumi <[email protected]>
Re: [PATCH 3/8] PCI: Move out pci_enable_bridges out of assign_unsigned_bus_res
Quoted 7 lines · Taku Izumi
Quoted 1 line · On Tue, 30 Oct 2012 10:42:40 -0700 Yinghai Lu <[email protected]> wrote:
So could use
assign_unassigned_bus_respci root bus addThis description doesn't match the following patch... This is for 4/8?
yes, this patch is preparation one for 4/8.
PATCH 4/8 PCI, ACPI: assign unassigned resource for hot add root bus
In reply to Yinghai LuAfter we get hot-added ioapic registered. pci_enable_bridges will try to enable ioapic irq for pci bridges.
--- drivers/acpi/pci_root.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/acpi/pci_root.c +7 -0
@@ -644,12 +644,19 @@ static int acpi_pci_root_start(struct acpi_device *device)struct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +if (system_state !=SYSTEM_BOOTING ) +pci_assign_unassigned_bus_resources (root->bus); +mutex_lock (&acpi_pci_root_lock);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->add) driver->add (root);mutex_unlock (&acpi_pci_root_lock); +/* need to after hot-added ioapic is registered */ +if (system_state !=SYSTEM_BOOTING ) +pci_enable_bridges (root->bus); +pci_bus_add_devices (root->bus);return 0 ;
Signature · 1 line
1.7.7
PATCH 5/8 PCI: Add pci_stop/remove_root_bus()
In reply to Yinghai LuIt supports both pci root bus and pci bus under pci bridge.
-v2: clear pci_bridge's subordinate.
-v3: only handle root bus. and also put Jiang's get/put pair in -v4: fold pci_stop/remove_bus_devices in... reducing confusing. -v5: split device_register/unregister to avoid extra get...
also remove extra blank line.
--- drivers/pci/remove.c | 36 ++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 2 ++ 2 files changed, 38 insertions(+), 0 deletions(-)
drivers/pci/remove.c +36 -0
@@ -111,3 +111,39 @@ void pci_stop_and_remove_bus_device(struct pci_dev *dev)pci_remove_bus_device (dev); }EXPORT_SYMBOL (pci_stop_and_remove_bus_device); + +void pci_stop_root_bus (struct pci_bus *bus) +{ +struct pci_dev *child, *tmp; +struct pci_host_bridge *host_bridge; + +if (!pci_is_root_bus (bus)) +return ; + + host_bridge =to_pci_host_bridge (bus->bridge); +list_for_each_entry_safe_reverse (child, tmp, + &bus->devices, bus_list) +pci_stop_bus_device (child); + +/* stop the host bridge */ +device_del (&host_bridge->dev); +} + +void pci_remove_root_bus (struct pci_bus *bus) +{ +struct pci_dev *child, *tmp; +struct pci_host_bridge *host_bridge; + +if (!pci_is_root_bus (bus)) +return ; + + host_bridge =to_pci_host_bridge (bus->bridge); +list_for_each_entry_safe (child, tmp, + &bus->devices, bus_list) +pci_remove_bus_device (child); +pci_remove_bus (bus); + host_bridge->bus =NULL ; + +/* remove the host bridge */ +put_device (&host_bridge->dev); +}
include/linux/pci.h +2 -0
@@ -734,6 +734,8 @@ extern struct pci_dev *pci_dev_get(struct pci_dev *dev);extern void pci_dev_put (struct pci_dev *dev);extern void pci_remove_bus (struct pci_bus *b);extern void pci_stop_and_remove_bus_device (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);extern void pci_sort_breadthfirst (void );#define dev_is_pci (d) ((d)->bus == &pci_bus_type)
Signature · 1 line
1.7.7
PATCH 6/8 PCI, ACPI: Make acpi_pci_root_remove stop/remove pci root bus
In reply to Yinghai LuIt will call new added pci_stop_and_remove_bus() to stop/remove pci root bus.
--- drivers/acpi/pci_root.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/acpi/pci_root.c +6 -0
@@ -667,14 +667,20 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)struct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +pci_stop_root_bus (root->bus); +mutex_lock (&acpi_pci_root_lock);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->remove) driver->remove (root); +mutex_unlock (&acpi_pci_root_lock);device_set_run_wake (root->bus->bridge, false);pci_acpi_remove_bus_pm_notifier (device); +pci_remove_root_bus (root->bus); + +mutex_lock (&acpi_pci_root_lock);list_del (&root->node);mutex_unlock (&acpi_pci_root_lock);kfree (root);
Signature · 1 line
1.7.7
PATCH 7/8 PCI, ACPI: delete root bus prt during hot remove path
In reply to Yinghai Lucorresponding to add path.
--- drivers/acpi/pci_root.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/acpi/pci_root.c +6 -0
@@ -664,6 +664,8 @@ static int acpi_pci_root_start(struct acpi_device *device)static int acpi_pci_root_remove (struct acpi_device *device,int type) { +acpi_status status; +acpi_handle handle;struct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver;
@@ -678,6 +680,10 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)device_set_run_wake (root->bus->bridge, false);pci_acpi_remove_bus_pm_notifier (device); + status =acpi_get_handle (device->handle,METHOD_NAME__PRT , &handle); +if (ACPI_SUCCESS (status)) +acpi_pci_irq_del_prt (root->bus); +pci_remove_root_bus (root->bus);mutex_lock (&acpi_pci_root_lock);
Signature · 1 line
1.7.7
PATCH 8/8 PCI, ACPI: remove acpi_root_driver in reserse order
In reply to Yinghai Luaka stop acpi root driver in this sequence: acpiphp, iommu, ioapic.
--- drivers/acpi/pci_root.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/acpi/pci_root.c +1 -1
@@ -672,7 +672,7 @@ static int acpi_pci_root_remove(struct acpi_device *device, int type)pci_stop_root_bus (root->bus);mutex_lock (&acpi_pci_root_lock); -list_for_each_entry (driver, &acpi_pci_drivers, node) +list_for_each_entry_reverse (driver, &acpi_pci_drivers, node)if (driver->remove) driver->remove (root);mutex_unlock (&acpi_pci_root_lock);
Signature · 1 line
1.7.7
Rafael J. Wysocki
Acked-byRe:
In reply to Yinghai LuHi,
Quoted 19 lines · Yinghai Lu
Subject: [PATCH resend 0/8] PCI, ACPI, x86: pci root bus hotplug support resources assign and remove path
1. add support for assign resource for hot add path.
2. stop and remove root bus during acpi root remove.could get from
git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.gitfor-pci-root-bus-hotplugYinghai Lu (8):
PCI: Separate outpci_assign_unassigned_bus_resources()
PCI: Movepci_rescan_bus()back toprobe.c
PCI: Move outpci_enable_bridgesout ofassign_unsigned_bus_resPCI, ACPI: assign unassigned resource for hot add root bus
PCI: Add pci_stop/remove_root_bus()
PCI, ACPI: Makeacpi_pci_root_removestop/remove pci root bus PCI, ACPI: delete root bus prt during hot remove path PCI, ACPI: removeacpi_root_driverin reserse order
Quoted 6 lines
drivers/acpi/pci_root.c | 21 ++++++++++++++++++++- drivers/pci/probe.c | 22 ++++++++++++++++++++++ drivers/pci/remove.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/pci/setup-bus.c | 22 +--------------------- include/linux/pci.h | 3 +++ 5 files changed, 82 insertions(+), 22 deletions(-)
Please feel free to add
to the ACPI-related patches in this series.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re:
Quoted 29 lines · Rafael J. Wysocki
Hi,
Quoted 19 lines · Yinghai Lu
Subject: [PATCH resend 0/8] PCI, ACPI, x86: pci root bus hotplug support resources assign and remove path
1. add support for assign resource for hot add path.
2. stop and remove root bus during acpi root remove.could get from
git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.gitfor-pci-root-bus-hotplugYinghai Lu (8):
PCI: Separate outpci_assign_unassigned_bus_resources()
PCI: Movepci_rescan_bus()back toprobe.c
PCI: Move outpci_enable_bridgesout ofassign_unsigned_bus_resPCI, ACPI: assign unassigned resource for hot add root bus
PCI: Add pci_stop/remove_root_bus()
PCI, ACPI: Makeacpi_pci_root_removestop/remove pci root bus PCI, ACPI: delete root bus prt during hot remove path PCI, ACPI: removeacpi_root_driverin reserse orderQuoted 6 lines
drivers/acpi/pci_root.c | 21 ++++++++++++++++++++- drivers/pci/probe.c | 22 ++++++++++++++++++++++ drivers/pci/remove.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/pci/setup-bus.c | 22 +--------------------- include/linux/pci.h | 3 +++ 5 files changed, 82 insertions(+), 22 deletions(-)
Quoted 5 lines
Please feel free to add
to the ACPI-related patches in this series.
I applied these to my pci/yinghai-for-pci-root-bus-hotplug branch as v3.8 material. They should appear in "next" tomorrow. Thanks!
Re:
Quoted 2 lines · Bjorn Helgaas
I applied these to my pci/yinghai-for-pci-root-bus-hotplug branch as v3.8 material. They should appear in "next" tomorrow. Thanks!
Thanks...
please check batch 2 at
https://patchwork.kernel.org/patch/1693211/
Yinghai
RE:
In reply to Yinghai LuReviewed and tested by Taku Izumi <[email protected]>
Quoted 40 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Yinghai Lu
Sent: Wednesday, October 31, 2012 2:43 AM
To: Bjorn Helgaas; Len Brown; Taku Izumi; Jiang Liu
Cc: [email protected]; [email protected]; Yinghai Lu
Subject:Subject: [PATCH resend 0/8] PCI, ACPI, x86: pci root bus hotplug support resources assign and remove path
1. add support for assign resource for hot add path.
2. stop and remove root bus during acpi root remove.could get from
git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.gitfor-pci-root-bus-hotplugYinghai Lu (8):
PCI: Separate outpci_assign_unassigned_bus_resources()
PCI: Movepci_rescan_bus()back toprobe.c
PCI: Move outpci_enable_bridgesout ofassign_unsigned_bus_resPCI, ACPI: assign unassigned resource for hot add root bus
PCI: Add pci_stop/remove_root_bus()
PCI, ACPI: Makeacpi_pci_root_removestop/remove pci root bus PCI, ACPI: delete root bus prt during hot remove path PCI, ACPI: removeacpi_root_driverin reserse orderdrivers/acpi/pci_root.c | 21 ++++++++++++++++++++- drivers/pci/probe.c | 22 ++++++++++++++++++++++ drivers/pci/remove.c | 36 ++++++++++++++++++++++++++++++++++++ drivers/pci/setup-bus.c | 22 +--------------------- include/linux/pci.h | 3 +++ 5 files changed, 82 insertions(+), 22 deletions(-)--
1.7.7--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH RESEND v3 7/8 ACPI, PCI: add hostbridge removal function
In reply to Bjorn HelgaasCurrently there's no PCI-related clean-up code in acpi_pci_root_remove() function.
This patch introduces function for hostbridge removal, and brings back pci_stop_bus_devices() function.
diff: rebased against current next
updated according to Bjorn's comment
--- drivers/acpi/pci_bind.c | 7 +++++++ drivers/acpi/pci_root.c | 6 ++++++ drivers/pci/remove.c | 28 ++++++++++++++++++++++++++++ include/acpi/acpi_drivers.h | 1 + include/linux/pci.h | 2 ++ 5 files changed, 44 insertions(+)
drivers/pci/remove.c +28 -0
@@ -111,3 +111,31 @@ void pci_stop_and_remove_bus_device(strupci_remove_bus_device (dev); }EXPORT_SYMBOL (pci_stop_and_remove_bus_device); + +void pci_stop_bus_devices (struct pci_bus *bus) +{ +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, + &bus->devices, bus_list) { +pci_stop_bus_device (dev); + } + +} +EXPORT_SYMBOL (pci_stop_bus_devices); + +void pci_remove_host_bridge (struct pci_host_bridge *bridge) +{ +struct pci_bus *root = bridge->bus; +struct pci_dev *dev, *tmp; + +list_for_each_entry_safe_reverse (dev, tmp, + &root->devices, bus_list) { +pci_remove_bus_device (dev); + } + +pci_remove_bus (root); + +device_unregister (&bridge->dev); +} +EXPORT_SYMBOL (pci_remove_host_bridge);
drivers/acpi/pci_root.c +6 -0
@@ -659,8 +659,10 @@ static int acpi_pci_root_remove(struct a {struct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +struct pci_host_bridge *bridge =to_pci_host_bridge (root->bus->bridge);mutex_lock (&acpi_pci_root_lock); +pci_stop_bus_devices (root->bus);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->remove) driver->remove (root);
@@ -668,6 +670,10 @@ static int acpi_pci_root_remove(struct adevice_set_run_wake (root->bus->bridge, false);pci_acpi_remove_bus_pm_notifier (device); +acpi_pci_unbind_root (device); + +pci_remove_host_bridge (bridge); +list_del (&root->node);mutex_unlock (&acpi_pci_root_lock);kfree (root);
include/linux/pci.h +2 -0
@@ -734,6 +734,8 @@ extern struct pci_dev *pci_dev_get(strucextern void pci_dev_put (struct pci_dev *dev);extern void pci_remove_bus (struct pci_bus *b);extern void pci_stop_and_remove_bus_device (struct pci_dev *dev); +extern void pci_stop_bus_devices (struct pci_bus *bus); +extern void pci_remove_host_bridge (struct pci_host_bridge *bridge);void pci_setup_cardbus (struct pci_bus *bus);extern void pci_sort_breadthfirst (void );#define dev_is_pci (d) ((d)->bus == &pci_bus_type)
drivers/acpi/pci_bind.c +7 -0
@@ -118,3 +118,10 @@ int acpi_pci_bind_root(struct acpi_devicreturn 0 ; } + +void acpi_pci_unbind_root (struct acpi_device *device) +{ + device->ops.bind =NULL ; + device->ops.unbind =NULL ; +} +
include/acpi/acpi_drivers.h +1 -0
@@ -101,6 +101,7 @@ struct pci_bus;struct pci_dev *acpi_get_pci_dev (acpi_handle );int acpi_pci_bind_root (struct acpi_device *device); +void acpi_pci_unbind_root (struct acpi_device *device);/* Arch-defined function to add a bus to the system */
PATCH RESEND v3 8/8 ACPI, PCI: add resoruce-assign code for devices under hot-added hostbridge
In reply to Bjorn HelgaasDevices under hot-added hostbridge have no chance to assign resources and to configure them, so this patch adds such code for hot-added hostbridges at acpi_pci_root_start().
diff: updated according to Yinhai's comment
disconnect dependency on CONFIG_HOTPLUG
--- drivers/acpi/pci_root.c | 13 +++++++++++++ include/acpi/acpi_bus.h | 1 + 2 files changed, 14 insertions(+)
drivers/acpi/pci_root.c +13 -0
@@ -628,6 +628,9 @@ static int __devinit acpi_pci_root_add(sif (device->wakeup.flags.run_wake)device_set_run_wake (root->bus->bridge, true); +if (system_state !=SYSTEM_BOOTING ) + root->hot_added = true; +return 0 ; out_del_root:
@@ -644,6 +647,16 @@ static int acpi_pci_root_start(struct acstruct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +/* +* Devices under hot-added hostbridge have no chance to assign +* resources and to configure them, so do that here +*/ +if (root->hot_added) { +pci_bus_size_bridges (root->bus); +pci_bus_assign_resources (root->bus); +pci_enable_bridges (root->bus); + } +mutex_lock (&acpi_pci_root_lock);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->add)
include/acpi/acpi_bus.h +1 -0
@@ -407,6 +407,7 @@ struct acpi_pci_root {u32 osc_support_set;/* _OSC state of support bits */ u32 osc_control_set;/* _OSC state of control bits */ phys_addr_t mcfg_addr; +bool hot_added; };/* helper */
cover PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
In reply to Bjorn HelgaasFor root bus hot add, fw could assign some resource for the devices for that root bus before notifying os via acpi, we should check and use those resources at first just like we do for booting path.
At first, we need to refactor x86 pci pcibios_allocate related functions for booting path to take bus as parameter.
After that, we could use the survey function for hot add root bus.
based on pci/yinghai-for-pci-root-bus-hotplug
could get from
git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git for-pci-survey-resources
Yinghai Lu (8):
PCI, x86: Separate out pcibios_allocate_bridge_resources() PCI, x86: Separate out pcibios_allocate_dev_resources() PCI, x86: Let pcibios_allocate_bus_resources() take bus instead PCI, x86: Separate out rom resource claim
PCI, x86: Add pcibios_fw_addr_done
PCI, x86: Remove __init for hw/fw allocated functions PCI, x86: Claim FW allocated resources in hot add path. PCI, ACPI: reserve fw allocated resource for hot added root bus
arch/x86/pci/i386.c | 185 +++++++++++++++++++++++++++++++---------------- drivers/acpi/pci_root.c | 4 +- drivers/pci/bus.c | 2 + include/linux/pci.h | 1 + 4 files changed, 127 insertions(+), 65 deletions(-)
Signature · 1 line
1.7.7
PATCH 1/8 PCI, x86: Separate out pcibios_allocate_bridge_resources()
Thus pcibios_allocate_bus_resources() could more simple and clean.
--- arch/x86/pci/i386.c | 46 ++++++++++++++++++++++++---------------------- 1 files changed, 24 insertions(+), 22 deletions(-)
arch/x86/pci/i386.c +24 -22
@@ -193,34 +193,36 @@ EXPORT_SYMBOL(pcibios_align_resource);* as well. */ -static void __init pcibios_allocate_bus_resources (struct list_head *bus_list) +static void __init pcibios_allocate_bridge_resources (struct pci_dev *dev) { -struct pci_bus *bus; -struct pci_dev *dev;int idx;struct resource *r; +for (idx =PCI_BRIDGE_RESOURCES ; idx <PCI_NUM_RESOURCES ; idx++) { + r = &dev->resource[idx]; +if (!r->flags) +continue ; +if (!r->start ||pci_claim_resource (dev, idx) <0 ) { +/* +* Something is wrong with the region. +* Invalidate the resource to prevent +* child resource allocations in this +* range. +*/ + r->start = r->end =0 ; + r->flags =0 ; + } + } +} + +static void __init pcibios_allocate_bus_resources (struct list_head *bus_list) +{ +struct pci_bus *bus; +/* Depth-First Search on bus tree */ list_for_each_entry (bus, bus_list, node) { -if ((dev = bus->self)) { -for (idx =PCI_BRIDGE_RESOURCES ; - idx <PCI_NUM_RESOURCES ; idx++) { - r = &dev->resource[idx]; -if (!r->flags) -continue ; -if (!r->start || -pci_claim_resource (dev, idx) <0 ) { -/* -* Something is wrong with the region. -* Invalidate the resource to prevent -* child resource allocations in this -* range. -*/ - r->start = r->end =0 ; - r->flags =0 ; - } - } - } +if (bus->self) +pcibios_allocate_bridge_resources (bus->self);pcibios_allocate_bus_resources (&bus->children); } }
Signature · 1 line
1.7.7
PATCH 2/8 PCI, x86: Separate out pcibios_allocate_dev_resources()
In reply to Yinghai LuThus pcibios_allocate_resources() could more simple and clean.
--- arch/x86/pci/i386.c | 42 +++++++++++++++++++++++------------------- 1 files changed, 23 insertions(+), 19 deletions(-)
arch/x86/pci/i386.c +23 -19
@@ -232,9 +232,8 @@ struct pci_check_idx_range {int end; }; -static void __init pcibios_allocate_resources (int pass) +static void __init pcibios_allocate_dev_resources (struct pci_dev *dev,int pass) { -struct pci_dev *dev =NULL ;int idx, disabled, i;u16 command;struct resource *r;
@@ -246,14 +245,13 @@ static void __init pcibios_allocate_resources(int pass)#endif }; -for_each_pci_dev (dev) { -pci_read_config_word (dev,PCI_COMMAND , &command); -for (i =0 ; i <ARRAY_SIZE (idx_range); i++) +pci_read_config_word (dev,PCI_COMMAND , &command); +for (i =0 ; i <ARRAY_SIZE (idx_range); i++)for (idx = idx_range[i].start; idx <= idx_range[i].end; idx++) { r = &dev->resource[idx]; -if (r->parent)/* Already allocated */ +if (r->parent)/* Already allocated */ continue ; -if (!r->start)/* Address not assigned at all */ +if (!r->start)/* Address not assigned at all */ continue ;if (r->flags &IORESOURCE_IO ) disabled = !(command &PCI_COMMAND_IO );
@@ -272,23 +270,29 @@ static void __init pcibios_allocate_resources(int pass) } } } -if (!pass) { - r = &dev->resource[PCI_ROM_RESOURCE ]; -if (r->flags &IORESOURCE_ROM_ENABLE ) { -/* Turn the ROM off, leave the resource region, -* but keep it unregistered. */ -u32 reg; -dev_dbg (&dev->dev,"disabling ROM %pR\n" , r); - r->flags &= ~IORESOURCE_ROM_ENABLE ; -pci_read_config_dword (dev, - dev->rom_base_reg, ®); -pci_write_config_dword (dev, dev->rom_base_reg, +if (!pass) { + r = &dev->resource[PCI_ROM_RESOURCE ]; +if (r->flags &IORESOURCE_ROM_ENABLE ) { +/* Turn the ROM off, leave the resource region, +* but keep it unregistered. */ +u32 reg; +dev_dbg (&dev->dev,"disabling ROM %pR\n" , r); + r->flags &= ~IORESOURCE_ROM_ENABLE ; +pci_read_config_dword (dev, dev->rom_base_reg, ®); +pci_write_config_dword (dev, dev->rom_base_reg, reg & ~PCI_ROM_ADDRESS_ENABLE ); - } } } } +static void __init pcibios_allocate_resources (int pass) +{ +struct pci_dev *dev =NULL ; + +for_each_pci_dev (dev) +pcibios_allocate_dev_resources (dev, pass); +} +static int __init pcibios_assign_resources (void ) {struct pci_dev *dev =NULL ;
Signature · 1 line
1.7.7
PATCH 3/8 PCI, x86: Let pcibios_allocate_bus_resources() take bus instead
In reply to Yinghai LuWill need call the same code for one single root bus during hot add. So make it take bus instead of bus list.
--- arch/x86/pci/i386.c | 38 +++++++++++++++++++++++++------------- 1 files changed, 25 insertions(+), 13 deletions(-)
arch/x86/pci/i386.c +25 -13
@@ -215,16 +215,15 @@ static void __init pcibios_allocate_bridge_resources(struct pci_dev *dev) } } -static void __init pcibios_allocate_bus_resources (struct list_head *bus_list) +static void __init pcibios_allocate_bus_resources (struct pci_bus *bus) { -struct pci_bus *bus; +struct pci_bus *child;/* Depth-First Search on bus tree */ -list_for_each_entry (bus, bus_list, node) { -if (bus->self) -pcibios_allocate_bridge_resources (bus->self); -pcibios_allocate_bus_resources (&bus->children); - } +if (bus->self) +pcibios_allocate_bridge_resources (bus->self); +list_for_each_entry (child, &bus->children, node) +pcibios_allocate_bus_resources (child); }struct pci_check_idx_range {
@@ -285,12 +284,18 @@ static void __init pcibios_allocate_dev_resources(struct pci_dev *dev, int pass) } } -static void __init pcibios_allocate_resources (int pass) +static void __init pcibios_allocate_resources (struct pci_bus *bus,int pass) { -struct pci_dev *dev =NULL ; +struct pci_dev *dev; +struct pci_bus *child; -for_each_pci_dev (dev) +list_for_each_entry (dev, &bus->devices, bus_list) {pcibios_allocate_dev_resources (dev, pass); + + child = dev->subordinate; +if (child) +pcibios_allocate_resources (child, pass); + } }static int __init pcibios_assign_resources (void )
@@ -323,10 +328,17 @@ static int __init pcibios_assign_resources(void)void __init pcibios_resource_survey (void ) { +struct pci_bus *bus; +DBG ("PCI: Allocating resources\n" ); -pcibios_allocate_bus_resources (&pci_root_buses); -pcibios_allocate_resources (0 ); -pcibios_allocate_resources (1 ); + +list_for_each_entry (bus, &pci_root_buses, node) +pcibios_allocate_bus_resources (bus); + +list_for_each_entry (bus, &pci_root_buses, node) +pcibios_allocate_resources (bus,0 ); +list_for_each_entry (bus, &pci_root_buses, node) +pcibios_allocate_resources (bus,1 );e820_reserve_resources_late ();/*
Signature · 1 line
1.7.7
PATCH 4/8 PCI, x86: Separate out rom resource claim
In reply to Yinghai LuSo could use it with hot-added root bus later.
-v2: remove extra functions.
--- arch/x86/pci/i386.c | 52 ++++++++++++++++++++++++++++++++++---------------- 1 files changed, 35 insertions(+), 17 deletions(-)
arch/x86/pci/i386.c +35 -17
@@ -298,27 +298,45 @@ static void __init pcibios_allocate_resources(struct pci_bus *bus, int pass) } } -static int __init pcibios_assign_resources (void ) +static void __init pcibios_allocate_dev_rom_resource (struct pci_dev *dev) { -struct pci_dev *dev =NULL ;struct resource *r; -if (!(pci_probe &PCI_ASSIGN_ROMS )) { -/* -* Try to use BIOS settings for ROMs, otherwise let -* pci_assign_unassigned_resources() allocate the new -* addresses. -*/ -for_each_pci_dev (dev) { - r = &dev->resource[PCI_ROM_RESOURCE ]; -if (!r->flags || !r->start) -continue ; -if (pci_claim_resource (dev,PCI_ROM_RESOURCE ) <0 ) { - r->end -= r->start; - r->start =0 ; - } - } +/* +* Try to use BIOS settings for ROMs, otherwise let +* pci_assign_unassigned_resources() allocate the new +* addresses. +*/ + r = &dev->resource[PCI_ROM_RESOURCE ]; +if (!r->flags || !r->start) +return ; + +if (pci_claim_resource (dev,PCI_ROM_RESOURCE ) <0 ) { + r->end -= r->start; + r->start =0 ; } +} +static void __init pcibios_allocate_rom_resources (struct pci_bus *bus) +{ +struct pci_dev *dev; +struct pci_bus *child; + +list_for_each_entry (dev, &bus->devices, bus_list) { +pcibios_allocate_dev_rom_resource (dev); + + child = dev->subordinate; +if (child) +pcibios_allocate_rom_resources (child); + } +} + +static int __init pcibios_assign_resources (void ) +{ +struct pci_bus *bus; + +if (!(pci_probe &PCI_ASSIGN_ROMS )) +list_for_each_entry (bus, &pci_root_buses, node) +pcibios_allocate_rom_resources (bus);pci_assign_unassigned_resources ();pcibios_fw_addr_list_del ();
Signature · 1 line
1.7.7
PATCH 5/8 PCI, x86: Add pcibios_fw_addr_done
In reply to Yinghai LuUse it to skip not needed function after pcibios_fw_addr_list_del is called.
for pci root bus hot add, we will need to use pcibios_allocate_dev_resources(), and don't want to mess up with fw_addr, for hot-add removing path.
--- arch/x86/pci/i386.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
arch/x86/pci/i386.c +9 -1
@@ -51,6 +51,7 @@ struct pcibios_fwaddrmap {static LIST_HEAD (pcibios_fwaddrmappings);static DEFINE_SPINLOCK (pcibios_fwaddrmap_lock); +static bool pcibios_fw_addr_done;/* Must be called with 'pcibios_fwaddrmap_lock' lock held. */ static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup (struct pci_dev *dev)
@@ -72,6 +73,9 @@ pcibios_save_fw_addr(struct pci_dev *dev, int idx, resource_size_t fw_addr)unsigned long flags;struct pcibios_fwaddrmap *map; +if (pcibios_fw_addr_done) +return ; +spin_lock_irqsave (&pcibios_fwaddrmap_lock, flags); map =pcibios_fwaddrmap_lookup (dev);if (!map) {
@@ -97,6 +101,9 @@ resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx)struct pcibios_fwaddrmap *map;resource_size_t fw_addr =0 ; +if (pcibios_fw_addr_done) +return fw_addr; +spin_lock_irqsave (&pcibios_fwaddrmap_lock, flags); map =pcibios_fwaddrmap_lookup (dev);if (map)
@@ -106,7 +113,7 @@ resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx)return fw_addr; } -static void pcibios_fw_addr_list_del (void ) +static void __init pcibios_fw_addr_list_del (void ) {unsigned long flags;struct pcibios_fwaddrmap *entry, *next;
@@ -118,6 +125,7 @@ static void pcibios_fw_addr_list_del(void)kfree (entry); }spin_unlock_irqrestore (&pcibios_fwaddrmap_lock, flags); + pcibios_fw_addr_done = true; } static int
Signature · 1 line
1.7.7
PATCH 6/8 PCI, x86: Remove __init for hw/fw allocated functions
In reply to Yinghai Luwill need it for hot add path.
--- arch/x86/pci/i386.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
arch/x86/pci/i386.c +6 -6
@@ -201,7 +201,7 @@ EXPORT_SYMBOL(pcibios_align_resource);* as well. */ -static void __init pcibios_allocate_bridge_resources (struct pci_dev *dev) +static void pcibios_allocate_bridge_resources (struct pci_dev *dev) {int idx;struct resource *r;
@@ -223,7 +223,7 @@ static void __init pcibios_allocate_bridge_resources(struct pci_dev *dev) } } -static void __init pcibios_allocate_bus_resources (struct pci_bus *bus) +static void pcibios_allocate_bus_resources (struct pci_bus *bus) {struct pci_bus *child;
@@ -239,7 +239,7 @@ struct pci_check_idx_range {int end; }; -static void __init pcibios_allocate_dev_resources (struct pci_dev *dev,int pass) +static void pcibios_allocate_dev_resources (struct pci_dev *dev,int pass) {int idx, disabled, i;u16 command;
@@ -292,7 +292,7 @@ static void __init pcibios_allocate_dev_resources(struct pci_dev *dev, int pass) } } -static void __init pcibios_allocate_resources (struct pci_bus *bus,int pass) +static void pcibios_allocate_resources (struct pci_bus *bus,int pass) {struct pci_dev *dev;struct pci_bus *child;
@@ -306,7 +306,7 @@ static void __init pcibios_allocate_resources(struct pci_bus *bus, int pass) } } -static void __init pcibios_allocate_dev_rom_resource (struct pci_dev *dev) +static void pcibios_allocate_dev_rom_resource (struct pci_dev *dev) {struct resource *r;
@@ -324,7 +324,7 @@ static void __init pcibios_allocate_dev_rom_resource(struct pci_dev *dev) r->start =0 ; } } -static void __init pcibios_allocate_rom_resources (struct pci_bus *bus) +static void pcibios_allocate_rom_resources (struct pci_bus *bus) {struct pci_dev *dev;struct pci_bus *child;
Signature · 1 line
1.7.7
PATCH 7/8 PCI, x86: Claim FW allocated resources in hot add path.
In reply to Yinghai LuDuring testing remove/rescan root bus 00, found
[ 338.142574] bus: 'pci': really_probe: probing driver ata_piix with device 0000:00:01.1 [ 338.146788] ata_piix 0000:00:01.1: device not available (can't reserve [io 0x01f0-0x01f7]) [ 338.150565] ata_piix: probe of 0000:00:01.1 failed with error -22
because that fixed resource is not claimed.
For bootint path it is claimed in from
arch/x86/pci/i386.c::pcibios_allocate_resources()
Claim those resources, so on the remove/rescan will still use old resources.
It is some kind honoring FW setting in the registers during hot add. esp root-bus hot add is through acpi, BIOS has chance to set some registers before handing over.
-v2: add rom resource claiming.
-v3: separate __init removing to another patch, also
put pci_probe checking with caller from rom resource allocating
--- arch/x86/pci/i386.c | 13 +++++++++++++ drivers/pci/bus.c | 2 ++ include/linux/pci.h | 1 + 3 files changed, 16 insertions(+), 0 deletions(-)
arch/x86/pci/i386.c +13 -0
@@ -352,6 +352,19 @@ static int __init pcibios_assign_resources(void)return 0 ; } +void pcibios_resource_survey_bus (struct pci_bus *bus) +{ +dev_printk (KERN_DEBUG , &bus->dev,"Allocating resources\n" ); + +pcibios_allocate_bus_resources (bus); + +pcibios_allocate_resources (bus,0 ); +pcibios_allocate_resources (bus,1 ); + +if (!(pci_probe &PCI_ASSIGN_ROMS )) +pcibios_allocate_rom_resources (bus); +} +void __init pcibios_resource_survey (void ) {struct pci_bus *bus;
drivers/pci/bus.c +2 -0
@@ -158,6 +158,8 @@ pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,return ret; } +void __weak pcibios_resource_survey_bus (struct pci_bus *bus) { } +/** * pci_bus_add_device - add a single device * @dev: device to add
include/linux/pci.h +1 -0
@@ -654,6 +654,7 @@ extern struct list_head pci_root_buses; /* list of all known PCI buses *//* Some device drivers need know if pci is initiated */ extern int no_pci_devices (void ); +void pcibios_resource_survey_bus (struct pci_bus *bus);void pcibios_fixup_bus (struct pci_bus *);int __must_check pcibios_enable_device (struct pci_dev *,int mask);/* Architecture specific versions may override this (weak) */
Signature · 1 line
1.7.7
PATCH 8/8 PCI, ACPI: reserve fw allocated resource for hot added root bus
In reply to Yinghai LuFW could already allocate resource in pci bar registers, and we need to reserve it before try to allocate another one.
--- drivers/acpi/pci_root.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/acpi/pci_root.c +3 -1
@@ -644,8 +644,10 @@ static int acpi_pci_root_start(struct acpi_device *device)struct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; -if (system_state !=SYSTEM_BOOTING ) +if (system_state !=SYSTEM_BOOTING ) { +pcibios_resource_survey_bus (root->bus);pci_assign_unassigned_bus_resources (root->bus); + }mutex_lock (&acpi_pci_root_lock);list_for_each_entry (driver, &acpi_pci_drivers, node)
Signature · 1 line
1.7.7
Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
In reply to Yinghai LuQuoted 24 lines · Yinghai Lu
For root bus hot add, fw could assign some resource for the devices for that root bus before notifying os via acpi, we should check and use those resources at first just like we do for booting path.
At first, we need to refactor x86 pci
pcibios_allocaterelated functions for booting path to take bus as parameter.After that, we could use the survey function for hot add root bus.
based on pci/yinghai-for-pci-root-bus-hotplug
could get from
git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.gitfor-pci-survey-resourcesYinghai Lu (8):
PCI, x86: Separate outpcibios_allocate_bridge_resources()PCI, x86: Separate outpcibios_allocate_dev_resources()PCI, x86: Letpcibios_allocate_bus_resources()take bus instead PCI, x86: Separate out rom resource claim
PCI, x86: Addpcibios_fw_addr_done
PCI, x86: Remove__initfor hw/fw allocated functions PCI, x86: Claim FW allocated resources in hot add path. PCI, ACPI: reserve fw allocated resource for hot added root bus
Quoted 6 lines
arch/x86/pci/i386.c | 185 +++++++++++++++++++++++++++++++---------------- drivers/acpi/pci_root.c | 4 +- drivers/pci/bus.c | 2 + include/linux/pci.h | 1 + 4 files changed, 127 insertions(+), 65 deletions(-)
Bjorn,
Can you queue those 8 patches for v3.9 in pci tree?
So I could resend out other pci root hotplug patches.
Thanks
Yinghai
Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
[+cc David, Michal, Koichi, Ben, Paul]
Quoted 32 lines · Yinghai Lu
Quoted 24 lines · Yinghai Lu
For root bus hot add, fw could assign some resource for the devices for that root bus before notifying os via acpi, we should check and use those resources at first just like we do for booting path.
At first, we need to refactor x86 pci
pcibios_allocaterelated functions for booting path to take bus as parameter.After that, we could use the survey function for hot add root bus.
based on pci/yinghai-for-pci-root-bus-hotplug
could get from
git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.gitfor-pci-survey-resourcesYinghai Lu (8):
PCI, x86: Separate outpcibios_allocate_bridge_resources()PCI, x86: Separate outpcibios_allocate_dev_resources()PCI, x86: Letpcibios_allocate_bus_resources()take bus instead PCI, x86: Separate out rom resource claim
PCI, x86: Addpcibios_fw_addr_done
PCI, x86: Remove__initfor hw/fw allocated functions PCI, x86: Claim FW allocated resources in hot add path. PCI, ACPI: reserve fw allocated resource for hot added root busQuoted 6 lines
arch/x86/pci/i386.c | 185 +++++++++++++++++++++++++++++++---------------- drivers/acpi/pci_root.c | 4 +- drivers/pci/bus.c | 2 + include/linux/pci.h | 1 + 4 files changed, 127 insertions(+), 65 deletions(-)
Quoted 5 lines
Bjorn,
Can you queue those 8 patches for v3.9 in pci tree?
So I could resend out other pci root hotplug patches.
I'm really sorry that it's taken me so long to get to these.
I applied these to my pci/yinghai-survey-resources branch. I re-ordered the last two and reworked some of the changelogs.
In general these look good. My main concern is that they only touch x86, without touching the similar code in frv, microblaze, mn10300, and powerpc.
This code (pcibios_resource_survey(), pcibios_assign_resources(), pcibios_allocate_resources(), pcibios_allocate_bus_resources()) was obviously copied from x86 originally, and I'd like to preserve the similarity between them. It would be even better to refactor it so it's actually *shared*, but I don't think that's a requirement right now.
If we allow it to diverge now, it will make it harder to refactor and harder to notice when bug fixes should be applied to all of them. For example, looking at pcibios_allocate_resources(), commit 575939cf5 added some SR-IOV support to x86. Should similar code be added for frv, microblaze, mn10300, and powerpc?
Anybody else have thoughts on this?
Bjorn
Bjorn Helgaas
maintainerRe: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
Quoted 37 lines · Bjorn Helgaas
[+cc David, Michal, Koichi, Ben, Paul]
Quoted 34 lines · Yinghai Lu
Quoted 24 lines · Yinghai Lu
For root bus hot add, fw could assign some resource for the devices for that root bus before notifying os via acpi, we should check and use those resources at first just like we do for booting path.
At first, we need to refactor x86 pci
pcibios_allocaterelated functions for booting path to take bus as parameter.After that, we could use the survey function for hot add root bus.
based on pci/yinghai-for-pci-root-bus-hotplug
could get from
git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.gitfor-pci-survey-resourcesYinghai Lu (8):
PCI, x86: Separate outpcibios_allocate_bridge_resources()PCI, x86: Separate outpcibios_allocate_dev_resources()PCI, x86: Letpcibios_allocate_bus_resources()take bus instead PCI, x86: Separate out rom resource claim
PCI, x86: Addpcibios_fw_addr_done
PCI, x86: Remove__initfor hw/fw allocated functions PCI, x86: Claim FW allocated resources in hot add path. PCI, ACPI: reserve fw allocated resource for hot added root busQuoted 6 lines
arch/x86/pci/i386.c | 185 +++++++++++++++++++++++++++++++---------------- drivers/acpi/pci_root.c | 4 +- drivers/pci/bus.c | 2 + include/linux/pci.h | 1 + 4 files changed, 127 insertions(+), 65 deletions(-)Bjorn,
Quoted 8 lines
Quoted 3 lines
Can you queue those 8 patches for v3.9 in pci tree?
So I could resend out other pci root hotplug patches.
I'm really sorry that it's taken me so long to get to these.
I applied these to my pci/yinghai-survey-resources branch. I re-ordered the last two and reworked some of the changelogs.
To be clear about this, the pci/yinghai-survey-resources branch I mentioned is a staging branch that just gets build test coverage. I don't plan to actually merge this or put it into -next until the questions below are resolved.
My inclination, until I'm persuaded otherwise, is to wait for patches that preserve the similarities among these architectures.
Quoted 20 lines
In general these look good. My main concern is that they only touch x86, without touching the similar code in frv, microblaze, mn10300, and powerpc.
This code (
pcibios_resource_survey(),pcibios_assign_resources(),pcibios_allocate_resources(),pcibios_allocate_bus_resources()) was obviously copied from x86 originally, and I'd like to preserve the similarity between them. It would be even better to refactor it so it's actually *shared*, but I don't think that's a requirement right now.If we allow it to diverge now, it will make it harder to refactor and harder to notice when bug fixes should be applied to all of them. For example, looking at
pcibios_allocate_resources(), commit575939cf5added some SR-IOV support to x86. Should similar code be added for frv, microblaze, mn10300, and powerpc?Anybody else have thoughts on this?
Bjorn
Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
Quoted 5 lines · Bjorn Helgaas
Quoted 4 lines
I'm really sorry that it's taken me so long to get to these.
I applied these to my pci/yinghai-survey-resources branch. I re-ordered the last two and reworked some of the changelogs.
Quoted 7 lines
To be clear about this, the pci/yinghai-survey-resources branch I mentioned is a staging branch that just gets build test coverage. I don't plan to actually merge this or put it into -next until the questions below are resolved.
My inclination, until I'm persuaded otherwise, is to wait for patches that preserve the similarities among these architectures.
I don't know, that could be separated patcheset after we conclude pci root bus hotplug support.
Quoted 11 lines
Quoted 11 lines
In general these look good. My main concern is that they only touch x86, without touching the similar code in frv, microblaze, mn10300, and powerpc.
This code (
pcibios_resource_survey(),pcibios_assign_resources(),pcibios_allocate_resources(),pcibios_allocate_bus_resources()) was obviously copied from x86 originally, and I'd like to preserve the similarity between them. It would be even better to refactor it so it's actually *shared*, but I don't think that's a requirement right now.
yes, should be moved to drivers/pci
Quoted 6 lines
Quoted 6 lines
If we allow it to diverge now, it will make it harder to refactor and harder to notice when bug fixes should be applied to all of them. For example, looking at
pcibios_allocate_resources(), commit575939cf5added some SR-IOV support to x86. Should similar code be added for frv, microblaze, mn10300, and powerpc?
should be treated the same.
Quoted 4 lines
Quoted 4 lines
Anybody else have thoughts on this?
Bjorn
Bjorn Helgaas
maintainerRe: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
Quoted 11 lines · Yinghai Lu
Quoted 10 lines · Bjorn Helgaas
Quoted 4 lines
I'm really sorry that it's taken me so long to get to these.
I applied these to my pci/yinghai-survey-resources branch. I re-ordered the last two and reworked some of the changelogs.
To be clear about this, the pci/yinghai-survey-resources branch I mentioned is a staging branch that just gets build test coverage. I don't plan to actually merge this or put it into -next until the questions below are resolved.
Quoted 5 lines
Quoted 2 lines
My inclination, until I'm persuaded otherwise, is to wait for patches that preserve the similarities among these architectures.
I don't know, that could be separated patcheset after we conclude pci root bus hotplug support.
The main reason I review patches before merging them is to identify issues that we can fix before they affect everybody. It makes my life a lot easier if I don't have to keep track of pending unaddressed review comments. Is there an advantage to waiting and doing this work later?
Quoted 26 lines
Quoted 10 lines
Quoted 10 lines
In general these look good. My main concern is that they only touch x86, without touching the similar code in frv, microblaze, mn10300, and powerpc.
This code (
pcibios_resource_survey(),pcibios_assign_resources(),pcibios_allocate_resources(),pcibios_allocate_bus_resources()) was obviously copied from x86 originally, and I'd like to preserve the similarity between them. It would be even better to refactor it so it's actually *shared*, but I don't think that's a requirement right now.yes, should be moved to
drivers/pciQuoted 6 lines
Quoted 6 lines
If we allow it to diverge now, it will make it harder to refactor and harder to notice when bug fixes should be applied to all of them. For example, looking at
pcibios_allocate_resources(), commit575939cf5added some SR-IOV support to x86. Should similar code be added for frv, microblaze, mn10300, and powerpc?should be treated the same.
Quoted 4 lines
Quoted 4 lines
Anybody else have thoughts on this?
Bjorn
Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
Quoted 12 lines · Bjorn Helgaas
Quoted 2 lines
I don't know, that could be separated patcheset after we conclude pci root bus hotplug support.
The main reason I review patches before merging them is to identify issues that we can fix before they affect everybody. It makes my life a lot easier if I don't have to keep track of pending unaddressed review comments. Is there an advantage to waiting and doing this work later?
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
In general these look good. My main concern is that they only touch x86, without touching the similar code in frv, microblaze, mn10300, and powerpc.
the reason why we need to change those codes for x86, we want to make it support pci root bus hotplug. So it would be reasonable for us to align other platform to x86
changes after pci root bus hotplug change is completely done.
Also I have for_dev_each_res patches rely on this patchset.
After those done, we can move the code from x86 to drivers/pci and delete other arches code one by one.
Yinghai
Bjorn Helgaas
maintainerRe: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
Quoted 10 lines · Yinghai Lu
Quoted 9 lines · Bjorn Helgaas
Quoted 2 lines
I don't know, that could be separated patcheset after we conclude pci root bus hotplug support.
The main reason I review patches before merging them is to identify issues that we can fix before they affect everybody. It makes my life a lot easier if I don't have to keep track of pending unaddressed review comments. Is there an advantage to waiting and doing this work later?
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
In general these look good. My main concern is that they only touch x86, without touching the similar code in frv, microblaze, mn10300, and powerpc.
the reason why we need to change those codes for x86, we want to make it support pci root bus hotplug. So it would be reasonable for us to align other platform to x86
changes after pci root bus hotplug change is completely done.
OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a way to keep track of this consistency issue and merged pci/yinghai-survey-resources to my -next branch.
Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
Quoted 8 lines · Bjorn Helgaas
Quoted 4 lines
the reason why we need to change those codes for x86, we want to make it support pci root bus hotplug. So it would be reasonable for us to align other platform to x86
changes after pci root bus hotplug change is completely done.OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a way to keep track of this consistency issue and merged pci/yinghai-survey-resources to my -next branch.
Thanks a lot. will send other pci root bus hotplug out.
question: now Rafael's tree has acpi-scan branch and it touches pci-root.c.
so is it ok for me to base patches on your pci/next and his pm/acpi-scan? how?
can you two have some arrangement like you pulling Rafael's branch?
Thanks
Yinghai
Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
Quoted 10 lines · Yinghai Lu
Quoted 8 lines · Bjorn Helgaas
Quoted 4 lines
the reason why we need to change those codes for x86, we want to make it support pci root bus hotplug. So it would be reasonable for us to align other platform to x86
changes after pci root bus hotplug change is completely done.OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a way to keep track of this consistency issue and merged pci/yinghai-survey-resources to my -next branch.
Quoted 7 lines
Thanks a lot. will send other pci root bus hotplug out.
question: now Rafael's tree has acpi-scan branch and it touches
pci-root.c.so is it ok for me to base patches on your pci/next and his pm/acpi-scan? how?
can you two have some arrangement like you pulling Rafael's branch?
My acpi-scan branch is not going to be rebased going forward, so it can be pulled from safely if that helps.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Bjorn Helgaas
maintainerRe: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
Quoted 13 lines · Rafael J. Wysocki
Quoted 12 lines · Yinghai Lu
Quoted 8 lines · Bjorn Helgaas
Quoted 4 lines
the reason why we need to change those codes for x86, we want to make it support pci root bus hotplug. So it would be reasonable for us to align other platform to x86
changes after pci root bus hotplug change is completely done.OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a way to keep track of this consistency issue and merged pci/yinghai-survey-resources to my -next branch.
Thanks a lot. will send other pci root bus hotplug out.
Quoted 8 lines
Quoted 5 lines
question: now Rafael's tree has acpi-scan branch and it touches
pci-root.c.so is it ok for me to base patches on your pci/next and his pm/acpi-scan? how?
can you two have some arrangement like you pulling Rafael's branch?My acpi-scan branch is not going to be rebased going forward, so it can be pulled from safely if that helps.
I'm happy to do that, but it is outside the scope of my limited git experience. My guess is that I should do this (doing the pull into a branch which I later merge into my -next branch):
$ git checkout -b pci/yinghai-survey-resources+acpi-scan pci/yinghai-survey-resources $ git pull --no-ff --log git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git acpi-scan $ vi drivers/acpi/pci_root.c # resolve conflicts $ git add drivers/acpi/pci_root.c $ git commit
$ git checkout next $ git merge --no-ff --log pci/yinghai-survey-resources+acpi-scan
Is that reasonable? This won't cause issues when both Rafael and I ask Linus to pull from our trees later?
Bjorn
Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
Quoted 36 lines · Bjorn Helgaas
Quoted 13 lines · Rafael J. Wysocki
Quoted 12 lines · Yinghai Lu
Quoted 8 lines · Bjorn Helgaas
Quoted 4 lines
the reason why we need to change those codes for x86, we want to make it support pci root bus hotplug. So it would be reasonable for us to align other platform to x86
changes after pci root bus hotplug change is completely done.OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a way to keep track of this consistency issue and merged pci/yinghai-survey-resources to my -next branch.
Thanks a lot. will send other pci root bus hotplug out.
Quoted 8 lines
Quoted 5 lines
question: now Rafael's tree has acpi-scan branch and it touches
pci-root.c.so is it ok for me to base patches on your pci/next and his pm/acpi-scan? how?
can you two have some arrangement like you pulling Rafael's branch?My acpi-scan branch is not going to be rebased going forward, so it can be pulled from safely if that helps.
I'm happy to do that, but it is outside the scope of my limited git experience. My guess is that I should do this (doing the pull into a branch which I later merge into my -next branch):
$ git checkout -b pci/yinghai-survey-resources+acpi-scan pci/yinghai-survey-resources $ git pull --no-ff --log git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git acpi-scan $ vi drivers/acpi/pci_root.c # resolve conflicts $ git add drivers/acpi/pci_root.c $ git commit
Quoted 4 lines
$ git checkout next $ git merge --no-ff --log pci/yinghai-survey-resources+acpi-scanIs that reasonable?
Yes, it looks reasonable.
Quoted 2 lines
This won't cause issues when both Rafael and I ask Linus to pull from our trees later?
No, it won't, as long as I don't rebase the original acpi-scan branch (which I'm not going to do) and you don't rebase your pci/yinghai-survey-resources+acpi-scan branch going forward.
The pull makes your tree contain the same commits (i.e. commit IDs along with the data) that are in my acpi-scan branch, so when Linus merges them together, git will notice that the commits are the same.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Bjorn Helgaas
maintainerRe: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
Quoted 47 lines · Rafael J. Wysocki
Quoted 36 lines · Bjorn Helgaas
Quoted 13 lines · Rafael J. Wysocki
Quoted 12 lines · Yinghai Lu
Quoted 8 lines · Bjorn Helgaas
Quoted 4 lines
the reason why we need to change those codes for x86, we want to make it support pci root bus hotplug. So it would be reasonable for us to align other platform to x86
changes after pci root bus hotplug change is completely done.OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a way to keep track of this consistency issue and merged pci/yinghai-survey-resources to my -next branch.
Thanks a lot. will send other pci root bus hotplug out.
Quoted 8 lines
Quoted 5 lines
question: now Rafael's tree has acpi-scan branch and it touches
pci-root.c.so is it ok for me to base patches on your pci/next and his pm/acpi-scan? how?
can you two have some arrangement like you pulling Rafael's branch?My acpi-scan branch is not going to be rebased going forward, so it can be pulled from safely if that helps.
I'm happy to do that, but it is outside the scope of my limited git experience. My guess is that I should do this (doing the pull into a branch which I later merge into my -next branch):
$ git checkout -b pci/yinghai-survey-resources+acpi-scan pci/yinghai-survey-resources $ git pull --no-ff --log git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git acpi-scan $ vi drivers/acpi/pci_root.c # resolve conflicts $ git add drivers/acpi/pci_root.c $ git commitQuoted 4 lines
$ git checkout next $ git merge --no-ff --log pci/yinghai-survey-resources+acpi-scanIs that reasonable?
Yes, it looks reasonable.
Quoted 2 lines
This won't cause issues when both Rafael and I ask Linus to pull from our trees later?
Quoted 7 lines
No, it won't, as long as I don't rebase the original acpi-scan branch (which I'm not going to do) and you don't rebase your pci/yinghai-survey-resources+acpi-scan branch going forward.
The pull makes your tree contain the same commits (i.e. commit IDs along with the data) that are in my acpi-scan branch, so when Linus merges them together, git will notice that the commits are the same.
OK, I did the above, merged it into my -next branch, and pushed it. Let me know if you see any issues.
Bjorn
Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
In reply to Bjorn HelgaasQuoted 11 lines · Bjorn Helgaas
Quoted 2 lines
the reason why we need to change those codes for x86, we want to
make it support
Quoted 1 line
pci root bus hotplug. So it would be reasonable for us to align
other
Quoted 2 lines
platform to x86
changes after pci root bus hotplug change is completely done.OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a way to keep track of this consistency issue and merged pci/yinghai-survey-resources to my -next branch.
Hrm... that's going to be tricky. For example the SR-IOV stuff will not work for us, we are working on a different implementation, due to some of "interesting" bridge constraints etc...
It would be nice to get more of the resource survey in common, our original code was actually completely different and I reconciled it a lot with x86 in the past few years, but I'm sure we can do better. However there are still going to be corner cases....
Ben.
Bjorn Helgaas
maintainerRe: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
In reply to Bjorn HelgaasQuoted 9 lines · Bjorn Helgaas
Quoted 4 lines · Yinghai Lu
the reason why we need to change those codes for x86, we want to make it support pci root bus hotplug. So it would be reasonable for us to align other platform to x86
changes after pci root bus hotplug change is completely done.OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a way to keep track of this consistency issue ...
What's your plan for this? We desperately need more cross-arch consistency in how we manage resources, and I'd like to make some progress in this cycle.
Bjorn
Re: [PATCH 0/8] PCI, ACPI, x86: Reserve fw allocated resource for hot-add root bus
Quoted 8 lines · Bjorn Helgaas
Quoted 7 lines · Bjorn Helgaas
Quoted 4 lines · Yinghai Lu
the reason why we need to change those codes for x86, we want to make it support pci root bus hotplug. So it would be reasonable for us to align other platform to x86
changes after pci root bus hotplug change is completely done.
Quoted 6 lines
Quoted 2 lines
OK, I opened https://bugzilla.kernel.org/show_bug.cgi?id=52531 as a way to keep track of this consistency issue ...
What's your plan for this? We desperately need more cross-arch consistency in how we manage resources, and I'd like to make some progress in this cycle.
Ok, will work on that.
but will on top of
[PATCH v5 0/7] PCI: Change assign unassigned resources per root bus bassis and attached.
will resend them after v3.11-rc1 is out.
Thanks
Yinghai
Subject: [PATCH] PCI: check pci bus address for unassigned res
We should compare res->start with root bus window offset. Otherwise will have problem with arch that support hostbridge resource offset.
BenH pointed out that during reviewing patchset that separate assign unassigned to per root buses.
According to Bjorn, have it in separated patch.
Use pcibios_resource_to_bus to get region at first, and check region.start instead.
--- drivers/pci/setup-bus.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/pci/setup-bus.c +6 -1
@@ -1420,9 +1420,14 @@ static int check_unassigned_resources(stfor (i =PCI_IOV_RESOURCES ; i <=PCI_IOV_RESOURCE_END ; i++) {struct resource *r = &dev->resource[i]; +struct pci_bus_region region;/* Not assigned, or rejected by kernel ? */ -if (r->flags && !r->start) { +if (!r->flags) +continue ; + +pcibios_resource_to_bus (dev, ®ion, r); +if (!region.start) { (*unassigned)++;return 1 ;/* return early from pci_walk_bus */ }
PATCH v3 8/8 ACPI, PCI: add resoruce-assign code for devices under hot-added hostbridge
In reply to Taku IzumiDevices under hot-added hostbridge have no chance to assign resources and to configure them, so this patch adds such code for hot-added hostbridges at acpi_pci_root_start().
--- drivers/acpi/pci_root.c | 17 +++++++++++++++++ include/acpi/acpi_bus.h | 1 + 2 files changed, 18 insertions(+)
drivers/acpi/pci_root.c +17 -0
@@ -38,6 +38,7 @@#include <acpi/acpi_bus.h> #include <acpi/acpi_drivers.h> #include <acpi/apei.h> +#include <linux/pci_hotplug.h> #define PREFIX "ACPI: "
@@ -459,6 +460,9 @@ static int __devinit acpi_pci_root_add(sif (!root)return -ENOMEM ; +if (system_state !=SYSTEM_BOOTING ) + root->hot_added = true; + segment =0 ; status =acpi_evaluate_integer (device->handle,METHOD_NAME__SEG ,NULL , &segment);
@@ -636,6 +640,7 @@ static int acpi_pci_root_start(struct ac {struct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +struct pci_dev *pdev;mutex_lock (&acpi_pci_root_lock);list_for_each_entry (driver, &acpi_pci_drivers, node)
@@ -643,6 +648,18 @@ static int acpi_pci_root_start(struct ac driver->add (root);mutex_unlock (&acpi_pci_root_lock); +/* +* Devices under hot-added hostbridge have no chance to assign +* resources and to configure them, so do that here +*/ +if (root->hot_added) { +pci_bus_size_bridges (root->bus); +pci_bus_assign_resources (root->bus); +list_for_each_entry (pdev, &root->bus->devices, bus_list) +pci_configure_slot (pdev); +pci_enable_bridges (root->bus); + } +pci_bus_add_devices (root->bus);return 0 ;
include/acpi/acpi_bus.h +1 -0
@@ -407,6 +407,7 @@ struct acpi_pci_root {u32 osc_support_set;/* _OSC state of support bits */ u32 osc_control_set;/* _OSC state of control bits */ phys_addr_t mcfg_addr; +bool hot_added; };/* helper */
Re: [PATCH v3 8/8] ACPI, PCI: add resoruce-assign code for devices under hot-added hostbridge
Quoted 24 lines · Taku Izumi
Devices under hot-added hostbridge have no chance to assign resources and to configure them, so this patch adds such code for hot-added hostbridges at
acpi_pci_root_start().Signed-off-by Taku Izumi <[email protected]>--- drivers/acpi/pci_root.c | 17 +++++++++++++++++ include/acpi/acpi_bus.h | 1 + 2 files changed, 18 insertions(+)Index:
Bjorn-next-0903/drivers/acpi/pci_root.c
===================================================================drivers/acpi/pci_root.c +1
-0@@ -38,6 +38,7 @@#include <acpi/acpi_bus.h> #include <acpi/acpi_drivers.h> #include <acpi/apei.h> +#include <linux/pci_hotplug.h> #define PREFIX "ACPI: "
drivers/acpi/pci_root.c static int __devinit acpi_pci_root_add(s · line 465
Quoted 6 lines
drivers/acpi/pci_root.c +3
-0@@ -459,6 +460,9 @@ static int __devinit acpi_pci_root_add(sif (!root)return -ENOMEM ; +if (system_state !=SYSTEM_BOOTING ) + root->hot_added = true; +
should be moved down just before return.
Quoted 16 lines
drivers/acpi/pci_root.c +2
-0segment =0 ; status =acpi_evaluate_integer (device->handle,METHOD_NAME__SEG ,NULL , &segment);@@ -636,6 +640,7 @@ static int acpi_pci_root_start(struct ac {struct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +struct pci_dev *pdev;mutex_lock (&acpi_pci_root_lock);list_for_each_entry (driver, &acpi_pci_drivers, node)@@ -643,6 +648,18 @@ static int acpi_pci_root_start(struct ac driver->add (root);mutex_unlock (&acpi_pci_root_lock); +/*
drivers/acpi/pci_root.c static int acpi_pci_root_start(struct ac · line 661
Quoted 10 lines
drivers/acpi/pci_root.c +10
-0+* Devices under hot-added hostbridge have no chance to assign +* resources and to configure them, so do that here +*/ +if (root->hot_added) { +pci_bus_size_bridges (root->bus); +pci_bus_assign_resources (root->bus); +list_for_each_entry (pdev, &root->bus->devices, bus_list) +pci_configure_slot (pdev); +pci_enable_bridges (root->bus); + }
should move that before acpi_pci_drivers.add calling
Quoted 17 lines
drivers/acpi/pci_root.c +1
-0+pci_bus_add_devices (root->bus);return 0 ;Index:
Bjorn-next-0903/include/acpi/acpi_bus.h
===================================================================include/acpi/acpi_bus.h +1
-0@@ -407,6 +407,7 @@ struct acpi_pci_root {u32 osc_support_set;/* _OSC state of support bits */ u32 osc_control_set;/* _OSC state of control bits */ phys_addr_t mcfg_addr; +bool hot_added; };/* helper */
Re: [PATCH v3 8/8] ACPI, PCI: add resoruce-assign code for devices under hot-added hostbridge
Quoted 36 lines · Yinghai Lu
Quoted 35 lines · Taku Izumi
Devices under hot-added hostbridge have no chance to assign resources and to configure them, so this patch adds such code for hot-added hostbridges at
acpi_pci_root_start().Signed-off-by Taku Izumi <[email protected]>--- drivers/acpi/pci_root.c | 17 +++++++++++++++++ include/acpi/acpi_bus.h | 1 + 2 files changed, 18 insertions(+)Index:
Bjorn-next-0903/drivers/acpi/pci_root.c
===================================================================drivers/acpi/pci_root.c +2
-0@@ -38,6 +38,7 @@#include <acpi/acpi_bus.h> #include <acpi/acpi_drivers.h> #include <acpi/apei.h> +#include <linux/pci_hotplug.h> #define PREFIX "ACPI: "@@ -636,6 +640,7 @@ static int acpi_pci_root_start(struct ac {struct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +struct pci_dev *pdev;mutex_lock (&acpi_pci_root_lock);list_for_each_entry (driver, &acpi_pci_drivers, node)@@ -643,6 +648,18 @@ static int acpi_pci_root_start(struct ac driver->add (root);mutex_unlock (&acpi_pci_root_lock);
Quoted 9 lines
drivers/acpi/pci_root.c static int acpi_pci_root_start(struct ac · line 659
Quoted 9 lines
drivers/acpi/pci_root.c +9
-0+/* +* Devices under hot-added hostbridge have no chance to assign +* resources and to configure them, so do that here +*/ +if (root->hot_added) { +pci_bus_size_bridges (root->bus); +pci_bus_assign_resources (root->bus); +list_for_each_entry (pdev, &root->bus->devices, bus_list) +pci_configure_slot (pdev);
one more problem, this one will have problem when CONFIG_HOTPLUG_PCI=m or not defined.
Also I do not see the point to call pci_config_slot here - my patcheset did not do that, So how do you figure that out?
or you just need to have mpss set?
Bjorn, You may need to have a patch that will enable CONFIG_HOTPLUG_PCI just Greg's enabling CONIFG_HOTPLUG forcely.
Yinghai
Re: [PATCH v3 8/8] ACPI, PCI: add resoruce-assign code for devices under hot-added hostbridge
Devices under hot-added hostbridge have no chance to assign resources and to configure them, so this patch adds such code for hot-added hostbridges at acpi_pci_root_start().
diff: updated according to Yinhai's comment
disconnect dependency on CONFIG_HOTPLUG
--- drivers/acpi/pci_root.c | 13 +++++++++++++ include/acpi/acpi_bus.h | 1 + 2 files changed, 14 insertions(+)
drivers/acpi/pci_root.c +13 -0
@@ -628,6 +628,9 @@ static int __devinit acpi_pci_root_add(sif (device->wakeup.flags.run_wake)device_set_run_wake (root->bus->bridge, true); +if (system_state !=SYSTEM_BOOTING ) + root->hot_added = true; +return 0 ; out_del_root:
@@ -644,6 +647,16 @@ static int acpi_pci_root_start(struct acstruct acpi_pci_root *root =acpi_driver_data (device);struct acpi_pci_driver *driver; +/* +* Devices under hot-added hostbridge have no chance to assign +* resources and to configure them, so do that here +*/ +if (root->hot_added) { +pci_bus_size_bridges (root->bus); +pci_bus_assign_resources (root->bus); +pci_enable_bridges (root->bus); + } +mutex_lock (&acpi_pci_root_lock);list_for_each_entry (driver, &acpi_pci_drivers, node)if (driver->add)
include/acpi/acpi_bus.h +1 -0
@@ -407,6 +407,7 @@ struct acpi_pci_root {u32 osc_support_set;/* _OSC state of support bits */ u32 osc_control_set;/* _OSC state of control bits */ phys_addr_t mcfg_addr; +bool hot_added; };/* helper */
Quoted 11 lines · Taku Izumi
Hi all,
This patchset is 3rd version of the following:
http://marc.info/?l=linux-pci&m=134457928913775&w=2 http://marc.info/?l=linux-pci&m=134665909321684&w=2v2 -> v3:
- changeacpi_pci_drivers' add/remove interface according to Bjorn's suggestion
- abandon RCU for protectingacpi_pci_rootslist according to Bjorn's suggestion
- changeacpi_pci_find_rootimplementation to avoid potential deadlock
Quoted 8 lines
* [PATCH v3 1/8] ACPI, PCI: Use normal list for struct
acpi_pci_driver
* [PATCH v3 2/8] ACPI, PCI: Notifyacpi_pci_driverswhen hot-plugging PCI root bridges
* [PATCH v3 3/8] ACPI, PCI: addacpi_pci_driversprotection
* [PATCH v3 4/8] ACPI, PCI: changeacpi_pci_drivers' add/remove interface
* [PATCH v3 5/8] ACPI, PCI: changeacpi_pci_find_rootimplementation
* [PATCH v3 6/8] ACPI, PCI: addacpi_pci_rootsprotection
* [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
* [PATCH v3 8/8] ACPI, PCI: add resoruce-assign code for devices under hot-added hostbridge
now it is more similar to my for-pci-root-bus-hotplug-part4 and part5
big difference:
I separated code from acpiphp_glue.c to pci_root_hp.c for root bridge hotplug support
I thought we all agreed on that acpi root bridge hotplug plug need to be separated from acpiphp at first.
and CONFIG_HOTPLUG will always be enabled, so root bridge hotplug will be always enabled.
acpiphp will still be used as one module, and to keep it simple pciehp will be used for pcie etc.
That make the system BIOS much simple to avoid acpiphp.
Thanks
Yinghai
Quoted 32 lines · Yinghai Lu
Quoted 11 lines · Taku Izumi
Hi all,
This patchset is 3rd version of the following:
http://marc.info/?l=linux-pci&m=134457928913775&w=2 http://marc.info/?l=linux-pci&m=134665909321684&w=2v2 -> v3:
- changeacpi_pci_drivers' add/remove interface according to Bjorn's suggestion
- abandon RCU for protectingacpi_pci_rootslist according to Bjorn's suggestion
- changeacpi_pci_find_rootimplementation to avoid potential deadlockQuoted 8 lines
* [PATCH v3 1/8] ACPI, PCI: Use normal list for struct
acpi_pci_driver
* [PATCH v3 2/8] ACPI, PCI: Notifyacpi_pci_driverswhen hot-plugging PCI root bridges
* [PATCH v3 3/8] ACPI, PCI: addacpi_pci_driversprotection
* [PATCH v3 4/8] ACPI, PCI: changeacpi_pci_drivers' add/remove interface
* [PATCH v3 5/8] ACPI, PCI: changeacpi_pci_find_rootimplementation
* [PATCH v3 6/8] ACPI, PCI: addacpi_pci_rootsprotection
* [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
* [PATCH v3 8/8] ACPI, PCI: add resoruce-assign code for devices under hot-added hostbridgenow it is more similar to my for-pci-root-bus-hotplug-part4 and part5
big difference:
I separated code fromacpiphp_glue.ctopci_root_hp.cfor root bridge hotplug supportI thought we all agreed on that acpi root bridge hotplug plug need to be separated from acpiphp at first.
Quoted 7 lines
and
CONFIG_HOTPLUGwill always be enabled, so root bridge hotplug will be always enabled.
acpiphp will still be used as one module, and to keep it simple pciehp will be used for pcie etc.
That make the system BIOS much simple to avoid acpiphp.
also current acpiphp only have root bridge add notification. and your code do not add any code for remove notification.
So how to you test your code with removal path?
Thanks
Yinghai
Quoted 41 lines · On Tue, 18 Sep 2012 11:57:59 -0700 Yinghai Lu <[email protected]> wrote:
Quoted 32 lines · Yinghai Lu
Quoted 11 lines · Taku Izumi
Hi all,
This patchset is 3rd version of the following:
http://marc.info/?l=linux-pci&m=134457928913775&w=2 http://marc.info/?l=linux-pci&m=134665909321684&w=2v2 -> v3:
- changeacpi_pci_drivers' add/remove interface according to Bjorn's suggestion
- abandon RCU for protectingacpi_pci_rootslist according to Bjorn's suggestion
- changeacpi_pci_find_rootimplementation to avoid potential deadlockQuoted 8 lines
* [PATCH v3 1/8] ACPI, PCI: Use normal list for struct
acpi_pci_driver
* [PATCH v3 2/8] ACPI, PCI: Notifyacpi_pci_driverswhen hot-plugging PCI root bridges
* [PATCH v3 3/8] ACPI, PCI: addacpi_pci_driversprotection
* [PATCH v3 4/8] ACPI, PCI: changeacpi_pci_drivers' add/remove interface
* [PATCH v3 5/8] ACPI, PCI: changeacpi_pci_find_rootimplementation
* [PATCH v3 6/8] ACPI, PCI: addacpi_pci_rootsprotection
* [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
* [PATCH v3 8/8] ACPI, PCI: add resoruce-assign code for devices under hot-added hostbridgenow it is more similar to my for-pci-root-bus-hotplug-part4 and part5
big difference:
I separated code fromacpiphp_glue.ctopci_root_hp.cfor root bridge hotplug supportI thought we all agreed on that acpi root bridge hotplug plug need to be separated from acpiphp at first.
Quoted 7 lines
and
CONFIG_HOTPLUGwill always be enabled, so root bridge hotplug will be always enabled.
acpiphp will still be used as one module, and to keep it simple pciehp will be used for pcie etc.
That make the system BIOS much simple to avoid acpiphp.
Quoted 4 lines
also current acpiphp only have root bridge add notification. and your code do not add any code for remove notification.
So how to you test your code with removal path?
You were saying how to hot-remove hostbridge ?
I tested by ejecting ACPI container which includes hostbridge. acpiphp is not the only way to hotplug hostbridge, so I ommit acpiphp work from this patchset. This patchset is core part.
Best regards,
Taku Izumi <[email protected]>
Quoted 10 lines · Taku Izumi
On Tue, 18 Sep 2012 11:57:59 -0700
Quoted 4 lines
also current acpiphp only have root bridge add notification. and your code do not add any code for remove notification.
So how to you test your code with removal path?
You were saying how to hot-remove hostbridge ?
I tested by ejecting ACPI container which includes hostbridge. acpiphp is not the only way to hotplug hostbridge, so I ommit acpiphp work from this patchset. This patchset is core part.
yes.
so acpi root for pci root bus will have parent? I did not think about.
I reordered my patchset and put updated version for your patch 8 into it.
the whole tree:
git://git.kernel.org/pub/scm/linux/kernel/git/yinghai/linux-yinghai.git
for-pci-root-bus-hotplug
Thanks
Yinghai
Quoted 32 lines · Yinghai Lu
Quoted 11 lines · Taku Izumi
Hi all,
This patchset is 3rd version of the following:
http://marc.info/?l=linux-pci&m=134457928913775&w=2 http://marc.info/?l=linux-pci&m=134665909321684&w=2v2 -> v3:
- changeacpi_pci_drivers' add/remove interface according to Bjorn's suggestion
- abandon RCU for protectingacpi_pci_rootslist according to Bjorn's suggestion
- changeacpi_pci_find_rootimplementation to avoid potential deadlockQuoted 8 lines
* [PATCH v3 1/8] ACPI, PCI: Use normal list for struct
acpi_pci_driver
* [PATCH v3 2/8] ACPI, PCI: Notifyacpi_pci_driverswhen hot-plugging PCI root bridges
* [PATCH v3 3/8] ACPI, PCI: addacpi_pci_driversprotection
* [PATCH v3 4/8] ACPI, PCI: changeacpi_pci_drivers' add/remove interface
* [PATCH v3 5/8] ACPI, PCI: changeacpi_pci_find_rootimplementation
* [PATCH v3 6/8] ACPI, PCI: addacpi_pci_rootsprotection
* [PATCH v3 7/8] ACPI, PCI: add hostbridge removal function
* [PATCH v3 8/8] ACPI, PCI: add resoruce-assign code for devices under hot-added hostbridgenow it is more similar to my for-pci-root-bus-hotplug-part4 and part5
big difference:
I separated code fromacpiphp_glue.ctopci_root_hp.cfor root bridge hotplug supportI thought we all agreed on that acpi root bridge hotplug plug need to be separated from acpiphp at first.
Quoted 7 lines
and
CONFIG_HOTPLUGwill always be enabled, so root bridge hotplug will be always enabled.
acpiphp will still be used as one module, and to keep it simple pciehp will be used for pcie etc.
That make the system BIOS much simple to avoid acpiphp.
I think it's a better way to separate host bridge hotplug functionality from acpiphp driver, so acpiphp only handles PCI device hotplug, which is much more clear.
--Gerry