aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/libata-core.c499
-rw-r--r--drivers/scsi/pdc_adma.c8
-rw-r--r--drivers/scsi/sata_mv.c7
-rw-r--r--drivers/scsi/sata_nv.c4
-rw-r--r--drivers/scsi/sata_promise.c7
-rw-r--r--drivers/scsi/sata_qstor.c11
-rw-r--r--drivers/scsi/sata_sx4.c6
-rw-r--r--drivers/scsi/sata_vsc.c7
8 files changed, 452 insertions, 97 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 5a0b67a602df..5060a1a1ad25 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -65,6 +65,7 @@ static unsigned int ata_dev_init_params(struct ata_port *ap,
65 struct ata_device *dev); 65 struct ata_device *dev);
66static void ata_set_mode(struct ata_port *ap); 66static void ata_set_mode(struct ata_port *ap);
67static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev); 67static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev);
68static void ata_pio_error(struct ata_port *ap);
68static unsigned int ata_dev_xfermask(struct ata_port *ap, 69static unsigned int ata_dev_xfermask(struct ata_port *ap,
69 struct ata_device *dev); 70 struct ata_device *dev);
70 71
@@ -1275,7 +1276,12 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev,
1275 dev->cylinders, dev->heads, dev->sectors); 1276 dev->cylinders, dev->heads, dev->sectors);
1276 } 1277 }
1277 1278
1278 dev->cdb_len = 16; 1279 if (dev->id[59] & 0x100) {
1280 dev->multi_count = dev->id[59] & 0xff;
1281 DPRINTK("ata%u: dev %u multi count %u\n",
1282 ap->id, device, dev->multi_count);
1283 }
1284
1279 } 1285 }
1280 1286
1281 /* ATAPI-specific feature tests */ 1287 /* ATAPI-specific feature tests */
@@ -1288,6 +1294,9 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev,
1288 } 1294 }
1289 dev->cdb_len = (unsigned int) rc; 1295 dev->cdb_len = (unsigned int) rc;
1290 1296
1297 if (ata_id_cdb_intr(dev->id))
1298 dev->flags |= ATA_DFLAG_CDB_INTR;
1299
1291 /* print device info to dmesg */ 1300 /* print device info to dmesg */
1292 if (print_info) 1301 if (print_info)
1293 printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n", 1302 printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n",
@@ -3081,7 +3090,6 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc)
3081 unsigned long flags; 3090 unsigned long flags;
3082 3091
3083 spin_lock_irqsave(&ap->host_set->lock, flags); 3092 spin_lock_irqsave(&ap->host_set->lock, flags);
3084 ap->flags &= ~ATA_FLAG_NOINTR;
3085 ata_irq_on(ap); 3093 ata_irq_on(ap);
3086 ata_qc_complete(qc); 3094 ata_qc_complete(qc);
3087 spin_unlock_irqrestore(&ap->host_set->lock, flags); 3095 spin_unlock_irqrestore(&ap->host_set->lock, flags);
@@ -3147,7 +3155,8 @@ static unsigned long ata_pio_poll(struct ata_port *ap)
3147 * None. (executing in kernel thread context) 3155 * None. (executing in kernel thread context)
3148 * 3156 *
3149 * RETURNS: 3157 * RETURNS:
3150 * Non-zero if qc completed, zero otherwise. 3158 * Zero if qc completed.
3159 * Non-zero if has next.
3151 */ 3160 */
3152 3161
3153static int ata_pio_complete (struct ata_port *ap) 3162static int ata_pio_complete (struct ata_port *ap)
@@ -3160,7 +3169,7 @@ static int ata_pio_complete (struct ata_port *ap)
3160 * we enter, BSY will be cleared in a chk-status or two. If not, 3169 * we enter, BSY will be cleared in a chk-status or two. If not,
3161 * the drive is probably seeking or something. Snooze for a couple 3170 * the drive is probably seeking or something. Snooze for a couple
3162 * msecs, then chk-status again. If still busy, fall back to 3171 * msecs, then chk-status again. If still busy, fall back to
3163 * HSM_ST_POLL state. 3172 * HSM_ST_LAST_POLL state.
3164 */ 3173 */
3165 drv_stat = ata_busy_wait(ap, ATA_BUSY, 10); 3174 drv_stat = ata_busy_wait(ap, ATA_BUSY, 10);
3166 if (drv_stat & ATA_BUSY) { 3175 if (drv_stat & ATA_BUSY) {
@@ -3169,7 +3178,7 @@ static int ata_pio_complete (struct ata_port *ap)
3169 if (drv_stat & ATA_BUSY) { 3178 if (drv_stat & ATA_BUSY) {
3170 ap->hsm_task_state = HSM_ST_LAST_POLL; 3179 ap->hsm_task_state = HSM_ST_LAST_POLL;
3171 ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO; 3180 ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO;
3172 return 0; 3181 return 1;
3173 } 3182 }
3174 } 3183 }
3175 3184
@@ -3180,7 +3189,7 @@ static int ata_pio_complete (struct ata_port *ap)
3180 if (!ata_ok(drv_stat)) { 3189 if (!ata_ok(drv_stat)) {
3181 qc->err_mask |= __ac_err_mask(drv_stat); 3190 qc->err_mask |= __ac_err_mask(drv_stat);
3182 ap->hsm_task_state = HSM_ST_ERR; 3191 ap->hsm_task_state = HSM_ST_ERR;
3183 return 0; 3192 return 1;
3184 } 3193 }
3185 3194
3186 ap->hsm_task_state = HSM_ST_IDLE; 3195 ap->hsm_task_state = HSM_ST_IDLE;
@@ -3190,7 +3199,7 @@ static int ata_pio_complete (struct ata_port *ap)
3190 3199
3191 /* another command may start at this point */ 3200 /* another command may start at this point */
3192 3201
3193 return 1; 3202 return 0;
3194} 3203}
3195 3204
3196 3205
@@ -3362,7 +3371,23 @@ static void ata_pio_sector(struct ata_queued_cmd *qc)
3362 page = nth_page(page, (offset >> PAGE_SHIFT)); 3371 page = nth_page(page, (offset >> PAGE_SHIFT));
3363 offset %= PAGE_SIZE; 3372 offset %= PAGE_SIZE;
3364 3373
3365 buf = kmap(page) + offset; 3374 DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
3375
3376 if (PageHighMem(page)) {
3377 unsigned long flags;
3378
3379 local_irq_save(flags);
3380 buf = kmap_atomic(page, KM_IRQ0);
3381
3382 /* do the actual data transfer */
3383 ata_data_xfer(ap, buf + offset, ATA_SECT_SIZE, do_write);
3384
3385 kunmap_atomic(buf, KM_IRQ0);
3386 local_irq_restore(flags);
3387 } else {
3388 buf = page_address(page);
3389 ata_data_xfer(ap, buf + offset, ATA_SECT_SIZE, do_write);
3390 }
3366 3391
3367 qc->cursect++; 3392 qc->cursect++;
3368 qc->cursg_ofs++; 3393 qc->cursg_ofs++;
@@ -3371,14 +3396,153 @@ static void ata_pio_sector(struct ata_queued_cmd *qc)
3371 qc->cursg++; 3396 qc->cursg++;
3372 qc->cursg_ofs = 0; 3397 qc->cursg_ofs = 0;
3373 } 3398 }
3399}
3374 3400
3375 DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); 3401/**
3402 * ata_pio_sectors - Transfer one or many 512-byte sectors.
3403 * @qc: Command on going
3404 *
3405 * Transfer one or many ATA_SECT_SIZE of data from/to the
3406 * ATA device for the DRQ request.
3407 *
3408 * LOCKING:
3409 * Inherited from caller.
3410 */
3411
3412static void ata_pio_sectors(struct ata_queued_cmd *qc)
3413{
3414 if (is_multi_taskfile(&qc->tf)) {
3415 /* READ/WRITE MULTIPLE */
3416 unsigned int nsect;
3417
3418 WARN_ON(qc->dev->multi_count == 0);
3419
3420 nsect = min(qc->nsect - qc->cursect, qc->dev->multi_count);
3421 while (nsect--)
3422 ata_pio_sector(qc);
3423 } else
3424 ata_pio_sector(qc);
3425}
3426
3427/**
3428 * atapi_send_cdb - Write CDB bytes to hardware
3429 * @ap: Port to which ATAPI device is attached.
3430 * @qc: Taskfile currently active
3431 *
3432 * When device has indicated its readiness to accept
3433 * a CDB, this function is called. Send the CDB.
3434 *
3435 * LOCKING:
3436 * caller.
3437 */
3438
3439static void atapi_send_cdb(struct ata_port *ap, struct ata_queued_cmd *qc)
3440{
3441 /* send SCSI cdb */
3442 DPRINTK("send cdb\n");
3443 WARN_ON(qc->dev->cdb_len < 12);
3444
3445 ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1);
3446 ata_altstatus(ap); /* flush */
3447
3448 switch (qc->tf.protocol) {
3449 case ATA_PROT_ATAPI:
3450 ap->hsm_task_state = HSM_ST;
3451 break;
3452 case ATA_PROT_ATAPI_NODATA:
3453 ap->hsm_task_state = HSM_ST_LAST;
3454 break;
3455 case ATA_PROT_ATAPI_DMA:
3456 ap->hsm_task_state = HSM_ST_LAST;
3457 /* initiate bmdma */
3458 ap->ops->bmdma_start(qc);
3459 break;
3460 }
3461}
3376 3462
3377 /* do the actual data transfer */ 3463/**
3378 do_write = (qc->tf.flags & ATA_TFLAG_WRITE); 3464 * ata_pio_first_block - Write first data block to hardware
3379 ata_data_xfer(ap, buf, ATA_SECT_SIZE, do_write); 3465 * @ap: Port to which ATA/ATAPI device is attached.
3466 *
3467 * When device has indicated its readiness to accept
3468 * the data, this function sends out the CDB or
3469 * the first data block by PIO.
3470 * After this,
3471 * - If polling, ata_pio_task() handles the rest.
3472 * - Otherwise, interrupt handler takes over.
3473 *
3474 * LOCKING:
3475 * Kernel thread context (may sleep)
3476 *
3477 * RETURNS:
3478 * Zero if irq handler takes over
3479 * Non-zero if has next (polling).
3480 */
3380 3481
3381 kunmap(page); 3482static int ata_pio_first_block(struct ata_port *ap)
3483{
3484 struct ata_queued_cmd *qc;
3485 u8 status;
3486 unsigned long flags;
3487 int has_next;
3488
3489 qc = ata_qc_from_tag(ap, ap->active_tag);
3490 WARN_ON(qc == NULL);
3491 WARN_ON((qc->flags & ATA_QCFLAG_ACTIVE) == 0);
3492
3493 /* if polling, we will stay in the work queue after sending the data.
3494 * otherwise, interrupt handler takes over after sending the data.
3495 */
3496 has_next = (qc->tf.flags & ATA_TFLAG_POLLING);
3497
3498 /* sleep-wait for BSY to clear */
3499 DPRINTK("busy wait\n");
3500 if (ata_busy_sleep(ap, ATA_TMOUT_DATAOUT_QUICK, ATA_TMOUT_DATAOUT)) {
3501 qc->err_mask |= AC_ERR_TIMEOUT;
3502 ap->hsm_task_state = HSM_ST_TMOUT;
3503 goto err_out;
3504 }
3505
3506 /* make sure DRQ is set */
3507 status = ata_chk_status(ap);
3508 if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) {
3509 /* device status error */
3510 qc->err_mask |= AC_ERR_HSM;
3511 ap->hsm_task_state = HSM_ST_ERR;
3512 goto err_out;
3513 }
3514
3515 /* Send the CDB (atapi) or the first data block (ata pio out).
3516 * During the state transition, interrupt handler shouldn't
3517 * be invoked before the data transfer is complete and
3518 * hsm_task_state is changed. Hence, the following locking.
3519 */
3520 spin_lock_irqsave(&ap->host_set->lock, flags);
3521
3522 if (qc->tf.protocol == ATA_PROT_PIO) {
3523 /* PIO data out protocol.
3524 * send first data block.
3525 */
3526
3527 /* ata_pio_sectors() might change the state to HSM_ST_LAST.
3528 * so, the state is changed here before ata_pio_sectors().
3529 */
3530 ap->hsm_task_state = HSM_ST;
3531 ata_pio_sectors(qc);
3532 ata_altstatus(ap); /* flush */
3533 } else
3534 /* send CDB */
3535 atapi_send_cdb(ap, qc);
3536
3537 spin_unlock_irqrestore(&ap->host_set->lock, flags);
3538
3539 /* if polling, ata_pio_task() handles the rest.
3540 * otherwise, interrupt handler takes over from here.
3541 */
3542 return has_next;
3543
3544err_out:
3545 return 1; /* has next */
3382} 3546}
3383 3547
3384/** 3548/**
@@ -3444,7 +3608,23 @@ next_sg:
3444 /* don't cross page boundaries */ 3608 /* don't cross page boundaries */
3445 count = min(count, (unsigned int)PAGE_SIZE - offset); 3609 count = min(count, (unsigned int)PAGE_SIZE - offset);
3446 3610
3447 buf = kmap(page) + offset; 3611 DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
3612
3613 if (PageHighMem(page)) {
3614 unsigned long flags;
3615
3616 local_irq_save(flags);
3617 buf = kmap_atomic(page, KM_IRQ0);
3618
3619 /* do the actual data transfer */
3620 ata_data_xfer(ap, buf + offset, count, do_write);
3621
3622 kunmap_atomic(buf, KM_IRQ0);
3623 local_irq_restore(flags);
3624 } else {
3625 buf = page_address(page);
3626 ata_data_xfer(ap, buf + offset, count, do_write);
3627 }
3448 3628
3449 bytes -= count; 3629 bytes -= count;
3450 qc->curbytes += count; 3630 qc->curbytes += count;
@@ -3455,13 +3635,6 @@ next_sg:
3455 qc->cursg_ofs = 0; 3635 qc->cursg_ofs = 0;
3456 } 3636 }
3457 3637
3458 DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
3459
3460 /* do the actual data transfer */
3461 ata_data_xfer(ap, buf, count, do_write);
3462
3463 kunmap(page);
3464
3465 if (bytes) 3638 if (bytes)
3466 goto next_sg; 3639 goto next_sg;
3467} 3640}
@@ -3498,6 +3671,8 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc)
3498 if (do_write != i_write) 3671 if (do_write != i_write)
3499 goto err_out; 3672 goto err_out;
3500 3673
3674 VPRINTK("ata%u: xfering %d bytes\n", ap->id, bytes);
3675
3501 __atapi_pio_bytes(qc, bytes); 3676 __atapi_pio_bytes(qc, bytes);
3502 3677
3503 return; 3678 return;
@@ -3568,8 +3743,10 @@ static void ata_pio_block(struct ata_port *ap)
3568 return; 3743 return;
3569 } 3744 }
3570 3745
3571 ata_pio_sector(qc); 3746 ata_pio_sectors(qc);
3572 } 3747 }
3748
3749 ata_altstatus(ap); /* flush */
3573} 3750}
3574 3751
3575static void ata_pio_error(struct ata_port *ap) 3752static void ata_pio_error(struct ata_port *ap)
@@ -3596,22 +3773,23 @@ static void ata_pio_task(void *_data)
3596{ 3773{
3597 struct ata_port *ap = _data; 3774 struct ata_port *ap = _data;
3598 unsigned long timeout; 3775 unsigned long timeout;
3599 int qc_completed; 3776 int has_next;
3600 3777
3601fsm_start: 3778fsm_start:
3602 timeout = 0; 3779 timeout = 0;
3603 qc_completed = 0; 3780 has_next = 1;
3604 3781
3605 switch (ap->hsm_task_state) { 3782 switch (ap->hsm_task_state) {
3606 case HSM_ST_IDLE: 3783 case HSM_ST_FIRST:
3607 return; 3784 has_next = ata_pio_first_block(ap);
3785 break;
3608 3786
3609 case HSM_ST: 3787 case HSM_ST:
3610 ata_pio_block(ap); 3788 ata_pio_block(ap);
3611 break; 3789 break;
3612 3790
3613 case HSM_ST_LAST: 3791 case HSM_ST_LAST:
3614 qc_completed = ata_pio_complete(ap); 3792 has_next = ata_pio_complete(ap);
3615 break; 3793 break;
3616 3794
3617 case HSM_ST_POLL: 3795 case HSM_ST_POLL:
@@ -3623,6 +3801,10 @@ fsm_start:
3623 case HSM_ST_ERR: 3801 case HSM_ST_ERR:
3624 ata_pio_error(ap); 3802 ata_pio_error(ap);
3625 return; 3803 return;
3804
3805 default:
3806 BUG();
3807 return;
3626 } 3808 }
3627 3809
3628 if (timeout) 3810 if (timeout)
@@ -3756,8 +3938,10 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
3756 printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x host_stat 0x%x\n", 3938 printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x host_stat 0x%x\n",
3757 ap->id, qc->tf.command, drv_stat, host_stat); 3939 ap->id, qc->tf.command, drv_stat, host_stat);
3758 3940
3941 ap->hsm_task_state = HSM_ST_IDLE;
3942
3759 /* complete taskfile transaction */ 3943 /* complete taskfile transaction */
3760 qc->err_mask |= ac_err_mask(drv_stat); 3944 qc->err_mask |= AC_ERR_TIMEOUT;
3761 break; 3945 break;
3762 } 3946 }
3763 3947
@@ -3984,43 +4168,104 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
3984{ 4168{
3985 struct ata_port *ap = qc->ap; 4169 struct ata_port *ap = qc->ap;
3986 4170
4171 /* Use polling pio if the LLD doesn't handle
4172 * interrupt driven pio and atapi CDB interrupt.
4173 */
4174 if (ap->flags & ATA_FLAG_PIO_POLLING) {
4175 switch (qc->tf.protocol) {
4176 case ATA_PROT_PIO:
4177 case ATA_PROT_ATAPI:
4178 case ATA_PROT_ATAPI_NODATA:
4179 qc->tf.flags |= ATA_TFLAG_POLLING;
4180 break;
4181 case ATA_PROT_ATAPI_DMA:
4182 if (qc->dev->flags & ATA_DFLAG_CDB_INTR)
4183 BUG();
4184 break;
4185 default:
4186 break;
4187 }
4188 }
4189
4190 /* select the device */
3987 ata_dev_select(ap, qc->dev->devno, 1, 0); 4191 ata_dev_select(ap, qc->dev->devno, 1, 0);
3988 4192
4193 /* start the command */
3989 switch (qc->tf.protocol) { 4194 switch (qc->tf.protocol) {
3990 case ATA_PROT_NODATA: 4195 case ATA_PROT_NODATA:
4196 if (qc->tf.flags & ATA_TFLAG_POLLING)
4197 ata_qc_set_polling(qc);
4198
3991 ata_tf_to_host(ap, &qc->tf); 4199 ata_tf_to_host(ap, &qc->tf);
4200 ap->hsm_task_state = HSM_ST_LAST;
4201
4202 if (qc->tf.flags & ATA_TFLAG_POLLING)
4203 ata_queue_pio_task(ap);
4204
3992 break; 4205 break;
3993 4206
3994 case ATA_PROT_DMA: 4207 case ATA_PROT_DMA:
4208 WARN_ON(qc->tf.flags & ATA_TFLAG_POLLING);
4209
3995 ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ 4210 ap->ops->tf_load(ap, &qc->tf); /* load tf registers */
3996 ap->ops->bmdma_setup(qc); /* set up bmdma */ 4211 ap->ops->bmdma_setup(qc); /* set up bmdma */
3997 ap->ops->bmdma_start(qc); /* initiate bmdma */ 4212 ap->ops->bmdma_start(qc); /* initiate bmdma */
4213 ap->hsm_task_state = HSM_ST_LAST;
3998 break; 4214 break;
3999 4215
4000 case ATA_PROT_PIO: /* load tf registers, initiate polling pio */ 4216 case ATA_PROT_PIO:
4001 ata_qc_set_polling(qc); 4217 if (qc->tf.flags & ATA_TFLAG_POLLING)
4002 ata_tf_to_host(ap, &qc->tf); 4218 ata_qc_set_polling(qc);
4003 ap->hsm_task_state = HSM_ST;
4004 ata_port_queue_task(ap, ata_pio_task, ap, 0);
4005 break;
4006 4219
4007 case ATA_PROT_ATAPI:
4008 ata_qc_set_polling(qc);
4009 ata_tf_to_host(ap, &qc->tf); 4220 ata_tf_to_host(ap, &qc->tf);
4010 ata_port_queue_task(ap, atapi_packet_task, ap, 0); 4221
4222 if (qc->tf.flags & ATA_TFLAG_WRITE) {
4223 /* PIO data out protocol */
4224 ap->hsm_task_state = HSM_ST_FIRST;
4225 ata_port_queue_task(ap, ata_pio_task, ap, 0);
4226
4227 /* always send first data block using
4228 * the ata_pio_task() codepath.
4229 */
4230 } else {
4231 /* PIO data in protocol */
4232 ap->hsm_task_state = HSM_ST;
4233
4234 if (qc->tf.flags & ATA_TFLAG_POLLING)
4235 ata_port_queue_task(ap, ata_pio_task, ap, 0);
4236
4237 /* if polling, ata_pio_task() handles the rest.
4238 * otherwise, interrupt handler takes over from here.
4239 */
4240 }
4241
4011 break; 4242 break;
4012 4243
4244 case ATA_PROT_ATAPI:
4013 case ATA_PROT_ATAPI_NODATA: 4245 case ATA_PROT_ATAPI_NODATA:
4014 ap->flags |= ATA_FLAG_NOINTR; 4246 if (qc->tf.flags & ATA_TFLAG_POLLING)
4247 ata_qc_set_polling(qc);
4248
4015 ata_tf_to_host(ap, &qc->tf); 4249 ata_tf_to_host(ap, &qc->tf);
4016 ata_port_queue_task(ap, atapi_packet_task, ap, 0); 4250
4251 ap->hsm_task_state = HSM_ST_FIRST;
4252
4253 /* send cdb by polling if no cdb interrupt */
4254 if ((!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) ||
4255 (qc->tf.flags & ATA_TFLAG_POLLING))
4256 ata_port_queue_task(ap, atapi_packet_task, ap, 0);
4017 break; 4257 break;
4018 4258
4019 case ATA_PROT_ATAPI_DMA: 4259 case ATA_PROT_ATAPI_DMA:
4020 ap->flags |= ATA_FLAG_NOINTR; 4260 WARN_ON(qc->tf.flags & ATA_TFLAG_POLLING);
4261
4021 ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ 4262 ap->ops->tf_load(ap, &qc->tf); /* load tf registers */
4022 ap->ops->bmdma_setup(qc); /* set up bmdma */ 4263 ap->ops->bmdma_setup(qc); /* set up bmdma */
4023 ata_port_queue_task(ap, atapi_packet_task, ap, 0); 4264 ap->hsm_task_state = HSM_ST_FIRST;
4265
4266 /* send cdb by polling if no cdb interrupt */
4267 if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR))
4268 ata_port_queue_task(ap, atapi_packet_task, ap, 0);
4024 break; 4269 break;
4025 4270
4026 default: 4271 default:
@@ -4281,48 +4526,160 @@ void ata_bmdma_stop(struct ata_queued_cmd *qc)
4281inline unsigned int ata_host_intr (struct ata_port *ap, 4526inline unsigned int ata_host_intr (struct ata_port *ap,
4282 struct ata_queued_cmd *qc) 4527 struct ata_queued_cmd *qc)
4283{ 4528{
4284 u8 status, host_stat; 4529 u8 status, host_stat = 0;
4285 4530
4286 switch (qc->tf.protocol) { 4531 VPRINTK("ata%u: protocol %d task_state %d\n",
4532 ap->id, qc->tf.protocol, ap->hsm_task_state);
4287 4533
4288 case ATA_PROT_DMA: 4534 /* Check whether we are expecting interrupt in this state */
4289 case ATA_PROT_ATAPI_DMA: 4535 switch (ap->hsm_task_state) {
4290 case ATA_PROT_ATAPI: 4536 case HSM_ST_FIRST:
4291 /* check status of DMA engine */ 4537 /* Check the ATA_DFLAG_CDB_INTR flag is enough here.
4292 host_stat = ap->ops->bmdma_status(ap); 4538 * The flag was turned on only for atapi devices.
4293 VPRINTK("ata%u: host_stat 0x%X\n", ap->id, host_stat); 4539 * No need to check is_atapi_taskfile(&qc->tf) again.
4294 4540 */
4295 /* if it's not our irq... */ 4541 if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR))
4296 if (!(host_stat & ATA_DMA_INTR))
4297 goto idle_irq; 4542 goto idle_irq;
4543 break;
4544 case HSM_ST_LAST:
4545 if (qc->tf.protocol == ATA_PROT_DMA ||
4546 qc->tf.protocol == ATA_PROT_ATAPI_DMA) {
4547 /* check status of DMA engine */
4548 host_stat = ap->ops->bmdma_status(ap);
4549 VPRINTK("ata%u: host_stat 0x%X\n", ap->id, host_stat);
4550
4551 /* if it's not our irq... */
4552 if (!(host_stat & ATA_DMA_INTR))
4553 goto idle_irq;
4554
4555 /* before we do anything else, clear DMA-Start bit */
4556 ap->ops->bmdma_stop(qc);
4557
4558 if (unlikely(host_stat & ATA_DMA_ERR)) {
4559 /* error when transfering data to/from memory */
4560 qc->err_mask |= AC_ERR_HOST_BUS;
4561 ap->hsm_task_state = HSM_ST_ERR;
4562 }
4563 }
4564 break;
4565 case HSM_ST:
4566 break;
4567 default:
4568 goto idle_irq;
4569 }
4298 4570
4299 /* before we do anything else, clear DMA-Start bit */ 4571 /* check altstatus */
4300 ap->ops->bmdma_stop(qc); 4572 status = ata_altstatus(ap);
4573 if (status & ATA_BUSY)
4574 goto idle_irq;
4301 4575
4302 /* fall through */ 4576 /* check main status, clearing INTRQ */
4577 status = ata_chk_status(ap);
4578 if (unlikely(status & ATA_BUSY))
4579 goto idle_irq;
4303 4580
4304 case ATA_PROT_ATAPI_NODATA: 4581 DPRINTK("ata%u: protocol %d task_state %d (dev_stat 0x%X)\n",
4305 case ATA_PROT_NODATA: 4582 ap->id, qc->tf.protocol, ap->hsm_task_state, status);
4306 /* check altstatus */
4307 status = ata_altstatus(ap);
4308 if (status & ATA_BUSY)
4309 goto idle_irq;
4310 4583
4311 /* check main status, clearing INTRQ */ 4584 /* ack bmdma irq events */
4312 status = ata_chk_status(ap); 4585 ap->ops->irq_clear(ap);
4313 if (unlikely(status & ATA_BUSY))
4314 goto idle_irq;
4315 DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n",
4316 ap->id, qc->tf.protocol, status);
4317 4586
4318 /* ack bmdma irq events */ 4587 /* check error */
4319 ap->ops->irq_clear(ap); 4588 if (unlikely(status & (ATA_ERR | ATA_DF))) {
4589 qc->err_mask |= AC_ERR_DEV;
4590 ap->hsm_task_state = HSM_ST_ERR;
4591 }
4592
4593fsm_start:
4594 switch (ap->hsm_task_state) {
4595 case HSM_ST_FIRST:
4596 /* Some pre-ATAPI-4 devices assert INTRQ
4597 * at this state when ready to receive CDB.
4598 */
4599
4600 /* check device status */
4601 if (unlikely((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ)) {
4602 /* Wrong status. Let EH handle this */
4603 qc->err_mask |= AC_ERR_HSM;
4604 ap->hsm_task_state = HSM_ST_ERR;
4605 goto fsm_start;
4606 }
4607
4608 atapi_send_cdb(ap, qc);
4609
4610 break;
4611
4612 case HSM_ST:
4613 /* complete command or read/write the data register */
4614 if (qc->tf.protocol == ATA_PROT_ATAPI) {
4615 /* ATAPI PIO protocol */
4616 if ((status & ATA_DRQ) == 0) {
4617 /* no more data to transfer */
4618 ap->hsm_task_state = HSM_ST_LAST;
4619 goto fsm_start;
4620 }
4621
4622 atapi_pio_bytes(qc);
4623
4624 if (unlikely(ap->hsm_task_state == HSM_ST_ERR))
4625 /* bad ireason reported by device */
4626 goto fsm_start;
4627
4628 } else {
4629 /* ATA PIO protocol */
4630 if (unlikely((status & ATA_DRQ) == 0)) {
4631 /* handle BSY=0, DRQ=0 as error */
4632 qc->err_mask |= AC_ERR_HSM;
4633 ap->hsm_task_state = HSM_ST_ERR;
4634 goto fsm_start;
4635 }
4636
4637 ata_pio_sectors(qc);
4638
4639 if (ap->hsm_task_state == HSM_ST_LAST &&
4640 (!(qc->tf.flags & ATA_TFLAG_WRITE))) {
4641 /* all data read */
4642 ata_altstatus(ap);
4643 status = ata_chk_status(ap);
4644 goto fsm_start;
4645 }
4646 }
4647
4648 ata_altstatus(ap); /* flush */
4649 break;
4650
4651 case HSM_ST_LAST:
4652 if (unlikely(status & ATA_DRQ)) {
4653 /* handle DRQ=1 as error */
4654 qc->err_mask |= AC_ERR_HSM;
4655 ap->hsm_task_state = HSM_ST_ERR;
4656 goto fsm_start;
4657 }
4658
4659 /* no more data to transfer */
4660 DPRINTK("ata%u: command complete, drv_stat 0x%x\n",
4661 ap->id, status);
4662
4663 ap->hsm_task_state = HSM_ST_IDLE;
4320 4664
4321 /* complete taskfile transaction */ 4665 /* complete taskfile transaction */
4322 qc->err_mask |= ac_err_mask(status); 4666 qc->err_mask |= ac_err_mask(status);
4323 ata_qc_complete(qc); 4667 ata_qc_complete(qc);
4324 break; 4668 break;
4325 4669
4670 case HSM_ST_ERR:
4671 if (qc->tf.command != ATA_CMD_PACKET)
4672 printk(KERN_ERR "ata%u: command error, drv_stat 0x%x host_stat 0x%x\n",
4673 ap->id, status, host_stat);
4674
4675 /* make sure qc->err_mask is available to
4676 * know what's wrong and recover
4677 */
4678 WARN_ON(qc->err_mask == 0);
4679
4680 ap->hsm_task_state = HSM_ST_IDLE;
4681 ata_qc_complete(qc);
4682 break;
4326 default: 4683 default:
4327 goto idle_irq; 4684 goto idle_irq;
4328 } 4685 }
@@ -4373,11 +4730,11 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
4373 4730
4374 ap = host_set->ports[i]; 4731 ap = host_set->ports[i];
4375 if (ap && 4732 if (ap &&
4376 !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { 4733 !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
4377 struct ata_queued_cmd *qc; 4734 struct ata_queued_cmd *qc;
4378 4735
4379 qc = ata_qc_from_tag(ap, ap->active_tag); 4736 qc = ata_qc_from_tag(ap, ap->active_tag);
4380 if (qc && (!(qc->tf.ctl & ATA_NIEN)) && 4737 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) &&
4381 (qc->flags & ATA_QCFLAG_ACTIVE)) 4738 (qc->flags & ATA_QCFLAG_ACTIVE))
4382 handled |= ata_host_intr(ap, qc); 4739 handled |= ata_host_intr(ap, qc);
4383 } 4740 }
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
index 5f33cc932e70..f32af5dc58c4 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/scsi/pdc_adma.c
@@ -457,13 +457,13 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set)
457 continue; 457 continue;
458 handled = 1; 458 handled = 1;
459 adma_enter_reg_mode(ap); 459 adma_enter_reg_mode(ap);
460 if (ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR)) 460 if (ap->flags & ATA_FLAG_PORT_DISABLED)
461 continue; 461 continue;
462 pp = ap->private_data; 462 pp = ap->private_data;
463 if (!pp || pp->state != adma_state_pkt) 463 if (!pp || pp->state != adma_state_pkt)
464 continue; 464 continue;
465 qc = ata_qc_from_tag(ap, ap->active_tag); 465 qc = ata_qc_from_tag(ap, ap->active_tag);
466 if (qc && (!(qc->tf.ctl & ATA_NIEN))) { 466 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
467 if ((status & (aPERR | aPSD | aUIRQ))) 467 if ((status & (aPERR | aPSD | aUIRQ)))
468 qc->err_mask |= AC_ERR_OTHER; 468 qc->err_mask |= AC_ERR_OTHER;
469 else if (pp->pkt[0] != cDONE) 469 else if (pp->pkt[0] != cDONE)
@@ -482,13 +482,13 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set)
482 for (port_no = 0; port_no < host_set->n_ports; ++port_no) { 482 for (port_no = 0; port_no < host_set->n_ports; ++port_no) {
483 struct ata_port *ap; 483 struct ata_port *ap;
484 ap = host_set->ports[port_no]; 484 ap = host_set->ports[port_no];
485 if (ap && (!(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR)))) { 485 if (ap && (!(ap->flags & ATA_FLAG_PORT_DISABLED))) {
486 struct ata_queued_cmd *qc; 486 struct ata_queued_cmd *qc;
487 struct adma_port_priv *pp = ap->private_data; 487 struct adma_port_priv *pp = ap->private_data;
488 if (!pp || pp->state != adma_state_mmio) 488 if (!pp || pp->state != adma_state_mmio)
489 continue; 489 continue;
490 qc = ata_qc_from_tag(ap, ap->active_tag); 490 qc = ata_qc_from_tag(ap, ap->active_tag);
491 if (qc && (!(qc->tf.ctl & ATA_NIEN))) { 491 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
492 492
493 /* check main status, clearing INTRQ */ 493 /* check main status, clearing INTRQ */
494 u8 status = ata_check_status(ap); 494 u8 status = ata_check_status(ap);
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index aceaf56999a5..692c63bdcff8 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -87,7 +87,7 @@ enum {
87 MV_FLAG_IRQ_COALESCE = (1 << 29), /* IRQ coalescing capability */ 87 MV_FLAG_IRQ_COALESCE = (1 << 29), /* IRQ coalescing capability */
88 MV_COMMON_FLAGS = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 88 MV_COMMON_FLAGS = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
89 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO | 89 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
90 ATA_FLAG_NO_ATAPI), 90 ATA_FLAG_PIO_POLLING),
91 MV_6XXX_FLAGS = MV_FLAG_IRQ_COALESCE, 91 MV_6XXX_FLAGS = MV_FLAG_IRQ_COALESCE,
92 92
93 CRQB_FLAG_READ = (1 << 0), 93 CRQB_FLAG_READ = (1 << 0),
@@ -1388,8 +1388,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1388 handled++; 1388 handled++;
1389 } 1389 }
1390 1390
1391 if (ap && 1391 if (ap && (ap->flags & ATA_FLAG_PORT_DISABLED))
1392 (ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR)))
1393 continue; 1392 continue;
1394 1393
1395 err_mask = ac_err_mask(ata_status); 1394 err_mask = ac_err_mask(ata_status);
@@ -1410,7 +1409,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1410 VPRINTK("port %u IRQ found for qc, " 1409 VPRINTK("port %u IRQ found for qc, "
1411 "ata_status 0x%x\n", port,ata_status); 1410 "ata_status 0x%x\n", port,ata_status);
1412 /* mark qc status appropriately */ 1411 /* mark qc status appropriately */
1413 if (!(qc->tf.ctl & ATA_NIEN)) { 1412 if (!(qc->tf.flags & ATA_TFLAG_POLLING)) {
1414 qc->err_mask |= err_mask; 1413 qc->err_mask |= err_mask;
1415 ata_qc_complete(qc); 1414 ata_qc_complete(qc);
1416 } 1415 }
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index caffadc2e0ae..5168db981dde 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -309,11 +309,11 @@ static irqreturn_t nv_interrupt (int irq, void *dev_instance,
309 309
310 ap = host_set->ports[i]; 310 ap = host_set->ports[i];
311 if (ap && 311 if (ap &&
312 !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { 312 !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
313 struct ata_queued_cmd *qc; 313 struct ata_queued_cmd *qc;
314 314
315 qc = ata_qc_from_tag(ap, ap->active_tag); 315 qc = ata_qc_from_tag(ap, ap->active_tag);
316 if (qc && (!(qc->tf.ctl & ATA_NIEN))) 316 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
317 handled += ata_host_intr(ap, qc); 317 handled += ata_host_intr(ap, qc);
318 else 318 else
319 // No request pending? Clear interrupt status 319 // No request pending? Clear interrupt status
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index 84cb3940ad88..e5862ad5e6cd 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -76,7 +76,8 @@ enum {
76 PDC_RESET = (1 << 11), /* HDMA reset */ 76 PDC_RESET = (1 << 11), /* HDMA reset */
77 77
78 PDC_COMMON_FLAGS = ATA_FLAG_NO_LEGACY | ATA_FLAG_SRST | 78 PDC_COMMON_FLAGS = ATA_FLAG_NO_LEGACY | ATA_FLAG_SRST |
79 ATA_FLAG_MMIO | ATA_FLAG_NO_ATAPI, 79 ATA_FLAG_MMIO | ATA_FLAG_NO_ATAPI |
80 ATA_FLAG_PIO_POLLING,
80}; 81};
81 82
82 83
@@ -535,11 +536,11 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r
535 ap = host_set->ports[i]; 536 ap = host_set->ports[i];
536 tmp = mask & (1 << (i + 1)); 537 tmp = mask & (1 << (i + 1));
537 if (tmp && ap && 538 if (tmp && ap &&
538 !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { 539 !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
539 struct ata_queued_cmd *qc; 540 struct ata_queued_cmd *qc;
540 541
541 qc = ata_qc_from_tag(ap, ap->active_tag); 542 qc = ata_qc_from_tag(ap, ap->active_tag);
542 if (qc && (!(qc->tf.ctl & ATA_NIEN))) 543 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
543 handled += pdc_host_intr(ap, qc); 544 handled += pdc_host_intr(ap, qc);
544 } 545 }
545 } 546 }
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c
index 9602f43a298e..bf7bb9ec18d0 100644
--- a/drivers/scsi/sata_qstor.c
+++ b/drivers/scsi/sata_qstor.c
@@ -177,7 +177,7 @@ static const struct ata_port_info qs_port_info[] = {
177 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 177 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
178 ATA_FLAG_SATA_RESET | 178 ATA_FLAG_SATA_RESET |
179 //FIXME ATA_FLAG_SRST | 179 //FIXME ATA_FLAG_SRST |
180 ATA_FLAG_MMIO, 180 ATA_FLAG_MMIO | ATA_FLAG_PIO_POLLING,
181 .pio_mask = 0x10, /* pio4 */ 181 .pio_mask = 0x10, /* pio4 */
182 .udma_mask = 0x7f, /* udma0-6 */ 182 .udma_mask = 0x7f, /* udma0-6 */
183 .port_ops = &qs_ata_ops, 183 .port_ops = &qs_ata_ops,
@@ -396,14 +396,13 @@ static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set)
396 DPRINTK("SFF=%08x%08x: sCHAN=%u sHST=%d sDST=%02x\n", 396 DPRINTK("SFF=%08x%08x: sCHAN=%u sHST=%d sDST=%02x\n",
397 sff1, sff0, port_no, sHST, sDST); 397 sff1, sff0, port_no, sHST, sDST);
398 handled = 1; 398 handled = 1;
399 if (ap && !(ap->flags & 399 if (ap && !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
400 (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) {
401 struct ata_queued_cmd *qc; 400 struct ata_queued_cmd *qc;
402 struct qs_port_priv *pp = ap->private_data; 401 struct qs_port_priv *pp = ap->private_data;
403 if (!pp || pp->state != qs_state_pkt) 402 if (!pp || pp->state != qs_state_pkt)
404 continue; 403 continue;
405 qc = ata_qc_from_tag(ap, ap->active_tag); 404 qc = ata_qc_from_tag(ap, ap->active_tag);
406 if (qc && (!(qc->tf.ctl & ATA_NIEN))) { 405 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
407 switch (sHST) { 406 switch (sHST) {
408 case 0: /* successful CPB */ 407 case 0: /* successful CPB */
409 case 3: /* device error */ 408 case 3: /* device error */
@@ -430,13 +429,13 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set)
430 struct ata_port *ap; 429 struct ata_port *ap;
431 ap = host_set->ports[port_no]; 430 ap = host_set->ports[port_no];
432 if (ap && 431 if (ap &&
433 !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { 432 !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
434 struct ata_queued_cmd *qc; 433 struct ata_queued_cmd *qc;
435 struct qs_port_priv *pp = ap->private_data; 434 struct qs_port_priv *pp = ap->private_data;
436 if (!pp || pp->state != qs_state_mmio) 435 if (!pp || pp->state != qs_state_mmio)
437 continue; 436 continue;
438 qc = ata_qc_from_tag(ap, ap->active_tag); 437 qc = ata_qc_from_tag(ap, ap->active_tag);
439 if (qc && (!(qc->tf.ctl & ATA_NIEN))) { 438 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
440 439
441 /* check main status, clearing INTRQ */ 440 /* check main status, clearing INTRQ */
442 u8 status = ata_check_status(ap); 441 u8 status = ata_check_status(ap);
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c
index 9f8a76815402..60ebe5ce32c4 100644
--- a/drivers/scsi/sata_sx4.c
+++ b/drivers/scsi/sata_sx4.c
@@ -220,7 +220,7 @@ static const struct ata_port_info pdc_port_info[] = {
220 .sht = &pdc_sata_sht, 220 .sht = &pdc_sata_sht,
221 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 221 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
222 ATA_FLAG_SRST | ATA_FLAG_MMIO | 222 ATA_FLAG_SRST | ATA_FLAG_MMIO |
223 ATA_FLAG_NO_ATAPI, 223 ATA_FLAG_PIO_POLLING,
224 .pio_mask = 0x1f, /* pio0-4 */ 224 .pio_mask = 0x1f, /* pio0-4 */
225 .mwdma_mask = 0x07, /* mwdma0-2 */ 225 .mwdma_mask = 0x07, /* mwdma0-2 */
226 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 226 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -835,11 +835,11 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re
835 tmp = mask & (1 << i); 835 tmp = mask & (1 << i);
836 VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp); 836 VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp);
837 if (tmp && ap && 837 if (tmp && ap &&
838 !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { 838 !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
839 struct ata_queued_cmd *qc; 839 struct ata_queued_cmd *qc;
840 840
841 qc = ata_qc_from_tag(ap, ap->active_tag); 841 qc = ata_qc_from_tag(ap, ap->active_tag);
842 if (qc && (!(qc->tf.ctl & ATA_NIEN))) 842 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
843 handled += pdc20621_host_intr(ap, qc, (i > 4), 843 handled += pdc20621_host_intr(ap, qc, (i > 4),
844 mmio_base); 844 mmio_base);
845 } 845 }
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index b574379a7a82..5845758e9a69 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -223,14 +223,13 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
223 handled++; 223 handled++;
224 } 224 }
225 225
226 if (ap && !(ap->flags & 226 if (ap && !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
227 (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) {
228 struct ata_queued_cmd *qc; 227 struct ata_queued_cmd *qc;
229 228
230 qc = ata_qc_from_tag(ap, ap->active_tag); 229 qc = ata_qc_from_tag(ap, ap->active_tag);
231 if (qc && (!(qc->tf.ctl & ATA_NIEN))) { 230 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
232 handled += ata_host_intr(ap, qc); 231 handled += ata_host_intr(ap, qc);
233 } else { 232 else {
234 printk(KERN_DEBUG "%s: ignoring interrupt(s)\n", __FUNCTION__); 233 printk(KERN_DEBUG "%s: ignoring interrupt(s)\n", __FUNCTION__);
235 ata_chk_status(ap); 234 ata_chk_status(ap);
236 handled++; 235 handled++;