diff options
Diffstat (limited to 'drivers/ata/libata-scsi.c')
-rw-r--r-- | drivers/ata/libata-scsi.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 0009818a4306..00a9a6c8f83c 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -333,6 +333,7 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
333 | scsi_cmd[8] = args[3]; | 333 | scsi_cmd[8] = args[3]; |
334 | scsi_cmd[10] = args[4]; | 334 | scsi_cmd[10] = args[4]; |
335 | scsi_cmd[12] = args[5]; | 335 | scsi_cmd[12] = args[5]; |
336 | scsi_cmd[13] = args[6] & 0x0f; | ||
336 | scsi_cmd[14] = args[0]; | 337 | scsi_cmd[14] = args[0]; |
337 | 338 | ||
338 | /* Good values for timeout and retries? Values below | 339 | /* Good values for timeout and retries? Values below |
@@ -781,7 +782,7 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) | |||
781 | */ | 782 | */ |
782 | if (qc->err_mask || | 783 | if (qc->err_mask || |
783 | tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { | 784 | tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { |
784 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, | 785 | ata_to_sense_error(qc->ap->print_id, tf->command, tf->feature, |
785 | &sb[1], &sb[2], &sb[3], verbose); | 786 | &sb[1], &sb[2], &sb[3], verbose); |
786 | sb[1] &= 0x0f; | 787 | sb[1] &= 0x0f; |
787 | } | 788 | } |
@@ -854,7 +855,7 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc) | |||
854 | */ | 855 | */ |
855 | if (qc->err_mask || | 856 | if (qc->err_mask || |
856 | tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { | 857 | tf->command & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { |
857 | ata_to_sense_error(qc->ap->id, tf->command, tf->feature, | 858 | ata_to_sense_error(qc->ap->print_id, tf->command, tf->feature, |
858 | &sb[1], &sb[2], &sb[3], verbose); | 859 | &sb[1], &sb[2], &sb[3], verbose); |
859 | sb[1] &= 0x0f; | 860 | sb[1] &= 0x0f; |
860 | } | 861 | } |
@@ -986,29 +987,32 @@ int ata_scsi_change_queue_depth(struct scsi_device *sdev, int queue_depth) | |||
986 | struct ata_port *ap = ata_shost_to_port(sdev->host); | 987 | struct ata_port *ap = ata_shost_to_port(sdev->host); |
987 | struct ata_device *dev; | 988 | struct ata_device *dev; |
988 | unsigned long flags; | 989 | unsigned long flags; |
989 | int max_depth; | ||
990 | 990 | ||
991 | if (queue_depth < 1) | 991 | if (queue_depth < 1 || queue_depth == sdev->queue_depth) |
992 | return sdev->queue_depth; | 992 | return sdev->queue_depth; |
993 | 993 | ||
994 | dev = ata_scsi_find_dev(ap, sdev); | 994 | dev = ata_scsi_find_dev(ap, sdev); |
995 | if (!dev || !ata_dev_enabled(dev)) | 995 | if (!dev || !ata_dev_enabled(dev)) |
996 | return sdev->queue_depth; | 996 | return sdev->queue_depth; |
997 | 997 | ||
998 | max_depth = min(sdev->host->can_queue, ata_id_queue_depth(dev->id)); | 998 | /* NCQ enabled? */ |
999 | max_depth = min(ATA_MAX_QUEUE - 1, max_depth); | ||
1000 | if (queue_depth > max_depth) | ||
1001 | queue_depth = max_depth; | ||
1002 | |||
1003 | scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, queue_depth); | ||
1004 | |||
1005 | spin_lock_irqsave(ap->lock, flags); | 999 | spin_lock_irqsave(ap->lock, flags); |
1006 | if (queue_depth > 1) | 1000 | dev->flags &= ~ATA_DFLAG_NCQ_OFF; |
1007 | dev->flags &= ~ATA_DFLAG_NCQ_OFF; | 1001 | if (queue_depth == 1 || !ata_ncq_enabled(dev)) { |
1008 | else | ||
1009 | dev->flags |= ATA_DFLAG_NCQ_OFF; | 1002 | dev->flags |= ATA_DFLAG_NCQ_OFF; |
1003 | queue_depth = 1; | ||
1004 | } | ||
1010 | spin_unlock_irqrestore(ap->lock, flags); | 1005 | spin_unlock_irqrestore(ap->lock, flags); |
1011 | 1006 | ||
1007 | /* limit and apply queue depth */ | ||
1008 | queue_depth = min(queue_depth, sdev->host->can_queue); | ||
1009 | queue_depth = min(queue_depth, ata_id_queue_depth(dev->id)); | ||
1010 | queue_depth = min(queue_depth, ATA_MAX_QUEUE - 1); | ||
1011 | |||
1012 | if (sdev->queue_depth == queue_depth) | ||
1013 | return -EINVAL; | ||
1014 | |||
1015 | scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, queue_depth); | ||
1012 | return queue_depth; | 1016 | return queue_depth; |
1013 | } | 1017 | } |
1014 | 1018 | ||
@@ -1469,7 +1473,7 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) | |||
1469 | } | 1473 | } |
1470 | 1474 | ||
1471 | if (need_sense && !ap->ops->error_handler) | 1475 | if (need_sense && !ap->ops->error_handler) |
1472 | ata_dump_status(ap->id, &qc->result_tf); | 1476 | ata_dump_status(ap->print_id, &qc->result_tf); |
1473 | 1477 | ||
1474 | qc->scsidone(cmd); | 1478 | qc->scsidone(cmd); |
1475 | 1479 | ||
@@ -1495,11 +1499,9 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc) | |||
1495 | static int ata_scmd_need_defer(struct ata_device *dev, int is_io) | 1499 | static int ata_scmd_need_defer(struct ata_device *dev, int is_io) |
1496 | { | 1500 | { |
1497 | struct ata_port *ap = dev->ap; | 1501 | struct ata_port *ap = dev->ap; |
1502 | int is_ncq = is_io && ata_ncq_enabled(dev); | ||
1498 | 1503 | ||
1499 | if (!(dev->flags & ATA_DFLAG_NCQ)) | 1504 | if (is_ncq) { |
1500 | return 0; | ||
1501 | |||
1502 | if (is_io) { | ||
1503 | if (!ata_tag_valid(ap->active_tag)) | 1505 | if (!ata_tag_valid(ap->active_tag)) |
1504 | return 0; | 1506 | return 0; |
1505 | } else { | 1507 | } else { |
@@ -2774,7 +2776,7 @@ static inline void ata_scsi_dump_cdb(struct ata_port *ap, | |||
2774 | u8 *scsicmd = cmd->cmnd; | 2776 | u8 *scsicmd = cmd->cmnd; |
2775 | 2777 | ||
2776 | DPRINTK("CDB (%u:%d,%d,%d) %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", | 2778 | DPRINTK("CDB (%u:%d,%d,%d) %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", |
2777 | ap->id, | 2779 | ap->print_id, |
2778 | scsidev->channel, scsidev->id, scsidev->lun, | 2780 | scsidev->channel, scsidev->id, scsidev->lun, |
2779 | scsicmd[0], scsicmd[1], scsicmd[2], scsicmd[3], | 2781 | scsicmd[0], scsicmd[1], scsicmd[2], scsicmd[3], |
2780 | scsicmd[4], scsicmd[5], scsicmd[6], scsicmd[7], | 2782 | scsicmd[4], scsicmd[5], scsicmd[6], scsicmd[7], |
@@ -3234,7 +3236,7 @@ struct ata_port *ata_sas_port_alloc(struct ata_host *host, | |||
3234 | 3236 | ||
3235 | ata_port_init(ap, host, ent, 0); | 3237 | ata_port_init(ap, host, ent, 0); |
3236 | ap->lock = shost->host_lock; | 3238 | ap->lock = shost->host_lock; |
3237 | kfree(ent); | 3239 | devm_kfree(host->dev, ent); |
3238 | return ap; | 3240 | return ap; |
3239 | } | 3241 | } |
3240 | EXPORT_SYMBOL_GPL(ata_sas_port_alloc); | 3242 | EXPORT_SYMBOL_GPL(ata_sas_port_alloc); |