Skip to contentSkip to conversation

libata ACPI support

PATCH New Jeff Garzik 1 participant 1 message Feb 17, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libata ACPI support

This has been living in libata-dev#ALL (and thus -mm) for quite a while now.

For both PATA and SATA, this helps at suspend/resume time.

For SATA, ACPI support mostly consists of taskfiles (ATA commands) that the BIOS wants us to send to the system drive. Most notably, if you have set a hard drive password in BIOS, you cannot access your data without ACPI support. Given that libata has survived this long without ACPI support, this does not appear to impact many people.

For PATA, it makes available some DMA/PIO timing functions that occasionally cannot be found anywhere else. There is at least one case of this where NVIDIA needs ACPI's help to reliably handle various DMA/PIO modes (search in lkml/linux-ide archives for "pata_acpi").

NOTE: It is difficult to tell from the diff below, but the module parameter (or kernel command line arg) is "libata.noacpi" not the more generic "noacpi" that the diff might mistakenly lead you to believe. search for the associated module_param() code for further details.

Should this cause problems, we can easily turn it off. But as months of -mm testing seem to indicate, this hasn't caused much of a ripple, aside from solving a few lingering problems.

Please pull from 'acpi' branch of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/libata-dev.git acpi

to receive the following updates:

 Documentation/kernel-parameters.txt |    5 +
 drivers/ata/Kconfig                 |   13 +
 drivers/ata/Makefile                |    2 +-
 drivers/ata/libata-acpi.c           |  698 +++++++++++++++++++++++++++++++++++
 drivers/ata/libata-core.c           |   14 +
 drivers/ata/libata.h                |   15 +
 include/linux/libata.h              |    5 +
 7 files changed, 751 insertions(+), 1 deletions(-)
 create mode 100644 drivers/ata/libata-acpi.c

Fiodor Suietov (1):
libata: wrong sizeof for BUFFER

Kristen Carlson Accardi (3):
libata: ACPI and _GTF support
libata: ACPI _SDD support
libata: change order of _SDD/_GTF execution (resend #3)

Documentation/kernel-parameters.txt +5 -0
index abd575c..5bc8970 100644
@@ -48,6 +48,7 @@ parameter is applicable:
 	ISAPNP	ISA PnP code is enabled.
 	ISDN	Appropriate ISDN support is enabled.
 	JOY	Appropriate joystick support is enabled.
+	LIBATA  Libata driver is enabled
 	LP	Printer support is enabled.
 	LOOP	Loopback device support is enabled.
 	M68k	M68k architecture is enabled.
@@ -1038,6 +1039,10 @@ and is between 256 and 4096 characters. It is defined in the file
 			emulation library even if a 387 maths coprocessor
 			is present.
 
+	noacpi		[LIBATA] Disables use of ACPI in libata suspend/resume
+			when set.
+			Format: <int>
+
 	noaliencache	[MM, NUMA] Disables the allcoation of alien caches in
 			the slab allocator.  Saves per-node memory, but will
 			impact performance on real NUMA hardware.
drivers/ata/Kconfig +13 -0
index 3747457..4af0a4b 100644
@@ -161,6 +161,19 @@ config SATA_INTEL_COMBINED
 	depends on IDE=y && !BLK_DEV_IDE_SATA && (SATA_AHCI || ATA_PIIX)
 	default y
 
+config SATA_ACPI
+	bool
+	depends on ACPI && PCI
+	default y
+	help
+	  This option adds support for SATA-related ACPI objects.
+	  These ACPI objects add the ability to retrieve taskfiles
+	  from the ACPI BIOS and write them to the disk controller.
+	  These objects may be related to performance, security,
+	  power management, or other areas.
+	  You can disable this at kernel boot time by using the
+	  option libata.noacpi=1
+
 config PATA_ALI
 	tristate "ALi PATA support (Experimental)"
 	depends on PCI && EXPERIMENTAL
drivers/ata/Makefile +1 -1
index cd096f0..74298af 100644
@@ -66,4 +66,4 @@ obj-$(CONFIG_ATA_GENERIC)	+= ata_generic.o
 obj-$(CONFIG_PATA_LEGACY)	+= pata_legacy.o
 
 libata-objs	:= libata-core.o libata-scsi.o libata-sff.o libata-eh.o
-
+libata-$(CONFIG_SATA_ACPI) += libata-acpi.o
drivers/ata/libata-acpi.c new file +698 -0

698 lines not on this page · raw message

drivers/ata/libata-core.c +14 -0
index 2cf8251..e900c5e 100644
@@ -93,6 +93,10 @@ static int ata_probe_timeout = ATA_TMOUT_INTERNAL / HZ;
 module_param(ata_probe_timeout, int, 0444);
 MODULE_PARM_DESC(ata_probe_timeout, "Set ATA probing timeout (seconds)");
 
+int noacpi;
+module_param(noacpi, int, 0444);
+MODULE_PARM_DESC(noacpi, "Disables the use of ACPI in suspend/resume when set");
+
 MODULE_AUTHOR("Jeff Garzik");
 MODULE_DESCRIPTION("Library module for ATA devices");
 MODULE_LICENSE("GPL");
@@ -1564,6 +1568,16 @@ int ata_dev_configure(struct ata_device *dev)
 		ata_dev_printk(dev, KERN_DEBUG, "%s: ENTER, host %u, dev %u\n",
 			       __FUNCTION__, ap->id, dev->devno);
 
+	/* set _SDD */
+	rc = ata_acpi_push_id(ap, dev->devno);
+	if (rc) {
+		ata_dev_printk(dev, KERN_WARNING, "failed to set _SDD(%d)\n",
+			rc);
+	}
+
+	/* retrieve and execute the ATA task file of _GTF */
+	ata_acpi_exec_tfs(ap);
+
 	/* print device capabilities */
 	if (ata_msg_probe(ap))
 		ata_dev_printk(dev, KERN_DEBUG,
drivers/ata/libata.h +15 -0
index 06ccf23..0ad7781 100644
@@ -47,6 +47,7 @@ extern struct workqueue_struct *ata_aux_wq;
 extern int atapi_enabled;
 extern int atapi_dmadir;
 extern int libata_fua;
+extern int noacpi;
 extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev);
 extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
 			   u64 block, u32 n_block, unsigned int tf_flags,
@@ -87,6 +88,20 @@ extern void ata_port_init(struct ata_port *ap, struct ata_host *host,
 extern struct ata_probe_ent *ata_probe_ent_alloc(struct device *dev,
 						 const struct ata_port_info *port);
 
+/* libata-acpi.c */
+#ifdef CONFIG_SATA_ACPI
+extern int ata_acpi_exec_tfs(struct ata_port *ap);
+extern int ata_acpi_push_id(struct ata_port *ap, unsigned int ix);
+#else
+static inline int ata_acpi_exec_tfs(struct ata_port *ap)
+{
+	return 0;
+}
+static inline int ata_acpi_push_id(struct ata_port *ap, unsigned int ix)
+{
+	return 0;
+}
+#endif
 
 /* libata-scsi.c */
 extern struct scsi_transport_template ata_scsi_transport_template;
include/linux/libata.h +5 -0
index b870b20..86762a9 100644
@@ -35,6 +35,7 @@
 #include <linux/ata.h>
 #include <linux/workqueue.h>
 #include <scsi/scsi_host.h>
+#include <linux/acpi.h>
 
 /*
  * Define if arch has non-standard setup.  This is a _PCI_ standard
@@ -495,6 +496,10 @@ struct ata_device {
 	/* error history */
 	struct ata_ering	ering;
 	unsigned int		horkage;	/* List of broken features */
+#ifdef CONFIG_SATA_ACPI
+	/* ACPI objects info */
+	acpi_handle obj_handle;
+#endif
 };
 
 /* Offset into struct ata_device.  Fields above it are maintained