aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/libata-core.c476
-rw-r--r--drivers/scsi/pdc_adma.c8
-rw-r--r--drivers/scsi/sata_mv.c3
-rw-r--r--drivers/scsi/sata_nv.c4
-rw-r--r--drivers/scsi/sata_promise.c13
-rw-r--r--drivers/scsi/sata_qstor.c11
-rw-r--r--drivers/scsi/sata_sx4.c7
-rw-r--r--drivers/scsi/sata_vsc.c6
8 files changed, 374 insertions, 154 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index f1942545a20d..ce18de9705c4 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -74,6 +74,7 @@ static int ata_choose_xfer_mode(const struct ata_port *ap,
74 u8 *xfer_mode_out, 74 u8 *xfer_mode_out,
75 unsigned int *xfer_shift_out); 75 unsigned int *xfer_shift_out);
76static void __ata_qc_complete(struct ata_queued_cmd *qc); 76static void __ata_qc_complete(struct ata_queued_cmd *qc);
77static void ata_pio_error(struct ata_port *ap);
77 78
78static unsigned int ata_unique_id = 1; 79static unsigned int ata_unique_id = 1;
79static struct workqueue_struct *ata_wq; 80static struct workqueue_struct *ata_wq;
@@ -1276,6 +1277,9 @@ retry:
1276 ap->cdb_len = (unsigned int) rc; 1277 ap->cdb_len = (unsigned int) rc;
1277 ap->host->max_cmd_len = (unsigned char) ap->cdb_len; 1278 ap->host->max_cmd_len = (unsigned char) ap->cdb_len;
1278 1279
1280 if (ata_id_cdb_intr(dev->id))
1281 dev->flags |= ATA_DFLAG_CDB_INTR;
1282
1279 /* print device info to dmesg */ 1283 /* print device info to dmesg */
1280 printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n", 1284 printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n",
1281 ap->id, device, 1285 ap->id, device,
@@ -2725,7 +2729,6 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
2725 unsigned long flags; 2729 unsigned long flags;
2726 2730
2727 spin_lock_irqsave(&ap->host_set->lock, flags); 2731 spin_lock_irqsave(&ap->host_set->lock, flags);
2728 ap->flags &= ~ATA_FLAG_NOINTR;
2729 ata_irq_on(ap); 2732 ata_irq_on(ap);
2730 ata_qc_complete(qc, err_mask); 2733 ata_qc_complete(qc, err_mask);
2731 spin_unlock_irqrestore(&ap->host_set->lock, flags); 2734 spin_unlock_irqrestore(&ap->host_set->lock, flags);
@@ -2989,7 +2992,23 @@ static void ata_pio_sector(struct ata_queued_cmd *qc)
2989 page = nth_page(page, (offset >> PAGE_SHIFT)); 2992 page = nth_page(page, (offset >> PAGE_SHIFT));
2990 offset %= PAGE_SIZE; 2993 offset %= PAGE_SIZE;
2991 2994
2992 buf = kmap(page) + offset; 2995 DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
2996
2997 if (PageHighMem(page)) {
2998 unsigned long flags;
2999
3000 local_irq_save(flags);
3001 buf = kmap_atomic(page, KM_IRQ0);
3002
3003 /* do the actual data transfer */
3004 ata_data_xfer(ap, buf + offset, ATA_SECT_SIZE, do_write);
3005
3006 kunmap_atomic(buf, KM_IRQ0);
3007 local_irq_restore(flags);
3008 } else {
3009 buf = page_address(page);
3010 ata_data_xfer(ap, buf + offset, ATA_SECT_SIZE, do_write);
3011 }
2993 3012
2994 qc->cursect++; 3013 qc->cursect++;
2995 qc->cursg_ofs++; 3014 qc->cursg_ofs++;
@@ -2998,14 +3017,114 @@ static void ata_pio_sector(struct ata_queued_cmd *qc)
2998 qc->cursg++; 3017 qc->cursg++;
2999 qc->cursg_ofs = 0; 3018 qc->cursg_ofs = 0;
3000 } 3019 }
3020}
3001 3021
3002 DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read"); 3022/**
3023 * atapi_send_cdb - Write CDB bytes to hardware
3024 * @ap: Port to which ATAPI device is attached.
3025 * @qc: Taskfile currently active
3026 *
3027 * When device has indicated its readiness to accept
3028 * a CDB, this function is called. Send the CDB.
3029 *
3030 * LOCKING:
3031 * caller.
3032 */
3033
3034static void atapi_send_cdb(struct ata_port *ap, struct ata_queued_cmd *qc)
3035{
3036 /* send SCSI cdb */
3037 DPRINTK("send cdb\n");
3038 assert(ap->cdb_len >= 12);
3039
3040 ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1);
3041 ata_altstatus(ap); /* flush */
3042
3043 switch (qc->tf.protocol) {
3044 case ATA_PROT_ATAPI:
3045 ap->hsm_task_state = HSM_ST;
3046 break;
3047 case ATA_PROT_ATAPI_NODATA:
3048 ap->hsm_task_state = HSM_ST_LAST;
3049 break;
3050 case ATA_PROT_ATAPI_DMA:
3051 ap->hsm_task_state = HSM_ST_LAST;
3052 /* initiate bmdma */
3053 ap->ops->bmdma_start(qc);
3054 break;
3055 }
3056}
3057
3058/**
3059 * ata_dataout_task - Write first data block to hardware
3060 * @_data: Port to which ATA/ATAPI device is attached.
3061 *
3062 * When device has indicated its readiness to accept
3063 * the data, this function sends out the CDB or
3064 * the first data block by PIO.
3065 * After this,
3066 * - If polling, ata_pio_task() handles the rest.
3067 * - Otherwise, interrupt handler takes over.
3068 *
3069 * LOCKING:
3070 * Kernel thread context (may sleep)
3071 */
3072
3073static void ata_dataout_task(void *_data)
3074{
3075 struct ata_port *ap = _data;
3076 struct ata_queued_cmd *qc;
3077 u8 status;
3078 unsigned long flags;
3079
3080 qc = ata_qc_from_tag(ap, ap->active_tag);
3081 assert(qc != NULL);
3082 assert(qc->flags & ATA_QCFLAG_ACTIVE);
3083
3084 /* sleep-wait for BSY to clear */
3085 DPRINTK("busy wait\n");
3086 if (ata_busy_sleep(ap, ATA_TMOUT_DATAOUT_QUICK, ATA_TMOUT_DATAOUT))
3087 goto err_out;
3003 3088
3004 /* do the actual data transfer */ 3089 /* make sure DRQ is set */
3005 do_write = (qc->tf.flags & ATA_TFLAG_WRITE); 3090 status = ata_chk_status(ap);
3006 ata_data_xfer(ap, buf, ATA_SECT_SIZE, do_write); 3091 if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ)
3092 goto err_out;
3093
3094 /* Send the CDB (atapi) or the first data block (ata pio out).
3095 * During the state transition, interrupt handler shouldn't
3096 * be invoked before the data transfer is complete and
3097 * hsm_task_state is changed. Hence, the following locking.
3098 */
3099 spin_lock_irqsave(&ap->host_set->lock, flags);
3100
3101 if (qc->tf.protocol == ATA_PROT_PIO) {
3102 /* PIO data out protocol.
3103 * send first data block.
3104 */
3105
3106 /* ata_pio_sector() might change the state to HSM_ST_LAST.
3107 * so, the state is changed here before ata_pio_sector().
3108 */
3109 ap->hsm_task_state = HSM_ST;
3110 ata_pio_sector(qc);
3111 ata_altstatus(ap); /* flush */
3112 } else
3113 /* send CDB */
3114 atapi_send_cdb(ap, qc);
3115
3116 /* if polling, ata_pio_task() handles the rest.
3117 * otherwise, interrupt handler takes over from here.
3118 */
3119 if (qc->tf.flags & ATA_TFLAG_POLLING)
3120 queue_work(ata_wq, &ap->pio_task);
3121
3122 spin_unlock_irqrestore(&ap->host_set->lock, flags);
3007 3123
3008 kunmap(page); 3124 return;
3125
3126err_out:
3127 ata_pio_error(ap);
3009} 3128}
3010 3129
3011/** 3130/**
@@ -3071,7 +3190,23 @@ next_sg:
3071 /* don't cross page boundaries */ 3190 /* don't cross page boundaries */
3072 count = min(count, (unsigned int)PAGE_SIZE - offset); 3191 count = min(count, (unsigned int)PAGE_SIZE - offset);
3073 3192
3074 buf = kmap(page) + offset; 3193 DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
3194
3195 if (PageHighMem(page)) {
3196 unsigned long flags;
3197
3198 local_irq_save(flags);
3199 buf = kmap_atomic(page, KM_IRQ0);
3200
3201 /* do the actual data transfer */
3202 ata_data_xfer(ap, buf + offset, count, do_write);
3203
3204 kunmap_atomic(buf, KM_IRQ0);
3205 local_irq_restore(flags);
3206 } else {
3207 buf = page_address(page);
3208 ata_data_xfer(ap, buf + offset, count, do_write);
3209 }
3075 3210
3076 bytes -= count; 3211 bytes -= count;
3077 qc->curbytes += count; 3212 qc->curbytes += count;
@@ -3082,13 +3217,6 @@ next_sg:
3082 qc->cursg_ofs = 0; 3217 qc->cursg_ofs = 0;
3083 } 3218 }
3084 3219
3085 DPRINTK("data %s\n", qc->tf.flags & ATA_TFLAG_WRITE ? "write" : "read");
3086
3087 /* do the actual data transfer */
3088 ata_data_xfer(ap, buf, count, do_write);
3089
3090 kunmap(page);
3091
3092 if (bytes) 3220 if (bytes)
3093 goto next_sg; 3221 goto next_sg;
3094} 3222}
@@ -3125,6 +3253,8 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc)
3125 if (do_write != i_write) 3253 if (do_write != i_write)
3126 goto err_out; 3254 goto err_out;
3127 3255
3256 VPRINTK("ata%u: xfering %d bytes\n", ap->id, bytes);
3257
3128 __atapi_pio_bytes(qc, bytes); 3258 __atapi_pio_bytes(qc, bytes);
3129 3259
3130 return; 3260 return;
@@ -3322,6 +3452,8 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
3322 printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x host_stat 0x%x\n", 3452 printk(KERN_ERR "ata%u: command 0x%x timeout, stat 0x%x host_stat 0x%x\n",
3323 ap->id, qc->tf.command, drv_stat, host_stat); 3453 ap->id, qc->tf.command, drv_stat, host_stat);
3324 3454
3455 ap->hsm_task_state = HSM_ST_IDLE;
3456
3325 /* complete taskfile transaction */ 3457 /* complete taskfile transaction */
3326 ata_qc_complete(qc, ac_err_mask(drv_stat)); 3458 ata_qc_complete(qc, ac_err_mask(drv_stat));
3327 break; 3459 break;
@@ -3607,43 +3739,103 @@ int ata_qc_issue_prot(struct ata_queued_cmd *qc)
3607{ 3739{
3608 struct ata_port *ap = qc->ap; 3740 struct ata_port *ap = qc->ap;
3609 3741
3742 /* Use polling pio if the LLD doesn't handle
3743 * interrupt driven pio and atapi CDB interrupt.
3744 */
3745 if (ap->flags & ATA_FLAG_PIO_POLLING) {
3746 switch (qc->tf.protocol) {
3747 case ATA_PROT_PIO:
3748 case ATA_PROT_ATAPI:
3749 case ATA_PROT_ATAPI_NODATA:
3750 qc->tf.flags |= ATA_TFLAG_POLLING;
3751 break;
3752 case ATA_PROT_ATAPI_DMA:
3753 if (qc->dev->flags & ATA_DFLAG_CDB_INTR)
3754 BUG();
3755 break;
3756 default:
3757 break;
3758 }
3759 }
3760
3761 /* select the device */
3610 ata_dev_select(ap, qc->dev->devno, 1, 0); 3762 ata_dev_select(ap, qc->dev->devno, 1, 0);
3611 3763
3764 /* start the command */
3612 switch (qc->tf.protocol) { 3765 switch (qc->tf.protocol) {
3613 case ATA_PROT_NODATA: 3766 case ATA_PROT_NODATA:
3767 if (qc->tf.flags & ATA_TFLAG_POLLING)
3768 ata_qc_set_polling(qc);
3769
3614 ata_tf_to_host(ap, &qc->tf); 3770 ata_tf_to_host(ap, &qc->tf);
3771 ap->hsm_task_state = HSM_ST_LAST;
3772
3773 if (qc->tf.flags & ATA_TFLAG_POLLING)
3774 queue_work(ata_wq, &ap->pio_task);
3775
3615 break; 3776 break;
3616 3777
3617 case ATA_PROT_DMA: 3778 case ATA_PROT_DMA:
3779 assert(!(qc->tf.flags & ATA_TFLAG_POLLING));
3780
3618 ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ 3781 ap->ops->tf_load(ap, &qc->tf); /* load tf registers */
3619 ap->ops->bmdma_setup(qc); /* set up bmdma */ 3782 ap->ops->bmdma_setup(qc); /* set up bmdma */
3620 ap->ops->bmdma_start(qc); /* initiate bmdma */ 3783 ap->ops->bmdma_start(qc); /* initiate bmdma */
3784 ap->hsm_task_state = HSM_ST_LAST;
3621 break; 3785 break;
3622 3786
3623 case ATA_PROT_PIO: /* load tf registers, initiate polling pio */ 3787 case ATA_PROT_PIO:
3624 ata_qc_set_polling(qc); 3788 if (qc->tf.flags & ATA_TFLAG_POLLING)
3625 ata_tf_to_host(ap, &qc->tf); 3789 ata_qc_set_polling(qc);
3626 ap->hsm_task_state = HSM_ST;
3627 queue_work(ata_wq, &ap->pio_task);
3628 break;
3629 3790
3630 case ATA_PROT_ATAPI:
3631 ata_qc_set_polling(qc);
3632 ata_tf_to_host(ap, &qc->tf); 3791 ata_tf_to_host(ap, &qc->tf);
3633 queue_work(ata_wq, &ap->packet_task); 3792
3793 if (qc->tf.flags & ATA_TFLAG_WRITE) {
3794 /* PIO data out protocol */
3795 ap->hsm_task_state = HSM_ST_FIRST;
3796 queue_work(ata_wq, &ap->dataout_task);
3797
3798 /* always send first data block using
3799 * the ata_dataout_task() codepath.
3800 */
3801 } else {
3802 /* PIO data in protocol */
3803 ap->hsm_task_state = HSM_ST;
3804
3805 if (qc->tf.flags & ATA_TFLAG_POLLING)
3806 queue_work(ata_wq, &ap->pio_task);
3807
3808 /* if polling, ata_pio_task() handles the rest.
3809 * otherwise, interrupt handler takes over from here.
3810 */
3811 }
3812
3634 break; 3813 break;
3635 3814
3815 case ATA_PROT_ATAPI:
3636 case ATA_PROT_ATAPI_NODATA: 3816 case ATA_PROT_ATAPI_NODATA:
3637 ap->flags |= ATA_FLAG_NOINTR; 3817 if (qc->tf.flags & ATA_TFLAG_POLLING)
3818 ata_qc_set_polling(qc);
3819
3638 ata_tf_to_host(ap, &qc->tf); 3820 ata_tf_to_host(ap, &qc->tf);
3639 queue_work(ata_wq, &ap->packet_task); 3821 ap->hsm_task_state = HSM_ST_FIRST;
3822
3823 /* send cdb by polling if no cdb interrupt */
3824 if ((!(qc->dev->flags & ATA_DFLAG_CDB_INTR)) ||
3825 (qc->tf.flags & ATA_TFLAG_POLLING))
3826 queue_work(ata_wq, &ap->dataout_task);
3640 break; 3827 break;
3641 3828
3642 case ATA_PROT_ATAPI_DMA: 3829 case ATA_PROT_ATAPI_DMA:
3643 ap->flags |= ATA_FLAG_NOINTR; 3830 assert(!(qc->tf.flags & ATA_TFLAG_POLLING));
3831
3644 ap->ops->tf_load(ap, &qc->tf); /* load tf registers */ 3832 ap->ops->tf_load(ap, &qc->tf); /* load tf registers */
3645 ap->ops->bmdma_setup(qc); /* set up bmdma */ 3833 ap->ops->bmdma_setup(qc); /* set up bmdma */
3646 queue_work(ata_wq, &ap->packet_task); 3834 ap->hsm_task_state = HSM_ST_FIRST;
3835
3836 /* send cdb by polling if no cdb interrupt */
3837 if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR))
3838 queue_work(ata_wq, &ap->dataout_task);
3647 break; 3839 break;
3648 3840
3649 default: 3841 default:
@@ -3904,47 +4096,142 @@ void ata_bmdma_stop(struct ata_queued_cmd *qc)
3904inline unsigned int ata_host_intr (struct ata_port *ap, 4096inline unsigned int ata_host_intr (struct ata_port *ap,
3905 struct ata_queued_cmd *qc) 4097 struct ata_queued_cmd *qc)
3906{ 4098{
3907 u8 status, host_stat; 4099 u8 status, host_stat = 0;
3908
3909 switch (qc->tf.protocol) {
3910 4100
3911 case ATA_PROT_DMA: 4101 VPRINTK("ata%u: protocol %d task_state %d\n",
3912 case ATA_PROT_ATAPI_DMA: 4102 ap->id, qc->tf.protocol, ap->hsm_task_state);
3913 case ATA_PROT_ATAPI:
3914 /* check status of DMA engine */
3915 host_stat = ap->ops->bmdma_status(ap);
3916 VPRINTK("ata%u: host_stat 0x%X\n", ap->id, host_stat);
3917 4103
3918 /* if it's not our irq... */ 4104 /* Check whether we are expecting interrupt in this state */
3919 if (!(host_stat & ATA_DMA_INTR)) 4105 switch (ap->hsm_task_state) {
4106 case HSM_ST_FIRST:
4107 /* Check the ATA_DFLAG_CDB_INTR flag is enough here.
4108 * The flag was turned on only for atapi devices.
4109 * No need to check is_atapi_taskfile(&qc->tf) again.
4110 */
4111 if (!(qc->dev->flags & ATA_DFLAG_CDB_INTR))
3920 goto idle_irq; 4112 goto idle_irq;
4113 break;
4114 case HSM_ST_LAST:
4115 if (qc->tf.protocol == ATA_PROT_DMA ||
4116 qc->tf.protocol == ATA_PROT_ATAPI_DMA) {
4117 /* check status of DMA engine */
4118 host_stat = ap->ops->bmdma_status(ap);
4119 VPRINTK("ata%u: host_stat 0x%X\n", ap->id, host_stat);
4120
4121 /* if it's not our irq... */
4122 if (!(host_stat & ATA_DMA_INTR))
4123 goto idle_irq;
4124
4125 /* before we do anything else, clear DMA-Start bit */
4126 ap->ops->bmdma_stop(qc);
4127 }
4128 break;
4129 case HSM_ST:
4130 break;
4131 default:
4132 goto idle_irq;
4133 }
3921 4134
3922 /* before we do anything else, clear DMA-Start bit */ 4135 /* check altstatus */
3923 ap->ops->bmdma_stop(qc); 4136 status = ata_altstatus(ap);
4137 if (status & ATA_BUSY)
4138 goto idle_irq;
3924 4139
3925 /* fall through */ 4140 /* check main status, clearing INTRQ */
4141 status = ata_chk_status(ap);
4142 if (unlikely(status & ATA_BUSY))
4143 goto idle_irq;
3926 4144
3927 case ATA_PROT_ATAPI_NODATA: 4145 DPRINTK("ata%u: protocol %d task_state %d (dev_stat 0x%X)\n",
3928 case ATA_PROT_NODATA: 4146 ap->id, qc->tf.protocol, ap->hsm_task_state, status);
3929 /* check altstatus */
3930 status = ata_altstatus(ap);
3931 if (status & ATA_BUSY)
3932 goto idle_irq;
3933 4147
3934 /* check main status, clearing INTRQ */ 4148 /* ack bmdma irq events */
3935 status = ata_chk_status(ap); 4149 ap->ops->irq_clear(ap);
3936 if (unlikely(status & ATA_BUSY))
3937 goto idle_irq;
3938 DPRINTK("ata%u: protocol %d (dev_stat 0x%X)\n",
3939 ap->id, qc->tf.protocol, status);
3940 4150
3941 /* ack bmdma irq events */ 4151 /* check error */
3942 ap->ops->irq_clear(ap); 4152 if (unlikely((status & ATA_ERR) || (host_stat & ATA_DMA_ERR)))
4153 ap->hsm_task_state = HSM_ST_ERR;
4154
4155fsm_start:
4156 switch (ap->hsm_task_state) {
4157 case HSM_ST_FIRST:
4158 /* Some pre-ATAPI-4 devices assert INTRQ
4159 * at this state when ready to receive CDB.
4160 */
4161
4162 /* check device status */
4163 if (unlikely((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ)) {
4164 /* Wrong status. Let EH handle this */
4165 ap->hsm_task_state = HSM_ST_ERR;
4166 goto fsm_start;
4167 }
4168
4169 atapi_send_cdb(ap, qc);
4170
4171 break;
4172
4173 case HSM_ST:
4174 /* complete command or read/write the data register */
4175 if (qc->tf.protocol == ATA_PROT_ATAPI) {
4176 /* ATAPI PIO protocol */
4177 if ((status & ATA_DRQ) == 0) {
4178 /* no more data to transfer */
4179 ap->hsm_task_state = HSM_ST_LAST;
4180 goto fsm_start;
4181 }
4182
4183 atapi_pio_bytes(qc);
4184
4185 if (unlikely(ap->hsm_task_state == HSM_ST_ERR))
4186 /* bad ireason reported by device */
4187 goto fsm_start;
4188
4189 } else {
4190 /* ATA PIO protocol */
4191 if (unlikely((status & ATA_DRQ) == 0)) {
4192 /* handle BSY=0, DRQ=0 as error */
4193 ap->hsm_task_state = HSM_ST_ERR;
4194 goto fsm_start;
4195 }
4196
4197 ata_pio_sector(qc);
4198
4199 if (ap->hsm_task_state == HSM_ST_LAST &&
4200 (!(qc->tf.flags & ATA_TFLAG_WRITE))) {
4201 /* all data read */
4202 ata_altstatus(ap);
4203 status = ata_chk_status(ap);
4204 goto fsm_start;
4205 }
4206 }
4207
4208 ata_altstatus(ap); /* flush */
4209 break;
4210
4211 case HSM_ST_LAST:
4212 if (unlikely(status & ATA_DRQ)) {
4213 /* handle DRQ=1 as error */
4214 ap->hsm_task_state = HSM_ST_ERR;
4215 goto fsm_start;
4216 }
4217
4218 /* no more data to transfer */
4219 DPRINTK("ata%u: command complete, drv_stat 0x%x\n",
4220 ap->id, status);
4221
4222 ap->hsm_task_state = HSM_ST_IDLE;
3943 4223
3944 /* complete taskfile transaction */ 4224 /* complete taskfile transaction */
3945 ata_qc_complete(qc, ac_err_mask(status)); 4225 ata_qc_complete(qc, ac_err_mask(status));
3946 break; 4226 break;
3947 4227
4228 case HSM_ST_ERR:
4229 printk(KERN_ERR "ata%u: command error, drv_stat 0x%x host_stat 0x%x\n",
4230 ap->id, status, host_stat);
4231
4232 ap->hsm_task_state = HSM_ST_IDLE;
4233 ata_qc_complete(qc, status | ATA_ERR);
4234 break;
3948 default: 4235 default:
3949 goto idle_irq; 4236 goto idle_irq;
3950 } 4237 }
@@ -3995,11 +4282,11 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
3995 4282
3996 ap = host_set->ports[i]; 4283 ap = host_set->ports[i];
3997 if (ap && 4284 if (ap &&
3998 !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { 4285 !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
3999 struct ata_queued_cmd *qc; 4286 struct ata_queued_cmd *qc;
4000 4287
4001 qc = ata_qc_from_tag(ap, ap->active_tag); 4288 qc = ata_qc_from_tag(ap, ap->active_tag);
4002 if (qc && (!(qc->tf.ctl & ATA_NIEN)) && 4289 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)) &&
4003 (qc->flags & ATA_QCFLAG_ACTIVE)) 4290 (qc->flags & ATA_QCFLAG_ACTIVE))
4004 handled |= ata_host_intr(ap, qc); 4291 handled |= ata_host_intr(ap, qc);
4005 } 4292 }
@@ -4011,77 +4298,6 @@ irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
4011} 4298}
4012 4299
4013/** 4300/**
4014 * atapi_packet_task - Write CDB bytes to hardware
4015 * @_data: Port to which ATAPI device is attached.
4016 *
4017 * When device has indicated its readiness to accept
4018 * a CDB, this function is called. Send the CDB.
4019 * If DMA is to be performed, exit immediately.
4020 * Otherwise, we are in polling mode, so poll
4021 * status under operation succeeds or fails.
4022 *
4023 * LOCKING:
4024 * Kernel thread context (may sleep)
4025 */
4026
4027static void atapi_packet_task(void *_data)
4028{
4029 struct ata_port *ap = _data;
4030 struct ata_queued_cmd *qc;
4031 u8 status;
4032
4033 qc = ata_qc_from_tag(ap, ap->active_tag);
4034 assert(qc != NULL);
4035 assert(qc->flags & ATA_QCFLAG_ACTIVE);
4036
4037 /* sleep-wait for BSY to clear */
4038 DPRINTK("busy wait\n");
4039 if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB))
4040 goto err_out_status;
4041
4042 /* make sure DRQ is set */
4043 status = ata_chk_status(ap);
4044 if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ)
4045 goto err_out;
4046
4047 /* send SCSI cdb */
4048 DPRINTK("send cdb\n");
4049 assert(ap->cdb_len >= 12);
4050
4051 if (qc->tf.protocol == ATA_PROT_ATAPI_DMA ||
4052 qc->tf.protocol == ATA_PROT_ATAPI_NODATA) {
4053 unsigned long flags;
4054
4055 /* Once we're done issuing command and kicking bmdma,
4056 * irq handler takes over. To not lose irq, we need
4057 * to clear NOINTR flag before sending cdb, but
4058 * interrupt handler shouldn't be invoked before we're
4059 * finished. Hence, the following locking.
4060 */
4061 spin_lock_irqsave(&ap->host_set->lock, flags);
4062 ap->flags &= ~ATA_FLAG_NOINTR;
4063 ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1);
4064 if (qc->tf.protocol == ATA_PROT_ATAPI_DMA)
4065 ap->ops->bmdma_start(qc); /* initiate bmdma */
4066 spin_unlock_irqrestore(&ap->host_set->lock, flags);
4067 } else {
4068 ata_data_xfer(ap, qc->cdb, ap->cdb_len, 1);
4069
4070 /* PIO commands are handled by polling */
4071 ap->hsm_task_state = HSM_ST;
4072 queue_work(ata_wq, &ap->pio_task);
4073 }
4074
4075 return;
4076
4077err_out_status:
4078 status = ata_chk_status(ap);
4079err_out:
4080 ata_poll_qc_complete(qc, __ac_err_mask(status));
4081}
4082
4083
4084/**
4085 * ata_port_start - Set port up for dma. 4301 * ata_port_start - Set port up for dma.
4086 * @ap: Port to initialize 4302 * @ap: Port to initialize
4087 * 4303 *
@@ -4207,7 +4423,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
4207 ap->active_tag = ATA_TAG_POISON; 4423 ap->active_tag = ATA_TAG_POISON;
4208 ap->last_ctl = 0xFF; 4424 ap->last_ctl = 0xFF;
4209 4425
4210 INIT_WORK(&ap->packet_task, atapi_packet_task, ap); 4426 INIT_WORK(&ap->dataout_task, ata_dataout_task, ap);
4211 INIT_WORK(&ap->pio_task, ata_pio_task, ap); 4427 INIT_WORK(&ap->pio_task, ata_pio_task, ap);
4212 4428
4213 for (i = 0; i < ATA_MAX_DEVICES; i++) 4429 for (i = 0; i < ATA_MAX_DEVICES; i++)
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
index 78b4ff117af6..6b1c901c5e4b 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 unsigned int err_mask = 0; 467 unsigned int err_mask = 0;
468 468
469 if ((status & (aPERR | aPSD | aUIRQ))) 469 if ((status & (aPERR | aPSD | aUIRQ)))
@@ -484,13 +484,13 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set)
484 for (port_no = 0; port_no < host_set->n_ports; ++port_no) { 484 for (port_no = 0; port_no < host_set->n_ports; ++port_no) {
485 struct ata_port *ap; 485 struct ata_port *ap;
486 ap = host_set->ports[port_no]; 486 ap = host_set->ports[port_no];
487 if (ap && (!(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR)))) { 487 if (ap && (!(ap->flags & ATA_FLAG_PORT_DISABLED))) {
488 struct ata_queued_cmd *qc; 488 struct ata_queued_cmd *qc;
489 struct adma_port_priv *pp = ap->private_data; 489 struct adma_port_priv *pp = ap->private_data;
490 if (!pp || pp->state != adma_state_mmio) 490 if (!pp || pp->state != adma_state_mmio)
491 continue; 491 continue;
492 qc = ata_qc_from_tag(ap, ap->active_tag); 492 qc = ata_qc_from_tag(ap, ap->active_tag);
493 if (qc && (!(qc->tf.ctl & ATA_NIEN))) { 493 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
494 494
495 /* check main status, clearing INTRQ */ 495 /* check main status, clearing INTRQ */
496 u8 status = ata_check_status(ap); 496 u8 status = ata_check_status(ap);
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index 93d55233af7b..f8976e3f6ada 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -88,7 +88,8 @@ enum {
88 MV_FLAG_IRQ_COALESCE = (1 << 29), /* IRQ coalescing capability */ 88 MV_FLAG_IRQ_COALESCE = (1 << 29), /* IRQ coalescing capability */
89 MV_FLAG_GLBL_SFT_RST = (1 << 28), /* Global Soft Reset support */ 89 MV_FLAG_GLBL_SFT_RST = (1 << 28), /* Global Soft Reset support */
90 MV_COMMON_FLAGS = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 90 MV_COMMON_FLAGS = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
91 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO), 91 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
92 ATA_FLAG_PIO_POLLING),
92 MV_6XXX_FLAGS = (MV_FLAG_IRQ_COALESCE | 93 MV_6XXX_FLAGS = (MV_FLAG_IRQ_COALESCE |
93 MV_FLAG_GLBL_SFT_RST), 94 MV_FLAG_GLBL_SFT_RST),
94 95
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index 37a4fae95ed4..5b7f7808add9 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -304,11 +304,11 @@ static irqreturn_t nv_interrupt (int irq, void *dev_instance,
304 304
305 ap = host_set->ports[i]; 305 ap = host_set->ports[i];
306 if (ap && 306 if (ap &&
307 !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { 307 !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
308 struct ata_queued_cmd *qc; 308 struct ata_queued_cmd *qc;
309 309
310 qc = ata_qc_from_tag(ap, ap->active_tag); 310 qc = ata_qc_from_tag(ap, ap->active_tag);
311 if (qc && (!(qc->tf.ctl & ATA_NIEN))) 311 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
312 handled += ata_host_intr(ap, qc); 312 handled += ata_host_intr(ap, qc);
313 } 313 }
314 314
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index 9edc9d91efc3..ac5b9cbebdd8 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -163,7 +163,8 @@ static struct ata_port_info pdc_port_info[] = {
163 { 163 {
164 .sht = &pdc_ata_sht, 164 .sht = &pdc_ata_sht,
165 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 165 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
166 ATA_FLAG_SRST | ATA_FLAG_MMIO, 166 ATA_FLAG_SRST | ATA_FLAG_MMIO |
167 ATA_FLAG_PIO_POLLING,
167 .pio_mask = 0x1f, /* pio0-4 */ 168 .pio_mask = 0x1f, /* pio0-4 */
168 .mwdma_mask = 0x07, /* mwdma0-2 */ 169 .mwdma_mask = 0x07, /* mwdma0-2 */
169 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 170 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -174,7 +175,8 @@ static struct ata_port_info pdc_port_info[] = {
174 { 175 {
175 .sht = &pdc_ata_sht, 176 .sht = &pdc_ata_sht,
176 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 177 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
177 ATA_FLAG_SRST | ATA_FLAG_MMIO, 178 ATA_FLAG_SRST | ATA_FLAG_MMIO |
179 ATA_FLAG_PIO_POLLING,
178 .pio_mask = 0x1f, /* pio0-4 */ 180 .pio_mask = 0x1f, /* pio0-4 */
179 .mwdma_mask = 0x07, /* mwdma0-2 */ 181 .mwdma_mask = 0x07, /* mwdma0-2 */
180 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 182 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -185,7 +187,8 @@ static struct ata_port_info pdc_port_info[] = {
185 { 187 {
186 .sht = &pdc_ata_sht, 188 .sht = &pdc_ata_sht,
187 .host_flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_SRST | 189 .host_flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_SRST |
188 ATA_FLAG_MMIO | ATA_FLAG_SLAVE_POSS, 190 ATA_FLAG_MMIO | ATA_FLAG_SLAVE_POSS |
191 ATA_FLAG_PIO_POLLING,
189 .pio_mask = 0x1f, /* pio0-4 */ 192 .pio_mask = 0x1f, /* pio0-4 */
190 .mwdma_mask = 0x07, /* mwdma0-2 */ 193 .mwdma_mask = 0x07, /* mwdma0-2 */
191 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 194 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -496,11 +499,11 @@ static irqreturn_t pdc_interrupt (int irq, void *dev_instance, struct pt_regs *r
496 ap = host_set->ports[i]; 499 ap = host_set->ports[i];
497 tmp = mask & (1 << (i + 1)); 500 tmp = mask & (1 << (i + 1));
498 if (tmp && ap && 501 if (tmp && ap &&
499 !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { 502 !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
500 struct ata_queued_cmd *qc; 503 struct ata_queued_cmd *qc;
501 504
502 qc = ata_qc_from_tag(ap, ap->active_tag); 505 qc = ata_qc_from_tag(ap, ap->active_tag);
503 if (qc && (!(qc->tf.ctl & ATA_NIEN))) 506 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
504 handled += pdc_host_intr(ap, qc); 507 handled += pdc_host_intr(ap, qc);
505 } 508 }
506 } 509 }
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c
index d274ab235781..0e3468a8b73d 100644
--- a/drivers/scsi/sata_qstor.c
+++ b/drivers/scsi/sata_qstor.c
@@ -177,7 +177,7 @@ static 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,
@@ -393,14 +393,13 @@ static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set)
393 DPRINTK("SFF=%08x%08x: sCHAN=%u sHST=%d sDST=%02x\n", 393 DPRINTK("SFF=%08x%08x: sCHAN=%u sHST=%d sDST=%02x\n",
394 sff1, sff0, port_no, sHST, sDST); 394 sff1, sff0, port_no, sHST, sDST);
395 handled = 1; 395 handled = 1;
396 if (ap && !(ap->flags & 396 if (ap && !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
397 (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) {
398 struct ata_queued_cmd *qc; 397 struct ata_queued_cmd *qc;
399 struct qs_port_priv *pp = ap->private_data; 398 struct qs_port_priv *pp = ap->private_data;
400 if (!pp || pp->state != qs_state_pkt) 399 if (!pp || pp->state != qs_state_pkt)
401 continue; 400 continue;
402 qc = ata_qc_from_tag(ap, ap->active_tag); 401 qc = ata_qc_from_tag(ap, ap->active_tag);
403 if (qc && (!(qc->tf.ctl & ATA_NIEN))) { 402 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
404 switch (sHST) { 403 switch (sHST) {
405 case 0: /* successful CPB */ 404 case 0: /* successful CPB */
406 case 3: /* device error */ 405 case 3: /* device error */
@@ -427,13 +426,13 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set)
427 struct ata_port *ap; 426 struct ata_port *ap;
428 ap = host_set->ports[port_no]; 427 ap = host_set->ports[port_no];
429 if (ap && 428 if (ap &&
430 !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { 429 !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
431 struct ata_queued_cmd *qc; 430 struct ata_queued_cmd *qc;
432 struct qs_port_priv *pp = ap->private_data; 431 struct qs_port_priv *pp = ap->private_data;
433 if (!pp || pp->state != qs_state_mmio) 432 if (!pp || pp->state != qs_state_mmio)
434 continue; 433 continue;
435 qc = ata_qc_from_tag(ap, ap->active_tag); 434 qc = ata_qc_from_tag(ap, ap->active_tag);
436 if (qc && (!(qc->tf.ctl & ATA_NIEN))) { 435 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING))) {
437 436
438 /* check main status, clearing INTRQ */ 437 /* check main status, clearing INTRQ */
439 u8 status = ata_check_status(ap); 438 u8 status = ata_check_status(ap);
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c
index d5a38784352b..c42b2d3eeb6c 100644
--- a/drivers/scsi/sata_sx4.c
+++ b/drivers/scsi/sata_sx4.c
@@ -220,7 +220,8 @@ static struct ata_port_info pdc_port_info[] = {
220 { 220 {
221 .sht = &pdc_sata_sht, 221 .sht = &pdc_sata_sht,
222 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 222 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
223 ATA_FLAG_SRST | ATA_FLAG_MMIO, 223 ATA_FLAG_SRST | ATA_FLAG_MMIO |
224 ATA_FLAG_PIO_POLLING,
224 .pio_mask = 0x1f, /* pio0-4 */ 225 .pio_mask = 0x1f, /* pio0-4 */
225 .mwdma_mask = 0x07, /* mwdma0-2 */ 226 .mwdma_mask = 0x07, /* mwdma0-2 */
226 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 227 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -832,11 +833,11 @@ static irqreturn_t pdc20621_interrupt (int irq, void *dev_instance, struct pt_re
832 tmp = mask & (1 << i); 833 tmp = mask & (1 << i);
833 VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp); 834 VPRINTK("seq %u, port_no %u, ap %p, tmp %x\n", i, port_no, ap, tmp);
834 if (tmp && ap && 835 if (tmp && ap &&
835 !(ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR))) { 836 !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
836 struct ata_queued_cmd *qc; 837 struct ata_queued_cmd *qc;
837 838
838 qc = ata_qc_from_tag(ap, ap->active_tag); 839 qc = ata_qc_from_tag(ap, ap->active_tag);
839 if (qc && (!(qc->tf.ctl & ATA_NIEN))) 840 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
840 handled += pdc20621_host_intr(ap, qc, (i > 4), 841 handled += pdc20621_host_intr(ap, qc, (i > 4),
841 mmio_base); 842 mmio_base);
842 } 843 }
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index ce8a2fd7da84..e819b2b4f298 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -201,12 +201,12 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
201 struct ata_port *ap; 201 struct ata_port *ap;
202 202
203 ap = host_set->ports[i]; 203 ap = host_set->ports[i];
204 if (ap && !(ap->flags & 204 if (ap &&
205 (ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) { 205 !(ap->flags & ATA_FLAG_PORT_DISABLED)) {
206 struct ata_queued_cmd *qc; 206 struct ata_queued_cmd *qc;
207 207
208 qc = ata_qc_from_tag(ap, ap->active_tag); 208 qc = ata_qc_from_tag(ap, ap->active_tag);
209 if (qc && (!(qc->tf.ctl & ATA_NIEN))) 209 if (qc && (!(qc->tf.flags & ATA_TFLAG_POLLING)))
210 handled += ata_host_intr(ap, qc); 210 handled += ata_host_intr(ap, qc);
211 } 211 }
212 } 212 }