diff options
Diffstat (limited to 'drivers/ide/ide-atapi.c')
| -rw-r--r-- | drivers/ide/ide-atapi.c | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index 2802031de670..adf04f99cdeb 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c | |||
| @@ -22,6 +22,8 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 22 | void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int)) | 22 | void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int)) |
| 23 | { | 23 | { |
| 24 | ide_hwif_t *hwif = drive->hwif; | 24 | ide_hwif_t *hwif = drive->hwif; |
| 25 | struct request *rq = hwif->hwgroup->rq; | ||
| 26 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
| 25 | xfer_func_t *xferfunc; | 27 | xfer_func_t *xferfunc; |
| 26 | unsigned int temp; | 28 | unsigned int temp; |
| 27 | u16 bcount; | 29 | u16 bcount; |
| @@ -30,12 +32,12 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 30 | debug_log("Enter %s - interrupt handler\n", __func__); | 32 | debug_log("Enter %s - interrupt handler\n", __func__); |
| 31 | 33 | ||
| 32 | if (pc->flags & PC_FLAG_TIMEDOUT) { | 34 | if (pc->flags & PC_FLAG_TIMEDOUT) { |
| 33 | pc->callback(drive); | 35 | drive->pc_callback(drive); |
| 34 | return ide_stopped; | 36 | return ide_stopped; |
| 35 | } | 37 | } |
| 36 | 38 | ||
| 37 | /* Clear the interrupt */ | 39 | /* Clear the interrupt */ |
| 38 | stat = ide_read_status(drive); | 40 | stat = tp_ops->read_status(hwif); |
| 39 | 41 | ||
| 40 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | 42 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { |
| 41 | if (hwif->dma_ops->dma_end(drive) || | 43 | if (hwif->dma_ops->dma_end(drive) || |
| @@ -63,8 +65,9 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 63 | local_irq_enable_in_hardirq(); | 65 | local_irq_enable_in_hardirq(); |
| 64 | 66 | ||
| 65 | if (drive->media == ide_tape && !scsi && | 67 | if (drive->media == ide_tape && !scsi && |
| 66 | (stat & ERR_STAT) && pc->c[0] == REQUEST_SENSE) | 68 | (stat & ERR_STAT) && rq->cmd[0] == REQUEST_SENSE) |
| 67 | stat &= ~ERR_STAT; | 69 | stat &= ~ERR_STAT; |
| 70 | |||
| 68 | if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) { | 71 | if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) { |
| 69 | /* Error detected */ | 72 | /* Error detected */ |
| 70 | debug_log("%s: I/O error\n", drive->name); | 73 | debug_log("%s: I/O error\n", drive->name); |
| @@ -75,16 +78,17 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 75 | goto cmd_finished; | 78 | goto cmd_finished; |
| 76 | } | 79 | } |
| 77 | 80 | ||
| 78 | if (pc->c[0] == REQUEST_SENSE) { | 81 | if (rq->cmd[0] == REQUEST_SENSE) { |
| 79 | printk(KERN_ERR "%s: I/O error in request sense" | 82 | printk(KERN_ERR "%s: I/O error in request sense" |
| 80 | " command\n", drive->name); | 83 | " command\n", drive->name); |
| 81 | return ide_do_reset(drive); | 84 | return ide_do_reset(drive); |
| 82 | } | 85 | } |
| 83 | 86 | ||
| 84 | debug_log("[cmd %x]: check condition\n", pc->c[0]); | 87 | debug_log("[cmd %x]: check condition\n", rq->cmd[0]); |
| 85 | 88 | ||
| 86 | /* Retry operation */ | 89 | /* Retry operation */ |
| 87 | retry_pc(drive); | 90 | retry_pc(drive); |
| 91 | |||
| 88 | /* queued, but not started */ | 92 | /* queued, but not started */ |
| 89 | return ide_stopped; | 93 | return ide_stopped; |
| 90 | } | 94 | } |
| @@ -95,8 +99,10 @@ cmd_finished: | |||
| 95 | dsc_handle(drive); | 99 | dsc_handle(drive); |
| 96 | return ide_stopped; | 100 | return ide_stopped; |
| 97 | } | 101 | } |
| 102 | |||
| 98 | /* Command finished - Call the callback function */ | 103 | /* Command finished - Call the callback function */ |
| 99 | pc->callback(drive); | 104 | drive->pc_callback(drive); |
| 105 | |||
| 100 | return ide_stopped; | 106 | return ide_stopped; |
| 101 | } | 107 | } |
| 102 | 108 | ||
| @@ -107,16 +113,15 @@ cmd_finished: | |||
| 107 | ide_dma_off(drive); | 113 | ide_dma_off(drive); |
| 108 | return ide_do_reset(drive); | 114 | return ide_do_reset(drive); |
| 109 | } | 115 | } |
| 110 | /* Get the number of bytes to transfer on this interrupt. */ | ||
| 111 | bcount = (hwif->INB(hwif->io_ports.lbah_addr) << 8) | | ||
| 112 | hwif->INB(hwif->io_ports.lbam_addr); | ||
| 113 | 116 | ||
| 114 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | 117 | /* Get the number of bytes to transfer on this interrupt. */ |
| 118 | ide_read_bcount_and_ireason(drive, &bcount, &ireason); | ||
| 115 | 119 | ||
| 116 | if (ireason & CD) { | 120 | if (ireason & CD) { |
| 117 | printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__); | 121 | printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__); |
| 118 | return ide_do_reset(drive); | 122 | return ide_do_reset(drive); |
| 119 | } | 123 | } |
| 124 | |||
| 120 | if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) { | 125 | if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) { |
| 121 | /* Hopefully, we will never get here */ | 126 | /* Hopefully, we will never get here */ |
| 122 | printk(KERN_ERR "%s: We wanted to %s, but the device wants us " | 127 | printk(KERN_ERR "%s: We wanted to %s, but the device wants us " |
| @@ -125,6 +130,7 @@ cmd_finished: | |||
| 125 | (ireason & IO) ? "Read" : "Write"); | 130 | (ireason & IO) ? "Read" : "Write"); |
| 126 | return ide_do_reset(drive); | 131 | return ide_do_reset(drive); |
| 127 | } | 132 | } |
| 133 | |||
| 128 | if (!(pc->flags & PC_FLAG_WRITING)) { | 134 | if (!(pc->flags & PC_FLAG_WRITING)) { |
| 129 | /* Reading - Check that we have enough space */ | 135 | /* Reading - Check that we have enough space */ |
| 130 | temp = pc->xferred + bcount; | 136 | temp = pc->xferred + bcount; |
| @@ -142,7 +148,7 @@ cmd_finished: | |||
| 142 | if (pc->sg) | 148 | if (pc->sg) |
| 143 | io_buffers(drive, pc, temp, 0); | 149 | io_buffers(drive, pc, temp, 0); |
| 144 | else | 150 | else |
| 145 | hwif->input_data(drive, NULL, | 151 | tp_ops->input_data(drive, NULL, |
| 146 | pc->cur_pos, temp); | 152 | pc->cur_pos, temp); |
| 147 | printk(KERN_ERR "%s: transferred %d of " | 153 | printk(KERN_ERR "%s: transferred %d of " |
| 148 | "%d bytes\n", | 154 | "%d bytes\n", |
| @@ -159,9 +165,9 @@ cmd_finished: | |||
| 159 | debug_log("The device wants to send us more data than " | 165 | debug_log("The device wants to send us more data than " |
| 160 | "expected - allowing transfer\n"); | 166 | "expected - allowing transfer\n"); |
| 161 | } | 167 | } |
| 162 | xferfunc = hwif->input_data; | 168 | xferfunc = tp_ops->input_data; |
| 163 | } else | 169 | } else |
| 164 | xferfunc = hwif->output_data; | 170 | xferfunc = tp_ops->output_data; |
| 165 | 171 | ||
| 166 | if ((drive->media == ide_floppy && !scsi && !pc->buf) || | 172 | if ((drive->media == ide_floppy && !scsi && !pc->buf) || |
| 167 | (drive->media == ide_tape && !scsi && pc->bh) || | 173 | (drive->media == ide_tape && !scsi && pc->bh) || |
| @@ -175,7 +181,7 @@ cmd_finished: | |||
| 175 | pc->cur_pos += bcount; | 181 | pc->cur_pos += bcount; |
| 176 | 182 | ||
| 177 | debug_log("[cmd %x] transferred %d bytes on that intr.\n", | 183 | debug_log("[cmd %x] transferred %d bytes on that intr.\n", |
| 178 | pc->c[0], bcount); | 184 | rq->cmd[0], bcount); |
| 179 | 185 | ||
| 180 | /* And set the interrupt handler again */ | 186 | /* And set the interrupt handler again */ |
| 181 | ide_set_handler(drive, handler, timeout, expiry); | 187 | ide_set_handler(drive, handler, timeout, expiry); |
| @@ -183,16 +189,27 @@ cmd_finished: | |||
| 183 | } | 189 | } |
| 184 | EXPORT_SYMBOL_GPL(ide_pc_intr); | 190 | EXPORT_SYMBOL_GPL(ide_pc_intr); |
| 185 | 191 | ||
| 192 | static u8 ide_read_ireason(ide_drive_t *drive) | ||
| 193 | { | ||
| 194 | ide_task_t task; | ||
| 195 | |||
| 196 | memset(&task, 0, sizeof(task)); | ||
| 197 | task.tf_flags = IDE_TFLAG_IN_NSECT; | ||
| 198 | |||
| 199 | drive->hwif->tp_ops->tf_read(drive, &task); | ||
| 200 | |||
| 201 | return task.tf.nsect & 3; | ||
| 202 | } | ||
| 203 | |||
| 186 | static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason) | 204 | static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason) |
| 187 | { | 205 | { |
| 188 | ide_hwif_t *hwif = drive->hwif; | ||
| 189 | int retries = 100; | 206 | int retries = 100; |
| 190 | 207 | ||
| 191 | while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { | 208 | while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { |
| 192 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " | 209 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " |
| 193 | "a packet command, retrying\n", drive->name); | 210 | "a packet command, retrying\n", drive->name); |
| 194 | udelay(100); | 211 | udelay(100); |
| 195 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | 212 | ireason = ide_read_ireason(drive); |
| 196 | if (retries == 0) { | 213 | if (retries == 0) { |
| 197 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " | 214 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " |
| 198 | "a packet command, ignoring\n", | 215 | "a packet command, ignoring\n", |
| @@ -210,6 +227,7 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 210 | ide_expiry_t *expiry) | 227 | ide_expiry_t *expiry) |
| 211 | { | 228 | { |
| 212 | ide_hwif_t *hwif = drive->hwif; | 229 | ide_hwif_t *hwif = drive->hwif; |
| 230 | struct request *rq = hwif->hwgroup->rq; | ||
| 213 | ide_startstop_t startstop; | 231 | ide_startstop_t startstop; |
| 214 | u8 ireason; | 232 | u8 ireason; |
| 215 | 233 | ||
| @@ -219,7 +237,7 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 219 | return startstop; | 237 | return startstop; |
| 220 | } | 238 | } |
| 221 | 239 | ||
| 222 | ireason = hwif->INB(hwif->io_ports.nsect_addr); | 240 | ireason = ide_read_ireason(drive); |
| 223 | if (drive->media == ide_tape && !drive->scsi) | 241 | if (drive->media == ide_tape && !drive->scsi) |
| 224 | ireason = ide_wait_ireason(drive, ireason); | 242 | ireason = ide_wait_ireason(drive, ireason); |
| 225 | 243 | ||
| @@ -239,8 +257,8 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 239 | } | 257 | } |
| 240 | 258 | ||
| 241 | /* Send the actual packet */ | 259 | /* Send the actual packet */ |
| 242 | if ((pc->flags & PC_FLAG_ZIP_DRIVE) == 0) | 260 | if ((drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) == 0) |
| 243 | hwif->output_data(drive, NULL, pc->c, 12); | 261 | hwif->tp_ops->output_data(drive, NULL, rq->cmd, 12); |
| 244 | 262 | ||
| 245 | return ide_started; | 263 | return ide_started; |
| 246 | } | 264 | } |
| @@ -284,7 +302,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 284 | bcount, dma); | 302 | bcount, dma); |
| 285 | 303 | ||
| 286 | /* Issue the packet command */ | 304 | /* Issue the packet command */ |
| 287 | if (pc->flags & PC_FLAG_DRQ_INTERRUPT) { | 305 | if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { |
| 288 | ide_execute_command(drive, WIN_PACKETCMD, handler, | 306 | ide_execute_command(drive, WIN_PACKETCMD, handler, |
| 289 | timeout, NULL); | 307 | timeout, NULL); |
| 290 | return ide_started; | 308 | return ide_started; |
