ide: remove ->end_request method
[GitHub/LineageOS/android_kernel_motorola_exynos9610.git] / drivers / ide / ide-atapi.c
... / ...
CommitLineData
1/*
2 * ATAPI support.
3 */
4
5#include <linux/kernel.h>
6#include <linux/cdrom.h>
7#include <linux/delay.h>
8#include <linux/ide.h>
9#include <scsi/scsi.h>
10
11#ifdef DEBUG
12#define debug_log(fmt, args...) \
13 printk(KERN_INFO "ide: " fmt, ## args)
14#else
15#define debug_log(fmt, args...) do {} while (0)
16#endif
17
18#define ATAPI_MIN_CDB_BYTES 12
19
20static inline int dev_is_idecd(ide_drive_t *drive)
21{
22 return drive->media == ide_cdrom || drive->media == ide_optical;
23}
24
25/*
26 * Check whether we can support a device,
27 * based on the ATAPI IDENTIFY command results.
28 */
29int ide_check_atapi_device(ide_drive_t *drive, const char *s)
30{
31 u16 *id = drive->id;
32 u8 gcw[2], protocol, device_type, removable, drq_type, packet_size;
33
34 *((u16 *)&gcw) = id[ATA_ID_CONFIG];
35
36 protocol = (gcw[1] & 0xC0) >> 6;
37 device_type = gcw[1] & 0x1F;
38 removable = (gcw[0] & 0x80) >> 7;
39 drq_type = (gcw[0] & 0x60) >> 5;
40 packet_size = gcw[0] & 0x03;
41
42#ifdef CONFIG_PPC
43 /* kludge for Apple PowerBook internal zip */
44 if (drive->media == ide_floppy && device_type == 5 &&
45 !strstr((char *)&id[ATA_ID_PROD], "CD-ROM") &&
46 strstr((char *)&id[ATA_ID_PROD], "ZIP"))
47 device_type = 0;
48#endif
49
50 if (protocol != 2)
51 printk(KERN_ERR "%s: %s: protocol (0x%02x) is not ATAPI\n",
52 s, drive->name, protocol);
53 else if ((drive->media == ide_floppy && device_type != 0) ||
54 (drive->media == ide_tape && device_type != 1))
55 printk(KERN_ERR "%s: %s: invalid device type (0x%02x)\n",
56 s, drive->name, device_type);
57 else if (removable == 0)
58 printk(KERN_ERR "%s: %s: the removable flag is not set\n",
59 s, drive->name);
60 else if (drive->media == ide_floppy && drq_type == 3)
61 printk(KERN_ERR "%s: %s: sorry, DRQ type (0x%02x) not "
62 "supported\n", s, drive->name, drq_type);
63 else if (packet_size != 0)
64 printk(KERN_ERR "%s: %s: packet size (0x%02x) is not 12 "
65 "bytes\n", s, drive->name, packet_size);
66 else
67 return 1;
68 return 0;
69}
70EXPORT_SYMBOL_GPL(ide_check_atapi_device);
71
72/* PIO data transfer routine using the scatter gather table. */
73int ide_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
74 unsigned int bcount, int write)
75{
76 ide_hwif_t *hwif = drive->hwif;
77 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
78 xfer_func_t *xf = write ? tp_ops->output_data : tp_ops->input_data;
79 struct scatterlist *sg = pc->sg;
80 char *buf;
81 int count, done = 0;
82
83 while (bcount) {
84 count = min(sg->length - pc->b_count, bcount);
85
86 if (PageHighMem(sg_page(sg))) {
87 unsigned long flags;
88
89 local_irq_save(flags);
90 buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset;
91 xf(drive, NULL, buf + pc->b_count, count);
92 kunmap_atomic(buf - sg->offset, KM_IRQ0);
93 local_irq_restore(flags);
94 } else {
95 buf = sg_virt(sg);
96 xf(drive, NULL, buf + pc->b_count, count);
97 }
98
99 bcount -= count;
100 pc->b_count += count;
101 done += count;
102
103 if (pc->b_count == sg->length) {
104 if (!--pc->sg_cnt)
105 break;
106 pc->sg = sg = sg_next(sg);
107 pc->b_count = 0;
108 }
109 }
110
111 if (bcount) {
112 printk(KERN_ERR "%s: %d leftover bytes, %s\n", drive->name,
113 bcount, write ? "padding with zeros"
114 : "discarding data");
115 ide_pad_transfer(drive, write, bcount);
116 }
117
118 return done;
119}
120EXPORT_SYMBOL_GPL(ide_io_buffers);
121
122void ide_init_pc(struct ide_atapi_pc *pc)
123{
124 memset(pc, 0, sizeof(*pc));
125 pc->buf = pc->pc_buf;
126 pc->buf_size = IDE_PC_BUFFER_SIZE;
127}
128EXPORT_SYMBOL_GPL(ide_init_pc);
129
130/*
131 * Generate a new packet command request in front of the request queue, before
132 * the current request, so that it will be processed immediately, on the next
133 * pass through the driver.
134 */
135static void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk,
136 struct ide_atapi_pc *pc, struct request *rq)
137{
138 blk_rq_init(NULL, rq);
139 rq->cmd_type = REQ_TYPE_SPECIAL;
140 rq->cmd_flags |= REQ_PREEMPT;
141 rq->buffer = (char *)pc;
142 rq->rq_disk = disk;
143
144 if (pc->req_xfer) {
145 rq->data = pc->buf;
146 rq->data_len = pc->req_xfer;
147 }
148
149 memcpy(rq->cmd, pc->c, 12);
150 if (drive->media == ide_tape)
151 rq->cmd[13] = REQ_IDETAPE_PC1;
152
153 drive->hwif->rq = NULL;
154
155 elv_add_request(drive->queue, rq, ELEVATOR_INSERT_FRONT, 0);
156}
157
158/*
159 * Add a special packet command request to the tail of the request queue,
160 * and wait for it to be serviced.
161 */
162int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
163 struct ide_atapi_pc *pc)
164{
165 struct request *rq;
166 int error;
167
168 rq = blk_get_request(drive->queue, READ, __GFP_WAIT);
169 rq->cmd_type = REQ_TYPE_SPECIAL;
170 rq->buffer = (char *)pc;
171
172 if (pc->req_xfer) {
173 rq->data = pc->buf;
174 rq->data_len = pc->req_xfer;
175 }
176
177 memcpy(rq->cmd, pc->c, 12);
178 if (drive->media == ide_tape)
179 rq->cmd[13] = REQ_IDETAPE_PC1;
180 error = blk_execute_rq(drive->queue, disk, rq, 0);
181 blk_put_request(rq);
182
183 return error;
184}
185EXPORT_SYMBOL_GPL(ide_queue_pc_tail);
186
187int ide_do_test_unit_ready(ide_drive_t *drive, struct gendisk *disk)
188{
189 struct ide_atapi_pc pc;
190
191 ide_init_pc(&pc);
192 pc.c[0] = TEST_UNIT_READY;
193
194 return ide_queue_pc_tail(drive, disk, &pc);
195}
196EXPORT_SYMBOL_GPL(ide_do_test_unit_ready);
197
198int ide_do_start_stop(ide_drive_t *drive, struct gendisk *disk, int start)
199{
200 struct ide_atapi_pc pc;
201
202 ide_init_pc(&pc);
203 pc.c[0] = START_STOP;
204 pc.c[4] = start;
205
206 if (drive->media == ide_tape)
207 pc.flags |= PC_FLAG_WAIT_FOR_DSC;
208
209 return ide_queue_pc_tail(drive, disk, &pc);
210}
211EXPORT_SYMBOL_GPL(ide_do_start_stop);
212
213int ide_set_media_lock(ide_drive_t *drive, struct gendisk *disk, int on)
214{
215 struct ide_atapi_pc pc;
216
217 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) == 0)
218 return 0;
219
220 ide_init_pc(&pc);
221 pc.c[0] = ALLOW_MEDIUM_REMOVAL;
222 pc.c[4] = on;
223
224 return ide_queue_pc_tail(drive, disk, &pc);
225}
226EXPORT_SYMBOL_GPL(ide_set_media_lock);
227
228void ide_create_request_sense_cmd(ide_drive_t *drive, struct ide_atapi_pc *pc)
229{
230 ide_init_pc(pc);
231 pc->c[0] = REQUEST_SENSE;
232 if (drive->media == ide_floppy) {
233 pc->c[4] = 255;
234 pc->req_xfer = 18;
235 } else {
236 pc->c[4] = 20;
237 pc->req_xfer = 20;
238 }
239}
240EXPORT_SYMBOL_GPL(ide_create_request_sense_cmd);
241
242/*
243 * Called when an error was detected during the last packet command.
244 * We queue a request sense packet command in the head of the request list.
245 */
246void ide_retry_pc(ide_drive_t *drive, struct gendisk *disk)
247{
248 struct request *rq = &drive->request_sense_rq;
249 struct ide_atapi_pc *pc = &drive->request_sense_pc;
250
251 (void)ide_read_error(drive);
252 ide_create_request_sense_cmd(drive, pc);
253 if (drive->media == ide_tape)
254 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags);
255 ide_queue_pc_head(drive, disk, pc, rq);
256}
257EXPORT_SYMBOL_GPL(ide_retry_pc);
258
259int ide_cd_expiry(ide_drive_t *drive)
260{
261 struct request *rq = drive->hwif->rq;
262 unsigned long wait = 0;
263
264 debug_log("%s: rq->cmd[0]: 0x%x\n", __func__, rq->cmd[0]);
265
266 /*
267 * Some commands are *slow* and normally take a long time to complete.
268 * Usually we can use the ATAPI "disconnect" to bypass this, but not all
269 * commands/drives support that. Let ide_timer_expiry keep polling us
270 * for these.
271 */
272 switch (rq->cmd[0]) {
273 case GPCMD_BLANK:
274 case GPCMD_FORMAT_UNIT:
275 case GPCMD_RESERVE_RZONE_TRACK:
276 case GPCMD_CLOSE_TRACK:
277 case GPCMD_FLUSH_CACHE:
278 wait = ATAPI_WAIT_PC;
279 break;
280 default:
281 if (!(rq->cmd_flags & REQ_QUIET))
282 printk(KERN_INFO "cmd 0x%x timed out\n",
283 rq->cmd[0]);
284 wait = 0;
285 break;
286 }
287 return wait;
288}
289EXPORT_SYMBOL_GPL(ide_cd_expiry);
290
291int ide_cd_get_xferlen(struct request *rq)
292{
293 if (blk_fs_request(rq))
294 return 32768;
295 else if (blk_sense_request(rq) || blk_pc_request(rq) ||
296 rq->cmd_type == REQ_TYPE_ATA_PC)
297 return rq->data_len;
298 else
299 return 0;
300}
301EXPORT_SYMBOL_GPL(ide_cd_get_xferlen);
302
303void ide_read_bcount_and_ireason(ide_drive_t *drive, u16 *bcount, u8 *ireason)
304{
305 ide_task_t task;
306
307 memset(&task, 0, sizeof(task));
308 task.tf_flags = IDE_TFLAG_IN_LBAH | IDE_TFLAG_IN_LBAM |
309 IDE_TFLAG_IN_NSECT;
310
311 drive->hwif->tp_ops->tf_read(drive, &task);
312
313 *bcount = (task.tf.lbah << 8) | task.tf.lbam;
314 *ireason = task.tf.nsect & 3;
315}
316EXPORT_SYMBOL_GPL(ide_read_bcount_and_ireason);
317
318/*
319 * This is the usual interrupt handler which will be called during a packet
320 * command. We will transfer some of the data (as requested by the drive)
321 * and will re-point interrupt handler to us.
322 */
323static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
324{
325 struct ide_atapi_pc *pc = drive->pc;
326 ide_hwif_t *hwif = drive->hwif;
327 struct request *rq = hwif->rq;
328 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
329 xfer_func_t *xferfunc;
330 unsigned int timeout, temp;
331 u16 bcount;
332 u8 stat, ireason, dsc = 0;
333
334 debug_log("Enter %s - interrupt handler\n", __func__);
335
336 timeout = (drive->media == ide_floppy) ? WAIT_FLOPPY_CMD
337 : WAIT_TAPE_CMD;
338
339 /* Clear the interrupt */
340 stat = tp_ops->read_status(hwif);
341
342 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
343 if (hwif->dma_ops->dma_end(drive) ||
344 (drive->media == ide_tape && (stat & ATA_ERR))) {
345 if (drive->media == ide_floppy)
346 printk(KERN_ERR "%s: DMA %s error\n",
347 drive->name, rq_data_dir(pc->rq)
348 ? "write" : "read");
349 pc->flags |= PC_FLAG_DMA_ERROR;
350 } else {
351 pc->xferred = pc->req_xfer;
352 if (drive->pc_update_buffers)
353 drive->pc_update_buffers(drive, pc);
354 }
355 debug_log("%s: DMA finished\n", drive->name);
356 }
357
358 /* No more interrupts */
359 if ((stat & ATA_DRQ) == 0) {
360 debug_log("Packet command completed, %d bytes transferred\n",
361 pc->xferred);
362
363 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
364
365 local_irq_enable_in_hardirq();
366
367 if (drive->media == ide_tape &&
368 (stat & ATA_ERR) && rq->cmd[0] == REQUEST_SENSE)
369 stat &= ~ATA_ERR;
370
371 if ((stat & ATA_ERR) || (pc->flags & PC_FLAG_DMA_ERROR)) {
372 /* Error detected */
373 debug_log("%s: I/O error\n", drive->name);
374
375 if (drive->media != ide_tape)
376 pc->rq->errors++;
377
378 if (rq->cmd[0] == REQUEST_SENSE) {
379 printk(KERN_ERR "%s: I/O error in request sense"
380 " command\n", drive->name);
381 return ide_do_reset(drive);
382 }
383
384 debug_log("[cmd %x]: check condition\n", rq->cmd[0]);
385
386 /* Retry operation */
387 ide_retry_pc(drive, rq->rq_disk);
388
389 /* queued, but not started */
390 return ide_stopped;
391 }
392 pc->error = 0;
393
394 if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) && (stat & ATA_DSC) == 0)
395 dsc = 1;
396
397 /* Command finished - Call the callback function */
398 drive->pc_callback(drive, dsc);
399
400 return ide_stopped;
401 }
402
403 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) {
404 pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS;
405 printk(KERN_ERR "%s: The device wants to issue more interrupts "
406 "in DMA mode\n", drive->name);
407 ide_dma_off(drive);
408 return ide_do_reset(drive);
409 }
410
411 /* Get the number of bytes to transfer on this interrupt. */
412 ide_read_bcount_and_ireason(drive, &bcount, &ireason);
413
414 if (ireason & ATAPI_COD) {
415 printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__);
416 return ide_do_reset(drive);
417 }
418
419 if (((ireason & ATAPI_IO) == ATAPI_IO) ==
420 !!(pc->flags & PC_FLAG_WRITING)) {
421 /* Hopefully, we will never get here */
422 printk(KERN_ERR "%s: We wanted to %s, but the device wants us "
423 "to %s!\n", drive->name,
424 (ireason & ATAPI_IO) ? "Write" : "Read",
425 (ireason & ATAPI_IO) ? "Read" : "Write");
426 return ide_do_reset(drive);
427 }
428
429 if (!(pc->flags & PC_FLAG_WRITING)) {
430 /* Reading - Check that we have enough space */
431 temp = pc->xferred + bcount;
432 if (temp > pc->req_xfer) {
433 if (temp > pc->buf_size) {
434 printk(KERN_ERR "%s: The device wants to send "
435 "us more data than expected - "
436 "discarding data\n",
437 drive->name);
438
439 ide_pad_transfer(drive, 0, bcount);
440 goto next_irq;
441 }
442 debug_log("The device wants to send us more data than "
443 "expected - allowing transfer\n");
444 }
445 xferfunc = tp_ops->input_data;
446 } else
447 xferfunc = tp_ops->output_data;
448
449 if ((drive->media == ide_floppy && !pc->buf) ||
450 (drive->media == ide_tape && pc->bh)) {
451 int done = drive->pc_io_buffers(drive, pc, bcount,
452 !!(pc->flags & PC_FLAG_WRITING));
453
454 /* FIXME: don't do partial completions */
455 if (drive->media == ide_floppy)
456 ide_end_request(drive, 1, done >> 9);
457 } else
458 xferfunc(drive, NULL, pc->cur_pos, bcount);
459
460 /* Update the current position */
461 pc->xferred += bcount;
462 pc->cur_pos += bcount;
463
464 debug_log("[cmd %x] transferred %d bytes on that intr.\n",
465 rq->cmd[0], bcount);
466next_irq:
467 /* And set the interrupt handler again */
468 ide_set_handler(drive, ide_pc_intr, timeout, NULL);
469 return ide_started;
470}
471
472static void ide_pktcmd_tf_load(ide_drive_t *drive, u32 tf_flags, u16 bcount)
473{
474 ide_hwif_t *hwif = drive->hwif;
475 ide_task_t task;
476 u8 dma = drive->dma;
477
478 memset(&task, 0, sizeof(task));
479 task.tf_flags = IDE_TFLAG_OUT_LBAH | IDE_TFLAG_OUT_LBAM |
480 IDE_TFLAG_OUT_FEATURE | tf_flags;
481 task.tf.feature = dma; /* Use PIO/DMA */
482 task.tf.lbam = bcount & 0xff;
483 task.tf.lbah = (bcount >> 8) & 0xff;
484
485 ide_tf_dump(drive->name, &task.tf);
486 hwif->tp_ops->set_irq(hwif, 1);
487 SELECT_MASK(drive, 0);
488 hwif->tp_ops->tf_load(drive, &task);
489}
490
491static u8 ide_read_ireason(ide_drive_t *drive)
492{
493 ide_task_t task;
494
495 memset(&task, 0, sizeof(task));
496 task.tf_flags = IDE_TFLAG_IN_NSECT;
497
498 drive->hwif->tp_ops->tf_read(drive, &task);
499
500 return task.tf.nsect & 3;
501}
502
503static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason)
504{
505 int retries = 100;
506
507 while (retries-- && ((ireason & ATAPI_COD) == 0 ||
508 (ireason & ATAPI_IO))) {
509 printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing "
510 "a packet command, retrying\n", drive->name);
511 udelay(100);
512 ireason = ide_read_ireason(drive);
513 if (retries == 0) {
514 printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing "
515 "a packet command, ignoring\n",
516 drive->name);
517 ireason |= ATAPI_COD;
518 ireason &= ~ATAPI_IO;
519 }
520 }
521
522 return ireason;
523}
524
525static int ide_delayed_transfer_pc(ide_drive_t *drive)
526{
527 /* Send the actual packet */
528 drive->hwif->tp_ops->output_data(drive, NULL, drive->pc->c, 12);
529
530 /* Timeout for the packet command */
531 return WAIT_FLOPPY_CMD;
532}
533
534static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)
535{
536 struct ide_atapi_pc *uninitialized_var(pc);
537 ide_hwif_t *hwif = drive->hwif;
538 struct request *rq = hwif->rq;
539 ide_expiry_t *expiry;
540 unsigned int timeout;
541 int cmd_len;
542 ide_startstop_t startstop;
543 u8 ireason;
544
545 if (ide_wait_stat(&startstop, drive, ATA_DRQ, ATA_BUSY, WAIT_READY)) {
546 printk(KERN_ERR "%s: Strange, packet command initiated yet "
547 "DRQ isn't asserted\n", drive->name);
548 return startstop;
549 }
550
551 if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) {
552 if (drive->dma)
553 drive->waiting_for_dma = 1;
554 }
555
556 if (dev_is_idecd(drive)) {
557 /* ATAPI commands get padded out to 12 bytes minimum */
558 cmd_len = COMMAND_SIZE(rq->cmd[0]);
559 if (cmd_len < ATAPI_MIN_CDB_BYTES)
560 cmd_len = ATAPI_MIN_CDB_BYTES;
561
562 timeout = rq->timeout;
563 expiry = ide_cd_expiry;
564 } else {
565 pc = drive->pc;
566
567 cmd_len = ATAPI_MIN_CDB_BYTES;
568
569 /*
570 * If necessary schedule the packet transfer to occur 'timeout'
571 * miliseconds later in ide_delayed_transfer_pc() after the
572 * device says it's ready for a packet.
573 */
574 if (drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) {
575 timeout = drive->pc_delay;
576 expiry = &ide_delayed_transfer_pc;
577 } else {
578 timeout = (drive->media == ide_floppy) ? WAIT_FLOPPY_CMD
579 : WAIT_TAPE_CMD;
580 expiry = NULL;
581 }
582
583 ireason = ide_read_ireason(drive);
584 if (drive->media == ide_tape)
585 ireason = ide_wait_ireason(drive, ireason);
586
587 if ((ireason & ATAPI_COD) == 0 || (ireason & ATAPI_IO)) {
588 printk(KERN_ERR "%s: (IO,CoD) != (0,1) while issuing "
589 "a packet command\n", drive->name);
590
591 return ide_do_reset(drive);
592 }
593 }
594
595 /* Set the interrupt routine */
596 ide_set_handler(drive,
597 (dev_is_idecd(drive) ? drive->irq_handler
598 : ide_pc_intr),
599 timeout, expiry);
600
601 /* Begin DMA, if necessary */
602 if (dev_is_idecd(drive)) {
603 if (drive->dma)
604 hwif->dma_ops->dma_start(drive);
605 } else {
606 if (pc->flags & PC_FLAG_DMA_OK) {
607 pc->flags |= PC_FLAG_DMA_IN_PROGRESS;
608 hwif->dma_ops->dma_start(drive);
609 }
610 }
611
612 /* Send the actual packet */
613 if ((drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) == 0)
614 hwif->tp_ops->output_data(drive, NULL, rq->cmd, cmd_len);
615
616 return ide_started;
617}
618
619ide_startstop_t ide_issue_pc(ide_drive_t *drive)
620{
621 struct ide_atapi_pc *pc;
622 ide_hwif_t *hwif = drive->hwif;
623 ide_expiry_t *expiry = NULL;
624 unsigned int timeout;
625 u32 tf_flags;
626 u16 bcount;
627
628 if (dev_is_idecd(drive)) {
629 tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL;
630 bcount = ide_cd_get_xferlen(hwif->rq);
631 expiry = ide_cd_expiry;
632 timeout = ATAPI_WAIT_PC;
633
634 if (drive->dma)
635 drive->dma = !hwif->dma_ops->dma_setup(drive);
636 } else {
637 pc = drive->pc;
638
639 /* We haven't transferred any data yet */
640 pc->xferred = 0;
641 pc->cur_pos = pc->buf;
642
643 tf_flags = IDE_TFLAG_OUT_DEVICE;
644 bcount = ((drive->media == ide_tape) ?
645 pc->req_xfer :
646 min(pc->req_xfer, 63 * 1024));
647
648 if (pc->flags & PC_FLAG_DMA_ERROR) {
649 pc->flags &= ~PC_FLAG_DMA_ERROR;
650 ide_dma_off(drive);
651 }
652
653 if ((pc->flags & PC_FLAG_DMA_OK) &&
654 (drive->dev_flags & IDE_DFLAG_USING_DMA))
655 drive->dma = !hwif->dma_ops->dma_setup(drive);
656
657 if (!drive->dma)
658 pc->flags &= ~PC_FLAG_DMA_OK;
659
660 timeout = (drive->media == ide_floppy) ? WAIT_FLOPPY_CMD
661 : WAIT_TAPE_CMD;
662 }
663
664 ide_pktcmd_tf_load(drive, tf_flags, bcount);
665
666 /* Issue the packet command */
667 if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) {
668 if (drive->dma)
669 drive->waiting_for_dma = 0;
670 ide_execute_command(drive, ATA_CMD_PACKET, ide_transfer_pc,
671 timeout, expiry);
672 return ide_started;
673 } else {
674 ide_execute_pkt_cmd(drive);
675 return ide_transfer_pc(drive);
676 }
677}
678EXPORT_SYMBOL_GPL(ide_issue_pc);