]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ata: set ncq_prio_enabled iff device has support
authorAdam Manzanares <adam.manzanares@hgst.com>
Thu, 20 Oct 2016 03:40:19 +0000 (20:40 -0700)
committerTejun Heo <tj@kernel.org>
Thu, 20 Oct 2016 14:06:30 +0000 (10:06 -0400)
We previously had a check to see if the device has support for
prioritized ncq commands and a check to see if a device flag
is set, through a sysfs variable, in order to send a prioritized
command.

This patch only allows the sysfs variable to be set if the device
supports prioritized commands enabling one check in ata_build_rw_tf
in order to determine whether or not to send a prioritized command.

This patch depends on ata: ATA Command Priority Disabled By Default

tj: Minor subject and formatting updates.

Signed-off-by: Adam Manzanares <adam.manzanares@wdc.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
drivers/ata/libata-core.c
drivers/ata/libata-scsi.c

index b294339159a44cbc28247da57d167fcc7a46aa27..43842fdcdc8764d6b5ef8f3c06d172f4485b0193 100644 (file)
@@ -787,8 +787,7 @@ int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
                if (tf->flags & ATA_TFLAG_FUA)
                        tf->device |= 1 << 7;
 
-               if ((dev->flags & ATA_DFLAG_NCQ_PRIO) &&
-                   (dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLE)) {
+               if (dev->flags & ATA_DFLAG_NCQ_PRIO_ENABLE) {
                        if (class == IOPRIO_CLASS_RT)
                                tf->hob_nsect |= ATA_PRIO_HIGH <<
                                                 ATA_SHIFT_PRIO;
index 87597a3f614981da2fefad9306bf5ffb11ad14bc..49c09d876358f788233556ef1c001a8ba2f50d0e 100644 (file)
@@ -323,10 +323,16 @@ static ssize_t ata_ncq_prio_enable_store(struct device *device,
                goto unlock;
        }
 
-       if (input)
+       if (input) {
+               if (!(dev->flags & ATA_DFLAG_NCQ_PRIO)) {
+                       rc = -EOPNOTSUPP;
+                       goto unlock;
+               }
+
                dev->flags |= ATA_DFLAG_NCQ_PRIO_ENABLE;
-       else
+       } else {
                dev->flags &= ~ATA_DFLAG_NCQ_PRIO_ENABLE;
+       }
 
 unlock:
        spin_unlock_irqrestore(ap->lock, flags);