aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/libata-core.c66
-rw-r--r--drivers/ata/libata-scsi.c10
-rw-r--r--drivers/ata/libata.h19
3 files changed, 31 insertions, 64 deletions
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index bbb3cae57492..8cb0b360bfd8 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1713,8 +1713,6 @@ unsigned ata_exec_internal_sg(struct ata_device *dev,
1713 else 1713 else
1714 tag = 0; 1714 tag = 0;
1715 1715
1716 if (test_and_set_bit(tag, &ap->qc_allocated))
1717 BUG();
1718 qc = __ata_qc_from_tag(ap, tag); 1716 qc = __ata_qc_from_tag(ap, tag);
1719 1717
1720 qc->tag = tag; 1718 qc->tag = tag;
@@ -4553,37 +4551,6 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words)
4553} 4551}
4554 4552
4555/** 4553/**
4556 * ata_qc_new - Request an available ATA command, for queueing
4557 * @ap: Port associated with device @dev
4558 * @dev: Device from whom we request an available command structure
4559 *
4560 * LOCKING:
4561 * None.
4562 */
4563
4564static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap)
4565{
4566 struct ata_queued_cmd *qc = NULL;
4567 unsigned int i;
4568
4569 /* no command while frozen */
4570 if (unlikely(ap->pflags & ATA_PFLAG_FROZEN))
4571 return NULL;
4572
4573 /* the last tag is reserved for internal command. */
4574 for (i = 0; i < ATA_MAX_QUEUE - 1; i++)
4575 if (!test_and_set_bit(i, &ap->qc_allocated)) {
4576 qc = __ata_qc_from_tag(ap, i);
4577 break;
4578 }
4579
4580 if (qc)
4581 qc->tag = i;
4582
4583 return qc;
4584}
4585
4586/**
4587 * ata_qc_new_init - Request an available ATA command, and initialize it 4554 * ata_qc_new_init - Request an available ATA command, and initialize it
4588 * @dev: Device from whom we request an available command structure 4555 * @dev: Device from whom we request an available command structure
4589 * 4556 *
@@ -4591,16 +4558,20 @@ static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap)
4591 * None. 4558 * None.
4592 */ 4559 */
4593 4560
4594struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev) 4561struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev, int tag)
4595{ 4562{
4596 struct ata_port *ap = dev->link->ap; 4563 struct ata_port *ap = dev->link->ap;
4597 struct ata_queued_cmd *qc; 4564 struct ata_queued_cmd *qc;
4598 4565
4599 qc = ata_qc_new(ap); 4566 if (unlikely(ap->pflags & ATA_PFLAG_FROZEN))
4567 return NULL;
4568
4569 qc = __ata_qc_from_tag(ap, tag);
4600 if (qc) { 4570 if (qc) {
4601 qc->scsicmd = NULL; 4571 qc->scsicmd = NULL;
4602 qc->ap = ap; 4572 qc->ap = ap;
4603 qc->dev = dev; 4573 qc->dev = dev;
4574 qc->tag = tag;
4604 4575
4605 ata_qc_reinit(qc); 4576 ata_qc_reinit(qc);
4606 } 4577 }
@@ -4608,31 +4579,6 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev)
4608 return qc; 4579 return qc;
4609} 4580}
4610 4581
4611/**
4612 * ata_qc_free - free unused ata_queued_cmd
4613 * @qc: Command to complete
4614 *
4615 * Designed to free unused ata_queued_cmd object
4616 * in case something prevents using it.
4617 *
4618 * LOCKING:
4619 * spin_lock_irqsave(host lock)
4620 */
4621void ata_qc_free(struct ata_queued_cmd *qc)
4622{
4623 struct ata_port *ap = qc->ap;
4624 unsigned int tag;
4625
4626 WARN_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
4627
4628 qc->flags = 0;
4629 tag = qc->tag;
4630 if (likely(ata_tag_valid(tag))) {
4631 qc->tag = ATA_TAG_POISON;
4632 clear_bit(tag, &ap->qc_allocated);
4633 }
4634}
4635
4636void __ata_qc_complete(struct ata_queued_cmd *qc) 4582void __ata_qc_complete(struct ata_queued_cmd *qc)
4637{ 4583{
4638 struct ata_port *ap = qc->ap; 4584 struct ata_port *ap = qc->ap;
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 5d312dc9be9f..d5b9b7266c8b 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -708,7 +708,7 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev,
708{ 708{
709 struct ata_queued_cmd *qc; 709 struct ata_queued_cmd *qc;
710 710
711 qc = ata_qc_new_init(dev); 711 qc = ata_qc_new_init(dev, cmd->request->tag);
712 if (qc) { 712 if (qc) {
713 qc->scsicmd = cmd; 713 qc->scsicmd = cmd;
714 qc->scsidone = done; 714 qc->scsidone = done;
@@ -1103,7 +1103,8 @@ static int ata_scsi_dev_config(struct scsi_device *sdev,
1103 1103
1104 depth = min(sdev->host->can_queue, ata_id_queue_depth(dev->id)); 1104 depth = min(sdev->host->can_queue, ata_id_queue_depth(dev->id));
1105 depth = min(ATA_MAX_QUEUE - 1, depth); 1105 depth = min(ATA_MAX_QUEUE - 1, depth);
1106 scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, depth); 1106 scsi_set_tag_type(sdev, MSG_SIMPLE_TAG);
1107 scsi_activate_tcq(sdev, depth);
1107 } 1108 }
1108 1109
1109 return 0; 1110 return 0;
@@ -1943,6 +1944,11 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
1943 hdr[1] |= (1 << 7); 1944 hdr[1] |= (1 << 7);
1944 1945
1945 memcpy(rbuf, hdr, sizeof(hdr)); 1946 memcpy(rbuf, hdr, sizeof(hdr));
1947
1948 /* if ncq, set tags supported */
1949 if (ata_id_has_ncq(args->id))
1950 rbuf[7] |= (1 << 1);
1951
1946 memcpy(&rbuf[8], "ATA ", 8); 1952 memcpy(&rbuf[8], "ATA ", 8);
1947 ata_id_string(args->id, &rbuf[16], ATA_ID_PROD, 16); 1953 ata_id_string(args->id, &rbuf[16], ATA_ID_PROD, 16);
1948 ata_id_string(args->id, &rbuf[32], ATA_ID_FW_REV, 4); 1954 ata_id_string(args->id, &rbuf[32], ATA_ID_FW_REV, 4);
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index fe2839e58774..d3831d39bdaa 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -74,7 +74,7 @@ extern struct ata_link *ata_dev_phys_link(struct ata_device *dev);
74extern void ata_force_cbl(struct ata_port *ap); 74extern void ata_force_cbl(struct ata_port *ap);
75extern u64 ata_tf_to_lba(const struct ata_taskfile *tf); 75extern u64 ata_tf_to_lba(const struct ata_taskfile *tf);
76extern u64 ata_tf_to_lba48(const struct ata_taskfile *tf); 76extern u64 ata_tf_to_lba48(const struct ata_taskfile *tf);
77extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev); 77extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev, int tag);
78extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, 78extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev,
79 u64 block, u32 n_block, unsigned int tf_flags, 79 u64 block, u32 n_block, unsigned int tf_flags,
80 unsigned int tag); 80 unsigned int tag);
@@ -103,7 +103,6 @@ extern int ata_dev_configure(struct ata_device *dev);
103extern int sata_down_spd_limit(struct ata_link *link); 103extern int sata_down_spd_limit(struct ata_link *link);
104extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel); 104extern int ata_down_xfermask_limit(struct ata_device *dev, unsigned int sel);
105extern void ata_sg_clean(struct ata_queued_cmd *qc); 105extern void ata_sg_clean(struct ata_queued_cmd *qc);
106extern void ata_qc_free(struct ata_queued_cmd *qc);
107extern void ata_qc_issue(struct ata_queued_cmd *qc); 106extern void ata_qc_issue(struct ata_queued_cmd *qc);
108extern void __ata_qc_complete(struct ata_queued_cmd *qc); 107extern void __ata_qc_complete(struct ata_queued_cmd *qc);
109extern int atapi_check_dma(struct ata_queued_cmd *qc); 108extern int atapi_check_dma(struct ata_queued_cmd *qc);
@@ -119,6 +118,22 @@ extern struct ata_port *ata_port_alloc(struct ata_host *host);
119extern void ata_dev_enable_pm(struct ata_device *dev, enum link_pm policy); 118extern void ata_dev_enable_pm(struct ata_device *dev, enum link_pm policy);
120extern void ata_lpm_schedule(struct ata_port *ap, enum link_pm); 119extern void ata_lpm_schedule(struct ata_port *ap, enum link_pm);
121 120
121/**
122 * ata_qc_free - free unused ata_queued_cmd
123 * @qc: Command to complete
124 *
125 * Designed to free unused ata_queued_cmd object
126 * in case something prevents using it.
127 *
128 * LOCKING:
129 * spin_lock_irqsave(host lock)
130 */
131static inline void ata_qc_free(struct ata_queued_cmd *qc)
132{
133 qc->flags = 0;
134 qc->tag = ATA_TAG_POISON;
135}
136
122/* libata-acpi.c */ 137/* libata-acpi.c */
123#ifdef CONFIG_ATA_ACPI 138#ifdef CONFIG_ATA_ACPI
124extern void ata_acpi_associate_sata_port(struct ata_port *ap); 139extern void ata_acpi_associate_sata_port(struct ata_port *ap);