History log of /linux-master/include/linux/ata.h
Revision Date Author Comments
# 18bd7718 10-May-2023 Niklas Cassel <niklas.cassel@wdc.com>

scsi: ata: libata: Handle completion of CDL commands using policy 0xD

A CDL timeout for policy 0xF is defined as a NCQ error, just with a CDL
specific sk/asc/ascq in the sense data. Therefore, the existing code in
libata does not need to be modified to handle a policy 0xF CDL timeout.

For Command Duration Limits policy 0xD:

The device shall complete the command without error with the additional
sense code set to DATA CURRENTLY UNAVAILABLE.

Since a CDL timeout for policy 0xD is not an error, we cannot use the NCQ
Command Error log (10h).

Instead, we need to read the Sense Data for Successful NCQ Commands log
(0Fh).

In the success case, just like in the error case, we cannot simply read a
log page from the interrupt handler itself, since reading a log page
involves sending a READ LOG DMA EXT or READ LOG EXT command.

Therefore, we add a new EH action ATA_EH_GET_SUCCESS_SENSE. When a command
completes without error, and when the ATA_SENSE bit is set, this new action
is set as pending, and EH is scheduled.

This way, similar to the NCQ error case, the log page will be read from EH
context.

An alternative would have been to add a new kthread or workqueue to handle
this. However, extending EH can be done with minimal changes and avoids the
need to synchronize a new kthread/workqueue with EH.

Co-developed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Link: https://lore.kernel.org/r/20230511011356.227789-20-nks@flawful.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# df60f9c6 10-May-2023 Damien Le Moal <dlemoal@kernel.org>

scsi: ata: libata: Add ATA feature control sub-page translation

Add support for the ATA feature control sub-page of the control mode page
to enable/disable the command duration limits feature using the cdl_ctrl
field of the ATA feature control sub-page.

Both mode sense and mode select translation are supported. For mode sense,
the ata device flag ATA_DFLAG_CDL_ENABLED is used to cache the status of
the command duration limits feature. Enabling this feature is done using a
SET FEATURES command with a cdl action set to 1 when the page cdl_ctrl
field value is 0x2 (T2A and T2B pages supported). If this field is 0, CDL
is disabled using the SET FEATURES command with a cdl action set to 0.

Since a device CDL and NCQ priority features should not be used
simultaneously, ata_mselect_control_ata_feature() returns an error when
attempting to enable CDL with the device priority feature enabled.
Conversely, the function ata_ncq_prio_enable_store() used to enable the use
of the device NCQ priority feature through sysfs is modified to return an
error if the device CDL feature is enabled.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Co-developed-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Link: https://lore.kernel.org/r/20230511011356.227789-18-nks@flawful.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 62e4a60e 10-May-2023 Damien Le Moal <dlemoal@kernel.org>

scsi: ata: libata: Detect support for command duration limits

Use the supported capabilities identify device data log page to detect if a
device supports the command duration limits feature. For devices supporting
this feature, set the device flag ATA_DFLAG_CDL. To support SCSI-ATA
translation, retrieve the command duration limits log page 18h and cache
this page content using the cdl array added to the ata_device data
structure.

Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Co-developed-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Link: https://lore.kernel.org/r/20230511011356.227789-15-nks@flawful.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# dc2e107e 24-Feb-2023 Sergey Shtylyov <s.shtylyov@omp.ru>

ata: drop unused ata_id_is_lba_capacity_ok()

This function was renamed from lba_capacity_is_ok()() and moved from
drivers/ide/ to <linux/ata.h> but it never got used by libata, thus it
became useless after drivers/ide/ removal...

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>


# 8d857540 24-Feb-2023 Sergey Shtylyov <s.shtylyov@omp.ru>

ata: drop unused ata_id_to_hd_driveid()

This function was renamed from ide_id_to_hd_driveid() and moved from
drivers/ide/ to <linux/ata.h> but it never got used by libata, thus it
became useless after drivers/ide/ removal...

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>


# 90c313d3 18-Oct-2022 Niklas Cassel <niklas.cassel@wdc.com>

ata: remove unused helper ata_id_flush_ext_enabled()

Not only is this function unused, but even worse, the bit it is checking
is actually used for signaling if the feature is supported, not enabled.
Therefore, remove the unused helper function ata_id_flush_ext_enabled().

ata_id_has_flush_ext() is left unmodified, since this extra supported bit
(Bit 13 of word 86) is simply a copy of the bit that ata_id_has_flush_ext()
already checks (Bit 13 of word 83), see ACS-5 r10:
7.13.6.41 Words 85..87, 120: Commands and feature sets supported or enabled

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>


# 73eb5507 18-Oct-2022 Niklas Cassel <niklas.cassel@wdc.com>

ata: remove unused helper ata_id_flush_enabled()

Not only is this function unused, but even worse, the bit it is checking
is actually used for signaling if the feature is supported, not enabled.
Therefore, remove the unused helper function ata_id_flush_enabled().

ata_id_has_flush() is left unmodified, since this extra supported bit
(Bit 12 of word 86) is simply a copy of the bit that ata_id_has_flush()
already checks (Bit 12 of word 83), see ACS-5 r10:
7.13.6.41 Words 85..87, 120: Commands and feature sets supported or enabled

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>


# 67776a9e 18-Oct-2022 Niklas Cassel <niklas.cassel@wdc.com>

ata: remove unused helper ata_id_lba48_enabled()

Not only is this function unused, but even worse, the bit it is checking
is actually used for signaling if the feature is supported, not enabled.
Therefore, remove the unused helper function ata_id_lba48_enabled().

ata_id_has_lba48() is left unmodified, since this extra supported bit
(Bit 10 of word 86) is simply a copy of the bit that ata_id_has_lba48()
already checks (Bit 10 of word 83), see ACS-5 r10:
7.13.6.41 Words 85..87, 120: Commands and feature sets supported or enabled

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>


# 630624cb 16-Sep-2022 Niklas Cassel <niklas.cassel@wdc.com>

ata: fix ata_id_has_dipm()

ACS-5 section
7.13.6.36 Word 78: Serial ATA features supported
states that:

If word 76 is not 0000h or FFFFh, word 78 reports the features supported
by the device. If this word is not supported, the word shall be cleared
to zero.

(This text also exists in really old ACS standards, e.g. ACS-3.)

The problem with ata_id_has_dipm() is that the while it performs a
check against 0 and 0xffff, it performs the check against
ATA_ID_FEATURE_SUPP (word 78), the same word where the feature bit
is stored.

Fix this by performing the check against ATA_ID_SATA_CAPABILITY
(word 76), like required by the spec. The feature bit check itself
is of course still performed against ATA_ID_FEATURE_SUPP (word 78).

Additionally, move the macro to the other ATA_ID_FEATURE_SUPP macros
(which already have this check), thus making it more likely that the
next ATA_ID_FEATURE_SUPP macro that is added will include this check.

Fixes: ca77329fb713 ("[libata] Link power management infrastructure")
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>


# a5fb6bf8 16-Sep-2022 Niklas Cassel <niklas.cassel@wdc.com>

ata: fix ata_id_has_ncq_autosense()

ACS-5 section
7.13.6.36 Word 78: Serial ATA features supported
states that:

If word 76 is not 0000h or FFFFh, word 78 reports the features supported
by the device. If this word is not supported, the word shall be cleared
to zero.

(This text also exists in really old ACS standards, e.g. ACS-3.)

Additionally, move the macro to the other ATA_ID_FEATURE_SUPP macros
(which already have this check), thus making it more likely that the
next ATA_ID_FEATURE_SUPP macro that is added will include this check.

Fixes: 5b01e4b9efa0 ("libata: Implement NCQ autosense")
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>


# 9c6e09a4 16-Sep-2022 Niklas Cassel <niklas.cassel@wdc.com>

ata: fix ata_id_has_devslp()

ACS-5 section
7.13.6.36 Word 78: Serial ATA features supported
states that:

If word 76 is not 0000h or FFFFh, word 78 reports the features supported
by the device. If this word is not supported, the word shall be cleared
to zero.

(This text also exists in really old ACS standards, e.g. ACS-3.)

Additionally, move the macro to the other ATA_ID_FEATURE_SUPP macros
(which already have this check), thus making it more likely that the
next ATA_ID_FEATURE_SUPP macro that is added will include this check.

Fixes: 65fe1f0f66a5 ("ahci: implement aggressive SATA device sleep support")
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>


# 690aa8c3 16-Sep-2022 Niklas Cassel <niklas.cassel@wdc.com>

ata: fix ata_id_sense_reporting_enabled() and ata_id_has_sense_reporting()

ACS-5 section
7.13.6.41 Words 85..87, 120: Commands and feature sets supported or enabled
states that:

If bit 15 of word 86 is set to one, bit 14 of word 119 is set to one,
and bit 15 of word 119 is cleared to zero, then word 119 is valid.

If bit 15 of word 86 is set to one, bit 14 of word 120 is set to one,
and bit 15 of word 120 is cleared to zero, then word 120 is valid.

(This text also exists in really old ACS standards, e.g. ACS-3.)

Currently, ata_id_sense_reporting_enabled() and
ata_id_has_sense_reporting() both check bit 15 of word 86,
but neither of them check that bit 14 of word 119 is set to one,
or that bit 15 of word 119 is cleared to zero.

Additionally, make ata_id_sense_reporting_enabled() return false
if !ata_id_has_sense_reporting(), similar to how e.g.
ata_id_flush_ext_enabled() returns false if !ata_id_has_flush_ext().

Fixes: e87fd28cf9a2 ("libata: Implement support for sense data reporting")
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>


# fda17afc 06-Feb-2022 Damien Le Moal <damien.lemoal@opensource.wdc.com>

ata: libata-core: Fix ata_dev_config_cpr()

The concurrent positioning ranges log page 47h is a general purpose log
page and not a subpage of the indentify device log. Using
ata_identify_page_supported() to test for concurrent positioning ranges
support is thus wrong. ata_log_supported() must be used.

Furthermore, unlike other advanced ATA features (e.g. NCQ priority),
accesses to the concurrent positioning ranges log page are not gated by
a feature bit from the device IDENTIFY data. Since many older drives
react badly to the READ LOG EXT and/or READ LOG DMA EXT commands isued
to read device log pages, avoid problems with older drives by limiting
the concurrent positioning ranges support detection to drives
implementing at least the ACS-4 ATA standard (major version 11). This
additional condition effectively turns ata_dev_config_cpr() into a nop
for older drives, avoiding problems in the field.

Fixes: fe22e1c2f705 ("libata: support concurrent positioning ranges log")
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=215519
Cc: stable@vger.kernel.org
Reviewed-by: Hannes Reinecke <hare@suse.de>
Tested-by: Abderraouf Adjal <adjal.arf@gmail.com>
Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>


# fe22e1c2 26-Oct-2021 Damien Le Moal <damien.lemoal@wdc.com>

libata: support concurrent positioning ranges log

Add support to discover if an ATA device supports the Concurrent
Positioning Ranges data log (address 0x47), indicating that the device
is capable of seeking to multiple different locations in parallel using
multiple actuators serving different LBA ranges.

Also add support to translate the concurrent positioning ranges log
into its equivalent Concurrent Positioning Ranges VPD page B9h in
libata-scsi.c.

The format of the Concurrent Positioning Ranges Log is defined in ACS-5
r9.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Link: https://lore.kernel.org/r/20211027022223.183838-4-damien.lemoal@wdc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>


# dbc557fa 09-Apr-2021 Andy Shevchenko <andriy.shevchenko@linux.intel.com>

ata: Replace inclusion of kernel.h by bits.h in the header

ata.h uses BIT() macro, hence bits.h must be included. Otherwise
there is no need to have kernel.h included, I do not see any
direct users of it in ata.h. Hence replace inclusion of kernel.h.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20210409153456.87798-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>


# c82ee6d3 19-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 18

Based on 1 normalized pattern(s):

this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 or at your option any
later version this program is distributed in the hope that it will
be useful but without any warranty without even the implied warranty
of merchantability or fitness for a particular purpose see the gnu
general public license for more details you should have received a
copy of the gnu general public license along with this program see
the file copying if not write to the free software foundation 675
mass ave cambridge ma 02139 usa

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 52 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Jilayne Lovejoy <opensource@jilayne.com>
Reviewed-by: Steve Winslow <swinslow@gmail.com>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190519154042.342335923@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# d5c15c2c 28-Dec-2017 chenxiang <chenxiang66@hisilicon.com>

scsi: ata: enhance the definition of SET MAX feature field value

There are two other values for SET MAX feature field according to ata
protocol. So definite them.

Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# e8f11db9 29-Aug-2017 Christoph Hellwig <hch@lst.de>

libata: check for trusted computing in IDENTIFY DEVICE data

ATA-8 and later mirrors the TRUSTED COMPUTING SUPPORTED bit in word 48 of
the IDENTIFY DEVICE data. Check this before issuing a READ LOG PAGE
command to avoid issues with buggy devices. The only downside is that
we can't support Security Send / Receive for a device with an older
revision due to the conflicting use of this field in earlier
specifications.

tj: The reason we need this is because some devices which don't
support READ LOG PAGE lock up after getting issued that command.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: David Ahern <dsahern@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 818831c8 04-Jun-2017 Christoph Hellwig <hch@lst.de>

libata: implement SECURITY PROTOCOL IN/OUT

This allows us to use the generic OPAL code with ATA devices.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 1d51d5f3 04-Jun-2017 Christoph Hellwig <hch@lst.de>

libata: clarify log page naming / grouping

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 9bb9a39c 16-May-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

ata: update references for libata documentation

The libata documentation is now using ReST. Update references
to it to point to the new place.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Acked-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 19285f3c 14-May-2017 Mauro Carvalho Chehab <mchehab@kernel.org>

ata: update references for libata documentation

The libata documentation is now using ReST. Update references
to it to point to the new place.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>


# 63ccc191 25-Apr-2017 Christoph Hellwig <hch@lst.de>

libata: remove SCT WRITE SAME support

This was already disabled a while ago because it caused I/O errors,
and it's severly getting into the way of the discard / write zeroes
rework.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 8e061784 17-Oct-2016 Adam Manzanares <adam.manzanares@hgst.com>

ata: Enabling ATA Command Priorities

This patch checks to see if an ATA device supports NCQ command priorities.
If so and the user has specified an iocontext that indicates
IO_PRIO_CLASS_RT then we build a tf with a high priority command.

This is done to improve the tail latency of commands that are high
priority by passing priority to the device.

tj: Removed trivial ata_ncq_prio_enabled() and open-coded the test.

Signed-off-by: Adam Manzanares <adam.manzanares@hgst.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 7b203094 21-Aug-2016 Shaun Tancheff <shaun@tancheff.com>

libata: Add support for SCT Write Same

SATA drives may support write same via SCT. This is useful
for setting the drive contents to a specific pattern (0's).

Translate a SCSI WRITE SAME 16 command to be either a DSM TRIM
command or an SCT Write Same command.

Based on the UNMAP flag:
- When set translate to DSM TRIM
- When not set translate to SCT Write Same

Signed-off-by: Shaun Tancheff <shaun.tancheff@seagate.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Acked-by: Tejun Heo <tj@kernel.org>


# 9379e6b8 21-Aug-2016 Shaun Tancheff <shaun@tancheff.com>

libata: Safely overwrite attached page in WRITE SAME xlat

Safely overwriting the attached page to ATA format from the SCSI formatted
variant.

Signed-off-by: Shaun Tancheff <shaun.tancheff@seagate.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Acked-by: Tejun Heo <tj@kernel.org>


# 37f92d77 16-Jul-2016 Christoph Hellwig <hch@lst.de>

ata: define ATA_PROT_* in terms of ATA_PROT_FLAG_*

This avoid the need to always translate between the two in ata_prot_flags
and generally cleans up the taskfile protocol usage.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 35303d5c 14-Jul-2016 Tom Yan <tom.ty89@gmail.com>

ata: make lba_{28,48}_ok() use ATA_MAX_SECTORS{,_LBA48}

Since we set ATA_MAX_SECTORS_LBA48 to 65535 to avoid the corner case
in some drives that commands with "count" set to 0000h (which
reprsents 65536) does not work as expected, lba_48_ok(), which is
used for number-of-blocks checking when libata pack commands, should
use the same limit as well. In fact, there is no reason for the two
functions not to use the macros anyway.

Signed-off-by: Tom Yan <tom.ty89@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 5b844b63 13-Jul-2016 Hannes Reinecke <hare@suse.de>

ata: Handle ATA NCQ NO-DATA commands correctly

Add a new taskfile protocol ATA_PROT_NCQ_NODATA to handle
ATA NCQ NO-DATA commands correctly.
And fixup ata_scsi_zbc_out_xlat() to use it.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 2983860c 12-Jul-2016 Tom Yan <tom.ty89@gmail.com>

libata-scsi: avoid repeated calculation of number of TRIM ranges

Currently libata statically allows only 1-block (512-byte) payload
for each TRIM command. Each payload can carry 64 TRIM ranges since
each range requires 8 bytes.

It is silly to keep doing the calculation (512 / 8) in different
places. Hence, define the new ATA_MAX_TRIM_RNUM for the result.

Signed-off-by: Tom Yan <tom.ty89@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 0c12735e 12-Jul-2016 Tom Yan <tom.ty89@gmail.com>

libata-scsi: fix SET FEATURES "filtering" for ata_msense_caching()

Without this fix, the DRA bit of the caching mode page would not
be updated when the read look-ahead feature is toggled (e.g. with
`smartctl --set`), but will only be until, for example, the write
cache feature is touched.

Signed-off-by: Tom Yan <tom.ty89@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 6d1003ae 24-Apr-2016 Hannes Reinecke <hare@suse.de>

libata: support host-aware and host-managed ZAC devices

Byte 69 bits 0:1 in the IDENTIFY DEVICE data indicate a
host-aware ZAC device.
Host-managed ZAC devices have their own individual signature,
and to not set the bits in the IDENTIFY DEVICE data.
And whenever we detect a ZAC-compatible device we should
be displaying the zoned block characteristics VPD page.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 856c4663 24-Apr-2016 Hannes Reinecke <hare@suse.de>

libata: support device-managed ZAC devices

Device-managed ZAC devices just set the zoned capabilities field
in INQUIRY byte 69 (cf ACS-4). This corresponds to the 'zoned'
field in the block device characteristics VPD page.
As this is only defined in SPC-5/SBC-4 we also need to update
the supported SCSI version descriptor.

Reviewed-by: Shaun Tancheff <shaun.tancheff@seagate.com>
Tested-by: Shaun Tancheff <shaun.tancheff@seagate.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 284b3b77 24-Apr-2016 Hannes Reinecke <hare@suse.de>

libata: NCQ encapsulation for ZAC MANAGEMENT OUT

Add NCQ encapsulation for ZAC MANAGEMENT OUT and evaluate
NCQ Non-Data log pages to figure out if NCQ encapsulation
is supported.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 27708a95 24-Apr-2016 Hannes Reinecke <hare@suse.de>

libata: Implement ZBC OUT translation

ZAC drives implement a 'ZAC Management Out' command template,
which maps onto the ZBC OUT command.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 28a3fc22 24-Apr-2016 Hannes Reinecke <hare@suse.de>

libata: implement ZBC IN translation

ZAC drives implement a 'ZAC Management In' command template,
which maps onto the ZBC IN command.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Tejun Heo <tj@kernel.org>


# a5703849 24-Apr-2016 Hannes Reinecke <hare@suse.de>

libata-trace: decode subcommands

Some commands like FPDMA RECEIVE or NCQ NON DATA can encapsulate
other commands to NCQ transport. So decode the subcmds, too.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# fe5af0cc 24-Apr-2016 Hannes Reinecke <hare@suse.de>

libata: Check log page directory before accessing pages

When reading the NCQ Send/Recv log it might actually not
supported, thereby causing irritating messages
'READ LOG DMA EXT failed'.
Instead we should be reading the log directory first to
figure out if the log is actually supported before trying
to access it.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 5c65d8bb 24-Apr-2016 Hannes Reinecke <hare@suse.de>

libata: Add command definitions for NCQ Encapsulation for READ LOG DMA EXT

ACS-4 defines an NCQ encapsulation for READ LOG DMA EXT.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 661ce1f0 24-Apr-2016 Hannes Reinecke <hare@suse.de>

libata/libsas: Define ATA_CMD_NCQ_NON_DATA

Define the NCQ NON DATA command and update libsas to handle it
correctly.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 974e0a45 03-Apr-2016 Damien Le Moal <damien.lemoal@hgst.com>

libata-core: Allow longer timeout for drive spinup from PUIS

When spinning up a drive from powered on standby mode (PUIS),
SETFEATURES_SPINUP is executed with the default timeout used
for any SETFEATURES subcommand, that is 5+10 seconds. The
total 15s is too short for some drives to complete spinup
(e.g. drives with a large indirection table stored on media),
resulting in ata_dev_read_id to fail twice on the execution
of SETFEATURES_SPINUP. For this feature, allow a larger
default timeout of 30 seconds. However, in the same spirit
as with the timeout of other feature subcommands, do not
ignore ata_probe_timeout if it is set).

Signed-off-by: Damien Le Moal <damien.lemoal@hgst.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# e87fd28c 04-Apr-2016 Hannes Reinecke <hare@suse.de>

libata: Implement support for sense data reporting

ACS-4 defines a sense data reporting feature set.
This patch implements support for it.

tj: Cosmetic formatting updates.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 5b01e4b9 04-Apr-2016 Hannes Reinecke <hare@suse.de>

libata: Implement NCQ autosense

Some newer devices support NCQ autosense (cf ACS-4), so we should
be using it to retrieve the sense code and speed up recovery.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 287e6611 11-Feb-2016 Arnd Bergmann <arnd@arndb.de>

libata: fix HDIO_GET_32BIT ioctl

As reported by Soohoon Lee, the HDIO_GET_32BIT ioctl does not
work correctly in compat mode with libata.

I have investigated the issue further and found multiple problems
that all appeared with the same commit that originally introduced
HDIO_GET_32BIT handling in libata back in linux-2.6.8 and presumably
also linux-2.4, as the code uses "copy_to_user(arg, &val, 1)" to copy
a 'long' variable containing either 0 or 1 to user space.

The problems with this are:

* On big-endian machines, this will always write a zero because it
stores the wrong byte into user space.

* In compat mode, the upper three bytes of the variable are updated
by the compat_hdio_ioctl() function, but they now contain
uninitialized stack data.

* The hdparm tool calling this ioctl uses a 'static long' variable
to store the result. This means at least the upper bytes are
initialized to zero, but calling another ioctl like HDIO_GET_MULTCOUNT
would fill them with data that remains stale when the low byte
is overwritten. Fortunately libata doesn't implement any of the
affected ioctl commands, so this would only happen when we query
both an IDE and an ATA device in the same command such as
"hdparm -N -c /dev/hda /dev/sda"

* The libata code for unknown reasons started using ATA_IOC_GET_IO32
and ATA_IOC_SET_IO32 as aliases for HDIO_GET_32BIT and HDIO_SET_32BIT,
while the ioctl commands that were added later use the normal
HDIO_* names. This is harmless but rather confusing.

This addresses all four issues by changing the code to use put_user()
on an 'unsigned long' variable in HDIO_GET_32BIT, like the IDE subsystem
does, and by clarifying the names of the ioctl commands.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reported-by: Soohoon Lee <Soohoon.Lee@f5.com>
Tested-by: Soohoon Lee <Soohoon.Lee@f5.com>
Cc: stable@vger.kernel.org
Signed-off-by: Tejun Heo <tj@kernel.org>


# 74a80d67 03-Aug-2015 Tejun Heo <tj@kernel.org>

Revert "libata: Implement NCQ autosense"

This reverts commit 42b966fbf35da9c87f08d98f9b8978edf9e717cf.

As implemented, ACS-4 sense reporting for ATA devices bypasses error
diagnosis and handling in libata degrading EH behavior significantly.
Revert the related changes for now.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Hannes Reinecke <hare@suse.de>
Cc: stable@vger.kernel.org #v4.1+


# 84ded2f8 03-Aug-2015 Tejun Heo <tj@kernel.org>

Revert "libata: Implement support for sense data reporting"

This reverts commit fe7173c206de63fc28475ee6ae42ff95c05692de.

As implemented, ACS-4 sense reporting for ATA devices bypasses error
diagnosis and handling in libata degrading EH behavior significantly.
Revert the related changes for now.

ATA_ID_COMMAND_SET_3/4 constants are not reverted as they're used by
later changes.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Hannes Reinecke <hare@suse.de>
Cc: stable@vger.kernel.org #v4.1+


# af34d637 13-Jul-2015 David Milburn <dmilburn@redhat.com>

libata: add ATA_HORKAGE_MAX_SEC_1024 to revert back to previous max_sectors limit

Since no longer limiting max_sectors to BLK_DEF_MAX_SECTORS (commit 34b48db66e08),
data corruption may occur on ST380013AS drive configured on 82801JI (ICH10 Family)
SATA controller. This patch will allow the driver to limit max_sectors as before

# cat /sys/block/sdb/queue/max_sectors_kb
512

I was able to double the max_sectors_kb value up to 16384 on linux-4.2.0-rc2
before seeing corruption, but seems safer to use previous limit. Without this
patch max_sectors_kb will be 32767.

tj: Minor comment update.

Reported-by: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: David Milburn <dmilburn@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: stable@vger.kernel.org # v3.19 and later
Fixes: 34b48db66e08 ("block: remove artifical max_hw_sectors cap")


# 406c057c 04-May-2015 Martin K. Petersen <martin.petersen@oracle.com>

libata: READ LOG DMA EXT support can be in either page 119 or 120

Support for the READ/WRITE LOG DMA EXT commands can be signaled either
in page 119 or page 120. We should check both pages.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Tejun Heo <tj@kernel.org>


# fe7173c2 27-Mar-2015 Hannes Reinecke <hare@suse.de>

libata: Implement support for sense data reporting

ACS-4 defines a sense data reporting feature set.
This patch implements support for it.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 42b966fb 27-Mar-2015 Hannes Reinecke <hare@suse.de>

libata: Implement NCQ autosense

Some newer devices support NCQ autosense (cf ACS-4), so we should
be using it to retrieve the sense code and speed up recovery.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 27f00e53 27-Mar-2015 Hannes Reinecke <hare@suse.de>

ide,ata: Rename ATA_IDX to ATA_SENSE

ATA-8 defines bit 1 as 'ATA_SENSE', not 'ATA_IDX'.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 9faa6438 27-Mar-2015 Hannes Reinecke <hare@suse.de>

libata: use READ_LOG_DMA_EXT

If READ_LOG_DMA_EXT is supported we should try to use it for
reading the log pages.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 0628ee7c 21-Dec-2014 Nicholas Krause <xerofoify@gmail.com>

libata: s/ata_id_removeable()/ata_id_removable()/

Changes the spelling typos of removeable to removable where
ata_id_removeable is defined in ata.h and called in libata-scsi.c
respectively.

Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# 3915c3b5 21-Oct-2013 Robert Hancock <hancockrwd@gmail.com>

libata: Add some missing command descriptions

Add some missing command enumerations from the ATA-8 ACS-3 spec into
include/linux/ata.h, and add the corresponding human-readable command
descriptions in libata-eh.c.

Signed-off-by: Robert Hancock <hancockrwd@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# ed36911c 25-Aug-2013 Marc Carino <marc.ceeeee@gmail.com>

libata: Add support for SEND/RECEIVE FPDMA QUEUED

Add support for the following ATA opcodes, which are present
in SATA 3.1 and T13 ATA ACS-3:

SEND FPDMA QUEUED
RECEIVE FPDMA QUEUED

Signed-off-by: Marc Carino <marc.ceeeee@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# dc34e7e1 30-Jun-2013 Sergei Shtylyov <sshtylyov@ru.mvista.com>

libata: move 'struct ata_taskfile' and friends from ata.h to libata.h

Move 'struct ata_taskfile', ata_prot_flags() and their friends from
<linux/ata.h> to <linux/libata.h>. They were misplaced from the beginning, as
<linux/ata.h> should cover ATA/ATAPI and related standards only -- to which the
aforementioned structure and function have only remote relation.

I would have moved 'enum ata_tf_protocols' closely related to 'struct
ata_taskfile' but it unfortunately gets used by 'drivers/ide/ide-ioctls.c'...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Tejun Heo <tj@kernel.org>


# d8668fcb 17-Mar-2013 Shan Hai <shan.hai@windriver.com>

libata: Use integer return value for atapi_command_packet_set

The function returns type of ATAPI drives so it should return integer value.
The commit 4dce8ba94c7 (libata: Use 'bool' return value for ata_id_XXX) since
v2.6.39 changed the type of return value from int to bool, the change would
cause all of the ATAPI class drives to be treated as TYPE_TAPE and the
max_sectors of the drives to be set to 65535 because of the commit
f8d8e5799b7(libata: increase 128 KB / cmd limit for ATAPI tape drives), for the
function would return true for all ATAPI class drives and the TYPE_TAPE is
defined as 0x01.

Cc: stable@vger.kernel.org
Signed-off-by: Shan Hai <shan.hai@windriver.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 803739d2 17-Dec-2012 Shane Huang <shane.huang@amd.com>

[libata] replace sata_settings with devslp_timing

NCQ capability was used to check availability of SATA Settings page
from Identify Device Data Log, which contains DevSlp timing variables.
It does not work on some HDDs and leads to error messages.

IDENTIFY word 78 bit 5(Hardware Feature Control) can't work either
because it is only the sufficient condition of Identify Device data
log, not the necessary condition.

This patch replaced ata_device->sata_settings with ->devslp_timing
to only save DevSlp timing variables(8 bytes), instead of the whole
SATA Settings page(512 bytes).

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=51881

Reported-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Shane Huang <shane.huang@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 8349e5ae 14-Dec-2012 Jeff Garzik <jeff@garzik.org>

Revert "libata: check SATA_SETTINGS log with HW Feature Ctrl"

This reverts commit de90cd71f68e947d3bd6c3f2ef5731ead010a768.

Shane Huang writes:

Please suspend this patch because I just received two new
DevSlp drives but found word 78 bit 5 is _not_ set.

I'm checking with the drive vendor whether he gave me
the wrong information. If bit 5 is not the necessary and
sufficient condition, I will implement another patch to
replace ata_device->sata_settings into ->devslp_timing.

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# de90cd71 17-Nov-2012 Shane Huang <shane.huang@amd.com>

libata: check SATA_SETTINGS log with HW Feature Ctrl

NCQ capability was used to check availability of SATA Settings page
from Identify Device Data Log, which contains DevSlp timing variables.
It does not work on some HDDs and leads to error messages.
IDENTIFY word 78 bit 5(Hardware Feature Control) should be used.

Quoting SATA spec 3.1:
If Hardware Feature Control is supported, then:
a) IDENTIFY DEVICE data word 78 bit 5 (see 13.2.1.18) shall be
set to one;
b) the SET FEATURES Select Hardware Feature Control subcommand
shall be supported (see 13.3.8);
c) page 08h of the Identify Device Data log (see 13.7.7) shall
be supported;

This patch is not tested on SATA HDD with DevSlp supported.

Reported-by: Borislav Petkov <bp@amd64.org>
Signed-off-by: Shane Huang <shane.huang@amd.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 65fe1f0f 07-Sep-2012 Shane Huang <shane.huang@amd.com>

ahci: implement aggressive SATA device sleep support

Device Sleep is a feature as described in AHCI 1.3.1 Technical Proposal.
This feature enables an HBA and SATA storage device to enter the DevSleep
interface state, enabling lower power SATA-based systems.

Aggressive Device Sleep enables the HBA to assert the DEVSLP signal as
soon as there are no commands outstanding to the device and the port
specific Device Sleep idle timer has expired. This enables autonomous
entry into the DevSleep interface state without waiting for software
in power sensitive systems.

This patch enables Aggressive Device Sleep only if both host controller
and device support it.

Tested on AMD reference board together with Device Sleep supported device
sample.

Signed-off-by: Shane Huang <shane.huang@amd.com>
Reviewed-by: Aaron Lu <aaron.lwe@gmail.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 583661a8 07-Sep-2012 Shane Huang <shane.huang@amd.com>

ata: define enum constants for IDENTIFY DEVICE

Define enumeration constants for IDENTIFY DEVICE words.

Signed-off-by: Shane Huang <shane.huang@amd.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# b1354cbb 25-Jun-2012 Lin Ming <ming.m.lin@intel.com>

libata: detect Device Attention support

Add a new flag ATA_DFLAG_DA to indicate that device supports "Device
Attention".

Acked-by: Aaron Lu <aaron.lu@amd.com>
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 4dce8ba9 14-Mar-2011 Hannes Reinecke <hare@suse.de>

libata: Use 'bool' return value for ata_id_XXX

Most ata_id_XXX inlines are simple tests, so we should set
the return value to 'bool' here.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>


# 6b3b9d73 07-Mar-2011 Hannes Reinecke <hare@suse.de>

libata: Include WWN ID in inquiry VPD emulation

As per SAT-3 the WWN ID should be included in the VPD page 0x83
(device identification) emulation.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>


# 295124dc 17-Aug-2010 Grant Grundler <grundler@google.com>

[libata] support for > 512 byte sectors (e.g. 4K Native)

This change enables my x86 machine to recognize and talk to a
"Native 4K" SATA device.

When I started working on this, I didn't know Matthew Wilcox had
posted a similar patch 2 years ago:
http://git.kernel.org/?p=linux/kernel/git/willy/ata.git;a=shortlog;h=refs/heads/ata-large-sectors

Gwendal Grignou pointed me at the the above code and small portions of
this patch include Matthew's work. That's why Mathew is first on the
"Signed-off-by:". I've NOT included his use of a bitmap to determine
512 vs Native for ATA command block size - just used a simple table.
And bugs are almost certainly mine.

Lastly, the patch has been tested with a native 4K 'Engineering
Sample' drive provided by Hitachi GST.

Signed-off-by: Matthew Wilcox <matthew.r.wilcox@intel.com>
Signed-off-by: Grant Grundler <grundler@google.com>
Reviewed-by: Gwendal Grignou <gwendal@google.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# f60d7011 10-May-2010 Tejun Heo <tj@kernel.org>

libata-sff: prd is BMDMA specific

struct ata_prd and ap->prd are BMDMA specific. Add bmdma_ prefix to
them and move them inside CONFIG_ATA_SFF.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 45c4d015 07-Apr-2010 Mark Lord <kernel@teksavvy.com>

libata: Fix accesses at LBA28 boundary (old bug, but nasty) (v2)

Most drives from Seagate, Hitachi, and possibly other brands,
do not allow LBA28 access to sector number 0x0fffffff (2^28 - 1).
So instead use LBA48 for such accesses.

This bug could bite a lot of systems, especially when the user has
taken care to align partitions to 4KB boundaries. On misaligned systems,
it is less likely to be encountered, since a 4KB read would end at
0x10000000 rather than at 0x0fffffff.

Signed-off-by: Mark Lord <mlord@pobox.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 4b7d1c05 22-Feb-2010 Ben Gardner <gardner.ben@gmail.com>

ata: Detect Delkin Devices compact flash

I have a Delkin Devices compact flash card that isn't being recognized using the
SATA/PATA drivers.
The card is recognized and works with the deprecated ATA drivers.

The error I am seeing is:
ata1.00: failed to IDENTIFY (device reports invalid type, err_mask=0x0)

I tracked it down to ata_id_is_cfa() in include/linux/ata.h.
The Delkin card has id[0] set to 0x844a and id[83] set to 0.
This isn't what the kernel expects and is probably incorrect.

The simplest work-around is to add a check for 0x844a to ata_id_is_cfa().

Signed-off-by: Ben Gardner <gardner.ben@gmail.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# f7acede6 28-Jan-2010 Christoph Hellwig <hch@lst.de>

libata: fix ata_id_logical_per_physical_sectors

The value we get from the low byte of the ATA_ID_SECTOR_SIZE word is not not
a plain multiple, but the log of it, so fix the helper to give the correct
answer. Without this we'll get an incorrect minimal I/O size in the block
limits VPD page for 4k sector drives.

Also change the return value of ata_id_logical_per_physical_sectors to u16
for the unlikely case of very large logical sectors.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# d0634c4a 25-Nov-2009 Martin K. Petersen <martin.petersen@oracle.com>

libata: Clarify ata_set_lba_range_entries function

ata_set_lba_range_entries used the variable max for two different things
which was confusing. Make the function take a buffer size in bytes as
argument and return the used buffer size upon completion.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# e78db4df 26-Nov-2009 Martin K. Petersen <martin.petersen@oracle.com>

libata: Report zeroed read after TRIM and max discard size

Our current TRIM payload is a single sector that can accommodate 64 *
65535 blocks being unmapped. Report this value in the Block Limits
Maximum Unmap LBA count field.

If a storage device supports TRIM and the DRAT and RZAT bits are set,
report TPRZ=1 in Read Capacity(16).

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 18f0f978 17-Nov-2009 Christoph Hellwig <hch@infradead.org>

libata: add translation for SCSI WRITE SAME (aka TRIM support)

Add support for the ATA TRIM command in libata. We translate a WRITE SAME 16
command with the unmap bit set into an ATA TRIM command and export enough
information in READ CAPACITY 16 and the block limits EVPD page so that the new
SCSI layer discard support will driver this for us.

Note that I hardcode the WRITE_SAME_16 opcode for now as the patch to introduce
the symbolic is not in 2.6.32 yet but only in the SCSI tree - as soon as it is
merged we can fix it up to properly use the symbolic name.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# fa5b561c 15-Sep-2009 Tejun Heo <tj@kernel.org>

libata: implement more acpi filtering options

Currently libata-acpi can only filter DIPM among SATA feature enables
via _GTF. This patch adds the capability to filter out FPDMA non-zero
offset, in-order guarantee and auto-activation.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# f1bce7f8 15-Sep-2009 Tejun Heo <tj@kernel.org>

libata: cosmetic updates

We're about to add more SATA_* and ATA_ACPI_FILTER_* constants.
Reformat them in preparation.

Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 6521148c 14-Jul-2009 Robert Hancock <hancockrwd@gmail.com>

libata: add command name parsing for error output

This patch improve libata's output for error/notification messages
to allow easier comprehension and debugging:

When ATAPI commands issued through the SCSI layer fail, use SCSI
functions to print the CDB in human-readable form instead of just
dumping out the CDB in hex.

Print out the name of the failed command (as defined by the ATA
specification) in error handling output along with the raw register
contents.

When reporting status of ACPI taskfile commands executed on resume,
also output the names of the commands being executed (or not) in
readable form.

Since the extra data for printing command names increases kernel
size slightly, a config option has been added to allow disabling
command name output (as well as some of the error register parsing)
for those highly sensitive to kernel text size.

Signed-off-by: Robert Hancock <hancockrwd@gmail.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 388539f3 26-Jul-2009 Shaohua Li <shaohua.li@intel.com>

[libata] add DMA setup FIS auto-activate feature

Hopefully results in fewer on-the-wire FIS's and no breakage. We'll see!

Signed-off-by: Shaohua Li <shaohua.li@intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 6dae44f9 15-Jun-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

ata: add ata_id_pio_need_iordy() helper (v2)

v2:
Minor fixes per Sergei's review.

Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>


# 4bca3286 14-May-2009 Martin K. Petersen <martin.petersen@oracle.com>

libata: Media rotation rate and form factor heuristics

This patch provides new heuristics for parsing both the form factor and
media rotation rate ATA IDENFITY words.

The reported ATA version must be 7 or greater and the device must return
values defined as valid in the standard. Only then are the
characteristics reported to SCSI via the VPD B1 page.

This seems like a reasonable compromise to me considering that we have
been shipping several kernel releases that key off the rotation rate bit
without any version checking whatsoever. With no complaints so far.

Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 0c659b82 02-Apr-2009 Matthew Wilcox <willy@infradead.org>

ata: Add TRIM infrastructure

This is common code shared between the IDE and libata implementations

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 22ddbd1e 14-Mar-2009 Erik Inge Bolsø <knan-lkml@anduin.net>

include/linux/ata.h: add some more transfer masks

Signed-off-by: Erik Inge Bolsø <knan-lkml@anduin.net>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 552d3a99 24-Mar-2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

ide: remove broken EXABYTENEST support

do_identify() marks EXABYTENEST device as non-present and frees
drive->id so enable_nest() has absolutely no chance of working.

The code was like this since at least 2.6.12-rc2 and nobody
has noticed so just remove broken EXABYTENEST support.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>


# d42ad15b 05-Mar-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com>

ata: add CFA specific identify data words

Declare CFA specific identify data words 162 and 163 for future use.

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
[bart: update patch summary/description]
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>


# 2999b58b 01-Feb-2009 Sergei Shtylyov <sshtylyov@ru.mvista.com>

ide/libata: fix ata_id_is_cfa() (take 4)

When checking for the CFA feature set support, ata_id_is_cfa() tests bit 2 in
word 82 of the identify data instead the word 83; it also checks the ATA/PI
version support in the word 80 (which the CompactFlash specifications have as
reserved), this having no slightest chance to work on the modern CF cards that
don't have 0x848A in the word 0...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# a02227c9 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

ide: lba_capacity_is_ok() -> ata_id_is_lba_capacity_ok()

Rename lba_capacity_is_ok() to ata_id_is_lba_capacity_ok()
and move it to <linux/ata.h> (remove needless parens while at it).

Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>


# 93734a23 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

ide: ide_id_to_hd_driveid() -> ata_id_to_hd_driveid()

Rename ide_id_to_hd_driveid() to ata_id_to_hd_driveid()
and move it to <linux/ata.h>.

Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>


# ff2779b5 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

ide: ide_id_has_flush_cache_ext() -> ata_id_flush_ext_enabled()

* Add ata_id_flush_ext_enabled() inline helper to <linux/ata.h>.

* ide_id_has_flush_cache_ext() -> ata_id_flush_ext_enabled()

The latter one also checks if the command is marked as
supported in word 83 and validity of words 83 & 86.

Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>


# 4b58f17d 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

ide: ide_id_has_flush_cache() -> ata_id_flush_enabled()

* Add ata_id_flush_enabled() inline helper to <linux/ata.h>.

* ide_id_has_flush_cache() -> ata_id_flush_enabled()

The latter one also checks if the command is marked as
supported in word 83 and validity of words 83 & 86.

Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>


# 942dcd85 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

ide: idedisk_supports_lba48() -> ata_id_lba48_enabled()

* Add ata_id_lba48_enabled() inline helper to <linux/ata.h>.

* idedisk_supports_lba48() -> ata_id_lba48_enabled()

The latter one also checks validity of words 83 & 86.

Cc: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>


# 367d7e78 10-Oct-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

ide: ide_dev_is_sata() -> ata_id_is_sata()

* Use optimized ATA version check from Sergei in ata_id_is_sata().

* ide_dev_is_sata() -> ata_id_is_sata()

Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>


# 8bff7c6b 24-Sep-2008 Jens Axboe <jens.axboe@oracle.com>

libata: set queue SSD flag for SSD devices

SSD devices should give an RPM setting of 1 in word 217 of the ID
page. If we see such a device, tell the block layer about it.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>


# ea6ce53c 19-Sep-2008 Elias Oltmanns <eo@nebensachen.de>

[libata] Introduce ata_id_has_unload()

Add a function to check an ATA device's id for head unload support as
specified in ATA-7.

Signed-off-by: Elias Oltmanns <eo@nebensachen.de>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 97b697a1 13-Sep-2008 Taisuke Yamada <tai@rakugaki.org>

[libata] LBA28/LBA48 off-by-one bug in ata.h

I recently bought 3 HGST P7K500-series 500GB SATA drives and
had trouble accessing the block right on the LBA28-LBA48 border.
Here's how it fails (same for all 3 drives):

# dd if=/dev/sdc bs=512 count=1 skip=268435455 > /dev/null
dd: reading `/dev/sdc': Input/output error
0+0 records in
0+0 records out
0 bytes (0 B) copied, 0.288033 seconds, 0.0 kB/s
# dmesg
ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
ata1.00: BMDMA stat 0x25
ata1.00: cmd c8/00:08:f8:ff:ff/00:00:00:00:00/ef tag 0 dma 4096 in
res 51/04:08:f8:ff:ff/00:00:00:00:00/ef Emask 0x1 (device error)
ata1.00: status: { DRDY ERR }
ata1.00: error: { ABRT }
ata1.00: configured for UDMA/33
ata1: EH complete
...

After some investigations, it turned out this seems to be caused
by misinterpretation of the ATA specification on LBA28 access.
Following part is the code in question:

=== include/linux/ata.h ===
static inline int lba_28_ok(u64 block, u32 n_block)
{
/* check the ending block number */
return ((block + n_block - 1) < ((u64)1 << 28)) && (n_block <= 256);
}

HGST drive (sometimes) fails with LBA28 access of {block = 0xfffffff,
n_block = 1}, and this behavior seems to be comformant. Other drives,
including other HGST drives are not that strict, through.

>From the ATA specification:
(http://www.t13.org/Documents/UploadedDocuments/project/d1410r3b-ATA-ATAPI-6.pdf)

8.15.29 Word (61:60): Total number of user addressable sectors
This field contains a value that is one greater than the total number
of user addressable sectors (see 6.2). The maximum value that shall
be placed in this field is 0FFFFFFFh.

So the driver shouldn't use the value of 0xfffffff for LBA28 request
as this exceeds maximum user addressable sector. The logical maximum
value for LBA28 is 0xffffffe.

The obvious fix is to cut "- 1" part, and the patch attached just do
that. I've been using the patched kernel for about a month now, and
the same fix is also floating on the net for some time. So I believe
this fix works reliably.

Just FYI, many Windows/Intel platform users also seems to be struck
by this, and HGST has issued a note pointing to Intel ICH8/9 driver.

"28-bit LBA command is being used to access LBAs 29-bits in length"
http://www.hitachigst.com/hddt/knowtree.nsf/cffe836ed7c12018862565b000530c74/b531b8bce8745fb78825740f00580e23

Also, *BSDs seems to have similar fix included sometime around ~2004,
through I have not checked out exact portion of the code.

Signed-off-by: Taisuke Yamada <tai@rakugaki.org>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# b5911620 18-Aug-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

ata: add missing ATA_* defines

Add missing ATA_* defines to <linux/ata.h>. Also add
ATAPI_{LFS,EOM,ILI,IO,CODE} defines while at it.

Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>


# 476d9894 18-Aug-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

ata: add missing ATA_CMD_* defines

Add missing ATA_CMD_* defines to <linux/ata.h>. Also add
ATA_EXABYTE_ENABLE_NEST, SETFEATURES_AAM_* and ATA_SMART_*
defines while at it.

Partially based on earlier work by Chris Wedgwood.

Acked-by: Chris Wedgwood <cw@f00f.org>
Acked-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>


# 37014c64 18-Aug-2008 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

ata: add missing ATA_ID_* defines (take 2)

Add missing ATA_ID_* defines and update {ata,atapi}_*()
inlines accordingly. The currently unused defines are
needed for the forthcoming drivers/ide/ changes.

v2:
Add ATA_ID_SPG.

Acked-by: Jeff Garzik <jgarzik@pobox.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>


# 91163006 20-Feb-2008 Tejun Heo <htejun@gmail.com>

libata: automatically use DMADIR if drive/bridge requires it

Back in 2.6.17-rc2, a libata module parameter was added for atapi_dmadir.

That's nice, but most SATA devices which need it will tell us about it
in their IDENTIFY PACKET response, as bit-15 of word-62 of the
returned data (as per ATA7, ATA8 specifications).

So for those which specify it, we should automatically use the DMADIR bit.
Otherwise, disc writing will fail by default on many SATA-ATAPI drives.

This patch adds ATA_DFLAG_DMADIR and make ata_dev_configure() set it
if atapi_dmadir is set or identify data indicates DMADIR is necessary.
atapi_xlat() is converted to check ATA_DFLAG_DMADIR before setting
DMADIR.

Original patch is from Mark Lord.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Mark Lord <mlord@pobox.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 4ca4e439 30-Dec-2007 Al Viro <viro@ZenIV.linux.org.uk>

libata annotations and fixes

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 0dc36888 18-Dec-2007 Tejun Heo <htejun@gmail.com>

libata: rename ATA_PROT_ATAPI_* to ATAPI_PROT_*

ATA_PROT_ATAPI_* are ugly and naming schemes between ATA_PROT_* and
ATA_PROT_ATAPI_* are inconsistent causing confusion. Rename them to
ATAPI_PROT_* and make them consistent with ATA counterpart.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# c88f90c3 27-Nov-2007 Tejun Heo <htejun@gmail.com>

libata: add ATA_CBL_PATA_IGN

ATA_CBL_PATA_UNK indicates that the cable type can't be determined
from the host side and might be either 80c or 40c. libata applies
drive or other generic limit in this case. However, there are
controllers where both host and drive side detections are
misimplemented and the driver has to rely solely on private method -
peeking BIOS or ACPI configuration or using some other private
mechanism.

This patch adds ATA_CBL_PATA_IGN which tells libata to ignore the
cable type completely and just let the LLD determine the transfer mode
via host transfer mode masks and ->mode_filter().

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 405e66b3 27-Nov-2007 Tejun Heo <htejun@gmail.com>

libata: implement protocol tests

Implement protocol tests - ata_is_atapi(), ata_is_nodata(),
ata_is_pio(), ata_is_dma(), ata_is_ncq() and ata_is_data() and use
them to replace is_atapi_taskfile() and hard coded protocol tests.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# ae8d4ee7 04-Nov-2007 Alan Cox <alan@lxorguk.ukuu.org.uk>

libata: Disable ATA8-ACS proposed Trusted Computing features by default

Historically word 48 in the identify data was used to mean 32bit I/O
was supported for VLB IDE etc. ATA8 reassigns this word to the Trusted
Computing Group, where it is used for TCG features. This means that
an ATA8 TCG drive is going to trigger 32bit I/O on some systems which
will be funny.

Anyway we need to sort this out ready for ATA8 so:
- Reorder the ata.h header a bit so the ata_version function occurs early
in it
- Make dword_io check the ATA version
- Add an ATA8 version checking TCG presence test

While we are at it the current drafts have a flaw where it may not be
possible to disable TCG features at boot (and opt out of the trusted
model) as TCG intends because it relies on presence of a different
optional feature (DCS). Handle this in software by refusing the TCG
commands if libata.allow_tpm is not set. (We must make it possible
as some environments such as proprietary VDR devices will doubtless
want to use it to lock up content)

Finally as with CPRM print a warning so that the user knows they may
not be able to full access and use the device.

Signed-off-by: Alan Cox <alan@redhat.com>


# 121a09e5 14-Jan-2008 Alan Cox <alan@lxorguk.ukuu.org.uk>

libata: correct handling of TSS DVD

Devices that misreport the validity bit for word 93 look like SATA. If
they are on the blacklist then we must not test for SATA but assume 40 wire
in the 40 wire case (The TSSCorp reports 80 wire on SATA it seems!)

Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Tejun Heo <htejun@gmail.com>
Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# ce2e0abb 14-Dec-2007 Tejun Heo <htejun@gmail.com>

libata: add more opcodes to ata.h

Add constants for DEVICE CONFIGURATION OVERLAY and SET_MAX to
include/linux/ata.h.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 6bbfd53d 05-Nov-2007 Alan Cox <alan@lxorguk.ukuu.org.uk>

libata: handle broken cable reporting

One or two ancient drives predated the cable spec and didn't sent the
valid bits for the field. I had hoped to leave this out of libata as a
piece of historical annoyance but a recent CD drive shows the same bug so
we have to import support for it.

Same concept as Bartlomiej's changes old IDE except that as we have
centralised blacklists we can avoid keeping another private table of stuff

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 17bd9a2f 29-Oct-2007 Geert Uytterhoeven <geert@linux-m68k.org>

libata and bogus LBA48 drives

A colleague noticed recent versions of Ubuntu no longer detect his 80 GB
ST380020ACE drive. This drive is special in that it advertises LBA48 support,
but has the lba_capacity_2 field set to zero (cfr.
http://lkml.org/lkml/2004/3/30/163).

Upon closer look, libata indeed doesn't seem to handle this case yet.
Below is an (untested) fix.

Signed-off-by: Jeff Garzik <jeff@garzik.org>


# f8d8e579 30-Oct-2007 Tony Battersby <tonyb@cybernetics.com>

libata: increase 128 KB / cmd limit for ATAPI tape drives

Commands sent to ATAPI tape drives via the SCSI generic (sg) driver are
limited in the amount of data that they can transfer by the max_sectors
value. The max_sectors value is currently calculated according to the
command set for disk drives, which doesn't apply to tape drives. The
default max_sectors value of 256 limits ATAPI tape drive commands to
128 KB. This patch against 2.6.24-rc1 increases the max_sectors value
for tape drives to 65535, which permits tape drive commands to transfer
just under 32 MB.

Tested with a SuperMicro PDSME motherboard, AHCI, and a Sony SDX-570V
SATA tape drive.

Note that some of the chipset drivers also set their own max_sectors
value, which may override the value set in libata-core. I don't have
any of these chipsets to test, so I didn't go messing with them. Also,
ATAPI devices other than tape drives may benefit from similar changes,
but I have only tape drives and disk drives to test.

Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# ca77329f 24-Oct-2007 Kristen Carlson Accardi <kristen.c.accardi@intel.com>

[libata] Link power management infrastructure

Device Initiated Power Management, which is defined
in SATA 2.5 can be enabled for disks which support it.
This patch enables DIPM when the user sets the link
power management policy to "min_power".

Additionally, libata drivers can define a function
(enable_pm) that will perform hardware specific actions to
enable whatever power management policy the user set up
for Host Initiated Power management (HIPM).
This power management policy will be activated after all
disks have been enumerated and intialized. Drivers should
also define disable_pm, which will turn off link power
management, but not change link power management policy.

Documentation/scsi/link_power_management_policy.txt has additional
information.

Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 054a5fba 25-Oct-2007 Tejun Heo <htejun@gmail.com>

libata: track SLEEP state and issue SRST to wake it up

ATA devices in SLEEP mode don't respond to any commands. SRST is
necessary to wake it up. Till now, when a command is issued to a
device in SLEEP mode, the command times out, which makes EH reset the
device and retry the command after that, causing a long delay.

This patch makes libata track SLEEP state and issue SRST automatically
if a command is about to be issued to a device in SLEEP.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Bruce Allen <ballen@gravity.phys.uwm.edu>
Cc: Andrew Paprocki <andrew@ishiboo.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 2dcb407e 19-Oct-2007 Jeff Garzik <jeff@garzik.org>

[libata] checkpatch-inspired cleanups

Tackle the relatively sane complaints of checkpatch --file.

The vast majority is indentation and whitespace changes, the rest are

* #include fixes
* printk KERN_xxx prefix addition
* BSS/initializer cleanups

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>


# 1333e194 02-Oct-2007 Robert Hancock <hancockr@shaw.ca>

libata: add human-readable error value decoding

This adds human-readable decoding of the ATA status and error registers
(similar to what drivers/ide does) as well as the SATA Serror register
to libata error handling output. This prevents the need to pore
through standards documents to figure out the meaning of the bits
in these registers when looking at error reports. Some bits that
drivers/ide decoded are not decoded here, since the bits are either
command-dependent or obsolete, and properly parsing them would add
too much complexity.

Signed-off-by: Robert Hancock <hancockr@shaw.ca>

[edited slightly to make output a bit more symmetric]
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 854c73a2 22-Sep-2007 Tejun Heo <htejun@gmail.com>

libata: misc updates for AN

Update AN support in preparation of PMP support.

* s/ata_id_has_AN/ata_id_has_atapi_AN/
* add AN enabled reporting during configuration
* add err_mask to AN configuration failure reporting
* update LOCKING comment for ata_scsi_media_change_notify()
* check whether ATA dev is attached to SCSI dev ata_scsi_media_change_notify()
* set ATA_FLAG_AN in ahci and sata_sil24

Signed-off-by: Tejun Heo <htejun@gmail.com>
Cc: Kriten Carlson Accardi <kristen.c.accardi@intel.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# c7293870 22-Aug-2007 Alan Cox <alan@lxorguk.ukuu.org.uk>

libata: Strict checking for identify reporting

The ATA specifications require checks on certain flags before assuming
the validity of other data. Go through the methods and correct those
needing extra checks. Also note limits on ata_id_major_version with
respect to ATA-1 and ATA-2. Correct the 32bit PIO check.

Wants to sit in -mm for a bit in case of a screwup on my part that I
didn't hit on the test drives and also in case someone, somewhere has
a drive that gets it wrong.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 9f45cbd3 15-Aug-2007 Kristen Carlson Accardi <kristen.c.accardi@intel.com>

[libata] check for SATA async notify support

Check to see if an ATAPI device supports Asynchronous Notification.
If so, enable it, if the host controller supports AN.

Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 0bc2a79a 31-Jul-2007 Alan Cox <alan@lxorguk.ukuu.org.uk>

libata: Correct IORDY handling

Debugging a report of a problem with an ancient solid state disk showed
up some problems in the IORDY handling

1. We check the wrong bit to see if the device has IORDY
2. Even then some ancient creaking piles of crap don't support
SETXFER at all.

The cases it fixes are obscure and the risk of side effects is slight
but possible. This also moves us slightly closer to supporting original
MFM/RLL disks with libata.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 91a6d4ed 27-Aug-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

ata: add ATA_MWDMA* and ATA_SWDMA* defines

Cc: Jeff Garzik <jeff@garzik.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 4099d143 19-Jul-2007 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

ide: add PIO masks

* Add ATA_PIO[0-6] defines to <linux/ata.h>.

* Add ->pio_mask field to ide_pci_device_t and ide_hwif_t.

* Add PIO masks to host drivers.

<linux/ata.h> change ACK-ed by Jeff Garzik <jeff@garzik.org>.

Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>


# 814600ee 01-Jul-2007 Tejun Heo <htejun@gmail.com>

libata-link: add PMP related ATA constants

Add Port Multiplier related ATA constants and macros. Some of these
will be used by ata_link implementation.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# ab2181cf 28-May-2007 Jeff Garzik <jeff@garzik.org>

[ATA] Add named constant for ATAPI command DEVICE RESET

Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 2c3d2a46 07-Jun-2007 Albert Lee <albertcc@tw.ibm.com>

libata passthru: update cached device paramters

INIT_DEV_PARAMS and SET_MULTI_MODE change the device parameters cached
by libata. Re-read IDENTIFY DEVICE info and update the cached device
paramters when seeing these commands.

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 1dce589c 07-Jun-2007 Albert Lee <albertcc@tw.ibm.com>

libata passthru: support PIO multi commands

support the pass through of PIO multi commands.

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 169439c2 17-Apr-2007 Mark Lord <liml@rtr.ca>

libata: Handle drives that require a spin-up command before first access

(S)ATA drives can be configured for "power-up in standby",
a mode whereby a specific "spin up now!" command is required
before the first media access.

Currently, a drive with this feature enabled can not be used at all
with libata, and once in this mode, the drive becomes a doorstop.

The older drivers/ide subsystem at least enumerates the drive,
so that it can be woken up after the fact from a userspace HDIO_*
command, but not libata.

This patch adds support to libata for the "power-up in standby"
mode where a "spin up now!" command (SET_FEATURES) is needed.
With this, libata will recognize such drives, spin them up,
and then re-IDENTIFY them if necessary to get a full/complete
set of drive features data.

Drives in this state are determined by looking for
special values in id[2], as documented in the current ATA specs.

Signed-off-by: Mark Lord <mlord@pobox.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 1e999736 10-Apr-2007 Alan Cox <alan@lxorguk.ukuu.org.uk>

libata: HPA support

Signed-off-by: Alan Cox <alan@redhat.com>

Add support for ignoring the BIOS HPA result (off by default) and setting
the disk to the full available size unless already frozen.

Tested with various platforms/disks and confirmed to work with the
Macintosh (which broke earlier) and ata_piix (breakage due to the LBA48
readback that Tejun fixed).

For normal users this brings us, I believe, to feature parity with old IDE
(and of course more featured in some areas too).
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 5a5dbd18 16-Mar-2007 Mark Lord <liml@rtr.ca>

libata: add support for READ/WRITE LONG

The READ/WRITE LONG commands are theoretically obsolete,
but the majority of drives in existance still implement them.

The WRITE_LONG and WRITE_LONG_ONCE commands are of particular
interest for fault injection testing -- eg. creating "media errors"
at specific locations on a disk.

The fussy bit is that these commands require a non-standard
sector size, usually 520 bytes instead of 512.

This patch adds support to libata for READ/WRITE LONG commands
issued via SG_IO/ATA_16.

Signed-off-by: Mark Lord <mlord@pobox.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 18d6e9d5 01-Apr-2007 Albert Lee <albertcc@tw.ibm.com>

libata: Limit max sector to 128 for TORiSAN DVD drives (take 3)

patch 3/4:
The TORiSAN drive locks up when max sector == 256.
Limit max sector to 128 for the TORiSAN DRD-N216 drives.
(http://bugzilla.kernel.org/show_bug.cgi?id=6710)

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 32d90911 21-Feb-2007 Tejun Heo <htejun@gmail.com>

libata: test major version in ata_id_is_sata()

Test major version in ata_id_is_sata() not separately.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 61f216c7 05-Feb-2007 Tejun Heo <htejun@gmail.com>

libata: fix drive side 80c cable check, take 3

The 80c wire bit is bit 13, not 14. Bit 14 is always 1 if word93 is
implemented. This increases the chance of incorrect wire detection
especially because host side cable detection is often unreliable and
we sometimes soley depend on drive side cable detection. Fix the test
and add word93 validity check.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 49554c19 05-Feb-2007 Alan Cox <alan@lxorguk.ukuu.org.uk>

ata: Add defines for the iordy bits

IORDY and IORDY enable/disable flags.

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# a0cf733b 02-Jan-2007 Tejun Heo <htejun@gmail.com>

libata: straighten out ATA_ID_* constants

* Kill _OFS suffixes in ATA_ID_{SERNO|FW_REV|PROD}_OFS for consistency
with other ATA_ID_* constants.

* Kill ATA_SERNO_LEN

* Add and use ATA_ID_SERNO_LEN, ATA_ID_FW_REV_LEN and ATA_ID_PROD_LEN.
This change also makes ata_device_blacklisted() use proper length
for fwrev.

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# fc085150 10-Oct-2006 Alan Cox <alan@lxorguk.ukuu.org.uk>

[PATCH] libata: add 40pin "short" cable support, honour drive side speed detection

[deweerdt@free.fr: build fix]
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Frederik Deweerdt <deweerdt@free.fr>
Cc: Tejun Heo <htejun@gmail.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 9bec2e38 30-Aug-2006 Jeff Garzik <jeff@garzik.org>

[libata] Trim trailing whitespace.


# b352e57d 10-Aug-2006 Alan Cox <alan@lxorguk.ukuu.org.uk>

[PATCH] libata: Add CompactFlash support

The CFA world has some additional rules and drive modes we need to support for
newer expansion cards and on embedded boxes

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 8b881b04 11-Jun-2006 Jeff Garzik <jeff@garzik.org>

[ATA] Increase lba48 max-sectors from 200 to 256.

Also, moved ATA_MAX_SECTORS and ATA_MAX_SECTORS_LBA48 from
linux/libata.h to linux/ata.h, now that they truly reflect the standard
(well... mostly; note TODO comment).

This changes the performance profile (and potential bug profile)
for a bunch of drivers, so be wary.


# 3057ac3c 11-Jun-2006 zhao, forrest <forrest.zhao@intel.com>

[PATCH] Snoop SET FEATURES - WRITE CACHE ENABLE/DISABLE command(v5)

This patch makes libata snoop 'SET FEATURES - WRITE CACHE
ENABLE/DISABLE' command, executing requisite revalidation processes
to update cached data.

Signed-off-by: Forrest Zhao <forrest.zhao@intel.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 88e49034 15-May-2006 Tejun Heo <htejun@gmail.com>

[PATCH] libata-ncq: add NCQ related ATA/libata constants and macros

Add NCQ related ATA/libata constants and macros.

Signed-off-by: Tejun Heo <htejun@gmail.com>


# 9be1e979 15-May-2006 Tejun Heo <htejun@gmail.com>

[PATCH] libata-eh: add ATA and libata flags for new EH

Add ATA and libata flags to be used by new EH.

Signed-off-by: Tejun Heo <htejun@gmail.com>


# b6782728 21-Mar-2006 Alan Cox <alan@lxorguk.ukuu.org.uk>

[PATCH] libata: Add the useful macros/constants needed for merging PATA stuff

HPA presence/enabled
HPA commands

Also add ata_id_is_cfa() as that is needed to detect and handle CF cards
which currently we reject.

Signed-off-by: Jeff Garzik <jeff@garzik.org>


# f59b0cf8 16-Mar-2006 Albert Lee <albertcc@tw.ibm.com>

[PATCH] libata-dev: Remove ATA_PROT_PIO_MULT

Remove the ATA_PROT_PIO_MULT protocol.

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# c2956a3b 02-Mar-2006 Albert Lee <albertcc@tw.ibm.com>

[PATCH] libata-dev: recognize WRITE_MULTI_FUA_EXT for r/w multiple

Recognize ATA_CMD_WRITE_MULTI_FUA_EXT as r/w multiple commands.

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>


# 3d2ca910 12-Feb-2006 Tejun Heo <htejun@gmail.com>

[PATCH] libata: separate out ata_id_major_version()

Separate out ATA major version calculation from ata_dev_identify()
into ata_id_major_version(). It's preparation for splitting
ata_dev_identify().

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>


# 9b847548 06-Jan-2006 Jens Axboe <axboe@suse.de>

[PATCH] Suspend support for libata

This patch adds suspend patch to libata, and ata_piix in particular. For
most low level drivers, they should just need to add the 4 hooks to
work. As I can only test ata_piix, I didn't enable it for more
though.

Suspend support is the single most important feature on a notebook, and
most new notebooks have sata drives. It's quite embarrassing that we
_still_ do not support this. Right now, it's perfectly possible to
suspend the drive in mid-transfer.

Signed-off-by: Jens Axboe <axboe@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 9a3dccc4 06-Jan-2006 Tejun Heo <htejun@gmail.com>

[BLOCK] add FUA support to libata

Signed-off-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: Jens Axboe <axboe@suse.de>


# 07f6f7d0 01-Nov-2005 Albert Lee <albertcc@tw.ibm.com>

[PATCH] libata irq-pio: add read/write multiple support

- add is_multi_taskfile() to ata.h
- initialize ata_device->multi_count with device identify data
- use ata_pio_sectors() to support r/w multiple commands

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>

========
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>


# 057ace5e 22-Oct-2005 Jeff Garzik <jgarzik@pobox.com>

libata: const-ification bombing run

Enforce access rules where appropriate.

If the compiler is smart enough, this may buy us an optimization or two
as a side effect.


# 11e29e21 21-Oct-2005 Alan Cox <alan@lxorguk.ukuu.org.uk>

libata: handle early device PIO modes correctly


# c6a33e24 12-Oct-2005 Albert Lee <albertcc@tw.ibm.com>

[PATCH] libata CHS: LBA28/LBA48 optimization (revise #6)

- add lba_28_ok() and lba_48_ok() to ata.h.
- check ending block number instead of staring block number.
- use lba_28_ok() for CHS range check
- LBA28/LBA48 optimization

Suggested by Mark Lord and Alan Cox.

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>

=====
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>


# 8cbd6df1 12-Oct-2005 Albert Lee <albertcc@tw.ibm.com>

[PATCH] libata CHS: calculate read/write commands and protocol on the fly (revise #6)

- merge ata_prot_to_cmd() and ata_dev_set_protocol() as
ata_rwcmd_protocol()
- pave road for read/write multiple support
- remove usage of pre-cached command and protocol values and call
ata_rwcmd_protocol() instead

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>

==============
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>


# b4b52db7 25-Sep-2005 Alan Cox <alan@lxorguk.ukuu.org.uk>

[PATCH] ata: re-order speeds sensibly.

Signed-off-by: Jeff Garzik <jgarzik@pobox.com>


# 312f7da2 27-Sep-2005 Albert Lee <albertcc@tw.ibm.com>

[PATCH] libata: interrupt driven pio for libata-core

- add PIO_ST_FIRST for the state before sending ATAPI CDB or sending
"ATA PIO data out" first data block.
- add ATA_TFLAG_POLLING and ATA_DFLAG_CDB_INTR flags
- remove the ATA_FLAG_NOINTR flag since the interrupt handler is now
aware of the states
- modify ata_pio_sector() and atapi_pio_bytes() to work in the interrupt
context
- modify the ata_host_intr() to handle PIO interrupts
- modify ata_qc_issue_prot() to initialize states
- atapi_packet_task() changed to handle "ATA PIO data out" first data block
- support the pre-ATA4 ATAPI device which raise interrupt when ready to
receive CDB

Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>


# af36d7f0 28-Aug-2005 Jeff Garzik <jgarzik@pobox.com>

[libata] license change, other bits

- changes license of all code from OSL+GPL to plain ole GPL
- except for NVIDIA, who hasn't yet responded about sata_nv
- copyright holders were already contacted privately

- adds info in each driver about where hardware/protocol docs may be
obtained

- where I have made major contributions, updated copyright dates


# 972dcafb 11-Aug-2005 Douglas Gilbert <dougg@torque.net>

[libata scsi] add START STOP UNIT translation


# 8bf62ece 12-May-2005 Albert Lee <albertcc@tw.ibm.com>

[libata] C/H/S support, for older devices


# 6f2f3812 12-May-2005 Brad Campbell <brad@wasp.net.au>

[PATCH] libata basic detection and errata for PATA->SATA bridges

This patch works around an issue with WD drives (and possibly others)
over SiL PATA->SATA Bridges on SATA controllers locking up with
transfers > 200 sectors.

Signed-off-by: Brad Campbell <brad@wasp.net.au>


# 1da177e4 16-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org>

Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!