ata: libata: Fix FUA handling in ata_build_rw_tf()
authorDamien Le Moal <damien.lemoal@opensource.wdc.com>
Thu, 27 Oct 2022 05:08:01 +0000 (14:08 +0900)
committerDamien Le Moal <damien.lemoal@opensource.wdc.com>
Fri, 13 Jan 2023 22:32:42 +0000 (07:32 +0900)
commitbc9af49094065ca182b4606ce770bcd6178729b6
treed2644a581b4228de83cacd9f7178868f5c5ca682
parent4d2e4980a5289ae31a1cff40d258b68573182a37
ata: libata: Fix FUA handling in ata_build_rw_tf()

If a user issues a write command with the FUA bit set for a device with
NCQ support disabled (that is, the device queue depth was set to 1), the
LBA 48 command WRITE DMA FUA EXT must be used. However,
ata_build_rw_tf() ignores this and first tests if LBA 28 can be used
based on the write command sector and number of blocks. That is, for
small FUA writes at low LBAs, ata_rwcmd_protocol() will cause the write
to fail.

Fix this by preventing the use of LBA 28 for any FUA write request.

Given that the WRITE MULTI FUA EXT command is marked as obsolete in the
ATA specification since ACS-3 (published in 2013), remove the
ATA_CMD_WRITE_MULTI_FUA_EXT command from the ata_rw_cmds array.

Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
drivers/ata/libata-core.c