ata: libata: cleanup fua support detection
authorDamien Le Moal <damien.lemoal@opensource.wdc.com>
Fri, 14 Oct 2022 09:05:38 +0000 (18:05 +0900)
committerDamien Le Moal <damien.lemoal@opensource.wdc.com>
Fri, 13 Jan 2023 22:32:42 +0000 (07:32 +0900)
commit4d2e4980a5289ae31a1cff40d258b68573182a37
treef49cfacbcbb31d84ca3d985b9606e7c602cfe5d2
parent77839debd1772204a60b9072ef6ae83ade1fb573
ata: libata: cleanup fua support detection

Move the detection of a device FUA support from
ata_scsiop_mode_sense()/ata_dev_supports_fua() to device scan time in
ata_dev_configure().

The function ata_dev_config_fua() is introduced to detect if a device
supports FUA and this support is indicated using the new device flag
ATA_DFLAG_FUA.

In order to blacklist known buggy devices, the horkage flag
ATA_HORKAGE_NO_FUA is introduced. Similarly to other horkage flags, the
libata.force= arguments "fua" and "nofua" are also introduced to allow
a user to control this horkage flag through the "force" libata
module parameter.

The ATA_DFLAG_FUA device flag is set only and only if all the following
conditions are met:
* libata.fua module parameter is set to 1
* The device supports the WRITE DMA FUA EXT command,
* The device is not marked with the ATA_HORKAGE_NO_FUA flag, either from
  the blacklist or set by the user with libata.force=nofua
* The device supports NCQ (while this is not mandated by the standards,
  this restriction is introduced to avoid problems with older non-NCQ
  devices).

Enabling or diabling libata FUA support for all devices can now also be
done using the "force=[no]fua" module parameter when libata.fua is set
to 1.

Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com>
Documentation/admin-guide/kernel-parameters.txt
drivers/ata/libata-core.c
drivers/ata/libata-scsi.c
include/linux/libata.h