aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/libata-scsi.c
diff options
context:
space:
mode:
authorTejun Heo <htejun@gmail.com>2007-08-06 05:36:22 -0400
committerJeff Garzik <jeff@garzik.org>2007-10-12 14:55:30 -0400
commit9af5c9c97dc9d599281778864c72b385f0c63341 (patch)
tree8359986bd42c4a9a5b1993078aa9ee4c7971ac3d /drivers/ata/libata-scsi.c
parent640fdb504941fa2b9f6f274716fc9f97f2bf6bff (diff)
libata-link: introduce ata_link
Introduce ata_link. It abstracts PHY and sits between ata_port and ata_device. This new level of abstraction is necessary to support SATA Port Multiplier, which basically adds a bunch of links (PHYs) to a ATA host port. Fields related to command execution, spd_limit and EH are per-link and thus moved to ata_link. This patch only defines the host link. Multiple link handling will be added later. Also, a lot of ap->link derefences are added but many of them will be removed as each part is converted to deal directly with ata_link instead of ata_port. This patch introduces no behavior change. Signed-off-by: Tejun Heo <htejun@gmail.com> Cc: James Bottomley <James.Bottomley@SteelEye.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/libata-scsi.c')
-rw-r--r--drivers/ata/libata-scsi.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index e83647651b31..ec0e2638200e 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1368,14 +1368,14 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1368 case ATA_CMD_SET_FEATURES: 1368 case ATA_CMD_SET_FEATURES:
1369 if ((qc->tf.feature == SETFEATURES_WC_ON) || 1369 if ((qc->tf.feature == SETFEATURES_WC_ON) ||
1370 (qc->tf.feature == SETFEATURES_WC_OFF)) { 1370 (qc->tf.feature == SETFEATURES_WC_OFF)) {
1371 ap->eh_info.action |= ATA_EH_REVALIDATE; 1371 ap->link.eh_info.action |= ATA_EH_REVALIDATE;
1372 ata_port_schedule_eh(ap); 1372 ata_port_schedule_eh(ap);
1373 } 1373 }
1374 break; 1374 break;
1375 1375
1376 case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */ 1376 case ATA_CMD_INIT_DEV_PARAMS: /* CHS translation changed */
1377 case ATA_CMD_SET_MULTI: /* multi_count changed */ 1377 case ATA_CMD_SET_MULTI: /* multi_count changed */
1378 ap->eh_info.action |= ATA_EH_REVALIDATE; 1378 ap->link.eh_info.action |= ATA_EH_REVALIDATE;
1379 ata_port_schedule_eh(ap); 1379 ata_port_schedule_eh(ap);
1380 break; 1380 break;
1381 } 1381 }
@@ -1439,14 +1439,14 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1439 */ 1439 */
1440static int ata_scmd_need_defer(struct ata_device *dev, int is_io) 1440static int ata_scmd_need_defer(struct ata_device *dev, int is_io)
1441{ 1441{
1442 struct ata_port *ap = dev->ap; 1442 struct ata_link *link = dev->link;
1443 int is_ncq = is_io && ata_ncq_enabled(dev); 1443 int is_ncq = is_io && ata_ncq_enabled(dev);
1444 1444
1445 if (is_ncq) { 1445 if (is_ncq) {
1446 if (!ata_tag_valid(ap->active_tag)) 1446 if (!ata_tag_valid(link->active_tag))
1447 return 0; 1447 return 0;
1448 } else { 1448 } else {
1449 if (!ata_tag_valid(ap->active_tag) && !ap->sactive) 1449 if (!ata_tag_valid(link->active_tag) && !link->sactive)
1450 return 0; 1450 return 0;
1451 } 1451 }
1452 return 1; 1452 return 1;
@@ -2426,7 +2426,7 @@ static unsigned int atapi_xlat(struct ata_queued_cmd *qc)
2426static struct ata_device * ata_find_dev(struct ata_port *ap, int id) 2426static struct ata_device * ata_find_dev(struct ata_port *ap, int id)
2427{ 2427{
2428 if (likely(id < ATA_MAX_DEVICES)) 2428 if (likely(id < ATA_MAX_DEVICES))
2429 return &ap->device[id]; 2429 return &ap->link.device[id];
2430 return NULL; 2430 return NULL;
2431} 2431}
2432 2432
@@ -2458,7 +2458,7 @@ static int ata_scsi_dev_enabled(struct ata_device *dev)
2458 if (unlikely(!ata_dev_enabled(dev))) 2458 if (unlikely(!ata_dev_enabled(dev)))
2459 return 0; 2459 return 0;
2460 2460
2461 if (!atapi_enabled || (dev->ap->flags & ATA_FLAG_NO_ATAPI)) { 2461 if (!atapi_enabled || (dev->link->ap->flags & ATA_FLAG_NO_ATAPI)) {
2462 if (unlikely(dev->class == ATA_DEV_ATAPI)) { 2462 if (unlikely(dev->class == ATA_DEV_ATAPI)) {
2463 ata_dev_printk(dev, KERN_WARNING, 2463 ata_dev_printk(dev, KERN_WARNING,
2464 "WARNING: ATAPI is %s, device ignored.\n", 2464 "WARNING: ATAPI is %s, device ignored.\n",
@@ -2961,7 +2961,7 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync)
2961 for (i = 0; i < ATA_MAX_DEVICES; i++) { 2961 for (i = 0; i < ATA_MAX_DEVICES; i++) {
2962 struct scsi_device *sdev; 2962 struct scsi_device *sdev;
2963 2963
2964 dev = &ap->device[i]; 2964 dev = &ap->link.device[i];
2965 2965
2966 if (!ata_dev_enabled(dev) || dev->sdev) 2966 if (!ata_dev_enabled(dev) || dev->sdev)
2967 continue; 2967 continue;
@@ -2978,7 +2978,7 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync)
2978 * whether all devices are attached. 2978 * whether all devices are attached.
2979 */ 2979 */
2980 for (i = 0; i < ATA_MAX_DEVICES; i++) { 2980 for (i = 0; i < ATA_MAX_DEVICES; i++) {
2981 dev = &ap->device[i]; 2981 dev = &ap->link.device[i];
2982 if (ata_dev_enabled(dev) && !dev->sdev) 2982 if (ata_dev_enabled(dev) && !dev->sdev)
2983 break; 2983 break;
2984 } 2984 }
@@ -3049,7 +3049,7 @@ int ata_scsi_offline_dev(struct ata_device *dev)
3049 */ 3049 */
3050static void ata_scsi_remove_dev(struct ata_device *dev) 3050static void ata_scsi_remove_dev(struct ata_device *dev)
3051{ 3051{
3052 struct ata_port *ap = dev->ap; 3052 struct ata_port *ap = dev->link->ap;
3053 struct scsi_device *sdev; 3053 struct scsi_device *sdev;
3054 unsigned long flags; 3054 unsigned long flags;
3055 3055
@@ -3123,7 +3123,7 @@ void ata_scsi_hotplug(struct work_struct *work)
3123 3123
3124 /* unplug detached devices */ 3124 /* unplug detached devices */
3125 for (i = 0; i < ATA_MAX_DEVICES; i++) { 3125 for (i = 0; i < ATA_MAX_DEVICES; i++) {
3126 struct ata_device *dev = &ap->device[i]; 3126 struct ata_device *dev = &ap->link.device[i];
3127 unsigned long flags; 3127 unsigned long flags;
3128 3128
3129 if (!(dev->flags & ATA_DFLAG_DETACHED)) 3129 if (!(dev->flags & ATA_DFLAG_DETACHED))
@@ -3162,6 +3162,7 @@ static int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
3162 unsigned int id, unsigned int lun) 3162 unsigned int id, unsigned int lun)
3163{ 3163{
3164 struct ata_port *ap = ata_shost_to_port(shost); 3164 struct ata_port *ap = ata_shost_to_port(shost);
3165 struct ata_eh_info *ehi = &ap->link.eh_info;
3165 unsigned long flags; 3166 unsigned long flags;
3166 int rc = 0; 3167 int rc = 0;
3167 3168
@@ -3175,15 +3176,15 @@ static int ata_scsi_user_scan(struct Scsi_Host *shost, unsigned int channel,
3175 spin_lock_irqsave(ap->lock, flags); 3176 spin_lock_irqsave(ap->lock, flags);
3176 3177
3177 if (id == SCAN_WILD_CARD) { 3178 if (id == SCAN_WILD_CARD) {
3178 ap->eh_info.probe_mask |= (1 << ATA_MAX_DEVICES) - 1; 3179 ehi->probe_mask |= (1 << ATA_MAX_DEVICES) - 1;
3179 ap->eh_info.action |= ATA_EH_SOFTRESET; 3180 ehi->action |= ATA_EH_SOFTRESET;
3180 } else { 3181 } else {
3181 struct ata_device *dev = ata_find_dev(ap, id); 3182 struct ata_device *dev = ata_find_dev(ap, id);
3182 3183
3183 if (dev) { 3184 if (dev) {
3184 ap->eh_info.probe_mask |= 1 << dev->devno; 3185 ehi->probe_mask |= 1 << dev->devno;
3185 ap->eh_info.action |= ATA_EH_SOFTRESET; 3186 ehi->action |= ATA_EH_SOFTRESET;
3186 ap->eh_info.flags |= ATA_EHI_RESUME_LINK; 3187 ehi->flags |= ATA_EHI_RESUME_LINK;
3187 } else 3188 } else
3188 rc = -EINVAL; 3189 rc = -EINVAL;
3189 } 3190 }
@@ -3220,7 +3221,7 @@ void ata_scsi_dev_rescan(struct work_struct *work)
3220 spin_lock_irqsave(ap->lock, flags); 3221 spin_lock_irqsave(ap->lock, flags);
3221 3222
3222 for (i = 0; i < ATA_MAX_DEVICES; i++) { 3223 for (i = 0; i < ATA_MAX_DEVICES; i++) {
3223 struct ata_device *dev = &ap->device[i]; 3224 struct ata_device *dev = &ap->link.device[i];
3224 struct scsi_device *sdev = dev->sdev; 3225 struct scsi_device *sdev = dev->sdev;
3225 3226
3226 if (!ata_dev_enabled(dev) || !sdev) 3227 if (!ata_dev_enabled(dev) || !sdev)
@@ -3359,7 +3360,7 @@ EXPORT_SYMBOL_GPL(ata_sas_port_destroy);
3359int ata_sas_slave_configure(struct scsi_device *sdev, struct ata_port *ap) 3360int ata_sas_slave_configure(struct scsi_device *sdev, struct ata_port *ap)
3360{ 3361{
3361 ata_scsi_sdev_config(sdev); 3362 ata_scsi_sdev_config(sdev);
3362 ata_scsi_dev_config(sdev, ap->device); 3363 ata_scsi_dev_config(sdev, ap->link.device);
3363 return 0; 3364 return 0;
3364} 3365}
3365EXPORT_SYMBOL_GPL(ata_sas_slave_configure); 3366EXPORT_SYMBOL_GPL(ata_sas_slave_configure);
@@ -3382,8 +3383,8 @@ int ata_sas_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
3382 3383
3383 ata_scsi_dump_cdb(ap, cmd); 3384 ata_scsi_dump_cdb(ap, cmd);
3384 3385
3385 if (likely(ata_scsi_dev_enabled(ap->device))) 3386 if (likely(ata_scsi_dev_enabled(ap->link.device)))
3386 rc = __ata_scsi_queuecmd(cmd, done, ap->device); 3387 rc = __ata_scsi_queuecmd(cmd, done, ap->link.device);
3387 else { 3388 else {
3388 cmd->result = (DID_BAD_TARGET << 16); 3389 cmd->result = (DID_BAD_TARGET << 16);
3389 done(cmd); 3390 done(cmd);