linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libata: Integrate ACPI-based PATA/SATA hotplug
@ 2007-09-15  3:01 Matthew Garrett
  2007-09-15 17:06 ` [PATCH] libata: Integrate ACPI-based PATA/SATA hotplug - version 2 Matthew Garrett
  0 siblings, 1 reply; 26+ messages in thread
From: Matthew Garrett @ 2007-09-15  3:01 UTC (permalink / raw)
  To: linux-ide, linux-acpi

Modern laptops with hotswap bays still tend to utilise a PATA interface 
on a SATA bridge, generally with the host controller in some legacy 
emulation mode rather than AHCI. This means that the existing hotplug 
code in libata is unable to work. The ACPI specification states that 
these devices can send notifications when hotswapped, which avoids the 
need to obtain notification from the controller. This patch uses the 
existing libata-acpi code and simply registers a notification in order 
to trigger a rescan whenever the firmware signals an event.

Signed-off-by: Matthew Garrett <mjg59@srcf.ucam.org>

---

I've tested this on the Dell I have here - the removal is a bit chatty 
(and it spends several seconds attempting to revalidate), but it 
destroys the device happily enough and handles reinsertion without 
complaining.

diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index c059f78..bc6bea6 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -66,6 +66,17 @@ static void ata_acpi_associate_ide_port(struct ata_port *ap)
 	}
 }
 
+static void ata_acpi_notify(acpi_handle handle, u32 event, void *data)
+{
+	struct ata_port *ap = data;
+	struct ata_eh_info *ehi = &ap->eh_info;
+
+	ata_ehi_clear_desc(ehi);
+	ata_ehi_push_desc(ehi, "ACPI event");
+	ata_ehi_hotplugged(ehi);
+	ata_port_freeze(ap);
+}
+
 /**
  * ata_acpi_associate - associate ATA host with ACPI objects
  * @host: target ATA host
@@ -97,6 +108,12 @@ void ata_acpi_associate(struct ata_host *host)
 			ata_acpi_associate_sata_port(ap);
 		else
 			ata_acpi_associate_ide_port(ap);
+
+		if (ap->device->acpi_handle)
+			acpi_install_notify_handler (ap->device->acpi_handle,
+						     ACPI_SYSTEM_NOTIFY,
+						     ata_acpi_notify,
+						     ap);
 	}
 }
 
-- 
Matthew Garrett | mjg59@srcf.ucam.org

^ permalink raw reply related	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2007-10-03 20:27 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-15  3:01 [PATCH] libata: Integrate ACPI-based PATA/SATA hotplug Matthew Garrett
2007-09-15 17:06 ` [PATCH] libata: Integrate ACPI-based PATA/SATA hotplug - version 2 Matthew Garrett
2007-09-16 12:22   ` Tejun Heo
2007-09-20 22:04   ` Jeff Garzik
2007-09-20 22:21     ` Matthew Garrett
2007-09-21  2:35       ` Tejun Heo
2007-09-21  2:42         ` Matthew Garrett
2007-09-21  2:53           ` Tejun Heo
2007-09-21  2:57             ` Matthew Garrett
2007-09-21  3:08               ` Tejun Heo
2007-09-21  3:12                 ` Matthew Garrett
2007-09-21  3:19                   ` Tejun Heo
2007-09-24 23:14                     ` [PATCH] libata: Integrate ACPI-based PATA/SATA hotplug - version 3 Matthew Garrett
2007-09-27 17:26                       ` Kristen Carlson Accardi
2007-09-27 17:55                         ` Matthew Garrett
2007-09-27 20:39                           ` Henrique de Moraes Holschuh
2007-10-02 15:04                       ` Jeff Garzik
2007-10-02 18:46                         ` Matthew Garrett
2007-10-02 18:49                         ` [PATCH] libata: Integrate ACPI-based PATA/SATA hotplug - version 4 Matthew Garrett
2007-10-02 18:55                           ` Jeff Garzik
2007-10-02 20:38                             ` Jeff Garzik
2007-10-02 20:42                               ` Matthew Garrett
2007-10-02 21:20                               ` Matthew Garrett
2007-10-02 21:23                                 ` Jeff Garzik
2007-10-03  0:24                                   ` [PATCH] libata: Integrate ACPI-based PATA/SATA hotplug - version 5 Matthew Garrett
2007-10-03 20:27                                     ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).