aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/libata-core.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 96b8bbaa7631..2e0e6cca327c 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -2790,7 +2790,8 @@ static unsigned long ata_pio_poll(struct ata_port *ap)
2790 * None. (executing in kernel thread context) 2790 * None. (executing in kernel thread context)
2791 * 2791 *
2792 * RETURNS: 2792 * RETURNS:
2793 * Non-zero if qc completed, zero otherwise. 2793 * Zero if qc completed.
2794 * Non-zero if has next.
2794 */ 2795 */
2795 2796
2796static int ata_pio_complete (struct ata_port *ap) 2797static int ata_pio_complete (struct ata_port *ap)
@@ -2812,14 +2813,14 @@ static int ata_pio_complete (struct ata_port *ap)
2812 if (drv_stat & (ATA_BUSY | ATA_DRQ)) { 2813 if (drv_stat & (ATA_BUSY | ATA_DRQ)) {
2813 ap->hsm_task_state = HSM_ST_LAST_POLL; 2814 ap->hsm_task_state = HSM_ST_LAST_POLL;
2814 ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO; 2815 ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO;
2815 return 0; 2816 return 1;
2816 } 2817 }
2817 } 2818 }
2818 2819
2819 drv_stat = ata_wait_idle(ap); 2820 drv_stat = ata_wait_idle(ap);
2820 if (!ata_ok(drv_stat)) { 2821 if (!ata_ok(drv_stat)) {
2821 ap->hsm_task_state = HSM_ST_ERR; 2822 ap->hsm_task_state = HSM_ST_ERR;
2822 return 0; 2823 return 1;
2823 } 2824 }
2824 2825
2825 qc = ata_qc_from_tag(ap, ap->active_tag); 2826 qc = ata_qc_from_tag(ap, ap->active_tag);
@@ -2831,7 +2832,7 @@ static int ata_pio_complete (struct ata_port *ap)
2831 2832
2832 /* another command may start at this point */ 2833 /* another command may start at this point */
2833 2834
2834 return 1; 2835 return 0;
2835} 2836}
2836 2837
2837 2838
@@ -3068,27 +3069,42 @@ static void atapi_send_cdb(struct ata_port *ap, struct ata_queued_cmd *qc)
3068 * 3069 *
3069 * LOCKING: 3070 * LOCKING:
3070 * Kernel thread context (may sleep) 3071 * Kernel thread context (may sleep)
3072 *
3073 * RETURNS:
3074 * Zero if irq handler takes over
3075 * Non-zero if has next (polling).
3071 */ 3076 */
3072 3077
3073static void ata_pio_first_block(struct ata_port *ap) 3078static int ata_pio_first_block(struct ata_port *ap)
3074{ 3079{
3075 struct ata_queued_cmd *qc; 3080 struct ata_queued_cmd *qc;
3076 u8 status; 3081 u8 status;
3077 unsigned long flags; 3082 unsigned long flags;
3083 int has_next;
3078 3084
3079 qc = ata_qc_from_tag(ap, ap->active_tag); 3085 qc = ata_qc_from_tag(ap, ap->active_tag);
3080 assert(qc != NULL); 3086 assert(qc != NULL);
3081 assert(qc->flags & ATA_QCFLAG_ACTIVE); 3087 assert(qc->flags & ATA_QCFLAG_ACTIVE);
3082 3088
3089 /* if polling, we will stay in the work queue after sending the data.
3090 * otherwise, interrupt handler takes over after sending the data.
3091 */
3092 has_next = (qc->tf.flags & ATA_TFLAG_POLLING);
3093
3083 /* sleep-wait for BSY to clear */ 3094 /* sleep-wait for BSY to clear */
3084 DPRINTK("busy wait\n"); 3095 DPRINTK("busy wait\n");
3085 if (ata_busy_sleep(ap, ATA_TMOUT_DATAOUT_QUICK, ATA_TMOUT_DATAOUT)) 3096 if (ata_busy_sleep(ap, ATA_TMOUT_DATAOUT_QUICK, ATA_TMOUT_DATAOUT)) {
3097 ap->hsm_task_state = HSM_ST_TMOUT;
3086 goto err_out; 3098 goto err_out;
3099 }
3087 3100
3088 /* make sure DRQ is set */ 3101 /* make sure DRQ is set */
3089 status = ata_chk_status(ap); 3102 status = ata_chk_status(ap);
3090 if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) 3103 if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) {
3104 /* device status error */
3105 ap->hsm_task_state = HSM_ST_ERR;
3091 goto err_out; 3106 goto err_out;
3107 }
3092 3108
3093 /* Send the CDB (atapi) or the first data block (ata pio out). 3109 /* Send the CDB (atapi) or the first data block (ata pio out).
3094 * During the state transition, interrupt handler shouldn't 3110 * During the state transition, interrupt handler shouldn't
@@ -3112,18 +3128,15 @@ static void ata_pio_first_block(struct ata_port *ap)
3112 /* send CDB */ 3128 /* send CDB */
3113 atapi_send_cdb(ap, qc); 3129 atapi_send_cdb(ap, qc);
3114 3130
3131 spin_unlock_irqrestore(&ap->host_set->lock, flags);
3132
3115 /* if polling, ata_pio_task() handles the rest. 3133 /* if polling, ata_pio_task() handles the rest.
3116 * otherwise, interrupt handler takes over from here. 3134 * otherwise, interrupt handler takes over from here.
3117 */ 3135 */
3118 if (qc->tf.flags & ATA_TFLAG_POLLING) 3136 return has_next;
3119 queue_work(ata_wq, &ap->pio_task);
3120
3121 spin_unlock_irqrestore(&ap->host_set->lock, flags);
3122
3123 return;
3124 3137
3125err_out: 3138err_out:
3126 ata_pio_error(ap); 3139 return 1; /* has next */
3127} 3140}
3128 3141
3129/** 3142/**
@@ -3338,23 +3351,23 @@ static void ata_pio_task(void *_data)
3338{ 3351{
3339 struct ata_port *ap = _data; 3352 struct ata_port *ap = _data;
3340 unsigned long timeout; 3353 unsigned long timeout;
3341 int qc_completed; 3354 int has_next;
3342 3355
3343fsm_start: 3356fsm_start:
3344 timeout = 0; 3357 timeout = 0;
3345 qc_completed = 0; 3358 has_next = 1;
3346 3359
3347 switch (ap->hsm_task_state) { 3360 switch (ap->hsm_task_state) {
3348 case HSM_ST_FIRST: 3361 case HSM_ST_FIRST:
3349 ata_pio_first_block(ap); 3362 has_next = ata_pio_first_block(ap);
3350 return; 3363 break;
3351 3364
3352 case HSM_ST: 3365 case HSM_ST:
3353 ata_pio_block(ap); 3366 ata_pio_block(ap);
3354 break; 3367 break;
3355 3368
3356 case HSM_ST_LAST: 3369 case HSM_ST_LAST:
3357 qc_completed = ata_pio_complete(ap); 3370 has_next = ata_pio_complete(ap);
3358 break; 3371 break;
3359 3372
3360 case HSM_ST_POLL: 3373 case HSM_ST_POLL:
@@ -3374,7 +3387,7 @@ fsm_start:
3374 3387
3375 if (timeout) 3388 if (timeout)
3376 queue_delayed_work(ata_wq, &ap->pio_task, timeout); 3389 queue_delayed_work(ata_wq, &ap->pio_task, timeout);
3377 else if (!qc_completed) 3390 else if (has_next)
3378 goto fsm_start; 3391 goto fsm_start;
3379} 3392}
3380 3393