+++ /dev/null
-From 44521527be36172864e6e7a6fba4b66e9aa48e40 Mon Sep 17 00:00:00 2001
-From: Aaron Lu <aaron.lu@intel.com>
-Date: Thu, 20 Jun 2013 09:38:34 +0800
-Subject: libata-acpi: add back ACPI based hotplug functionality
-
-From: Aaron Lu <aaron.lu@intel.com>
-
-commit 44521527be36172864e6e7a6fba4b66e9aa48e40 upstream.
-
-Commit 30dcf76acc69 "libata: migrate ACPI code over to new bindings"
-mistakenly dropped the code to register hotplug notificaion handler
-for ATA port/devices, causing regression for people using ATA bay,
-as kernel bug #59871 shows.
-
-Fix this by adding back the hotplug notification handler registration
-code. Since this code has to be run once and notification needs to
-be installed on every ATA port/devices handle no matter if there is
-actual device attached, we can't do this in binding time for ATA
-device ACPI handle, as the binding only occurs when a SCSI device is
-created, i.e. there is device attached. So introduce the
-ata_acpi_hotplug_init() function to loop scan all ATA ACPI handles
-and if it is available, install the notificaion handler for it during
-ATA init time.
-
-With the ATA ACPI handle binding to SCSI device tree, it is possible
-now that when the SCSI hotplug work removes the SCSI device, the ACPI
-unbind function will find that the corresponding ACPI device has
-already been deleted by dock driver, causing a scaring message like:
-[ 128.263966] scsi 4:0:0:0: Oops, 'acpi_handle' corrupt
-Fix this by waiting for SCSI hotplug task finish in our notificaion
-handler, so that the removal of ACPI device done in ACPI unbind
-function triggered by the removal of SCSI device is run earlier when
-ACPI device is still available.
-
-[rjw: Rebased]
-References: https://bugzilla.kernel.org/show_bug.cgi?id=59871
-Reported-bisected-and-tested-by: Dirk Griesbach <spamthis@freenet.de>
-Signed-off-by: Aaron Lu <aaron.lu@intel.com>
-Acked-by: Tejun Heo <tj@kernel.org>
-Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-
----
- drivers/ata/libata-acpi.c | 37 ++++++++++++++++++++++++++++++++++++-
- drivers/ata/libata-core.c | 2 ++
- drivers/ata/libata.h | 2 ++
- 3 files changed, 40 insertions(+), 1 deletion(-)
-
---- a/drivers/ata/libata-acpi.c
-+++ b/drivers/ata/libata-acpi.c
-@@ -157,8 +157,10 @@ static void ata_acpi_handle_hotplug(stru
-
- spin_unlock_irqrestore(ap->lock, flags);
-
-- if (wait)
-+ if (wait) {
- ata_port_wait_eh(ap);
-+ flush_work(&ap->hotplug_task.work);
-+ }
- }
-
- static void ata_acpi_dev_notify_dock(acpi_handle handle, u32 event, void *data)
-@@ -215,6 +217,39 @@ static const struct acpi_dock_ops ata_ac
- .uevent = ata_acpi_ap_uevent,
- };
-
-+void ata_acpi_hotplug_init(struct ata_host *host)
-+{
-+ int i;
-+
-+ for (i = 0; i < host->n_ports; i++) {
-+ struct ata_port *ap = host->ports[i];
-+ acpi_handle handle;
-+ struct ata_device *dev;
-+
-+ if (!ap)
-+ continue;
-+
-+ handle = ata_ap_acpi_handle(ap);
-+ if (handle) {
-+ /* we might be on a docking station */
-+ register_hotplug_dock_device(handle,
-+ &ata_acpi_ap_dock_ops, ap,
-+ NULL, NULL);
-+ }
-+
-+ ata_for_each_dev(dev, &ap->link, ALL) {
-+ handle = ata_dev_acpi_handle(dev);
-+ if (!handle)
-+ continue;
-+
-+ /* we might be on a docking station */
-+ register_hotplug_dock_device(handle,
-+ &ata_acpi_dev_dock_ops,
-+ dev, NULL, NULL);
-+ }
-+ }
-+}
-+
- /**
- * ata_acpi_dissociate - dissociate ATA host from ACPI objects
- * @host: target ATA host
---- a/drivers/ata/libata-core.c
-+++ b/drivers/ata/libata-core.c
-@@ -6148,6 +6148,8 @@ int ata_host_register(struct ata_host *h
- if (rc)
- goto err_tadd;
-
-+ ata_acpi_hotplug_init(host);
-+
- /* set cable, sata_spd_limit and report */
- for (i = 0; i < host->n_ports; i++) {
- struct ata_port *ap = host->ports[i];
---- a/drivers/ata/libata.h
-+++ b/drivers/ata/libata.h
-@@ -122,6 +122,7 @@ extern int ata_acpi_register(void);
- extern void ata_acpi_unregister(void);
- extern void ata_acpi_bind(struct ata_device *dev);
- extern void ata_acpi_unbind(struct ata_device *dev);
-+extern void ata_acpi_hotplug_init(struct ata_host *host);
- #else
- static inline void ata_acpi_dissociate(struct ata_host *host) { }
- static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; }
-@@ -134,6 +135,7 @@ static inline int ata_acpi_register(void
- static inline void ata_acpi_unregister(void) { }
- static inline void ata_acpi_bind(struct ata_device *dev) { }
- static inline void ata_acpi_unbind(struct ata_device *dev) { }
-+static inline void ata_acpi_hotplug_init(struct ata_host *host) {}
- #endif
-
- /* libata-scsi.c */
+++ /dev/null
-From 3f327e39b4b8f760c331bb2836735be6d83fbf53 Mon Sep 17 00:00:00 2001
-From: Yinghai Lu <yinghai@kernel.org>
-Date: Tue, 7 May 2013 11:06:03 -0600
-Subject: PCI: acpiphp: Re-enumerate devices when host bridge receives Bus Check
-
-From: Yinghai Lu <yinghai@kernel.org>
-
-commit 3f327e39b4b8f760c331bb2836735be6d83fbf53 upstream.
-
-When a PCI host bridge device receives a Bus Check notification, we
-must re-enumerate starting with the bridge to discover changes (devices
-that have been added or removed).
-
-Prior to 668192b678 ("PCI: acpiphp: Move host bridge hotplug to
-pci_root.c"), this happened in _handle_hotplug_event_bridge(). After that
-commit, _handle_hotplug_event_bridge() is not installed for host bridges,
-and the host bridge notify handler, _handle_hotplug_event_root() did not
-re-enumerate.
-
-This patch adds re-enumeration to _handle_hotplug_event_root().
-
-This fixes cases where we don't notice the addition or removal of
-PCI devices, e.g., the PCI-to-USB ExpressCard in the bugzilla below.
-
--v1: Backport of 3f327e39b4 to v3.9 by Bjorn Helgaas <bhelgaas@google.com>
--v2: use request_module("acpiphp") for acpiphp as module instead of built-in.
-
-[bhelgaas: changelog, references]
-Reference: https://lkml.kernel.org/r/CAAh6nkmbKR3HTqm5ommevsBwhL_u0N8Rk7Wsms_LfP=nBgKNew@mail.gmail.com
-Reference: https://bugzilla.kernel.org/show_bug.cgi?id=57961
-Reported-by: Gavin Guo <tuffkidtt@gmail.com>
-Tested-by: Gavin Guo <tuffkidtt@gmail.com>
-Signed-off-by: Yinghai Lu <yinghai@kernel.org>
-Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-Reviewed-by: Jiang Liu <jiang.liu@huawei.com>
-Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-
----
- drivers/acpi/pci_root.c | 7 ++++++-
- drivers/pci/hotplug/acpiphp_glue.c | 14 ++++++++++++++
- include/linux/pci-acpi.h | 2 ++
- 3 files changed, 22 insertions(+), 1 deletion(-)
-
---- a/drivers/acpi/pci_root.c
-+++ b/drivers/acpi/pci_root.c
-@@ -665,6 +665,7 @@ static void handle_root_bridge_removal(s
- kfree(ej_event);
- }
-
-+void (*acpiphp_check_host_bridge)(acpi_handle handle);
- static void _handle_hotplug_event_root(struct work_struct *work)
- {
- struct acpi_pci_root *root;
-@@ -687,7 +688,11 @@ static void _handle_hotplug_event_root(s
- /* bus enumerate */
- printk(KERN_DEBUG "%s: Bus check notify on %s\n", __func__,
- (char *)buffer.pointer);
-- if (!root)
-+ if (root) {
-+ request_module("acpiphp");
-+ if (acpiphp_check_host_bridge)
-+ acpiphp_check_host_bridge(handle);
-+ } else
- handle_root_bridge_insertion(handle);
-
- break;
---- a/drivers/pci/hotplug/acpiphp_glue.c
-+++ b/drivers/pci/hotplug/acpiphp_glue.c
-@@ -1122,6 +1122,18 @@ check_sub_bridges(acpi_handle handle, u3
- return AE_OK ;
- }
-
-+static void __acpiphp_check_host_bridge(acpi_handle handle)
-+{
-+ struct acpiphp_bridge *bridge;
-+
-+ bridge = acpiphp_handle_to_bridge(handle);
-+ if (bridge)
-+ acpiphp_check_bridge(bridge);
-+
-+ acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
-+ ACPI_UINT32_MAX, check_sub_bridges, NULL, NULL, NULL);
-+}
-+
- static void _handle_hotplug_event_bridge(struct work_struct *work)
- {
- struct acpiphp_bridge *bridge;
-@@ -1305,6 +1317,7 @@ static struct acpi_pci_driver acpi_pci_h
- int __init acpiphp_glue_init(void)
- {
- acpi_pci_register_driver(&acpi_pci_hp_driver);
-+ acpiphp_check_host_bridge = __acpiphp_check_host_bridge;
-
- return 0;
- }
-@@ -1317,6 +1330,7 @@ int __init acpiphp_glue_init(void)
- */
- void acpiphp_glue_exit(void)
- {
-+ acpiphp_check_host_bridge = NULL;
- acpi_pci_unregister_driver(&acpi_pci_hp_driver);
- }
-
---- a/include/linux/pci-acpi.h
-+++ b/include/linux/pci-acpi.h
-@@ -43,6 +43,8 @@ static inline acpi_handle acpi_pci_get_b
- }
- #endif
-
-+extern void (*acpiphp_check_host_bridge)(acpi_handle handle);
-+
- #ifdef CONFIG_ACPI_APEI
- extern bool aer_acpi_firmware_first(void);
- #else