aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/ide-cd.c187
1 files changed, 150 insertions, 37 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 880d6d042fc8..52e4bbdfd4a8 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -23,6 +23,9 @@
23 * Documentation/ide/ChangeLog.ide-cd.1994-2004 23 * Documentation/ide/ChangeLog.ide-cd.1994-2004
24 */ 24 */
25 25
26#define DRV_NAME "ide-cd"
27#define PFX DRV_NAME ": "
28
26#define IDECD_VERSION "5.00" 29#define IDECD_VERSION "5.00"
27 30
28#include <linux/module.h> 31#include <linux/module.h>
@@ -50,6 +53,14 @@
50 53
51#include "ide-cd.h" 54#include "ide-cd.h"
52 55
56#define IDECD_DEBUG_LOG 1
57
58#if IDECD_DEBUG_LOG
59#define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, args)
60#else
61#define ide_debug_log(lvl, fmt, args...) do {} while (0)
62#endif
63
53static DEFINE_MUTEX(idecd_ref_mutex); 64static DEFINE_MUTEX(idecd_ref_mutex);
54 65
55static void ide_cd_release(struct kref *); 66static void ide_cd_release(struct kref *);
@@ -97,6 +108,9 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq,
97{ 108{
98 int log = 0; 109 int log = 0;
99 110
111 ide_debug_log(IDE_DBG_SENSE, "Call %s, sense_key: 0x%x\n", __func__,
112 sense->sense_key);
113
100 if (!sense || !rq || (rq->cmd_flags & REQ_QUIET)) 114 if (!sense || !rq || (rq->cmd_flags & REQ_QUIET))
101 return 0; 115 return 0;
102 116
@@ -145,6 +159,14 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
145 unsigned long bio_sectors; 159 unsigned long bio_sectors;
146 struct cdrom_info *info = drive->driver_data; 160 struct cdrom_info *info = drive->driver_data;
147 161
162 ide_debug_log(IDE_DBG_SENSE, "Call %s, error_code: 0x%x, "
163 "sense_key: 0x%x\n", __func__, sense->error_code,
164 sense->sense_key);
165
166 if (failed_command)
167 ide_debug_log(IDE_DBG_SENSE, "%s: failed cmd: 0x%x\n",
168 __func__, failed_command->cmd[0]);
169
148 if (!cdrom_log_sense(drive, failed_command, sense)) 170 if (!cdrom_log_sense(drive, failed_command, sense))
149 return; 171 return;
150 172
@@ -195,6 +217,8 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
195 struct cdrom_info *info = drive->driver_data; 217 struct cdrom_info *info = drive->driver_data;
196 struct request *rq = &info->request_sense_request; 218 struct request *rq = &info->request_sense_request;
197 219
220 ide_debug_log(IDE_DBG_SENSE, "Call %s\n", __func__);
221
198 if (sense == NULL) 222 if (sense == NULL)
199 sense = &info->sense_data; 223 sense = &info->sense_data;
200 224
@@ -214,6 +238,10 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense,
214 /* NOTE! Save the failed command in "rq->buffer" */ 238 /* NOTE! Save the failed command in "rq->buffer" */
215 rq->buffer = (void *) failed_command; 239 rq->buffer = (void *) failed_command;
216 240
241 if (failed_command)
242 ide_debug_log(IDE_DBG_SENSE, "failed_cmd: 0x%x\n",
243 failed_command->cmd[0]);
244
217 ide_do_drive_cmd(drive, rq); 245 ide_do_drive_cmd(drive, rq);
218} 246}
219 247
@@ -222,6 +250,10 @@ static void cdrom_end_request(ide_drive_t *drive, int uptodate)
222 struct request *rq = HWGROUP(drive)->rq; 250 struct request *rq = HWGROUP(drive)->rq;
223 int nsectors = rq->hard_cur_sectors; 251 int nsectors = rq->hard_cur_sectors;
224 252
253 ide_debug_log(IDE_DBG_FUNC, "Call %s, cmd: 0x%x, uptodate: 0x%x, "
254 "nsectors: %d\n", __func__, rq->cmd[0], uptodate,
255 nsectors);
256
225 if (blk_sense_request(rq) && uptodate) { 257 if (blk_sense_request(rq) && uptodate) {
226 /* 258 /*
227 * For REQ_TYPE_SENSE, "rq->buffer" points to the original 259 * For REQ_TYPE_SENSE, "rq->buffer" points to the original
@@ -264,6 +296,9 @@ static void cdrom_end_request(ide_drive_t *drive, int uptodate)
264 if (!nsectors) 296 if (!nsectors)
265 nsectors = 1; 297 nsectors = 1;
266 298
299 ide_debug_log(IDE_DBG_FUNC, "Exit %s, uptodate: 0x%x, nsectors: %d\n",
300 __func__, uptodate, nsectors);
301
267 ide_end_request(drive, uptodate, nsectors); 302 ide_end_request(drive, uptodate, nsectors);
268} 303}
269 304
@@ -299,11 +334,15 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
299 sense_key = err >> 4; 334 sense_key = err >> 4;
300 335
301 if (rq == NULL) { 336 if (rq == NULL) {
302 printk(KERN_ERR "%s: missing rq in %s\n", 337 printk(KERN_ERR PFX "%s: missing rq in %s\n",
303 drive->name, __func__); 338 drive->name, __func__);
304 return 1; 339 return 1;
305 } 340 }
306 341
342 ide_debug_log(IDE_DBG_RQ, "%s: stat: 0x%x, good_stat: 0x%x, "
343 "rq->cmd_type: 0x%x, err: 0x%x\n", __func__, stat,
344 good_stat, rq->cmd_type, err);
345
307 if (blk_sense_request(rq)) { 346 if (blk_sense_request(rq)) {
308 /* 347 /*
309 * We got an error trying to get sense info from the drive 348 * We got an error trying to get sense info from the drive
@@ -369,7 +408,8 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
369 cdrom_saw_media_change(drive); 408 cdrom_saw_media_change(drive);
370 409
371 /* fail the request */ 410 /* fail the request */
372 printk(KERN_ERR "%s: tray open\n", drive->name); 411 printk(KERN_ERR PFX "%s: tray open\n",
412 drive->name);
373 do_end_request = 1; 413 do_end_request = 1;
374 } else { 414 } else {
375 struct cdrom_info *info = drive->driver_data; 415 struct cdrom_info *info = drive->driver_data;
@@ -455,7 +495,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
455 if (stat & ATA_ERR) 495 if (stat & ATA_ERR)
456 cdrom_queue_request_sense(drive, NULL, NULL); 496 cdrom_queue_request_sense(drive, NULL, NULL);
457 } else { 497 } else {
458 blk_dump_rq_flags(rq, "ide-cd: bad rq"); 498 blk_dump_rq_flags(rq, PFX "bad rq");
459 cdrom_end_request(drive, 0); 499 cdrom_end_request(drive, 0);
460 } 500 }
461 501
@@ -483,6 +523,9 @@ static int cdrom_timer_expiry(ide_drive_t *drive)
483 struct request *rq = HWGROUP(drive)->rq; 523 struct request *rq = HWGROUP(drive)->rq;
484 unsigned long wait = 0; 524 unsigned long wait = 0;
485 525
526 ide_debug_log(IDE_DBG_RQ, "Call %s: rq->cmd[0]: 0x%x\n", __func__,
527 rq->cmd[0]);
528
486 /* 529 /*
487 * Some commands are *slow* and normally take a long time to complete. 530 * Some commands are *slow* and normally take a long time to complete.
488 * Usually we can use the ATAPI "disconnect" to bypass this, but not all 531 * Usually we can use the ATAPI "disconnect" to bypass this, but not all
@@ -499,7 +542,7 @@ static int cdrom_timer_expiry(ide_drive_t *drive)
499 break; 542 break;
500 default: 543 default:
501 if (!(rq->cmd_flags & REQ_QUIET)) 544 if (!(rq->cmd_flags & REQ_QUIET))
502 printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", 545 printk(KERN_INFO PFX "cmd 0x%x timed out\n",
503 rq->cmd[0]); 546 rq->cmd[0]);
504 wait = 0; 547 wait = 0;
505 break; 548 break;
@@ -522,6 +565,8 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,
522 struct cdrom_info *info = drive->driver_data; 565 struct cdrom_info *info = drive->driver_data;
523 ide_hwif_t *hwif = drive->hwif; 566 ide_hwif_t *hwif = drive->hwif;
524 567
568 ide_debug_log(IDE_DBG_PC, "Call %s, xferlen: %d\n", __func__, xferlen);
569
525 /* FIXME: for Virtual DMA we must check harder */ 570 /* FIXME: for Virtual DMA we must check harder */
526 if (info->dma) 571 if (info->dma)
527 info->dma = !hwif->dma_ops->dma_setup(drive); 572 info->dma = !hwif->dma_ops->dma_setup(drive);
@@ -562,6 +607,8 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive,
562 struct cdrom_info *info = drive->driver_data; 607 struct cdrom_info *info = drive->driver_data;
563 ide_startstop_t startstop; 608 ide_startstop_t startstop;
564 609
610 ide_debug_log(IDE_DBG_PC, "Call %s\n", __func__);
611
565 if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { 612 if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) {
566 /* 613 /*
567 * Here we should have been called after receiving an interrupt 614 * Here we should have been called after receiving an interrupt
@@ -610,6 +657,9 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq,
610{ 657{
611 ide_hwif_t *hwif = drive->hwif; 658 ide_hwif_t *hwif = drive->hwif;
612 659
660 ide_debug_log(IDE_DBG_FUNC, "Call %s, ireason: 0x%x, rw: 0x%x\n",
661 __func__, ireason, rw);
662
613 /* 663 /*
614 * ireason == 0: the drive wants to receive data from us 664 * ireason == 0: the drive wants to receive data from us
615 * ireason == 2: the drive is expecting to transfer data to us 665 * ireason == 2: the drive is expecting to transfer data to us
@@ -619,7 +669,7 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq,
619 else if (ireason == (rw << 1)) { 669 else if (ireason == (rw << 1)) {
620 670
621 /* whoops... */ 671 /* whoops... */
622 printk(KERN_ERR "%s: %s: wrong transfer direction!\n", 672 printk(KERN_ERR PFX "%s: %s: wrong transfer direction!\n",
623 drive->name, __func__); 673 drive->name, __func__);
624 674
625 ide_pad_transfer(drive, rw, len); 675 ide_pad_transfer(drive, rw, len);
@@ -632,7 +682,7 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq,
632 return 0; 682 return 0;
633 } else { 683 } else {
634 /* drive wants a command packet, or invalid ireason... */ 684 /* drive wants a command packet, or invalid ireason... */
635 printk(KERN_ERR "%s: %s: bad interrupt reason 0x%02x\n", 685 printk(KERN_ERR PFX "%s: %s: bad interrupt reason 0x%02x\n",
636 drive->name, __func__, ireason); 686 drive->name, __func__, ireason);
637 } 687 }
638 688
@@ -649,17 +699,19 @@ static int ide_cd_check_ireason(ide_drive_t *drive, struct request *rq,
649 */ 699 */
650static int ide_cd_check_transfer_size(ide_drive_t *drive, int len) 700static int ide_cd_check_transfer_size(ide_drive_t *drive, int len)
651{ 701{
702 ide_debug_log(IDE_DBG_FUNC, "Call %s, len: %d\n", __func__, len);
703
652 if ((len % SECTOR_SIZE) == 0) 704 if ((len % SECTOR_SIZE) == 0)
653 return 0; 705 return 0;
654 706
655 printk(KERN_ERR "%s: %s: Bad transfer size %d\n", 707 printk(KERN_ERR PFX "%s: %s: Bad transfer size %d\n", drive->name,
656 drive->name, __func__, len); 708 __func__, len);
657 709
658 if (drive->atapi_flags & IDE_AFLAG_LIMIT_NFRAMES) 710 if (drive->atapi_flags & IDE_AFLAG_LIMIT_NFRAMES)
659 printk(KERN_ERR " This drive is not supported by " 711 printk(KERN_ERR PFX "This drive is not supported by this "
660 "this version of the driver\n"); 712 "version of the driver\n");
661 else { 713 else {
662 printk(KERN_ERR " Trying to limit transfer sizes\n"); 714 printk(KERN_ERR PFX "Trying to limit transfer sizes\n");
663 drive->atapi_flags |= IDE_AFLAG_LIMIT_NFRAMES; 715 drive->atapi_flags |= IDE_AFLAG_LIMIT_NFRAMES;
664 } 716 }
665 717
@@ -671,6 +723,9 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *);
671static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive, 723static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive,
672 struct request *rq) 724 struct request *rq)
673{ 725{
726 ide_debug_log(IDE_DBG_RQ, "Call %s: rq->cmd_flags: 0x%x\n", __func__,
727 rq->cmd_flags);
728
674 if (rq_data_dir(rq) == READ) { 729 if (rq_data_dir(rq) == READ) {
675 unsigned short sectors_per_frame = 730 unsigned short sectors_per_frame =
676 queue_hardsect_size(drive->queue) >> SECTOR_BITS; 731 queue_hardsect_size(drive->queue) >> SECTOR_BITS;
@@ -690,7 +745,7 @@ static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive,
690 /* sanity check... */ 745 /* sanity check... */
691 if (rq->current_nr_sectors != 746 if (rq->current_nr_sectors !=
692 bio_cur_sectors(rq->bio)) { 747 bio_cur_sectors(rq->bio)) {
693 printk(KERN_ERR "%s: %s: buffer botch (%u)\n", 748 printk(KERN_ERR PFX "%s: %s: buffer botch (%u)\n",
694 drive->name, __func__, 749 drive->name, __func__,
695 rq->current_nr_sectors); 750 rq->current_nr_sectors);
696 cdrom_end_request(drive, 0); 751 cdrom_end_request(drive, 0);
@@ -699,11 +754,7 @@ static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive,
699 rq->current_nr_sectors += nskip; 754 rq->current_nr_sectors += nskip;
700 } 755 }
701 } 756 }
702#if 0 757
703 else
704 /* the immediate bit */
705 rq->cmd[1] = 1 << 3;
706#endif
707 /* set up the command */ 758 /* set up the command */
708 rq->timeout = ATAPI_WAIT_PC; 759 rq->timeout = ATAPI_WAIT_PC;
709 760
@@ -734,6 +785,8 @@ static ide_startstop_t cdrom_seek_intr(ide_drive_t *drive)
734 int stat; 785 int stat;
735 static int retry = 10; 786 static int retry = 10;
736 787
788 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
789
737 if (cdrom_decode_status(drive, 0, &stat)) 790 if (cdrom_decode_status(drive, 0, &stat))
738 return ide_stopped; 791 return ide_stopped;
739 792
@@ -750,6 +803,8 @@ static void ide_cd_prepare_seek_request(ide_drive_t *drive, struct request *rq)
750{ 803{
751 sector_t frame = rq->sector; 804 sector_t frame = rq->sector;
752 805
806 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
807
753 sector_div(frame, queue_hardsect_size(drive->queue) >> SECTOR_BITS); 808 sector_div(frame, queue_hardsect_size(drive->queue) >> SECTOR_BITS);
754 809
755 memset(rq->cmd, 0, BLK_MAX_CDB); 810 memset(rq->cmd, 0, BLK_MAX_CDB);
@@ -770,8 +825,11 @@ static ide_startstop_t cdrom_start_seek_continuation(ide_drive_t *drive)
770 * Fix up a possibly partially-processed request so that we can start it over 825 * Fix up a possibly partially-processed request so that we can start it over
771 * entirely, or even put it back on the request queue. 826 * entirely, or even put it back on the request queue.
772 */ 827 */
773static void restore_request(struct request *rq) 828static void ide_cd_restore_request(ide_drive_t *drive, struct request *rq)
774{ 829{
830
831 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
832
775 if (rq->buffer != bio_data(rq->bio)) { 833 if (rq->buffer != bio_data(rq->bio)) {
776 sector_t n = 834 sector_t n =
777 (rq->buffer - (char *)bio_data(rq->bio)) / SECTOR_SIZE; 835 (rq->buffer - (char *)bio_data(rq->bio)) / SECTOR_SIZE;
@@ -790,8 +848,11 @@ static void restore_request(struct request *rq)
790/* 848/*
791 * All other packet commands. 849 * All other packet commands.
792 */ 850 */
793static void ide_cd_request_sense_fixup(struct request *rq) 851static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct request *rq)
794{ 852{
853
854 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
855
795 /* 856 /*
796 * Some of the trailing request sense fields are optional, 857 * Some of the trailing request sense fields are optional,
797 * and some drives don't send them. Sigh. 858 * and some drives don't send them. Sigh.
@@ -817,6 +878,10 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
817 if (!sense) 878 if (!sense)
818 sense = &local_sense; 879 sense = &local_sense;
819 880
881 ide_debug_log(IDE_DBG_PC, "Call %s, rq->cmd[0]: 0x%x, write: 0x%x, "
882 "timeout: %d, cmd_flags: 0x%x\n", __func__, cmd[0], write,
883 timeout, cmd_flags);
884
820 /* start of retry loop */ 885 /* start of retry loop */
821 do { 886 do {
822 struct request *rq; 887 struct request *rq;
@@ -900,13 +965,16 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
900 u16 len; 965 u16 len;
901 u8 ireason; 966 u8 ireason;
902 967
968 ide_debug_log(IDE_DBG_PC, "Call %s, rq->cmd[0]: 0x%x, write: 0x%x\n",
969 __func__, rq->cmd[0], write);
970
903 /* check for errors */ 971 /* check for errors */
904 dma = info->dma; 972 dma = info->dma;
905 if (dma) { 973 if (dma) {
906 info->dma = 0; 974 info->dma = 0;
907 dma_error = hwif->dma_ops->dma_end(drive); 975 dma_error = hwif->dma_ops->dma_end(drive);
908 if (dma_error) { 976 if (dma_error) {
909 printk(KERN_ERR "%s: DMA %s error\n", drive->name, 977 printk(KERN_ERR PFX "%s: DMA %s error\n", drive->name,
910 write ? "write" : "read"); 978 write ? "write" : "read");
911 ide_dma_off(drive); 979 ide_dma_off(drive);
912 } 980 }
@@ -932,6 +1000,9 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
932 if (thislen > len) 1000 if (thislen > len)
933 thislen = len; 1001 thislen = len;
934 1002
1003 ide_debug_log(IDE_DBG_PC, "%s: DRQ: stat: 0x%x, thislen: %d\n",
1004 __func__, stat, thislen);
1005
935 /* If DRQ is clear, the command has completed. */ 1006 /* If DRQ is clear, the command has completed. */
936 if ((stat & ATA_DRQ) == 0) { 1007 if ((stat & ATA_DRQ) == 0) {
937 if (blk_fs_request(rq)) { 1008 if (blk_fs_request(rq)) {
@@ -941,7 +1012,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
941 */ 1012 */
942 uptodate = 1; 1013 uptodate = 1;
943 if (rq->current_nr_sectors > 0) { 1014 if (rq->current_nr_sectors > 0) {
944 printk(KERN_ERR "%s: %s: data underrun " 1015 printk(KERN_ERR PFX "%s: %s: data underrun "
945 "(%d blocks)\n", 1016 "(%d blocks)\n",
946 drive->name, __func__, 1017 drive->name, __func__,
947 rq->current_nr_sectors); 1018 rq->current_nr_sectors);
@@ -952,7 +1023,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
952 cdrom_end_request(drive, uptodate); 1023 cdrom_end_request(drive, uptodate);
953 return ide_stopped; 1024 return ide_stopped;
954 } else if (!blk_pc_request(rq)) { 1025 } else if (!blk_pc_request(rq)) {
955 ide_cd_request_sense_fixup(rq); 1026 ide_cd_request_sense_fixup(drive, rq);
956 /* complain if we still have data left to transfer */ 1027 /* complain if we still have data left to transfer */
957 uptodate = rq->data_len ? 0 : 1; 1028 uptodate = rq->data_len ? 0 : 1;
958 } 1029 }
@@ -995,6 +1066,9 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
995 xferfunc = hwif->tp_ops->input_data; 1066 xferfunc = hwif->tp_ops->input_data;
996 } 1067 }
997 1068
1069 ide_debug_log(IDE_DBG_PC, "%s: data transfer, rq->cmd_type: 0x%x, "
1070 "ireason: 0x%x\n", __func__, rq->cmd_type, ireason);
1071
998 /* transfer data */ 1072 /* transfer data */
999 while (thislen > 0) { 1073 while (thislen > 0) {
1000 u8 *ptr = blk_fs_request(rq) ? NULL : rq->data; 1074 u8 *ptr = blk_fs_request(rq) ? NULL : rq->data;
@@ -1019,7 +1093,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
1019 */ 1093 */
1020 ide_pad_transfer(drive, 0, thislen); 1094 ide_pad_transfer(drive, 0, thislen);
1021 else { 1095 else {
1022 printk(KERN_ERR "%s: confused, missing data\n", 1096 printk(KERN_ERR PFX "%s: confused, missing data\n",
1023 drive->name); 1097 drive->name);
1024 blk_dump_rq_flags(rq, rq_data_dir(rq) 1098 blk_dump_rq_flags(rq, rq_data_dir(rq)
1025 ? "cdrom_newpc_intr, write" 1099 ? "cdrom_newpc_intr, write"
@@ -1106,6 +1180,9 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
1106 unsigned short sectors_per_frame = 1180 unsigned short sectors_per_frame =
1107 queue_hardsect_size(drive->queue) >> SECTOR_BITS; 1181 queue_hardsect_size(drive->queue) >> SECTOR_BITS;
1108 1182
1183 ide_debug_log(IDE_DBG_RQ, "Call %s, write: 0x%x, secs_per_frame: %u\n",
1184 __func__, write, sectors_per_frame);
1185
1109 if (write) { 1186 if (write) {
1110 /* disk has become write protected */ 1187 /* disk has become write protected */
1111 if (get_disk_ro(cd->disk)) { 1188 if (get_disk_ro(cd->disk)) {
@@ -1117,7 +1194,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
1117 * We may be retrying this request after an error. Fix up any 1194 * We may be retrying this request after an error. Fix up any
1118 * weirdness which might be present in the request packet. 1195 * weirdness which might be present in the request packet.
1119 */ 1196 */
1120 restore_request(rq); 1197 ide_cd_restore_request(drive, rq);
1121 } 1198 }
1122 1199
1123 /* use DMA, if possible / writes *must* be hardware frame aligned */ 1200 /* use DMA, if possible / writes *must* be hardware frame aligned */
@@ -1148,6 +1225,9 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1148{ 1225{
1149 struct cdrom_info *info = drive->driver_data; 1226 struct cdrom_info *info = drive->driver_data;
1150 1227
1228 ide_debug_log(IDE_DBG_PC, "Call %s, rq->cmd_type: 0x%x\n", __func__,
1229 rq->cmd_type);
1230
1151 if (blk_pc_request(rq)) 1231 if (blk_pc_request(rq))
1152 rq->cmd_flags |= REQ_QUIET; 1232 rq->cmd_flags |= REQ_QUIET;
1153 else 1233 else
@@ -1191,6 +1271,9 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1191 ide_handler_t *fn; 1271 ide_handler_t *fn;
1192 int xferlen; 1272 int xferlen;
1193 1273
1274 ide_debug_log(IDE_DBG_RQ, "Call %s, rq->cmd_type: 0x%x, block: %llu\n",
1275 __func__, rq->cmd_type, (u64)block);
1276
1194 if (blk_fs_request(rq)) { 1277 if (blk_fs_request(rq)) {
1195 if (drive->atapi_flags & IDE_AFLAG_SEEKING) { 1278 if (drive->atapi_flags & IDE_AFLAG_SEEKING) {
1196 ide_hwif_t *hwif = drive->hwif; 1279 ide_hwif_t *hwif = drive->hwif;
@@ -1203,7 +1286,7 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1203 IDECD_SEEK_TIMER); 1286 IDECD_SEEK_TIMER);
1204 return ide_stopped; 1287 return ide_stopped;
1205 } 1288 }
1206 printk(KERN_ERR "%s: DSC timeout\n", 1289 printk(KERN_ERR PFX "%s: DSC timeout\n",
1207 drive->name); 1290 drive->name);
1208 } 1291 }
1209 drive->atapi_flags &= ~IDE_AFLAG_SEEKING; 1292 drive->atapi_flags &= ~IDE_AFLAG_SEEKING;
@@ -1244,7 +1327,7 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1244 cdrom_end_request(drive, 1); 1327 cdrom_end_request(drive, 1);
1245 return ide_stopped; 1328 return ide_stopped;
1246 } else { 1329 } else {
1247 blk_dump_rq_flags(rq, "ide-cd bad flags"); 1330 blk_dump_rq_flags(rq, DRV_NAME " bad flags");
1248 cdrom_end_request(drive, 0); 1331 cdrom_end_request(drive, 0);
1249 return ide_stopped; 1332 return ide_stopped;
1250 } 1333 }
@@ -1274,6 +1357,8 @@ int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense)
1274 struct cdrom_device_info *cdi = &info->devinfo; 1357 struct cdrom_device_info *cdi = &info->devinfo;
1275 unsigned char cmd[BLK_MAX_CDB]; 1358 unsigned char cmd[BLK_MAX_CDB];
1276 1359
1360 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
1361
1277 memset(cmd, 0, BLK_MAX_CDB); 1362 memset(cmd, 0, BLK_MAX_CDB);
1278 cmd[0] = GPCMD_TEST_UNIT_READY; 1363 cmd[0] = GPCMD_TEST_UNIT_READY;
1279 1364
@@ -1300,6 +1385,8 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
1300 unsigned len = sizeof(capbuf); 1385 unsigned len = sizeof(capbuf);
1301 u32 blocklen; 1386 u32 blocklen;
1302 1387
1388 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
1389
1303 memset(cmd, 0, BLK_MAX_CDB); 1390 memset(cmd, 0, BLK_MAX_CDB);
1304 cmd[0] = GPCMD_READ_CDVD_CAPACITY; 1391 cmd[0] = GPCMD_READ_CDVD_CAPACITY;
1305 1392
@@ -1319,10 +1406,10 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
1319 case 4096: 1406 case 4096:
1320 break; 1407 break;
1321 default: 1408 default:
1322 printk(KERN_ERR "%s: weird block size %u\n", 1409 printk(KERN_ERR PFX "%s: weird block size %u\n",
1323 drive->name, blocklen); 1410 drive->name, blocklen);
1324 printk(KERN_ERR "%s: default to 2kb block size\n", 1411 printk(KERN_ERR PFX "%s: default to 2kb block size\n",
1325 drive->name); 1412 drive->name);
1326 blocklen = 2048; 1413 blocklen = 2048;
1327 break; 1414 break;
1328 } 1415 }
@@ -1338,6 +1425,8 @@ static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag,
1338{ 1425{
1339 unsigned char cmd[BLK_MAX_CDB]; 1426 unsigned char cmd[BLK_MAX_CDB];
1340 1427
1428 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
1429
1341 memset(cmd, 0, BLK_MAX_CDB); 1430 memset(cmd, 0, BLK_MAX_CDB);
1342 1431
1343 cmd[0] = GPCMD_READ_TOC_PMA_ATIP; 1432 cmd[0] = GPCMD_READ_TOC_PMA_ATIP;
@@ -1366,11 +1455,13 @@ int ide_cd_read_toc(ide_drive_t *drive, struct request_sense *sense)
1366 long last_written; 1455 long last_written;
1367 unsigned long sectors_per_frame = SECTORS_PER_FRAME; 1456 unsigned long sectors_per_frame = SECTORS_PER_FRAME;
1368 1457
1458 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
1459
1369 if (toc == NULL) { 1460 if (toc == NULL) {
1370 /* try to allocate space */ 1461 /* try to allocate space */
1371 toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); 1462 toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL);
1372 if (toc == NULL) { 1463 if (toc == NULL) {
1373 printk(KERN_ERR "%s: No cdrom TOC buffer!\n", 1464 printk(KERN_ERR PFX "%s: No cdrom TOC buffer!\n",
1374 drive->name); 1465 drive->name);
1375 return -ENOMEM; 1466 return -ENOMEM;
1376 } 1467 }
@@ -1526,6 +1617,8 @@ int ide_cdrom_get_capabilities(ide_drive_t *drive, u8 *buf)
1526 struct packet_command cgc; 1617 struct packet_command cgc;
1527 int stat, attempts = 3, size = ATAPI_CAPABILITIES_PAGE_SIZE; 1618 int stat, attempts = 3, size = ATAPI_CAPABILITIES_PAGE_SIZE;
1528 1619
1620 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
1621
1529 if ((drive->atapi_flags & IDE_AFLAG_FULL_CAPS_PAGE) == 0) 1622 if ((drive->atapi_flags & IDE_AFLAG_FULL_CAPS_PAGE) == 0)
1530 size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE; 1623 size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE;
1531 1624
@@ -1544,6 +1637,8 @@ void ide_cdrom_update_speed(ide_drive_t *drive, u8 *buf)
1544 struct cdrom_info *cd = drive->driver_data; 1637 struct cdrom_info *cd = drive->driver_data;
1545 u16 curspeed, maxspeed; 1638 u16 curspeed, maxspeed;
1546 1639
1640 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
1641
1547 if (drive->atapi_flags & IDE_AFLAG_LE_SPEED_FIELDS) { 1642 if (drive->atapi_flags & IDE_AFLAG_LE_SPEED_FIELDS) {
1548 curspeed = le16_to_cpup((__le16 *)&buf[8 + 14]); 1643 curspeed = le16_to_cpup((__le16 *)&buf[8 + 14]);
1549 maxspeed = le16_to_cpup((__le16 *)&buf[8 + 8]); 1644 maxspeed = le16_to_cpup((__le16 *)&buf[8 + 8]);
@@ -1584,6 +1679,8 @@ static int ide_cdrom_register(ide_drive_t *drive, int nslots)
1584 struct cdrom_info *info = drive->driver_data; 1679 struct cdrom_info *info = drive->driver_data;
1585 struct cdrom_device_info *devinfo = &info->devinfo; 1680 struct cdrom_device_info *devinfo = &info->devinfo;
1586 1681
1682 ide_debug_log(IDE_DBG_PROBE, "Call %s, nslots: %d\n", __func__, nslots);
1683
1587 devinfo->ops = &ide_cdrom_dops; 1684 devinfo->ops = &ide_cdrom_dops;
1588 devinfo->speed = info->current_speed; 1685 devinfo->speed = info->current_speed;
1589 devinfo->capacity = nslots; 1686 devinfo->capacity = nslots;
@@ -1605,13 +1702,17 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive)
1605 mechtype_t mechtype; 1702 mechtype_t mechtype;
1606 int nslots = 1; 1703 int nslots = 1;
1607 1704
1705 ide_debug_log(IDE_DBG_PROBE, "Call %s, drive->media: 0x%x, "
1706 "drive->atapi_flags: 0x%lx\n", __func__, drive->media,
1707 drive->atapi_flags);
1708
1608 cdi->mask = (CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | 1709 cdi->mask = (CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R |
1609 CDC_DVD_RAM | CDC_SELECT_DISC | CDC_PLAY_AUDIO | 1710 CDC_DVD_RAM | CDC_SELECT_DISC | CDC_PLAY_AUDIO |
1610 CDC_MO_DRIVE | CDC_RAM); 1711 CDC_MO_DRIVE | CDC_RAM);
1611 1712
1612 if (drive->media == ide_optical) { 1713 if (drive->media == ide_optical) {
1613 cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM); 1714 cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM);
1614 printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", 1715 printk(KERN_ERR PFX "%s: ATAPI magneto-optical drive\n",
1615 drive->name); 1716 drive->name);
1616 return nslots; 1717 return nslots;
1617 } 1718 }
@@ -1669,7 +1770,7 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive)
1669 1770
1670 ide_cdrom_update_speed(drive, buf); 1771 ide_cdrom_update_speed(drive, buf);
1671 1772
1672 printk(KERN_INFO "%s: ATAPI", drive->name); 1773 printk(KERN_INFO PFX "%s: ATAPI", drive->name);
1673 1774
1674 /* don't print speed if the drive reported 0 */ 1775 /* don't print speed if the drive reported 0 */
1675 if (cd->max_speed) 1776 if (cd->max_speed)
@@ -1692,7 +1793,8 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive)
1692 else 1793 else
1693 printk(KERN_CONT " drive"); 1794 printk(KERN_CONT " drive");
1694 1795
1695 printk(KERN_CONT ", %dkB Cache\n", be16_to_cpup((__be16 *)&buf[8 + 12])); 1796 printk(KERN_CONT ", %dkB Cache\n",
1797 be16_to_cpup((__be16 *)&buf[8 + 12]));
1696 1798
1697 return nslots; 1799 return nslots;
1698} 1800}
@@ -1879,6 +1981,8 @@ static int ide_cdrom_setup(ide_drive_t *drive)
1879 char *fw_rev = (char *)&id[ATA_ID_FW_REV]; 1981 char *fw_rev = (char *)&id[ATA_ID_FW_REV];
1880 int nslots; 1982 int nslots;
1881 1983
1984 ide_debug_log(IDE_DBG_PROBE, "Call %s\n", __func__);
1985
1882 blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn); 1986 blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn);
1883 blk_queue_dma_alignment(drive->queue, 31); 1987 blk_queue_dma_alignment(drive->queue, 31);
1884 blk_queue_update_dma_pad(drive->queue, 15); 1988 blk_queue_update_dma_pad(drive->queue, 15);
@@ -1911,7 +2015,7 @@ static int ide_cdrom_setup(ide_drive_t *drive)
1911 drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; 2015 drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP;
1912 2016
1913 if (ide_cdrom_register(drive, nslots)) { 2017 if (ide_cdrom_register(drive, nslots)) {
1914 printk(KERN_ERR "%s: %s failed to register device with the" 2018 printk(KERN_ERR PFX "%s: %s failed to register device with the"
1915 " cdrom driver.\n", drive->name, __func__); 2019 " cdrom driver.\n", drive->name, __func__);
1916 cd->devinfo.handle = NULL; 2020 cd->devinfo.handle = NULL;
1917 return 1; 2021 return 1;
@@ -1925,6 +2029,8 @@ static void ide_cd_remove(ide_drive_t *drive)
1925{ 2029{
1926 struct cdrom_info *info = drive->driver_data; 2030 struct cdrom_info *info = drive->driver_data;
1927 2031
2032 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
2033
1928 ide_proc_unregister_driver(drive, info->driver); 2034 ide_proc_unregister_driver(drive, info->driver);
1929 2035
1930 del_gendisk(info->disk); 2036 del_gendisk(info->disk);
@@ -1939,6 +2045,8 @@ static void ide_cd_release(struct kref *kref)
1939 ide_drive_t *drive = info->drive; 2045 ide_drive_t *drive = info->drive;
1940 struct gendisk *g = info->disk; 2046 struct gendisk *g = info->disk;
1941 2047
2048 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
2049
1942 kfree(info->toc); 2050 kfree(info->toc);
1943 if (devinfo->handle == drive) 2051 if (devinfo->handle == drive)
1944 unregister_cdrom(devinfo); 2052 unregister_cdrom(devinfo);
@@ -2099,6 +2207,10 @@ static int ide_cd_probe(ide_drive_t *drive)
2099 struct gendisk *g; 2207 struct gendisk *g;
2100 struct request_sense sense; 2208 struct request_sense sense;
2101 2209
2210 ide_debug_log(IDE_DBG_PROBE, "Call %s, drive->driver_req: %s, "
2211 "drive->media: 0x%x\n", __func__, drive->driver_req,
2212 drive->media);
2213
2102 if (!strstr("ide-cdrom", drive->driver_req)) 2214 if (!strstr("ide-cdrom", drive->driver_req))
2103 goto failed; 2215 goto failed;
2104 2216
@@ -2108,14 +2220,14 @@ static int ide_cd_probe(ide_drive_t *drive)
2108 /* skip drives that we were told to ignore */ 2220 /* skip drives that we were told to ignore */
2109 if (ignore != NULL) { 2221 if (ignore != NULL) {
2110 if (strstr(ignore, drive->name)) { 2222 if (strstr(ignore, drive->name)) {
2111 printk(KERN_INFO "ide-cd: ignoring drive %s\n", 2223 printk(KERN_INFO PFX "ignoring drive %s\n",
2112 drive->name); 2224 drive->name);
2113 goto failed; 2225 goto failed;
2114 } 2226 }
2115 } 2227 }
2116 info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); 2228 info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL);
2117 if (info == NULL) { 2229 if (info == NULL) {
2118 printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", 2230 printk(KERN_ERR PFX "%s: Can't allocate a cdrom structure\n",
2119 drive->name); 2231 drive->name);
2120 goto failed; 2232 goto failed;
2121 } 2233 }
@@ -2163,6 +2275,7 @@ static void __exit ide_cdrom_exit(void)
2163 2275
2164static int __init ide_cdrom_init(void) 2276static int __init ide_cdrom_init(void)
2165{ 2277{
2278 printk(KERN_INFO DRV_NAME " driver " IDECD_VERSION "\n");
2166 return driver_register(&ide_cdrom_driver.gen_driver); 2279 return driver_register(&ide_cdrom_driver.gen_driver);
2167} 2280}
2168 2281