ide: generic ATAPI support
cover ide: generic ATAPI support
Hi,
This patch series unifies ATAPI support present in ide-{floppy,tape,scsi} device drivers and moves it out to the core IDE code (new ide-atapi.c file).
In the process many bugs were shaken out and ~300 LOC were removed.
diffstat:
drivers/ide/Kconfig | 6 drivers/ide/Makefile | 1 drivers/ide/ide-atapi.c | 296 ++++++++++++++++++++++ drivers/ide/ide-cd.c | 5 drivers/ide/ide-floppy.c | 431 +++++++------------------------- drivers/ide/ide-tape.c | 630 ++++++++++++++--------------------------------- drivers/scsi/ide-scsi.c | 455 +++++++++++---------------------- include/linux/ide.h | 28 +- 8 files changed, 777 insertions(+), 1075 deletions(-)
Now, while this is a big step in the right direction there are still some things left on TODO for generic ATAPI support to be complete:
- convert ide-cd to use generic ATAPI code
- kill pc and rq stacks in ide-{floppy,tape}
- generic handling of REQUEST SENSE command
- generic handling of MODE SENSE command for ide-{floppy,tape}
- convert ide-{cd,floppy,tape} to use scatterlists for PIO transers (ala ide-scsi)
I know that Borislav is working on the first two items but other ones are free at the moment so if you feel brave you may give it a try :-).
PS I'll be travelling during this weekend and be rather busy with day job
so replies from me may be delayed a bit.
Thanks,
Bart
PATCH 1/40 ide-scsi: fix race in idescsi_transfer_pc()
Start DMA engine before sending content of packet command (otherwise it is possible that IRQ will happen before DMA engine is started).
--- drivers/scsi/ide-scsi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/ide-scsi.c +4 -3
@@ -494,13 +494,14 @@ static ide_startstop_t idescsi_transfer_/* Set the interrupt routine */ ide_set_handler (drive, &idescsi_pc_intr,get_timeout (pc), idescsi_expiry); -/* Send the actual packet */ - hwif->output_data (drive,NULL , scsi->pc->c,12 ); -if (pc->flags &PC_FLAG_DMA_OK ) { pc->flags |=PC_FLAG_DMA_IN_PROGRESS ; hwif->dma_ops->dma_start (drive); } + +/* Send the actual packet */ + hwif->output_data (drive,NULL , scsi->pc->c,12 ); +return ide_started; }
PATCH 2/40 ide-scsi: fix DRQ checking for DMA transfers in idescsi_pc_intr()
In reply to Bartlomiej ZolnierkiewiczIf DRQ bit of Status Register is not cleared it is an error condition and should be handled accordingly (disable DMA + reset the device).
--- drivers/scsi/ide-scsi.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/scsi/ide-scsi.c +8 -1
@@ -388,7 +388,6 @@ static ide_startstop_t idescsi_pc_intr (return ide_stopped; }if (pc->flags &PC_FLAG_DMA_IN_PROGRESS ) { - pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS ;#if IDESCSI_DEBUG_LOG printk ("ide-scsi: %s: DMA complete\n" , drive->name);#endif /* IDESCSI_DEBUG_LOG */
@@ -404,12 +403,20 @@ static ide_startstop_t idescsi_pc_intr (if (test_bit (IDESCSI_LOG_CMD , &scsi->log))printk (KERN_INFO "Packet command completed, %d bytes" " transferred\n" , pc->xferred); + pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS ;local_irq_enable_in_hardirq ();if (stat &ERR_STAT ) rq->errors++;idescsi_end_request (drive,1 ,0 );return ide_stopped; } +if (pc->flags &PC_FLAG_DMA_IN_PROGRESS ) { + pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS ; +printk (KERN_ERR "%s: The device wants to issue more interrupts " +"in DMA mode\n" , drive->name); +ide_dma_off (drive); +return ide_do_reset (drive); + } bcount = (hwif->INB (hwif->io_ports.lbah_addr) <<8 ) | hwif->INB (hwif->io_ports.lbam_addr); ireason = hwif->INB (hwif->io_ports.nsect_addr);
PATCH 3/40 ide-scsi: fix handling of DMA errors in idescsi_pc_intr()
In reply to Bartlomiej ZolnierkiewiczCheck return value of ->dma_end method and if there was a DMA error handle it accordingly (set PC_FLAG_DMA_ERROR pc flag, don't update pc->xferred and increase rq->errors).
Also move debug message in the right place while at it.
--- drivers/scsi/ide-scsi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/scsi/ide-scsi.c +5 -3
@@ -388,11 +388,13 @@ static ide_startstop_t idescsi_pc_intr (return ide_stopped; }if (pc->flags &PC_FLAG_DMA_IN_PROGRESS ) { +if (hwif->dma_ops->dma_end (drive)) + pc->flags |=PC_FLAG_DMA_ERROR ; +else + pc->xferred = pc->req_xfer;#if IDESCSI_DEBUG_LOG printk ("ide-scsi: %s: DMA complete\n" , drive->name);#endif /* IDESCSI_DEBUG_LOG */ - pc->xferred = pc->req_xfer; - (void )hwif->dma_ops->dma_end (drive); }/* Clear the interrupt */
@@ -405,7 +407,7 @@ static ide_startstop_t idescsi_pc_intr ( " transferred\n", pc->xferred); pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS ;local_irq_enable_in_hardirq (); -if (stat &ERR_STAT ) +if ((stat &ERR_STAT ) || (pc->flags &PC_FLAG_DMA_ERROR )) rq->errors++;idescsi_end_request (drive,1 ,0 );return ide_stopped;
PATCH 4/40 ide-scsi: fix Interrupt Reason checking in idescsi_pc_intr()
In reply to Bartlomiej ZolnierkiewiczSet PC_FLAG_WRITING pc flag in idescsi_queue() (if needed) and then fix Interrupt Reason checking in idescsi_pc_intr().
--- drivers/scsi/ide-scsi.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/scsi/ide-scsi.c +11 -6
@@ -427,7 +427,15 @@ static ide_startstop_t idescsi_pc_intr (printk (KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n" );return ide_do_reset (drive); } -if (ireason &IO ) { +if (((ireason &IO ) ==IO ) == !!(pc->flags &PC_FLAG_WRITING )) { +/* Hopefully, we will never get here */ +printk (KERN_ERR "%s: We wanted to %s, but the device wants us " +"to %s!\n" , drive->name, + (ireason &IO ) ?"Write" :"Read" , + (ireason &IO ) ?"Read" :"Write" ); +return ide_do_reset (drive); + } +if (!(pc->flags &PC_FLAG_WRITING )) { temp = pc->xferred + bcount;if (temp > pc->req_xfer) {if (temp > pc->buf_size) {
@@ -436,7 +444,6 @@ static ide_startstop_t idescsi_pc_intr ( "- discarding data\n"); temp = pc->buf_size - pc->xferred;if (temp) { - pc->flags &= ~PC_FLAG_WRITING ;if (pc->sg)idescsi_input_buffers (drive, pc, temp);
@@ -457,15 +464,11 @@ static ide_startstop_t idescsi_pc_intr (printk (KERN_NOTICE "ide-scsi: The scsi wants to send us more data than expected - allowing transfer\n" );#endif /* IDESCSI_DEBUG_LOG */ } - } -if (ireason &IO ) { - pc->flags &= ~PC_FLAG_WRITING ;if (pc->sg)idescsi_input_buffers (drive, pc, bcount);else hwif->input_data (drive,NULL , pc->cur_pos, bcount); }else { - pc->flags |=PC_FLAG_WRITING ;if (pc->sg)idescsi_output_buffers (drive, pc, bcount);else
@@ -777,6 +780,8 @@ static int idescsi_queue (struct scsi_cmmemset (pc->c,0 ,12 ); pc->flags =0 ; +if (cmd->sc_data_direction ==DMA_TO_DEVICE ) + pc->flags |=PC_FLAG_WRITING ; pc->rq = rq;memcpy (pc->c, cmd->cmnd, cmd->cmd_len); pc->buf =NULL ;
Re: [PATCH 04/40] ide-scsi: fix Interrupt Reason checking in idescsi_pc_intr()
Quoted 41 lines · Bartlomiej Zolnierkiewicz
Set
PC_FLAG_WRITINGpc flag inidescsi_queue()(if needed) and then fix Interrupt Reason checking inidescsi_pc_intr().Cc Borislav Petkov <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>--- drivers/scsi/ide-scsi.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)Index:
b/drivers/scsi/ide-scsi.c
===================================================================drivers/scsi/ide-scsi.c +9
-2@@ -427,7 +427,15 @@ static ide_startstop_t idescsi_pc_intr (printk (KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n" );return ide_do_reset (drive); } -if (ireason &IO ) { +if (((ireason &IO ) ==IO ) == !!(pc->flags &PC_FLAG_WRITING )) { +/* Hopefully, we will never get here */ +printk (KERN_ERR "%s: We wanted to %s, but the device wants us " +"to %s!\n" , drive->name, + (ireason &IO ) ?"Write" :"Read" , + (ireason &IO ) ?"Read" :"Write" ); +return ide_do_reset (drive); + } +if (!(pc->flags &PC_FLAG_WRITING )) { temp = pc->xferred + bcount;if (temp > pc->req_xfer) {if (temp > pc->buf_size) {@@ -436,7 +444,6 @@ static ide_startstop_t idescsi_pc_intr ( "- discarding data\n"); temp = pc->buf_size - pc->xferred;if (temp) { - pc->flags &= ~PC_FLAG_WRITING ;if (pc->sg)idescsi_input_buffers (drive, pc, temp);@@ -457,15 +464,11 @@ static ide_startstop_t idescsi_pc_intr (printk (KERN_NOTICE "ide-scsi: The scsi wants to send us more data than expected - allowing transfer\n" );#endif /* IDESCSI_DEBUG_LOG */
drivers/scsi/ide-scsi.c static ide_startstop_t idescsi_pc_intr ( · line 468
Quoted 10 lines
drivers/scsi/ide-scsi.c +0
-4} - } -if (ireason &IO ) { - pc->flags &= ~PC_FLAG_WRITING ;if (pc->sg)idescsi_input_buffers (drive, pc, bcount);else hwif->input_data (drive,NULL , pc->cur_pos, bcount); }else { - pc->flags |=PC_FLAG_WRITING ;
Yeah, what was the driver doing turning on/off that flag in the irq handler? Are those pc's getting reused in ide-scsi... I guess this is one of the bugs you were talking about :).
Quoted 12 lines
drivers/scsi/ide-scsi.c +2
-0if (pc->sg)idescsi_output_buffers (drive, pc, bcount);else @@ -777,6 +780,8 @@ static int idescsi_queue (struct scsi_cmmemset (pc->c,0 ,12 ); pc->flags =0 ; +if (cmd->sc_data_direction ==DMA_TO_DEVICE ) + pc->flags |=PC_FLAG_WRITING ; pc->rq = rq;memcpy (pc->c, cmd->cmnd, cmd->cmd_len); pc->buf =NULL ;
Signature · 2 lines
Regards/Gruß,
Boris.Re: [PATCH 04/40] ide-scsi: fix Interrupt Reason checking in idescsi_pc_intr()
Quoted 48 lines · Borislav Petkov
Quoted 47 lines · Bartlomiej Zolnierkiewicz
Set
PC_FLAG_WRITINGpc flag inidescsi_queue()(if needed) and then fix Interrupt Reason checking inidescsi_pc_intr().Cc Borislav Petkov <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>--- drivers/scsi/ide-scsi.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)Index:
b/drivers/scsi/ide-scsi.c
===================================================================drivers/scsi/ide-scsi.c +9
-5@@ -427,7 +427,15 @@ static ide_startstop_t idescsi_pc_intr (printk (KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n" );return ide_do_reset (drive); } -if (ireason &IO ) { +if (((ireason &IO ) ==IO ) == !!(pc->flags &PC_FLAG_WRITING )) { +/* Hopefully, we will never get here */ +printk (KERN_ERR "%s: We wanted to %s, but the device wants us " +"to %s!\n" , drive->name, + (ireason &IO ) ?"Write" :"Read" , + (ireason &IO ) ?"Read" :"Write" ); +return ide_do_reset (drive); + } +if (!(pc->flags &PC_FLAG_WRITING )) { temp = pc->xferred + bcount;if (temp > pc->req_xfer) {if (temp > pc->buf_size) {@@ -436,7 +444,6 @@ static ide_startstop_t idescsi_pc_intr ( "- discarding data\n"); temp = pc->buf_size - pc->xferred;if (temp) { - pc->flags &= ~PC_FLAG_WRITING ;if (pc->sg)idescsi_input_buffers (drive, pc, temp);@@ -457,15 +464,11 @@ static ide_startstop_t idescsi_pc_intr (printk (KERN_NOTICE "ide-scsi: The scsi wants to send us more data than expected - allowing transfer\n" );#endif /* IDESCSI_DEBUG_LOG */ } - } -if (ireason &IO ) { - pc->flags &= ~PC_FLAG_WRITING ;if (pc->sg)idescsi_input_buffers (drive, pc, bcount);
Quoted 8 lines
drivers/scsi/ide-scsi.c static ide_startstop_t idescsi_pc_intr ( · line 468
Quoted 4 lines
drivers/scsi/ide-scsi.c +0
-1else hwif->input_data (drive,NULL , pc->cur_pos, bcount); }else { - pc->flags |=PC_FLAG_WRITING ;Yeah, what was the driver doing turning on/off that flag in the irq handler? Are those pc's getting reused in ide-scsi... I guess this is one of the bugs you were talking about :).
I guess that it was a left-over from the old days...
[ nowadays idescsi_queue() dynamically allocates new pc-s ]
Thanks,
Bart
PATCH 5/40 ide-scsi: merge idescsi_input_buffers() and idescsi_output_buffers()
In reply to Bartlomiej Zolnierkiewicz* Merge idescsi_input_buffers() and idescsi_output_buffers() into ide_scsi_io_buffers() helper.
While at it:
* Log device name instead of driver name on error.
* Use xfer_func_t.
--- drivers/scsi/ide-scsi.c | 81 ++++++++++++++---------------------------------- 1 file changed, 24 insertions(+), 57 deletions(-)
drivers/scsi/ide-scsi.c +24 -57
@@ -129,51 +129,15 @@ static inline idescsi_scsi_t *drive_to_i#define IDESCSI_PC_RQ 90/* -* PIO data transfer routines using the scatter gather table. +* PIO data transfer routine using the scatter gather table. */ -static void idescsi_input_buffers (ide_drive_t *drive,struct ide_atapi_pc *pc, -unsigned int bcount) +static void ide_scsi_io_buffers (ide_drive_t *drive,struct ide_atapi_pc *pc, +unsigned int bcount,int write) {ide_hwif_t *hwif = drive->hwif; -int count; +xfer_func_t *xf = write ? hwif->output_data : hwif->input_data;char *buf; - -while (bcount) { - count =min (pc->sg->length - pc->b_count, bcount); -if (PageHighMem (sg_page (pc->sg))) { -unsigned long flags; - -local_irq_save (flags); - buf =kmap_atomic (sg_page (pc->sg),KM_IRQ0 ) + - pc->sg->offset; - hwif->input_data (drive,NULL , buf + pc->b_count, count); -kunmap_atomic (buf - pc->sg->offset,KM_IRQ0 ); -local_irq_restore (flags); - }else { - buf =sg_virt (pc->sg); - hwif->input_data (drive,NULL , buf + pc->b_count, count); - } - bcount -= count; pc->b_count += count; -if (pc->b_count == pc->sg->length) { -if (!--pc->sg_cnt) -break ; - pc->sg =sg_next (pc->sg); - pc->b_count =0 ; - } - } - -if (bcount) { -printk (KERN_ERR "ide-scsi: scatter gather table too small, discarding data\n" ); -ide_pad_transfer (drive,0 , bcount); - } -} - -static void idescsi_output_buffers (ide_drive_t *drive,struct ide_atapi_pc *pc, -unsigned int bcount) -{ -ide_hwif_t *hwif = drive->hwif;int count; -char *buf;while (bcount) { count =min (pc->sg->length - pc->b_count, bcount);
@@ -182,13 +146,13 @@ static void idescsi_output_buffers(ide_dlocal_irq_save (flags); buf =kmap_atomic (sg_page (pc->sg),KM_IRQ0 ) + - pc->sg->offset; - hwif->output_data (drive,NULL , buf + pc->b_count, count); + pc->sg->offset; +xf (drive,NULL , buf + pc->b_count, count);kunmap_atomic (buf - pc->sg->offset,KM_IRQ0 );local_irq_restore (flags); }else { buf =sg_virt (pc->sg); - hwif->output_data (drive,NULL , buf + pc->b_count, count); +xf (drive,NULL , buf + pc->b_count, count); } bcount -= count; pc->b_count += count;if (pc->b_count == pc->sg->length) {
@@ -200,8 +164,10 @@ static void idescsi_output_buffers(ide_d }if (bcount) { -printk (KERN_ERR "ide-scsi: scatter gather table too small, padding with zeros\n" ); -ide_pad_transfer (drive,1 , bcount); +printk (KERN_ERR "%s: scatter gather table too small, %s\n" , + drive->name, write ?"padding with zeros" + :"discarding data" ); +ide_pad_transfer (drive, write, bcount); } }
@@ -370,6 +336,7 @@ static ide_startstop_t idescsi_pc_intr (ide_hwif_t *hwif = drive->hwif;struct ide_atapi_pc *pc = scsi->pc;struct request *rq = pc->rq; +xfer_func_t *xferfunc;unsigned int temp;u16 bcount;u8 stat, ireason;
@@ -445,8 +412,8 @@ static ide_startstop_t idescsi_pc_intr ( temp = pc->buf_size - pc->xferred;if (temp) {if (pc->sg) -idescsi_input_buffers (drive, pc, - temp); +ide_scsi_io_buffers (drive, pc, + temp,0 );else hwif->input_data (drive,NULL , pc->cur_pos, temp);
@@ -464,16 +431,16 @@ static ide_startstop_t idescsi_pc_intr (printk (KERN_NOTICE "ide-scsi: The scsi wants to send us more data than expected - allowing transfer\n" );#endif /* IDESCSI_DEBUG_LOG */ } -if (pc->sg) -idescsi_input_buffers (drive, pc, bcount); -else - hwif->input_data (drive,NULL , pc->cur_pos, bcount); - }else { -if (pc->sg) -idescsi_output_buffers (drive, pc, bcount); -else - hwif->output_data (drive,NULL , pc->cur_pos, bcount); - } + xferfunc = hwif->input_data; + }else + xferfunc = hwif->output_data; + +if (pc->sg) +ide_scsi_io_buffers (drive, pc, bcount, + !!(pc->flags &PC_FLAG_WRITING )); +else +xferfunc (drive,NULL , pc->cur_pos, bcount); +/* Update the current position */ pc->xferred += bcount; pc->cur_pos += bcount;
PATCH 6/40 ide-scsi: remove superfluous BUG_ON() from idescsi_transfer_pc()
In reply to Bartlomiej Zolnierkiewiczide_set_handler() bugs on ->handler == NULL so no need to do it in idescsi_transfer_pc().
There should be no functional changes caused by this patch.
--- drivers/scsi/ide-scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ide-scsi.c +1 -1
@@ -469,7 +469,7 @@ static ide_startstop_t idescsi_transfer_ "issuing a packet command\n");return ide_do_reset (drive); } -BUG_ON (HWGROUP (drive)->handler !=NULL ); +/* Set the interrupt routine */ ide_set_handler (drive, &idescsi_pc_intr,get_timeout (pc), idescsi_expiry);
PATCH 7/40 ide-scsi: add debug_log() macro
In reply to Bartlomiej ZolnierkiewiczAdd debug_log() macro and convert the driver to use it.
[ This makes debug messages to be always prefixed with "ide-scsi: "
and use KERN_INFO level. ]
While at it:
* Change "DMA complete" debug message to "DMA finished" to match other ATAPI device drivers.
* Use __func__.
--- drivers/scsi/ide-scsi.c | 51 +++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 26 deletions(-)
drivers/scsi/ide-scsi.c +25 -26
@@ -60,6 +60,13 @@#define IDESCSI_DEBUG_LOG 0 +#if IDESCSI_DEBUG_LOG +#define debug_log(fmt, args...) \ + printk(KERN_INFO "ide-scsi: " fmt, ## args) +#else +#define debug_log(fmt, args...) do {} while (0) +#endif +/* * SCSI command transformation layer */
@@ -237,10 +244,9 @@ idescsi_atapi_error(ide_drive_t *drive,static ide_startstop_t idescsi_atapi_abort (ide_drive_t *drive,struct request *rq) { -#if IDESCSI_DEBUG_LOG -printk (KERN_WARNING "idescsi_atapi_abort called for %lu\n" , +debug_log ("%s called for %lu\n" , __func__, ((struct ide_atapi_pc *) rq->special)->scsi_cmd->serial_number); -#endif + rq->errors |=ERROR_MAX ;idescsi_end_request (drive,0 ,0 );
@@ -319,9 +325,9 @@ static int idescsi_expiry(ide_drive_t *didescsi_scsi_t *scsi =drive_to_idescsi (drive);struct ide_atapi_pc *pc = scsi->pc; -#if IDESCSI_DEBUG_LOG -printk (KERN_WARNING "idescsi_expiry called for %lu at %lu\n" , pc->scsi_cmd->serial_number, jiffies); -#endif +debug_log ("%s called for %lu at %lu\n" , __func__, + pc->scsi_cmd->serial_number, jiffies); + pc->flags |=PC_FLAG_TIMEDOUT ;return 0 ;/* we do not want the ide subsystem to retry */
@@ -341,15 +347,11 @@ static ide_startstop_t idescsi_pc_intr (u16 bcount;u8 stat, ireason; -#if IDESCSI_DEBUG_LOG -printk (KERN_INFO "ide-scsi: Reached idescsi_pc_intr interrupt handler\n" ); -#endif /* IDESCSI_DEBUG_LOG */ +debug_log ("Reached %s interrupt handler\n" , __func__);if (pc->flags &PC_FLAG_TIMEDOUT ) { -#if IDESCSI_DEBUG_LOG -printk (KERN_WARNING "idescsi_pc_intr: got timed out packet %lu at %lu\n" , - pc->scsi_cmd->serial_number, jiffies); -#endif +debug_log ("%s: got timed out packet %lu at %lu\n" , __func__, + pc->scsi_cmd->serial_number, jiffies);/* end this request now - scsi should retry it*/ idescsi_end_request (drive,1 ,0 );return ide_stopped;
@@ -359,9 +361,7 @@ static ide_startstop_t idescsi_pc_intr ( pc->flags |=PC_FLAG_DMA_ERROR ; else pc->xferred = pc->req_xfer; -#if IDESCSI_DEBUG_LOG -printk ("ide-scsi: %s: DMA complete\n" , drive->name); -#endif /* IDESCSI_DEBUG_LOG */ +debug_log ("%s: DMA finished\n" , drive->name); }/* Clear the interrupt */
@@ -427,9 +427,8 @@ static ide_startstop_t idescsi_pc_intr (ide_set_handler (drive, &idescsi_pc_intr,get_timeout (pc), idescsi_expiry);return ide_started; } -#if IDESCSI_DEBUG_LOG -printk (KERN_NOTICE "ide-scsi: The scsi wants to send us more data than expected - allowing transfer\n" ); -#endif /* IDESCSI_DEBUG_LOG */ +debug_log ("The scsi wants to send us more data than " +"expected - allowing transfer\n" ); } xferfunc = hwif->input_data; }else
@@ -566,10 +565,10 @@ static ide_startstop_t idescsi_issue_pc(*/ static ide_startstop_t idescsi_do_request (ide_drive_t *drive,struct request *rq,sector_t block) { -#if IDESCSI_DEBUG_LOG -printk (KERN_INFO "dev: %s, cmd: %x, errors: %d\n" , rq->rq_disk->disk_name,rq->cmd[0 ],rq->errors); -printk (KERN_INFO "sector: %ld, nr_sectors: %ld, current_nr_sectors: %d\n" ,rq->sector,rq->nr_sectors,rq->current_nr_sectors); -#endif /* IDESCSI_DEBUG_LOG */ +debug_log ("dev: %s, cmd: %x, errors: %d\n" , rq->rq_disk->disk_name, + rq->cmd[0 ], rq->errors); +debug_log ("sector: %ld, nr_sectors: %ld, current_nr_sectors: %d\n" , + rq->sector, rq->nr_sectors, rq->current_nr_sectors);if (blk_sense_request (rq) ||blk_special_request (rq)) { return idescsi_issue_pc(drive,
@@ -976,10 +975,10 @@ static int ide_scsi_probe(ide_drive_t *d host->max_id =1 ; -#if IDESCSI_DEBUG_LOG if (drive->id->last_lun) -printk (KERN_NOTICE "%s: id->last_lun=%u\n" , drive->name, drive->id->last_lun); -#endif +debug_log ("%s: id->last_lun=%u\n" , drive->name, + drive->id->last_lun); +if ((drive->id->last_lun &0x7 ) !=7 ) host->max_lun = (drive->id->last_lun &0x7 ) +1 ;else
PATCH 8/40 ide-tape: idetape_pc_intr() should use local_irq_enable_in_hardirq()
In reply to Bartlomiej Zolnierkiewicz--- drivers/ide/ide-tape.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ide/ide-tape.c +1 -1
@@ -794,7 +794,7 @@ static ide_startstop_t idetape_pc_intr(i " transferred\n", pc->xferred); pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS ; -local_irq_enable (); +local_irq_enable_in_hardirq ();#if SIMULATE_ERRORS if ((pc->c[0] == WRITE_6 || pc->c[0] == READ_6) &&
PATCH 9/40 ide-tape: remove superfluous error message from idetape_pc_intr()
In reply to Bartlomiej Zolnierkiewiczide_dma_off() prints info about DMA being disabled.
--- drivers/ide/ide-tape.c | 1 - 1 file changed, 1 deletion(-)
drivers/ide/ide-tape.c +0 -1
@@ -842,7 +842,6 @@ static ide_startstop_t idetape_pc_intr(i pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS ;printk (KERN_ERR "ide-tape: The tape wants to issue more " "interrupts in DMA mode\n" ); -printk (KERN_ERR "ide-tape: DMA disabled, reverting to PIO\n" );ide_dma_off (drive);return ide_do_reset (drive); }
PATCH 10/40 ide-tape: remove superfluous warning message from idetape_issue_pc()
In reply to Bartlomiej Zolnierkiewiczide_dma_off() prints info about DMA being disabled.
--- drivers/ide/ide-tape.c | 2 -- 1 file changed, 2 deletions(-)
drivers/ide/ide-tape.c +0 -2
@@ -1038,8 +1038,6 @@ static ide_startstop_t idetape_issue_pc(if (pc->flags &PC_FLAG_DMA_ERROR ) { pc->flags &= ~PC_FLAG_DMA_ERROR ; -printk (KERN_WARNING "ide-tape: DMA disabled, " -"reverting to PIO\n" );ide_dma_off (drive); }if ((pc->flags &PC_FLAG_DMA_RECOMMENDED ) && drive->using_dma)
PATCH 11/40 ide-tape: remove unneeded CONFIG_BLK_DEV_IDEDMA ifdef
In reply to Bartlomiej ZolnierkiewiczPC_FLAG_DMA_IN_PROGRESS flag is never set if DMA support is disabled.
--- drivers/ide/ide-tape.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ide/ide-tape.c +2 -2
@@ -973,11 +973,11 @@ static ide_startstop_t idetape_transfer_ }/* Set the interrupt routine */ ide_set_handler (drive, &idetape_pc_intr,IDETAPE_WAIT_CMD ,NULL ); -#ifdef CONFIG_BLK_DEV_IDEDMA +/* Begin DMA, if necessary */ if (pc->flags &PC_FLAG_DMA_IN_PROGRESS ) hwif->dma_ops->dma_start (drive); -#endif +/* Send the actual packet */ hwif->output_data (drive,NULL , pc->c,12 );
PATCH 12/40 ide-tape: remove stale comments from idetape_pc_intr()
In reply to Bartlomiej Zolnierkiewicz--- drivers/ide/ide-tape.c | 21 --------------------- 1 file changed, 21 deletions(-)
drivers/ide/ide-tape.c +0 -21
@@ -758,27 +758,6 @@ static ide_startstop_t idetape_pc_intr(iif (pc->flags &PC_FLAG_DMA_IN_PROGRESS ) {if (hwif->dma_ops->dma_end (drive) || (stat &ERR_STAT )) { -/* -* A DMA error is sometimes expected. For example, -* if the tape is crossing a filemark during a -* READ command, it will issue an irq and position -* itself before the filemark, so that only a partial -* data transfer will occur (which causes the DMA -* error). In that case, we will later ask the tape -* how much bytes of the original request were -* actually transferred (we can't receive that -* information from the DMA engine on most chipsets). -*/ - -/* -* On the contrary, a DMA error is never expected; -* it usually indicates a hardware error or abort. -* If the tape crosses a filemark during a READ -* command, it will issue an irq and position itself -* after the filemark (not before). Only a partial -* data transfer will occur, but no DMA error. -* (AS, 19 Apr 2001) -*/ pc->flags |=PC_FLAG_DMA_ERROR ; }else { pc->xferred = pc->req_xfer;
PATCH 13/40 ide-tape: remove SIMULATE_ERRORS debug code
In reply to Bartlomiej Zolnierkiewicz--- drivers/ide/ide-tape.c | 14 -------------- 1 file changed, 14 deletions(-)
drivers/ide/ide-tape.c +0 -14
@@ -144,9 +144,6 @@ enum {/*************************** End of tunable parameters ***********************/ -/* Read/Write error simulation */ -#define SIMULATE_ERRORS 0 -/* tape directions */ enum {IDETAPE_DIR_NONE = (1 <<0 ),
@@ -745,9 +742,6 @@ static ide_startstop_t idetape_pc_intr(ixfer_func_t *xferfunc;idetape_io_buf *iobuf;unsigned int temp; -#if SIMULATE_ERRORS -static int error_sim_count; -#endif u16 bcount;u8 stat, ireason;
@@ -775,14 +769,6 @@ static ide_startstop_t idetape_pc_intr(i pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS ;local_irq_enable_in_hardirq (); -#if SIMULATE_ERRORS -if ((pc->c[0 ] ==WRITE_6 || pc->c[0 ] ==READ_6 ) && - (++error_sim_count %100 ) ==0 ) { -printk (KERN_INFO "ide-tape: %s: simulating error\n" , - tape->name); - stat |=ERR_STAT ; - } -#endif if ((stat &ERR_STAT ) && pc->c[0 ] ==REQUEST_SENSE ) stat &= ~ERR_STAT ;if ((stat &ERR_STAT ) || (pc->flags &PC_FLAG_DMA_ERROR )) {
PATCH 14/40 ide-floppy: merge idefloppy_transfer_pc() and idefloppy_transfer_pc1()
In reply to Bartlomiej Zolnierkiewicz* Check IDEFLOPPY_FLAG_ZIP_DRIVE flag in idefloppy_transfer_pc1() and skip idefloppy_transfer_pc2()-phase if the flag is not set.
* Always use idefloppy_transfer_pc1() in idefloppy_issue_pc() and remove no longer needed idefloppy_transfer_pc().
There should be no functional changes caused by this patch.
--- drivers/ide/ide-floppy.c | 65 ++++++++++++----------------------------------- 1 file changed, 17 insertions(+), 48 deletions(-)
drivers/ide/ide-floppy.c +17 -48
@@ -522,40 +522,6 @@ static ide_startstop_t idefloppy_pc_intr }/* -* This is the original routine that did the packet transfer. -* It fails at high speeds on the Iomega ZIP drive, so there's a slower version -* for that drive below. The algorithm is chosen based on drive type -*/ -static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive) -{ -ide_hwif_t *hwif = drive->hwif; -ide_startstop_t startstop; -idefloppy_floppy_t *floppy = drive->driver_data; -u8 ireason; - -if (ide_wait_stat (&startstop, drive,DRQ_STAT ,BUSY_STAT ,WAIT_READY )) { -printk (KERN_ERR "ide-floppy: Strange, packet command " -"initiated yet DRQ isn't asserted\n" ); -return startstop; - } - ireason = hwif->INB (hwif->io_ports.nsect_addr); -if ((ireason &CD ) ==0 || (ireason &IO )) { -printk (KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while " -"issuing a packet command\n" ); -return ide_do_reset (drive); - } - -/* Set the interrupt routine */ -ide_set_handler (drive, &idefloppy_pc_intr,IDEFLOPPY_WAIT_CMD ,NULL ); - -/* Send the actual packet */ - hwif->output_data (drive,NULL , floppy->pc->c,12 ); - -return ide_started; -} - - -/* * What we have here is a classic case of a top half / bottom half interrupt * service routine. In interrupt mode, the device sends an interrupt to signal * that it is ready to receive a packet. However, we need to delay about 2-3
@@ -580,6 +546,8 @@ static ide_startstop_t idefloppy_transfe {ide_hwif_t *hwif = drive->hwif;idefloppy_floppy_t *floppy = drive->driver_data; +ide_expiry_t *expiry; +unsigned int timeout;ide_startstop_t startstop;u8 ireason;
@@ -602,9 +570,20 @@ static ide_startstop_t idefloppy_transfe* 40 and 50msec work well. idefloppy_pc_intr will not be actually * used until after the packet is moved in about 50 msec. */ +if (floppy->flags &IDEFLOPPY_FLAG_ZIP_DRIVE ) { + timeout = floppy->ticks; + expiry = &idefloppy_transfer_pc2; + }else { + timeout =IDEFLOPPY_WAIT_CMD ; + expiry =NULL ; + } + +ide_set_handler (drive, &idefloppy_pc_intr, timeout, expiry); + +if ((floppy->flags &IDEFLOPPY_FLAG_ZIP_DRIVE ) ==0 ) +/* Send the actual packet */ + hwif->output_data (drive,NULL , floppy->pc->c,12 ); -ide_set_handler (drive, &idefloppy_pc_intr, floppy->ticks, - &idefloppy_transfer_pc2);return ide_started; }
@@ -629,7 +608,6 @@ static ide_startstop_t idefloppy_issue_p {idefloppy_floppy_t *floppy = drive->driver_data;ide_hwif_t *hwif = drive->hwif; -ide_handler_t *pkt_xfer_routine;u16 bcount;u8 dma;
@@ -675,26 +653,17 @@ static ide_startstop_t idefloppy_issue_p hwif->dma_ops->dma_start (drive); } -/* Can we transfer the packet when we get the interrupt or wait? */ -if (floppy->flags &IDEFLOPPY_FLAG_ZIP_DRIVE ) { -/* wait */ - pkt_xfer_routine = &idefloppy_transfer_pc1; - }else { -/* immediate */ - pkt_xfer_routine = &idefloppy_transfer_pc; - } -if (floppy->flags &IDEFLOPPY_FLAG_DRQ_INTERRUPT ) {/* Issue the packet command */ ide_execute_command (drive,WIN_PACKETCMD , - pkt_xfer_routine, + &idefloppy_transfer_pc1,IDEFLOPPY_WAIT_CMD ,NULL );return ide_started; }else {/* Issue the packet command */ ide_execute_pkt_cmd (drive); -return (*pkt_xfer_routine) (drive); +return idefloppy_transfer_pc1 (drive); } }
Re: [PATCH 14/40] ide-floppy: merge idefloppy_transfer_pc() and idefloppy_transfer_pc1()
Quoted 5 lines · Bartlomiej Zolnierkiewicz
* Check
IDEFLOPPY_FLAG_ZIP_DRIVEflag inidefloppy_transfer_pc1()and skip idefloppy_transfer_pc2()-phase if the flag is not set.* Always use
idefloppy_transfer_pc1()inidefloppy_issue_pc()and remove no longer neededidefloppy_transfer_pc().
... and also probably mv idefloppy_transfer_pc1() to something like idefloppy_start_transfer_pc() and rename idefloppy_transfer_pc2() to something more appropriate like e.g. idefloppy_do_transfer_pc() or similar and do away with those misleading names and probably even the comments are superfluous then.
Quoted 123 lines
There should be no functional changes caused by this patch.
Cc Borislav Petkov <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>--- drivers/ide/ide-floppy.c | 65 ++++++++++++----------------------------------- 1 file changed, 17 insertions(+), 48 deletions(-)Index:
b/drivers/ide/ide-floppy.c
===================================================================drivers/ide/ide-floppy.c +17
-48@@ -522,40 +522,6 @@ static ide_startstop_t idefloppy_pc_intr }/* -* This is the original routine that did the packet transfer. -* It fails at high speeds on the Iomega ZIP drive, so there's a slower version -* for that drive below. The algorithm is chosen based on drive type -*/ -static ide_startstop_t idefloppy_transfer_pc (ide_drive_t *drive) -{ -ide_hwif_t *hwif = drive->hwif; -ide_startstop_t startstop; -idefloppy_floppy_t *floppy = drive->driver_data; -u8 ireason; - -if (ide_wait_stat (&startstop, drive,DRQ_STAT ,BUSY_STAT ,WAIT_READY )) { -printk (KERN_ERR "ide-floppy: Strange, packet command " -"initiated yet DRQ isn't asserted\n" ); -return startstop; - } - ireason = hwif->INB (hwif->io_ports.nsect_addr); -if ((ireason &CD ) ==0 || (ireason &IO )) { -printk (KERN_ERR "ide-floppy: (IO,CoD) != (0,1) while " -"issuing a packet command\n" ); -return ide_do_reset (drive); - } - -/* Set the interrupt routine */ -ide_set_handler (drive, &idefloppy_pc_intr,IDEFLOPPY_WAIT_CMD ,NULL ); - -/* Send the actual packet */ - hwif->output_data (drive,NULL , floppy->pc->c,12 ); - -return ide_started; -} - - -/* * What we have here is a classic case of a top half / bottom half interrupt * service routine. In interrupt mode, the device sends an interrupt to signal * that it is ready to receive a packet. However, we need to delay about 2-3 @@ -580,6 +546,8 @@ static ide_startstop_t idefloppy_transfe {ide_hwif_t *hwif = drive->hwif;idefloppy_floppy_t *floppy = drive->driver_data; +ide_expiry_t *expiry; +unsigned int timeout;ide_startstop_t startstop;u8 ireason;@@ -602,9 +570,20 @@ static ide_startstop_t idefloppy_transfe* 40 and 50msec work well. idefloppy_pc_intr will not be actually * used until after the packet is moved in about 50 msec. */ +if (floppy->flags &IDEFLOPPY_FLAG_ZIP_DRIVE ) { + timeout = floppy->ticks; + expiry = &idefloppy_transfer_pc2; + }else { + timeout =IDEFLOPPY_WAIT_CMD ; + expiry =NULL ; + } + +ide_set_handler (drive, &idefloppy_pc_intr, timeout, expiry); + +if ((floppy->flags &IDEFLOPPY_FLAG_ZIP_DRIVE ) ==0 ) +/* Send the actual packet */ + hwif->output_data (drive,NULL , floppy->pc->c,12 ); -ide_set_handler (drive, &idefloppy_pc_intr, floppy->ticks, - &idefloppy_transfer_pc2);return ide_started; }@@ -629,7 +608,6 @@ static ide_startstop_t idefloppy_issue_p {idefloppy_floppy_t *floppy = drive->driver_data;ide_hwif_t *hwif = drive->hwif; -ide_handler_t *pkt_xfer_routine;u16 bcount;u8 dma;@@ -675,26 +653,17 @@ static ide_startstop_t idefloppy_issue_p hwif->dma_ops->dma_start (drive); } -/* Can we transfer the packet when we get the interrupt or wait? */ -if (floppy->flags &IDEFLOPPY_FLAG_ZIP_DRIVE ) { -/* wait */ - pkt_xfer_routine = &idefloppy_transfer_pc1; - }else { -/* immediate */ - pkt_xfer_routine = &idefloppy_transfer_pc; - } -if (floppy->flags &IDEFLOPPY_FLAG_DRQ_INTERRUPT ) {/* Issue the packet command */ ide_execute_command (drive,WIN_PACKETCMD , - pkt_xfer_routine, + &idefloppy_transfer_pc1,IDEFLOPPY_WAIT_CMD ,NULL );return ide_started; }else {/* Issue the packet command */ ide_execute_pkt_cmd (drive); -return (*pkt_xfer_routine) (drive); +return idefloppy_transfer_pc1 (drive); } }
Signature · 2 lines
Regards/Gruß,
Boris.Re: [PATCH 14/40] ide-floppy: merge idefloppy_transfer_pc() and idefloppy_transfer_pc1()
Quoted 11 lines · Borislav Petkov
Quoted 5 lines · Bartlomiej Zolnierkiewicz
* Check
IDEFLOPPY_FLAG_ZIP_DRIVEflag inidefloppy_transfer_pc1()and skip idefloppy_transfer_pc2()-phase if the flag is not set.* Always use
idefloppy_transfer_pc1()inidefloppy_issue_pc()and remove no longer neededidefloppy_transfer_pc().... and also probably mv
idefloppy_transfer_pc1()to something likeidefloppy_start_transfer_pc()and renameidefloppy_transfer_pc2()to something more appropriate like e.g.idefloppy_do_transfer_pc()or similar and do away with those misleading names and probably even the comments are superfluous then.
Probably the most intuitive would be to do:
idefloppy_transfer_pc1() -> idefloppy_transfer_pc()
and
idefloppy_transfer_pc2() -> idefloppy_do_transfer_pc()
but I don't feel too strong about it and welcome other ideas (preferably in form of patches :).
Thanks,
Bart
Re: [PATCH 14/40] ide-floppy: merge idefloppy_transfer_pc() and idefloppy_transfer_pc1()
Quoted 15 lines · Bartlomiej Zolnierkiewicz
Quoted 11 lines · Borislav Petkov
Quoted 5 lines · Bartlomiej Zolnierkiewicz
* Check
IDEFLOPPY_FLAG_ZIP_DRIVEflag inidefloppy_transfer_pc1()and skip idefloppy_transfer_pc2()-phase if the flag is not set.* Always use
idefloppy_transfer_pc1()inidefloppy_issue_pc()and remove no longer neededidefloppy_transfer_pc().... and also probably mv
idefloppy_transfer_pc1()to something likeidefloppy_start_transfer_pc()and renameidefloppy_transfer_pc2()to something more appropriate like e.g.idefloppy_do_transfer_pc()or similar and do away with those misleading names and probably even the comments are superfluous then.Probably the most intuitive would be to do:
Quoted 8 lines
idefloppy_transfer_pc1() -> idefloppy_transfer_pc()and
idefloppy_transfer_pc2() -> idefloppy_do_transfer_pc()but I don't feel too strong about it and welcome other ideas (preferably in form of patches :).
^Hint^! :) Sure, what about the following:
--
From: Borislav Petkov <[email protected]>
Date: Tue, 27 May 2008 07:31:37 +0200
Subject: [PATCH] ide-floppy: fix unfortunate function naming
mv idefloppy_transfer_pc1 idefloppy_start_pc_transfer mv idefloppy_transfer_pc2 idefloppy_transfer_pc
which describes their functionality and disambiguates them. There should be no functionality change introduced by this patch.
--- drivers/ide/ide-floppy.c | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-)
drivers/ide/ide-floppy.c +10 -8
@@ -399,12 +399,8 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive)* service routine. In interrupt mode, the device sends an interrupt to signal * that it is ready to receive a packet. However, we need to delay about 2-3 * ticks before issuing the packet or we gets in trouble. -* -* So, follow carefully. transfer_pc1 is called as an interrupt (or directly). -* In either case, when the device says it's ready for a packet, we schedule -* the packet transfer to occur about 2-3 ticks later in transfer_pc2. */ -static int idefloppy_transfer_pc2 (ide_drive_t *drive) +static int idefloppy_transfer_pc (ide_drive_t *drive) {idefloppy_floppy_t *floppy = drive->driver_data;
@@ -415,7 +411,13 @@ static int idefloppy_transfer_pc2(ide_drive_t *drive)return IDEFLOPPY_WAIT_CMD ; } -static ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) + +/* +* Called as an interrupt (or directly). When the device says it's ready for a +* packet, we schedule the packet transfer to occur about 2-3 ticks later in +* transfer_pc. +*/ +static ide_startstop_t idefloppy_start_pc_transfer (ide_drive_t *drive) {idefloppy_floppy_t *floppy = drive->driver_data;struct ide_atapi_pc *pc = floppy->pc;
@@ -432,7 +434,7 @@ static ide_startstop_t idefloppy_transfer_pc1(ide_drive_t *drive)*/ if (pc->flags &PC_FLAG_ZIP_DRIVE ) { timeout = floppy->ticks; - expiry = &idefloppy_transfer_pc2; + expiry = &idefloppy_transfer_pc; }else { timeout =IDEFLOPPY_WAIT_CMD ; expiry =NULL ;
@@ -483,7 +485,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, pc->retries++; -return ide_issue_pc (drive, pc, idefloppy_transfer_pc1, +return ide_issue_pc (drive, pc, idefloppy_start_pc_transfer,IDEFLOPPY_WAIT_CMD ,NULL ); }
Signature · 5 lines
1.5.5.1
--
Regards/Gruß,
Boris.Bartlomiej Zolnierkiewicz
AppliedRe: [PATCH 14/40] ide-floppy: merge idefloppy_transfer_pc() and idefloppy_transfer_pc1()
Quoted 32 lines · Borislav Petkov
Quoted 15 lines · Bartlomiej Zolnierkiewicz
Quoted 11 lines · Borislav Petkov
Quoted 5 lines · Bartlomiej Zolnierkiewicz
* Check
IDEFLOPPY_FLAG_ZIP_DRIVEflag inidefloppy_transfer_pc1()and skip idefloppy_transfer_pc2()-phase if the flag is not set.* Always use
idefloppy_transfer_pc1()inidefloppy_issue_pc()and remove no longer neededidefloppy_transfer_pc().... and also probably mv
idefloppy_transfer_pc1()to something likeidefloppy_start_transfer_pc()and renameidefloppy_transfer_pc2()to something more appropriate like e.g.idefloppy_do_transfer_pc()or similar and do away with those misleading names and probably even the comments are superfluous then.Probably the most intuitive would be to do:
Quoted 8 lines
idefloppy_transfer_pc1() -> idefloppy_transfer_pc()and
idefloppy_transfer_pc2() -> idefloppy_do_transfer_pc()but I don't feel too strong about it and welcome other ideas (preferably in form of patches :).
^Hint^! :) Sure, what about the following:
--From: Borislav Petkov <[email protected]>
Date: Tue, 27 May 2008 07:31:37 +0200
Subject: [PATCH] ide-floppy: fix unfortunate function naming
Quoted 7 lines
mv
idefloppy_transfer_pc1idefloppy_start_pc_transfermvidefloppy_transfer_pc2idefloppy_transfer_pcwhich describes their functionality and disambiguates them. There should be no functionality change introduced by this patch.
Signed-off-by Borislav Petkov <[email protected]>
applied, thanks
PATCH 15/40 ide-{floppy,tape,scsi}: log device name instead of driver name
In reply to Bartlomiej ZolnierkiewiczLog device name instead of driver name in *_pc_intr() and *_transfer_pc*().
While at it:
* Merge two consecutive printk()-s in *_pc_intr() together.
* Replace "floppy"/"tape"/"scsi" references in printk()-s by "device".
--- drivers/ide/ide-floppy.c | 35 ++++++++++++++++++----------------- drivers/ide/ide-tape.c | 42 ++++++++++++++++++++++-------------------- drivers/scsi/ide-scsi.c | 24 +++++++++++++----------- 3 files changed, 53 insertions(+), 48 deletions(-)
drivers/ide/ide-floppy.c +18 -17
@@ -438,8 +438,8 @@ static ide_startstop_t idefloppy_pc_intrdebug_log ("%s: I/O error\n" , drive->name); rq->errors++;if (pc->c[0 ] ==GPCMD_REQUEST_SENSE ) { -printk (KERN_ERR "ide-floppy: I/O error in " -"request sense command\n" ); +printk (KERN_ERR "%s: I/O error in request sense" +" command\n" , drive->name);return ide_do_reset (drive); }/* Retry operation */
@@ -457,8 +457,8 @@ static ide_startstop_t idefloppy_pc_intrif (pc->flags &PC_FLAG_DMA_IN_PROGRESS ) { pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS ; -printk (KERN_ERR "ide-floppy: The floppy wants to issue " -"more interrupts in DMA mode\n" ); +printk (KERN_ERR "%s: The device wants to issue more interrupts " +"in DMA mode\n" , drive->name);ide_dma_off (drive);return ide_do_reset (drive); }
@@ -470,14 +470,14 @@ static ide_startstop_t idefloppy_pc_intr ireason = hwif->INB (hwif->io_ports.nsect_addr);if (ireason &CD ) { -printk (KERN_ERR "ide-floppy: CoD != 0 in %s\n" , __func__); +printk (KERN_ERR "%s: CoD != 0 in %s\n" , drive->name, __func__);return ide_do_reset (drive); }if (((ireason &IO ) ==IO ) == !!(pc->flags &PC_FLAG_WRITING )) {/* Hopefully, we will never get here */ -printk (KERN_ERR "ide-floppy: We wanted to %s, " , - (ireason &IO ) ?"Write" :"Read" ); -printk (KERN_ERR "but the floppy wants us to %s !\n" , +printk (KERN_ERR "%s: We wanted to %s, but the device wants us " +"to %s!\n" , drive->name, + (ireason &IO ) ?"Write" :"Read" , (ireason &IO ) ?"Read" :"Write" );return ide_do_reset (drive); }
@@ -486,9 +486,10 @@ static ide_startstop_t idefloppy_pc_intr temp = pc->xferred + bcount;if (temp > pc->req_xfer) {if (temp > pc->buf_size) { -printk (KERN_ERR "ide-floppy: The floppy wants " -"to send us more data than expected " -"- discarding data\n" ); +printk (KERN_ERR "%s: The device wants to send " +"us more data than expected - " +"discarding data\n" , + drive->name);ide_pad_transfer (drive,0 , bcount); ide_set_handler(drive,
@@ -497,8 +498,8 @@ static ide_startstop_t idefloppy_pc_intr NULL);return ide_started; } -debug_log ("The floppy wants to send us more data than" -" expected - allowing transfer\n" ); +debug_log ("The device wants to send us more data than " +"expected - allowing transfer\n" ); } }if (pc->flags &PC_FLAG_WRITING )
@@ -552,14 +553,14 @@ static ide_startstop_t idefloppy_transfeu8 ireason;if (ide_wait_stat (&startstop, drive,DRQ_STAT ,BUSY_STAT ,WAIT_READY )) { -printk (KERN_ERR "ide-floppy: Strange, packet command " -"initiated yet DRQ isn't asserted\n" ); +printk (KERN_ERR "%s: Strange, packet command initiated yet " +"DRQ isn't asserted\n" , drive->name);return startstop; } ireason = hwif->INB (hwif->io_ports.nsect_addr);if ((ireason &CD ) ==0 || (ireason &IO )) { -printk (KERN_ERR "ide-floppy: (IO,CoD) != (0,1) " -"while issuing a packet command\n" ); +printk (KERN_ERR "%s: (IO,CoD) != (0,1) while issuing " +"a packet command\n" , drive->name);return ide_do_reset (drive); }/*
drivers/ide/ide-tape.c +22 -20
93 lines not on this page · raw message
drivers/scsi/ide-scsi.c +13 -11
@@ -391,7 +391,7 @@ static ide_startstop_t idescsi_pc_intr ( ireason = hwif->INB (hwif->io_ports.nsect_addr);if (ireason &CD ) { -printk (KERN_ERR "ide-scsi: CoD != 0 in idescsi_pc_intr\n" ); +printk (KERN_ERR "%s: CoD != 0 in %s\n" , drive->name, __func__);return ide_do_reset (drive); }if (((ireason &IO ) ==IO ) == !!(pc->flags &PC_FLAG_WRITING )) {
@@ -406,9 +406,10 @@ static ide_startstop_t idescsi_pc_intr ( temp = pc->xferred + bcount;if (temp > pc->req_xfer) {if (temp > pc->buf_size) { -printk (KERN_ERR "ide-scsi: The scsi wants to " -"send us more data than expected " -"- discarding data\n" ); +printk (KERN_ERR "%s: The device wants to send " +"us more data than expected - " +"discarding data\n" , + drive->name); temp = pc->buf_size - pc->xferred;if (temp) {if (pc->sg)
@@ -417,8 +418,9 @@ static ide_startstop_t idescsi_pc_intr (else hwif->input_data (drive,NULL , pc->cur_pos, temp); -printk (KERN_ERR "ide-scsi: transferred" -" %d of %d bytes\n" , +printk (KERN_ERR "%s: transferred %d of " +"%d bytes\n" , + drive->name, temp, bcount); } pc->xferred += temp;
@@ -427,7 +429,7 @@ static ide_startstop_t idescsi_pc_intr (ide_set_handler (drive, &idescsi_pc_intr,get_timeout (pc), idescsi_expiry);return ide_started; } -debug_log ("The scsi wants to send us more data than " +debug_log ("The device wants to send us more data than " "expected - allowing transfer\n" ); } xferfunc = hwif->input_data;
@@ -458,14 +460,14 @@ static ide_startstop_t idescsi_transfer_u8 ireason;if (ide_wait_stat (&startstop,drive,DRQ_STAT ,BUSY_STAT ,WAIT_READY )) { -printk (KERN_ERR "ide-scsi: Strange, packet command " -"initiated yet DRQ isn't asserted\n" ); +printk (KERN_ERR "%s: Strange, packet command initiated yet " +"DRQ isn't asserted\n" , drive->name);return startstop; } ireason = hwif->INB (hwif->io_ports.nsect_addr);if ((ireason &CD ) ==0 || (ireason &IO )) { -printk (KERN_ERR "ide-scsi: (IO,CoD) != (0,1) while " -"issuing a packet command\n" ); +printk (KERN_ERR "%s: (IO,CoD) != (0,1) while issuing " +"a packet command\n" , drive->name);return ide_do_reset (drive); }
PATCH 16/40 ide-tape: make idetape_retry_pc() void
In reply to Bartlomiej Zolnierkiewiczidetape_retry_pc() always returns ide_stopped so make it void.
There should be no functional changes caused by this patch.
--- drivers/ide/ide-tape.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/ide/ide-tape.c +5 -4
@@ -696,7 +696,7 @@ static void idetape_queue_pc_head(ide_dr* last packet command. We queue a request sense packet command in * the head of the request list. */ -static ide_startstop_t idetape_retry_pc (ide_drive_t *drive) +static void idetape_retry_pc (ide_drive_t *drive) {idetape_tape_t *tape = drive->driver_data;struct ide_atapi_pc *pc;
@@ -708,7 +708,6 @@ static ide_startstop_t idetape_retry_pcidetape_create_request_sense_cmd (pc);set_bit (IDETAPE_FLAG_IGNORE_DSC , &tape->flags);idetape_queue_pc_head (drive, pc, rq); -return ide_stopped; }/*
@@ -784,7 +783,8 @@ static ide_startstop_t idetape_pc_intr(i pc->c[0]);/* Retry operation */ -return idetape_retry_pc (drive); +idetape_retry_pc (drive); +return ide_stopped; } pc->error =0 ; if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) &&
@@ -1078,7 +1078,8 @@ static ide_startstop_t idetape_media_accprintk (KERN_ERR "ide-tape: %s: I/O error, " , tape->name);/* Retry operation */ -return idetape_retry_pc (drive); +idetape_retry_pc (drive); +return ide_stopped; } pc->error =0 ;if (tape->failed_pc == pc)
PATCH 17/40 ide-tape: merge callbacks
In reply to Bartlomiej ZolnierkiewiczThe appropriate functionality of the callback is established through querying the ATAPI packet command in pc->c[0].
While at it:
- add uptodate variable + leave just one idetape_end_request() call
- don't use HWGROUP() macro
--- drivers/ide/ide-tape.c | 168 ++++++++++++++++++------------------------------- 1 file changed, 64 insertions(+), 104 deletions(-)
drivers/ide/ide-tape.c +64 -104
@@ -503,18 +503,6 @@ static struct request *idetape_next_rq_sreturn (&tape->rq_stack[tape->rq_stack_index++]); } -static void idetape_init_pc (struct ide_atapi_pc *pc) -{ -memset (pc->c,0 ,12 ); - pc->retries =0 ; - pc->flags =0 ; - pc->req_xfer =0 ; - pc->buf = pc->pc_buf; - pc->buf_size =IDETAPE_PC_BUFFER_SIZE ; - pc->bh =NULL ; - pc->b_data =NULL ; -} -/* * called on each failed packet command retry to analyze the request sense. We * currently do not utilize this information.
@@ -631,30 +619,85 @@ static int idetape_end_request(ide_drivereturn 0 ; } -static ide_startstop_t idetape_request_sense_callback (ide_drive_t *drive) +static ide_startstop_t ide_tape_callback (ide_drive_t *drive) {idetape_tape_t *tape = drive->driver_data; +struct ide_atapi_pc *pc = tape->pc; +int uptodate = pc->error ?0 :1 ;debug_log (DBG_PROCS ,"Enter %s\n" , __func__); -if (!tape->pc->error) { -idetape_analyze_error (drive, tape->pc->buf); -idetape_end_request (drive,1 ,0 ); - }else { -printk (KERN_ERR "ide-tape: Error in REQUEST SENSE itself - " -"Aborting request!\n" ); -idetape_end_request (drive,0 ,0 ); +if (pc->c[0 ] ==REQUEST_SENSE ) { +if (uptodate) +idetape_analyze_error (drive, pc->buf); +else +printk (KERN_ERR "ide-tape: Error in REQUEST SENSE " +"itself - Aborting request!\n" ); + }else if (pc->c[0 ] ==READ_6 || pc->c[0 ] ==WRITE_6 ) { +struct request *rq = drive->hwif->hwgroup->rq; +int blocks = pc->xferred / tape->blk_size; + + tape->avg_size += blocks * tape->blk_size; + +if (time_after_eq (jiffies, tape->avg_time +HZ )) { + tape->avg_speed = tape->avg_size *HZ / + (jiffies - tape->avg_time) /1024 ; + tape->avg_size =0 ; + tape->avg_time = jiffies; + } + + tape->first_frame += blocks; + rq->current_nr_sectors -= blocks; + +if (pc->error) + uptodate = pc->error; + }else if (pc->c[0 ] ==READ_POSITION && uptodate) { +u8 *readpos = tape->pc->buf; + +debug_log (DBG_SENSE ,"BOP - %s\n" , + (readpos[0 ] &0x80 ) ?"Yes" :"No" ); +debug_log (DBG_SENSE ,"EOP - %s\n" , + (readpos[0 ] &0x40 ) ?"Yes" :"No" ); + +if (readpos[0 ] &0x4 ) { +printk (KERN_INFO "ide-tape: Block location is unknown" +"to the tape\n" ); +clear_bit (IDETAPE_FLAG_ADDRESS_VALID , &tape->flags); + uptodate =0 ; + }else { +debug_log (DBG_SENSE ,"Block Location - %u\n" , +be32_to_cpu (*(u32 *)&readpos[4 ])); + + tape->partition = readpos[1 ]; + tape->first_frame =be32_to_cpu (*(u32 *)&readpos[4 ]); +set_bit (IDETAPE_FLAG_ADDRESS_VALID , &tape->flags); + } } + +idetape_end_request (drive, uptodate,0 ); +return ide_stopped; } +static void idetape_init_pc (struct ide_atapi_pc *pc) +{ +memset (pc->c,0 ,12 ); + pc->retries =0 ; + pc->flags =0 ; + pc->req_xfer =0 ; + pc->buf = pc->pc_buf; + pc->buf_size =IDETAPE_PC_BUFFER_SIZE ; + pc->bh =NULL ; + pc->b_data =NULL ; + pc->idetape_callback = ide_tape_callback; +} +static void idetape_create_request_sense_cmd (struct ide_atapi_pc *pc) {idetape_init_pc (pc); pc->c[0 ] =REQUEST_SENSE ; pc->c[4 ] =20 ; pc->req_xfer =20 ; - pc->idetape_callback = &idetape_request_sense_callback; }static void idetape_init_rq (struct request *rq,u8 cmd)
@@ -1025,16 +1068,6 @@ static ide_startstop_t idetape_issue_pc( } } -static ide_startstop_t idetape_pc_callback (ide_drive_t *drive) -{ -idetape_tape_t *tape = drive->driver_data; - -debug_log (DBG_PROCS ,"Enter %s\n" , __func__); - -idetape_end_request (drive, tape->pc->error ?0 :1 ,0 ); -return ide_stopped; -} -/* A mode sense command is used to "sense" tape parameters. */ static void idetape_create_mode_sense_cmd (struct ide_atapi_pc *pc,u8 page_code) {
@@ -1060,7 +1093,6 @@ static void idetape_create_mode_sense_cm pc->req_xfer =24 ; else pc->req_xfer = 50; - pc->idetape_callback = &idetape_pc_callback; }static ide_startstop_t idetape_media_access_finished (ide_drive_t *drive)
@@ -1091,32 +1123,6 @@ static ide_startstop_t idetape_media_accreturn pc->idetape_callback (drive); } -static ide_startstop_t idetape_rw_callback (ide_drive_t *drive) -{ -idetape_tape_t *tape = drive->driver_data; -struct request *rq =HWGROUP (drive)->rq; -int blocks = tape->pc->xferred / tape->blk_size; - - tape->avg_size += blocks * tape->blk_size; - -if (time_after_eq (jiffies, tape->avg_time +HZ )) { - tape->avg_speed = tape->avg_size *HZ / - (jiffies - tape->avg_time) /1024 ; - tape->avg_size =0 ; - tape->avg_time = jiffies; - } -debug_log (DBG_PROCS ,"Enter %s\n" , __func__); - - tape->first_frame += blocks; - rq->current_nr_sectors -= blocks; - -if (!tape->pc->error) -idetape_end_request (drive,1 ,0 ); -else -idetape_end_request (drive, tape->pc->error,0 ); -return ide_stopped; -} -static void idetape_create_read_cmd (idetape_tape_t *tape,struct ide_atapi_pc *pc,unsigned int length,struct idetape_bh *bh)
@@ -1125,7 +1131,6 @@ static void idetape_create_read_cmd(idet pc->c[0 ] =READ_6 ;put_unaligned (cpu_to_be32 (length), (unsigned int *) &pc->c[1 ]); pc->c[1 ] =1 ; - pc->idetape_callback = &idetape_rw_callback; pc->bh = bh;atomic_set (&bh->b_count,0 ); pc->buf =NULL ;
@@ -1143,7 +1148,6 @@ static void idetape_create_write_cmd(ide pc->c[0 ] =WRITE_6 ;put_unaligned (cpu_to_be32 (length), (unsigned int *) &pc->c[1 ]); pc->c[1 ] =1 ; - pc->idetape_callback = &idetape_rw_callback; pc->flags |=PC_FLAG_WRITING ; pc->bh = bh; pc->b_data = bh->b_data;
@@ -1412,40 +1416,6 @@ static void idetape_init_merge_buffer(id } } -static ide_startstop_t idetape_read_position_callback (ide_drive_t *drive) -{ -idetape_tape_t *tape = drive->driver_data; -u8 *readpos = tape->pc->buf; - -debug_log (DBG_PROCS ,"Enter %s\n" , __func__); - -if (!tape->pc->error) { -debug_log (DBG_SENSE ,"BOP - %s\n" , - (readpos[0 ] &0x80 ) ?"Yes" :"No" ); -debug_log (DBG_SENSE ,"EOP - %s\n" , - (readpos[0 ] &0x40 ) ?"Yes" :"No" ); - -if (readpos[0 ] &0x4 ) { -printk (KERN_INFO "ide-tape: Block location is unknown" -"to the tape\n" ); -clear_bit (IDETAPE_FLAG_ADDRESS_VALID , &tape->flags); -idetape_end_request (drive,0 ,0 ); - }else { -debug_log (DBG_SENSE ,"Block Location - %u\n" , -be32_to_cpu (*(u32 *)&readpos[4 ])); - - tape->partition = readpos[1 ]; - tape->first_frame = -be32_to_cpu (*(u32 *)&readpos[4 ]); -set_bit (IDETAPE_FLAG_ADDRESS_VALID , &tape->flags); -idetape_end_request (drive,1 ,0 ); - } - }else { -idetape_end_request (drive,0 ,0 ); - } -return ide_stopped; -} -/* * Write a filemark if write_filemark=1. Flush the device buffers without * writing a filemark otherwise.
@@ -1457,14 +1427,12 @@ static void idetape_create_write_filemar pc->c[0 ] =WRITE_FILEMARKS ; pc->c[4 ] = write_filemark; pc->flags |=PC_FLAG_WAIT_FOR_DSC ; - pc->idetape_callback = &idetape_pc_callback; }static void idetape_create_test_unit_ready_cmd (struct ide_atapi_pc *pc) {idetape_init_pc (pc); pc->c[0 ] =TEST_UNIT_READY ; - pc->idetape_callback = &idetape_pc_callback; }/*
@@ -1502,7 +1470,6 @@ static void idetape_create_load_unload_c pc->c[0 ] =START_STOP ; pc->c[4 ] = cmd; pc->flags |=PC_FLAG_WAIT_FOR_DSC ; - pc->idetape_callback = &idetape_pc_callback; }static int idetape_wait_ready (ide_drive_t *drive,unsigned long timeout)
@@ -1554,7 +1521,6 @@ static void idetape_create_read_positionidetape_init_pc (pc); pc->c[0 ] =READ_POSITION ; pc->req_xfer =20 ; - pc->idetape_callback = &idetape_read_position_callback; }static int idetape_read_position (ide_drive_t *drive)
@@ -1582,7 +1548,6 @@ static void idetape_create_locate_cmd(idput_unaligned (cpu_to_be32 (block), (unsigned int *) &pc->c[3 ]); pc->c[8 ] = partition; pc->flags |=PC_FLAG_WAIT_FOR_DSC ; - pc->idetape_callback = &idetape_pc_callback; } static int idetape_create_prevent_cmd(ide_drive_t *drive,
@@ -1597,7 +1562,6 @@ static int idetape_create_prevent_cmd(ididetape_init_pc (pc); pc->c[0 ] =ALLOW_MEDIUM_REMOVAL ; pc->c[4 ] = prevent; - pc->idetape_callback = &idetape_pc_callback;return 1 ; }
@@ -1704,7 +1668,6 @@ static void idetape_create_inquiry_cmd(s pc->c[0 ] =INQUIRY ; pc->c[4 ] =254 ; pc->req_xfer =254 ; - pc->idetape_callback = &idetape_pc_callback; } static void idetape_create_rewind_cmd(ide_drive_t *drive,
@@ -1713,7 +1676,6 @@ static void idetape_create_rewind_cmd(ididetape_init_pc (pc); pc->c[0 ] =REZERO_UNIT ; pc->flags |=PC_FLAG_WAIT_FOR_DSC ; - pc->idetape_callback = &idetape_pc_callback; }static void idetape_create_erase_cmd (struct ide_atapi_pc *pc)
@@ -1722,7 +1684,6 @@ static void idetape_create_erase_cmd(str pc->c[0 ] =ERASE ; pc->c[1 ] =1 ; pc->flags |=PC_FLAG_WAIT_FOR_DSC ; - pc->idetape_callback = &idetape_pc_callback; }static void idetape_create_space_cmd (struct ide_atapi_pc *pc,int count,u8 cmd)
@@ -1732,7 +1693,6 @@ static void idetape_create_space_cmd(strput_unaligned (cpu_to_be32 (count), (unsigned int *) &pc->c[1 ]); pc->c[1 ] = cmd; pc->flags |=PC_FLAG_WAIT_FOR_DSC ; - pc->idetape_callback = &idetape_pc_callback; }/* Queue up a character device originated write request. */
PATCH 18/40 ide-tape: make pc->idetape_callback void
In reply to Bartlomiej ZolnierkiewiczThere should be no functional changes caused by this patch.
--- drivers/ide/ide-tape.c | 13 +++++++------ include/linux/ide.h | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-)
drivers/ide/ide-tape.c +7 -6
@@ -619,7 +619,7 @@ static int idetape_end_request(ide_drivereturn 0 ; } -static ide_startstop_t ide_tape_callback (ide_drive_t *drive) +static void ide_tape_callback (ide_drive_t *drive) {idetape_tape_t *tape = drive->driver_data;struct ide_atapi_pc *pc = tape->pc;
@@ -675,8 +675,6 @@ static ide_startstop_t ide_tape_callback }idetape_end_request (drive, uptodate,0 ); - -return ide_stopped; }static void idetape_init_pc (struct ide_atapi_pc *pc)
@@ -843,7 +841,8 @@ static ide_startstop_t idetape_pc_intr(iif (tape->failed_pc == pc) tape->failed_pc =NULL ;/* Command finished - Call the callback function */ -return pc->idetape_callback (drive); + pc->idetape_callback (drive); +return ide_stopped; }if (pc->flags &PC_FLAG_DMA_IN_PROGRESS ) {
@@ -1035,7 +1034,8 @@ static ide_startstop_t idetape_issue_pc( pc->error =IDETAPE_ERROR_GENERAL ; } tape->failed_pc =NULL ; -return pc->idetape_callback (drive); + pc->idetape_callback (drive); +return ide_stopped; }debug_log (DBG_SENSE ,"Retry #%d, cmd = %02X\n" , pc->retries, pc->c[0 ]);
@@ -1120,7 +1120,8 @@ static ide_startstop_t idetape_media_acc pc->error =IDETAPE_ERROR_GENERAL ; tape->failed_pc =NULL ; } -return pc->idetape_callback (drive); + pc->idetape_callback (drive); +return ide_stopped; } static void idetape_create_read_cmd(idetape_tape_t *tape,
include/linux/ide.h +1 -1
@@ -626,7 +626,7 @@ struct ide_atapi_pc {*/ u8 pc_buf[256 ];void (*idefloppy_callback) (ide_drive_t *); -ide_startstop_t (*idetape_callback) (ide_drive_t *); +void (*idetape_callback) (ide_drive_t *);/* idetape only */ struct idetape_bh *bh;
PATCH 19/40 ide-floppy: merge callbacks
In reply to Bartlomiej ZolnierkiewiczFrom: Borislav Petkov <[email protected]>
Subject: [PATCH] ide-floppy: merge callbacks
The appropriate functionality of the callback is established through querying the ATAPI packet command in pc->c[0].
While at it, simplify if (floppy->failed_pc)-branch to be found in the original idefloppy_request_sense_callback().
Bart:
- keep handling for blk_pc_request() requests unchanged + add FIXME
- add uptodate variable + leave just one idefloppy_end_request() call
- add newline to the debug message
--- drivers/ide/ide-floppy.c | 71 +++++++++++++++-------------------------------- 1 file changed, 24 insertions(+), 47 deletions(-)
drivers/ide/ide-floppy.c +24 -47
@@ -312,50 +312,38 @@ static struct request *idefloppy_next_rqreturn (&floppy->rq_stack[floppy->rq_stack_index++]); } -static void idefloppy_request_sense_callback (ide_drive_t *drive) +static void ide_floppy_callback (ide_drive_t *drive) {idefloppy_floppy_t *floppy = drive->driver_data; -u8 *buf = floppy->pc->buf; +struct ide_atapi_pc *pc = floppy->pc; +int uptodate = pc->error ?0 :1 ;debug_log ("Reached %s\n" , __func__); -if (!floppy->pc->error) { - floppy->sense_key = buf[2 ] &0x0F ; - floppy->asc = buf[12 ]; - floppy->ascq = buf[13 ]; - floppy->progress_indication = buf[15 ] &0x80 ? - (u16 )get_unaligned ((u16 *)&buf[16 ]) :0x10000 ; - -if (floppy->failed_pc) -debug_log ("pc = %x, sense key = %x, asc = %x," -" ascq = %x\n" , - floppy->failed_pc->c[0 ], - floppy->sense_key, - floppy->asc, - floppy->ascq); -else -debug_log ("sense key = %x, asc = %x, ascq = %x\n" , - floppy->sense_key, - floppy->asc, - floppy->ascq); +if (pc->c[0 ] ==GPCMD_READ_10 || pc->c[0 ] ==GPCMD_WRITE_10 || + (pc->rq &&blk_pc_request (pc->rq))) + uptodate =1 ;/* FIXME */ +else if (pc->c[0 ] ==GPCMD_REQUEST_SENSE ) { +u8 *buf = floppy->pc->buf; + +if (!pc->error) { + floppy->sense_key = buf[2 ] &0x0F ; + floppy->asc = buf[12 ]; + floppy->ascq = buf[13 ]; + floppy->progress_indication = buf[15 ] &0x80 ? + (u16 )get_unaligned ((u16 *)&buf[16 ]) :0x10000 ; +if (floppy->failed_pc) +debug_log ("pc = %x, " , floppy->failed_pc->c[0 ]); -idefloppy_end_request (drive,1 ,0 ); - }else { -printk (KERN_ERR "Error in REQUEST SENSE itself - Aborting" -" request!\n" ); -idefloppy_end_request (drive,0 ,0 ); +debug_log ("sense key = %x, asc = %x, ascq = %x\n" , + floppy->sense_key, floppy->asc, floppy->ascq); + }else +printk (KERN_ERR "Error in REQUEST SENSE itself - " +"Aborting request!\n" ); } -} -/* General packet command callback function. */ -static void idefloppy_pc_callback (ide_drive_t *drive) -{ -idefloppy_floppy_t *floppy = drive->driver_data; - -debug_log ("Reached %s\n" , __func__); - -idefloppy_end_request (drive, floppy->pc->error ?0 :1 ,0 ); +idefloppy_end_request (drive, uptodate,0 ); }static void idefloppy_init_pc (struct ide_atapi_pc *pc)
@@ -366,7 +354,7 @@ static void idefloppy_init_pc(struct ide pc->req_xfer =0 ; pc->buf = pc->pc_buf; pc->buf_size =IDEFLOPPY_PC_BUFFER_SIZE ; - pc->idefloppy_callback = &idefloppy_pc_callback; + pc->idefloppy_callback = &ide_floppy_callback; }static void idefloppy_create_request_sense_cmd (struct ide_atapi_pc *pc)
@@ -375,7 +363,6 @@ static void idefloppy_create_request_sen pc->c[0 ] =GPCMD_REQUEST_SENSE ; pc->c[4 ] =255 ; pc->req_xfer =18 ; - pc->idefloppy_callback = &idefloppy_request_sense_callback; }/*
@@ -668,14 +655,6 @@ static ide_startstop_t idefloppy_issue_p } } -static void idefloppy_rw_callback (ide_drive_t *drive) -{ -debug_log ("Reached %s\n" , __func__); - -idefloppy_end_request (drive,1 ,0 ); -return ; -} -static void idefloppy_create_prevent_cmd (struct ide_atapi_pc *pc,int prevent) {debug_log ("creating prevent removal command, prevent = %d\n" , prevent);
@@ -770,7 +749,6 @@ static void idefloppy_create_rw_cmd(idefput_unaligned (cpu_to_be16 (blocks), (unsigned short *)&pc->c[7 ]);put_unaligned (cpu_to_be32 (block), (unsigned int *) &pc->c[2 ]); - pc->idefloppy_callback = &idefloppy_rw_callback; pc->rq = rq; pc->b_count = cmd ==READ ?0 : rq->bio->bi_size;if (rq->cmd_flags &REQ_RW )
@@ -784,7 +762,6 @@ static void idefloppy_blockpc_cmd(ideflo struct ide_atapi_pc *pc, struct request *rq) {idefloppy_init_pc (pc ); - pc->idefloppy_callback = &idefloppy_rw_callback;memcpy (pc->c, rq->cmd,sizeof (pc->c)); pc->rq = rq; pc->b_count = rq->data_len;
PATCH 20/40 ide-{floppy,tape}: merge pc->idefloppy_callback and pc->idetape_callback
In reply to Bartlomiej ZolnierkiewiczMerge pc->idefloppy_callback and pc->idetape_callback into pc->callback.
There should be no functional changes caused by this patch.
--- drivers/ide/ide-floppy.c | 6 +++--- drivers/ide/ide-tape.c | 8 ++++---- include/linux/ide.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)
drivers/ide/ide-floppy.c +3 -3
@@ -354,7 +354,7 @@ static void idefloppy_init_pc(struct ide pc->req_xfer =0 ; pc->buf = pc->pc_buf; pc->buf_size =IDEFLOPPY_PC_BUFFER_SIZE ; - pc->idefloppy_callback = &ide_floppy_callback; + pc->callback = ide_floppy_callback; }static void idefloppy_create_request_sense_cmd (struct ide_atapi_pc *pc)
@@ -438,7 +438,7 @@ static ide_startstop_t idefloppy_pc_intrif (floppy->failed_pc == pc) floppy->failed_pc =NULL ;/* Command finished - Call the callback function */ - pc->idefloppy_callback (drive); + pc->callback (drive);return ide_stopped; }
@@ -612,7 +612,7 @@ static ide_startstop_t idefloppy_issue_p pc->error =IDEFLOPPY_ERROR_GENERAL ; floppy->failed_pc =NULL ; - pc->idefloppy_callback (drive); + pc->callback (drive);return ide_stopped; }
drivers/ide/ide-tape.c +4 -4
@@ -687,7 +687,7 @@ static void idetape_init_pc(struct ide_a pc->buf_size =IDETAPE_PC_BUFFER_SIZE ; pc->bh =NULL ; pc->b_data =NULL ; - pc->idetape_callback = ide_tape_callback; + pc->callback = ide_tape_callback; }static void idetape_create_request_sense_cmd (struct ide_atapi_pc *pc)
@@ -841,7 +841,7 @@ static ide_startstop_t idetape_pc_intr(iif (tape->failed_pc == pc) tape->failed_pc =NULL ;/* Command finished - Call the callback function */ - pc->idetape_callback (drive); + pc->callback (drive);return ide_stopped; }
@@ -1034,7 +1034,7 @@ static ide_startstop_t idetape_issue_pc( pc->error =IDETAPE_ERROR_GENERAL ; } tape->failed_pc =NULL ; - pc->idetape_callback (drive); + pc->callback (drive);return ide_stopped; }debug_log (DBG_SENSE ,"Retry #%d, cmd = %02X\n" , pc->retries, pc->c[0 ]);
@@ -1120,7 +1120,7 @@ static ide_startstop_t idetape_media_acc pc->error =IDETAPE_ERROR_GENERAL ; tape->failed_pc =NULL ; } - pc->idetape_callback (drive); + pc->callback (drive);return ide_stopped; }
include/linux/ide.h +2 -2
@@ -625,8 +625,8 @@ struct ide_atapi_pc {* to change/removal later. */ u8 pc_buf[256 ]; -void (*idefloppy_callback) (ide_drive_t *); -void (*idetape_callback) (ide_drive_t *); + +void (*callback)(ide_drive_t *);/* idetape only */ struct idetape_bh *bh;
PATCH 21/40 ide-{floppy,tape}: PC_FLAG_DMA_RECOMMENDED -> PC_FLAG_DMA_OK
In reply to Bartlomiej Zolnierkiewicz* Use PC_FLAG_DMA_OK flag instead of PC_FLAG_DMA_RECOMMENDED one.
* Remove no longer used PC_FLAG_DMA_RECOMMENDED flag.
There should be no functional changes caused by this patch.
--- drivers/ide/ide-floppy.c | 6 +++--- drivers/ide/ide-tape.c | 6 +++--- include/linux/ide.h | 9 ++++----- 3 files changed, 10 insertions(+), 11 deletions(-)
drivers/ide/ide-floppy.c +3 -3
@@ -630,7 +630,7 @@ static ide_startstop_t idefloppy_issue_p } dma =0 ; -if ((pc->flags &PC_FLAG_DMA_RECOMMENDED ) && drive->using_dma) +if ((pc->flags &PC_FLAG_DMA_OK ) && drive->using_dma) dma = !hwif->dma_ops->dma_setup (drive);ide_pktcmd_tf_load (drive,IDE_TFLAG_OUT_DEVICE , bcount, dma);
@@ -755,7 +755,7 @@ static void idefloppy_create_rw_cmd(idef pc->flags |=PC_FLAG_WRITING ; pc->buf =NULL ; pc->req_xfer = pc->buf_size = blocks * floppy->block_size; - pc->flags |=PC_FLAG_DMA_RECOMMENDED ; + pc->flags |=PC_FLAG_DMA_OK ; } static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy,
@@ -769,7 +769,7 @@ static void idefloppy_blockpc_cmd(ideflo pc->flags |=PC_FLAG_WRITING ; pc->buf = rq->data;if (rq->bio) - pc->flags |=PC_FLAG_DMA_RECOMMENDED ; + pc->flags |=PC_FLAG_DMA_OK ;/* * possibly problematic, doesn't look like ide-floppy correctly * handled scattered requests if dma fails...
drivers/ide/ide-tape.c +3 -3
@@ -1050,7 +1050,7 @@ static ide_startstop_t idetape_issue_pc( pc->flags &= ~PC_FLAG_DMA_ERROR ;ide_dma_off (drive); } -if ((pc->flags &PC_FLAG_DMA_RECOMMENDED ) && drive->using_dma) +if ((pc->flags &PC_FLAG_DMA_OK ) && drive->using_dma) dma_ok = !hwif->dma_ops->dma_setup (drive);ide_pktcmd_tf_load (drive,IDE_TFLAG_OUT_DEVICE , bcount, dma_ok);
@@ -1138,7 +1138,7 @@ static void idetape_create_read_cmd(idet pc->buf_size = length * tape->blk_size; pc->req_xfer = pc->buf_size;if (pc->req_xfer == tape->buffer_size) - pc->flags |=PC_FLAG_DMA_RECOMMENDED ; + pc->flags |=PC_FLAG_DMA_OK ; } static void idetape_create_write_cmd(idetape_tape_t *tape,
@@ -1157,7 +1157,7 @@ static void idetape_create_write_cmd(ide pc->buf_size = length * tape->blk_size; pc->req_xfer = pc->buf_size;if (pc->req_xfer == tape->buffer_size) - pc->flags |=PC_FLAG_DMA_RECOMMENDED ; + pc->flags |=PC_FLAG_DMA_OK ; } static ide_startstop_t idetape_do_request(ide_drive_t *drive,
include/linux/ide.h +4 -5
@@ -587,12 +587,11 @@ enum {PC_FLAG_SUPPRESS_ERROR = (1 <<1 ),PC_FLAG_WAIT_FOR_DSC = (1 <<2 ),PC_FLAG_DMA_OK = (1 <<3 ), -PC_FLAG_DMA_RECOMMENDED = (1 <<4 ), -PC_FLAG_DMA_IN_PROGRESS = (1 <<5 ), -PC_FLAG_DMA_ERROR = (1 <<6 ), -PC_FLAG_WRITING = (1 <<7 ), +PC_FLAG_DMA_IN_PROGRESS = (1 <<4 ), +PC_FLAG_DMA_ERROR = (1 <<5 ), +PC_FLAG_WRITING = (1 <<6 ),/* command timed out */ - PC_FLAG_TIMEDOUT = (1 << 8), + PC_FLAG_TIMEDOUT = (1 << 7), }; struct ide_atapi_pc {
PATCH 22/40 ide-floppy: start DMA engine in idefloppy_transfer_pc1()
In reply to Bartlomiej ZolnierkiewiczStart DMA engine and set PC_FLAG_DMA_IN_PROGRESS flag in idefloppy_transfer_pc1() instead of idefloppy_issue_pc() so the Status Register and the Interrupt Reason Register are checked first.
--- drivers/ide/ide-floppy.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/ide/ide-floppy.c +10 -6
@@ -534,6 +534,7 @@ static ide_startstop_t idefloppy_transfe {ide_hwif_t *hwif = drive->hwif;idefloppy_floppy_t *floppy = drive->driver_data; +struct ide_atapi_pc *pc = floppy->pc;ide_expiry_t *expiry;unsigned int timeout;ide_startstop_t startstop;
@@ -568,6 +569,12 @@ static ide_startstop_t idefloppy_transfeide_set_handler (drive, &idefloppy_pc_intr, timeout, expiry); +/* Begin DMA, if necessary */ +if (pc->flags &PC_FLAG_DMA_OK ) { + pc->flags |=PC_FLAG_DMA_IN_PROGRESS ; + hwif->dma_ops->dma_start (drive); + } +if ((floppy->flags &IDEFLOPPY_FLAG_ZIP_DRIVE ) ==0 )/* Send the actual packet */ hwif->output_data (drive,NULL , floppy->pc->c,12 );
@@ -633,13 +640,10 @@ static ide_startstop_t idefloppy_issue_pif ((pc->flags &PC_FLAG_DMA_OK ) && drive->using_dma) dma = !hwif->dma_ops->dma_setup (drive); -ide_pktcmd_tf_load (drive,IDE_TFLAG_OUT_DEVICE , bcount, dma); +if (!dma) + pc->flags &= ~PC_FLAG_DMA_OK ; -if (dma) { -/* Begin DMA, if necessary */ - pc->flags |=PC_FLAG_DMA_IN_PROGRESS ; - hwif->dma_ops->dma_start (drive); - } +ide_pktcmd_tf_load (drive,IDE_TFLAG_OUT_DEVICE , bcount, dma);if (floppy->flags &IDEFLOPPY_FLAG_DRQ_INTERRUPT ) {/* Issue the packet command */
Re: [PATCH 22/40] ide-floppy: start DMA engine in idefloppy_transfer_pc1()
Hello.
Quoted 2 lines · Bartlomiej Zolnierkiewicz
Start DMA engine and set
PC_FLAG_DMA_IN_PROGRESSflag inidefloppy_transfer_pc1()instead ofidefloppy_issue_pc()
Good. I have long ago noticed that DMA is started too early in ide-floppy
which is known to cobfuse some chips (like PDC20246) and was going to do a patch at first but the lack of hardware (and time) stopped me...
Quoted 10 lines
so the Status Register and the Interrupt Reason Register are checked first.
Cc Borislav Petkov <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>Index:
b/drivers/ide/ide-floppy.c
===================================================================drivers/ide/ide-floppy.c +0
-0
[...]
drivers/ide/ide-floppy.c static ide_startstop_t idefloppy_transfe · line 577
Quoted 10 lines
drivers/ide/ide-floppy.c +6
-0@@ -568,6 +569,12 @@ static ide_startstop_t idefloppy_transfeide_set_handler (drive, &idefloppy_pc_intr, timeout, expiry); +/* Begin DMA, if necessary */ +if (pc->flags &PC_FLAG_DMA_OK ) { + pc->flags |=PC_FLAG_DMA_IN_PROGRESS ; + hwif->dma_ops->dma_start (drive); + } +
May be too early still... ide-cd does this after writing the command packet.
WBR, Sergei
Re: [PATCH 22/40] ide-floppy: start DMA engine in idefloppy_transfer_pc1()
Quoted 26 lines · Sergei Shtylyov
Hello.
Quoted 2 lines · Bartlomiej Zolnierkiewicz
Start DMA engine and set
PC_FLAG_DMA_IN_PROGRESSflag inidefloppy_transfer_pc1()instead ofidefloppy_issue_pc()Good. I have long ago noticed that DMA is started too early in ide-floppy
which is known to cobfuse some chips (like PDC20246) and was going to do a patch at first but the lack of hardware (and time) stopped me...Quoted 10 lines
so the Status Register and the Interrupt Reason Register are checked first.
Cc Borislav Petkov <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>Index:
b/drivers/ide/ide-floppy.c
===================================================================drivers/ide/ide-floppy.c +0
-0[...]
Quoted 4 lines
drivers/ide/ide-floppy.c +0
-0@@ -568,6 +569,12 @@ static ide_startstop_t idefloppy_transfeide_set_handler (drive, &idefloppy_pc_intr, timeout, expiry);
Quoted 8 lines
drivers/ide/ide-floppy.c static ide_startstop_t idefloppy_transfe · line 577
Quoted 6 lines
drivers/ide/ide-floppy.c +6
-0+/* Begin DMA, if necessary */ +if (pc->flags &PC_FLAG_DMA_OK ) { + pc->flags |=PC_FLAG_DMA_IN_PROGRESS ; + hwif->dma_ops->dma_start (drive); + } +May be too early still... ide-cd does this after writing the command packet.
I would rather say that ide-cd is doing things too late.
Now that's your patch opportunity! No excuses this time... ;)
Thanks,
Bart
PATCH 23/40 ide-tape: set PC_FLAG_DMA_IN_PROGRESS flag in idetape_transfer_pc()
In reply to Bartlomiej ZolnierkiewiczSet PC_FLAG_DMA_IN_PROGRESS flag in idetape_transfer_pc() instead of idetape_issue_pc() to match the other ATAPI device drivers.
--- drivers/ide/ide-tape.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/ide/ide-tape.c +6 -4
@@ -984,8 +984,10 @@ static ide_startstop_t idetape_transfer_ide_set_handler (drive, &idetape_pc_intr,IDETAPE_WAIT_CMD ,NULL );/* Begin DMA, if necessary */ -if (pc->flags &PC_FLAG_DMA_IN_PROGRESS ) +if (pc->flags &PC_FLAG_DMA_OK ) { + pc->flags |=PC_FLAG_DMA_IN_PROGRESS ; hwif->dma_ops->dma_start (drive); + }/* Send the actual packet */ hwif->output_data (drive,NULL , pc->c,12 );
@@ -1053,11 +1055,11 @@ static ide_startstop_t idetape_issue_pc(if ((pc->flags &PC_FLAG_DMA_OK ) && drive->using_dma) dma_ok = !hwif->dma_ops->dma_setup (drive); +if (!dma_ok) + pc->flags &= ~PC_FLAG_DMA_OK ; +ide_pktcmd_tf_load (drive,IDE_TFLAG_OUT_DEVICE , bcount, dma_ok); -if (dma_ok) -/* Will begin DMA later */ - pc->flags |=PC_FLAG_DMA_IN_PROGRESS ;if (test_bit (IDETAPE_FLAG_DRQ_INTERRUPT , &tape->flags)) {ide_execute_command (drive,WIN_PACKETCMD , &idetape_transfer_pc,IDETAPE_WAIT_CMD ,NULL );
PATCH 24/40 ide-tape: factor out waiting for good ireason from idetape_transfer_pc()
In reply to Bartlomiej ZolnierkiewiczFactor out waiting for good ireason from idetape_transfer_pc() to ide_tape_wait_ireason() as a preparation for adding generic ide_transfer_pc() helper.
There should be no functional changes caused by this patch.
--- drivers/ide/ide-tape.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-)
drivers/ide/ide-tape.c +23 -11
@@ -947,21 +947,12 @@ static ide_startstop_t idetape_pc_intr(i* again, the callback function will be called and then we will handle the next * request. */ -static ide_startstop_t idetape_transfer_pc (ide_drive_t *drive) + +static u8 ide_tape_wait_ireason (ide_drive_t *drive,u8 ireason) {ide_hwif_t *hwif = drive->hwif; -idetape_tape_t *tape = drive->driver_data; -struct ide_atapi_pc *pc = tape->pc;int retries =100 ; -ide_startstop_t startstop; -u8 ireason; -if (ide_wait_stat (&startstop, drive,DRQ_STAT ,BUSY_STAT ,WAIT_READY )) { -printk (KERN_ERR "%s: Strange, packet command initiated yet " -"DRQ isn't asserted\n" , drive->name); -return startstop; - } - ireason = hwif->INB (hwif->io_ports.nsect_addr);while (retries-- && ((ireason &CD ) ==0 || (ireason &IO ))) {printk (KERN_ERR "%s: (IO,CoD != (0,1) while issuing " "a packet command, retrying\n" , drive->name);
@@ -975,6 +966,27 @@ static ide_startstop_t idetape_transfer_ ireason &= ~IO ; } } + +return ireason; +} + +static ide_startstop_t idetape_transfer_pc (ide_drive_t *drive) +{ +ide_hwif_t *hwif = drive->hwif; +idetape_tape_t *tape = drive->driver_data; +struct ide_atapi_pc *pc = tape->pc; +ide_startstop_t startstop; +u8 ireason; + +if (ide_wait_stat (&startstop, drive,DRQ_STAT ,BUSY_STAT ,WAIT_READY )) { +printk (KERN_ERR "%s: Strange, packet command initiated yet " +"DRQ isn't asserted\n" , drive->name); +return startstop; + } + + ireason = hwif->INB (hwif->io_ports.nsect_addr); + ireason =ide_tape_wait_ireason (drive, ireason); +if ((ireason &CD ) ==0 || (ireason &IO )) {printk (KERN_ERR "%s: (IO,CoD) != (0,1) while issuing " "a packet command\n" , drive->name);
PATCH 25/40 ide: add PC_FLAG_ZIP_DRIVE pc flag
In reply to Bartlomiej ZolnierkiewiczAdd PC_FLAG_ZIP_DRIVE pc flag, set it in idefloppy_do_request() and check for it (instead of checking for IDEFLOPPY_FLAG_ZIP_DRIVE) in idefloppy_transfer_pc(). This is a preparation for adding generic ide_transfer_pc() helper.
There should be no functional changes caused by this patch.
--- drivers/ide/ide-floppy.c | 8 ++++++-- include/linux/ide.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/ide/ide-floppy.c +6 -2
@@ -559,7 +559,7 @@ static ide_startstop_t idefloppy_transfe* 40 and 50msec work well. idefloppy_pc_intr will not be actually * used until after the packet is moved in about 50 msec. */ -if (floppy->flags &IDEFLOPPY_FLAG_ZIP_DRIVE ) { +if (pc->flags &PC_FLAG_ZIP_DRIVE ) { timeout = floppy->ticks; expiry = &idefloppy_transfer_pc2; }else {
@@ -575,7 +575,7 @@ static ide_startstop_t idefloppy_transfe hwif->dma_ops->dma_start (drive); } -if ((floppy->flags &IDEFLOPPY_FLAG_ZIP_DRIVE ) ==0 ) +if ((pc->flags &PC_FLAG_ZIP_DRIVE ) ==0 )/* Send the actual packet */ hwif->output_data (drive,NULL , floppy->pc->c,12 );
@@ -826,7 +826,11 @@ static ide_startstop_t idefloppy_do_requreturn ide_stopped; } +if (floppy->flags &IDEFLOPPY_FLAG_ZIP_DRIVE ) + pc->flags |=PC_FLAG_ZIP_DRIVE ; + pc->rq = rq; +return idefloppy_issue_pc (drive, pc); }
include/linux/ide.h +1 -0
@@ -592,6 +592,7 @@ enum {PC_FLAG_WRITING = (1 <<6 ),/* command timed out */ PC_FLAG_TIMEDOUT = (1 <<7 ), + PC_FLAG_ZIP_DRIVE = (1 << 8), }; struct ide_atapi_pc {
PATCH 26/40 ide-{cd,floppy,tape}: remove checking for drive->scsi
In reply to Bartlomiej ZolnierkiewiczRemove checking for drive->scsi which is no longer set by IDE core code (leave the flag since it will be re-used for generic ATAPI support).
--- drivers/ide/ide-cd.c | 5 ----- drivers/ide/ide-floppy.c | 5 ----- drivers/ide/ide-tape.c | 5 ----- 3 files changed, 15 deletions(-)
drivers/ide/ide-cd.c +0 -5
@@ -2106,11 +2106,6 @@ static int ide_cd_probe(ide_drive_t *dri goto failed; } } -if (drive->scsi) { -printk (KERN_INFO "ide-cd: passing drive %s to ide-scsi " -"emulation.\n" , drive->name); - goto failed; - } info =kzalloc (sizeof (struct cdrom_info ),GFP_KERNEL );if (info ==NULL ) { printk(KERN_ERR "%s: Can't allocate a cdrom structure\n",
drivers/ide/ide-floppy.c +0 -5
@@ -1579,11 +1579,6 @@ static int ide_floppy_probe(ide_drive_t " of ide-floppy\n", drive->name); goto failed; } -if (drive->scsi) { -printk (KERN_INFO "ide-floppy: passing drive %s to ide-scsi" -" emulation.\n" , drive->name); - goto failed; - } floppy =kzalloc (sizeof (idefloppy_floppy_t),GFP_KERNEL );if (!floppy) { printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy"
drivers/ide/ide-tape.c +0 -5
@@ -2850,11 +2850,6 @@ static int ide_tape_probe(ide_drive_t *d " the driver\n", drive->name); goto failed; } -if (drive->scsi) { -printk (KERN_INFO "ide-tape: passing drive %s to ide-scsi" -" emulation.\n" , drive->name); - goto failed; - } tape =kzalloc (sizeof (idetape_tape_t),GFP_KERNEL );if (tape ==NULL ) { printk(KERN_ERR "ide-tape: %s: Can't allocate a tape struct\n",
PATCH 27/40 ide-scsi: set drive->scsi flag for devices handled by the driver
In reply to Bartlomiej ZolnierkiewiczThis is a preparation for adding generic ide_transfer_pc() helper.
There should be no functional changes caused by this patch.
--- drivers/scsi/ide-scsi.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/scsi/ide-scsi.c +5 -0
@@ -629,6 +629,8 @@ static void ide_scsi_remove(ide_drive_tput_disk (g);ide_scsi_put (scsi); + + drive->scsi =0 ; }static int ide_scsi_probe (ide_drive_t *);
@@ -969,6 +971,8 @@ static int ide_scsi_probe(ide_drive_t *d !(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t))))return -ENODEV ; + drive->scsi =1 ; + g =alloc_disk (1 <<PARTN_BITS );if (!g) goto out_host_put;
@@ -1009,6 +1013,7 @@ static int ide_scsi_probe(ide_drive_t *dput_disk (g); out_host_put: + drive->scsi =0 ;scsi_host_put (host);return err; }
PATCH 28/40 ide: add ide_transfer_pc() helper
In reply to Bartlomiej Zolnierkiewicz* Add ide-atapi.c file for generic ATAPI support together with CONFIG_IDE_ATAPI config option.
* Add generic ide_transfer_pc() helper to ide-atapi.c and then convert ide-{floppy,tape,scsi} device drivers to use it.
There should be no functional changes caused by this patch.
--- drivers/ide/Kconfig | 6 ++++ drivers/ide/Makefile | 1 drivers/ide/ide-atapi.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/ide/ide-floppy.c | 28 ------------------ drivers/ide/ide-tape.c | 56 +------------------------------------ drivers/scsi/ide-scsi.c | 30 +------------------- include/linux/ide.h | 3 ++ 7 files changed, 85 insertions(+), 109 deletions(-)
drivers/ide/Kconfig +6 -0
@@ -98,6 +98,9 @@ if BLK_DEV_IDE comment "Please see Documentation/ide/ide.txt for help/info on IDE drives" +config IDE_ATAPI + bool + config BLK_DEV_IDE_SATA bool "Support for SATA (deprecated; conflicts with libata SATA driver)" default n
@@ -201,6 +204,7 @@ config BLK_DEV_IDECD_VERBOSE_ERRORS config BLK_DEV_IDETAPE tristate "Include IDE/ATAPI TAPE support" + select IDE_ATAPI help If you have an IDE tape drive using the ATAPI protocol, say Y. ATAPI is a newer protocol used by IDE tape and CD-ROM drives,
@@ -223,6 +227,7 @@ config BLK_DEV_IDETAPE config BLK_DEV_IDEFLOPPY tristate "Include IDE/ATAPI FLOPPY support" + select IDE_ATAPI ---help--- If you have an IDE floppy drive which uses the ATAPI protocol, answer Y. ATAPI is a newer protocol used by IDE CD-ROM/tape/floppy
@@ -246,6 +251,7 @@ config BLK_DEV_IDEFLOPPY config BLK_DEV_IDESCSI tristate "SCSI emulation support" depends on SCSI + select IDE_ATAPI ---help--- WARNING: ide-scsi is no longer needed for cd writing applications! The 2.6 kernel supports direct writing to ide-cd, which eliminates
drivers/ide/Makefile +1 -0
@@ -14,6 +14,7 @@ EXTRA_CFLAGS += -Idrivers/ide ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o # core IDE code +ide-core-$(CONFIG_IDE_ATAPI) += ide-atapi.o ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o ide-core-$(CONFIG_IDE_PROC_FS) += ide-proc.o
drivers/ide/ide-atapi.c new file +70 -0
70 lines not on this page · raw message
drivers/ide/ide-floppy.c +1 -27
@@ -532,25 +532,11 @@ static int idefloppy_transfer_pc2(ide_drstatic ide_startstop_t idefloppy_transfer_pc1 (ide_drive_t *drive) { -ide_hwif_t *hwif = drive->hwif;idefloppy_floppy_t *floppy = drive->driver_data;struct ide_atapi_pc *pc = floppy->pc;ide_expiry_t *expiry;unsigned int timeout; -ide_startstop_t startstop; -u8 ireason; -if (ide_wait_stat (&startstop, drive,DRQ_STAT ,BUSY_STAT ,WAIT_READY )) { -printk (KERN_ERR "%s: Strange, packet command initiated yet " -"DRQ isn't asserted\n" , drive->name); -return startstop; - } - ireason = hwif->INB (hwif->io_ports.nsect_addr); -if ((ireason &CD ) ==0 || (ireason &IO )) { -printk (KERN_ERR "%s: (IO,CoD) != (0,1) while issuing " -"a packet command\n" , drive->name); -return ide_do_reset (drive); - }/* * The following delay solves a problem with ATAPI Zip 100 drives * where the Busy flag was apparently being deasserted before the
@@ -567,19 +553,7 @@ static ide_startstop_t idefloppy_transfe expiry =NULL ; } -ide_set_handler (drive, &idefloppy_pc_intr, timeout, expiry); - -/* Begin DMA, if necessary */ -if (pc->flags &PC_FLAG_DMA_OK ) { - pc->flags |=PC_FLAG_DMA_IN_PROGRESS ; - hwif->dma_ops->dma_start (drive); - } - -if ((pc->flags &PC_FLAG_ZIP_DRIVE ) ==0 ) -/* Send the actual packet */ - hwif->output_data (drive,NULL , floppy->pc->c,12 ); - -return ide_started; +return ide_transfer_pc (drive, pc, idefloppy_pc_intr, timeout, expiry); } static void ide_floppy_report_error(idefloppy_floppy_t *floppy,
drivers/ide/ide-tape.c +2 -54
66 lines not on this page · raw message
drivers/scsi/ide-scsi.c +2 -28
@@ -453,36 +453,10 @@ static ide_startstop_t idescsi_pc_intr (static ide_startstop_t idescsi_transfer_pc (ide_drive_t *drive) { -ide_hwif_t *hwif = drive->hwif;idescsi_scsi_t *scsi =drive_to_idescsi (drive); -struct ide_atapi_pc *pc = scsi->pc; -ide_startstop_t startstop; -u8 ireason; - -if (ide_wait_stat (&startstop,drive,DRQ_STAT ,BUSY_STAT ,WAIT_READY )) { -printk (KERN_ERR "%s: Strange, packet command initiated yet " -"DRQ isn't asserted\n" , drive->name); -return startstop; - } - ireason = hwif->INB (hwif->io_ports.nsect_addr); -if ((ireason &CD ) ==0 || (ireason &IO )) { -printk (KERN_ERR "%s: (IO,CoD) != (0,1) while issuing " -"a packet command\n" , drive->name); -return ide_do_reset (drive); - } - -/* Set the interrupt routine */ -ide_set_handler (drive, &idescsi_pc_intr,get_timeout (pc), idescsi_expiry); - -if (pc->flags &PC_FLAG_DMA_OK ) { - pc->flags |=PC_FLAG_DMA_IN_PROGRESS ; - hwif->dma_ops->dma_start (drive); - } - -/* Send the actual packet */ - hwif->output_data (drive,NULL , scsi->pc->c,12 ); -return ide_started; +return ide_transfer_pc (drive, scsi->pc, idescsi_pc_intr, +get_timeout (scsi->pc), idescsi_expiry); }static inline int idescsi_set_direction (struct ide_atapi_pc *pc)
include/linux/ide.h +3 -0
@@ -952,6 +952,9 @@ extern int drive_is_ready(ide_drive_t *)void ide_pktcmd_tf_load (ide_drive_t *,u32 ,u16 ,u8 ); +ide_startstop_t ide_transfer_pc (ide_drive_t *,struct ide_atapi_pc *, +ide_handler_t *,unsigned int ,ide_expiry_t *); +ide_startstop_t do_rw_taskfile (ide_drive_t *,ide_task_t *);void task_end_request (ide_drive_t *,struct request *,u8 );
PATCH 29/40 ide-scsi: move idescsi_map_sg() call out from idescsi_issue_pc()
In reply to Bartlomiej ZolnierkiewiczMove idescsi_map_sg() call out from idescsi_issue_pc() to idescsi_do_request() as a preparation to adding generic ide_issue_pc() helper.
There should be no functional changes caused by this patch.
--- drivers/scsi/ide-scsi.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/scsi/ide-scsi.c +10 -6
@@ -514,16 +514,16 @@ static ide_startstop_t idescsi_issue_pc(/* Request to transfer the entire buffer at once */ bcount =min (pc->req_xfer,63 *1024 ); -if (drive->using_dma && !idescsi_map_sg (drive, pc)) { +if ((pc->flags &PC_FLAG_DMA_OK ) && drive->using_dma) { hwif->sg_mapped =1 ; dma = !hwif->dma_ops->dma_setup (drive); hwif->sg_mapped =0 ; } -ide_pktcmd_tf_load (drive,0 , bcount, dma); +if (!dma) + pc->flags &= ~PC_FLAG_DMA_OK ; -if (dma) - pc->flags |=PC_FLAG_DMA_OK ; +ide_pktcmd_tf_load (drive,0 , bcount, dma);if (test_bit (IDESCSI_DRQ_INTERRUPT , &scsi->flags)) { ide_execute_command(drive, WIN_PACKETCMD, &idescsi_transfer_pc,
@@ -547,8 +547,12 @@ static ide_startstop_t idescsi_do_reques rq->sector, rq->nr_sectors, rq->current_nr_sectors);if (blk_sense_request (rq) ||blk_special_request (rq)) { -return idescsi_issue_pc (drive, - (struct ide_atapi_pc *) rq->special); +struct ide_atapi_pc *pc = (struct ide_atapi_pc *)rq->special; + +if (drive->using_dma && !idescsi_map_sg (drive, pc)) + pc->flags |=PC_FLAG_DMA_OK ; + +return idescsi_issue_pc (drive, pc); }blk_dump_rq_flags (rq,"ide-scsi: unsup command" );idescsi_end_request (drive,0 ,0 );
PATCH 30/40 ide: add PC_FLAG_DRQ_INTERRUPT pc flag
In reply to Bartlomiej ZolnierkiewiczAdd PC_FLAG_DRQ_INTERRUPT pc flag, set it in ide*_do_request() and check for it (instead of checking for IDE*_FLAG_DRQ_INTERRUPT) in ide*_issue_pc(). This is a preparation for adding generic ide_issue_pc() helper.
There should be no functional changes caused by this patch.
--- drivers/ide/ide-floppy.c | 5 ++++- drivers/ide/ide-tape.c | 11 ++++++++--- drivers/scsi/ide-scsi.c | 6 +++++- include/linux/ide.h | 1 + 4 files changed, 18 insertions(+), 5 deletions(-)
drivers/ide/ide-floppy.c +4 -1
@@ -619,7 +619,7 @@ static ide_startstop_t idefloppy_issue_pide_pktcmd_tf_load (drive,IDE_TFLAG_OUT_DEVICE , bcount, dma); -if (floppy->flags &IDEFLOPPY_FLAG_DRQ_INTERRUPT ) { +if (pc->flags &PC_FLAG_DRQ_INTERRUPT ) {/* Issue the packet command */ ide_execute_command(drive, WIN_PACKETCMD, &idefloppy_transfer_pc1,
@@ -800,6 +800,9 @@ static ide_startstop_t idefloppy_do_requreturn ide_stopped; } +if (floppy->flags &IDEFLOPPY_FLAG_DRQ_INTERRUPT ) + pc->flags |=PC_FLAG_DRQ_INTERRUPT ; +if (floppy->flags &IDEFLOPPY_FLAG_ZIP_DRIVE ) pc->flags |=PC_FLAG_ZIP_DRIVE ;
drivers/ide/ide-tape.c +8 -3
@@ -1020,7 +1020,7 @@ static ide_startstop_t idetape_issue_pc(ide_pktcmd_tf_load (drive,IDE_TFLAG_OUT_DEVICE , bcount, dma_ok); -if (test_bit (IDETAPE_FLAG_DRQ_INTERRUPT , &tape->flags)) { +if (pc->flags &PC_FLAG_DRQ_INTERRUPT ) {ide_execute_command (drive,WIN_PACKETCMD , &idetape_transfer_pc,IDETAPE_WAIT_CMD ,NULL );return ide_started;
@@ -1143,8 +1143,10 @@ static ide_startstop_t idetape_do_reques }/* Retry a failed packet command */ -if (tape->failed_pc && tape->pc->c[0 ] ==REQUEST_SENSE ) -return idetape_issue_pc (drive, tape->failed_pc); +if (tape->failed_pc && tape->pc->c[0 ] ==REQUEST_SENSE ) { + pc = tape->failed_pc; + goto out; + }if (postponed_rq !=NULL )if (rq != postponed_rq) {
@@ -1216,6 +1218,9 @@ static ide_startstop_t idetape_do_reques }BUG (); out: +if (test_bit (IDETAPE_FLAG_DRQ_INTERRUPT , &tape->flags)) + pc->flags |=PC_FLAG_DRQ_INTERRUPT ; +return idetape_issue_pc (drive, pc); }
drivers/scsi/ide-scsi.c +5 -1
@@ -525,7 +525,7 @@ static ide_startstop_t idescsi_issue_pc(ide_pktcmd_tf_load (drive,0 , bcount, dma); -if (test_bit (IDESCSI_DRQ_INTERRUPT , &scsi->flags)) { +if (pc->flags &PC_FLAG_DRQ_INTERRUPT ) {ide_execute_command (drive,WIN_PACKETCMD , &idescsi_transfer_pc,get_timeout (pc), idescsi_expiry);return ide_started;
@@ -548,6 +548,10 @@ static ide_startstop_t idescsi_do_requesif (blk_sense_request (rq) ||blk_special_request (rq)) {struct ide_atapi_pc *pc = (struct ide_atapi_pc *)rq->special; +idescsi_scsi_t *scsi =drive_to_idescsi (drive); + +if (test_bit (IDESCSI_DRQ_INTERRUPT , &scsi->flags)) + pc->flags |=PC_FLAG_DRQ_INTERRUPT ;if (drive->using_dma && !idescsi_map_sg (drive, pc)) pc->flags |=PC_FLAG_DMA_OK ;
include/linux/ide.h +1 -0
@@ -593,6 +593,7 @@ enum {/* command timed out */ PC_FLAG_TIMEDOUT = (1 <<7 ),PC_FLAG_ZIP_DRIVE = (1 <<8 ), + PC_FLAG_DRQ_INTERRUPT = (1 << 9), }; struct ide_atapi_pc {
PATCH 31/40 ide: add ide_issue_pc() helper
In reply to Bartlomiej ZolnierkiewiczAdd generic ide_issue_pc() helper to ide-atapi.c and then convert ide-{floppy,tape,scsi} device drivers to use it.
There should be no functional changes caused by this patch.
--- drivers/ide/ide-atapi.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/ide/ide-floppy.c | 37 ++--------------------------------- drivers/ide/ide-tape.c | 32 ++---------------------------- drivers/scsi/ide-scsi.c | 32 ++---------------------------- include/linux/ide.h | 2 + 5 files changed, 60 insertions(+), 92 deletions(-)
drivers/ide/ide-atapi.c +49 -0
@@ -68,3 +68,52 @@ ide_startstop_t ide_transfer_pc(ide_drivreturn ide_started; }EXPORT_SYMBOL_GPL (ide_transfer_pc); + +ide_startstop_t ide_issue_pc (ide_drive_t *drive,struct ide_atapi_pc *pc, +ide_handler_t *handler,unsigned int timeout, +ide_expiry_t *expiry) +{ +ide_hwif_t *hwif = drive->hwif; +u16 bcount; +u8 dma =0 ; + +/* We haven't transferred any data yet */ + pc->xferred =0 ; + pc->cur_pos = pc->buf; + +/* Request to transfer the entire buffer at once */ +if (drive->media == ide_tape && !drive->scsi) + bcount = pc->req_xfer; +else + bcount =min (pc->req_xfer,63 *1024 ); + +if (pc->flags &PC_FLAG_DMA_ERROR ) { + pc->flags &= ~PC_FLAG_DMA_ERROR ; +ide_dma_off (drive); + } + +if ((pc->flags &PC_FLAG_DMA_OK ) && drive->using_dma) { +if (drive->scsi) + hwif->sg_mapped =1 ; + dma = !hwif->dma_ops->dma_setup (drive); +if (drive->scsi) + hwif->sg_mapped =0 ; + } + +if (!dma) + pc->flags &= ~PC_FLAG_DMA_OK ; + +ide_pktcmd_tf_load (drive, drive->scsi ?0 :IDE_TFLAG_OUT_DEVICE , + bcount, dma); + +/* Issue the packet command */ +if (pc->flags &PC_FLAG_DRQ_INTERRUPT ) { +ide_execute_command (drive,WIN_PACKETCMD , handler, + timeout,NULL ); +return ide_started; + }else { +ide_execute_pkt_cmd (drive); +return (*handler)(drive); + } +} +EXPORT_SYMBOL_GPL (ide_issue_pc);
drivers/ide/ide-floppy.c +3 -34
@@ -576,9 +576,6 @@ static ide_startstop_t idefloppy_issue_p struct ide_atapi_pc *pc) {idefloppy_floppy_t *floppy = drive->driver_data; -ide_hwif_t *hwif = drive->hwif; -u16 bcount; -u8 dma;if (floppy->failed_pc ==NULL && pc->c[0 ] !=GPCMD_REQUEST_SENSE )
@@ -600,37 +597,9 @@ static ide_startstop_t idefloppy_issue_pdebug_log ("Retry number - %d\n" , pc->retries); pc->retries++; -/* We haven't transferred any data yet */ - pc->xferred =0 ; - pc->cur_pos = pc->buf; - bcount =min (pc->req_xfer,63 *1024 ); - -if (pc->flags &PC_FLAG_DMA_ERROR ) { - pc->flags &= ~PC_FLAG_DMA_ERROR ; -ide_dma_off (drive); - } - dma =0 ; - -if ((pc->flags &PC_FLAG_DMA_OK ) && drive->using_dma) - dma = !hwif->dma_ops->dma_setup (drive); - -if (!dma) - pc->flags &= ~PC_FLAG_DMA_OK ; - -ide_pktcmd_tf_load (drive,IDE_TFLAG_OUT_DEVICE , bcount, dma); - -if (pc->flags &PC_FLAG_DRQ_INTERRUPT ) { -/* Issue the packet command */ -ide_execute_command (drive,WIN_PACKETCMD , - &idefloppy_transfer_pc1, -IDEFLOPPY_WAIT_CMD , -NULL ); -return ide_started; - }else { -/* Issue the packet command */ -ide_execute_pkt_cmd (drive); -return idefloppy_transfer_pc1 (drive); - } + +return ide_issue_pc (drive, pc, idefloppy_transfer_pc1, +IDEFLOPPY_WAIT_CMD ,NULL ); }static void idefloppy_create_prevent_cmd (struct ide_atapi_pc *pc,int prevent)
drivers/ide/ide-tape.c +3 -29
@@ -958,10 +958,7 @@ static ide_startstop_t idetape_transfer_static ide_startstop_t idetape_issue_pc (ide_drive_t *drive,struct ide_atapi_pc *pc) { -ide_hwif_t *hwif = drive->hwif;idetape_tape_t *tape = drive->driver_data; -int dma_ok =0 ; -u16 bcount;if (tape->pc->c[0 ] ==REQUEST_SENSE && pc->c[0 ] ==REQUEST_SENSE ) {
@@ -1002,32 +999,9 @@ static ide_startstop_t idetape_issue_pc(debug_log (DBG_SENSE ,"Retry #%d, cmd = %02X\n" , pc->retries, pc->c[0 ]); pc->retries++; -/* We haven't transferred any data yet */ - pc->xferred =0 ; - pc->cur_pos = pc->buf; -/* Request to transfer the entire buffer at once */ - bcount = pc->req_xfer; - -if (pc->flags &PC_FLAG_DMA_ERROR ) { - pc->flags &= ~PC_FLAG_DMA_ERROR ; -ide_dma_off (drive); - } -if ((pc->flags &PC_FLAG_DMA_OK ) && drive->using_dma) - dma_ok = !hwif->dma_ops->dma_setup (drive); - -if (!dma_ok) - pc->flags &= ~PC_FLAG_DMA_OK ; - -ide_pktcmd_tf_load (drive,IDE_TFLAG_OUT_DEVICE , bcount, dma_ok); - -if (pc->flags &PC_FLAG_DRQ_INTERRUPT ) { -ide_execute_command (drive,WIN_PACKETCMD , &idetape_transfer_pc, -IDETAPE_WAIT_CMD ,NULL ); -return ide_started; - }else { -ide_execute_pkt_cmd (drive); -return idetape_transfer_pc (drive); - } + +return ide_issue_pc (drive, pc, idetape_transfer_pc, +IDETAPE_WAIT_CMD ,NULL ); }/* A mode sense command is used to "sense" tape parameters. */
drivers/scsi/ide-scsi.c +3 -29
@@ -502,38 +502,12 @@ static ide_startstop_t idescsi_issue_pc( struct ide_atapi_pc *pc) {idescsi_scsi_t *scsi =drive_to_idescsi (drive); -ide_hwif_t *hwif = drive->hwif; -u16 bcount; -u8 dma =0 ;/* Set the current packet command */ scsi->pc = pc; -/* We haven't transferred any data yet */ - pc->xferred =0 ; - pc->cur_pos = pc->buf; -/* Request to transfer the entire buffer at once */ - bcount =min (pc->req_xfer,63 *1024 ); - -if ((pc->flags &PC_FLAG_DMA_OK ) && drive->using_dma) { - hwif->sg_mapped =1 ; - dma = !hwif->dma_ops->dma_setup (drive); - hwif->sg_mapped =0 ; - } - -if (!dma) - pc->flags &= ~PC_FLAG_DMA_OK ; - -ide_pktcmd_tf_load (drive,0 , bcount, dma); - -if (pc->flags &PC_FLAG_DRQ_INTERRUPT ) { -ide_execute_command (drive,WIN_PACKETCMD , &idescsi_transfer_pc, -get_timeout (pc), idescsi_expiry); -return ide_started; - }else { -/* Issue the packet command */ -ide_execute_pkt_cmd (drive); -return idescsi_transfer_pc (drive); - } + +return ide_issue_pc (drive, pc, idescsi_transfer_pc, +get_timeout (pc), idescsi_expiry); }/*
include/linux/ide.h +2 -0
@@ -955,6 +955,8 @@ void ide_pktcmd_tf_load(ide_drive_t *, uide_startstop_t ide_transfer_pc (ide_drive_t *,struct ide_atapi_pc *,ide_handler_t *,unsigned int ,ide_expiry_t *); +ide_startstop_t ide_issue_pc (ide_drive_t *,struct ide_atapi_pc *, +ide_handler_t *,unsigned int ,ide_expiry_t *);ide_startstop_t do_rw_taskfile (ide_drive_t *,ide_task_t *);
PATCH 32/40 ide-{floppy,tape}: move checking of ->failed_pc to ->callback
In reply to Bartlomiej ZolnierkiewiczMove checking/resetting of ->failed_pc from ide*_pc_intr() to ->callback as a preparation for adding generic ide_pc_intr() helper.
There should be no functional changes caused by this patch.
--- drivers/ide/ide-floppy.c | 5 +++-- drivers/ide/ide-tape.c | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/ide/ide-floppy.c +3 -2
@@ -320,6 +320,9 @@ static void ide_floppy_callback(ide_drivdebug_log ("Reached %s\n" , __func__); +if (floppy->failed_pc == pc) + floppy->failed_pc =NULL ; +if (pc->c[0 ] ==GPCMD_READ_10 || pc->c[0 ] ==GPCMD_WRITE_10 || (pc->rq &&blk_pc_request (pc->rq))) uptodate =1 ;/* FIXME */
@@ -435,8 +438,6 @@ static ide_startstop_t idefloppy_pc_intrreturn ide_stopped; } pc->error =0 ; -if (floppy->failed_pc == pc) - floppy->failed_pc =NULL ;/* Command finished - Call the callback function */ pc->callback (drive);return ide_stopped;
drivers/ide/ide-tape.c +3 -4
@@ -627,6 +627,9 @@ static void ide_tape_callback(ide_drive_debug_log (DBG_PROCS ,"Enter %s\n" , __func__); +if (tape->failed_pc == pc) + tape->failed_pc =NULL ; +if (pc->c[0 ] ==REQUEST_SENSE ) {if (uptodate)idetape_analyze_error (drive, pc->buf);
@@ -838,8 +841,6 @@ static ide_startstop_t idetape_pc_intr(iidetape_postpone_request (drive);return ide_stopped; } -if (tape->failed_pc == pc) - tape->failed_pc =NULL ;/* Command finished - Call the callback function */ pc->callback (drive);return ide_stopped;
@@ -1050,8 +1051,6 @@ static ide_startstop_t idetape_media_accreturn ide_stopped; } pc->error =0 ; -if (tape->failed_pc == pc) - tape->failed_pc =NULL ; }else { pc->error =IDETAPE_ERROR_GENERAL ; tape->failed_pc =NULL ;
PATCH 33/40 ide-tape: factor out DSC handling from idetape_pc_intr()
In reply to Bartlomiej ZolnierkiewiczFactor out DSC handling from idetape_pc_intr() to ide_tape_handle_dsc() helper as a preparation for adding generic ide_pc_intr() helper.
There should be no functional changes caused by this patch.
--- drivers/ide/ide-tape.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/ide/ide-tape.c +13 -6
@@ -768,6 +768,18 @@ static void idetape_postpone_request(ideide_stall_queue (drive, tape->dsc_poll_freq); } +static void ide_tape_handle_dsc (ide_drive_t *drive) +{ +idetape_tape_t *tape = drive->driver_data; + +/* Media access command */ + tape->dsc_polling_start = jiffies; + tape->dsc_poll_freq =IDETAPE_DSC_MA_FAST ; + tape->dsc_timeout = jiffies +IDETAPE_DSC_MA_TIMEOUT ; +/* Allow ide.c to handle other requests */ +idetape_postpone_request (drive); +} +typedef void idetape_io_buf (ide_drive_t *,struct ide_atapi_pc *,unsigned int );/*
@@ -833,12 +845,7 @@ static ide_startstop_t idetape_pc_intr(i pc->error =0 ;if ((pc->flags &PC_FLAG_WAIT_FOR_DSC ) && (stat &SEEK_STAT ) ==0 ) { -/* Media access command */ - tape->dsc_polling_start = jiffies; - tape->dsc_poll_freq =IDETAPE_DSC_MA_FAST ; - tape->dsc_timeout = jiffies +IDETAPE_DSC_MA_TIMEOUT ; -/* Allow ide.c to handle other requests */ -idetape_postpone_request (drive); +ide_tape_handle_dsc (drive);return ide_stopped; }/* Command finished - Call the callback function */
PATCH 34/40 ide-tape: add ide_tape_io_buffers() helper
In reply to Bartlomiej Zolnierkiewicz* Add ide_tape_io_buffers() helper which is a wrapper for idetape_{in,out}put_buffers() and convert idetape_pc_intr() to use it.
* Remove no longer used idetape_io_buf typedef.
There should be no functional changes caused by this patch.
--- drivers/ide/ide-tape.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/ide/ide-tape.c +10 -5
@@ -780,7 +780,14 @@ static void ide_tape_handle_dsc(ide_drividetape_postpone_request (drive); } -typedef void idetape_io_buf (ide_drive_t *,struct ide_atapi_pc *,unsigned int ); +static void ide_tape_io_buffers (ide_drive_t *drive,struct ide_atapi_pc *pc, +unsigned int bcount,int write) +{ +if (write) +idetape_output_buffers (drive, pc, bcount); +else +idetape_input_buffers (drive, pc, bcount); +}/* * This is the usual interrupt handler which will be called during a packet
@@ -795,7 +802,6 @@ static ide_startstop_t idetape_pc_intr(iidetape_tape_t *tape = drive->driver_data;struct ide_atapi_pc *pc = tape->pc;xfer_func_t *xferfunc; -idetape_io_buf *iobuf;unsigned int temp;u16 bcount;u8 stat, ireason;
@@ -895,15 +901,14 @@ static ide_startstop_t idetape_pc_intr(idebug_log (DBG_SENSE ,"The device wants to send us more " "data than expected - allowing transfer\n" ); } - iobuf = &idetape_input_buffers; xferfunc = hwif->input_data; }else { - iobuf = &idetape_output_buffers; xferfunc = hwif->output_data; }if (pc->bh) -iobuf (drive, pc, bcount); +ide_tape_io_buffers (drive, pc, bcount, + !!(pc->flags &PC_FLAG_WRITING ));else xferfunc (drive,NULL , pc->cur_pos, bcount);
PATCH 35/40 ide-tape: always log debug info in idetape_pc_intr() if debugging is enabled
In reply to Bartlomiej ZolnierkiewiczAdd DBG_PC_INTR debug level and use it to always log debug info in idetape_pc_intr() if debugging is enabled.
While at it:
* Use drive->name instead of tape->name.
* Log device name with "DMA finished" message.
This is a preparation for adding generic ide_pc_intr() helper.
--- drivers/ide/ide-tape.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/ide/ide-tape.c +10 -9
@@ -56,6 +56,8 @@ enum {DBG_PROCS = (1 <<3 ),/* buffer alloc info (pc_stack & rq_stack) */ DBG_PCRQ_STACK = (1 <<4 ), +/* IRQ handler (always log debug info if debugging is on) */ + DBG_PC_INTR = (1 << 5), };/* define to see debug info */
@@ -64,7 +66,7 @@ enum {#if IDETAPE_DEBUG_LOG #define debug_log(lvl, fmt, args...) \ { \ - if (tape->debug_mask & lvl) \ + if ((lvl & DBG_PC_INTR) || (tape->debug_mask & lvl)) \ printk(KERN_INFO "ide-tape: " fmt, ## args); \ }#else
@@ -806,7 +808,7 @@ static ide_startstop_t idetape_pc_intr(iu16 bcount;u8 stat, ireason; -debug_log (DBG_PROCS ,"Enter %s - interrupt handler\n" , __func__); +debug_log (DBG_PC_INTR ,"Enter %s - interrupt handler\n" , __func__);/* Clear the interrupt */ stat =ide_read_status (drive);
@@ -818,13 +820,12 @@ static ide_startstop_t idetape_pc_intr(i pc->xferred = pc->req_xfer;idetape_update_buffers (pc); } -debug_log (DBG_PROCS ,"DMA finished\n" ); - +debug_log (DBG_PC_INTR ,"%s: DMA finished\n" , drive->name); }/* No more interrupts */ if ((stat &DRQ_STAT ) ==0 ) { -debug_log (DBG_SENSE ,"Packet command completed, %d bytes" +debug_log (DBG_PC_INTR ,"Packet command completed, %d bytes" " transferred\n" , pc->xferred); pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS ;
@@ -834,14 +835,14 @@ static ide_startstop_t idetape_pc_intr(i stat &= ~ERR_STAT ;if ((stat &ERR_STAT ) || (pc->flags &PC_FLAG_DMA_ERROR )) {/* Error detected */ -debug_log (DBG_ERR ,"%s: I/O error\n" , tape->name); +debug_log (DBG_PC_INTR ,"%s: I/O error\n" , drive->name);if (pc->c[0 ] ==REQUEST_SENSE ) {printk (KERN_ERR "%s: I/O error in request sense" " command\n" , drive->name);return ide_do_reset (drive); } -debug_log (DBG_ERR ,"[cmd %x]: check condition\n" , +debug_log (DBG_PC_INTR ,"[cmd %x]: check condition\n" , pc->c[0 ]);/* Retry operation */
@@ -898,7 +899,7 @@ static ide_startstop_t idetape_pc_intr(i IDETAPE_WAIT_CMD, NULL);return ide_started; } -debug_log (DBG_SENSE ,"The device wants to send us more " +debug_log (DBG_PC_INTR ,"The device wants to send us more " "data than expected - allowing transfer\n" ); } xferfunc = hwif->input_data;
@@ -916,7 +917,7 @@ static ide_startstop_t idetape_pc_intr(i pc->xferred += bcount; pc->cur_pos += bcount; -debug_log (DBG_SENSE ,"[cmd %x] transferred %d bytes on that intr.\n" , +debug_log (DBG_PC_INTR ,"[cmd %x] transferred %d bytes on that intr.\n" , pc->c[0 ], bcount);/* And set the interrupt handler again */
PATCH 36/40 ide-floppy: add more debugging to idefloppy_pc_intr()
In reply to Bartlomiej ZolnierkiewiczAdd more debugging to idefloppy_pc_intr() to match ide-tape's idetape_pc_intr().
While at it:
* Correct the first debug message.
* Log device name with "DMA finished" message.
This is a preparation for adding generic ide_pc_intr() helper.
--- drivers/ide/ide-floppy.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/ide/ide-floppy.c +8 -2
@@ -397,7 +397,7 @@ static ide_startstop_t idefloppy_pc_intru16 bcount;u8 stat, ireason; -debug_log ("Reached %s interrupt handler\n" , __func__); +debug_log ("Enter %s - interrupt handler\n" , __func__);if (pc->flags &PC_FLAG_DMA_IN_PROGRESS ) { dma_error = hwif->dma_ops->dma_end (drive);
@@ -409,7 +409,7 @@ static ide_startstop_t idefloppy_pc_intr pc->xferred = pc->req_xfer;idefloppy_update_buffers (drive, pc); } -debug_log ("DMA finished\n" ); +debug_log ("%s: DMA finished\n" , drive->name); }/* Clear the interrupt */
@@ -432,6 +432,9 @@ static ide_startstop_t idefloppy_pc_intr " command\n", drive->name);return ide_do_reset (drive); } + +debug_log ("[cmd %x]: check condition\n" , pc->c[0 ]); +/* Retry operation */ idefloppy_retry_pc (drive);/* queued, but not started */
@@ -505,6 +508,9 @@ static ide_startstop_t idefloppy_pc_intr pc->xferred += bcount; pc->cur_pos += bcount; +debug_log ("[cmd %x] transferred %d bytes on that intr.\n" , + pc->c[0 ], bcount); +/* And set the interrupt handler again */ ide_set_handler (drive, &idefloppy_pc_intr,IDEFLOPPY_WAIT_CMD ,NULL );return ide_started;
PATCH 37/40 ide-scsi: use pc->callback
In reply to Bartlomiej Zolnierkiewicz* Add ide_scsi_callback() pc->callback implementation, then update idescsi_check_condition() and idescsi_queue() to setup ->callback.
* Convert idescsi_pc_intr() to use pc->callback.
This is a preparation for adding generic ide_pc_intr() helper.
--- drivers/scsi/ide-scsi.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
drivers/scsi/ide-scsi.c +22 -10
@@ -183,6 +183,24 @@ static void ide_scsi_hex_dump(u8 *data,print_hex_dump (KERN_CONT ,"" ,DUMP_PREFIX_NONE ,16 ,1 , data, len,0 ); } +static int idescsi_end_request (ide_drive_t *,int ,int ); + +static void ide_scsi_callback (ide_drive_t *drive) +{ +idescsi_scsi_t *scsi =drive_to_idescsi (drive); +struct ide_atapi_pc *pc = scsi->pc; + +if (pc->flags &PC_FLAG_TIMEDOUT ) +debug_log ("%s: got timed out packet %lu at %lu\n" , __func__, + pc->scsi_cmd->serial_number, jiffies); +/* end this request now - scsi should retry it*/ +else if (test_bit (IDESCSI_LOG_CMD , &scsi->log)) +printk (KERN_INFO "Packet command completed, %d bytes" +" transferred\n" , pc->xferred); + +idescsi_end_request (drive,1 ,0 ); +} +static int idescsi_check_condition (ide_drive_t *drive,struct request *failed_cmd) {
@@ -210,6 +228,7 @@ static int idescsi_check_condition(ide_d rq->cmd_type =REQ_TYPE_SENSE ; rq->cmd_flags |=REQ_PREEMPT ; pc->timeout = jiffies +WAIT_READY ; + pc->callback = ide_scsi_callback;/* NOTE! Save the failed packet command in "rq->buffer" */ rq->buffer = (void *) failed_cmd->special; pc->scsi_cmd = ((struct ide_atapi_pc *) failed_cmd->special)->scsi_cmd;
@@ -222,8 +241,6 @@ static int idescsi_check_condition(ide_dreturn 0 ; } -static int idescsi_end_request (ide_drive_t *,int ,int ); -static ide_startstop_t idescsi_atapi_error (ide_drive_t *drive,struct request *rq,u8 stat,u8 err) {
@@ -350,10 +367,7 @@ static ide_startstop_t idescsi_pc_intr (debug_log ("Reached %s interrupt handler\n" , __func__);if (pc->flags &PC_FLAG_TIMEDOUT ) { -debug_log ("%s: got timed out packet %lu at %lu\n" , __func__, - pc->scsi_cmd->serial_number, jiffies); -/* end this request now - scsi should retry it*/ -idescsi_end_request (drive,1 ,0 ); + pc->callback (drive);return ide_stopped; }if (pc->flags &PC_FLAG_DMA_IN_PROGRESS ) {
@@ -369,14 +383,11 @@ static ide_startstop_t idescsi_pc_intr (if ((stat &DRQ_STAT ) ==0 ) {/* No more interrupts */ -if (test_bit (IDESCSI_LOG_CMD , &scsi->log)) -printk (KERN_INFO "Packet command completed, %d bytes" -" transferred\n" , pc->xferred); pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS ;local_irq_enable_in_hardirq ();if ((stat &ERR_STAT ) || (pc->flags &PC_FLAG_DMA_ERROR )) rq->errors++; -idescsi_end_request (drive,1 ,0 ); + pc->callback (drive);return ide_stopped; }if (pc->flags &PC_FLAG_DMA_IN_PROGRESS ) {
@@ -718,6 +729,7 @@ static int idescsi_queue (struct scsi_cm pc->scsi_cmd = cmd; pc->done = done; pc->timeout = jiffies + cmd->timeout_per_command; + pc->callback = ide_scsi_callback;if (test_bit (IDESCSI_LOG_CMD , &scsi->log)) {printk ("ide-scsi: %s: que %lu, cmd = " , drive->name, cmd->serial_number);
PATCH 38/40 ide-scsi: add more debugging to idescsi_pc_intr()
In reply to Bartlomiej ZolnierkiewiczAdd more debugging to idescsi_pc_intr() to match ide-tape's idetape_pc_intr().
While at it:
* Correct the first debug message.
This is a preparation for adding generic ide_pc_intr() helper.
--- drivers/scsi/ide-scsi.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/scsi/ide-scsi.c +11 -2
@@ -364,7 +364,7 @@ static ide_startstop_t idescsi_pc_intr (u16 bcount;u8 stat, ireason; -debug_log ("Reached %s interrupt handler\n" , __func__); +debug_log ("Enter %s - interrupt handler\n" , __func__);if (pc->flags &PC_FLAG_TIMEDOUT ) { pc->callback (drive);
@@ -383,10 +383,16 @@ static ide_startstop_t idescsi_pc_intr (if ((stat &DRQ_STAT ) ==0 ) {/* No more interrupts */ +debug_log ("Packet command completed, %d bytes transferred\n" , + pc->xferred); pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS ;local_irq_enable_in_hardirq (); -if ((stat &ERR_STAT ) || (pc->flags &PC_FLAG_DMA_ERROR )) +if ((stat &ERR_STAT ) || (pc->flags &PC_FLAG_DMA_ERROR )) { +/* Error detected */ +debug_log ("%s: I/O error\n" , drive->name); + rq->errors++; + } pc->callback (drive);return ide_stopped; }
@@ -457,6 +463,9 @@ static ide_startstop_t idescsi_pc_intr ( pc->xferred += bcount; pc->cur_pos += bcount; +debug_log ("[cmd %x] transferred %d bytes on that intr.\n" , + pc->c[0 ], bcount); +/* And set the interrupt handler again */ ide_set_handler (drive, &idescsi_pc_intr,get_timeout (pc), idescsi_expiry);return ide_started;
PATCH 39/40 ide-{floppy,scsi}: read Status Register before stopping DMA engine
In reply to Bartlomiej ZolnierkiewiczRead Status Register before stopping DMA engine to match ide-tape device driver - it should be safe and shouldn't affect anything.
This is a preparation for adding generic ide_pc_intr() helper.
--- drivers/ide/ide-floppy.c | 6 +++--- drivers/scsi/ide-scsi.c | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-)
drivers/ide/ide-floppy.c +3 -3
@@ -399,6 +399,9 @@ static ide_startstop_t idefloppy_pc_intrdebug_log ("Enter %s - interrupt handler\n" , __func__); +/* Clear the interrupt */ + stat =ide_read_status (drive); +if (pc->flags &PC_FLAG_DMA_IN_PROGRESS ) { dma_error = hwif->dma_ops->dma_end (drive);if (dma_error) {
@@ -412,9 +415,6 @@ static ide_startstop_t idefloppy_pc_intrdebug_log ("%s: DMA finished\n" , drive->name); } -/* Clear the interrupt */ - stat =ide_read_status (drive); -/* No more interrupts */ if ((stat &DRQ_STAT ) ==0 ) { debug_log("Packet command completed, %d bytes transferred\n",
drivers/scsi/ide-scsi.c +4 -3
@@ -370,6 +370,10 @@ static ide_startstop_t idescsi_pc_intr ( pc->callback (drive);return ide_stopped; } + +/* Clear the interrupt */ + stat =ide_read_status (drive); +if (pc->flags &PC_FLAG_DMA_IN_PROGRESS ) {if (hwif->dma_ops->dma_end (drive)) pc->flags |=PC_FLAG_DMA_ERROR ;
@@ -378,9 +382,6 @@ static ide_startstop_t idescsi_pc_intr (debug_log ("%s: DMA finished\n" , drive->name); } -/* Clear the interrupt */ - stat =ide_read_status (drive); -if ((stat &DRQ_STAT ) ==0 ) {/* No more interrupts */ debug_log("Packet command completed, %d bytes transferred\n",
PATCH 40/40 ide: add ide_pc_intr() helper
In reply to Bartlomiej Zolnierkiewicz* ide-tape.c: add 'drive' argument to idetape_update_buffers().
* Add generic ide_pc_intr() helper to ide-atapi.c and then convert ide-{floppy,tape,scsi} device drivers to use it.
* ide-tape.c: remove no longer needed DBG_PC_INTR.
There should be no functional changes caused by this patch (unless the debugging is explicitely compiled in).
--- drivers/ide/ide-atapi.c | 177 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/ide/ide-floppy.c | 128 --------------------------------- drivers/ide/ide-tape.c | 132 +---------------------------------- drivers/scsi/ide-scsi.c | 115 ------------------------------ include/linux/ide.h | 6 + 5 files changed, 195 insertions(+), 363 deletions(-)
drivers/ide/ide-atapi.c +177 -0
@@ -5,6 +5,183 @@#include <linux/kernel.h> #include <linux/delay.h> #include <linux/ide.h> +#include <scsi/scsi.h> + +#ifdef DEBUG +#define debug_log(fmt, args...) \ + printk(KERN_INFO "ide: " fmt, ## args) +#else +#define debug_log(fmt, args...) do {} while (0) +#endif + +/* TODO: unify the code thus making some arguments go away */ +ide_startstop_t ide_pc_intr (ide_drive_t *drive,struct ide_atapi_pc *pc, +ide_handler_t *handler,unsigned int timeout,ide_expiry_t *expiry, +void (*update_buffers)(ide_drive_t *,struct ide_atapi_pc *), +void (*retry_pc)(ide_drive_t *),void (*dsc_handle)(ide_drive_t *), +void (*io_buffers)(ide_drive_t *,struct ide_atapi_pc *,unsigned ,int )) +{ +ide_hwif_t *hwif = drive->hwif; +xfer_func_t *xferfunc; +unsigned int temp; +u16 bcount; +u8 stat, ireason, scsi = drive->scsi; + +debug_log ("Enter %s - interrupt handler\n" , __func__); + +if (pc->flags &PC_FLAG_TIMEDOUT ) { + pc->callback (drive); +return ide_stopped; + } + +/* Clear the interrupt */ + stat =ide_read_status (drive); + +if (pc->flags &PC_FLAG_DMA_IN_PROGRESS ) { +if (hwif->dma_ops->dma_end (drive) || + (drive->media == ide_tape && !scsi && (stat &ERR_STAT ))) { +if (drive->media == ide_floppy && !scsi) +printk (KERN_ERR "%s: DMA %s error\n" , + drive->name,rq_data_dir (pc->rq) + ?"write" :"read" ); + pc->flags |=PC_FLAG_DMA_ERROR ; + }else { + pc->xferred = pc->req_xfer; +if (update_buffers) +update_buffers (drive, pc); + } +debug_log ("%s: DMA finished\n" , drive->name); + } + +/* No more interrupts */ +if ((stat &DRQ_STAT ) ==0 ) { +debug_log ("Packet command completed, %d bytes transferred\n" , + pc->xferred); + + pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS ; + +local_irq_enable_in_hardirq (); + +if (drive->media == ide_tape && !scsi && + (stat &ERR_STAT ) && pc->c[0 ] ==REQUEST_SENSE ) + stat &= ~ERR_STAT ; +if ((stat &ERR_STAT ) || (pc->flags &PC_FLAG_DMA_ERROR )) { +/* Error detected */ +debug_log ("%s: I/O error\n" , drive->name); + +if (drive->media != ide_tape || scsi) { + pc->rq->errors++; +if (scsi) + goto cmd_finished; + } + +if (pc->c[0 ] ==REQUEST_SENSE ) { +printk (KERN_ERR "%s: I/O error in request sense" +" command\n" , drive->name); +return ide_do_reset (drive); + } + +debug_log ("[cmd %x]: check condition\n" , pc->c[0 ]); + +/* Retry operation */ +retry_pc (drive); +/* queued, but not started */ +return ide_stopped; + } +cmd_finished: + pc->error =0 ; +if ((pc->flags &PC_FLAG_WAIT_FOR_DSC ) && + (stat &SEEK_STAT ) ==0 ) { +dsc_handle (drive); +return ide_stopped; + } +/* Command finished - Call the callback function */ + pc->callback (drive); +return ide_stopped; + } + +if (pc->flags &PC_FLAG_DMA_IN_PROGRESS ) { + pc->flags &= ~PC_FLAG_DMA_IN_PROGRESS ; +printk (KERN_ERR "%s: The device wants to issue more interrupts " +"in DMA mode\n" , drive->name); +ide_dma_off (drive); +return ide_do_reset (drive); + } +/* Get the number of bytes to transfer on this interrupt. */ + bcount = (hwif->INB (hwif->io_ports.lbah_addr) <<8 ) | + hwif->INB (hwif->io_ports.lbam_addr); + + ireason = hwif->INB (hwif->io_ports.nsect_addr); + +if (ireason &CD ) { +printk (KERN_ERR "%s: CoD != 0 in %s\n" , drive->name, __func__); +return ide_do_reset (drive); + } +if (((ireason &IO ) ==IO ) == !!(pc->flags &PC_FLAG_WRITING )) { +/* Hopefully, we will never get here */ +printk (KERN_ERR "%s: We wanted to %s, but the device wants us " +"to %s!\n" , drive->name, + (ireason &IO ) ?"Write" :"Read" , + (ireason &IO ) ?"Read" :"Write" ); +return ide_do_reset (drive); + } +if (!(pc->flags &PC_FLAG_WRITING )) { +/* Reading - Check that we have enough space */ + temp = pc->xferred + bcount; +if (temp > pc->req_xfer) { +if (temp > pc->buf_size) { +printk (KERN_ERR "%s: The device wants to send " +"us more data than expected - " +"discarding data\n" , + drive->name); +if (scsi) + temp = pc->buf_size - pc->xferred; +else + temp =0 ; +if (temp) { +if (pc->sg) +io_buffers (drive, pc, temp,0 ); +else + hwif->input_data (drive,NULL , + pc->cur_pos, temp); +printk (KERN_ERR "%s: transferred %d of " +"%d bytes\n" , + drive->name, + temp, bcount); + } + pc->xferred += temp; + pc->cur_pos += temp; +ide_pad_transfer (drive,0 , bcount - temp); +ide_set_handler (drive, handler, timeout, + expiry); +return ide_started; + } +debug_log ("The device wants to send us more data than " +"expected - allowing transfer\n" ); + } + xferfunc = hwif->input_data; + }else + xferfunc = hwif->output_data; + +if ((drive->media == ide_floppy && !scsi && !pc->buf) || + (drive->media == ide_tape && !scsi && pc->bh) || + (scsi && pc->sg)) +io_buffers (drive, pc, bcount, !!(pc->flags &PC_FLAG_WRITING )); +else +xferfunc (drive,NULL , pc->cur_pos, bcount); + +/* Update the current position */ + pc->xferred += bcount; + pc->cur_pos += bcount; + +debug_log ("[cmd %x] transferred %d bytes on that intr.\n" , + pc->c[0 ], bcount); + +/* And set the interrupt handler again */ +ide_set_handler (drive, handler, timeout, expiry); +return ide_started; +} +EXPORT_SYMBOL_GPL (ide_pc_intr);static u8 ide_wait_ireason (ide_drive_t *drive,u8 ireason) {
drivers/ide/ide-floppy.c +3 -125
135 lines not on this page · raw message
drivers/ide/ide-tape.c +6 -126
164 lines not on this page · raw message
drivers/scsi/ide-scsi.c +3 -112
123 lines not on this page · raw message
include/linux/ide.h +6 -0
@@ -953,6 +953,12 @@ extern int drive_is_ready(ide_drive_t *)void ide_pktcmd_tf_load (ide_drive_t *,u32 ,u16 ,u8 ); +ide_startstop_t ide_pc_intr (ide_drive_t *drive,struct ide_atapi_pc *pc, +ide_handler_t *handler,unsigned int timeout,ide_expiry_t *expiry, +void (*update_buffers)(ide_drive_t *,struct ide_atapi_pc *), +void (*retry_pc)(ide_drive_t *),void (*dsc_handle)(ide_drive_t *), +void (*io_buffers)(ide_drive_t *,struct ide_atapi_pc *,unsigned int , +int ));ide_startstop_t ide_transfer_pc (ide_drive_t *,struct ide_atapi_pc *,ide_handler_t *,unsigned int ,ide_expiry_t *); ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_atapi_pc *,
Quoted 31 lines · Bartlomiej Zolnierkiewicz
Hi,
This patch series unifies ATAPI support present in ide-{floppy,tape,scsi} device drivers and moves it out to the core IDE code (new
ide-atapi.cfile).In the process many bugs were shaken out and ~300 LOC were removed.
diffstat:
drivers/ide/Kconfig | 6 drivers/ide/Makefile | 1 drivers/ide/ide-atapi.c | 296 ++++++++++++++++++++++ drivers/ide/ide-cd.c | 5 drivers/ide/ide-floppy.c | 431 +++++++------------------------- drivers/ide/ide-tape.c | 630 ++++++++++++++--------------------------------- drivers/scsi/ide-scsi.c | 455 +++++++++++---------------------- include/linux/ide.h | 28 +- 8 files changed, 777 insertions(+), 1075 deletions(-)Now, while this is a big step in the right direction there are still some things left on TODO for generic ATAPI support to be complete:
- convert ide-cd to use generic ATAPI code
- kill pc and rq stacks in ide-{floppy,tape}
- generic handling of REQUEST SENSE command
- generic handling of MODE SENSE command for ide-{floppy,tape}
Quoted 8 lines
- convert ide-{cd,floppy,tape} to use scatterlists for PIO transers (ala ide-scsi)
I know that Borislav is working on the first two items but other ones are free at the moment so if you feel brave you may give it a try :-).
PS I'll be travelling during this weekend and be rather busy with day job
so replies from me may be delayed a bit.
Hi Bart,
yep, these all look real good, makes all drivers really lightweight. Looks like ide-cd will follow not too far behind. By the way, here's another one you count apply ontop:
From: Borislav Petkov <[email protected]>
Date: Thu, 22 May 2008 09:36:53 +0200
Subject: [PATCH] ide-tape: unify idetape_create_read/write_cmd
A straightforward one. There should be no functional change resulting from this change.
--- drivers/ide/ide-tape.c | 47 ++++++++++++++++++++--------------------------- 1 files changed, 20 insertions(+), 27 deletions(-)
drivers/ide/ide-tape.c +20 -27
@@ -952,40 +952,31 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive)return ide_stopped; } -static void idetape_create_read_cmd (idetape_tape_t *tape, -struct ide_atapi_pc *pc, -unsigned int length,struct idetape_bh *bh) +static void ide_tape_create_rw_cmd (idetape_tape_t *tape, +struct ide_atapi_pc *pc,unsigned int length, +struct idetape_bh *bh,int opcode) {idetape_init_pc (pc); - pc->c[0 ] =READ_6 ;put_unaligned (cpu_to_be32 (length), (unsigned int *) &pc->c[1 ]); pc->c[1 ] =1 ; pc->bh = bh; -atomic_set (&bh->b_count,0 ); pc->buf =NULL ; pc->buf_size = length * tape->blk_size; pc->req_xfer = pc->buf_size;if (pc->req_xfer == tape->buffer_size) pc->flags |=PC_FLAG_DMA_OK ; -} -static void idetape_create_write_cmd (idetape_tape_t *tape, -struct ide_atapi_pc *pc, -unsigned int length,struct idetape_bh *bh) -{ -idetape_init_pc (pc); - pc->c[0 ] =WRITE_6 ; -put_unaligned (cpu_to_be32 (length), (unsigned int *) &pc->c[1 ]); - pc->c[1 ] =1 ; - pc->flags |=PC_FLAG_WRITING ; - pc->bh = bh; - pc->b_data = bh->b_data; - pc->b_count =atomic_read (&bh->b_count); - pc->buf =NULL ; - pc->buf_size = length * tape->blk_size; - pc->req_xfer = pc->buf_size; -if (pc->req_xfer == tape->buffer_size) - pc->flags |=PC_FLAG_DMA_OK ; +if (opcode ==READ_6 ) { + pc->c[0 ] =READ_6 ; +atomic_set (&bh->b_count,0 ); + } +else if (opcode ==WRITE_6 ) { + pc->c[0 ] =WRITE_6 ; + pc->flags |=PC_FLAG_WRITING ; + pc->b_data = bh->b_data; + pc->b_count =atomic_read (&bh->b_count); + }else +printk (KERN_ERR "%s: Invalid opcode: 0x%x\n" , __func__, opcode); } static ide_startstop_t idetape_do_request(ide_drive_t *drive,
@@ -1062,14 +1053,16 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, }if (rq->cmd[0 ] &REQ_IDETAPE_READ ) { pc =idetape_next_pc_storage (drive); -idetape_create_read_cmd (tape, pc, rq->current_nr_sectors, - (struct idetape_bh *)rq->special); +ide_tape_create_rw_cmd (tape, pc, rq->current_nr_sectors, + (struct idetape_bh *)rq->special, +READ_6 ); goto out; }if (rq->cmd[0 ] &REQ_IDETAPE_WRITE ) { pc =idetape_next_pc_storage (drive); -idetape_create_write_cmd (tape, pc, rq->current_nr_sectors, - (struct idetape_bh *)rq->special); +ide_tape_create_rw_cmd (tape, pc, rq->current_nr_sectors, + (struct idetape_bh *)rq->special, +WRITE_6 ); goto out; }if (rq->cmd[0 ] &REQ_IDETAPE_PC1 ) {
Signature · 5 lines
1.5.5.1
--
Regards/Gruß,
Boris.Quoted 46 lines · Borislav Petkov
Quoted 31 lines · Bartlomiej Zolnierkiewicz
Hi,
This patch series unifies ATAPI support present in ide-{floppy,tape,scsi} device drivers and moves it out to the core IDE code (new
ide-atapi.cfile).In the process many bugs were shaken out and ~300 LOC were removed.
diffstat:
drivers/ide/Kconfig | 6 drivers/ide/Makefile | 1 drivers/ide/ide-atapi.c | 296 ++++++++++++++++++++++ drivers/ide/ide-cd.c | 5 drivers/ide/ide-floppy.c | 431 +++++++------------------------- drivers/ide/ide-tape.c | 630 ++++++++++++++--------------------------------- drivers/scsi/ide-scsi.c | 455 +++++++++++---------------------- include/linux/ide.h | 28 +- 8 files changed, 777 insertions(+), 1075 deletions(-)Now, while this is a big step in the right direction there are still some things left on TODO for generic ATAPI support to be complete:
- convert ide-cd to use generic ATAPI code
- kill pc and rq stacks in ide-{floppy,tape}
- generic handling of REQUEST SENSE command
- generic handling of MODE SENSE command for ide-{floppy,tape}
Quoted 8 lines
- convert ide-{cd,floppy,tape} to use scatterlists for PIO transers (ala ide-scsi)
I know that Borislav is working on the first two items but other ones are free at the moment so if you feel brave you may give it a try :-).
PS I'll be travelling during this weekend and be rather busy with day job
so replies from me may be delayed a bit.Hi Bart,
yep, these all look real good, makes all drivers really lightweight. Looks like ide-cd will follow not too far behind. By the way, here's another one you count apply ontop:
Quoted 8 lines
From: Borislav Petkov <[email protected]>
Date: Thu, 22 May 2008 09:36:53 +0200
Subject: [PATCH] ide-tape: unify idetape_create_read/write_cmdA straightforward one. There should be no functional change resulting from this change.
Signed-off-by Borislav Petkov <[email protected]>
applied with minor fixups (mainly to silence checkpatch.pl, interdiff below)
thanks!
drivers/ide/ide-tape.c +3 -5
@@ -954,7 +954,7 @@static void ide_tape_create_rw_cmd (idetape_tape_t *tape,struct ide_atapi_pc *pc,unsigned int length, -struct idetape_bh *bh,int opcode) +struct idetape_bh *bh,u8 opcode) {idetape_init_pc (pc);put_unaligned (cpu_to_be32 (length), (unsigned int *) &pc->c[1 ]);
@@ -969,14 +969,12 @@if (opcode ==READ_6 ) { pc->c[0 ] =READ_6 ;atomic_set (&bh->b_count,0 ); - } -else if (opcode ==WRITE_6 ) { + }else if (opcode ==WRITE_6 ) { pc->c[0 ] =WRITE_6 ; pc->flags |=PC_FLAG_WRITING ; pc->b_data = bh->b_data; pc->b_count =atomic_read (&bh->b_count); - }else -printk (KERN_ERR "%s: Invalid opcode: 0x%x\n" , __func__, opcode); + } } static ide_startstop_t idetape_do_request(ide_drive_t *drive,