diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/scsi/libata-core.c | 804 | ||||
-rw-r--r-- | drivers/scsi/libata-eh.c | 5 | ||||
-rw-r--r-- | drivers/scsi/pdc_adma.c | 8 | ||||
-rw-r--r-- | drivers/scsi/sata_mv.c | 6 | ||||
-rw-r--r-- | drivers/scsi/sata_nv.c | 4 | ||||
-rw-r--r-- | drivers/scsi/sata_promise.c | 7 | ||||
-rw-r--r-- | drivers/scsi/sata_qstor.c | 11 | ||||
-rw-r--r-- | drivers/scsi/sata_sx4.c | 6 | ||||
-rw-r--r-- | drivers/scsi/sata_vsc.c | 15 |
9 files changed, 533 insertions, 333 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c index 966be3034b..56537293ad 100644 --- a/drivers/scsi/libata-core.c +++ b/drivers/scsi/libata-core.c | |||
@@ -1305,11 +1305,19 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev, | |||
1305 | dev->cylinders, dev->heads, dev->sectors); | 1305 | dev->cylinders, dev->heads, dev->sectors); |
1306 | } | 1306 | } |
1307 | 1307 | ||
1308 | if (dev->id[59] & 0x100) { | ||
1309 | dev->multi_count = dev->id[59] & 0xff; | ||
1310 | DPRINTK("ata%u: dev %u multi count %u\n", | ||
1311 | ap->id, dev->devno, dev->multi_count); | ||
1312 | } | ||
1313 | |||
1308 | dev->cdb_len = 16; | 1314 | dev->cdb_len = 16; |
1309 | } | 1315 | } |
1310 | 1316 | ||
1311 | /* ATAPI-specific feature tests */ | 1317 | /* ATAPI-specific feature tests */ |
1312 | else if (dev->class == ATA_DEV_ATAPI) { | 1318 | else if (dev->class == ATA_DEV_ATAPI) { |
1319 | char *cdb_intr_string = ""; | ||
1320 | |||
1313 | rc = atapi_cdb_len(id); | 1321 | rc = atapi_cdb_len(id); |
1314 | if ((rc < 12) || (rc > ATAPI_CDB_LEN)) { | 1322 | if ((rc < 12) || (rc > ATAPI_CDB_LEN)) { |
1315 | printk(KERN_WARNING "ata%u: unsupported CDB len\n", ap->id); | 1323 | printk(KERN_WARNING "ata%u: unsupported CDB len\n", ap->id); |
@@ -1318,10 +1326,16 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev, | |||
1318 | } | 1326 | } |
1319 | dev->cdb_len = (unsigned int) rc; | 1327 | dev->cdb_len = (unsigned int) rc; |
1320 | 1328 | ||
1329 | if (ata_id_cdb_intr(dev->id)) { | ||
1330 | dev->flags |= ATA_DFLAG_CDB_INTR; | ||
1331 | cdb_intr_string = ", CDB intr"; | ||
1332 | } | ||
1333 | |||
1321 | /* print device info to dmesg */ | 1334 | /* print device info to dmesg */ |
1322 | if (print_info) | 1335 | if (print_info) |
1323 | printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n", | 1336 | printk(KERN_INFO "ata%u: dev %u ATAPI, max %s%s\n", |
1324 | ap->id, dev->devno, ata_mode_string(xfer_mask)); | 1337 | ap->id, dev->devno, ata_mode_string(xfer_mask), |
1338 | cdb_intr_string); | ||
1325 | } | 1339 | } |
1326 | 1340 | ||
1327 | ap->host->max_cmd_len = 0; | 1341 | ap->host->max_cmd_len = 0; |
@@ -3167,6 +3181,15 @@ int ata_check_atapi_dma(struct ata_queued_cmd *qc) | |||
3167 | if (ap->ops->check_atapi_dma) | 3181 | if (ap->ops->check_atapi_dma) |
3168 | rc = ap->ops->check_atapi_dma(qc); | 3182 | rc = ap->ops->check_atapi_dma(qc); |
3169 | 3183 | ||
3184 | /* We don't support polling DMA. | ||
3185 | * Use PIO if the LLDD handles only interrupts in | ||
3186 | * the HSM_ST_LAST state and the ATAPI device | ||
3187 | * generates CDB interrupts. | ||
3188 | */ | ||
3189 | if ((ap->flags & ATA_FLAG_PIO_POLLING) && | ||
3190 | (qc->dev->flags & ATA_DFLAG_CDB_INTR)) | ||
3191 | rc = 1; | ||
3192 | |||
3170 | return rc; | 3193 | return rc; |
3171 | } | 3194 | } |
3172 | /** | 3195 | /** |
@@ -3409,112 +3432,12 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc) | |||
3409 | unsigned long flags; | 3432 | unsigned long flags; |
3410 | 3433 | ||
3411 | spin_lock_irqsave(&ap->host_set->lock, flags); | 3434 | spin_lock_irqsave(&ap->host_set->lock, flags); |
3412 | ap->flags &= ~ATA_FLAG_NOINTR; | ||
3413 | ata_irq_on(ap); | 3435 | ata_irq_on(ap); |
3414 | ata_qc_complete(qc); | 3436 | ata_qc_complete(qc); |
3415 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | 3437 | spin_unlock_irqrestore(&ap->host_set->lock, flags); |
3416 | } | 3438 | } |
3417 | 3439 | ||
3418 | /** | 3440 | /** |
3419 | * ata_pio_poll - poll using PIO, depending on current state | ||
3420 | * @qc: qc in progress | ||
3421 | * | ||
3422 | * LOCKING: | ||
3423 | * None. (executing in kernel thread context) | ||
3424 | * | ||
3425 | * RETURNS: | ||
3426 | * timeout value to use | ||
3427 | */ | ||
3428 | static unsigned long ata_pio_poll(struct ata_queued_cmd *qc) | ||
3429 | { | ||
3430 | struct ata_port *ap = qc->ap; | ||
3431 | u8 status; | ||
3432 | unsigned int poll_state = HSM_ST_UNKNOWN; | ||
3433 | unsigned int reg_state = HSM_ST_UNKNOWN; | ||
3434 | |||
3435 | switch (ap->hsm_task_state) { | ||
3436 | case HSM_ST: | ||
3437 | case HSM_ST_POLL: | ||
3438 | poll_state = HSM_ST_POLL; | ||
3439 | reg_state = HSM_ST; | ||
3440 | break; | ||
3441 | case HSM_ST_LAST: | ||
3442 | case HSM_ST_LAST_POLL: | ||
3443 | poll_state = HSM_ST_LAST_POLL; | ||
3444 | reg_state = HSM_ST_LAST; | ||
3445 | break; | ||
3446 | default: | ||
3447 | BUG(); | ||
3448 | break; | ||
3449 | } | ||
3450 | |||
3451 | status = ata_chk_status(ap); | ||
3452 | if (status & ATA_BUSY) { | ||
3453 | if (time_after(jiffies, ap->pio_task_timeout)) { | ||
3454 | qc->err_mask |= AC_ERR_TIMEOUT; | ||
3455 | ap->hsm_task_state = HSM_ST_TMOUT; | ||
3456 | return 0; | ||
3457 | } | ||
3458 | ap->hsm_task_state = poll_state; | ||
3459 | return ATA_SHORT_PAUSE; | ||
3460 | } | ||
3461 | |||
3462 | ap->hsm_task_state = reg_state; | ||
3463 | return 0; | ||
3464 | } | ||
3465 | |||
3466 | /** | ||
3467 | * ata_pio_complete - check if drive is busy or idle | ||
3468 | * @qc: qc to complete | ||
3469 | * | ||
3470 | * LOCKING: | ||
3471 | * None. (executing in kernel thread context) | ||
3472 | * | ||
3473 | * RETURNS: | ||
3474 | * Non-zero if qc completed, zero otherwise. | ||
3475 | */ | ||
3476 | static int ata_pio_complete(struct ata_queued_cmd *qc) | ||
3477 | { | ||
3478 | struct ata_port *ap = qc->ap; | ||
3479 | u8 drv_stat; | ||
3480 | |||
3481 | /* | ||
3482 | * This is purely heuristic. This is a fast path. Sometimes when | ||
3483 | * we enter, BSY will be cleared in a chk-status or two. If not, | ||
3484 | * the drive is probably seeking or something. Snooze for a couple | ||
3485 | * msecs, then chk-status again. If still busy, fall back to | ||
3486 | * HSM_ST_POLL state. | ||
3487 | */ | ||
3488 | drv_stat = ata_busy_wait(ap, ATA_BUSY, 10); | ||
3489 | if (drv_stat & ATA_BUSY) { | ||
3490 | msleep(2); | ||
3491 | drv_stat = ata_busy_wait(ap, ATA_BUSY, 10); | ||
3492 | if (drv_stat & ATA_BUSY) { | ||
3493 | ap->hsm_task_state = HSM_ST_LAST_POLL; | ||
3494 | ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO; | ||
3495 | return 0; | ||
3496 | } | ||
3497 | } | ||
3498 | |||
3499 | drv_stat = ata_wait_idle(ap); | ||
3500 | if (!ata_ok(drv_stat)) { | ||
3501 | qc->err_mask |= __ac_err_mask(drv_stat); | ||
3502 | ap->hsm_task_state = HSM_ST_ERR; | ||
3503 | return 0; | ||
3504 | } | ||
3505 | |||
3506 | ap->hsm_task_state = HSM_ST_IDLE; | ||
3507 | |||
3508 | WARN_ON(qc->err_mask); | ||
3509 | ata_poll_qc_complete(qc); | ||
3510 | |||
3511 | /* another command may start at this point */ | ||
3512 | |||
3513 | return 1; | ||
3514 | } | ||
3515 | |||
3516 | |||
3517 | /** | ||
3518 | * swap_buf_le16 - swap halves of 16-bit words in place | 3441 | * swap_buf_le16 - swap halves of 16-bit words in place |
3519 | * @buf: Buffer to swap | 3442 | * @buf: Buffer to swap |
3520 | * @buf_words: Number of 16-bit words in buffer. | 3443 | * @buf_words: Number of 16-bit words in buffer. |
@@ -3682,7 +3605,23 @@ static void ata_pio_sector(struct ata_queued_cmd *qc) | |||
3682 | page = nth_page(page, (offset >> PAGE_SHIFT)); | 3605 | page = nth_page(page, (offset >> PAGE_SHIFT)); |
3683 | offset %= PAGE_SIZE; | 3606 | offset %= PAGE_SIZE; |
3684 | 3607 | ||
3685 | buf = kmap(page) + offset; | 3608 | DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); |
3609 | |||
3610 | if (PageHighMem(page)) { | ||
3611 | unsigned long flags; | ||
3612 | |||
3613 | local_irq_save(flags); | ||
3614 | buf = kmap_atomic(page, KM_IRQ0); | ||
3615 | |||
3616 | /* do the actual data transfer */ | ||
3617 | ata_data_xfer(ap, buf + offset, ATA_SECT_SIZE, do_write); | ||
3618 | |||
3619 | kunmap_atomic(buf, KM_IRQ0); | ||
3620 | local_irq_restore(flags); | ||
3621 | } else { | ||
3622 | buf = page_address(page); | ||
3623 | ata_data_xfer(ap, buf + offset, ATA_SECT_SIZE, do_write); | ||
3624 | } | ||
3686 | 3625 | ||
3687 | qc->cursect++; | 3626 | qc->cursect++; |
3688 | qc->cursg_ofs++; | 3627 | qc->cursg_ofs++; |
@@ -3691,14 +3630,68 @@ static void ata_pio_sector(struct ata_queued_cmd *qc) | |||
3691 | qc->cursg++; | 3630 | qc->cursg++; |
3692 | qc->cursg_ofs = 0; | 3631 | qc->cursg_ofs = 0; |
3693 | } | 3632 | } |
3633 | } | ||
3694 | 3634 | ||
3695 | DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); | 3635 | /** |
3636 | * ata_pio_sectors - Transfer one or many 512-byte sectors. | ||
3637 | * @qc: Command on going | ||
3638 | * | ||
3639 | * Transfer one or many ATA_SECT_SIZE of data from/to the | ||
3640 | * ATA device for the DRQ request. | ||
3641 | * | ||
3642 | * LOCKING: | ||
3643 | * Inherited from caller. | ||
3644 | */ | ||
3645 | |||
3646 | static void ata_pio_sectors(struct ata_queued_cmd *qc) | ||
3647 | { | ||
3648 | if (is_multi_taskfile(&qc->tf)) { | ||
3649 | /* READ/WRITE MULTIPLE */ | ||
3650 | unsigned int nsect; | ||
3651 | |||
3652 | WARN_ON(qc->dev->multi_count == 0); | ||
3653 | |||
3654 | nsect = min(qc->nsect - qc->cursect, qc->dev->multi_count); | ||
3655 | while (nsect--) | ||
3656 | ata_pio_sector(qc); | ||
3657 | } else | ||
3658 | ata_pio_sector(qc); | ||
3659 | } | ||
3660 | |||
3661 | /** | ||
3662 | * atapi_send_cdb - Write CDB bytes to hardware | ||
3663 | * @ap: Port to which ATAPI device is attached. | ||
3664 | * @qc: Taskfile currently active | ||
3665 | * | ||
3666 | * When device has indicated its readiness to accept | ||
3667 | * a CDB, this function is called. Send the CDB. | ||
3668 | * | ||
3669 | * LOCKING: | ||
3670 | * caller. | ||
3671 | */ | ||
3696 | 3672 | ||
3697 | /* do the actual data transfer */ | 3673 | static void atapi_send_cdb(struct ata_port *ap, struct ata_queued_cmd *qc) |
3698 | do_write = (qc->tf.flags & ATA_TFLAG_WRITE); | 3674 | { |
3699 | ata_data_xfer(ap, buf, ATA_SECT_SIZE, do_write); | 3675 | /* send SCSI cdb */ |
3676 | DPRINTK("send cdb\n"); | ||
3677 | WARN_ON(qc->dev->cdb_len < 12); | ||
3678 | |||
3679 | ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1); | ||
3680 | ata_altstatus(ap); /* flush */ | ||
3700 | 3681 | ||
3701 | kunmap(page); | 3682 | switch (qc->tf.protocol) { |
3683 | case ATA_PROT_ATAPI: | ||
3684 | ap->hsm_task_state = HSM_ST; | ||
3685 | break; | ||
3686 | case ATA_PROT_ATAPI_NODATA: | ||
3687 | ap->hsm_task_state = HSM_ST_LAST; | ||
3688 | break; | ||
3689 | case ATA_PROT_ATAPI_DMA: | ||
3690 | ap->hsm_task_state = HSM_ST_LAST; | ||
3691 | /* initiate bmdma */ | ||
3692 | ap->ops->bmdma_start(qc); | ||
3693 | break; | ||
3694 | } | ||
3702 | } | 3695 | } |
3703 | 3696 | ||
3704 | /** | 3697 | /** |
@@ -3764,7 +3757,23 @@ next_sg: | |||
3764 | /* don't cross page boundaries */ | 3757 | /* don't cross page boundaries */ |
3765 | count = min(count, (unsigned int)PAGE_SIZE - offset); | 3758 | count = min(count, (unsigned int)PAGE_SIZE - offset); |
3766 | 3759 | ||
3767 | buf = kmap(page) + offset; | 3760 | DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); |
3761 | |||
3762 | if (PageHighMem(page)) { | ||
3763 | unsigned long flags; | ||
3764 | |||
3765 | local_irq_save(flags); | ||
3766 | buf = kmap_atomic(page, KM_IRQ0); | ||
3767 | |||
3768 | /* do the actual data transfer */ | ||
3769 | ata_data_xfer(ap, buf + offset, count, do_write); | ||
3770 | |||
3771 | kunmap_atomic(buf, KM_IRQ0); | ||
3772 | local_irq_restore(flags); | ||
3773 | } else { | ||
3774 | buf = page_address(page); | ||
3775 | ata_data_xfer(ap, buf + offset, count, do_write); | ||
3776 | } | ||
3768 | 3777 | ||
3769 | bytes -= count; | 3778 | bytes -= count; |
3770 | qc->curbytes += count; | 3779 | qc->curbytes += count; |
@@ -3775,13 +3784,6 @@ next_sg: | |||
3775 | qc->cursg_ofs = 0; | 3784 | qc->cursg_ofs = 0; |
3776 | } | 3785 | } |
3777 | 3786 | ||
3778 | DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); | ||
3779 | |||
3780 | /* do the actual data transfer */ | ||
3781 | ata_data_xfer(ap, buf, count, do_write); | ||
3782 | |||
3783 | kunmap(page); | ||
3784 | |||
3785 | if (bytes) | 3787 | if (bytes) |
3786 | goto next_sg; | 3788 | goto next_sg; |
3787 | } | 3789 | } |
@@ -3818,6 +3820,8 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc) | |||
3818 | if (do_write != i_write) | 3820 | if (do_write != i_write) |
3819 | goto err_out; | 3821 | goto err_out; |
3820 | 3822 | ||
3823 | VPRINTK("ata%u: xfering %d bytes\n", ap->id, bytes); | ||
3824 | |||
3821 | __atapi_pio_bytes(qc, bytes); | 3825 | __atapi_pio_bytes(qc, bytes); |
3822 | 3826 | ||
3823 | return; | 3827 | return; |
@@ -3830,187 +3834,297 @@ err_out: | |||
3830 | } | 3834 | } |
3831 | 3835 | ||
3832 | /** | 3836 | /** |
3833 | * ata_pio_block - start PIO on a block | 3837 | * ata_hsm_ok_in_wq - Check if the qc can be handled in the workqueue. |
3834 | * @qc: qc to transfer block for | 3838 | * @ap: the target ata_port |
3839 | * @qc: qc on going | ||
3835 | * | 3840 | * |
3836 | * LOCKING: | 3841 | * RETURNS: |
3837 | * None. (executing in kernel thread context) | 3842 | * 1 if ok in workqueue, 0 otherwise. |
3838 | */ | 3843 | */ |
3839 | static void ata_pio_block(struct ata_queued_cmd *qc) | 3844 | |
3845 | static inline int ata_hsm_ok_in_wq(struct ata_port *ap, struct ata_queued_cmd *qc) | ||
3840 | { | 3846 | { |
3841 | struct ata_port *ap = qc->ap; | 3847 | if (qc->tf.flags & ATA_TFLAG_POLLING) |
3842 | u8 status; | 3848 | return 1; |
3843 | 3849 | ||
3844 | /* | 3850 | if (ap->hsm_task_state == HSM_ST_FIRST) { |
3845 | * This is purely heuristic. This is a fast path. | 3851 | if (qc->tf.protocol == ATA_PROT_PIO && |
3846 | * Sometimes when we enter, BSY will be cleared in | 3852 | (qc->tf.flags & ATA_TFLAG_WRITE)) |
3847 | * a chk-status or two. If not, the drive is probably seeking | 3853 | return 1; |
3848 | * or something. Snooze for a couple msecs, then | ||
3849 | * chk-status again. If still busy, fall back to | ||
3850 | * HSM_ST_POLL state. | ||
3851 | */ | ||
3852 | status = ata_busy_wait(ap, ATA_BUSY, 5); | ||
3853 | if (status & ATA_BUSY) { | ||
3854 | msleep(2); | ||
3855 | status = ata_busy_wait(ap, ATA_BUSY, 10); | ||
3856 | if (status & ATA_BUSY) { | ||
3857 | ap->hsm_task_state = HSM_ST_POLL; | ||
3858 | ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO; | ||
3859 | return; | ||
3860 | } | ||
3861 | } | ||
3862 | 3854 | ||
3863 | /* check error */ | 3855 | if (is_atapi_taskfile(&qc->tf) && |
3864 | if (status & (ATA_ERR | ATA_DF)) { | 3856 | !(qc->dev->flags & ATA_DFLAG_CDB_INTR)) |
3865 | qc->err_mask |= AC_ERR_DEV; | 3857 | return 1; |
3866 | ap->hsm_task_state = HSM_ST_ERR; | ||
3867 | return; | ||
3868 | } | 3858 | } |
3869 | 3859 | ||
3870 | /* transfer data if any */ | 3860 | return 0; |
3871 | if (is_atapi_taskfile(&qc->tf)) { | 3861 | } |
3872 | /* DRQ=0 means no more data to transfer */ | ||
3873 | if ((status & ATA_DRQ) == 0) { | ||
3874 | ap->hsm_task_state = HSM_ST_LAST; | ||
3875 | return; | ||
3876 | } | ||
3877 | 3862 | ||
3878 | atapi_pio_bytes(qc); | 3863 | /** |
3879 | } else { | 3864 | * ata_hsm_move - move the HSM to the next state. |
3880 | /* handle BSY=0, DRQ=0 as error */ | 3865 | * @ap: the target ata_port |
3881 | if ((status & ATA_DRQ) == 0) { | 3866 | * @qc: qc on going |
3867 | * @status: current device status | ||
3868 | * @in_wq: 1 if called from workqueue, 0 otherwise | ||
3869 | * | ||
3870 | * RETURNS: | ||
3871 | * 1 when poll next status needed, 0 otherwise. | ||
3872 | */ | ||
3873 | |||
3874 | static int ata_hsm_move(struct ata_port *ap, struct ata_queued_cmd *qc, | ||
3875 | u8 status, int in_wq) | ||
3876 | { | ||
3877 | unsigned long flags = 0; | ||
3878 | int poll_next; | ||
3879 | |||
3880 | WARN_ON((qc->flags & ATA_QCFLAG_ACTIVE) == 0); | ||
3881 | |||
3882 | /* Make sure ata_qc_issue_prot() does not throw things | ||
3883 | * like DMA polling into the workqueue. Notice that | ||
3884 | * in_wq is not equivalent to (qc->tf.flags & ATA_TFLAG_POLLING). | ||
3885 | */ | ||
3886 | WARN_ON(in_wq != ata_hsm_ok_in_wq(ap, qc)); | ||
3887 | |||
3888 | fsm_start: | ||
3889 | DPRINTK("ata%u: protocol %d task_state %d (dev_stat 0x%X)\n", | ||
3890 | ap->id, qc->tf.protocol, ap->hsm_task_state, status); | ||
3891 | |||
3892 | switch (ap->hsm_task_state) { | ||
3893 | case HSM_ST_FIRST: | ||
3894 | /* Send first data block or PACKET CDB */ | ||
3895 | |||
3896 | /* If polling, we will stay in the work queue after | ||
3897 | * sending the data. Otherwise, interrupt handler | ||
3898 | * takes over after sending the data. | ||
3899 | */ | ||
3900 | poll_next = (qc->tf.flags & ATA_TFLAG_POLLING); | ||
3901 | |||
3902 | /* check device status */ | ||
3903 | if (unlikely((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ)) { | ||
3904 | /* Wrong status. Let EH handle this */ | ||
3882 | qc->err_mask |= AC_ERR_HSM; | 3905 | qc->err_mask |= AC_ERR_HSM; |
3883 | ap->hsm_task_state = HSM_ST_ERR; | 3906 | ap->hsm_task_state = HSM_ST_ERR; |
3884 | return; | 3907 | goto fsm_start; |
3885 | } | 3908 | } |
3886 | 3909 | ||
3887 | ata_pio_sector(qc); | 3910 | /* Device should not ask for data transfer (DRQ=1) |
3888 | } | 3911 | * when it finds something wrong. |
3889 | } | 3912 | * We ignore DRQ here and stop the HSM by |
3913 | * changing hsm_task_state to HSM_ST_ERR and | ||
3914 | * let the EH abort the command or reset the device. | ||
3915 | */ | ||
3916 | if (unlikely(status & (ATA_ERR | ATA_DF))) { | ||
3917 | printk(KERN_WARNING "ata%d: DRQ=1 with device error, dev_stat 0x%X\n", | ||
3918 | ap->id, status); | ||
3919 | qc->err_mask |= AC_ERR_DEV; | ||
3920 | ap->hsm_task_state = HSM_ST_ERR; | ||
3921 | goto fsm_start; | ||
3922 | } | ||
3890 | 3923 | ||
3891 | static void ata_pio_error(struct ata_queued_cmd *qc) | 3924 | /* Send the CDB (atapi) or the first data block (ata pio out). |
3892 | { | 3925 | * During the state transition, interrupt handler shouldn't |
3893 | struct ata_port *ap = qc->ap; | 3926 | * be invoked before the data transfer is complete and |
3927 | * hsm_task_state is changed. Hence, the following locking. | ||
3928 | */ | ||
3929 | if (in_wq) | ||
3930 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
3894 | 3931 | ||
3895 | if (qc->tf.command != ATA_CMD_PACKET) | 3932 | if (qc->tf.protocol == ATA_PROT_PIO) { |
3896 | printk(KERN_WARNING "ata%u: dev %u PIO error\n", | 3933 | /* PIO data out protocol. |
3897 | ap->id, qc->dev->devno); | 3934 | * send first data block. |
3935 | */ | ||
3898 | 3936 | ||
3899 | /* make sure qc->err_mask is available to | 3937 | /* ata_pio_sectors() might change the state |
3900 | * know what's wrong and recover | 3938 | * to HSM_ST_LAST. so, the state is changed here |
3901 | */ | 3939 | * before ata_pio_sectors(). |
3902 | WARN_ON(qc->err_mask == 0); | 3940 | */ |
3941 | ap->hsm_task_state = HSM_ST; | ||
3942 | ata_pio_sectors(qc); | ||
3943 | ata_altstatus(ap); /* flush */ | ||
3944 | } else | ||
3945 | /* send CDB */ | ||
3946 | atapi_send_cdb(ap, qc); | ||
3947 | |||
3948 | if (in_wq) | ||
3949 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
3950 | |||
3951 | /* if polling, ata_pio_task() handles the rest. | ||
3952 | * otherwise, interrupt handler takes over from here. | ||
3953 | */ | ||
3954 | break; | ||
3903 | 3955 | ||
3904 | ap->hsm_task_state = HSM_ST_IDLE; | 3956 | case HSM_ST: |
3957 | /* complete command or read/write the data register */ | ||
3958 | if (qc->tf.protocol == ATA_PROT_ATAPI) { | ||
3959 | /* ATAPI PIO protocol */ | ||
3960 | if ((status & ATA_DRQ) == 0) { | ||
3961 | /* no more data to transfer */ | ||
3962 | ap->hsm_task_state = HSM_ST_LAST; | ||
3963 | goto fsm_start; | ||
3964 | } | ||
3905 | 3965 | ||
3906 | ata_poll_qc_complete(qc); | 3966 | /* Device should not ask for data transfer (DRQ=1) |
3907 | } | 3967 | * when it finds something wrong. |
3968 | * We ignore DRQ here and stop the HSM by | ||
3969 | * changing hsm_task_state to HSM_ST_ERR and | ||
3970 | * let the EH abort the command or reset the device. | ||
3971 | */ | ||
3972 | if (unlikely(status & (ATA_ERR | ATA_DF))) { | ||
3973 | printk(KERN_WARNING "ata%d: DRQ=1 with device error, dev_stat 0x%X\n", | ||
3974 | ap->id, status); | ||
3975 | qc->err_mask |= AC_ERR_DEV; | ||
3976 | ap->hsm_task_state = HSM_ST_ERR; | ||
3977 | goto fsm_start; | ||
3978 | } | ||
3908 | 3979 | ||
3909 | static void ata_pio_task(void *_data) | 3980 | atapi_pio_bytes(qc); |
3910 | { | ||
3911 | struct ata_queued_cmd *qc = _data; | ||
3912 | struct ata_port *ap = qc->ap; | ||
3913 | unsigned long timeout; | ||
3914 | int qc_completed; | ||
3915 | 3981 | ||
3916 | fsm_start: | 3982 | if (unlikely(ap->hsm_task_state == HSM_ST_ERR)) |
3917 | timeout = 0; | 3983 | /* bad ireason reported by device */ |
3918 | qc_completed = 0; | 3984 | goto fsm_start; |
3919 | 3985 | ||
3920 | switch (ap->hsm_task_state) { | 3986 | } else { |
3921 | case HSM_ST_IDLE: | 3987 | /* ATA PIO protocol */ |
3922 | return; | 3988 | if (unlikely((status & ATA_DRQ) == 0)) { |
3989 | /* handle BSY=0, DRQ=0 as error */ | ||
3990 | qc->err_mask |= AC_ERR_HSM; | ||
3991 | ap->hsm_task_state = HSM_ST_ERR; | ||
3992 | goto fsm_start; | ||
3993 | } | ||
3923 | 3994 | ||
3924 | case HSM_ST: | 3995 | /* For PIO reads, some devices may ask for |
3925 | ata_pio_block(qc); | 3996 | * data transfer (DRQ=1) alone with ERR=1. |
3997 | * We respect DRQ here and transfer one | ||
3998 | * block of junk data before changing the | ||
3999 | * hsm_task_state to HSM_ST_ERR. | ||
4000 | * | ||
4001 | * For PIO writes, ERR=1 DRQ=1 doesn't make | ||
4002 | * sense since the data block has been | ||
4003 | * transferred to the device. | ||
4004 | */ | ||
4005 | if (unlikely(status & (ATA_ERR | ATA_DF))) { | ||
4006 | /* data might be corrputed */ | ||
4007 | qc->err_mask |= AC_ERR_DEV; | ||
4008 | |||
4009 | if (!(qc->tf.flags & ATA_TFLAG_WRITE)) { | ||
4010 | ata_pio_sectors(qc); | ||
4011 | ata_altstatus(ap); | ||
4012 | status = ata_wait_idle(ap); | ||
4013 | } | ||
4014 | |||
4015 | /* ata_pio_sectors() might change the | ||
4016 | * state to HSM_ST_LAST. so, the state | ||
4017 | * is changed after ata_pio_sectors(). | ||
4018 | */ | ||
4019 | ap->hsm_task_state = HSM_ST_ERR; | ||
4020 | goto fsm_start; | ||
4021 | } | ||
4022 | |||
4023 | ata_pio_sectors(qc); | ||
4024 | |||
4025 | if (ap->hsm_task_state == HSM_ST_LAST && | ||
4026 | (!(qc->tf.flags & ATA_TFLAG_WRITE))) { | ||
4027 | /* all data read */ | ||
4028 | ata_altstatus(ap); | ||
4029 | status = ata_wait_idle(ap); | ||
4030 | goto fsm_start; | ||
4031 | } | ||
4032 | } | ||
4033 | |||
4034 | ata_altstatus(ap); /* flush */ | ||
4035 | poll_next = 1; | ||
3926 | break; | 4036 | break; |
3927 | 4037 | ||
3928 | case HSM_ST_LAST: | 4038 | case HSM_ST_LAST: |
3929 | qc_completed = ata_pio_complete(qc); | 4039 | if (unlikely(!ata_ok(status))) { |
3930 | break; | 4040 | qc->err_mask |= __ac_err_mask(status); |
4041 | ap->hsm_task_state = HSM_ST_ERR; | ||
4042 | goto fsm_start; | ||
4043 | } | ||
4044 | |||
4045 | /* no more data to transfer */ | ||
4046 | DPRINTK("ata%u: command complete, drv_stat 0x%x\n", | ||
4047 | ap->id, status); | ||
4048 | |||
4049 | WARN_ON(qc->err_mask); | ||
4050 | |||
4051 | ap->hsm_task_state = HSM_ST_IDLE; | ||
3931 | 4052 | ||
3932 | case HSM_ST_POLL: | 4053 | /* complete taskfile transaction */ |
3933 | case HSM_ST_LAST_POLL: | 4054 | if (in_wq) |
3934 | timeout = ata_pio_poll(qc); | 4055 | ata_poll_qc_complete(qc); |
4056 | else | ||
4057 | ata_qc_complete(qc); | ||
4058 | |||
4059 | poll_next = 0; | ||
3935 | break; | 4060 | break; |
3936 | 4061 | ||
3937 | case HSM_ST_TMOUT: | ||
3938 | case HSM_ST_ERR: | 4062 | case HSM_ST_ERR: |
3939 | ata_pio_error(qc); | 4063 | if (qc->tf.command != ATA_CMD_PACKET) |
3940 | return; | 4064 | printk(KERN_ERR "ata%u: command error, drv_stat 0x%x\n", |
4065 | ap->id, status); | ||
4066 | |||
4067 | /* make sure qc->err_mask is available to | ||
4068 | * know what's wrong and recover | ||
4069 | */ | ||
4070 | WARN_ON(qc->err_mask == 0); | ||
4071 | |||
4072 | ap->hsm_task_state = HSM_ST_IDLE; | ||
4073 | |||
4074 | /* complete taskfile transaction */ | ||
4075 | if (in_wq) | ||
4076 | ata_poll_qc_complete(qc); | ||
4077 | else | ||
4078 | ata_qc_complete(qc); | ||
4079 | |||
4080 | poll_next = 0; | ||
4081 | break; | ||
4082 | default: | ||
4083 | poll_next = 0; | ||
4084 | BUG(); | ||
3941 | } | 4085 | } |
3942 | 4086 | ||
3943 | if (timeout) | 4087 | return poll_next; |
3944 | ata_port_queue_task(ap, ata_pio_task, qc, timeout); | ||
3945 | else if (!qc_completed) | ||
3946 | goto fsm_start; | ||
3947 | } | 4088 | } |
3948 | 4089 | ||
3949 | /** | 4090 | static void ata_pio_task(void *_data) |
3950 | * atapi_packet_task - Write CDB bytes to hardware | ||
3951 | * @_data: qc in progress | ||
3952 | * | ||
3953 | * When device has indicated its readiness to accept | ||
3954 | * a CDB, this function is called. Send the CDB. | ||
3955 | * If DMA is to be performed, exit immediately. | ||
3956 | * Otherwise, we are in polling mode, so poll | ||
3957 | * status under operation succeeds or fails. | ||
3958 | * | ||
3959 | * LOCKING: | ||
3960 | * Kernel thread context (may sleep) | ||
3961 | */ | ||
3962 | static void atapi_packet_task(void *_data) | ||
3963 | { | 4091 | { |
3964 | struct ata_queued_cmd *qc = _data; | 4092 | struct ata_queued_cmd *qc = _data; |
3965 | struct ata_port *ap = qc->ap; | 4093 | struct ata_port *ap = qc->ap; |
3966 | u8 status; | 4094 | u8 status; |
4095 | int poll_next; | ||
3967 | 4096 | ||
3968 | /* sleep-wait for BSY to clear */ | 4097 | fsm_start: |
3969 | DPRINTK("busy wait\n"); | 4098 | WARN_ON(ap->hsm_task_state == HSM_ST_IDLE); |
3970 | if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) { | ||
3971 | qc->err_mask |= AC_ERR_TIMEOUT; | ||
3972 | goto err_out; | ||
3973 | } | ||
3974 | |||
3975 | /* make sure DRQ is set */ | ||
3976 | status = ata_chk_status(ap); | ||
3977 | if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) { | ||
3978 | qc->err_mask |= AC_ERR_HSM; | ||
3979 | goto err_out; | ||
3980 | } | ||
3981 | |||
3982 | /* send SCSI cdb */ | ||
3983 | DPRINTK("send cdb\n"); | ||
3984 | WARN_ON(qc->dev->cdb_len < 12); | ||
3985 | |||
3986 | if (qc->tf.protocol == ATA_PROT_ATAPI_DMA || | ||
3987 | qc->tf.protocol == ATA_PROT_ATAPI_NODATA) { | ||
3988 | unsigned long flags; | ||
3989 | 4099 | ||
3990 | /* Once we're done issuing command and kicking bmdma, | 4100 | qc = ata_qc_from_tag(ap, ap->active_tag); |
3991 | * irq handler takes over. To not lose irq, we need | 4101 | WARN_ON(qc == NULL); |
3992 | * to clear NOINTR flag before sending cdb, but | ||
3993 | * interrupt handler shouldn't be invoked before we're | ||
3994 | * finished. Hence, the following locking. | ||
3995 | */ | ||
3996 | spin_lock_irqsave(&ap->host_set->lock, flags); | ||
3997 | ap->flags &= ~ATA_FLAG_NOINTR; | ||
3998 | ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1); | ||
3999 | if (qc->tf.protocol == ATA_PROT_ATAPI_DMA) | ||
4000 | ap->ops->bmdma_start(qc); /* initiate bmdma */ | ||
4001 | spin_unlock_irqrestore(&ap->host_set->lock, flags); | ||
4002 | } else { | ||
4003 | ata_data_xfer(ap, qc->cdb, qc->dev->cdb_len, 1); | ||
4004 | 4102 | ||
4005 | /* PIO commands are handled by polling */ | 4103 | /* |
4006 | ap->hsm_task_state = HSM_ST; | 4104 | * This is purely heuristic. This is a fast path. |
4007 | ata_port_queue_task(ap, ata_pio_task, qc, 0); | 4105 | * Sometimes when we enter, BSY will be cleared in |
4106 | * a chk-status or two. If not, the drive is probably seeking | ||
4107 | * or something. Snooze for a couple msecs, then | ||
4108 | * chk-status again. If still busy, queue delayed work. | ||
4109 | */ | ||
4110 | status = ata_busy_wait(ap, ATA_BUSY, 5); | ||
4111 | if (status & ATA_BUSY) { | ||
4112 | msleep(2); | ||
4113 | status = ata_busy_wait(ap, ATA_BUSY, 10); | ||
4114 | if (status & ATA_BUSY) { | ||
4115 | ata_port_queue_task(ap, ata_pio_task, ap, ATA_SHORT_PAUSE); | ||
4116 | return; | ||
4117 | } | ||
4008 | } | 4118 | } |
4009 | 4119 | ||
4010 | return; | 4120 | /* move the HSM */ |
4121 | poll_next = ata_hsm_move(ap, qc, status, 1); | ||
4011 | 4122 | ||
4012 | err_out: | 4123 | /* another command or interrupt handler |
4013 | ata_poll_qc_complete(qc); | 4124 | * may be running at this point. |
4125 | */ | ||
4126 | if (poll_next) | ||
4127 | goto fsm_start; | ||
4014 | } | 4128 | } |
4015 | 4129 | ||
4016 | /** | 4130 | /** |
@@ -4200,43 +4314,105 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc) | |||
4200 | { | 4314 | { |
4201 | struct ata_port *ap = qc->ap; | 4315 | struct ata_port *ap = qc->ap; |
4202 | 4316 | ||
4317 | /* Use polling pio if the LLD doesn't handle | ||
4318 | * interrupt driven pio and atapi CDB interrupt. | ||
4319 | */ | ||
4320 | if (ap->flags & ATA_FLAG_PIO_POLLING) { | ||
4321 | switch (qc->tf.protocol) { | ||
4322 | case ATA_PROT_PIO: | ||
4323 | case ATA_PROT_ATAPI: | ||
4324 | case ATA_PROT_ATAPI_NODATA: | ||
4325 | qc->tf.flags |= ATA_TFLAG_POLLING; | ||
4326 | break; | ||
4327 | case ATA_PROT_ATAPI_DMA: | ||
4328 | if (qc->dev->flags & ATA_DFLAG_CDB_INTR) | ||
4329 | /* see ata_check_atapi_dma() */ | ||
4330 | BUG(); | ||
4331 | break; | ||
4332 | default: | ||
4333 | break; | ||
4334 | } | ||
4335 | } | ||
4336 | |||
4337 | /* select the device */ | ||
4203 | ata_dev_select(ap, qc->dev->devno, 1, 0); | 4338 | ata_dev_select(ap, qc->dev->devno, 1, 0); |
4204 | 4339 | ||
4340 | /* start the command */ | ||
4205 | switch (qc->tf.protocol) { | 4341 | switch (qc->tf.protocol) { |
4206 | case ATA_PROT_NODATA: | 4342 | case ATA_PROT_NODATA: |
4343 | if (qc->tf.flags & ATA_TFLAG_POLLING) | ||
4344 | ata_qc_set_polling(qc); | ||
4345 | |||
4207 | ata_tf_to_host(ap, &qc->tf); | 4346 | ata_tf_to_host(ap, &qc->tf); |
4347 | ap->hsm_task_state = HSM_ST_LAST; | ||
4348 | |||
4349 | if (qc->tf.flags & ATA_TFLAG_POLLING) | ||
4350 | ata_port_queue_task(ap, ata_pio_task, ap, 0); | ||
4351 | |||
4208 | break; | 4352 | break; |
4209 | 4353 | ||
4210 | case ATA_PROT_DMA: | 4354 | case ATA_PROT_DMA: |
4355 | WARN_ON(qc->tf.flags & ATA_TFLAG_POLLING); | ||
4356 | |||
4211 | ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ | 4357 | ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ |
4212 | ap->ops->bmdma_setup(qc); /* set up bmdma */ | 4358 | ap->ops->bmdma_setup(qc); /* set up bmdma */ |
4213 | ap->ops->bmdma_start(qc); /* initiate bmdma */ | 4359 | ap->ops->bmdma_start(qc); /* initiate bmdma */ |
4360 | ap->hsm_task_state = HSM_ST_LAST; | ||
4214 | break; | 4361 | break; |
4215 | 4362 | ||
4216 | case ATA_PROT_PIO: /* load tf registers, initiate polling pio */ | 4363 | case ATA_PROT_PIO: |
4217 | ata_qc_set_polling(qc); | 4364 | if (qc->tf.flags & ATA_TFLAG_POLLING) |
4218 | ata_tf_to_host(ap, &qc->tf); | 4365 | ata_qc_set_polling(qc); |
4219 | ap->hsm_task_state = HSM_ST; | ||
4220 | ata_port_queue_task(ap, ata_pio_task, qc, 0); | ||
4221 | break; | ||
4222 | 4366 | ||
4223 | case ATA_PROT_ATAPI: | ||
4224 | ata_qc_set_polling(qc); | ||
4225 | ata_tf_to_host(ap, &qc->tf); | 4367 | ata_tf_to_host(ap, &qc->tf); |
4226 | ata_port_queue_task(ap, atapi_packet_task, qc, 0); | 4368 | |
4369 | if (qc->tf.flags & ATA_TFLAG_WRITE) { | ||
4370 | /* PIO data out protocol */ | ||
4371 | ap->hsm_task_state = HSM_ST_FIRST; | ||
4372 | ata_port_queue_task(ap, ata_pio_task, ap, 0); | ||
4373 | |||
4374 | /* always send first data block using | ||
4375 | * the ata_pio_task() codepath. | ||
4376 | */ | ||
4377 | } else { | ||
4378 | /* PIO data in protocol */ | ||
4379 | ap->hsm_task_state = HSM_ST; | ||
4380 | |||
4381 | if (qc->tf.flags & ATA_TFLAG_POLLING) | ||
4382 | ata_port_queue_task(ap, ata_pio_task, ap, 0); | ||
4383 | |||
4384 | /* if polling, ata_pio_task() handles the rest. | ||
4385 | * otherwise, interrupt handler takes over from here. | ||
4386 | */ | ||
4387 | } | ||
4388 | |||
4227 | break; | 4389 | break; |
4228 | 4390 | ||
4391 | case ATA_PROT_ATAPI: | ||
4229 | case ATA_PROT_ATAPI_NODATA: | 4392 | case ATA_PROT_ATAPI_NODATA: |
4230 | ap->flags |= ATA_FLAG_NOINTR; | 4393 | if (qc->tf.flags & ATA_TFLAG_POLLING) |
4394 | ata_qc_set_polling(qc); | ||
4395 | |||
4231 | ata_tf_to_host(ap, &qc->tf); | 4396 | ata_tf_to_host(ap, &qc->tf); |
4232 | ata_port_queue_task(ap, atapi_packet_task, qc, 0); | 4397 | |
4398 | ap->hsm_task_state = HSM_ST_FIRST; | ||
4399 | |||
4400 | /* send cdb by polling if no cdb interrupt */ | ||
4401 | if ((!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) || | ||
4402 | (qc->tf.flags & ATA_TFLAG_POLLING)) | ||
4403 | ata_port_queue_task(ap, ata_pio_task, ap, 0); | ||
4233 | break; | 4404 | break; |
4234 | 4405 | ||
4235 | case ATA_PROT_ATAPI_DMA: | 4406 | case ATA_PROT_ATAPI_DMA: |
4236 | ap->flags |= ATA_FLAG_NOINTR; | 4407 | WARN_ON(qc->tf.flags & ATA_TFLAG_POLLING); |
4408 | |||
4237 | ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ | 4409 | ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ |
4238 | ap->ops->bmdma_setup(qc); /* set up bmdma */ | 4410 | ap->ops->bmdma_setup(qc); /* set up bmdma */ |
4239 | ata_port_queue_task(ap, atapi_packet_task, qc, 0); | 4411 | ap->hsm_task_state = HSM_ST_FIRST; |
4412 | |||
4413 | /* send cdb by polling if no cdb interrupt */ | ||
4414 | if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) | ||
4415 | ata_port_queue_task(ap, ata_pio_task, ap, 0); | ||
4240 | break; | 4416 | break; |
4241 | 4417 | ||
4242 | default: | 4418 | default: |
@@ -4266,52 +4442,66 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc) | |||
4266 | inline unsigned int ata_host_intr (struct ata_port *ap, | 4442 | inline unsigned int ata_host_intr (struct ata_port *ap, |
4267 | struct ata_queued_cmd *qc) | 4443 | struct ata_queued_cmd *qc) |
4268 | { | 4444 | { |
4269 | u8 status, host_stat; | 4445 | u8 status, host_stat = 0; |
4270 | |||
4271 | switch (qc->tf.protocol) { | ||
4272 | 4446 | ||
4273 | case ATA_PROT_DMA: | 4447 | VPRINTK("ata%u: protocol %d task_state %d\n", |
4274 | case ATA_PROT_ATAPI_DMA: | 4448 | ap->id, qc->tf.protocol, ap->hsm_task_state); |
4275 | case ATA_PROT_ATAPI: | ||
4276 | /* check status of DMA engine */ | ||
4277 | host_stat = ap->ops->bmdma_status(ap); | ||
4278 | VPRINTK("ata%u: host_stat 0x%X\n", ap->id, host_stat); | ||
4279 | |||
4280 | /* if it's not our irq... */ | ||
4281 | if (!(host_stat & ATA_DMA_INTR)) | ||
4282 | goto idle_irq; | ||
4283 | |||
4284 | /* before we do anything else, clear DMA-Start bit */ | ||
4285 | ap->ops->bmdma_stop(qc); | ||
4286 | 4449 | ||
4287 | /* fall through */ | 4450 | /* Check whether we are expecting interrupt in this state */ |
4288 | 4451 | switch (ap->hsm_task_state) { | |
4289 | case ATA_PROT_ATAPI_NODATA: | 4452 | case HSM_ST_FIRST: |
4290 | case ATA_PROT_NODATA: | 4453 | /* Some pre-ATAPI-4 devices assert INTRQ |
4291 | /* check altstatus */ | 4454 | * at this state when ready to receive CDB. |
4292 | status = ata_altstatus(ap); | 4455 | */ |
4293 | if (status & ATA_BUSY) | ||
4294 | goto idle_irq; | ||
4295 | 4456 | ||
4296 | /* check main status, clearing INTRQ */ | 4457 | /* Check the ATA_DFLAG_CDB_INTR flag is enough here. |
4297 | status = ata_chk_status(ap); | 4458 | * The flag was turned on only for atapi devices. |
4298 | if (unlikely(status & ATA_BUSY)) | 4459 | * No need to check is_atapi_taskfile(&qc->tf) again. |
4460 | */ | ||
4461 | if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) | ||
4299 | goto idle_irq; | 4462 | goto idle_irq; |
4300 | DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n", | ||
4301 | ap->id, qc->tf.protocol, status); | ||
4302 | |||
4303 | /* ack bmdma irq events */ | ||
4304 | ap->ops->irq_clear(ap); | ||
4305 | |||
4306 | /* complete taskfile transaction */ | ||
4307 | qc->err_mask |= ac_err_mask(status); | ||
4308 | ata_qc_complete(qc); | ||
4309 | break; | 4463 | break; |
4310 | 4464 | case HSM_ST_LAST: | |
4465 | if (qc->tf.protocol == ATA_PROT_DMA || | ||
4466 | qc->tf.protocol == ATA_PROT_ATAPI_DMA) { | ||
4467 | /* check status of DMA engine */ | ||
4468 | host_stat = ap->ops->bmdma_status(ap); | ||
4469 | VPRINTK("ata%u: host_stat 0x%X\n", ap->id, host_stat); | ||
4470 | |||
4471 | /* if it's not our irq... */ | ||
4472 | if (!(host_stat & ATA_DMA_INTR)) | ||
4473 | goto idle_irq; | ||
4474 | |||
4475 | /* before we do anything else, clear DMA-Start bit */ | ||
4476 | ap->ops->bmdma_stop(qc); | ||
4477 | |||
4478 | if (unlikely(host_stat & ATA_DMA_ERR)) { | ||
4479 | /* error when transfering data to/from memory */ | ||
4480 | qc->err_mask |= AC_ERR_HOST_BUS; | ||
4481 | ap->hsm_task_state = HSM_ST_ERR; | ||
4482 | } | ||
4483 | } | ||
4484 | break; | ||
4485 | case HSM_ST: | ||
4486 | break; | ||
4311 | default: | 4487 | default: |
4312 | goto idle_irq; | 4488 | goto idle_irq; |
4313 | } | 4489 | } |
4314 | 4490 | ||
4491 | /* check altstatus */ | ||
4492 | status = ata_altstatus(ap); | ||
4493 | if (status & ATA_BUSY) | ||
4494 | goto idle_irq; | ||
4495 | |||
4496 | /* check main status, clearing INTRQ */ | ||
4497 | status = ata_chk_status(ap); | ||
4498 | if (unlikely(status & ATA_BUSY)) | ||
4499 | goto idle_irq; | ||
4500 | |||
4501 | /* ack bmdma irq events */ | ||
4502 | ap->ops->irq_clear(ap); | ||
4503 | |||
4504 | ata_hsm_move(ap, qc, status, 0); | ||
4315 | return 1; /* irq handled */ | 4505 | return 1; /* irq handled */ |
4316 | 4506 | ||
4317 | idle_irq: | 4507 | idle_irq: |
@@ -4358,11 +4548,11 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs) | |||
4358 | 4548 | ||
4359 | ap = host_set->ports[i]; | 4549 | ap = host_set->ports[i]; |
4360 | if (ap && | 4550 | if (ap && |
4361 | !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) { | 4551 | !(ap->flags & ATA_FLAG_DISABLED)) { |
4362 | struct ata_queued_cmd *qc; | 4552 | struct ata_queued_cmd *qc; |
4363 | 4553 | ||
4364 | qc = ata_qc_from_tag(ap, ap->active_tag); | 4554 | qc = ata_qc_from_tag(ap, ap->active_tag); |
4365 | if (qc && (!(qc->tf.ctl & ATA_NIEN)) && | 4555 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) && |
4366 | (qc->flags & ATA_QCFLAG_ACTIVE)) | 4556 | (qc->flags & ATA_QCFLAG_ACTIVE)) |
4367 | handled |= ata_host_intr(ap, qc); | 4557 | handled |= ata_host_intr(ap, qc); |
4368 | } | 4558 | } |
diff --git a/drivers/scsi/libata-eh.c b/drivers/scsi/libata-eh.c index e73f5612ae..011e083b19 100644 --- a/drivers/scsi/libata-eh.c +++ b/drivers/scsi/libata-eh.c | |||
@@ -137,6 +137,7 @@ int ata_scsi_error(struct Scsi_Host *host) | |||
137 | * LOCKING: | 137 | * LOCKING: |
138 | * Inherited from SCSI layer (none, can sleep) | 138 | * Inherited from SCSI layer (none, can sleep) |
139 | */ | 139 | */ |
140 | |||
140 | static void ata_qc_timeout(struct ata_queued_cmd *qc) | 141 | static void ata_qc_timeout(struct ata_queued_cmd *qc) |
141 | { | 142 | { |
142 | struct ata_port *ap = qc->ap; | 143 | struct ata_port *ap = qc->ap; |
@@ -171,8 +172,10 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc) | |||
171 | printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x host_stat 0x%x\n", | 172 | printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x host_stat 0x%x\n", |
172 | ap->id, qc->tf.command, drv_stat, host_stat); | 173 | ap->id, qc->tf.command, drv_stat, host_stat); |
173 | 174 | ||
175 | ap->hsm_task_state = HSM_ST_IDLE; | ||
176 | |||
174 | /* complete taskfile transaction */ | 177 | /* complete taskfile transaction */ |
175 | qc->err_mask |= ac_err_mask(drv_stat); | 178 | qc->err_mask |= AC_ERR_TIMEOUT; |
176 | break; | 179 | break; |
177 | } | 180 | } |
178 | 181 | ||
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c index d64073dd02..a4dcb43522 100644 --- a/drivers/scsi/pdc_adma.c +++ b/drivers/scsi/pdc_adma.c | |||
@@ -456,13 +456,13 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set) | |||
456 | continue; | 456 | continue; |
457 | handled = 1; | 457 | handled = 1; |
458 | adma_enter_reg_mode(ap); | 458 | adma_enter_reg_mode(ap); |
459 | if (ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR)) | 459 | if (ap->flags & ATA_FLAG_DISABLED) |
460 | continue; | 460 | continue; |
461 | pp = ap->private_data; | 461 | pp = ap->private_data; |
462 | if (!pp || pp->state != adma_state_pkt) | 462 | if (!pp || pp->state != adma_state_pkt) |
463 | continue; | 463 | continue; |
464 | qc = ata_qc_from_tag(ap, ap->active_tag); | 464 | qc = ata_qc_from_tag(ap, ap->active_tag); |
465 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) { | 465 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) { |
466 | if ((status & (aPERR | aPSD | aUIRQ))) | 466 | if ((status & (aPERR | aPSD | aUIRQ))) |
467 | qc->err_mask |= AC_ERR_OTHER; | 467 | qc->err_mask |= AC_ERR_OTHER; |
468 | else if (pp->pkt[0] != cDONE) | 468 | else if (pp->pkt[0] != cDONE) |
@@ -481,13 +481,13 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set) | |||
481 | for (port_no = 0; port_no < host_set->n_ports; ++port_no) { | 481 | for (port_no = 0; port_no < host_set->n_ports; ++port_no) { |
482 | struct ata_port *ap; | 482 | struct ata_port *ap; |
483 | ap = host_set->ports[port_no]; | 483 | ap = host_set->ports[port_no]; |
484 | if (ap && (!(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR)))) { | 484 | if (ap && (!(ap->flags & ATA_FLAG_DISABLED))) { |
485 | struct ata_queued_cmd *qc; | 485 | struct ata_queued_cmd *qc; |
486 | struct adma_port_priv *pp = ap->private_data; | 486 | struct adma_port_priv *pp = ap->private_data; |
487 | if (!pp || pp->state != adma_state_mmio) | 487 | if (!pp || pp->state != adma_state_mmio) |
488 | continue; | 488 | continue; |
489 | qc = ata_qc_from_tag(ap, ap->active_tag); | 489 | qc = ata_qc_from_tag(ap, ap->active_tag); |
490 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) { | 490 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) { |
491 | 491 | ||
492 | /* check main status, clearing INTRQ */ | 492 | /* check main status, clearing INTRQ */ |
493 | u8 status = ata_check_status(ap); | 493 | u8 status = ata_check_status(ap); |
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c index e9152f8500..fd9f2173f0 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), |
@@ -1397,7 +1397,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, | |||
1397 | } | 1397 | } |
1398 | } | 1398 | } |
1399 | 1399 | ||
1400 | if (ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR)) | 1400 | if (ap && (ap->flags & ATA_FLAG_DISABLED)) |
1401 | continue; | 1401 | continue; |
1402 | 1402 | ||
1403 | err_mask = ac_err_mask(ata_status); | 1403 | err_mask = ac_err_mask(ata_status); |
@@ -1418,7 +1418,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant, | |||
1418 | VPRINTK("port %u IRQ found for qc, " | 1418 | VPRINTK("port %u IRQ found for qc, " |
1419 | "ata_status 0x%x\n", port,ata_status); | 1419 | "ata_status 0x%x\n", port,ata_status); |
1420 | /* mark qc status appropriately */ | 1420 | /* mark qc status appropriately */ |
1421 | if (!(qc->tf.ctl & ATA_NIEN)) { | 1421 | if (!(qc->tf.flags & ATA_TFLAG_POLLING)) { |
1422 | qc->err_mask |= err_mask; | 1422 | qc->err_mask |= err_mask; |
1423 | ata_qc_complete(qc); | 1423 | ata_qc_complete(qc); |
1424 | } | 1424 | } |
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c index 72721ac482..be38f328a4 100644 --- a/drivers/scsi/sata_nv.c +++ b/drivers/scsi/sata_nv.c | |||
@@ -280,11 +280,11 @@ static irqreturn_t nv_interrupt (int irq, void *dev_instance, | |||
280 | 280 | ||
281 | ap = host_set->ports[i]; | 281 | ap = host_set->ports[i]; |
282 | if (ap && | 282 | if (ap && |
283 | !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) { | 283 | !(ap->flags & ATA_FLAG_DISABLED)) { |
284 | struct ata_queued_cmd *qc; | 284 | struct ata_queued_cmd *qc; |
285 | 285 | ||
286 | qc = ata_qc_from_tag(ap, ap->active_tag); | 286 | qc = ata_qc_from_tag(ap, ap->active_tag); |
287 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) | 287 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) |
288 | handled += ata_host_intr(ap, qc); | 288 | handled += ata_host_intr(ap, qc); |
289 | else | 289 | else |
290 | // No request pending? Clear interrupt status | 290 | // No request pending? Clear interrupt status |
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c index 9557c7aa45..322525d849 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 | ||
@@ -534,11 +535,11 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r | |||
534 | ap = host_set->ports[i]; | 535 | ap = host_set->ports[i]; |
535 | tmp = mask & (1 << (i + 1)); | 536 | tmp = mask & (1 << (i + 1)); |
536 | if (tmp && ap && | 537 | if (tmp && ap && |
537 | !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) { | 538 | !(ap->flags & ATA_FLAG_DISABLED)) { |
538 | struct ata_queued_cmd *qc; | 539 | struct ata_queued_cmd *qc; |
539 | 540 | ||
540 | qc = ata_qc_from_tag(ap, ap->active_tag); | 541 | qc = ata_qc_from_tag(ap, ap->active_tag); |
541 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) | 542 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) |
542 | handled += pdc_host_intr(ap, qc); | 543 | handled += pdc_host_intr(ap, qc); |
543 | } | 544 | } |
544 | } | 545 | } |
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c index 8ef042a094..f86858962f 100644 --- a/drivers/scsi/sata_qstor.c +++ b/drivers/scsi/sata_qstor.c | |||
@@ -176,7 +176,7 @@ static const struct ata_port_info qs_port_info[] = { | |||
176 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 176 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
177 | ATA_FLAG_SATA_RESET | | 177 | ATA_FLAG_SATA_RESET | |
178 | //FIXME ATA_FLAG_SRST | | 178 | //FIXME ATA_FLAG_SRST | |
179 | ATA_FLAG_MMIO, | 179 | ATA_FLAG_MMIO | ATA_FLAG_PIO_POLLING, |
180 | .pio_mask = 0x10, /* pio4 */ | 180 | .pio_mask = 0x10, /* pio4 */ |
181 | .udma_mask = 0x7f, /* udma0-6 */ | 181 | .udma_mask = 0x7f, /* udma0-6 */ |
182 | .port_ops = &qs_ata_ops, | 182 | .port_ops = &qs_ata_ops, |
@@ -395,14 +395,13 @@ static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set) | |||
395 | DPRINTK("SFF=%08x%08x: sCHAN=%u sHST=%d sDST=%02x\n", | 395 | DPRINTK("SFF=%08x%08x: sCHAN=%u sHST=%d sDST=%02x\n", |
396 | sff1, sff0, port_no, sHST, sDST); | 396 | sff1, sff0, port_no, sHST, sDST); |
397 | handled = 1; | 397 | handled = 1; |
398 | if (ap && !(ap->flags & | 398 | if (ap && !(ap->flags & ATA_FLAG_DISABLED)) { |
399 | (ATA_FLAG_DISABLED|ATA_FLAG_NOINTR))) { | ||
400 | struct ata_queued_cmd *qc; | 399 | struct ata_queued_cmd *qc; |
401 | struct qs_port_priv *pp = ap->private_data; | 400 | struct qs_port_priv *pp = ap->private_data; |
402 | if (!pp || pp->state != qs_state_pkt) | 401 | if (!pp || pp->state != qs_state_pkt) |
403 | continue; | 402 | continue; |
404 | qc = ata_qc_from_tag(ap, ap->active_tag); | 403 | qc = ata_qc_from_tag(ap, ap->active_tag); |
405 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) { | 404 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) { |
406 | switch (sHST) { | 405 | switch (sHST) { |
407 | case 0: /* successful CPB */ | 406 | case 0: /* successful CPB */ |
408 | case 3: /* device error */ | 407 | case 3: /* device error */ |
@@ -429,13 +428,13 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set) | |||
429 | struct ata_port *ap; | 428 | struct ata_port *ap; |
430 | ap = host_set->ports[port_no]; | 429 | ap = host_set->ports[port_no]; |
431 | if (ap && | 430 | if (ap && |
432 | !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) { | 431 | !(ap->flags & ATA_FLAG_DISABLED)) { |
433 | struct ata_queued_cmd *qc; | 432 | struct ata_queued_cmd *qc; |
434 | struct qs_port_priv *pp = ap->private_data; | 433 | struct qs_port_priv *pp = ap->private_data; |
435 | if (!pp || pp->state != qs_state_mmio) | 434 | if (!pp || pp->state != qs_state_mmio) |
436 | continue; | 435 | continue; |
437 | qc = ata_qc_from_tag(ap, ap->active_tag); | 436 | qc = ata_qc_from_tag(ap, ap->active_tag); |
438 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) { | 437 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) { |
439 | 438 | ||
440 | /* check main status, clearing INTRQ */ | 439 | /* check main status, clearing INTRQ */ |
441 | u8 status = ata_check_status(ap); | 440 | u8 status = ata_check_status(ap); |
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c index 3af28ef76f..45c78c399b 100644 --- a/drivers/scsi/sata_sx4.c +++ b/drivers/scsi/sata_sx4.c | |||
@@ -219,7 +219,7 @@ static const struct ata_port_info pdc_port_info[] = { | |||
219 | .sht = &pdc_sata_sht, | 219 | .sht = &pdc_sata_sht, |
220 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | | 220 | .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | |
221 | ATA_FLAG_SRST | ATA_FLAG_MMIO | | 221 | ATA_FLAG_SRST | ATA_FLAG_MMIO | |
222 | ATA_FLAG_NO_ATAPI, | 222 | ATA_FLAG_PIO_POLLING, |
223 | .pio_mask = 0x1f, /* pio0-4 */ | 223 | .pio_mask = 0x1f, /* pio0-4 */ |
224 | .mwdma_mask = 0x07, /* mwdma0-2 */ | 224 | .mwdma_mask = 0x07, /* mwdma0-2 */ |
225 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ | 225 | .udma_mask = 0x7f, /* udma0-6 ; FIXME */ |
@@ -834,11 +834,11 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re | |||
834 | tmp = mask & (1 << i); | 834 | tmp = mask & (1 << i); |
835 | VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp); | 835 | VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp); |
836 | if (tmp && ap && | 836 | if (tmp && ap && |
837 | !(ap->flags & (ATA_FLAG_DISABLED | ATA_FLAG_NOINTR))) { | 837 | !(ap->flags & ATA_FLAG_DISABLED)) { |
838 | struct ata_queued_cmd *qc; | 838 | struct ata_queued_cmd *qc; |
839 | 839 | ||
840 | qc = ata_qc_from_tag(ap, ap->active_tag); | 840 | qc = ata_qc_from_tag(ap, ap->active_tag); |
841 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) | 841 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) |
842 | handled += pdc20621_host_intr(ap, qc, (i > 4), | 842 | handled += pdc20621_host_intr(ap, qc, (i > 4), |
843 | mmio_base); | 843 | mmio_base); |
844 | } | 844 | } |
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c index cecc1f7625..b7d6a31628 100644 --- a/drivers/scsi/sata_vsc.c +++ b/drivers/scsi/sata_vsc.c | |||
@@ -221,14 +221,21 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance, | |||
221 | 221 | ||
222 | ap = host_set->ports[i]; | 222 | ap = host_set->ports[i]; |
223 | 223 | ||
224 | if (ap && !(ap->flags & | 224 | if (is_vsc_sata_int_err(i, int_status)) { |
225 | (ATA_FLAG_DISABLED|ATA_FLAG_NOINTR))) { | 225 | u32 err_status; |
226 | printk(KERN_DEBUG "%s: ignoring interrupt(s)\n", __FUNCTION__); | ||
227 | err_status = ap ? vsc_sata_scr_read(ap, SCR_ERROR) : 0; | ||
228 | vsc_sata_scr_write(ap, SCR_ERROR, err_status); | ||
229 | handled++; | ||
230 | } | ||
231 | |||
232 | if (ap && !(ap->flags & ATA_FLAG_DISABLED)) { | ||
226 | struct ata_queued_cmd *qc; | 233 | struct ata_queued_cmd *qc; |
227 | 234 | ||
228 | qc = ata_qc_from_tag(ap, ap->active_tag); | 235 | qc = ata_qc_from_tag(ap, ap->active_tag); |
229 | if (qc && (!(qc->tf.ctl & ATA_NIEN))) { | 236 | if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) |
230 | handled += ata_host_intr(ap, qc); | 237 | handled += ata_host_intr(ap, qc); |
231 | } else if (is_vsc_sata_int_err(i, int_status)) { | 238 | else if (is_vsc_sata_int_err(i, int_status)) { |
232 | /* | 239 | /* |
233 | * On some chips (i.e. Intel 31244), an error | 240 | * On some chips (i.e. Intel 31244), an error |
234 | * interrupt will sneak in at initialization | 241 | * interrupt will sneak in at initialization |