libata: fix bug with non-ncq devices

The recent commit 2fca5ccf97d2c28bcfce44f5b07d85e74e3cd18e ("libata:
switch to using block layer tagging support") to enable support for
block layer tagging in libata was broken for non-NCQ devices

The block layer initializes the tag field to -1 to detect invalid uses
of a tag, and if the libata devices does NOT support NCQ, we just used
that field to index the internal command list. So we need to check for
-1 first and only use the tag field if it's valid.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Reported-by: Alexander Beregalov <a.beregalov@gmail.com>
Tested-by: Paul Mundt <lethal@linux-sh.org>
Tested-by: Dave Young <hidave.darkstar@gmail.com>
Tested-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by Jens Axboe and committed by Linus Torvalds e013e13b 57f8f7b6

+5 -1
+5 -1
drivers/ata/libata-scsi.c
··· 708 { 709 struct ata_queued_cmd *qc; 710 711 - qc = ata_qc_new_init(dev, cmd->request->tag); 712 if (qc) { 713 qc->scsicmd = cmd; 714 qc->scsidone = done;
··· 708 { 709 struct ata_queued_cmd *qc; 710 711 + if (cmd->request->tag != -1) 712 + qc = ata_qc_new_init(dev, cmd->request->tag); 713 + else 714 + qc = ata_qc_new_init(dev, 0); 715 + 716 if (qc) { 717 qc->scsicmd = cmd; 718 qc->scsidone = done;