Commit a3b6bbd5 authored by Bjorn Helgaas's avatar Bjorn Helgaas

Merge branch 'pci/jiang-subdrivers' into next

* pci/jiang-subdrivers:
  PCI/ACPI: Remove support of ACPI PCI subdrivers
  PCI: acpiphp: Protect acpiphp data structures from concurrent updates
  PCI: acpiphp: Use normal list to simplify implementation
  PCI: acpiphp: Do not use ACPI PCI subdriver mechanism
  PCI: acpiphp: Convert acpiphp to be builtin only, not modular
  PCI/ACPI: Handle PCI slot devices when creating/destroying PCI buses
  x86/PCI: Implement pcibios_{add|remove}_bus() hooks
  ia64/PCI: Implement pcibios_{add|remove}_bus() hooks
  PCI/ACPI: Prepare stub functions to handle ACPI PCI (hotplug) slots
  PCI: Add pcibios hooks for adding and removing PCI buses
  PCI: acpiphp: Replace local macros with standard ACPI macros
  PCI: acpiphp: Remove all functions even if function 0 doesn't exist
  PCI: acpiphp: Use list_for_each_entry_safe() in acpiphp_sanitize_bus()
  PCI: Clean up usages of pci_bus->is_added
  PCI: When removing bus, always remove legacy files & unregister
parents 30e22b23 c309dbb4
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/pci-acpi.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -458,6 +459,16 @@ void pcibios_fixup_bus(struct pci_bus *b) ...@@ -458,6 +459,16 @@ void pcibios_fixup_bus(struct pci_bus *b)
platform_pci_fixup_bus(b); platform_pci_fixup_bus(b);
} }
void pcibios_add_bus(struct pci_bus *bus)
{
acpi_pci_add_bus(bus);
}
void pcibios_remove_bus(struct pci_bus *bus)
{
acpi_pci_remove_bus(bus);
}
void pcibios_set_master (struct pci_dev *dev) void pcibios_set_master (struct pci_dev *dev)
{ {
/* No special bus mastering setup handling */ /* No special bus mastering setup handling */
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/pci-acpi.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/dmi.h> #include <linux/dmi.h>
...@@ -170,6 +171,16 @@ void pcibios_fixup_bus(struct pci_bus *b) ...@@ -170,6 +171,16 @@ void pcibios_fixup_bus(struct pci_bus *b)
pcibios_fixup_device_resources(dev); pcibios_fixup_device_resources(dev);
} }
void pcibios_add_bus(struct pci_bus *bus)
{
acpi_pci_add_bus(bus);
}
void pcibios_remove_bus(struct pci_bus *bus)
{
acpi_pci_remove_bus(bus);
}
/* /*
* Only use DMI information to set this if nothing was passed * Only use DMI information to set this if nothing was passed
* on the kernel command line (which was parsed earlier). * on the kernel command line (which was parsed earlier).
......
...@@ -65,44 +65,12 @@ static struct acpi_scan_handler pci_root_handler = { ...@@ -65,44 +65,12 @@ static struct acpi_scan_handler pci_root_handler = {
.detach = acpi_pci_root_remove, .detach = acpi_pci_root_remove,
}; };
/* Lock to protect both acpi_pci_roots and acpi_pci_drivers lists */ /* Lock to protect both acpi_pci_roots lists */
static DEFINE_MUTEX(acpi_pci_root_lock); static DEFINE_MUTEX(acpi_pci_root_lock);
static LIST_HEAD(acpi_pci_roots); static LIST_HEAD(acpi_pci_roots);
static LIST_HEAD(acpi_pci_drivers);
static DEFINE_MUTEX(osc_lock); static DEFINE_MUTEX(osc_lock);
int acpi_pci_register_driver(struct acpi_pci_driver *driver)
{
int n = 0;
struct acpi_pci_root *root;
mutex_lock(&acpi_pci_root_lock);
list_add_tail(&driver->node, &acpi_pci_drivers);
if (driver->add)
list_for_each_entry(root, &acpi_pci_roots, node) {
driver->add(root);
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)
list_for_each_entry(root, &acpi_pci_roots, node)
driver->remove(root);
mutex_unlock(&acpi_pci_root_lock);
}
EXPORT_SYMBOL(acpi_pci_unregister_driver);
/** /**
* acpi_is_root_bridge - determine whether an ACPI CA node is a PCI root bridge * acpi_is_root_bridge - determine whether an ACPI CA node is a PCI root bridge
* @handle - the ACPI CA node in question. * @handle - the ACPI CA node in question.
...@@ -413,7 +381,6 @@ static int acpi_pci_root_add(struct acpi_device *device, ...@@ -413,7 +381,6 @@ static int acpi_pci_root_add(struct acpi_device *device,
acpi_status status; acpi_status status;
int result; int result;
struct acpi_pci_root *root; struct acpi_pci_root *root;
struct acpi_pci_driver *driver;
u32 flags, base_flags; u32 flags, base_flags;
bool is_osc_granted = false; bool is_osc_granted = false;
...@@ -573,12 +540,6 @@ static int acpi_pci_root_add(struct acpi_device *device, ...@@ -573,12 +540,6 @@ static int acpi_pci_root_add(struct acpi_device *device,
pci_assign_unassigned_bus_resources(root->bus); 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 */ /* need to after hot-added ioapic is registered */
if (system_state != SYSTEM_BOOTING) if (system_state != SYSTEM_BOOTING)
pci_enable_bridges(root->bus); pci_enable_bridges(root->bus);
...@@ -599,16 +560,9 @@ static int acpi_pci_root_add(struct acpi_device *device, ...@@ -599,16 +560,9 @@ static int acpi_pci_root_add(struct acpi_device *device,
static void acpi_pci_root_remove(struct acpi_device *device) static void acpi_pci_root_remove(struct acpi_device *device)
{ {
struct acpi_pci_root *root = acpi_driver_data(device); struct acpi_pci_root *root = acpi_driver_data(device);
struct acpi_pci_driver *driver;
pci_stop_root_bus(root->bus); pci_stop_root_bus(root->bus);
mutex_lock(&acpi_pci_root_lock);
list_for_each_entry_reverse(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); device_set_run_wake(root->bus->bridge, false);
pci_acpi_remove_bus_pm_notifier(device); pci_acpi_remove_bus_pm_notifier(device);
......
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
* Copyright (C) 2007-2008 Hewlett-Packard Development Company, L.P. * Copyright (C) 2007-2008 Hewlett-Packard Development Company, L.P.
* Alex Chiang <achiang@hp.com> * Alex Chiang <achiang@hp.com>
* *
* Copyright (C) 2013 Huawei Tech. Co., Ltd.
* Jiang Liu <jiang.liu@huawei.com>
*
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License, * under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation. * version 2, as published by the Free Software Foundation.
...@@ -28,10 +31,9 @@ ...@@ -28,10 +31,9 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/list.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/acpi.h> #include <linux/acpi.h>
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
#include <linux/dmi.h> #include <linux/dmi.h>
static bool debug; static bool debug;
...@@ -61,20 +63,12 @@ ACPI_MODULE_NAME("pci_slot"); ...@@ -61,20 +63,12 @@ ACPI_MODULE_NAME("pci_slot");
#define SLOT_NAME_SIZE 21 /* Inspired by #define in acpiphp.h */ #define SLOT_NAME_SIZE 21 /* Inspired by #define in acpiphp.h */
struct acpi_pci_slot { struct acpi_pci_slot {
acpi_handle root_handle; /* handle of the root bridge */
struct pci_slot *pci_slot; /* corresponding pci_slot */ struct pci_slot *pci_slot; /* corresponding pci_slot */
struct list_head list; /* node in the list of slots */ struct list_head list; /* node in the list of slots */
}; };
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 LIST_HEAD(slot_list);
static DEFINE_MUTEX(slot_list_lock); static DEFINE_MUTEX(slot_list_lock);
static struct acpi_pci_driver acpi_pci_slot_driver = {
.add = acpi_pci_slot_add,
.remove = acpi_pci_slot_remove,
};
static int static int
check_slot(acpi_handle handle, unsigned long long *sun) check_slot(acpi_handle handle, unsigned long long *sun)
...@@ -113,21 +107,8 @@ check_slot(acpi_handle handle, unsigned long long *sun) ...@@ -113,21 +107,8 @@ check_slot(acpi_handle handle, unsigned long long *sun)
return device; return device;
} }
struct callback_args {
acpi_walk_callback user_function; /* only for walk_p2p_bridge */
struct pci_bus *pci_bus;
acpi_handle root_handle;
};
/* /*
* register_slot * Check whether handle has an associated slot and create PCI slot if it has.
*
* Called once for each SxFy object in the namespace. Don't worry about
* calling pci_create_slot multiple times for the same pci_bus:device,
* since each subsequent call simply bumps the refcount on the pci_slot.
*
* The number of calls to pci_destroy_slot from unregister_slot is
* symmetrical.
*/ */
static acpi_status static acpi_status
register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
...@@ -137,13 +118,22 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -137,13 +118,22 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
char name[SLOT_NAME_SIZE]; char name[SLOT_NAME_SIZE];
struct acpi_pci_slot *slot; struct acpi_pci_slot *slot;
struct pci_slot *pci_slot; struct pci_slot *pci_slot;
struct callback_args *parent_context = context; struct pci_bus *pci_bus = context;
struct pci_bus *pci_bus = parent_context->pci_bus;
device = check_slot(handle, &sun); device = check_slot(handle, &sun);
if (device < 0) if (device < 0)
return AE_OK; return AE_OK;
/*
* There may be multiple PCI functions associated with the same slot.
* Check whether PCI slot has already been created for this PCI device.
*/
list_for_each_entry(slot, &slot_list, list) {
pci_slot = slot->pci_slot;
if (pci_slot->bus == pci_bus && pci_slot->number == device)
return AE_OK;
}
slot = kmalloc(sizeof(*slot), GFP_KERNEL); slot = kmalloc(sizeof(*slot), GFP_KERNEL);
if (!slot) { if (!slot) {
err("%s: cannot allocate memory\n", __func__); err("%s: cannot allocate memory\n", __func__);
...@@ -158,12 +148,8 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -158,12 +148,8 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
return AE_OK; return AE_OK;
} }
slot->root_handle = parent_context->root_handle;
slot->pci_slot = pci_slot; slot->pci_slot = pci_slot;
INIT_LIST_HEAD(&slot->list);
mutex_lock(&slot_list_lock);
list_add(&slot->list, &slot_list); list_add(&slot->list, &slot_list);
mutex_unlock(&slot_list_lock);
get_device(&pci_bus->dev); get_device(&pci_bus->dev);
...@@ -173,131 +159,24 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) ...@@ -173,131 +159,24 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
return AE_OK; return AE_OK;
} }
/* void acpi_pci_slot_enumerate(struct pci_bus *bus, acpi_handle handle)
* walk_p2p_bridge - discover and walk p2p bridges
* @handle: points to an acpi_pci_root
* @context: p2p_bridge_context pointer
*
* Note that when we call ourselves recursively, we pass a different
* value of pci_bus in the child_context.
*/
static acpi_status
walk_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv)
{
int device, function;
unsigned long long adr;
acpi_status status;
acpi_handle dummy_handle;
acpi_walk_callback user_function;
struct pci_dev *dev;
struct pci_bus *pci_bus;
struct callback_args child_context;
struct callback_args *parent_context = context;
pci_bus = parent_context->pci_bus;
user_function = parent_context->user_function;
status = acpi_get_handle(handle, "_ADR", &dummy_handle);
if (ACPI_FAILURE(status))
return AE_OK;
status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
if (ACPI_FAILURE(status))
return AE_OK;
device = (adr >> 16) & 0xffff;
function = adr & 0xffff;
dev = pci_get_slot(pci_bus, PCI_DEVFN(device, function));
if (!dev || !dev->subordinate)
goto out;
child_context.pci_bus = dev->subordinate;
child_context.user_function = user_function;
child_context.root_handle = parent_context->root_handle;
dbg("p2p bridge walk, pci_bus = %x\n", dev->subordinate->number);
status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
user_function, NULL, &child_context, NULL);
if (ACPI_FAILURE(status))
goto out;
status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
walk_p2p_bridge, NULL, &child_context, NULL);
out:
pci_dev_put(dev);
return AE_OK;
}
/*
* walk_root_bridge - generic root bridge walker
* @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(struct acpi_pci_root *root, acpi_walk_callback user_function)
{
acpi_status status;
acpi_handle handle = root->device->handle;
struct pci_bus *pci_bus = root->bus;
struct callback_args context;
context.pci_bus = pci_bus;
context.user_function = user_function;
context.root_handle = handle;
dbg("root bridge walk, pci_bus = %x\n", pci_bus->number);
status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
user_function, NULL, &context, NULL);
if (ACPI_FAILURE(status))
return status;
status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
walk_p2p_bridge, NULL, &context, NULL);
if (ACPI_FAILURE(status))
err("%s: walk_p2p_bridge failure - %d\n", __func__, status);
return status;
}
/*
* acpi_pci_slot_add
* @handle: points to an acpi_pci_root
*/
static int
acpi_pci_slot_add(struct acpi_pci_root *root)
{ {
acpi_status status; mutex_lock(&slot_list_lock);
acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
status = walk_root_bridge(root, register_slot); register_slot, NULL, bus, NULL);
if (ACPI_FAILURE(status)) mutex_unlock(&slot_list_lock);
err("%s: register_slot failure - %d\n", __func__, status);
return status;
} }
/* void acpi_pci_slot_remove(struct pci_bus *bus)
* acpi_pci_slot_remove
* @handle: points to an acpi_pci_root
*/
static void
acpi_pci_slot_remove(struct acpi_pci_root *root)
{ {
struct acpi_pci_slot *slot, *tmp; struct acpi_pci_slot *slot, *tmp;
struct pci_bus *pbus;
acpi_handle handle = root->device->handle;
mutex_lock(&slot_list_lock); mutex_lock(&slot_list_lock);
list_for_each_entry_safe(slot, tmp, &slot_list, list) { list_for_each_entry_safe(slot, tmp, &slot_list, list) {
if (slot->root_handle == handle) { if (slot->pci_slot->bus == bus) {
list_del(&slot->list); list_del(&slot->list);
pbus = slot->pci_slot->bus;
pci_destroy_slot(slot->pci_slot); pci_destroy_slot(slot->pci_slot);
put_device(&pbus->dev); put_device(&bus->dev);
kfree(slot); kfree(slot);
} }
} }
...@@ -332,5 +211,4 @@ static struct dmi_system_id acpi_pci_slot_dmi_table[] __initdata = { ...@@ -332,5 +211,4 @@ static struct dmi_system_id acpi_pci_slot_dmi_table[] __initdata = {
void __init acpi_pci_slot_init(void) void __init acpi_pci_slot_init(void)
{ {
dmi_check_system(acpi_pci_slot_dmi_table); dmi_check_system(acpi_pci_slot_dmi_table);
acpi_pci_register_driver(&acpi_pci_slot_driver);
} }
...@@ -1790,7 +1790,6 @@ int __init acpi_scan_init(void) ...@@ -1790,7 +1790,6 @@ int __init acpi_scan_init(void)
acpi_platform_init(); acpi_platform_init();
acpi_csrt_init(); acpi_csrt_init();
acpi_container_init(); acpi_container_init();
acpi_pci_slot_init();
mutex_lock(&acpi_scan_lock); mutex_lock(&acpi_scan_lock);
/* /*
......
...@@ -206,16 +206,9 @@ void pci_bus_add_devices(const struct pci_bus *bus) ...@@ -206,16 +206,9 @@ void pci_bus_add_devices(const struct pci_bus *bus)
list_for_each_entry(dev, &bus->devices, bus_list) { list_for_each_entry(dev, &bus->devices, bus_list) {
BUG_ON(!dev->is_added); BUG_ON(!dev->is_added);
child = dev->subordinate; child = dev->subordinate;
if (child)
if (!child) pci_bus_add_devices(child);
continue;
pci_bus_add_devices(child);
if (child->is_added)
continue;
child->is_added = 1;
} }
} }
......
...@@ -52,15 +52,12 @@ config HOTPLUG_PCI_IBM ...@@ -52,15 +52,12 @@ config HOTPLUG_PCI_IBM
When in doubt, say N. When in doubt, say N.
config HOTPLUG_PCI_ACPI config HOTPLUG_PCI_ACPI
tristate "ACPI PCI Hotplug driver" bool "ACPI PCI Hotplug driver"
depends on (!ACPI_DOCK && ACPI) || (ACPI_DOCK) depends on HOTPLUG_PCI=y && ((!ACPI_DOCK && ACPI) || (ACPI_DOCK))
help help
Say Y here if you have a system that supports PCI Hotplug using Say Y here if you have a system that supports PCI Hotplug using
ACPI. ACPI.
To compile this driver as a module, choose M here: the
module will be called acpiphp.
When in doubt, say N. When in doubt, say N.
config HOTPLUG_PCI_ACPI_IBM config HOTPLUG_PCI_ACPI_IBM
......
...@@ -73,8 +73,9 @@ static inline const char *slot_name(struct slot *slot) ...@@ -73,8 +73,9 @@ static inline const char *slot_name(struct slot *slot)
*/ */
struct acpiphp_bridge { struct acpiphp_bridge {
struct list_head list; struct list_head list;
struct list_head slots;
struct kref ref;
acpi_handle handle; acpi_handle handle;
struct acpiphp_slot *slots;
/* Ejectable PCI-to-PCI bridge (PCI bridge and PCI function) */ /* Ejectable PCI-to-PCI bridge (PCI bridge and PCI function) */
struct acpiphp_func *func; struct acpiphp_func *func;
...@@ -97,7 +98,7 @@ struct acpiphp_bridge { ...@@ -97,7 +98,7 @@ struct acpiphp_bridge {
* PCI slot information for each *physical* PCI slot * PCI slot information for each *physical* PCI slot
*/ */
struct acpiphp_slot { struct acpiphp_slot {
struct acpiphp_slot *next; struct list_head node;
struct acpiphp_bridge *bridge; /* parent */ struct acpiphp_bridge *bridge; /* parent */
struct list_head funcs; /* one slot may have different struct list_head funcs; /* one slot may have different
objects (i.e. for each function) */ objects (i.e. for each function) */
...@@ -119,7 +120,6 @@ struct acpiphp_slot { ...@@ -119,7 +120,6 @@ struct acpiphp_slot {
*/ */
struct acpiphp_func { struct acpiphp_func {
struct acpiphp_slot *slot; /* parent */ struct acpiphp_slot *slot; /* parent */
struct acpiphp_bridge *bridge; /* Ejectable PCI-to-PCI bridge */
struct list_head sibling; struct list_head sibling;
struct notifier_block nb; struct notifier_block nb;
...@@ -146,10 +146,6 @@ struct acpiphp_attention_info ...@@ -146,10 +146,6 @@ struct acpiphp_attention_info
#define ACPI_PCI_HOST_HID "PNP0A03" #define ACPI_PCI_HOST_HID "PNP0A03"
/* ACPI _STA method value (ignore bit 4; battery present) */ /* ACPI _STA method value (ignore bit 4; battery present) */
#define ACPI_STA_PRESENT (0x00000001)
#define ACPI_STA_ENABLED (0x00000002)
#define ACPI_STA_SHOW_IN_UI (0x00000004)
#define ACPI_STA_FUNCTIONING (0x00000008)
#define ACPI_STA_ALL (0x0000000f) #define ACPI_STA_ALL (0x0000000f)
/* bridge flags */ /* bridge flags */
...@@ -180,8 +176,6 @@ extern int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot); ...@@ -180,8 +176,6 @@ extern int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot);
extern void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot); extern void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot);
/* acpiphp_glue.c */ /* acpiphp_glue.c */
extern int acpiphp_glue_init (void);
extern void acpiphp_glue_exit (void);
typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data); typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
extern int acpiphp_enable_slot (struct acpiphp_slot *slot); extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
...@@ -194,5 +188,6 @@ extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot); ...@@ -194,5 +188,6 @@ extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot);
/* variables */ /* variables */
extern bool acpiphp_debug; extern bool acpiphp_debug;
extern bool acpiphp_disabled;
#endif /* _ACPIPHP_H */ #endif /* _ACPIPHP_H */
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/pci-acpi.h>
#include <linux/pci_hotplug.h> #include <linux/pci_hotplug.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/smp.h> #include <linux/smp.h>
...@@ -48,6 +49,7 @@ ...@@ -48,6 +49,7 @@
#define SLOT_NAME_SIZE 21 /* {_SUN} */ #define SLOT_NAME_SIZE 21 /* {_SUN} */
bool acpiphp_debug; bool acpiphp_debug;
bool acpiphp_disabled;
/* local variables */ /* local variables */
static struct acpiphp_attention_info *attention_info; static struct acpiphp_attention_info *attention_info;
...@@ -60,7 +62,9 @@ MODULE_AUTHOR(DRIVER_AUTHOR); ...@@ -60,7 +62,9 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC); MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_PARM_DESC(debug, "Debugging mode enabled or not"); MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
MODULE_PARM_DESC(disable, "disable acpiphp driver");
module_param_named(debug, acpiphp_debug, bool, 0644); module_param_named(debug, acpiphp_debug, bool, 0644);
module_param_named(disable, acpiphp_disabled, bool, 0444);
/* export the attention callback registration methods */ /* export the attention callback registration methods */
EXPORT_SYMBOL_GPL(acpiphp_register_attention); EXPORT_SYMBOL_GPL(acpiphp_register_attention);
...@@ -351,27 +355,9 @@ void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot) ...@@ -351,27 +355,9 @@ void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
} }
static int __init acpiphp_init(void) void __init acpiphp_init(void)
{ {
info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); info(DRIVER_DESC " version: " DRIVER_VERSION "%s\n",
acpiphp_disabled ? ", disabled by user; please report a bug"
if (acpi_pci_disabled) : "");
return 0;
/* read all the ACPI info from the system */
/* initialize internal data structure etc. */
return acpiphp_glue_init();
}
static void __exit acpiphp_exit(void)
{
if (acpi_pci_disabled)
return;
/* deallocate internal data structures etc. */
acpiphp_glue_exit();
} }
module_init(acpiphp_init);
module_exit(acpiphp_exit);
This diff is collapsed.
...@@ -287,6 +287,32 @@ static struct pci_platform_pm_ops acpi_pci_platform_pm = { ...@@ -287,6 +287,32 @@ static struct pci_platform_pm_ops acpi_pci_platform_pm = {
.run_wake = acpi_pci_run_wake, .run_wake = acpi_pci_run_wake,
}; };
void acpi_pci_add_bus(struct pci_bus *bus)
{
acpi_handle handle = NULL;
if (bus->bridge)
handle = ACPI_HANDLE(bus->bridge);
if (acpi_pci_disabled || handle == NULL)
return;
acpi_pci_slot_enumerate(bus, handle);
acpiphp_enumerate_slots(bus, handle);
}
void acpi_pci_remove_bus(struct pci_bus *bus)
{
/*
* bus->bridge->acpi_node.handle has already been reset to NULL
* when acpi_pci_remove_bus() is called, so don't check ACPI handle.
*/
if (acpi_pci_disabled)
return;
acpiphp_remove_slots(bus);
acpi_pci_slot_remove(bus);
}
/* ACPI bus type */ /* ACPI bus type */
static int acpi_pci_find_device(struct device *dev, acpi_handle *handle) static int acpi_pci_find_device(struct device *dev, acpi_handle *handle)
{ {
...@@ -361,7 +387,11 @@ static int __init acpi_pci_init(void) ...@@ -361,7 +387,11 @@ static int __init acpi_pci_init(void)
ret = register_acpi_bus_type(&acpi_pci_bus); ret = register_acpi_bus_type(&acpi_pci_bus);
if (ret) if (ret)
return 0; return 0;
pci_set_platform_pm(&acpi_pci_platform_pm); pci_set_platform_pm(&acpi_pci_platform_pm);
acpi_pci_slot_init();
acpiphp_init();
return 0; return 0;
} }
arch_initcall(acpi_pci_init); arch_initcall(acpi_pci_init);
...@@ -673,6 +673,8 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, ...@@ -673,6 +673,8 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
ret = device_register(&child->dev); ret = device_register(&child->dev);
WARN_ON(ret < 0); WARN_ON(ret < 0);
pcibios_add_bus(child);
/* Create legacy_io and legacy_mem files for this bus */ /* Create legacy_io and legacy_mem files for this bus */
pci_create_legacy_files(child); pci_create_legacy_files(child);
...@@ -1627,8 +1629,7 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus) ...@@ -1627,8 +1629,7 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus)
if (!bus->is_added) { if (!bus->is_added) {
dev_dbg(&bus->dev, "fixups for bus\n"); dev_dbg(&bus->dev, "fixups for bus\n");
pcibios_fixup_bus(bus); pcibios_fixup_bus(bus);
if (pci_is_root_bus(bus)) bus->is_added = 1;
bus->is_added = 1;
} }
for (pass=0; pass < 2; pass++) for (pass=0; pass < 2; pass++)
...@@ -1661,6 +1662,14 @@ int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) ...@@ -1661,6 +1662,14 @@ int __weak pcibios_root_bridge_prepare(struct pci_host_bridge *bridge)
return 0; return 0;
} }
void __weak pcibios_add_bus(struct pci_bus *bus)
{
}
void __weak pcibios_remove_bus(struct pci_bus *bus)
{
}
struct pci_bus *pci_create_root_bus(struct device *parent, int bus, struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
struct pci_ops *ops, void *sysdata, struct list_head *resources) struct pci_ops *ops, void *sysdata, struct list_head *resources)
{ {
...@@ -1715,6 +1724,8 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, ...@@ -1715,6 +1724,8 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus,
if (error) if (error)
goto class_dev_reg_err; goto class_dev_reg_err;
pcibios_add_bus(b);
/* Create legacy_io and legacy_mem files for this bus */ /* Create legacy_io and legacy_mem files for this bus */
pci_create_legacy_files(b); pci_create_legacy_files(b);
......
...@@ -50,10 +50,8 @@ void pci_remove_bus(struct pci_bus *bus) ...@@ -50,10 +50,8 @@ void pci_remove_bus(struct pci_bus *bus)
list_del(&bus->node); list_del(&bus->node);
pci_bus_release_busn_res(bus); pci_bus_release_busn_res(bus);
up_write(&pci_bus_sem); up_write(&pci_bus_sem);
if (!bus->is_added)
return;
pci_remove_legacy_files(bus); pci_remove_legacy_files(bus);
pcibios_remove_bus(bus);
device_unregister(&bus->dev); device_unregister(&bus->dev);
} }
EXPORT_SYMBOL(pci_remove_bus); EXPORT_SYMBOL(pci_remove_bus);
......
...@@ -152,15 +152,6 @@ void acpi_penalize_isa_irq(int irq, int active); ...@@ -152,15 +152,6 @@ void acpi_penalize_isa_irq(int irq, int active);
void acpi_pci_irq_disable (struct pci_dev *dev); void acpi_pci_irq_disable (struct pci_dev *dev);
struct acpi_pci_driver {
struct list_head node;
int (*add)(struct acpi_pci_root *root);
void (*remove)(struct acpi_pci_root *root);
};
int acpi_pci_register_driver(struct acpi_pci_driver *driver);
void acpi_pci_unregister_driver(struct acpi_pci_driver *driver);
extern int ec_read(u8 addr, u8 *val); extern int ec_read(u8 addr, u8 *val);
extern int ec_write(u8 addr, u8 val); extern int ec_write(u8 addr, u8 val);
extern int ec_transaction(u8 command, extern int ec_transaction(u8 command,
......
...@@ -41,8 +41,37 @@ static inline acpi_handle acpi_pci_get_bridge_handle(struct pci_bus *pbus) ...@@ -41,8 +41,37 @@ static inline acpi_handle acpi_pci_get_bridge_handle(struct pci_bus *pbus)
return DEVICE_ACPI_HANDLE(dev); return DEVICE_ACPI_HANDLE(dev);
} }
void acpi_pci_add_bus(struct pci_bus *bus);
void acpi_pci_remove_bus(struct pci_bus *bus);
#ifdef CONFIG_ACPI_PCI_SLOT
void acpi_pci_slot_init(void);
void acpi_pci_slot_enumerate(struct pci_bus *bus, acpi_handle handle);
void acpi_pci_slot_remove(struct pci_bus *bus);
#else
static inline void acpi_pci_slot_init(void) { }
static inline void acpi_pci_slot_enumerate(struct pci_bus *bus,
acpi_handle handle) { }
static inline void acpi_pci_slot_remove(struct pci_bus *bus) { }
#endif #endif
#ifdef CONFIG_HOTPLUG_PCI_ACPI
void acpiphp_init(void);
void acpiphp_enumerate_slots(struct pci_bus *bus, acpi_handle handle);
void acpiphp_remove_slots(struct pci_bus *bus);
#else
static inline void acpiphp_init(void) { }
static inline void acpiphp_enumerate_slots(struct pci_bus *bus,
acpi_handle handle) { }
static inline void acpiphp_remove_slots(struct pci_bus *bus) { }
#endif
#else /* CONFIG_ACPI */
static inline void acpi_pci_add_bus(struct pci_bus *bus) { }
static inline void acpi_pci_remove_bus(struct pci_bus *bus) { }
#endif /* CONFIG_ACPI */
#ifdef CONFIG_ACPI_APEI #ifdef CONFIG_ACPI_APEI
extern bool aer_acpi_firmware_first(void); extern bool aer_acpi_firmware_first(void);
#else #else
......
...@@ -693,6 +693,8 @@ extern struct list_head pci_root_buses; /* list of all known PCI buses */ ...@@ -693,6 +693,8 @@ extern struct list_head pci_root_buses; /* list of all known PCI buses */
extern int no_pci_devices(void); extern int no_pci_devices(void);
void pcibios_resource_survey_bus(struct pci_bus *bus); void pcibios_resource_survey_bus(struct pci_bus *bus);
void pcibios_add_bus(struct pci_bus *bus);
void pcibios_remove_bus(struct pci_bus *bus);
void pcibios_fixup_bus(struct pci_bus *); void pcibios_fixup_bus(struct pci_bus *);
int __must_check pcibios_enable_device(struct pci_dev *, int mask); int __must_check pcibios_enable_device(struct pci_dev *, int mask);
/* Architecture specific versions may override this (weak) */ /* Architecture specific versions may override this (weak) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment