aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-io.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-io.c')
-rw-r--r--drivers/ide/ide-io.c237
1 files changed, 95 insertions, 142 deletions
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 1c51949833be..77c6eaeacefa 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -78,8 +78,9 @@ static int __ide_end_request(ide_drive_t *drive, struct request *rq,
78 * decide whether to reenable DMA -- 3 is a random magic for now, 78 * decide whether to reenable DMA -- 3 is a random magic for now,
79 * if we DMA timeout more than 3 times, just stay in PIO 79 * if we DMA timeout more than 3 times, just stay in PIO
80 */ 80 */
81 if (drive->state == DMA_PIO_RETRY && drive->retry_pio <= 3) { 81 if ((drive->dev_flags & IDE_DFLAG_DMA_PIO_RETRY) &&
82 drive->state = 0; 82 drive->retry_pio <= 3) {
83 drive->dev_flags &= ~IDE_DFLAG_DMA_PIO_RETRY;
83 ide_dma_on(drive); 84 ide_dma_on(drive);
84 } 85 }
85 86
@@ -131,21 +132,6 @@ int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors)
131} 132}
132EXPORT_SYMBOL(ide_end_request); 133EXPORT_SYMBOL(ide_end_request);
133 134
134/*
135 * Power Management state machine. This one is rather trivial for now,
136 * we should probably add more, like switching back to PIO on suspend
137 * to help some BIOSes, re-do the door locking on resume, etc...
138 */
139
140enum {
141 ide_pm_flush_cache = ide_pm_state_start_suspend,
142 idedisk_pm_standby,
143
144 idedisk_pm_restore_pio = ide_pm_state_start_resume,
145 idedisk_pm_idle,
146 ide_pm_restore_dma,
147};
148
149static void ide_complete_power_step(ide_drive_t *drive, struct request *rq, u8 stat, u8 error) 135static void ide_complete_power_step(ide_drive_t *drive, struct request *rq, u8 stat, u8 error)
150{ 136{
151 struct request_pm_state *pm = rq->data; 137 struct request_pm_state *pm = rq->data;
@@ -154,20 +140,20 @@ static void ide_complete_power_step(ide_drive_t *drive, struct request *rq, u8 s
154 return; 140 return;
155 141
156 switch (pm->pm_step) { 142 switch (pm->pm_step) {
157 case ide_pm_flush_cache: /* Suspend step 1 (flush cache) complete */ 143 case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */
158 if (pm->pm_state == PM_EVENT_FREEZE) 144 if (pm->pm_state == PM_EVENT_FREEZE)
159 pm->pm_step = ide_pm_state_completed; 145 pm->pm_step = IDE_PM_COMPLETED;
160 else 146 else
161 pm->pm_step = idedisk_pm_standby; 147 pm->pm_step = IDE_PM_STANDBY;
162 break; 148 break;
163 case idedisk_pm_standby: /* Suspend step 2 (standby) complete */ 149 case IDE_PM_STANDBY: /* Suspend step 2 (standby) */
164 pm->pm_step = ide_pm_state_completed; 150 pm->pm_step = IDE_PM_COMPLETED;
165 break; 151 break;
166 case idedisk_pm_restore_pio: /* Resume step 1 complete */ 152 case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */
167 pm->pm_step = idedisk_pm_idle; 153 pm->pm_step = IDE_PM_IDLE;
168 break; 154 break;
169 case idedisk_pm_idle: /* Resume step 2 (idle) complete */ 155 case IDE_PM_IDLE: /* Resume step 2 (idle)*/
170 pm->pm_step = ide_pm_restore_dma; 156 pm->pm_step = IDE_PM_RESTORE_DMA;
171 break; 157 break;
172 } 158 }
173} 159}
@@ -180,11 +166,12 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
180 memset(args, 0, sizeof(*args)); 166 memset(args, 0, sizeof(*args));
181 167
182 switch (pm->pm_step) { 168 switch (pm->pm_step) {
183 case ide_pm_flush_cache: /* Suspend step 1 (flush cache) */ 169 case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */
184 if (drive->media != ide_disk) 170 if (drive->media != ide_disk)
185 break; 171 break;
186 /* Not supported? Switch to next step now. */ 172 /* Not supported? Switch to next step now. */
187 if (!drive->wcache || ata_id_flush_enabled(drive->id) == 0) { 173 if (ata_id_flush_enabled(drive->id) == 0 ||
174 (drive->dev_flags & IDE_DFLAG_WCACHE) == 0) {
188 ide_complete_power_step(drive, rq, 0, 0); 175 ide_complete_power_step(drive, rq, 0, 0);
189 return ide_stopped; 176 return ide_stopped;
190 } 177 }
@@ -193,27 +180,23 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
193 else 180 else
194 args->tf.command = ATA_CMD_FLUSH; 181 args->tf.command = ATA_CMD_FLUSH;
195 goto out_do_tf; 182 goto out_do_tf;
196 183 case IDE_PM_STANDBY: /* Suspend step 2 (standby) */
197 case idedisk_pm_standby: /* Suspend step 2 (standby) */
198 args->tf.command = ATA_CMD_STANDBYNOW1; 184 args->tf.command = ATA_CMD_STANDBYNOW1;
199 goto out_do_tf; 185 goto out_do_tf;
200 186 case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */
201 case idedisk_pm_restore_pio: /* Resume step 1 (restore PIO) */
202 ide_set_max_pio(drive); 187 ide_set_max_pio(drive);
203 /* 188 /*
204 * skip idedisk_pm_idle for ATAPI devices 189 * skip IDE_PM_IDLE for ATAPI devices
205 */ 190 */
206 if (drive->media != ide_disk) 191 if (drive->media != ide_disk)
207 pm->pm_step = ide_pm_restore_dma; 192 pm->pm_step = IDE_PM_RESTORE_DMA;
208 else 193 else
209 ide_complete_power_step(drive, rq, 0, 0); 194 ide_complete_power_step(drive, rq, 0, 0);
210 return ide_stopped; 195 return ide_stopped;
211 196 case IDE_PM_IDLE: /* Resume step 2 (idle) */
212 case idedisk_pm_idle: /* Resume step 2 (idle) */
213 args->tf.command = ATA_CMD_IDLEIMMEDIATE; 197 args->tf.command = ATA_CMD_IDLEIMMEDIATE;
214 goto out_do_tf; 198 goto out_do_tf;
215 199 case IDE_PM_RESTORE_DMA: /* Resume step 3 (restore DMA) */
216 case ide_pm_restore_dma: /* Resume step 3 (restore DMA) */
217 /* 200 /*
218 * Right now, all we do is call ide_set_dma(drive), 201 * Right now, all we do is call ide_set_dma(drive),
219 * we could be smarter and check for current xfer_speed 202 * we could be smarter and check for current xfer_speed
@@ -222,12 +205,13 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request *
222 if (drive->hwif->dma_ops == NULL) 205 if (drive->hwif->dma_ops == NULL)
223 break; 206 break;
224 /* 207 /*
225 * TODO: respect ->using_dma setting 208 * TODO: respect IDE_DFLAG_USING_DMA
226 */ 209 */
227 ide_set_dma(drive); 210 ide_set_dma(drive);
228 break; 211 break;
229 } 212 }
230 pm->pm_step = ide_pm_state_completed; 213
214 pm->pm_step = IDE_PM_COMPLETED;
231 return ide_stopped; 215 return ide_stopped;
232 216
233out_do_tf: 217out_do_tf:
@@ -287,7 +271,7 @@ static void ide_complete_pm_request (ide_drive_t *drive, struct request *rq)
287 if (blk_pm_suspend_request(rq)) { 271 if (blk_pm_suspend_request(rq)) {
288 blk_stop_queue(drive->queue); 272 blk_stop_queue(drive->queue);
289 } else { 273 } else {
290 drive->blocked = 0; 274 drive->dev_flags &= ~IDE_DFLAG_BLOCKED;
291 blk_start_queue(drive->queue); 275 blk_start_queue(drive->queue);
292 } 276 }
293 HWGROUP(drive)->rq = NULL; 277 HWGROUP(drive)->rq = NULL;
@@ -343,7 +327,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err)
343 drive->name, rq->pm->pm_step, stat, err); 327 drive->name, rq->pm->pm_step, stat, err);
344#endif 328#endif
345 ide_complete_power_step(drive, rq, stat, err); 329 ide_complete_power_step(drive, rq, stat, err);
346 if (pm->pm_step == ide_pm_state_completed) 330 if (pm->pm_step == IDE_PM_COMPLETED)
347 ide_complete_pm_request(drive, rq); 331 ide_complete_pm_request(drive, rq);
348 return; 332 return;
349 } 333 }
@@ -374,13 +358,14 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8
374{ 358{
375 ide_hwif_t *hwif = drive->hwif; 359 ide_hwif_t *hwif = drive->hwif;
376 360
377 if ((stat & ATA_BUSY) || ((stat & ATA_DF) && !drive->nowerr)) { 361 if ((stat & ATA_BUSY) ||
362 ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) {
378 /* other bits are useless when BUSY */ 363 /* other bits are useless when BUSY */
379 rq->errors |= ERROR_RESET; 364 rq->errors |= ERROR_RESET;
380 } else if (stat & ATA_ERR) { 365 } else if (stat & ATA_ERR) {
381 /* err has different meaning on cdrom and tape */ 366 /* err has different meaning on cdrom and tape */
382 if (err == ATA_ABORTED) { 367 if (err == ATA_ABORTED) {
383 if (drive->select.b.lba && 368 if ((drive->dev_flags & IDE_DFLAG_LBA) &&
384 /* some newer drives don't support ATA_CMD_INIT_DEV_PARAMS */ 369 /* some newer drives don't support ATA_CMD_INIT_DEV_PARAMS */
385 hwif->tp_ops->read_status(hwif) == ATA_CMD_INIT_DEV_PARAMS) 370 hwif->tp_ops->read_status(hwif) == ATA_CMD_INIT_DEV_PARAMS)
386 return ide_stopped; 371 return ide_stopped;
@@ -428,7 +413,8 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u
428{ 413{
429 ide_hwif_t *hwif = drive->hwif; 414 ide_hwif_t *hwif = drive->hwif;
430 415
431 if ((stat & ATA_BUSY) || ((stat & ATA_DF) && !drive->nowerr)) { 416 if ((stat & ATA_BUSY) ||
417 ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) {
432 /* other bits are useless when BUSY */ 418 /* other bits are useless when BUSY */
433 rq->errors |= ERROR_RESET; 419 rq->errors |= ERROR_RESET;
434 } else { 420 } else {
@@ -509,7 +495,7 @@ static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf)
509 tf->lbal = drive->sect; 495 tf->lbal = drive->sect;
510 tf->lbam = drive->cyl; 496 tf->lbam = drive->cyl;
511 tf->lbah = drive->cyl >> 8; 497 tf->lbah = drive->cyl >> 8;
512 tf->device = ((drive->head - 1) | drive->select.all) & ~ATA_LBA; 498 tf->device = (drive->head - 1) | drive->select;
513 tf->command = ATA_CMD_INIT_DEV_PARAMS; 499 tf->command = ATA_CMD_INIT_DEV_PARAMS;
514} 500}
515 501
@@ -557,30 +543,6 @@ static ide_startstop_t ide_disk_special(ide_drive_t *drive)
557 return ide_started; 543 return ide_started;
558} 544}
559 545
560/*
561 * handle HDIO_SET_PIO_MODE ioctl abusers here, eventually it will go away
562 */
563static int set_pio_mode_abuse(ide_hwif_t *hwif, u8 req_pio)
564{
565 switch (req_pio) {
566 case 202:
567 case 201:
568 case 200:
569 case 102:
570 case 101:
571 case 100:
572 return (hwif->host_flags & IDE_HFLAG_ABUSE_DMA_MODES) ? 1 : 0;
573 case 9:
574 case 8:
575 return (hwif->host_flags & IDE_HFLAG_ABUSE_PREFETCH) ? 1 : 0;
576 case 7:
577 case 6:
578 return (hwif->host_flags & IDE_HFLAG_ABUSE_FAST_DEVSEL) ? 1 : 0;
579 default:
580 return 0;
581 }
582}
583
584/** 546/**
585 * do_special - issue some special commands 547 * do_special - issue some special commands
586 * @drive: drive the command is for 548 * @drive: drive the command is for
@@ -598,45 +560,12 @@ static ide_startstop_t do_special (ide_drive_t *drive)
598#ifdef DEBUG 560#ifdef DEBUG
599 printk("%s: do_special: 0x%02x\n", drive->name, s->all); 561 printk("%s: do_special: 0x%02x\n", drive->name, s->all);
600#endif 562#endif
601 if (s->b.set_tune) { 563 if (drive->media == ide_disk)
602 ide_hwif_t *hwif = drive->hwif; 564 return ide_disk_special(drive);
603 const struct ide_port_ops *port_ops = hwif->port_ops;
604 u8 req_pio = drive->tune_req;
605
606 s->b.set_tune = 0;
607
608 if (set_pio_mode_abuse(drive->hwif, req_pio)) {
609 /*
610 * take ide_lock for drive->[no_]unmask/[no_]io_32bit
611 */
612 if (req_pio == 8 || req_pio == 9) {
613 unsigned long flags;
614
615 spin_lock_irqsave(&ide_lock, flags);
616 port_ops->set_pio_mode(drive, req_pio);
617 spin_unlock_irqrestore(&ide_lock, flags);
618 } else
619 port_ops->set_pio_mode(drive, req_pio);
620 } else {
621 int keep_dma = drive->using_dma;
622
623 ide_set_pio(drive, req_pio);
624
625 if (hwif->host_flags & IDE_HFLAG_SET_PIO_MODE_KEEP_DMA) {
626 if (keep_dma)
627 ide_dma_on(drive);
628 }
629 }
630
631 return ide_stopped;
632 } else {
633 if (drive->media == ide_disk)
634 return ide_disk_special(drive);
635 565
636 s->all = 0; 566 s->all = 0;
637 drive->mult_req = 0; 567 drive->mult_req = 0;
638 return ide_stopped; 568 return ide_stopped;
639 }
640} 569}
641 570
642void ide_map_sg(ide_drive_t *drive, struct request *rq) 571void ide_map_sg(ide_drive_t *drive, struct request *rq)
@@ -726,10 +655,7 @@ int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting,
726 if (!(setting->flags & DS_SYNC)) 655 if (!(setting->flags & DS_SYNC))
727 return setting->set(drive, arg); 656 return setting->set(drive, arg);
728 657
729 rq = blk_get_request(q, READ, GFP_KERNEL); 658 rq = blk_get_request(q, READ, __GFP_WAIT);
730 if (!rq)
731 return -ENOMEM;
732
733 rq->cmd_type = REQ_TYPE_SPECIAL; 659 rq->cmd_type = REQ_TYPE_SPECIAL;
734 rq->cmd_len = 5; 660 rq->cmd_len = 5;
735 rq->cmd[0] = REQ_DEVSET_EXEC; 661 rq->cmd[0] = REQ_DEVSET_EXEC;
@@ -746,7 +672,32 @@ EXPORT_SYMBOL_GPL(ide_devset_execute);
746 672
747static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq) 673static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq)
748{ 674{
749 switch (rq->cmd[0]) { 675 u8 cmd = rq->cmd[0];
676
677 if (cmd == REQ_PARK_HEADS || cmd == REQ_UNPARK_HEADS) {
678 ide_task_t task;
679 struct ide_taskfile *tf = &task.tf;
680
681 memset(&task, 0, sizeof(task));
682 if (cmd == REQ_PARK_HEADS) {
683 drive->sleep = *(unsigned long *)rq->special;
684 drive->dev_flags |= IDE_DFLAG_SLEEPING;
685 tf->command = ATA_CMD_IDLEIMMEDIATE;
686 tf->feature = 0x44;
687 tf->lbal = 0x4c;
688 tf->lbam = 0x4e;
689 tf->lbah = 0x55;
690 task.tf_flags |= IDE_TFLAG_CUSTOM_HANDLER;
691 } else /* cmd == REQ_UNPARK_HEADS */
692 tf->command = ATA_CMD_CHK_POWER;
693
694 task.tf_flags |= IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
695 task.rq = rq;
696 drive->hwif->data_phase = task.data_phase = TASKFILE_NO_DATA;
697 return do_rw_taskfile(drive, &task);
698 }
699
700 switch (cmd) {
750 case REQ_DEVSET_EXEC: 701 case REQ_DEVSET_EXEC:
751 { 702 {
752 int err, (*setfunc)(ide_drive_t *, int) = rq->special; 703 int err, (*setfunc)(ide_drive_t *, int) = rq->special;
@@ -773,11 +724,11 @@ static void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
773 struct request_pm_state *pm = rq->data; 724 struct request_pm_state *pm = rq->data;
774 725
775 if (blk_pm_suspend_request(rq) && 726 if (blk_pm_suspend_request(rq) &&
776 pm->pm_step == ide_pm_state_start_suspend) 727 pm->pm_step == IDE_PM_START_SUSPEND)
777 /* Mark drive blocked when starting the suspend sequence. */ 728 /* Mark drive blocked when starting the suspend sequence. */
778 drive->blocked = 1; 729 drive->dev_flags |= IDE_DFLAG_BLOCKED;
779 else if (blk_pm_resume_request(rq) && 730 else if (blk_pm_resume_request(rq) &&
780 pm->pm_step == ide_pm_state_start_resume) { 731 pm->pm_step == IDE_PM_START_RESUME) {
781 /* 732 /*
782 * The first thing we do on wakeup is to wait for BSY bit to 733 * The first thing we do on wakeup is to wait for BSY bit to
783 * go away (with a looong timeout) as a drive on this hwif may 734 * go away (with a looong timeout) as a drive on this hwif may
@@ -857,7 +808,7 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq)
857#endif 808#endif
858 startstop = ide_start_power_step(drive, rq); 809 startstop = ide_start_power_step(drive, rq);
859 if (startstop == ide_stopped && 810 if (startstop == ide_stopped &&
860 pm->pm_step == ide_pm_state_completed) 811 pm->pm_step == IDE_PM_COMPLETED)
861 ide_complete_pm_request(drive, rq); 812 ide_complete_pm_request(drive, rq);
862 return startstop; 813 return startstop;
863 } else if (!rq->rq_disk && blk_special_request(rq)) 814 } else if (!rq->rq_disk && blk_special_request(rq))
@@ -895,7 +846,7 @@ void ide_stall_queue (ide_drive_t *drive, unsigned long timeout)
895 if (timeout > WAIT_WORSTCASE) 846 if (timeout > WAIT_WORSTCASE)
896 timeout = WAIT_WORSTCASE; 847 timeout = WAIT_WORSTCASE;
897 drive->sleep = timeout + jiffies; 848 drive->sleep = timeout + jiffies;
898 drive->sleeping = 1; 849 drive->dev_flags |= IDE_DFLAG_SLEEPING;
899} 850}
900 851
901EXPORT_SYMBOL(ide_stall_queue); 852EXPORT_SYMBOL(ide_stall_queue);
@@ -935,18 +886,23 @@ repeat:
935 } 886 }
936 887
937 do { 888 do {
938 if ((!drive->sleeping || time_after_eq(jiffies, drive->sleep)) 889 u8 dev_s = !!(drive->dev_flags & IDE_DFLAG_SLEEPING);
939 && !elv_queue_empty(drive->queue)) { 890 u8 best_s = (best && !!(best->dev_flags & IDE_DFLAG_SLEEPING));
940 if (!best 891
941 || (drive->sleeping && (!best->sleeping || time_before(drive->sleep, best->sleep))) 892 if ((dev_s == 0 || time_after_eq(jiffies, drive->sleep)) &&
942 || (!best->sleeping && time_before(WAKEUP(drive), WAKEUP(best)))) 893 !elv_queue_empty(drive->queue)) {
943 { 894 if (best == NULL ||
895 (dev_s && (best_s == 0 || time_before(drive->sleep, best->sleep))) ||
896 (best_s == 0 && time_before(WAKEUP(drive), WAKEUP(best)))) {
944 if (!blk_queue_plugged(drive->queue)) 897 if (!blk_queue_plugged(drive->queue))
945 best = drive; 898 best = drive;
946 } 899 }
947 } 900 }
948 } while ((drive = drive->next) != hwgroup->drive); 901 } while ((drive = drive->next) != hwgroup->drive);
949 if (best && best->nice1 && !best->sleeping && best != hwgroup->drive && best->service_time > WAIT_MIN_SLEEP) { 902
903 if (best && (best->dev_flags & IDE_DFLAG_NICE1) &&
904 (best->dev_flags & IDE_DFLAG_SLEEPING) == 0 &&
905 best != hwgroup->drive && best->service_time > WAIT_MIN_SLEEP) {
950 long t = (signed long)(WAKEUP(best) - jiffies); 906 long t = (signed long)(WAKEUP(best) - jiffies);
951 if (t >= WAIT_MIN_SLEEP) { 907 if (t >= WAIT_MIN_SLEEP) {
952 /* 908 /*
@@ -955,7 +911,7 @@ repeat:
955 */ 911 */
956 drive = best->next; 912 drive = best->next;
957 do { 913 do {
958 if (!drive->sleeping 914 if ((drive->dev_flags & IDE_DFLAG_SLEEPING) == 0
959 && time_before(jiffies - best->service_time, WAKEUP(drive)) 915 && time_before(jiffies - best->service_time, WAKEUP(drive))
960 && time_before(WAKEUP(drive), jiffies + t)) 916 && time_before(WAKEUP(drive), jiffies + t))
961 { 917 {
@@ -1026,7 +982,9 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
1026 hwgroup->rq = NULL; 982 hwgroup->rq = NULL;
1027 drive = hwgroup->drive; 983 drive = hwgroup->drive;
1028 do { 984 do {
1029 if (drive->sleeping && (!sleeping || time_before(drive->sleep, sleep))) { 985 if ((drive->dev_flags & IDE_DFLAG_SLEEPING) &&
986 (sleeping == 0 ||
987 time_before(drive->sleep, sleep))) {
1030 sleeping = 1; 988 sleeping = 1;
1031 sleep = drive->sleep; 989 sleep = drive->sleep;
1032 } 990 }
@@ -1075,7 +1033,7 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
1075 } 1033 }
1076 hwgroup->hwif = hwif; 1034 hwgroup->hwif = hwif;
1077 hwgroup->drive = drive; 1035 hwgroup->drive = drive;
1078 drive->sleeping = 0; 1036 drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED);
1079 drive->service_start = jiffies; 1037 drive->service_start = jiffies;
1080 1038
1081 if (blk_queue_plugged(drive->queue)) { 1039 if (blk_queue_plugged(drive->queue)) {
@@ -1109,7 +1067,9 @@ static void ide_do_request (ide_hwgroup_t *hwgroup, int masked_irq)
1109 * We count how many times we loop here to make sure we service 1067 * We count how many times we loop here to make sure we service
1110 * all drives in the hwgroup without looping for ever 1068 * all drives in the hwgroup without looping for ever
1111 */ 1069 */
1112 if (drive->blocked && !blk_pm_request(rq) && !(rq->cmd_flags & REQ_PREEMPT)) { 1070 if ((drive->dev_flags & IDE_DFLAG_BLOCKED) &&
1071 blk_pm_request(rq) == 0 &&
1072 (rq->cmd_flags & REQ_PREEMPT) == 0) {
1113 drive = drive->next ? drive->next : hwgroup->drive; 1073 drive = drive->next ? drive->next : hwgroup->drive;
1114 if (loops++ < 4 && !blk_queue_plugged(drive->queue)) 1074 if (loops++ < 4 && !blk_queue_plugged(drive->queue))
1115 goto again; 1075 goto again;
@@ -1182,8 +1142,8 @@ static ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
1182 * a timeout -- we'll reenable after we finish this next request 1142 * a timeout -- we'll reenable after we finish this next request
1183 * (or rather the first chunk of it) in pio. 1143 * (or rather the first chunk of it) in pio.
1184 */ 1144 */
1145 drive->dev_flags |= IDE_DFLAG_DMA_PIO_RETRY;
1185 drive->retry_pio++; 1146 drive->retry_pio++;
1186 drive->state = DMA_PIO_RETRY;
1187 ide_dma_off_quietly(drive); 1147 ide_dma_off_quietly(drive);
1188 1148
1189 /* 1149 /*
@@ -1480,23 +1440,16 @@ irqreturn_t ide_intr (int irq, void *dev_id)
1480 del_timer(&hwgroup->timer); 1440 del_timer(&hwgroup->timer);
1481 spin_unlock(&ide_lock); 1441 spin_unlock(&ide_lock);
1482 1442
1483 /* Some controllers might set DMA INTR no matter DMA or PIO; 1443 if (hwif->port_ops && hwif->port_ops->clear_irq)
1484 * bmdma status might need to be cleared even for 1444 hwif->port_ops->clear_irq(drive);
1485 * PIO interrupts to prevent spurious/lost irq.
1486 */
1487 if (hwif->ide_dma_clear_irq && !(drive->waiting_for_dma))
1488 /* ide_dma_end() needs bmdma status for error checking.
1489 * So, skip clearing bmdma status here and leave it
1490 * to ide_dma_end() if this is dma interrupt.
1491 */
1492 hwif->ide_dma_clear_irq(drive);
1493 1445
1494 if (drive->unmask) 1446 if (drive->dev_flags & IDE_DFLAG_UNMASK)
1495 local_irq_enable_in_hardirq(); 1447 local_irq_enable_in_hardirq();
1448
1496 /* service this interrupt, may set handler for next interrupt */ 1449 /* service this interrupt, may set handler for next interrupt */
1497 startstop = handler(drive); 1450 startstop = handler(drive);
1498 spin_lock_irq(&ide_lock);
1499 1451
1452 spin_lock_irq(&ide_lock);
1500 /* 1453 /*
1501 * Note that handler() may have set things up for another 1454 * Note that handler() may have set things up for another
1502 * interrupt to occur soon, but it cannot happen until 1455 * interrupt to occur soon, but it cannot happen until