Skip to contentSkip to conversation

libata: _GTF support

PATCH Applied Kristen Carlson Accardi 8 participants 21 messages Sep 28, 2006 – Nov 14, 2006 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/2 libata: _GTF support

_GTF is an acpi method that is used to reinitialize the drive. It returns a task file containing ata commands that are sent back to the drive to restore it to boot up defaults.

---
 Documentation/kernel-parameters.txt |    5 
 drivers/ata/Kconfig                 |   13 
 drivers/ata/Makefile                |    2 
 drivers/ata/libata-acpi.c           |  602 ++++++++++++++++++++++++++++++++++++
 drivers/ata/libata-core.c           |    7 
 drivers/ata/libata.h                |   10 
 include/linux/libata.h              |    5 
 7 files changed, 643 insertions(+), 1 deletion(-)
Documentation/kernel-parameters.txt +5 -0
@@ -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.
@@ -1011,6 +1012,10 @@ and is between 256 and 4096 characters. 
 			emulation library even if a 387 maths coprocessor
 			is present.
 
+	noacpi		[LIBATA] Disables use of ACPI in libata suspend/resume
+			when set.
+			Format: <int>
+
 	noalign		[KNL,ARM]
 
 	noapic		[SMP,APIC] Tells the kernel to not make use of any
drivers/ata/Kconfig +13 -0
@@ -147,6 +147,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
@@ -59,4 +59,4 @@ obj-$(CONFIG_ATA_GENERIC)	+= ata_generic
 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 +602 -0

602 lines not on this page · raw message

drivers/ata/libata-core.c +7 -0
@@ -90,6 +90,10 @@ static int ata_probe_timeout = ATA_TMOUT
 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");
@@ -1597,6 +1601,9 @@ int ata_bus_probe(struct ata_port *ap)
 	/* reset and determine device classes */
 	ap->ops->phy_reset(ap);
 
+	/* retrieve and execute the ATA task file of _GTF */
+	ata_acpi_exec_tfs(ap);
+
 	for (i = 0; i < ATA_MAX_DEVICES; i++) {
 		dev = &ap->device[i];
 
drivers/ata/libata.h +10 -0
@@ -43,6 +43,7 @@ extern struct workqueue_struct *ata_aux_
 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_rwcmd_protocol(struct ata_queued_cmd *qc);
 extern void ata_dev_disable(struct ata_device *dev);
@@ -74,6 +75,15 @@ extern void ata_port_init(struct ata_por
 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);
+#else
+static inline int ata_acpi_exec_tfs(struct ata_port *ap)
+{
+	return 0;
+}
+#endif
 
 /* libata-scsi.c */
 extern struct scsi_transport_template ata_scsi_transport_template;
include/linux/libata.h +5 -0
@@ -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

--

#2 lore raw

drivers/ata/Kconfig config SATA_INTEL_COMBINED · line 152

Quoted 3 lines · Kristen Carlson Accardi
drivers/ata/Kconfig +3 -0
+config SATA_ACPI
+	bool
+	depends on ACPI && PCI

Why not s/SATA_ACPI/ACPI/ and delete the kconfig option, so this feature gets enabled automatically when user enables ACPI?

#3 lore raw
Quoted 9 lines · Diego Calleja

drivers/ata/Kconfig config SATA_INTEL_COMBINED · line 152

Quoted 3 lines · Kristen Carlson Accardi
drivers/ata/Kconfig +3 -0
+config SATA_ACPI
+	bool
+	depends on ACPI && PCI

Why not s/SATA_ACPI/ACPI/ and delete the kconfig option, so this feature gets enabled automatically when user enables ACPI?

It's a reasonable request, but I think it's better to integrate as-is, and then delete the Kconfig option as you describe once everybody is happy with the upstream, [hopefully-]working code.

Jeff

Applied
#4 lore raw
In reply to Kristen Carlson Accardi

Applied patches 1-2. Thanks to everyone involved -- you, Randy, and Forrest (who probably won't see this message).

I applied this to the new 'acpi' branch of libata-dev.git, and merged it into the meta-branch 'ALL', so that it will be automatically picked up by akpm's -mm tree.

I want this to get some testing before it goes upstream.

Jeff

#5 lore raw
In reply to Kristen Carlson Accardi

On Thu, Sep 28, 2006 at 11:29:01AM -0700, Kristen Carlson Accardi wrote:

I mentioned this to Randy a while back, but I can't remember what sort of resolution we came to. In any case:

Quoted 1 line

+ * sata_get_dev_handle - finds acpi_handle and PCI device.function

I'm a bit uncomfortable that we seem to have two quite different ways of accomplishing much the same thing. On the PCI bus, we have a callback that gets triggered whenever a new PCI device is attached. At that point, we look for the associated ACPI object and put a pointer to that in the device structure. Then, whenever we want to make an ACPI call, we can simply refer to that.

This implementation seems to reimplement much of the same lookup code, but makes it libata specific. Wouldn't it be cleaner to implement it in a similar way to PCI? The only real downside is that you need to add a callback in the ata bus code. drivers/pci/pci-acpi.c/pci_acpi_init is the sort of thing required.

(Thinking ahead, would that make it easier to maintain links in sysfs between devices and acpi objects?)

Signature · 1 line
Matthew Garrett | [email protected]
#6 lore raw
Quoted 14 lines · On Fri, 29 Sep 2006 03:07:07 +0100 Matthew Garrett <[email protected]> wrote:

On Thu, Sep 28, 2006 at 11:29:01AM -0700, Kristen Carlson Accardi wrote:

I mentioned this to Randy a while back, but I can't remember what sort of resolution we came to. In any case:

Quoted 1 line

+ * sata_get_dev_handle - finds acpi_handle and PCI device.function

I'm a bit uncomfortable that we seem to have two quite different ways of accomplishing much the same thing. On the PCI bus, we have a callback that gets triggered whenever a new PCI device is attached. At that point, we look for the associated ACPI object and put a pointer to that in the device structure. Then, whenever we want to make an ACPI call, we can simply refer to that.

Quoted 11 lines

This implementation seems to reimplement much of the same lookup code, but makes it libata specific. Wouldn't it be cleaner to implement it in a similar way to PCI? The only real downside is that you need to add a callback in the ata bus code. drivers/pci/pci-acpi.c/pci_acpi_init is the sort of thing required.

(Thinking ahead, would that make it easier to maintain links in sysfs between devices and acpi objects?)

Signature · 1 line
Matthew Garrett | [email protected]

This makes sense to me. I'm happy to put together some patches for commenting on if people think this is a good way to go. It would be much cleaner in my opinion and we could get rid of a good chunk of code.

Kristen

#7 lore raw
Quoted 26 lines · On Fri, 29 Sep 2006 09:54:09 -0700 Kristen Carlson Accardi wrote:
Quoted 23 lines · On Fri, 29 Sep 2006 03:07:07 +0100 Matthew Garrett <[email protected]> wrote:

On Thu, Sep 28, 2006 at 11:29:01AM -0700, Kristen Carlson Accardi wrote:

I mentioned this to Randy a while back, but I can't remember what sort of resolution we came to. In any case:

Quoted 1 line

+ * sata_get_dev_handle - finds acpi_handle and PCI device.function

I'm a bit uncomfortable that we seem to have two quite different ways of accomplishing much the same thing. On the PCI bus, we have a callback that gets triggered whenever a new PCI device is attached. At that point, we look for the associated ACPI object and put a pointer to that in the device structure. Then, whenever we want to make an ACPI call, we can simply refer to that.

This implementation seems to reimplement much of the same lookup code, but makes it libata specific. Wouldn't it be cleaner to implement it in a similar way to PCI? The only real downside is that you need to add a callback in the ata bus code. drivers/pci/pci-acpi.c/pci_acpi_init is the sort of thing required.

(Thinking ahead, would that make it easier to maintain links in sysfs between devices and acpi objects?)

Quoted 6 lines
Quoted 2 lines
Signature · 1 line
Matthew Garrett | [email protected]

This makes sense to me. I'm happy to put together some patches for commenting on if people think this is a good way to go. It would be much cleaner in my opinion and we could get rid of a good chunk of code.

My belated memory of it is that I tried Matthew's suggestion and it didn't work, but I have confidence in Kristen. Go for it.

---
~Randy

#8 lore raw
In reply to Matthew Garrett
Quoted 14 lines · On Fri, 29 Sep 2006 03:07:07 +0100 Matthew Garrett <[email protected]> wrote:

On Thu, Sep 28, 2006 at 11:29:01AM -0700, Kristen Carlson Accardi wrote:

I mentioned this to Randy a while back, but I can't remember what sort of resolution we came to. In any case:

Quoted 1 line

+ * sata_get_dev_handle - finds acpi_handle and PCI device.function

I'm a bit uncomfortable that we seem to have two quite different ways of accomplishing much the same thing. On the PCI bus, we have a callback that gets triggered whenever a new PCI device is attached. At that point, we look for the associated ACPI object and put a pointer to that in the device structure. Then, whenever we want to make an ACPI call, we can simply refer to that.

Quoted 11 lines

This implementation seems to reimplement much of the same lookup code, but makes it libata specific. Wouldn't it be cleaner to implement it in a similar way to PCI? The only real downside is that you need to add a callback in the ata bus code. drivers/pci/pci-acpi.c/pci_acpi_init is the sort of thing required.

(Thinking ahead, would that make it easier to maintain links in sysfs between devices and acpi objects?)

Signature · 1 line
Matthew Garrett | [email protected]

This makes sense to me. I'm happy to put together some patches for commenting on if people think this is a good way to go. It would be much cleaner in my opinion and we could get rid of a good chunk of code.

Kristen

#9 lore raw
In reply to Kristen Carlson Accardi
Quoted 4 lines · Kristen Carlson Accardi

_GTF is an acpi method that is used to reinitialize the drive. It returns a task file containing ata commands that are sent back to the drive to restore it to boot up defaults.

[...]

drivers/ata/libata-core.c int ata_bus_probe(struct ata_port *ap) · line 1609

Quoted 10 lines
drivers/ata/libata-core.c +3 -0
@@ -1597,6 +1601,9 @@ int ata_bus_probe(struct ata_port *ap)
 /* reset and determine device classes */
 ap->ops->phy_reset(ap);
 
+     /* retrieve and execute the ATA task file of _GTF */
+     ata_acpi_exec_tfs(ap);
+
 for (i = 0; i < ATA_MAX_DEVICES; i++) {
 dev = &ap->device[i];
 

ata_bus_probe() seems to be called only if driver does not provide own error handler? Also would GTF be executed on resume? I hoped it may fix resume from RAM problem I have but it looks like this is never executed in my case (pata_ali).

TIA

-andrey

#10 lore raw
Quoted 23 lines · On Sun, 01 Oct 2006 21:02:21 +0400 Andrey Borzenkov <[email protected]> wrote:
Quoted 4 lines · Kristen Carlson Accardi

_GTF is an acpi method that is used to reinitialize the drive. It returns a task file containing ata commands that are sent back to the drive to restore it to boot up defaults.

[...]

drivers/ata/libata-core.c int ata_bus_probe(struct ata_port *ap) · line 1609

Quoted 10 lines
drivers/ata/libata-core.c +3 -0
@@ -1597,6 +1601,9 @@ int ata_bus_probe(struct ata_port *ap)
 /* reset and determine device classes */
 ap->ops->phy_reset(ap);
 
+     /* retrieve and execute the ATA task file of _GTF */
+     ata_acpi_exec_tfs(ap);
+
 for (i = 0; i < ATA_MAX_DEVICES; i++) {
 dev = &ap->device[i];
 

ata_bus_probe() seems to be called only if driver does not provide own error handler? Also would GTF be executed on resume? I hoped it may fix resume from RAM problem I have but it looks like this is never executed in my case (pata_ali).

Quoted 3 lines

TIA

-andrey

Hi Andrey
On Friday I submitted another patch which changes where this is executed.
http://marc.theaimsgroup.com/?l=linux-ide&m=115957671114738&w=2

Hopefully this will work better for you.

Kristen

#11 lore raw
In reply to Kristen Carlson Accardi

Hi!

Documentation/kernel-parameters.txt and is between 256 and 4096 characters. · line 1017

Quoted 13 lines

_GTF is an acpi method that is used to reinitialize the drive. It returns a task file containing ata commands that are sent back to the drive to restore it to boot up defaults.

Documentation/kernel-parameters.txt +3 -0
@@ -1011,6 +1012,10 @@ and is between 256 and 4096 characters. 
 			emulation library even if a 387 maths coprocessor
 			is present.
 
+	noacpi		[LIBATA] Disables use of ACPI in libata suspend/resume
+			when set.
+			Format: <int>

Ugh, so we have noacpi=0/1, and it only affects suspend/resume? We definitely need better name here.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#12 lore raw

PATCH 1/2 libata: _GTF support

In reply to a message not in the archive

_GTF is an acpi method that is used to reinitialize the drive. It returns a task file containing ata commands that are sent back to the drive to restore it to boot up defaults.

---
 Documentation/kernel-parameters.txt |    5 
 drivers/ata/Kconfig                 |   13 
 drivers/ata/Makefile                |    2 
 drivers/ata/libata-acpi.c           |  602 ++++++++++++++++++++++++++++++++++++
 drivers/ata/libata-core.c           |    7 
 drivers/ata/libata.h                |   10 
 include/linux/libata.h              |    5 
 7 files changed, 643 insertions(+), 1 deletion(-)
Documentation/kernel-parameters.txt +5 -0
@@ -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.
@@ -1011,6 +1012,10 @@ and is between 256 and 4096 characters. 
 			emulation library even if a 387 maths coprocessor
 			is present.
 
+	noacpi		[LIBATA] Disables use of ACPI in libata suspend/resume
+			when set.
+			Format: <int>
+
 	noalign		[KNL,ARM]
 
 	noapic		[SMP,APIC] Tells the kernel to not make use of any
drivers/ata/Kconfig +13 -0
@@ -147,6 +147,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
@@ -59,4 +59,4 @@ obj-$(CONFIG_ATA_GENERIC)	+= ata_generic
 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 +602 -0

602 lines not on this page · raw message

drivers/ata/libata-core.c +7 -0
@@ -90,6 +90,10 @@ static int ata_probe_timeout = ATA_TMOUT
 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");
@@ -1597,6 +1601,9 @@ int ata_bus_probe(struct ata_port *ap)
 	/* reset and determine device classes */
 	ap->ops->phy_reset(ap);
 
+	/* retrieve and execute the ATA task file of _GTF */
+	ata_acpi_exec_tfs(ap);
+
 	for (i = 0; i < ATA_MAX_DEVICES; i++) {
 		dev = &ap->device[i];
 
drivers/ata/libata.h +10 -0
@@ -43,6 +43,7 @@ extern struct workqueue_struct *ata_aux_
 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_rwcmd_protocol(struct ata_queued_cmd *qc);
 extern void ata_dev_disable(struct ata_device *dev);
@@ -74,6 +75,15 @@ extern void ata_port_init(struct ata_por
 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);
+#else
+static inline int ata_acpi_exec_tfs(struct ata_port *ap)
+{
+	return 0;
+}
+#endif
 
 /* libata-scsi.c */
 extern struct scsi_transport_template ata_scsi_transport_template;
include/linux/libata.h +5 -0
@@ -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

--

#13 lore raw

PATCH 1/2 libata: _GTF support

In reply to a message not in the archive

_GTF is an acpi method that is used to reinitialize the drive. It returns a task file containing ata commands that are sent back to the drive to restore it to boot up defaults.

---
 Documentation/kernel-parameters.txt |    5 
 drivers/ata/Kconfig                 |   13 
 drivers/ata/Makefile                |    2 
 drivers/ata/libata-acpi.c           |  602 ++++++++++++++++++++++++++++++++++++
 drivers/ata/libata-core.c           |    7 
 drivers/ata/libata.h                |   10 
 include/linux/libata.h              |    5 
 7 files changed, 643 insertions(+), 1 deletion(-)
Documentation/kernel-parameters.txt +5 -0
@@ -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.
@@ -1011,6 +1012,10 @@ and is between 256 and 4096 characters. 
 			emulation library even if a 387 maths coprocessor
 			is present.
 
+	noacpi		[LIBATA] Disables use of ACPI in libata suspend/resume
+			when set.
+			Format: <int>
+
 	noalign		[KNL,ARM]
 
 	noapic		[SMP,APIC] Tells the kernel to not make use of any
drivers/ata/Kconfig +13 -0
@@ -147,6 +147,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
@@ -59,4 +59,4 @@ obj-$(CONFIG_ATA_GENERIC)	+= ata_generic
 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 +602 -0

602 lines not on this page · raw message

drivers/ata/libata-core.c +7 -0
@@ -90,6 +90,10 @@ static int ata_probe_timeout = ATA_TMOUT
 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");
@@ -1597,6 +1601,9 @@ int ata_bus_probe(struct ata_port *ap)
 	/* reset and determine device classes */
 	ap->ops->phy_reset(ap);
 
+	/* retrieve and execute the ATA task file of _GTF */
+	ata_acpi_exec_tfs(ap);
+
 	for (i = 0; i < ATA_MAX_DEVICES; i++) {
 		dev = &ap->device[i];
 
drivers/ata/libata.h +10 -0
@@ -43,6 +43,7 @@ extern struct workqueue_struct *ata_aux_
 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_rwcmd_protocol(struct ata_queued_cmd *qc);
 extern void ata_dev_disable(struct ata_device *dev);
@@ -74,6 +75,15 @@ extern void ata_port_init(struct ata_por
 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);
+#else
+static inline int ata_acpi_exec_tfs(struct ata_port *ap)
+{
+	return 0;
+}
+#endif
 
 /* libata-scsi.c */
 extern struct scsi_transport_template ata_scsi_transport_template;
include/linux/libata.h +5 -0
@@ -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

--

#14 lore raw

PATCH 2/2 libata: _SDD support

In reply to a message not in the archive

_SDD (Set Device Data) is an ACPI method that is used to tell the firmware what the identify data is of the device that is attached to the port. It is an optional method, and it's ok for it to be missing. Because of this, we always return success from the routine that calls this method, even if the execution fails.

---
 drivers/ata/libata-acpi.c |   96 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/ata/libata-core.c |    8 +++
 drivers/ata/libata.h      |    5 ++
 3 files changed, 109 insertions(+)
drivers/ata/libata-acpi.c +96 -0
@@ -600,3 +600,99 @@ int ata_acpi_exec_tfs(struct ata_port *a
 	return ret;
 }
 
+/**
+ * ata_acpi_push_id - send Identify data to drive
+ * @ap: the ata_port for the drive
+ * @ix: drive index
+ *
+ * _SDD ACPI object: for SATA mode only
+ * Must be after Identify (Packet) Device -- uses its data
+ * ATM this function never returns a failure.  It is an optional
+ * method and if it fails for whatever reason, we should still
+ * just keep going.
+ */
+int ata_acpi_push_id(struct ata_port *ap, unsigned int ix)
+{
+	acpi_handle                     handle;
+	acpi_integer                    pcidevfn;
+	int                             err;
+	struct device                   *dev = ap->host->dev;
+	struct ata_device               *atadev = &ap->device[ix];
+	u32                             dev_adr;
+	acpi_status                     status;
+	struct acpi_object_list         input;
+	union acpi_object               in_params[1];
+
+	if (noacpi)
+		return 0;
+
+	if (ata_msg_probe(ap))
+		ata_dev_printk(atadev, KERN_DEBUG,
+			"%s: ap->id: %d, ix = %d, port#: %d\n",
+			__FUNCTION__, ap->id, ix, ap->port_no);
+
+	/* Don't continue if not a SATA device. */
+	if (!(ap->cbl == ATA_CBL_SATA)) {
+		if (ata_msg_probe(ap))
+			ata_dev_printk(atadev, KERN_DEBUG,
+				"%s: Not a SATA device\n", __FUNCTION__);
+		goto out;
+	}
+
+	/* Don't continue if device has no _ADR method.
+	 * _SDD is intended for known motherboard devices. */
+	err = sata_get_dev_handle(dev, &handle, &pcidevfn);
+	if (err < 0) {
+		if (ata_msg_probe(ap))
+			ata_dev_printk(atadev, KERN_DEBUG,
+				"%s: sata_get_dev_handle failed (%d\n",
+				__FUNCTION__, err);
+		goto out;
+	}
+
+	/* Get this drive's _ADR info, if not already known */
+	if (!atadev->obj_handle) {
+		dev_adr = SATA_ADR_RSVD;
+		err = get_sata_adr(dev, handle, pcidevfn, ix, ap, atadev,
+					&dev_adr);
+		if (err < 0 || dev_adr == SATA_ADR_RSVD ||
+			!atadev->obj_handle) {
+			if (ata_msg_probe(ap))
+				ata_dev_printk(atadev, KERN_DEBUG,
+					"%s: get_sata_adr failed: "
+					"err=%d, dev_adr=%u, obj_handle=0x%p\n",
+					__FUNCTION__, err, dev_adr,
+					atadev->obj_handle);
+			goto out;
+		}
+	}
+
+	/* Give the drive Identify data to the drive via the _SDD method */
+	/* _SDD: set up input parameters */
+	input.count = 1;
+	input.pointer = in_params;
+	in_params[0].type = ACPI_TYPE_BUFFER;
+	in_params[0].buffer.length = sizeof(atadev->id[0] * ATA_ID_WORDS);
+	in_params[0].buffer.pointer = (u8 *)atadev->id;
+	/* Output buffer: _SDD has no output */
+
+	/* It's OK for _SDD to be missing too. */
+	swap_buf_le16(atadev->id, ATA_ID_WORDS);
+	status = acpi_evaluate_object(atadev->obj_handle, "_SDD", &input, NULL);
+	swap_buf_le16(atadev->id, ATA_ID_WORDS);
+
+	err = ACPI_FAILURE(status) ? -EIO : 0;
+	if (err < 0) {
+		if (ata_msg_probe(ap))
+			ata_dev_printk(atadev, KERN_DEBUG,
+				"ata%u(%u): %s _SDD error: status = 0x%x\n",
+				ap->id, ap->device->devno,
+				__FUNCTION__, status);
+	}
+
+	/* always return success */
+out:
+	return 0;
+}
+
+
drivers/ata/libata-core.c +8 -0
@@ -1556,6 +1556,14 @@ int ata_dev_configure(struct ata_device 
 	if (ap->ops->dev_config)
 		ap->ops->dev_config(ap, dev);
 
+	/* 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);
+		goto err_out_nosup;
+	}
+
 	if (ata_msg_probe(ap))
 		ata_dev_printk(dev, KERN_DEBUG, "%s: EXIT, drv_stat = 0x%x\n",
 			__FUNCTION__, ata_chk_status(ap));
drivers/ata/libata.h +5 -0
@@ -78,11 +78,16 @@ extern struct ata_probe_ent *ata_probe_e
 /* 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 */

--

#15 lore raw

Re: [patch 2/2] libata: _SDD support

This may be paranoia, but:

If I'm reading the code right (I may well not be), you seem to be evaulating _GTF before _SDD. The spec (9.9.1.1) claims that _SDD should be evaulated before _GTF - we had a couple of bug reports against an earlier version of the patch that may have been due to that, but I never had a chance to chase them down properly.

Signature · 1 line
Matthew Garrett | [email protected]
#16 lore raw

Re: [patch 2/2] libata: _SDD support

Quoted 10 lines · On Fri, 29 Sep 2006 03:13:53 +0100 Matthew Garrett <[email protected]> wrote:

This may be paranoia, but:

If I'm reading the code right (I may well not be), you seem to be evaulating _GTF before _SDD. The spec (9.9.1.1) claims that _SDD should be evaulated before _GTF - we had a couple of bug reports against an earlier version of the patch that may have been due to that, but I never had a chance to chase them down properly.

Signature · 1 line
Matthew Garrett | [email protected]

You are right, that was happening. this patch fixes the issue:

Subject: libata: change order of sdd/gtf execution

Make the sdd call come before gtf. _SDD is used to provide input to the _GTF file, so it should be executed first.

---
 drivers/ata/libata-core.c |   21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/ata/libata-core.c +10 -11
@@ -1404,6 +1404,16 @@ int ata_dev_configure(struct ata_device 
 		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,
@@ -1556,14 +1566,6 @@ int ata_dev_configure(struct ata_device 
 	if (ap->ops->dev_config)
 		ap->ops->dev_config(ap, dev);
 
-	/* 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);
-		goto err_out_nosup;
-	}
-
 	if (ata_msg_probe(ap))
 		ata_dev_printk(dev, KERN_DEBUG, "%s: EXIT, drv_stat = 0x%x\n",
 			__FUNCTION__, ata_chk_status(ap));
@@ -1609,9 +1611,6 @@ int ata_bus_probe(struct ata_port *ap)
 	/* reset and determine device classes */
 	ap->ops->phy_reset(ap);
 
-	/* retrieve and execute the ATA task file of _GTF */
-	ata_acpi_exec_tfs(ap);
-
 	for (i = 0; i < ATA_MAX_DEVICES; i++) {
 		dev = &ap->device[i];
 
#17 lore raw

PATCH 1/1 libata: change order of _SDD/_GTF execution (resend #3)

In reply to Matthew Garrett

Make the sdd call come before gtf. _SDD is used to provide input to the _GTF file, so it should be executed first.

---
 drivers/ata/libata-core.c |   21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/ata/libata-core.c +10 -11
@@ -1411,6 +1411,16 @@ int ata_dev_configure(struct ata_device 
 		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,
@@ -1568,14 +1578,6 @@ int ata_dev_configure(struct ata_device 
 	if (ap->ops->dev_config)
 		ap->ops->dev_config(ap, dev);
 
-	/* 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);
-		goto err_out_nosup;
-	}
-
 	if (ata_msg_probe(ap))
 		ata_dev_printk(dev, KERN_DEBUG, "%s: EXIT, drv_stat = 0x%x\n",
 			__FUNCTION__, ata_chk_status(ap));
@@ -1621,9 +1623,6 @@ int ata_bus_probe(struct ata_port *ap)
 	/* reset and determine device classes */
 	ap->ops->phy_reset(ap);
 
-	/* retrieve and execute the ATA task file of _GTF */
-	ata_acpi_exec_tfs(ap);
-
 	for (i = 0; i < ATA_MAX_DEVICES; i++) {
 		dev = &ap->device[i];
 
Applied
#18 lore raw

Re: [patch] libata: change order of _SDD/_GTF execution (resend #3)

Quoted 4 lines · Kristen Carlson Accardi

Make the sdd call come before gtf. _SDD is used to provide input to the _GTF file, so it should be executed first.

applied

#19 lore raw

Re: [patch 2/2] libata: _SDD support

In reply to Kristen Carlson Accardi

Hi!

drivers/ata/libata-acpi.c int ata_acpi_exec_tfs(struct ata_port *a · line 627

Quoted 10 lines

_SDD (Set Device Data) is an ACPI method that is used to tell the firmware what the identify data is of the device that is attached to the port. It is an optional method, and it's ok for it to be missing. Because of this, we always return success from the routine that calls this method, even if the execution fails.

drivers/ata/libata-acpi.c +2 -0
+	if (noacpi)
+		return 0;

That variable needs better name, too.

drivers/ata/libata-acpi.c int ata_acpi_exec_tfs(struct ata_port *a · line 635

Quoted 2 lines
drivers/ata/libata-acpi.c +2 -0
+	/* Don't continue if not a SATA device. */
+	if (!(ap->cbl == ATA_CBL_SATA)) {

Can we just use != ?

drivers/ata/libata-acpi.c int ata_acpi_exec_tfs(struct ata_port *a · line 691

Quoted 8 lines
drivers/ata/libata-acpi.c +8 -0
+	err = ACPI_FAILURE(status) ? -EIO : 0;
+	if (err < 0) {
+		if (ata_msg_probe(ap))
+			ata_dev_printk(atadev, KERN_DEBUG,
+				"ata%u(%u): %s _SDD error: status = 0x%x\n",
+				ap->id, ap->device->devno,
+				__FUNCTION__, status);
+	}

err is unused, you always return 0; can we do if (ACPI_FAILURE()) instead?

drivers/ata/libata-acpi.c int ata_acpi_exec_tfs(struct ata_port *a · line 696

Quoted 4 lines
drivers/ata/libata-acpi.c +4 -0
+	/* always return success */
+out:
+	return 0;
+}

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#20 lore raw

PATCH 2/2 libata: _SDD support

In reply to a message not in the archive

_SDD (Set Device Data) is an ACPI method that is used to tell the firmware what the identify data is of the device that is attached to the port. It is an optional method, and it's ok for it to be missing. Because of this, we always return success from the routine that calls this method, even if the execution fails.

---
 drivers/ata/libata-acpi.c |   96 ++++++++++++++++++++++++++++++++++++++++++++++
 drivers/ata/libata-core.c |    8 +++
 drivers/ata/libata.h      |    5 ++
 3 files changed, 109 insertions(+)
drivers/ata/libata-acpi.c +96 -0
@@ -600,3 +600,99 @@ int ata_acpi_exec_tfs(struct ata_port *a
 	return ret;
 }
 
+/**
+ * ata_acpi_push_id - send Identify data to drive
+ * @ap: the ata_port for the drive
+ * @ix: drive index
+ *
+ * _SDD ACPI object: for SATA mode only
+ * Must be after Identify (Packet) Device -- uses its data
+ * ATM this function never returns a failure.  It is an optional
+ * method and if it fails for whatever reason, we should still
+ * just keep going.
+ */
+int ata_acpi_push_id(struct ata_port *ap, unsigned int ix)
+{
+	acpi_handle                     handle;
+	acpi_integer                    pcidevfn;
+	int                             err;
+	struct device                   *dev = ap->host->dev;
+	struct ata_device               *atadev = &ap->device[ix];
+	u32                             dev_adr;
+	acpi_status                     status;
+	struct acpi_object_list         input;
+	union acpi_object               in_params[1];
+
+	if (noacpi)
+		return 0;
+
+	if (ata_msg_probe(ap))
+		ata_dev_printk(atadev, KERN_DEBUG,
+			"%s: ap->id: %d, ix = %d, port#: %d\n",
+			__FUNCTION__, ap->id, ix, ap->port_no);
+
+	/* Don't continue if not a SATA device. */
+	if (!(ap->cbl == ATA_CBL_SATA)) {
+		if (ata_msg_probe(ap))
+			ata_dev_printk(atadev, KERN_DEBUG,
+				"%s: Not a SATA device\n", __FUNCTION__);
+		goto out;
+	}
+
+	/* Don't continue if device has no _ADR method.
+	 * _SDD is intended for known motherboard devices. */
+	err = sata_get_dev_handle(dev, &handle, &pcidevfn);
+	if (err < 0) {
+		if (ata_msg_probe(ap))
+			ata_dev_printk(atadev, KERN_DEBUG,
+				"%s: sata_get_dev_handle failed (%d\n",
+				__FUNCTION__, err);
+		goto out;
+	}
+
+	/* Get this drive's _ADR info, if not already known */
+	if (!atadev->obj_handle) {
+		dev_adr = SATA_ADR_RSVD;
+		err = get_sata_adr(dev, handle, pcidevfn, ix, ap, atadev,
+					&dev_adr);
+		if (err < 0 || dev_adr == SATA_ADR_RSVD ||
+			!atadev->obj_handle) {
+			if (ata_msg_probe(ap))
+				ata_dev_printk(atadev, KERN_DEBUG,
+					"%s: get_sata_adr failed: "
+					"err=%d, dev_adr=%u, obj_handle=0x%p\n",
+					__FUNCTION__, err, dev_adr,
+					atadev->obj_handle);
+			goto out;
+		}
+	}
+
+	/* Give the drive Identify data to the drive via the _SDD method */
+	/* _SDD: set up input parameters */
+	input.count = 1;
+	input.pointer = in_params;
+	in_params[0].type = ACPI_TYPE_BUFFER;
+	in_params[0].buffer.length = sizeof(atadev->id[0] * ATA_ID_WORDS);
+	in_params[0].buffer.pointer = (u8 *)atadev->id;
+	/* Output buffer: _SDD has no output */
+
+	/* It's OK for _SDD to be missing too. */
+	swap_buf_le16(atadev->id, ATA_ID_WORDS);
+	status = acpi_evaluate_object(atadev->obj_handle, "_SDD", &input, NULL);
+	swap_buf_le16(atadev->id, ATA_ID_WORDS);
+
+	err = ACPI_FAILURE(status) ? -EIO : 0;
+	if (err < 0) {
+		if (ata_msg_probe(ap))
+			ata_dev_printk(atadev, KERN_DEBUG,
+				"ata%u(%u): %s _SDD error: status = 0x%x\n",
+				ap->id, ap->device->devno,
+				__FUNCTION__, status);
+	}
+
+	/* always return success */
+out:
+	return 0;
+}
+
+
drivers/ata/libata-core.c +8 -0
@@ -1556,6 +1556,14 @@ int ata_dev_configure(struct ata_device 
 	if (ap->ops->dev_config)
 		ap->ops->dev_config(ap, dev);
 
+	/* 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);
+		goto err_out_nosup;
+	}
+
 	if (ata_msg_probe(ap))
 		ata_dev_printk(dev, KERN_DEBUG, "%s: EXIT, drv_stat = 0x%x\n",
 			__FUNCTION__, ata_chk_status(ap));
drivers/ata/libata.h +5 -0
@@ -78,11 +78,16 @@ extern struct ata_probe_ent *ata_probe_e
 /* 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 */

--

#21 lore raw

Re: [patch 2/2] libata: _SDD support

Quoted 5 lines · Kristen Carlson Accardi

_SDD (Set Device Data) is an ACPI method that is used to tell the firmware what the identify data is of the device that is attached to the port. It is an optional method, and it's ok for it to be missing. Because of this, we always return success from the routine that calls this method, even if the execution fails.

I'm OK on it returning success if the _SDD is missing entirely. And I see where it's properly droppping a KERN_DEBUG-level printk if it misbehaves. Whether it should continue on and return success anyhow, I'm not sure. Can one of the ACPI wizards comment on that?