2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* ACPI PCI HotPlug glue functions to ACPI CA subsystem
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002,2003 Takayoshi Kochi (t-kochi@bq.jp.nec.com)
|
|
|
|
* Copyright (C) 2002 Hiroshi Aono (h-aono@ap.jp.nec.com)
|
|
|
|
* Copyright (C) 2002,2003 NEC Corporation
|
2005-04-28 07:25:53 +00:00
|
|
|
* Copyright (C) 2003-2005 Matthew Wilcox (matthew.wilcox@hp.com)
|
|
|
|
* Copyright (C) 2003-2005 Hewlett Packard
|
2005-04-28 07:25:56 +00:00
|
|
|
* Copyright (C) 2005 Rajesh Shah (rajesh.shah@intel.com)
|
|
|
|
* Copyright (C) 2005 Intel Corporation
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
|
|
|
|
* NON INFRINGEMENT. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
2006-07-26 17:52:33 +00:00
|
|
|
* Send feedback to <kristen.c.accardi@intel.com>
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-04-28 07:25:53 +00:00
|
|
|
/*
|
|
|
|
* Lifetime rules for pci_dev:
|
|
|
|
* - The one in acpiphp_bridge has its refcount elevated by pci_get_slot()
|
|
|
|
* when the bridge is scanned and it loses a refcount when the bridge
|
|
|
|
* is removed.
|
2009-03-30 16:50:14 +00:00
|
|
|
* - When a P2P bridge is present, we elevate the refcount on the subordinate
|
|
|
|
* bus. It loses the refcount when the the driver unloads.
|
2005-04-28 07:25:53 +00:00
|
|
|
*/
|
|
|
|
|
2013-09-25 00:11:48 +00:00
|
|
|
#define pr_fmt(fmt) "acpiphp_glue: " fmt
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/pci.h>
|
2006-10-14 03:05:19 +00:00
|
|
|
#include <linux/pci_hotplug.h>
|
2008-12-17 03:09:12 +00:00
|
|
|
#include <linux/pci-acpi.h>
|
ACPI / hotplug / PCI: Check for new devices on enabled slots
The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is
ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not
ACPI_STA_ALL.
This behavior is not sufficient to handle the Thunderbolt daisy
chaining case properly, however, because in that case the bus
behind the already enabled slot needs to be rescanned for new
devices.
For this reason, modify acpiphp_check_bridge() so that slots are
disabled and stopped if they are not in the ACPI_STA_ALL state.
For slots in the ACPI_STA_ALL state, devices behind them that don't
respond are trimmed using a new function, trim_stale_devices(),
introduced specifically for this purpose. That function walks
the given bus and checks each device on it. If the device doesn't
respond, it is assumed to be gone and is removed.
Once all of the stale devices directy behind the slot have been
removed, acpiphp_check_bridge() will start looking for new devices
that might have appeared on the given bus. It will do that even if
the slot is already enabled (SLOT_ENABLED is set for it).
In addition to that, make the bus check notification ignore
SLOT_ENABLED and go for enable_device() directly if bridge is NULL,
so that devices behind the slot are re-enumerated in that case too.
This change is based on earlier patches from Kirill A Shutemov
and Mika Westerberg.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2013-07-16 20:10:35 +00:00
|
|
|
#include <linux/pm_runtime.h>
|
2006-01-13 15:02:15 +00:00
|
|
|
#include <linux/mutex.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2011-09-28 23:40:53 +00:00
|
|
|
#include <linux/acpi.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include "../pci.h"
|
|
|
|
#include "acpiphp.h"
|
|
|
|
|
|
|
|
static LIST_HEAD(bridge_list);
|
2013-04-12 05:44:28 +00:00
|
|
|
static DEFINE_MUTEX(bridge_mutex);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2014-02-21 00:10:27 +00:00
|
|
|
static int acpiphp_hotplug_notify(struct acpi_device *adev, u32 type);
|
2014-02-21 00:10:18 +00:00
|
|
|
static void acpiphp_post_dock_fixup(struct acpi_device *adev);
|
2005-10-19 00:21:40 +00:00
|
|
|
static void acpiphp_sanitize_bus(struct pci_bus *bus);
|
2009-09-14 22:35:10 +00:00
|
|
|
static void acpiphp_set_hpp_values(struct pci_bus *bus);
|
2014-02-03 23:42:20 +00:00
|
|
|
static void hotplug_event(u32 type, struct acpiphp_context *context);
|
2013-04-12 05:44:28 +00:00
|
|
|
static void free_bridge(struct kref *kref);
|
2005-10-19 00:21:40 +00:00
|
|
|
|
2013-07-13 21:27:24 +00:00
|
|
|
/**
|
|
|
|
* acpiphp_init_context - Create hotplug context and grab a reference to it.
|
2014-02-03 23:39:33 +00:00
|
|
|
* @adev: ACPI device object to create the context for.
|
2013-07-13 21:27:24 +00:00
|
|
|
*
|
2014-02-03 23:43:17 +00:00
|
|
|
* Call under acpi_hp_context_lock.
|
2013-07-13 21:27:24 +00:00
|
|
|
*/
|
2014-02-03 23:39:33 +00:00
|
|
|
static struct acpiphp_context *acpiphp_init_context(struct acpi_device *adev)
|
2013-07-13 21:27:24 +00:00
|
|
|
{
|
|
|
|
struct acpiphp_context *context;
|
|
|
|
|
|
|
|
context = kzalloc(sizeof(*context), GFP_KERNEL);
|
|
|
|
if (!context)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
context->refcount = 1;
|
2014-02-21 00:10:27 +00:00
|
|
|
acpi_set_hp_context(adev, &context->hp, acpiphp_hotplug_notify, NULL,
|
2014-02-21 00:10:18 +00:00
|
|
|
acpiphp_post_dock_fixup);
|
2013-07-13 21:27:24 +00:00
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* acpiphp_get_context - Get hotplug context and grab a reference to it.
|
2014-02-06 16:31:37 +00:00
|
|
|
* @adev: ACPI device object to get the context for.
|
2013-07-13 21:27:24 +00:00
|
|
|
*
|
2014-02-03 23:43:17 +00:00
|
|
|
* Call under acpi_hp_context_lock.
|
2013-07-13 21:27:24 +00:00
|
|
|
*/
|
2014-02-06 16:31:37 +00:00
|
|
|
static struct acpiphp_context *acpiphp_get_context(struct acpi_device *adev)
|
2013-07-13 21:27:24 +00:00
|
|
|
{
|
2014-02-06 16:31:37 +00:00
|
|
|
struct acpiphp_context *context;
|
2013-07-13 21:27:24 +00:00
|
|
|
|
2014-02-06 16:31:37 +00:00
|
|
|
if (!adev->hp)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
context = to_acpiphp_context(adev->hp);
|
|
|
|
context->refcount++;
|
2013-07-13 21:27:24 +00:00
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* acpiphp_put_context - Drop a reference to ACPI hotplug context.
|
2014-02-03 23:39:33 +00:00
|
|
|
* @context: ACPI hotplug context to drop a reference to.
|
2013-07-13 21:27:24 +00:00
|
|
|
*
|
|
|
|
* The context object is removed if there are no more references to it.
|
|
|
|
*
|
2014-02-03 23:43:17 +00:00
|
|
|
* Call under acpi_hp_context_lock.
|
2013-07-13 21:27:24 +00:00
|
|
|
*/
|
|
|
|
static void acpiphp_put_context(struct acpiphp_context *context)
|
|
|
|
{
|
|
|
|
if (--context->refcount)
|
|
|
|
return;
|
|
|
|
|
2013-07-13 21:27:25 +00:00
|
|
|
WARN_ON(context->bridge);
|
2014-02-06 16:31:37 +00:00
|
|
|
context->hp.self->hp = NULL;
|
2013-07-13 21:27:24 +00:00
|
|
|
kfree(context);
|
|
|
|
}
|
|
|
|
|
2013-04-12 05:44:28 +00:00
|
|
|
static inline void get_bridge(struct acpiphp_bridge *bridge)
|
|
|
|
{
|
|
|
|
kref_get(&bridge->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void put_bridge(struct acpiphp_bridge *bridge)
|
|
|
|
{
|
|
|
|
kref_put(&bridge->ref, free_bridge);
|
|
|
|
}
|
|
|
|
|
2014-02-21 00:10:18 +00:00
|
|
|
static struct acpiphp_context *acpiphp_grab_context(struct acpi_device *adev)
|
|
|
|
{
|
|
|
|
struct acpiphp_context *context;
|
|
|
|
|
|
|
|
acpi_lock_hp_context();
|
|
|
|
context = acpiphp_get_context(adev);
|
|
|
|
if (!context || context->func.parent->is_going_away) {
|
|
|
|
acpi_unlock_hp_context();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
get_bridge(context->func.parent);
|
|
|
|
acpiphp_put_context(context);
|
|
|
|
acpi_unlock_hp_context();
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void acpiphp_let_context_go(struct acpiphp_context *context)
|
|
|
|
{
|
|
|
|
put_bridge(context->func.parent);
|
|
|
|
}
|
|
|
|
|
2013-04-12 05:44:28 +00:00
|
|
|
static void free_bridge(struct kref *kref)
|
|
|
|
{
|
2013-07-13 21:27:24 +00:00
|
|
|
struct acpiphp_context *context;
|
2013-04-12 05:44:28 +00:00
|
|
|
struct acpiphp_bridge *bridge;
|
|
|
|
struct acpiphp_slot *slot, *next;
|
|
|
|
struct acpiphp_func *func, *tmp;
|
|
|
|
|
2014-02-03 23:43:17 +00:00
|
|
|
acpi_lock_hp_context();
|
2013-07-13 21:27:24 +00:00
|
|
|
|
2013-04-12 05:44:28 +00:00
|
|
|
bridge = container_of(kref, struct acpiphp_bridge, ref);
|
|
|
|
|
|
|
|
list_for_each_entry_safe(slot, next, &bridge->slots, node) {
|
2013-07-13 21:27:25 +00:00
|
|
|
list_for_each_entry_safe(func, tmp, &slot->funcs, sibling)
|
|
|
|
acpiphp_put_context(func_to_context(func));
|
|
|
|
|
2013-04-12 05:44:28 +00:00
|
|
|
kfree(slot);
|
|
|
|
}
|
|
|
|
|
2013-07-13 21:27:24 +00:00
|
|
|
context = bridge->context;
|
2013-07-13 21:27:24 +00:00
|
|
|
/* Root bridges will not have hotplug context. */
|
|
|
|
if (context) {
|
|
|
|
/* Release the reference taken by acpiphp_enumerate_slots(). */
|
2013-07-13 21:27:25 +00:00
|
|
|
put_bridge(context->func.parent);
|
2013-07-13 21:27:24 +00:00
|
|
|
context->bridge = NULL;
|
|
|
|
acpiphp_put_context(context);
|
|
|
|
}
|
2013-07-13 21:27:24 +00:00
|
|
|
|
2013-04-12 05:44:28 +00:00
|
|
|
put_device(&bridge->pci_bus->dev);
|
|
|
|
pci_dev_put(bridge->pci_dev);
|
|
|
|
kfree(bridge);
|
2013-07-13 21:27:24 +00:00
|
|
|
|
2014-02-03 23:43:17 +00:00
|
|
|
acpi_unlock_hp_context();
|
2013-04-12 05:44:28 +00:00
|
|
|
}
|
|
|
|
|
2014-02-21 00:10:18 +00:00
|
|
|
/**
|
|
|
|
* acpiphp_post_dock_fixup - Post-dock fixups for PCI devices.
|
|
|
|
* @adev: ACPI device object corresponding to a PCI device.
|
2006-06-28 07:08:06 +00:00
|
|
|
*
|
2014-02-21 00:10:18 +00:00
|
|
|
* TBD - figure out a way to only call fixups for systems that require them.
|
2006-06-28 07:08:06 +00:00
|
|
|
*/
|
2014-02-21 00:10:18 +00:00
|
|
|
static void acpiphp_post_dock_fixup(struct acpi_device *adev)
|
2006-06-28 07:08:06 +00:00
|
|
|
{
|
2014-02-21 00:10:18 +00:00
|
|
|
struct acpiphp_context *context = acpiphp_grab_context(adev);
|
|
|
|
struct pci_bus *bus;
|
2006-06-28 07:08:06 +00:00
|
|
|
u32 buses;
|
|
|
|
|
2014-02-21 00:10:18 +00:00
|
|
|
if (!context)
|
2013-07-05 01:03:25 +00:00
|
|
|
return;
|
2006-06-28 07:08:06 +00:00
|
|
|
|
2014-02-21 00:10:18 +00:00
|
|
|
bus = context->func.slot->bus;
|
|
|
|
if (!bus->self)
|
|
|
|
goto out;
|
|
|
|
|
2006-06-28 07:08:06 +00:00
|
|
|
/* fixup bad _DCK function that rewrites
|
|
|
|
* secondary bridge on slot
|
|
|
|
*/
|
2014-02-21 00:10:18 +00:00
|
|
|
pci_read_config_dword(bus->self, PCI_PRIMARY_BUS, &buses);
|
2006-06-28 07:08:06 +00:00
|
|
|
|
2012-05-18 01:51:11 +00:00
|
|
|
if (((buses >> 8) & 0xff) != bus->busn_res.start) {
|
2006-06-28 07:08:06 +00:00
|
|
|
buses = (buses & 0xff000000)
|
2008-12-11 18:17:55 +00:00
|
|
|
| ((unsigned int)(bus->primary) << 0)
|
2012-05-18 01:51:11 +00:00
|
|
|
| ((unsigned int)(bus->busn_res.start) << 8)
|
|
|
|
| ((unsigned int)(bus->busn_res.end) << 16);
|
2006-06-28 07:08:06 +00:00
|
|
|
pci_write_config_dword(bus->self, PCI_PRIMARY_BUS, buses);
|
|
|
|
}
|
|
|
|
|
2014-02-21 00:10:18 +00:00
|
|
|
out:
|
|
|
|
acpiphp_let_context_go(context);
|
2014-02-03 21:30:15 +00:00
|
|
|
}
|
2006-06-28 07:08:06 +00:00
|
|
|
|
2012-08-22 15:16:45 +00:00
|
|
|
/* Check whether the PCI device is managed by native PCIe hotplug driver */
|
|
|
|
static bool device_is_managed_by_native_pciehp(struct pci_dev *pdev)
|
|
|
|
{
|
|
|
|
u32 reg32;
|
|
|
|
acpi_handle tmp;
|
|
|
|
struct acpi_pci_root *root;
|
|
|
|
|
|
|
|
/* Check whether the PCIe port supports native PCIe hotplug */
|
|
|
|
if (pcie_capability_read_dword(pdev, PCI_EXP_SLTCAP, ®32))
|
|
|
|
return false;
|
|
|
|
if (!(reg32 & PCI_EXP_SLTCAP_HPC))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check whether native PCIe hotplug has been enabled for
|
|
|
|
* this PCIe hierarchy.
|
|
|
|
*/
|
|
|
|
tmp = acpi_find_root_bridge_handle(pdev);
|
|
|
|
if (!tmp)
|
|
|
|
return false;
|
|
|
|
root = acpi_pci_find_root(tmp);
|
|
|
|
if (!root)
|
|
|
|
return false;
|
|
|
|
if (!(root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-15 23:12:00 +00:00
|
|
|
/**
|
|
|
|
* acpiphp_add_context - Add ACPIPHP context to an ACPI device object.
|
|
|
|
* @handle: ACPI handle of the object to add a context to.
|
|
|
|
* @lvl: Not used.
|
|
|
|
* @data: The object's parent ACPIPHP bridge.
|
|
|
|
* @rv: Not used.
|
|
|
|
*/
|
|
|
|
static acpi_status acpiphp_add_context(acpi_handle handle, u32 lvl, void *data,
|
|
|
|
void **rv)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2013-07-13 21:27:24 +00:00
|
|
|
struct acpiphp_bridge *bridge = data;
|
|
|
|
struct acpiphp_context *context;
|
2014-02-03 23:39:33 +00:00
|
|
|
struct acpi_device *adev;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct acpiphp_slot *slot;
|
|
|
|
struct acpiphp_func *newfunc;
|
|
|
|
acpi_status status = AE_OK;
|
2013-07-13 21:27:24 +00:00
|
|
|
unsigned long long adr;
|
|
|
|
int device, function;
|
2008-12-17 03:09:12 +00:00
|
|
|
struct pci_bus *pbus = bridge->pci_bus;
|
2013-07-13 21:27:24 +00:00
|
|
|
struct pci_dev *pdev = bridge->pci_dev;
|
2013-04-12 05:44:26 +00:00
|
|
|
u32 val;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-06-20 22:18:29 +00:00
|
|
|
status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2013-11-27 20:33:09 +00:00
|
|
|
if (status != AE_NOT_FOUND)
|
|
|
|
acpi_handle_warn(handle,
|
|
|
|
"can't evaluate _ADR (%#x)\n", status);
|
2012-06-20 22:18:29 +00:00
|
|
|
return AE_OK;
|
|
|
|
}
|
2014-02-03 23:39:33 +00:00
|
|
|
if (acpi_bus_get_device(handle, &adev))
|
|
|
|
return AE_OK;
|
2012-06-20 22:18:29 +00:00
|
|
|
|
|
|
|
device = (adr >> 16) & 0xffff;
|
|
|
|
function = adr & 0xffff;
|
|
|
|
|
2014-02-03 23:43:17 +00:00
|
|
|
acpi_lock_hp_context();
|
2014-02-03 23:39:33 +00:00
|
|
|
context = acpiphp_init_context(adev);
|
2013-07-13 21:27:24 +00:00
|
|
|
if (!context) {
|
2014-02-03 23:43:17 +00:00
|
|
|
acpi_unlock_hp_context();
|
2013-07-13 21:27:24 +00:00
|
|
|
acpi_handle_err(handle, "No hotplug context\n");
|
|
|
|
return AE_NOT_EXIST;
|
|
|
|
}
|
2013-07-13 21:27:25 +00:00
|
|
|
newfunc = &context->func;
|
|
|
|
newfunc->function = function;
|
2013-07-13 21:27:25 +00:00
|
|
|
newfunc->parent = bridge;
|
2014-02-21 00:10:18 +00:00
|
|
|
acpi_unlock_hp_context();
|
2013-07-13 21:27:24 +00:00
|
|
|
|
2014-02-21 00:10:18 +00:00
|
|
|
/*
|
|
|
|
* If this is a dock device, its _EJ0 should be executed by the dock
|
|
|
|
* notify handler after calling _DCK.
|
|
|
|
*/
|
|
|
|
if (!is_dock_device(adev) && acpi_has_method(handle, "_EJ0"))
|
2006-02-24 01:56:03 +00:00
|
|
|
newfunc->flags = FUNC_HAS_EJ0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-06-28 16:24:43 +00:00
|
|
|
if (acpi_has_method(handle, "_STA"))
|
2005-04-16 22:20:36 +00:00
|
|
|
newfunc->flags |= FUNC_HAS_STA;
|
|
|
|
|
|
|
|
/* search for objects that share the same slot */
|
2013-04-12 05:44:27 +00:00
|
|
|
list_for_each_entry(slot, &bridge->slots, node)
|
2013-07-13 21:27:24 +00:00
|
|
|
if (slot->device == device)
|
2013-07-13 21:27:24 +00:00
|
|
|
goto slot_found;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-07-13 21:27:24 +00:00
|
|
|
slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
|
|
|
|
if (!slot) {
|
2014-02-03 23:43:17 +00:00
|
|
|
acpi_lock_hp_context();
|
2014-02-03 23:38:15 +00:00
|
|
|
acpiphp_put_context(context);
|
2014-02-03 23:43:17 +00:00
|
|
|
acpi_unlock_hp_context();
|
2014-02-03 23:38:15 +00:00
|
|
|
return AE_NO_MEMORY;
|
2013-07-13 21:27:24 +00:00
|
|
|
}
|
|
|
|
|
2013-07-13 21:27:25 +00:00
|
|
|
slot->bus = bridge->pci_bus;
|
2013-07-13 21:27:24 +00:00
|
|
|
slot->device = device;
|
|
|
|
INIT_LIST_HEAD(&slot->funcs);
|
|
|
|
|
|
|
|
list_add_tail(&slot->node, &bridge->slots);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2014-02-15 23:12:09 +00:00
|
|
|
/*
|
|
|
|
* Expose slots to user space for functions that have _EJ0 or _RMV or
|
|
|
|
* are located in dock stations. Do not expose them for devices handled
|
|
|
|
* by the native PCIe hotplug (PCIeHP), becuase that code is supposed to
|
|
|
|
* expose slots to user space in those cases.
|
|
|
|
*/
|
2014-02-21 00:10:09 +00:00
|
|
|
if ((acpi_pci_check_ejectable(pbus, handle) || is_dock_device(adev))
|
2014-02-15 23:12:09 +00:00
|
|
|
&& !(pdev && device_is_managed_by_native_pciehp(pdev))) {
|
2013-07-13 21:27:24 +00:00
|
|
|
unsigned long long sun;
|
|
|
|
int retval;
|
2013-07-13 21:27:24 +00:00
|
|
|
|
2013-07-13 21:27:24 +00:00
|
|
|
bridge->nr_slots++;
|
|
|
|
status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun);
|
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
sun = bridge->nr_slots;
|
|
|
|
|
2013-09-25 00:11:48 +00:00
|
|
|
pr_debug("found ACPI PCI Hotplug slot %llu at PCI %04x:%02x:%02x\n",
|
2013-07-13 21:27:25 +00:00
|
|
|
sun, pci_domain_nr(pbus), pbus->number, device);
|
2013-07-13 21:27:24 +00:00
|
|
|
|
2013-07-13 21:27:25 +00:00
|
|
|
retval = acpiphp_register_hotplug_slot(slot, sun);
|
2013-07-13 21:27:24 +00:00
|
|
|
if (retval) {
|
2013-08-17 20:16:33 +00:00
|
|
|
slot->slot = NULL;
|
2013-07-13 21:27:24 +00:00
|
|
|
bridge->nr_slots--;
|
|
|
|
if (retval == -EBUSY)
|
2013-09-25 00:11:48 +00:00
|
|
|
pr_warn("Slot %llu already registered by another "
|
2013-07-13 21:27:25 +00:00
|
|
|
"hotplug driver\n", sun);
|
2013-07-13 21:27:24 +00:00
|
|
|
else
|
2013-09-25 00:11:48 +00:00
|
|
|
pr_warn("acpiphp_register_hotplug_slot failed "
|
2013-07-13 21:27:24 +00:00
|
|
|
"(err code = 0x%x)\n", retval);
|
|
|
|
}
|
|
|
|
/* Even if the slot registration fails, we can still use it. */
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2013-07-13 21:27:24 +00:00
|
|
|
slot_found:
|
2005-04-16 22:20:36 +00:00
|
|
|
newfunc->slot = slot;
|
|
|
|
list_add_tail(&newfunc->sibling, &slot->funcs);
|
|
|
|
|
2013-04-12 05:44:26 +00:00
|
|
|
if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function),
|
|
|
|
&val, 60*1000))
|
2013-07-13 21:27:26 +00:00
|
|
|
slot->flags |= SLOT_ENABLED;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-07-13 21:27:23 +00:00
|
|
|
return AE_OK;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2014-02-03 23:45:13 +00:00
|
|
|
static struct acpiphp_bridge *acpiphp_dev_to_bridge(struct acpi_device *adev)
|
2005-04-28 07:25:53 +00:00
|
|
|
{
|
2013-07-13 21:27:24 +00:00
|
|
|
struct acpiphp_context *context;
|
|
|
|
struct acpiphp_bridge *bridge = NULL;
|
2009-10-27 03:25:27 +00:00
|
|
|
|
2014-02-03 23:43:17 +00:00
|
|
|
acpi_lock_hp_context();
|
2014-02-06 16:31:37 +00:00
|
|
|
context = acpiphp_get_context(adev);
|
2013-07-13 21:27:24 +00:00
|
|
|
if (context) {
|
|
|
|
bridge = context->bridge;
|
|
|
|
if (bridge)
|
2013-04-12 05:44:28 +00:00
|
|
|
get_bridge(bridge);
|
2005-04-28 07:25:53 +00:00
|
|
|
|
2013-07-13 21:27:24 +00:00
|
|
|
acpiphp_put_context(context);
|
|
|
|
}
|
2014-02-03 23:43:17 +00:00
|
|
|
acpi_unlock_hp_context();
|
2013-07-13 21:27:24 +00:00
|
|
|
return bridge;
|
2005-04-28 07:25:53 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-04-28 07:25:54 +00:00
|
|
|
static void cleanup_bridge(struct acpiphp_bridge *bridge)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2013-04-12 05:44:28 +00:00
|
|
|
struct acpiphp_slot *slot;
|
|
|
|
struct acpiphp_func *func;
|
2005-04-28 07:25:53 +00:00
|
|
|
|
2013-04-12 05:44:28 +00:00
|
|
|
list_for_each_entry(slot, &bridge->slots, node) {
|
|
|
|
list_for_each_entry(func, &slot->funcs, sibling) {
|
2014-02-06 12:58:13 +00:00
|
|
|
struct acpi_device *adev = func_to_acpi_device(func);
|
2013-07-13 21:27:25 +00:00
|
|
|
|
2014-02-06 12:58:13 +00:00
|
|
|
acpi_lock_hp_context();
|
2014-02-21 00:10:27 +00:00
|
|
|
adev->hp->notify = NULL;
|
2014-02-21 00:10:18 +00:00
|
|
|
adev->hp->fixup = NULL;
|
2014-02-06 12:58:13 +00:00
|
|
|
acpi_unlock_hp_context();
|
2005-04-28 07:25:53 +00:00
|
|
|
}
|
2014-01-10 14:24:41 +00:00
|
|
|
slot->flags |= SLOT_IS_GOING_AWAY;
|
2013-08-17 20:16:33 +00:00
|
|
|
if (slot->slot)
|
|
|
|
acpiphp_unregister_hotplug_slot(slot);
|
2005-04-28 07:25:53 +00:00
|
|
|
}
|
|
|
|
|
2013-04-12 05:44:28 +00:00
|
|
|
mutex_lock(&bridge_mutex);
|
2005-04-28 07:25:53 +00:00
|
|
|
list_del(&bridge->list);
|
2013-04-12 05:44:28 +00:00
|
|
|
mutex_unlock(&bridge_mutex);
|
2014-01-10 14:24:41 +00:00
|
|
|
|
2014-02-03 23:43:17 +00:00
|
|
|
acpi_lock_hp_context();
|
2014-01-10 14:24:41 +00:00
|
|
|
bridge->is_going_away = true;
|
2014-02-03 23:43:17 +00:00
|
|
|
acpi_unlock_hp_context();
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-02-24 01:55:58 +00:00
|
|
|
/**
|
2007-11-28 17:04:30 +00:00
|
|
|
* acpiphp_max_busnr - return the highest reserved bus number under the given bus.
|
2006-02-24 01:55:58 +00:00
|
|
|
* @bus: bus to start search with
|
|
|
|
*/
|
|
|
|
static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
|
|
|
|
{
|
2014-02-13 13:13:58 +00:00
|
|
|
struct pci_bus *tmp;
|
2006-02-24 01:55:58 +00:00
|
|
|
unsigned char max, n;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* pci_bus_max_busnr will return the highest
|
|
|
|
* reserved busnr for all these children.
|
|
|
|
* that is equivalent to the bus->subordinate
|
|
|
|
* value. We don't want to use the parent's
|
|
|
|
* bus->subordinate value because it could have
|
|
|
|
* padding in it.
|
|
|
|
*/
|
2012-05-18 01:51:11 +00:00
|
|
|
max = bus->busn_res.start;
|
2006-02-24 01:55:58 +00:00
|
|
|
|
2014-02-13 13:13:58 +00:00
|
|
|
list_for_each_entry(tmp, &bus->children, node) {
|
|
|
|
n = pci_bus_max_busnr(tmp);
|
2006-02-24 01:55:58 +00:00
|
|
|
if (n > max)
|
|
|
|
max = n;
|
|
|
|
}
|
|
|
|
return max;
|
|
|
|
}
|
|
|
|
|
2010-02-25 02:59:34 +00:00
|
|
|
static void acpiphp_set_acpi_region(struct acpiphp_slot *slot)
|
|
|
|
{
|
|
|
|
struct acpiphp_func *func;
|
|
|
|
union acpi_object params[2];
|
|
|
|
struct acpi_object_list arg_list;
|
|
|
|
|
|
|
|
list_for_each_entry(func, &slot->funcs, sibling) {
|
|
|
|
arg_list.count = 2;
|
|
|
|
arg_list.pointer = params;
|
|
|
|
params[0].type = ACPI_TYPE_INTEGER;
|
|
|
|
params[0].integer.value = ACPI_ADR_SPACE_PCI_CONFIG;
|
|
|
|
params[1].type = ACPI_TYPE_INTEGER;
|
|
|
|
params[1].integer.value = 1;
|
|
|
|
/* _REG is optional, we don't care about if there is failure */
|
2013-07-13 21:27:25 +00:00
|
|
|
acpi_evaluate_object(func_to_handle(func), "_REG", &arg_list,
|
|
|
|
NULL);
|
2010-02-25 02:59:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-21 21:20:42 +00:00
|
|
|
static void check_hotplug_bridge(struct acpiphp_slot *slot, struct pci_dev *dev)
|
|
|
|
{
|
|
|
|
struct acpiphp_func *func;
|
|
|
|
|
|
|
|
/* quirk, or pcie could set it already */
|
|
|
|
if (dev->is_hotplug_bridge)
|
|
|
|
return;
|
|
|
|
|
|
|
|
list_for_each_entry(func, &slot->funcs, sibling) {
|
|
|
|
if (PCI_FUNC(dev->devfn) == func->function) {
|
2013-07-13 21:27:24 +00:00
|
|
|
dev->is_hotplug_bridge = 1;
|
2013-01-21 21:20:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-04-12 05:44:26 +00:00
|
|
|
|
ACPI / hotplug / PCI: Avoid parent bus rescans on spurious device checks
In the current ACPIPHP notify handler we always go directly for a
rescan of the parent bus if we get a device check notification for
a device that is not a bridge. However, this obviously is
overzealous if nothing really changes, because this way we may rescan
the whole PCI hierarchy pretty much in vain.
That happens on Alex Williamson's machine whose ACPI tables contain
device objects that are supposed to coresspond to PCIe root ports,
but those ports aren't physically present (or at least they aren't
visible in the PCI config space to us). The BIOS generates multiple
device check notifies for those objects during boot and for each of
them we go straight for the parent bus rescan, but the parent bus is
the root bus in this particular case. In consequence, we rescan the
whole PCI bus from the top several times in a row, which is
completely unnecessary, increases boot time by 50% (after previous
fixes) and generates excess dmesg output from the PCI subsystem.
Fix the problem by checking if we can find anything new in the
slot corresponding to the device we've got a device check notify
for and doing nothig if that's not the case.
The spec (ACPI 5.0, Section 5.6.6) appears to mandate this behavior,
as it says:
Device Check. Used to notify OSPM that the device either appeared
or disappeared. If the device has appeared, OSPM will re-enumerate
from the parent. If the device has disappeared, OSPM will
invalidate the state of the device. OSPM may optimize out
re-enumeration.
Therefore, according to the spec, we are free to do nothing if
nothing changes.
References: https://bugzilla.kernel.org/show_bug.cgi?id=60865
Reported-and-tested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-09-07 22:07:28 +00:00
|
|
|
static int acpiphp_rescan_slot(struct acpiphp_slot *slot)
|
|
|
|
{
|
|
|
|
struct acpiphp_func *func;
|
|
|
|
|
2014-02-03 23:39:58 +00:00
|
|
|
list_for_each_entry(func, &slot->funcs, sibling) {
|
|
|
|
struct acpi_device *adev = func_to_acpi_device(func);
|
ACPI / hotplug / PCI: Avoid parent bus rescans on spurious device checks
In the current ACPIPHP notify handler we always go directly for a
rescan of the parent bus if we get a device check notification for
a device that is not a bridge. However, this obviously is
overzealous if nothing really changes, because this way we may rescan
the whole PCI hierarchy pretty much in vain.
That happens on Alex Williamson's machine whose ACPI tables contain
device objects that are supposed to coresspond to PCIe root ports,
but those ports aren't physically present (or at least they aren't
visible in the PCI config space to us). The BIOS generates multiple
device check notifies for those objects during boot and for each of
them we go straight for the parent bus rescan, but the parent bus is
the root bus in this particular case. In consequence, we rescan the
whole PCI bus from the top several times in a row, which is
completely unnecessary, increases boot time by 50% (after previous
fixes) and generates excess dmesg output from the PCI subsystem.
Fix the problem by checking if we can find anything new in the
slot corresponding to the device we've got a device check notify
for and doing nothig if that's not the case.
The spec (ACPI 5.0, Section 5.6.6) appears to mandate this behavior,
as it says:
Device Check. Used to notify OSPM that the device either appeared
or disappeared. If the device has appeared, OSPM will re-enumerate
from the parent. If the device has disappeared, OSPM will
invalidate the state of the device. OSPM may optimize out
re-enumeration.
Therefore, according to the spec, we are free to do nothing if
nothing changes.
References: https://bugzilla.kernel.org/show_bug.cgi?id=60865
Reported-and-tested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-09-07 22:07:28 +00:00
|
|
|
|
2014-02-03 23:39:58 +00:00
|
|
|
acpi_bus_scan(adev->handle);
|
|
|
|
if (acpi_device_enumerated(adev))
|
|
|
|
acpi_device_set_power(adev, ACPI_STATE_D0);
|
|
|
|
}
|
ACPI / hotplug / PCI: Avoid parent bus rescans on spurious device checks
In the current ACPIPHP notify handler we always go directly for a
rescan of the parent bus if we get a device check notification for
a device that is not a bridge. However, this obviously is
overzealous if nothing really changes, because this way we may rescan
the whole PCI hierarchy pretty much in vain.
That happens on Alex Williamson's machine whose ACPI tables contain
device objects that are supposed to coresspond to PCIe root ports,
but those ports aren't physically present (or at least they aren't
visible in the PCI config space to us). The BIOS generates multiple
device check notifies for those objects during boot and for each of
them we go straight for the parent bus rescan, but the parent bus is
the root bus in this particular case. In consequence, we rescan the
whole PCI bus from the top several times in a row, which is
completely unnecessary, increases boot time by 50% (after previous
fixes) and generates excess dmesg output from the PCI subsystem.
Fix the problem by checking if we can find anything new in the
slot corresponding to the device we've got a device check notify
for and doing nothig if that's not the case.
The spec (ACPI 5.0, Section 5.6.6) appears to mandate this behavior,
as it says:
Device Check. Used to notify OSPM that the device either appeared
or disappeared. If the device has appeared, OSPM will re-enumerate
from the parent. If the device has disappeared, OSPM will
invalidate the state of the device. OSPM may optimize out
re-enumeration.
Therefore, according to the spec, we are free to do nothing if
nothing changes.
References: https://bugzilla.kernel.org/show_bug.cgi?id=60865
Reported-and-tested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-09-07 22:07:28 +00:00
|
|
|
return pci_scan_slot(slot->bus, PCI_DEVFN(slot->device, 0));
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/**
|
2013-07-13 21:27:26 +00:00
|
|
|
* enable_slot - enable, configure a slot
|
2005-04-16 22:20:36 +00:00
|
|
|
* @slot: slot to be enabled
|
|
|
|
*
|
|
|
|
* This function should be called per *physical slot*,
|
|
|
|
* not per each slot object in ACPI namespace.
|
|
|
|
*/
|
2013-07-13 21:27:26 +00:00
|
|
|
static void __ref enable_slot(struct acpiphp_slot *slot)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct pci_dev *dev;
|
2013-07-13 21:27:25 +00:00
|
|
|
struct pci_bus *bus = slot->bus;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct acpiphp_func *func;
|
2013-07-13 21:27:26 +00:00
|
|
|
int max, pass;
|
PCI / ACPI: Use boot-time resource allocation rules during hotplug
On x86 platforms, the kernel respects PCI resource assignments from
the BIOS and only reassigns resources for unassigned BARs at boot
time. However, with the ACPI-based hotplug (acpiphp), it ignores the
BIOS' PCI resource assignments completely and reassigns all resources
by itself. This causes differences in PCI resource allocation
between boot time and runtime hotplug to occur, which is generally
undesirable and sometimes actively breaks things.
Namely, if there are enough resources, reassigning all PCI resources
during runtime hotplug should work, but it may fail if the resources
are constrained. This may happen, for instance, when some PCI
devices with huge MMIO BARs are involved in the runtime hotplug
operations, because the current PCI MMIO alignment algorithm may
waste huge chunks of MMIO address space in those cases.
On the Alexander's Sony VAIO VPCZ23A4R the BIOS allocates limited
MMIO resources for the dock station which contains a device
(graphics adapter) with a 256MB MMIO BAR. An attempt to reassign
that during runtime hotplug causes the dock station MMIO window to be
exhausted and acpiphp fails to allocate resources for the majority
of devices on the dock station as a result.
To prevent that from happening, modify acpiphp to follow the boot
time resources allocation behavior so that the BIOS' resource
assignments are respected during runtime hotplug too.
[rjw: Changelog]
References: https://bugzilla.kernel.org/show_bug.cgi?id=56531
Reported-and-tested-by: Alexander E. Patrakov <patrakov@gmail.com>
Tested-by: Illya Klymov <xanf@xanf.me>
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
Cc: 3.9+ <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-06-22 23:01:35 +00:00
|
|
|
LIST_HEAD(add_list);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-10-30 12:40:36 +00:00
|
|
|
acpiphp_rescan_slot(slot);
|
2006-02-24 01:55:58 +00:00
|
|
|
max = acpiphp_max_busnr(bus);
|
2005-04-28 07:25:53 +00:00
|
|
|
for (pass = 0; pass < 2; pass++) {
|
|
|
|
list_for_each_entry(dev, &bus->devices, bus_list) {
|
|
|
|
if (PCI_SLOT(dev->devfn) != slot->device)
|
|
|
|
continue;
|
2013-07-13 21:27:26 +00:00
|
|
|
|
2005-04-28 07:25:53 +00:00
|
|
|
if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
|
2005-12-14 17:37:26 +00:00
|
|
|
dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
|
2005-04-28 07:25:53 +00:00
|
|
|
max = pci_scan_bridge(bus, dev, max, pass);
|
2013-01-21 21:20:42 +00:00
|
|
|
if (pass && dev->subordinate) {
|
|
|
|
check_hotplug_bridge(slot, dev);
|
PCI / ACPI: Use boot-time resource allocation rules during hotplug
On x86 platforms, the kernel respects PCI resource assignments from
the BIOS and only reassigns resources for unassigned BARs at boot
time. However, with the ACPI-based hotplug (acpiphp), it ignores the
BIOS' PCI resource assignments completely and reassigns all resources
by itself. This causes differences in PCI resource allocation
between boot time and runtime hotplug to occur, which is generally
undesirable and sometimes actively breaks things.
Namely, if there are enough resources, reassigning all PCI resources
during runtime hotplug should work, but it may fail if the resources
are constrained. This may happen, for instance, when some PCI
devices with huge MMIO BARs are involved in the runtime hotplug
operations, because the current PCI MMIO alignment algorithm may
waste huge chunks of MMIO address space in those cases.
On the Alexander's Sony VAIO VPCZ23A4R the BIOS allocates limited
MMIO resources for the dock station which contains a device
(graphics adapter) with a 256MB MMIO BAR. An attempt to reassign
that during runtime hotplug causes the dock station MMIO window to be
exhausted and acpiphp fails to allocate resources for the majority
of devices on the dock station as a result.
To prevent that from happening, modify acpiphp to follow the boot
time resources allocation behavior so that the BIOS' resource
assignments are respected during runtime hotplug too.
[rjw: Changelog]
References: https://bugzilla.kernel.org/show_bug.cgi?id=56531
Reported-and-tested-by: Alexander E. Patrakov <patrakov@gmail.com>
Tested-by: Illya Klymov <xanf@xanf.me>
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
Cc: 3.9+ <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-06-22 23:01:35 +00:00
|
|
|
pcibios_resource_survey_bus(dev->subordinate);
|
|
|
|
__pci_bus_size_bridges(dev->subordinate,
|
|
|
|
&add_list);
|
2013-01-21 21:20:42 +00:00
|
|
|
}
|
2005-12-14 17:37:26 +00:00
|
|
|
}
|
2005-04-28 07:25:53 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
PCI / ACPI: Use boot-time resource allocation rules during hotplug
On x86 platforms, the kernel respects PCI resource assignments from
the BIOS and only reassigns resources for unassigned BARs at boot
time. However, with the ACPI-based hotplug (acpiphp), it ignores the
BIOS' PCI resource assignments completely and reassigns all resources
by itself. This causes differences in PCI resource allocation
between boot time and runtime hotplug to occur, which is generally
undesirable and sometimes actively breaks things.
Namely, if there are enough resources, reassigning all PCI resources
during runtime hotplug should work, but it may fail if the resources
are constrained. This may happen, for instance, when some PCI
devices with huge MMIO BARs are involved in the runtime hotplug
operations, because the current PCI MMIO alignment algorithm may
waste huge chunks of MMIO address space in those cases.
On the Alexander's Sony VAIO VPCZ23A4R the BIOS allocates limited
MMIO resources for the dock station which contains a device
(graphics adapter) with a 256MB MMIO BAR. An attempt to reassign
that during runtime hotplug causes the dock station MMIO window to be
exhausted and acpiphp fails to allocate resources for the majority
of devices on the dock station as a result.
To prevent that from happening, modify acpiphp to follow the boot
time resources allocation behavior so that the BIOS' resource
assignments are respected during runtime hotplug too.
[rjw: Changelog]
References: https://bugzilla.kernel.org/show_bug.cgi?id=56531
Reported-and-tested-by: Alexander E. Patrakov <patrakov@gmail.com>
Tested-by: Illya Klymov <xanf@xanf.me>
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
Cc: 3.9+ <stable@vger.kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-06-22 23:01:35 +00:00
|
|
|
__pci_bus_assign_resources(bus, &add_list, NULL);
|
2013-09-06 13:41:32 +00:00
|
|
|
|
2005-10-19 00:21:40 +00:00
|
|
|
acpiphp_sanitize_bus(bus);
|
2009-09-14 22:35:10 +00:00
|
|
|
acpiphp_set_hpp_values(bus);
|
2010-02-25 02:59:34 +00:00
|
|
|
acpiphp_set_acpi_region(slot);
|
2011-05-11 16:00:32 +00:00
|
|
|
|
|
|
|
list_for_each_entry(dev, &bus->devices, bus_list) {
|
|
|
|
/* Assume that newly added devices are powered on already. */
|
|
|
|
if (!dev->is_added)
|
|
|
|
dev->current_state = PCI_D0;
|
|
|
|
}
|
|
|
|
|
2005-04-28 07:25:53 +00:00
|
|
|
pci_bus_add_devices(bus);
|
|
|
|
|
PCI: Can continually add funcs after adding func0
Boot up a KVM guest, and hotplug multifunction
devices(func1,func2,func0,func3) to guest.
for i in 1 2 0 3;do
qemu-img create /tmp/resize$i.qcow2 1G -f qcow2
(qemu) drive_add 0x11.$i id=drv11$i,if=none,file=/tmp/resize$i.qcow2
(qemu) device_add virtio-blk-pci,id=dev11$i,drive=drv11$i,addr=0x11.$i,multifunction=on
done
In linux kernel, when func0 of the slot is hot-added, the whole
slot will be marked as 'enabled', then driver will ignore other new
hotadded funcs.
But in Win7 & WinXP, we can continaully add other funcs after adding
func0, all funcs will be added in guest.
drivers/pci/hotplug/acpiphp_glue.c:
static int acpiphp_check_bridge(struct acpiphp_bridge *bridge)
{
....
for (slot = bridge->slots; slot; slot = slot->next) {
if (slot->flags & SLOT_ENABLED) {
acpiphp_disable_slot()
else
acpiphp_enable_slot()
.... |
} v
enable_device()
|
v
//only don't enable slot if func0 is not added
list_for_each_entry(func, &slot->funcs, sibling) {
...
}
slot->flags |= SLOT_ENABLED; //mark slot to 'enabled'
This patch just make pci driver can continaully add funcs after adding
func 0. Only mark slot to 'enabled' when all funcs are added.
For pci multifunction hotplug, we can add functions one by one(func 0 is
necessary), and all functions will be removed in one time.
Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2011-11-25 07:03:07 +00:00
|
|
|
slot->flags |= SLOT_ENABLED;
|
2009-10-27 03:25:27 +00:00
|
|
|
list_for_each_entry(func, &slot->funcs, sibling) {
|
2009-05-21 22:21:15 +00:00
|
|
|
dev = pci_get_slot(bus, PCI_DEVFN(slot->device,
|
|
|
|
func->function));
|
PCI: Can continually add funcs after adding func0
Boot up a KVM guest, and hotplug multifunction
devices(func1,func2,func0,func3) to guest.
for i in 1 2 0 3;do
qemu-img create /tmp/resize$i.qcow2 1G -f qcow2
(qemu) drive_add 0x11.$i id=drv11$i,if=none,file=/tmp/resize$i.qcow2
(qemu) device_add virtio-blk-pci,id=dev11$i,drive=drv11$i,addr=0x11.$i,multifunction=on
done
In linux kernel, when func0 of the slot is hot-added, the whole
slot will be marked as 'enabled', then driver will ignore other new
hotadded funcs.
But in Win7 & WinXP, we can continaully add other funcs after adding
func0, all funcs will be added in guest.
drivers/pci/hotplug/acpiphp_glue.c:
static int acpiphp_check_bridge(struct acpiphp_bridge *bridge)
{
....
for (slot = bridge->slots; slot; slot = slot->next) {
if (slot->flags & SLOT_ENABLED) {
acpiphp_disable_slot()
else
acpiphp_enable_slot()
.... |
} v
enable_device()
|
v
//only don't enable slot if func0 is not added
list_for_each_entry(func, &slot->funcs, sibling) {
...
}
slot->flags |= SLOT_ENABLED; //mark slot to 'enabled'
This patch just make pci driver can continaully add funcs after adding
func 0. Only mark slot to 'enabled' when all funcs are added.
For pci multifunction hotplug, we can add functions one by one(func 0 is
necessary), and all functions will be removed in one time.
Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2011-11-25 07:03:07 +00:00
|
|
|
if (!dev) {
|
|
|
|
/* Do not set SLOT_ENABLED flag if some funcs
|
|
|
|
are not added. */
|
|
|
|
slot->flags &= (~SLOT_ENABLED);
|
2006-03-22 05:49:20 +00:00
|
|
|
continue;
|
PCI: Can continually add funcs after adding func0
Boot up a KVM guest, and hotplug multifunction
devices(func1,func2,func0,func3) to guest.
for i in 1 2 0 3;do
qemu-img create /tmp/resize$i.qcow2 1G -f qcow2
(qemu) drive_add 0x11.$i id=drv11$i,if=none,file=/tmp/resize$i.qcow2
(qemu) device_add virtio-blk-pci,id=dev11$i,drive=drv11$i,addr=0x11.$i,multifunction=on
done
In linux kernel, when func0 of the slot is hot-added, the whole
slot will be marked as 'enabled', then driver will ignore other new
hotadded funcs.
But in Win7 & WinXP, we can continaully add other funcs after adding
func0, all funcs will be added in guest.
drivers/pci/hotplug/acpiphp_glue.c:
static int acpiphp_check_bridge(struct acpiphp_bridge *bridge)
{
....
for (slot = bridge->slots; slot; slot = slot->next) {
if (slot->flags & SLOT_ENABLED) {
acpiphp_disable_slot()
else
acpiphp_enable_slot()
.... |
} v
enable_device()
|
v
//only don't enable slot if func0 is not added
list_for_each_entry(func, &slot->funcs, sibling) {
...
}
slot->flags |= SLOT_ENABLED; //mark slot to 'enabled'
This patch just make pci driver can continaully add funcs after adding
func 0. Only mark slot to 'enabled' when all funcs are added.
For pci multifunction hotplug, we can add functions one by one(func 0 is
necessary), and all functions will be removed in one time.
Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
2011-11-25 07:03:07 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-07-13 21:27:26 +00:00
|
|
|
* disable_slot - disable a slot
|
2007-11-28 17:04:30 +00:00
|
|
|
* @slot: ACPI PHP slot
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2013-07-13 21:27:26 +00:00
|
|
|
static void disable_slot(struct acpiphp_slot *slot)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2014-02-03 23:37:02 +00:00
|
|
|
struct pci_bus *bus = slot->bus;
|
|
|
|
struct pci_dev *dev, *prev;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct acpiphp_func *func;
|
2006-03-22 05:49:20 +00:00
|
|
|
|
2012-05-23 16:20:35 +00:00
|
|
|
/*
|
2013-07-13 21:27:26 +00:00
|
|
|
* enable_slot() enumerates all functions in this device via
|
2012-05-23 16:20:35 +00:00
|
|
|
* pci_scan_slot(), whether they have associated ACPI hotplug
|
|
|
|
* methods (_EJ0, etc.) or not. Therefore, we remove all functions
|
|
|
|
* here.
|
|
|
|
*/
|
2014-02-03 23:37:02 +00:00
|
|
|
list_for_each_entry_safe_reverse(dev, prev, &bus->devices, bus_list)
|
|
|
|
if (PCI_SLOT(dev->devfn) == slot->device)
|
|
|
|
pci_stop_and_remove_bus_device(dev);
|
2006-09-12 17:22:53 +00:00
|
|
|
|
2013-07-13 21:27:25 +00:00
|
|
|
list_for_each_entry(func, &slot->funcs, sibling)
|
2014-02-03 23:39:33 +00:00
|
|
|
acpi_bus_trim(func_to_acpi_device(func));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
slot->flags &= (~SLOT_ENABLED);
|
|
|
|
}
|
|
|
|
|
2014-02-03 23:39:20 +00:00
|
|
|
static bool acpiphp_no_hotplug(struct acpi_device *adev)
|
ACPIPHP / radeon / nouveau: Fix VGA switcheroo problem related to hotplug
The changes in the ACPI-based PCI hotplug (ACPIPHP) subsystem made
during the 3.12 development cycle uncovered a problem with VGA
switcheroo that on some systems, when the device-specific method
(ATPX in the radeon case, _DSM in the nouveau case) is used to turn
off the discrete graphics, the BIOS generates ACPI hotplug events for
that device and those events cause ACPIPHP to attempt to remove the
device from the system (they are events for a device that was present
previously and is not present any more, so that's what should be done
according to the spec). Then, the system stops functioning correctly.
Since the hotplug events in question were simply silently ignored
previously, the least intrusive way to address that problem is to
make ACPIPHP ignore them again. For this purpose, introduce a new
ACPI device flag, no_hotplug, and modify ACPIPHP to ignore hotplug
events for PCI devices whose ACPI companions have that flag set.
Next, make the radeon and nouveau switcheroo detection code set the
no_hotplug flag for the discrete graphics' ACPI companion.
Fixes: bbd34fcdd1b2 (ACPI / hotplug / PCI: Register all devices under the given bridge)
References: https://bugzilla.kernel.org/show_bug.cgi?id=61891
References: https://bugzilla.kernel.org/show_bug.cgi?id=64891
Reported-and-tested-by: Mike Lothian <mike@fireburn.co.uk>
Reported-and-tested-by: <madcatx@atlas.cz>
Reported-and-tested-by: Joaquín Aramendía <samsagax@gmail.com>
Cc: Alex Deucher <alexdeucher@gmail.com>
Cc: Dave Airlie <airlied@linux.ie>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: 3.12+ <stable@vger.kernel.org> # 3.12+
2013-12-31 12:39:42 +00:00
|
|
|
{
|
|
|
|
return adev && adev->flags.no_hotplug;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool slot_no_hotplug(struct acpiphp_slot *slot)
|
|
|
|
{
|
|
|
|
struct acpiphp_func *func;
|
|
|
|
|
|
|
|
list_for_each_entry(func, &slot->funcs, sibling)
|
2014-02-03 23:39:33 +00:00
|
|
|
if (acpiphp_no_hotplug(func_to_acpi_device(func)))
|
ACPIPHP / radeon / nouveau: Fix VGA switcheroo problem related to hotplug
The changes in the ACPI-based PCI hotplug (ACPIPHP) subsystem made
during the 3.12 development cycle uncovered a problem with VGA
switcheroo that on some systems, when the device-specific method
(ATPX in the radeon case, _DSM in the nouveau case) is used to turn
off the discrete graphics, the BIOS generates ACPI hotplug events for
that device and those events cause ACPIPHP to attempt to remove the
device from the system (they are events for a device that was present
previously and is not present any more, so that's what should be done
according to the spec). Then, the system stops functioning correctly.
Since the hotplug events in question were simply silently ignored
previously, the least intrusive way to address that problem is to
make ACPIPHP ignore them again. For this purpose, introduce a new
ACPI device flag, no_hotplug, and modify ACPIPHP to ignore hotplug
events for PCI devices whose ACPI companions have that flag set.
Next, make the radeon and nouveau switcheroo detection code set the
no_hotplug flag for the discrete graphics' ACPI companion.
Fixes: bbd34fcdd1b2 (ACPI / hotplug / PCI: Register all devices under the given bridge)
References: https://bugzilla.kernel.org/show_bug.cgi?id=61891
References: https://bugzilla.kernel.org/show_bug.cgi?id=64891
Reported-and-tested-by: Mike Lothian <mike@fireburn.co.uk>
Reported-and-tested-by: <madcatx@atlas.cz>
Reported-and-tested-by: Joaquín Aramendía <samsagax@gmail.com>
Cc: Alex Deucher <alexdeucher@gmail.com>
Cc: Dave Airlie <airlied@linux.ie>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: 3.12+ <stable@vger.kernel.org> # 3.12+
2013-12-31 12:39:42 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get_slot_status - get ACPI slot status
|
2007-11-28 17:04:30 +00:00
|
|
|
* @slot: ACPI PHP slot
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
2007-11-28 17:04:30 +00:00
|
|
|
* If a slot has _STA for each function and if any one of them
|
|
|
|
* returned non-zero status, return it.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
2007-11-28 17:04:30 +00:00
|
|
|
* If a slot doesn't have _STA and if any one of its functions'
|
|
|
|
* configuration space is configured, return 0x0f as a _STA.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
2007-11-28 17:04:30 +00:00
|
|
|
* Otherwise return 0.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
static unsigned int get_slot_status(struct acpiphp_slot *slot)
|
|
|
|
{
|
2008-10-10 06:22:59 +00:00
|
|
|
unsigned long long sta = 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct acpiphp_func *func;
|
|
|
|
|
2009-10-27 03:25:27 +00:00
|
|
|
list_for_each_entry(func, &slot->funcs, sibling) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if (func->flags & FUNC_HAS_STA) {
|
2013-07-13 21:27:25 +00:00
|
|
|
acpi_status status;
|
|
|
|
|
|
|
|
status = acpi_evaluate_integer(func_to_handle(func),
|
|
|
|
"_STA", NULL, &sta);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ACPI_SUCCESS(status) && sta)
|
|
|
|
break;
|
|
|
|
} else {
|
2013-07-13 21:27:25 +00:00
|
|
|
u32 dvid;
|
|
|
|
|
2013-07-13 21:27:25 +00:00
|
|
|
pci_bus_read_config_dword(slot->bus,
|
2005-04-16 22:20:36 +00:00
|
|
|
PCI_DEVFN(slot->device,
|
|
|
|
func->function),
|
|
|
|
PCI_VENDOR_ID, &dvid);
|
|
|
|
if (dvid != 0xffffffff) {
|
|
|
|
sta = ACPI_STA_ALL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (unsigned int)sta;
|
|
|
|
}
|
|
|
|
|
2014-02-11 10:42:37 +00:00
|
|
|
static inline bool device_status_valid(unsigned int sta)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* ACPI spec says that _STA may return bit 0 clear with bit 3 set
|
|
|
|
* if the device is valid but does not require a device driver to be
|
|
|
|
* loaded (Section 6.3.7 of ACPI 5.0A).
|
|
|
|
*/
|
|
|
|
unsigned int mask = ACPI_STA_DEVICE_ENABLED | ACPI_STA_DEVICE_FUNCTIONING;
|
|
|
|
return (sta & mask) == mask;
|
|
|
|
}
|
|
|
|
|
ACPI / hotplug / PCI: Check for new devices on enabled slots
The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is
ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not
ACPI_STA_ALL.
This behavior is not sufficient to handle the Thunderbolt daisy
chaining case properly, however, because in that case the bus
behind the already enabled slot needs to be rescanned for new
devices.
For this reason, modify acpiphp_check_bridge() so that slots are
disabled and stopped if they are not in the ACPI_STA_ALL state.
For slots in the ACPI_STA_ALL state, devices behind them that don't
respond are trimmed using a new function, trim_stale_devices(),
introduced specifically for this purpose. That function walks
the given bus and checks each device on it. If the device doesn't
respond, it is assumed to be gone and is removed.
Once all of the stale devices directy behind the slot have been
removed, acpiphp_check_bridge() will start looking for new devices
that might have appeared on the given bus. It will do that even if
the slot is already enabled (SLOT_ENABLED is set for it).
In addition to that, make the bus check notification ignore
SLOT_ENABLED and go for enable_device() directly if bridge is NULL,
so that devices behind the slot are re-enumerated in that case too.
This change is based on earlier patches from Kirill A Shutemov
and Mika Westerberg.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2013-07-16 20:10:35 +00:00
|
|
|
/**
|
|
|
|
* trim_stale_devices - remove PCI devices that are not responding.
|
|
|
|
* @dev: PCI device to start walking the hierarchy from.
|
|
|
|
*/
|
|
|
|
static void trim_stale_devices(struct pci_dev *dev)
|
|
|
|
{
|
2014-02-03 23:38:52 +00:00
|
|
|
struct acpi_device *adev = ACPI_COMPANION(&dev->dev);
|
ACPI / hotplug / PCI: Check for new devices on enabled slots
The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is
ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not
ACPI_STA_ALL.
This behavior is not sufficient to handle the Thunderbolt daisy
chaining case properly, however, because in that case the bus
behind the already enabled slot needs to be rescanned for new
devices.
For this reason, modify acpiphp_check_bridge() so that slots are
disabled and stopped if they are not in the ACPI_STA_ALL state.
For slots in the ACPI_STA_ALL state, devices behind them that don't
respond are trimmed using a new function, trim_stale_devices(),
introduced specifically for this purpose. That function walks
the given bus and checks each device on it. If the device doesn't
respond, it is assumed to be gone and is removed.
Once all of the stale devices directy behind the slot have been
removed, acpiphp_check_bridge() will start looking for new devices
that might have appeared on the given bus. It will do that even if
the slot is already enabled (SLOT_ENABLED is set for it).
In addition to that, make the bus check notification ignore
SLOT_ENABLED and go for enable_device() directly if bridge is NULL,
so that devices behind the slot are re-enumerated in that case too.
This change is based on earlier patches from Kirill A Shutemov
and Mika Westerberg.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2013-07-16 20:10:35 +00:00
|
|
|
struct pci_bus *bus = dev->subordinate;
|
|
|
|
bool alive = false;
|
|
|
|
|
2014-02-03 23:38:52 +00:00
|
|
|
if (adev) {
|
ACPI / hotplug / PCI: Check for new devices on enabled slots
The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is
ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not
ACPI_STA_ALL.
This behavior is not sufficient to handle the Thunderbolt daisy
chaining case properly, however, because in that case the bus
behind the already enabled slot needs to be rescanned for new
devices.
For this reason, modify acpiphp_check_bridge() so that slots are
disabled and stopped if they are not in the ACPI_STA_ALL state.
For slots in the ACPI_STA_ALL state, devices behind them that don't
respond are trimmed using a new function, trim_stale_devices(),
introduced specifically for this purpose. That function walks
the given bus and checks each device on it. If the device doesn't
respond, it is assumed to be gone and is removed.
Once all of the stale devices directy behind the slot have been
removed, acpiphp_check_bridge() will start looking for new devices
that might have appeared on the given bus. It will do that even if
the slot is already enabled (SLOT_ENABLED is set for it).
In addition to that, make the bus check notification ignore
SLOT_ENABLED and go for enable_device() directly if bridge is NULL,
so that devices behind the slot are re-enumerated in that case too.
This change is based on earlier patches from Kirill A Shutemov
and Mika Westerberg.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2013-07-16 20:10:35 +00:00
|
|
|
acpi_status status;
|
|
|
|
unsigned long long sta;
|
|
|
|
|
2014-02-03 23:39:20 +00:00
|
|
|
status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta);
|
2014-02-11 10:42:37 +00:00
|
|
|
alive = (ACPI_SUCCESS(status) && device_status_valid(sta))
|
2014-02-03 23:39:20 +00:00
|
|
|
|| acpiphp_no_hotplug(adev);
|
ACPI / hotplug / PCI: Check for new devices on enabled slots
The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is
ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not
ACPI_STA_ALL.
This behavior is not sufficient to handle the Thunderbolt daisy
chaining case properly, however, because in that case the bus
behind the already enabled slot needs to be rescanned for new
devices.
For this reason, modify acpiphp_check_bridge() so that slots are
disabled and stopped if they are not in the ACPI_STA_ALL state.
For slots in the ACPI_STA_ALL state, devices behind them that don't
respond are trimmed using a new function, trim_stale_devices(),
introduced specifically for this purpose. That function walks
the given bus and checks each device on it. If the device doesn't
respond, it is assumed to be gone and is removed.
Once all of the stale devices directy behind the slot have been
removed, acpiphp_check_bridge() will start looking for new devices
that might have appeared on the given bus. It will do that even if
the slot is already enabled (SLOT_ENABLED is set for it).
In addition to that, make the bus check notification ignore
SLOT_ENABLED and go for enable_device() directly if bridge is NULL,
so that devices behind the slot are re-enumerated in that case too.
This change is based on earlier patches from Kirill A Shutemov
and Mika Westerberg.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2013-07-16 20:10:35 +00:00
|
|
|
}
|
2014-03-03 23:48:57 +00:00
|
|
|
if (!alive)
|
|
|
|
alive = pci_device_is_present(dev);
|
ACPI / hotplug / PCI: Check for new devices on enabled slots
The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is
ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not
ACPI_STA_ALL.
This behavior is not sufficient to handle the Thunderbolt daisy
chaining case properly, however, because in that case the bus
behind the already enabled slot needs to be rescanned for new
devices.
For this reason, modify acpiphp_check_bridge() so that slots are
disabled and stopped if they are not in the ACPI_STA_ALL state.
For slots in the ACPI_STA_ALL state, devices behind them that don't
respond are trimmed using a new function, trim_stale_devices(),
introduced specifically for this purpose. That function walks
the given bus and checks each device on it. If the device doesn't
respond, it is assumed to be gone and is removed.
Once all of the stale devices directy behind the slot have been
removed, acpiphp_check_bridge() will start looking for new devices
that might have appeared on the given bus. It will do that even if
the slot is already enabled (SLOT_ENABLED is set for it).
In addition to that, make the bus check notification ignore
SLOT_ENABLED and go for enable_device() directly if bridge is NULL,
so that devices behind the slot are re-enumerated in that case too.
This change is based on earlier patches from Kirill A Shutemov
and Mika Westerberg.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2013-07-16 20:10:35 +00:00
|
|
|
|
|
|
|
if (!alive) {
|
|
|
|
pci_stop_and_remove_bus_device(dev);
|
2014-02-03 23:38:52 +00:00
|
|
|
if (adev)
|
|
|
|
acpi_bus_trim(adev);
|
ACPI / hotplug / PCI: Check for new devices on enabled slots
The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is
ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not
ACPI_STA_ALL.
This behavior is not sufficient to handle the Thunderbolt daisy
chaining case properly, however, because in that case the bus
behind the already enabled slot needs to be rescanned for new
devices.
For this reason, modify acpiphp_check_bridge() so that slots are
disabled and stopped if they are not in the ACPI_STA_ALL state.
For slots in the ACPI_STA_ALL state, devices behind them that don't
respond are trimmed using a new function, trim_stale_devices(),
introduced specifically for this purpose. That function walks
the given bus and checks each device on it. If the device doesn't
respond, it is assumed to be gone and is removed.
Once all of the stale devices directy behind the slot have been
removed, acpiphp_check_bridge() will start looking for new devices
that might have appeared on the given bus. It will do that even if
the slot is already enabled (SLOT_ENABLED is set for it).
In addition to that, make the bus check notification ignore
SLOT_ENABLED and go for enable_device() directly if bridge is NULL,
so that devices behind the slot are re-enumerated in that case too.
This change is based on earlier patches from Kirill A Shutemov
and Mika Westerberg.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2013-07-16 20:10:35 +00:00
|
|
|
} else if (bus) {
|
|
|
|
struct pci_dev *child, *tmp;
|
|
|
|
|
|
|
|
/* The device is a bridge. so check the bus below it. */
|
|
|
|
pm_runtime_get_sync(&dev->dev);
|
2014-02-03 01:22:07 +00:00
|
|
|
list_for_each_entry_safe_reverse(child, tmp, &bus->devices, bus_list)
|
ACPI / hotplug / PCI: Check for new devices on enabled slots
The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is
ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not
ACPI_STA_ALL.
This behavior is not sufficient to handle the Thunderbolt daisy
chaining case properly, however, because in that case the bus
behind the already enabled slot needs to be rescanned for new
devices.
For this reason, modify acpiphp_check_bridge() so that slots are
disabled and stopped if they are not in the ACPI_STA_ALL state.
For slots in the ACPI_STA_ALL state, devices behind them that don't
respond are trimmed using a new function, trim_stale_devices(),
introduced specifically for this purpose. That function walks
the given bus and checks each device on it. If the device doesn't
respond, it is assumed to be gone and is removed.
Once all of the stale devices directy behind the slot have been
removed, acpiphp_check_bridge() will start looking for new devices
that might have appeared on the given bus. It will do that even if
the slot is already enabled (SLOT_ENABLED is set for it).
In addition to that, make the bus check notification ignore
SLOT_ENABLED and go for enable_device() directly if bridge is NULL,
so that devices behind the slot are re-enumerated in that case too.
This change is based on earlier patches from Kirill A Shutemov
and Mika Westerberg.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2013-07-16 20:10:35 +00:00
|
|
|
trim_stale_devices(child);
|
|
|
|
|
|
|
|
pm_runtime_put(&dev->dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/**
|
|
|
|
* acpiphp_check_bridge - re-enumerate devices
|
2007-11-28 17:04:30 +00:00
|
|
|
* @bridge: where to begin re-enumeration
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Iterate over all slots under this bridge and make sure that if a
|
|
|
|
* card is present they are enabled, and if not they are disabled.
|
|
|
|
*/
|
ACPI / hotplug / PCI: Check for new devices on enabled slots
The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is
ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not
ACPI_STA_ALL.
This behavior is not sufficient to handle the Thunderbolt daisy
chaining case properly, however, because in that case the bus
behind the already enabled slot needs to be rescanned for new
devices.
For this reason, modify acpiphp_check_bridge() so that slots are
disabled and stopped if they are not in the ACPI_STA_ALL state.
For slots in the ACPI_STA_ALL state, devices behind them that don't
respond are trimmed using a new function, trim_stale_devices(),
introduced specifically for this purpose. That function walks
the given bus and checks each device on it. If the device doesn't
respond, it is assumed to be gone and is removed.
Once all of the stale devices directy behind the slot have been
removed, acpiphp_check_bridge() will start looking for new devices
that might have appeared on the given bus. It will do that even if
the slot is already enabled (SLOT_ENABLED is set for it).
In addition to that, make the bus check notification ignore
SLOT_ENABLED and go for enable_device() directly if bridge is NULL,
so that devices behind the slot are re-enumerated in that case too.
This change is based on earlier patches from Kirill A Shutemov
and Mika Westerberg.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2013-07-16 20:10:35 +00:00
|
|
|
static void acpiphp_check_bridge(struct acpiphp_bridge *bridge)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct acpiphp_slot *slot;
|
|
|
|
|
2014-01-10 14:24:41 +00:00
|
|
|
/* Bail out if the bridge is going away. */
|
|
|
|
if (bridge->is_going_away)
|
|
|
|
return;
|
|
|
|
|
2013-04-12 05:44:27 +00:00
|
|
|
list_for_each_entry(slot, &bridge->slots, node) {
|
ACPI / hotplug / PCI: Check for new devices on enabled slots
The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is
ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not
ACPI_STA_ALL.
This behavior is not sufficient to handle the Thunderbolt daisy
chaining case properly, however, because in that case the bus
behind the already enabled slot needs to be rescanned for new
devices.
For this reason, modify acpiphp_check_bridge() so that slots are
disabled and stopped if they are not in the ACPI_STA_ALL state.
For slots in the ACPI_STA_ALL state, devices behind them that don't
respond are trimmed using a new function, trim_stale_devices(),
introduced specifically for this purpose. That function walks
the given bus and checks each device on it. If the device doesn't
respond, it is assumed to be gone and is removed.
Once all of the stale devices directy behind the slot have been
removed, acpiphp_check_bridge() will start looking for new devices
that might have appeared on the given bus. It will do that even if
the slot is already enabled (SLOT_ENABLED is set for it).
In addition to that, make the bus check notification ignore
SLOT_ENABLED and go for enable_device() directly if bridge is NULL,
so that devices behind the slot are re-enumerated in that case too.
This change is based on earlier patches from Kirill A Shutemov
and Mika Westerberg.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2013-07-16 20:10:35 +00:00
|
|
|
struct pci_bus *bus = slot->bus;
|
|
|
|
struct pci_dev *dev, *tmp;
|
|
|
|
|
ACPIPHP / radeon / nouveau: Fix VGA switcheroo problem related to hotplug
The changes in the ACPI-based PCI hotplug (ACPIPHP) subsystem made
during the 3.12 development cycle uncovered a problem with VGA
switcheroo that on some systems, when the device-specific method
(ATPX in the radeon case, _DSM in the nouveau case) is used to turn
off the discrete graphics, the BIOS generates ACPI hotplug events for
that device and those events cause ACPIPHP to attempt to remove the
device from the system (they are events for a device that was present
previously and is not present any more, so that's what should be done
according to the spec). Then, the system stops functioning correctly.
Since the hotplug events in question were simply silently ignored
previously, the least intrusive way to address that problem is to
make ACPIPHP ignore them again. For this purpose, introduce a new
ACPI device flag, no_hotplug, and modify ACPIPHP to ignore hotplug
events for PCI devices whose ACPI companions have that flag set.
Next, make the radeon and nouveau switcheroo detection code set the
no_hotplug flag for the discrete graphics' ACPI companion.
Fixes: bbd34fcdd1b2 (ACPI / hotplug / PCI: Register all devices under the given bridge)
References: https://bugzilla.kernel.org/show_bug.cgi?id=61891
References: https://bugzilla.kernel.org/show_bug.cgi?id=64891
Reported-and-tested-by: Mike Lothian <mike@fireburn.co.uk>
Reported-and-tested-by: <madcatx@atlas.cz>
Reported-and-tested-by: Joaquín Aramendía <samsagax@gmail.com>
Cc: Alex Deucher <alexdeucher@gmail.com>
Cc: Dave Airlie <airlied@linux.ie>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: 3.12+ <stable@vger.kernel.org> # 3.12+
2013-12-31 12:39:42 +00:00
|
|
|
if (slot_no_hotplug(slot)) {
|
|
|
|
; /* do nothing */
|
2014-02-11 10:42:37 +00:00
|
|
|
} else if (device_status_valid(get_slot_status(slot))) {
|
ACPI / hotplug / PCI: Check for new devices on enabled slots
The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is
ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not
ACPI_STA_ALL.
This behavior is not sufficient to handle the Thunderbolt daisy
chaining case properly, however, because in that case the bus
behind the already enabled slot needs to be rescanned for new
devices.
For this reason, modify acpiphp_check_bridge() so that slots are
disabled and stopped if they are not in the ACPI_STA_ALL state.
For slots in the ACPI_STA_ALL state, devices behind them that don't
respond are trimmed using a new function, trim_stale_devices(),
introduced specifically for this purpose. That function walks
the given bus and checks each device on it. If the device doesn't
respond, it is assumed to be gone and is removed.
Once all of the stale devices directy behind the slot have been
removed, acpiphp_check_bridge() will start looking for new devices
that might have appeared on the given bus. It will do that even if
the slot is already enabled (SLOT_ENABLED is set for it).
In addition to that, make the bus check notification ignore
SLOT_ENABLED and go for enable_device() directly if bridge is NULL,
so that devices behind the slot are re-enumerated in that case too.
This change is based on earlier patches from Kirill A Shutemov
and Mika Westerberg.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2013-07-16 20:10:35 +00:00
|
|
|
/* remove stale devices if any */
|
2014-02-03 01:22:07 +00:00
|
|
|
list_for_each_entry_safe_reverse(dev, tmp,
|
|
|
|
&bus->devices, bus_list)
|
ACPI / hotplug / PCI: Check for new devices on enabled slots
The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is
ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not
ACPI_STA_ALL.
This behavior is not sufficient to handle the Thunderbolt daisy
chaining case properly, however, because in that case the bus
behind the already enabled slot needs to be rescanned for new
devices.
For this reason, modify acpiphp_check_bridge() so that slots are
disabled and stopped if they are not in the ACPI_STA_ALL state.
For slots in the ACPI_STA_ALL state, devices behind them that don't
respond are trimmed using a new function, trim_stale_devices(),
introduced specifically for this purpose. That function walks
the given bus and checks each device on it. If the device doesn't
respond, it is assumed to be gone and is removed.
Once all of the stale devices directy behind the slot have been
removed, acpiphp_check_bridge() will start looking for new devices
that might have appeared on the given bus. It will do that even if
the slot is already enabled (SLOT_ENABLED is set for it).
In addition to that, make the bus check notification ignore
SLOT_ENABLED and go for enable_device() directly if bridge is NULL,
so that devices behind the slot are re-enumerated in that case too.
This change is based on earlier patches from Kirill A Shutemov
and Mika Westerberg.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2013-07-16 20:10:35 +00:00
|
|
|
if (PCI_SLOT(dev->devfn) == slot->device)
|
|
|
|
trim_stale_devices(dev);
|
|
|
|
|
|
|
|
/* configure all functions */
|
2013-07-13 21:27:26 +00:00
|
|
|
enable_slot(slot);
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
2013-07-13 21:27:26 +00:00
|
|
|
disable_slot(slot);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-09-14 22:35:10 +00:00
|
|
|
static void acpiphp_set_hpp_values(struct pci_bus *bus)
|
2005-04-28 07:25:56 +00:00
|
|
|
{
|
|
|
|
struct pci_dev *dev;
|
|
|
|
|
2009-09-14 22:35:35 +00:00
|
|
|
list_for_each_entry(dev, &bus->devices, bus_list)
|
|
|
|
pci_configure_slot(dev);
|
2005-04-28 07:25:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Remove devices for which we could not assign resources, call
|
|
|
|
* arch specific code to fix-up the bus
|
|
|
|
*/
|
|
|
|
static void acpiphp_sanitize_bus(struct pci_bus *bus)
|
|
|
|
{
|
2013-04-12 05:44:17 +00:00
|
|
|
struct pci_dev *dev, *tmp;
|
2005-04-28 07:25:56 +00:00
|
|
|
int i;
|
|
|
|
unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM;
|
|
|
|
|
2014-02-03 01:22:07 +00:00
|
|
|
list_for_each_entry_safe_reverse(dev, tmp, &bus->devices, bus_list) {
|
2005-04-28 07:25:56 +00:00
|
|
|
for (i=0; i<PCI_BRIDGE_RESOURCES; i++) {
|
|
|
|
struct resource *res = &dev->resource[i];
|
|
|
|
if ((res->flags & type_mask) && !res->start &&
|
|
|
|
res->end) {
|
|
|
|
/* Could not assign a required resources
|
|
|
|
* for this device, remove it */
|
2012-02-25 21:54:20 +00:00
|
|
|
pci_stop_and_remove_bus_device(dev);
|
2005-04-28 07:25:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* ACPI event handlers
|
|
|
|
*/
|
|
|
|
|
2014-02-03 23:45:13 +00:00
|
|
|
void acpiphp_check_host_bridge(struct acpi_device *adev)
|
2013-05-07 17:06:03 +00:00
|
|
|
{
|
|
|
|
struct acpiphp_bridge *bridge;
|
|
|
|
|
2014-02-03 23:45:13 +00:00
|
|
|
bridge = acpiphp_dev_to_bridge(adev);
|
2013-05-07 17:06:03 +00:00
|
|
|
if (bridge) {
|
2014-02-03 01:22:27 +00:00
|
|
|
pci_lock_rescan_remove();
|
|
|
|
|
2013-05-07 17:06:03 +00:00
|
|
|
acpiphp_check_bridge(bridge);
|
2014-02-03 01:22:27 +00:00
|
|
|
|
|
|
|
pci_unlock_rescan_remove();
|
2013-05-07 17:06:03 +00:00
|
|
|
put_bridge(bridge);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-10 14:24:41 +00:00
|
|
|
static int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot);
|
|
|
|
|
2014-02-03 23:42:20 +00:00
|
|
|
static void hotplug_event(u32 type, struct acpiphp_context *context)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2014-02-06 16:31:37 +00:00
|
|
|
acpi_handle handle = context->hp.self->handle;
|
2013-07-13 21:27:25 +00:00
|
|
|
struct acpiphp_func *func = &context->func;
|
2014-02-03 23:40:46 +00:00
|
|
|
struct acpiphp_slot *slot = func->slot;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct acpiphp_bridge *bridge;
|
2011-09-28 23:40:53 +00:00
|
|
|
|
2014-02-03 23:43:17 +00:00
|
|
|
acpi_lock_hp_context();
|
2013-07-13 21:27:24 +00:00
|
|
|
bridge = context->bridge;
|
2013-07-13 21:27:24 +00:00
|
|
|
if (bridge)
|
|
|
|
get_bridge(bridge);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2014-02-03 23:43:17 +00:00
|
|
|
acpi_unlock_hp_context();
|
ACPI / hotplug: Fix concurrency issues and memory leaks
This changeset is aimed at fixing a few different but related
problems in the ACPI hotplug infrastructure.
First of all, since notify handlers may be run in parallel with
acpi_bus_scan(), acpi_bus_trim() and acpi_bus_hot_remove_device()
and some of them are installed for ACPI handles that have no struct
acpi_device objects attached (i.e. before those objects are created),
those notify handlers have to take acpi_scan_lock to prevent races
from taking place (e.g. a struct acpi_device is found to be present
for the given ACPI handle, but right after that it is removed by
acpi_bus_trim() running in parallel to the given notify handler).
Moreover, since some of them call acpi_bus_scan() and
acpi_bus_trim(), this leads to the conclusion that acpi_scan_lock
should be acquired by the callers of these two funtions rather by
these functions themselves.
For these reasons, make all notify handlers that can handle device
addition and eject events take acpi_scan_lock and remove the
acpi_scan_lock locking from acpi_bus_scan() and acpi_bus_trim().
Accordingly, update all of their users to make sure that they
are always called under acpi_scan_lock.
Furthermore, since eject operations are carried out asynchronously
with respect to the notify events that trigger them, with the help
of acpi_bus_hot_remove_device(), even if notify handlers take the
ACPI scan lock, it still is possible that, for example,
acpi_bus_trim() will run between acpi_bus_hot_remove_device() and
the notify handler that scheduled its execution and that
acpi_bus_trim() will remove the device node passed to
acpi_bus_hot_remove_device() for ejection. In that case, the struct
acpi_device object obtained by acpi_bus_hot_remove_device() will be
invalid and not-so-funny things will ensue. To protect agaist that,
make the users of acpi_bus_hot_remove_device() run get_device() on
ACPI device node objects that are about to be passed to it and make
acpi_bus_hot_remove_device() run put_device() on them and check if
their ACPI handles are not NULL (make acpi_device_unregister() clear
the device nodes' ACPI handles for that check to work).
Finally, observe that acpi_os_hotplug_execute() actually can fail,
in which case its caller ought to free memory allocated for the
context object to prevent leaks from happening. It also needs to
run put_device() on the device node that it ran get_device() on
previously in that case. Modify the code accordingly.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
2013-02-13 13:36:47 +00:00
|
|
|
|
2014-02-03 01:22:17 +00:00
|
|
|
pci_lock_rescan_remove();
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case ACPI_NOTIFY_BUS_CHECK:
|
|
|
|
/* bus re-enumerate */
|
2014-02-03 23:41:52 +00:00
|
|
|
acpi_handle_debug(handle, "Bus check in %s()\n", __func__);
|
2014-02-03 23:40:46 +00:00
|
|
|
if (bridge)
|
2013-07-13 21:27:24 +00:00
|
|
|
acpiphp_check_bridge(bridge);
|
2014-02-03 23:40:46 +00:00
|
|
|
else if (!(slot->flags & SLOT_IS_GOING_AWAY))
|
2013-07-13 21:27:26 +00:00
|
|
|
enable_slot(slot);
|
ACPI / hotplug / PCI: Check for new devices on enabled slots
The current implementation of acpiphp_check_bridge() is pretty dumb:
- It enables a slot if it's not enabled and the slot status is
ACPI_STA_ALL.
- It disables a slot if it's enabled and the slot status is not
ACPI_STA_ALL.
This behavior is not sufficient to handle the Thunderbolt daisy
chaining case properly, however, because in that case the bus
behind the already enabled slot needs to be rescanned for new
devices.
For this reason, modify acpiphp_check_bridge() so that slots are
disabled and stopped if they are not in the ACPI_STA_ALL state.
For slots in the ACPI_STA_ALL state, devices behind them that don't
respond are trimmed using a new function, trim_stale_devices(),
introduced specifically for this purpose. That function walks
the given bus and checks each device on it. If the device doesn't
respond, it is assumed to be gone and is removed.
Once all of the stale devices directy behind the slot have been
removed, acpiphp_check_bridge() will start looking for new devices
that might have appeared on the given bus. It will do that even if
the slot is already enabled (SLOT_ENABLED is set for it).
In addition to that, make the bus check notification ignore
SLOT_ENABLED and go for enable_device() directly if bridge is NULL,
so that devices behind the slot are re-enumerated in that case too.
This change is based on earlier patches from Kirill A Shutemov
and Mika Westerberg.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2013-07-16 20:10:35 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_NOTIFY_DEVICE_CHECK:
|
|
|
|
/* device check */
|
2014-02-03 23:41:52 +00:00
|
|
|
acpi_handle_debug(handle, "Device check in %s()\n", __func__);
|
ACPI / hotplug / PCI: Avoid parent bus rescans on spurious device checks
In the current ACPIPHP notify handler we always go directly for a
rescan of the parent bus if we get a device check notification for
a device that is not a bridge. However, this obviously is
overzealous if nothing really changes, because this way we may rescan
the whole PCI hierarchy pretty much in vain.
That happens on Alex Williamson's machine whose ACPI tables contain
device objects that are supposed to coresspond to PCIe root ports,
but those ports aren't physically present (or at least they aren't
visible in the PCI config space to us). The BIOS generates multiple
device check notifies for those objects during boot and for each of
them we go straight for the parent bus rescan, but the parent bus is
the root bus in this particular case. In consequence, we rescan the
whole PCI bus from the top several times in a row, which is
completely unnecessary, increases boot time by 50% (after previous
fixes) and generates excess dmesg output from the PCI subsystem.
Fix the problem by checking if we can find anything new in the
slot corresponding to the device we've got a device check notify
for and doing nothig if that's not the case.
The spec (ACPI 5.0, Section 5.6.6) appears to mandate this behavior,
as it says:
Device Check. Used to notify OSPM that the device either appeared
or disappeared. If the device has appeared, OSPM will re-enumerate
from the parent. If the device has disappeared, OSPM will
invalidate the state of the device. OSPM may optimize out
re-enumeration.
Therefore, according to the spec, we are free to do nothing if
nothing changes.
References: https://bugzilla.kernel.org/show_bug.cgi?id=60865
Reported-and-tested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-09-07 22:07:28 +00:00
|
|
|
if (bridge) {
|
2013-07-13 21:27:24 +00:00
|
|
|
acpiphp_check_bridge(bridge);
|
2014-02-03 23:40:46 +00:00
|
|
|
} else if (!(slot->flags & SLOT_IS_GOING_AWAY)) {
|
ACPI / hotplug / PCI: Avoid parent bus rescans on spurious device checks
In the current ACPIPHP notify handler we always go directly for a
rescan of the parent bus if we get a device check notification for
a device that is not a bridge. However, this obviously is
overzealous if nothing really changes, because this way we may rescan
the whole PCI hierarchy pretty much in vain.
That happens on Alex Williamson's machine whose ACPI tables contain
device objects that are supposed to coresspond to PCIe root ports,
but those ports aren't physically present (or at least they aren't
visible in the PCI config space to us). The BIOS generates multiple
device check notifies for those objects during boot and for each of
them we go straight for the parent bus rescan, but the parent bus is
the root bus in this particular case. In consequence, we rescan the
whole PCI bus from the top several times in a row, which is
completely unnecessary, increases boot time by 50% (after previous
fixes) and generates excess dmesg output from the PCI subsystem.
Fix the problem by checking if we can find anything new in the
slot corresponding to the device we've got a device check notify
for and doing nothig if that's not the case.
The spec (ACPI 5.0, Section 5.6.6) appears to mandate this behavior,
as it says:
Device Check. Used to notify OSPM that the device either appeared
or disappeared. If the device has appeared, OSPM will re-enumerate
from the parent. If the device has disappeared, OSPM will
invalidate the state of the device. OSPM may optimize out
re-enumeration.
Therefore, according to the spec, we are free to do nothing if
nothing changes.
References: https://bugzilla.kernel.org/show_bug.cgi?id=60865
Reported-and-tested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-09-07 22:07:28 +00:00
|
|
|
/*
|
|
|
|
* Check if anything has changed in the slot and rescan
|
|
|
|
* from the parent if that's the case.
|
|
|
|
*/
|
2014-02-03 23:40:25 +00:00
|
|
|
if (acpiphp_rescan_slot(slot))
|
ACPI / hotplug / PCI: Avoid parent bus rescans on spurious device checks
In the current ACPIPHP notify handler we always go directly for a
rescan of the parent bus if we get a device check notification for
a device that is not a bridge. However, this obviously is
overzealous if nothing really changes, because this way we may rescan
the whole PCI hierarchy pretty much in vain.
That happens on Alex Williamson's machine whose ACPI tables contain
device objects that are supposed to coresspond to PCIe root ports,
but those ports aren't physically present (or at least they aren't
visible in the PCI config space to us). The BIOS generates multiple
device check notifies for those objects during boot and for each of
them we go straight for the parent bus rescan, but the parent bus is
the root bus in this particular case. In consequence, we rescan the
whole PCI bus from the top several times in a row, which is
completely unnecessary, increases boot time by 50% (after previous
fixes) and generates excess dmesg output from the PCI subsystem.
Fix the problem by checking if we can find anything new in the
slot corresponding to the device we've got a device check notify
for and doing nothig if that's not the case.
The spec (ACPI 5.0, Section 5.6.6) appears to mandate this behavior,
as it says:
Device Check. Used to notify OSPM that the device either appeared
or disappeared. If the device has appeared, OSPM will re-enumerate
from the parent. If the device has disappeared, OSPM will
invalidate the state of the device. OSPM may optimize out
re-enumeration.
Therefore, according to the spec, we are free to do nothing if
nothing changes.
References: https://bugzilla.kernel.org/show_bug.cgi?id=60865
Reported-and-tested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2013-09-07 22:07:28 +00:00
|
|
|
acpiphp_check_bridge(func->parent);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_NOTIFY_EJECT_REQUEST:
|
|
|
|
/* request device eject */
|
2014-02-03 23:41:52 +00:00
|
|
|
acpi_handle_debug(handle, "Eject request in %s()\n", __func__);
|
2014-02-03 23:40:46 +00:00
|
|
|
acpiphp_disable_and_eject_slot(slot);
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-09-28 23:40:53 +00:00
|
|
|
|
2014-02-03 01:22:17 +00:00
|
|
|
pci_unlock_rescan_remove();
|
2013-07-13 21:27:24 +00:00
|
|
|
if (bridge)
|
|
|
|
put_bridge(bridge);
|
ACPI / dock / PCI: Synchronous handling of dock events for PCI devices
The interactions between the ACPI dock driver and the ACPI-based PCI
hotplug (acpiphp) are currently problematic because of ordering
issues during hot-remove operations.
First of all, the current ACPI glue code expects that physical
devices will always be deleted before deleting the companion ACPI
device objects. Otherwise, acpi_unbind_one() will fail with a
warning message printed to the kernel log, for example:
[ 185.026073] usb usb5: Oops, 'acpi_handle' corrupt
[ 185.035150] pci 0000:1b:00.0: Oops, 'acpi_handle' corrupt
[ 185.035515] pci 0000:18:02.0: Oops, 'acpi_handle' corrupt
[ 180.013656] port1: Oops, 'acpi_handle' corrupt
This means, in particular, that struct pci_dev objects have to
be deleted before the struct acpi_device objects they are "glued"
with.
Now, the following happens the during the undocking of an ACPI-based
dock station:
1) hotplug_dock_devices() invokes registered hotplug callbacks to
destroy physical devices associated with the ACPI device objects
depending on the dock station. It calls dd->ops->handler() for
each of those device objects.
2) For PCI devices dd->ops->handler() points to
handle_hotplug_event_func() that queues up a separate work item
to execute _handle_hotplug_event_func() for the given device and
returns immediately. That work item will be executed later.
3) hotplug_dock_devices() calls dock_remove_acpi_device() for each
device depending on the dock station. This runs acpi_bus_trim()
for each of them, which causes the underlying ACPI device object
to be destroyed, but the work items queued up by
handle_hotplug_event_func() haven't been started yet.
4) _handle_hotplug_event_func() queued up in step 2) are executed
and cause the above failure to happen, because the PCI devices
they handle do not have the companion ACPI device objects any
more (those objects have been deleted in step 3).
The possible breakage doesn't end here, though, because
hotplug_dock_devices() may return before at least some of the
_handle_hotplug_event_func() work items spawned by it have a
chance to complete and then undock() will cause _DCK to be
evaluated and that will cause the devices handled by the
_handle_hotplug_event_func() to go away possibly while they are
being accessed.
This means that dd->ops->handler() for PCI devices should not point
to handle_hotplug_event_func(). Instead, it should point to a
function that will do the work of _handle_hotplug_event_func()
synchronously. For this reason, introduce such a function,
hotplug_event_func(), and modity acpiphp_dock_ops to point to
it as the handler.
Unfortunately, however, this is not sufficient, because if the dock
code were not changed further, hotplug_event_func() would now
deadlock with hotplug_dock_devices() that called it, since it would
run unregister_hotplug_dock_device() which in turn would attempt to
acquire the dock station's hp_lock mutex already acquired by
hotplug_dock_devices().
To resolve that deadlock use the observation that
unregister_hotplug_dock_device() won't need to acquire hp_lock
if PCI bridges the devices on the dock station depend on are
prevented from being removed prematurely while the first loop in
hotplug_dock_devices() is in progress.
To make that possible, introduce a mechanism by which the callers of
register_hotplug_dock_device() can provide "init" and "release"
routines that will be executed, respectively, during the addition
and removal of the physical device object associated with the
given ACPI device handle. Make acpiphp use two new functions,
acpiphp_dock_init() and acpiphp_dock_release(), that call
get_bridge() and put_bridge(), respectively, on the acpiphp bridge
holding the given device, for this purpose.
In addition to that, remove the dock station's list of
"hotplug devices" and make the dock code always walk the whole list
of "dependent devices" instead in such a way that the loops in
hotplug_dock_devices() and dock_event() (replacing the loops over
"hotplug devices") will take references to the list entries that
register_hotplug_dock_device() has been called for. That prevents
the "release" routines associated with those entries from being
called while the given entry is being processed and for PCI
devices this means that their bridges won't be removed (by a
concurrent thread) while hotplug_event_func() handling them is
being executed.
This change is based on two earlier patches from Jiang Liu.
References: https://bugzilla.kernel.org/show_bug.cgi?id=59501
Reported-and-tested-by: Alexander E. Patrakov <patrakov@gmail.com>
Tracked-down-by: Jiang Liu <jiang.liu@huawei.com>
Tested-by: Illya Klymov <xanf@xanf.me>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Yinghai Lu <yinghai@kernel.org>
Cc: 3.9+ <stable@vger.kernel.org>
2013-06-24 09:22:53 +00:00
|
|
|
}
|
|
|
|
|
2014-02-21 00:10:27 +00:00
|
|
|
static int acpiphp_hotplug_notify(struct acpi_device *adev, u32 type)
|
2011-09-28 23:40:53 +00:00
|
|
|
{
|
2013-07-13 21:27:24 +00:00
|
|
|
struct acpiphp_context *context;
|
|
|
|
|
2014-02-21 00:10:18 +00:00
|
|
|
context = acpiphp_grab_context(adev);
|
|
|
|
if (!context)
|
2014-02-06 16:31:37 +00:00
|
|
|
return -ENODATA;
|
2014-02-03 21:30:06 +00:00
|
|
|
|
2014-02-06 16:31:37 +00:00
|
|
|
hotplug_event(type, context);
|
2014-02-21 00:10:18 +00:00
|
|
|
acpiphp_let_context_go(context);
|
2014-02-06 16:31:37 +00:00
|
|
|
return 0;
|
2005-04-28 07:25:56 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2014-02-03 23:37:35 +00:00
|
|
|
/**
|
|
|
|
* acpiphp_enumerate_slots - Enumerate PCI slots for a given bus.
|
|
|
|
* @bus: PCI bus to enumerate the slots for.
|
|
|
|
*
|
|
|
|
* A "slot" is an object associated with a PCI device number. All functions
|
|
|
|
* (PCI devices) with the same bus and device number belong to the same slot.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2013-07-13 21:27:23 +00:00
|
|
|
void acpiphp_enumerate_slots(struct pci_bus *bus)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2013-04-12 05:44:26 +00:00
|
|
|
struct acpiphp_bridge *bridge;
|
2014-02-03 23:39:33 +00:00
|
|
|
struct acpi_device *adev;
|
2013-07-13 21:27:23 +00:00
|
|
|
acpi_handle handle;
|
|
|
|
acpi_status status;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-04-12 05:44:26 +00:00
|
|
|
if (acpiphp_disabled)
|
|
|
|
return;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2014-02-03 23:39:33 +00:00
|
|
|
adev = ACPI_COMPANION(bus->bridge);
|
|
|
|
if (!adev)
|
2013-04-12 05:44:26 +00:00
|
|
|
return;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2014-02-03 23:39:33 +00:00
|
|
|
handle = adev->handle;
|
2013-04-12 05:44:26 +00:00
|
|
|
bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
|
2013-07-13 21:27:24 +00:00
|
|
|
if (!bridge) {
|
|
|
|
acpi_handle_err(handle, "No memory for bridge object\n");
|
2013-04-12 05:44:26 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-12 05:44:27 +00:00
|
|
|
INIT_LIST_HEAD(&bridge->slots);
|
2013-04-12 05:44:28 +00:00
|
|
|
kref_init(&bridge->ref);
|
2013-04-12 05:44:26 +00:00
|
|
|
bridge->pci_dev = pci_dev_get(bus->self);
|
|
|
|
bridge->pci_bus = bus;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Grab a ref to the subordinate PCI bus in case the bus is
|
|
|
|
* removed via PCI core logical hotplug. The ref pins the bus
|
|
|
|
* (which we access during module unload).
|
|
|
|
*/
|
|
|
|
get_device(&bus->dev);
|
|
|
|
|
2013-07-13 21:27:24 +00:00
|
|
|
if (!pci_is_root_bus(bridge->pci_bus)) {
|
|
|
|
struct acpiphp_context *context;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This bridge should have been registered as a hotplug function
|
2013-10-11 23:49:48 +00:00
|
|
|
* under its parent, so the context should be there, unless the
|
|
|
|
* parent is going to be handled by pciehp, in which case this
|
|
|
|
* bridge is not interesting to us either.
|
2013-07-13 21:27:24 +00:00
|
|
|
*/
|
2014-02-03 23:43:17 +00:00
|
|
|
acpi_lock_hp_context();
|
2014-02-06 16:31:37 +00:00
|
|
|
context = acpiphp_get_context(adev);
|
2013-10-11 23:49:48 +00:00
|
|
|
if (!context) {
|
2014-02-03 23:43:17 +00:00
|
|
|
acpi_unlock_hp_context();
|
2013-07-13 21:27:24 +00:00
|
|
|
put_device(&bus->dev);
|
2013-10-11 11:20:50 +00:00
|
|
|
pci_dev_put(bridge->pci_dev);
|
2013-07-13 21:27:24 +00:00
|
|
|
kfree(bridge);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bridge->context = context;
|
|
|
|
context->bridge = bridge;
|
|
|
|
/* Get a reference to the parent bridge. */
|
2013-07-13 21:27:25 +00:00
|
|
|
get_bridge(context->func.parent);
|
2014-02-03 23:43:17 +00:00
|
|
|
acpi_unlock_hp_context();
|
2013-07-13 21:27:24 +00:00
|
|
|
}
|
|
|
|
|
2014-02-15 23:12:00 +00:00
|
|
|
/* Must be added to the list prior to calling acpiphp_add_context(). */
|
2013-07-13 21:27:23 +00:00
|
|
|
mutex_lock(&bridge_mutex);
|
|
|
|
list_add(&bridge->list, &bridge_list);
|
|
|
|
mutex_unlock(&bridge_mutex);
|
|
|
|
|
|
|
|
/* register all slot objects under this bridge */
|
2013-07-13 21:27:25 +00:00
|
|
|
status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
|
2014-02-15 23:12:00 +00:00
|
|
|
acpiphp_add_context, NULL, bridge, NULL);
|
2013-07-13 21:27:23 +00:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2013-07-13 21:27:25 +00:00
|
|
|
acpi_handle_err(handle, "failed to register slots\n");
|
2013-07-13 21:27:24 +00:00
|
|
|
cleanup_bridge(bridge);
|
|
|
|
put_bridge(bridge);
|
2013-07-13 21:27:23 +00:00
|
|
|
}
|
2013-04-12 05:44:26 +00:00
|
|
|
}
|
|
|
|
|
2014-02-03 23:37:35 +00:00
|
|
|
/**
|
|
|
|
* acpiphp_remove_slots - Remove slot objects associated with a given bus.
|
|
|
|
* @bus: PCI bus to remove the slot objects for.
|
|
|
|
*/
|
2013-04-12 05:44:26 +00:00
|
|
|
void acpiphp_remove_slots(struct pci_bus *bus)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2013-07-13 21:27:26 +00:00
|
|
|
struct acpiphp_bridge *bridge;
|
2013-04-12 05:44:26 +00:00
|
|
|
|
|
|
|
if (acpiphp_disabled)
|
|
|
|
return;
|
|
|
|
|
2013-07-13 21:27:26 +00:00
|
|
|
mutex_lock(&bridge_mutex);
|
|
|
|
list_for_each_entry(bridge, &bridge_list, list)
|
2013-04-12 05:44:26 +00:00
|
|
|
if (bridge->pci_bus == bus) {
|
2013-07-13 21:27:26 +00:00
|
|
|
mutex_unlock(&bridge_mutex);
|
2013-04-12 05:44:26 +00:00
|
|
|
cleanup_bridge(bridge);
|
2013-04-12 05:44:28 +00:00
|
|
|
put_bridge(bridge);
|
2013-07-13 21:27:26 +00:00
|
|
|
return;
|
2013-04-12 05:44:26 +00:00
|
|
|
}
|
2013-07-13 21:27:26 +00:00
|
|
|
|
|
|
|
mutex_unlock(&bridge_mutex);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* acpiphp_enable_slot - power on slot
|
2007-11-28 17:04:30 +00:00
|
|
|
* @slot: ACPI PHP slot
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
int acpiphp_enable_slot(struct acpiphp_slot *slot)
|
|
|
|
{
|
2014-01-10 14:24:41 +00:00
|
|
|
pci_lock_rescan_remove();
|
|
|
|
|
|
|
|
if (slot->flags & SLOT_IS_GOING_AWAY)
|
|
|
|
return -ENODEV;
|
|
|
|
|
2013-07-13 21:27:26 +00:00
|
|
|
/* configure all functions */
|
2013-07-13 21:27:26 +00:00
|
|
|
if (!(slot->flags & SLOT_ENABLED))
|
2013-07-13 21:27:26 +00:00
|
|
|
enable_slot(slot);
|
2013-07-13 21:27:26 +00:00
|
|
|
|
2014-01-10 14:24:41 +00:00
|
|
|
pci_unlock_rescan_remove();
|
2013-07-13 21:27:26 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-07-13 21:27:26 +00:00
|
|
|
* acpiphp_disable_and_eject_slot - power off and eject slot
|
2007-11-28 17:04:30 +00:00
|
|
|
* @slot: ACPI PHP slot
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2014-01-10 14:24:41 +00:00
|
|
|
static int acpiphp_disable_and_eject_slot(struct acpiphp_slot *slot)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2013-07-13 21:27:26 +00:00
|
|
|
struct acpiphp_func *func;
|
2014-01-10 14:24:41 +00:00
|
|
|
|
|
|
|
if (slot->flags & SLOT_IS_GOING_AWAY)
|
|
|
|
return -ENODEV;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* unconfigure all functions */
|
2013-07-13 21:27:26 +00:00
|
|
|
disable_slot(slot);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-07-13 21:27:26 +00:00
|
|
|
list_for_each_entry(func, &slot->funcs, sibling)
|
|
|
|
if (func->flags & FUNC_HAS_EJ0) {
|
|
|
|
acpi_handle handle = func_to_handle(func);
|
|
|
|
|
|
|
|
if (ACPI_FAILURE(acpi_evaluate_ej0(handle)))
|
|
|
|
acpi_handle_err(handle, "_EJ0 failed\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-01-10 14:24:41 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2014-01-10 14:24:41 +00:00
|
|
|
int acpiphp_disable_slot(struct acpiphp_slot *slot)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
2014-02-10 12:36:26 +00:00
|
|
|
/*
|
|
|
|
* Acquire acpi_scan_lock to ensure that the execution of _EJ0 in
|
|
|
|
* acpiphp_disable_and_eject_slot() will be synchronized properly.
|
|
|
|
*/
|
|
|
|
acpi_scan_lock_acquire();
|
2014-01-10 14:24:41 +00:00
|
|
|
pci_lock_rescan_remove();
|
|
|
|
ret = acpiphp_disable_and_eject_slot(slot);
|
|
|
|
pci_unlock_rescan_remove();
|
2014-02-10 12:36:26 +00:00
|
|
|
acpi_scan_lock_release();
|
2014-01-10 14:24:41 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* slot enabled: 1
|
|
|
|
* slot disabled: 0
|
|
|
|
*/
|
|
|
|
u8 acpiphp_get_power_status(struct acpiphp_slot *slot)
|
|
|
|
{
|
2013-07-13 21:27:26 +00:00
|
|
|
return (slot->flags & SLOT_ENABLED);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2006-10-25 18:44:57 +00:00
|
|
|
* latch open: 1
|
|
|
|
* latch closed: 0
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
u8 acpiphp_get_latch_status(struct acpiphp_slot *slot)
|
|
|
|
{
|
2013-07-13 21:27:26 +00:00
|
|
|
return !(get_slot_status(slot) & ACPI_STA_DEVICE_UI);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* adapter presence : 1
|
|
|
|
* absence : 0
|
|
|
|
*/
|
|
|
|
u8 acpiphp_get_adapter_status(struct acpiphp_slot *slot)
|
|
|
|
{
|
2013-07-13 21:27:26 +00:00
|
|
|
return !!get_slot_status(slot);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|