libata: _GTF support
Subsystems (2)
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 | 604 ++++++++++++++++++++++++++++++++++++ drivers/ata/libata-core.c | 7 drivers/ata/libata.h | 28 + include/linux/libata.h | 5 7 files changed, 663 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.
@@ -1013,6 +1014,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
@@ -145,6 +145,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 +604 -0
604 lines not on this page · raw message
drivers/ata/libata-core.c +7 -0
@@ -90,6 +90,10 @@ static int ata_probe_timeout = ATA_TMOUTmodule_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 +28 -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,33 @@ extern void ata_port_init(struct ata_porextern 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 do_drive_get_GTF (struct ata_port *ap,int ix, +unsigned int *gtf_length,unsigned long *gtf_address, +unsigned long *obj_loc); +extern int do_drive_set_taskfiles (struct ata_port *ap, +struct ata_device *atadev,unsigned int gtf_length, +unsigned long gtf_address); +extern int ata_acpi_exec_tfs (struct ata_port *ap); +#else +static inline int do_drive_get_GTF (struct ata_port *ap,int ix, +unsigned int *gtf_length,unsigned long *gtf_address, +unsigned long *obj_loc) +{ +return 0 ; +} +static inline int do_drive_set_taskfiles (struct ata_port *ap, +struct ata_device *atadev, +unsigned int gtf_length,unsigned long gtf_address) +{ +return 0 ; +} +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> #include <asm/libata-portmap.h>
@@ -483,6 +484,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
--
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 | 97 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/ata/libata-core.c | 8 +++ drivers/ata/libata.h | 5 ++ 3 files changed, 110 insertions(+)
drivers/ata/libata-acpi.c +97 -0
@@ -602,3 +602,100 @@ int ata_acpi_exec_tfs(struct ata_port *a }EXPORT_SYMBOL_GPL (ata_acpi_exec_tfs); +/** +* 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 (!ata_id_is_sata (atadev->id)) { +if (ata_msg_probe (ap)) +ata_dev_printk (atadev,KERN_DEBUG , +"%s: ata_id_is_sata is False\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 ; +} +EXPORT_SYMBOL_GPL (ata_acpi_push_id); + +
drivers/ata/libata-core.c +8 -0
@@ -1556,6 +1556,14 @@ int ata_dev_configure(struct ata_deviceif (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
@@ -84,6 +84,7 @@ extern int do_drive_set_taskfiles(struct struct ata_device *atadev, unsigned int gtf_length, unsigned long gtf_address);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 do_drive_get_GTF(struct ata_port *ap, int ix, unsigned int *gtf_length, unsigned long *gtf_address,
@@ -101,6 +102,10 @@ static inline int ata_acpi_exec_tfs(stru {return 0 ; } +static inline int ata_acpi_push_id (struct ata_port *ap,unsigned int ix) +{ +return 0 ; +}#endif /* libata-scsi.c */
--
Quoted 5 lines · Kristen Carlson Accardi
_GTFis 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.Signed-off-by Kristen Carlson Accardi <[email protected]>
I have minor complaints only...
Quoted 58 lines
drivers/ata/libata-acpi.c new file +4
-0+EXPORT_SYMBOL_GPL (do_drive_get_GTF); +EXPORT_SYMBOL_GPL (do_drive_set_taskfiles); +EXPORT_SYMBOL_GPL (ata_acpi_exec_tfs); +drivers/ata/libata-core.c +7
-0@@ -90,6 +90,10 @@ static int ata_probe_timeout = ATA_TMOUTmodule_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 +18
-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,33 @@ extern void ata_port_init(struct ata_porextern 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 do_drive_get_GTF (struct ata_port *ap,int ix, +unsigned int *gtf_length,unsigned long *gtf_address, +unsigned long *obj_loc); +extern int do_drive_set_taskfiles (struct ata_port *ap, +struct ata_device *atadev,unsigned int gtf_length, +unsigned long gtf_address); +extern int ata_acpi_exec_tfs (struct ata_port *ap); +#else +static inline int do_drive_get_GTF (struct ata_port *ap,int ix, +unsigned int *gtf_length,unsigned long *gtf_address, +unsigned long *obj_loc) +{ +return 0 ; +} +static inline int do_drive_set_taskfiles(struct ata_port *ap,
drivers/ata/libata.h extern void ata_port_init(struct ata_por · line 104
Quoted 10 lines
drivers/ata/libata.h +10
-0+struct ata_device *atadev, + unsigned int gtf_length, unsigned long gtf_address) +{ + return 0; +} +static inline int ata_acpi_exec_tfs (struct ata_port *ap) +{ +return 0 ; +} +#endif
1) No symbols should be exported to external kernel modules. Delete all EXPORT_SYMBOL_GPL()
2) No symbols except for ata_acpi_exec_tfs() should be exported outside of the libata-acpi.c C module. Mark everything except ata_acpi_exec_tfs() static, and remove the 'static inline' no-op functions for everything but ata_acpi_exec_tfs().
Otherwise ACK.
Jeff
Re: [patch 2/2] libata: _SDD support
In reply to Kristen Carlson Accardidrivers/ata/libata-acpi.c int ata_acpi_exec_tfs(struct ata_port *a · line 642
Quoted 7 lines · Kristen Carlson Accardi
drivers/ata/libata-acpi.c +7
-0+/* Don't continue if not a SATA device. */ +if (!ata_id_is_sata (atadev->id)) { +if (ata_msg_probe (ap)) +ata_dev_printk (atadev,KERN_DEBUG , +"%s: ata_id_is_sata is False\n" , __FUNCTION__); + goto out; + }
I forgot to note this in patch #1, so this comment applies to both patch #1 and patch #2:
ata_id_is_sata() is probably not the check you want. This tests Word 93 of IDENTIFY DEVICE output, which is a check that's not in the ATA specification, but rather something I came up with. It will indicate false for ATA devices that attach via SATA cables, but have a PATA bridge chip soldered onto the ATA device.
A better test is probably "ap->cbl == ATA_CBL_SATA".
Quoted 1 line
+EXPORT_SYMBOL_GPL(ata_acpi_push_id);
Remove the export, this is for exporting symbols to export kernel modules, not for making symbols visible at the C level, to other C modules.
Jeff
Quoted 20 lines · Kristen Carlson Accardi
_GTFis 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.Signed-off-by Kristen Carlson Accardi <[email protected]>--- Documentation/kernel-parameters.txt | 5Documentation/kernel-parameters.txt +1
-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.
Documentation/kernel-parameters.txt and is between 256 and 4096 characters. · line 1019
Quoted 6 lines
Documentation/kernel-parameters.txt +3
-0@@ -1013,6 +1014,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>
this will confuse users that already think they can disable ACPI with "noacpi" (instead of "acpi=off") and that already fight with "noapic". I have seen too many confusions of this kind in bugreports.
Couldn't it be made "libata=noacpi" like we have "pci=noacpi" already?
Signature · 3 lines
Stefan Seyfried QA / R&D Team Mobile Devices | "Any ideas, John?" SUSE LINUX Products GmbH, Nürnberg | "Well, surrounding them's out."
Quoted 32 lines · On Mon, 9 Oct 2006 13:41:50 +0200 Stefan Seyfried wrote:
Quoted 20 lines · Kristen Carlson Accardi
_GTFis 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.Signed-off-by Kristen Carlson Accardi <[email protected]>--- Documentation/kernel-parameters.txt | 5Documentation/kernel-parameters.txt +1
-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.Documentation/kernel-parameters.txt and is between 256 and 4096 characters. · line 1019
Quoted 6 lines
Documentation/kernel-parameters.txt +3
-0@@ -1013,6 +1014,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>this will confuse users that already think they can disable ACPI with "noacpi" (instead of "acpi=off") and that already fight with "noapic". I have seen too many confusions of this kind in bugreports.
Quoted 1 line
Couldn't it be made "libata=noacpi" like we have "pci=noacpi" already?
It only applies to the libata module, so it could be more fully documented as "libata.noacpi=1" to disable ACPI for libata. We don't usually do that in Documentation/kernel-parameters.txt, but there are a few cases/examples of doing so.
Of course, that's for libata built-in the kernel image. If libata is a loadable module, it's just
modprobe libata noacpi=1
or set it in /etc/modprobe.conf.
---
~Randy