ide-cd: use generic ide_issue_pc
cover ide-cd: use generic ide_issue_pc
Hi Bart,
here are some patches converting ide-cd to using ide_issue_pc. Next is replacing cdrom_transfer_packet_command with ide_transfer_pc.
drivers/ide/ide-atapi.c | 71 ++++++++++++++++++++++--------- drivers/ide/ide-cd.c | 104 ++++++--------------------------------------- drivers/ide/ide-cd.h | 30 +++++++++++++- drivers/ide/ide-floppy.c | 2 +- drivers/ide/ide-tape.c | 2 +- drivers/scsi/ide-scsi.c | 3 +- include/linux/ide.h | 5 ++- 7 files changed, 102 insertions(+), 115 deletions(-)
PATCH 1/10 ide: add ide_drive_t.dma flag
This flag is to accomodate ide-cd functionality into ide atapi.
There should be no functionality change resulting from this patch.
--- drivers/ide/ide-atapi.c | 9 +++++---- include/linux/ide.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/ide/ide-atapi.c +5 -4
@@ -545,7 +545,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,struct ide_atapi_pc *pc = drive->pc;ide_hwif_t *hwif = drive->hwif;u16 bcount; -u8 dma =0 , scsi = !!(drive->dev_flags &IDE_DFLAG_SCSI ); +u8 scsi = !!(drive->dev_flags &IDE_DFLAG_SCSI );/* We haven't transferred any data yet */ pc->xferred =0 ;
@@ -566,15 +566,16 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout, (drive->dev_flags & IDE_DFLAG_USING_DMA)) {if (scsi) hwif->sg_mapped =1 ; - dma = !hwif->dma_ops->dma_setup (drive); + drive->dma = !hwif->dma_ops->dma_setup (drive);if (scsi) hwif->sg_mapped =0 ; } -if (!dma) +if (!drive->dma) pc->flags &= ~PC_FLAG_DMA_OK ; -ide_pktcmd_tf_load (drive, scsi ?0 :IDE_TFLAG_OUT_DEVICE , bcount, dma); +ide_pktcmd_tf_load (drive, scsi ?0 :IDE_TFLAG_OUT_DEVICE , bcount, + drive->dma);/* Issue the packet command */ if (drive->atapi_flags &IDE_AFLAG_DRQ_INTERRUPT ) {
include/linux/ide.h +1 -0
@@ -601,6 +601,7 @@ struct ide_drive_s {u8 select;/* basic drive/head select reg value */ u8 retry_pio;/* retrying dma capable host in pio */ u8 waiting_for_dma;/* dma currently in progress */ +u8 dma;/* atapi dma flag */ u8 quirk_list;/* considered quirky, set for a specific host */ u8 init_speed;/* transfer rate set at boot */
Signature · 1 line
1.5.5.1
Bartlomiej Zolnierkiewicz
AppliedRe: [PATCH 01/10] ide: add ide_drive_t.dma flag
Quoted 5 lines · On Sunday 14 September 2008 13:35:49 Borislav Petkov wrote:
This flag is to accomodate ide-cd functionality into ide atapi.
There should be no functionality change resulting from this patch.
Signed-off-by Borislav Petkov <[email protected]>
applied
PATCH 2/10 ide-cd: move cdrom_info.dma to ide_drive_t.dma
In reply to Borislav PetkovThere should be no functionality change resulting from this patch.
--- drivers/ide/ide-cd.c | 32 ++++++++++++++------------------ drivers/ide/ide-cd.h | 1 - 2 files changed, 14 insertions(+), 19 deletions(-)
drivers/ide/ide-cd.c +14 -18
@@ -556,22 +556,21 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive,int xferlen, ide_handler_t *handler) { - struct cdrom_info *info = drive->driver_data; ide_hwif_t *hwif = drive->hwif;ide_debug_log (IDE_DBG_PC ,"Call %s, xferlen: %d\n" , __func__, xferlen);/* FIXME: for Virtual DMA we must check harder */ -if (info->dma) - info->dma = !hwif->dma_ops->dma_setup (drive); +if (drive->dma) + drive->dma = !hwif->dma_ops->dma_setup (drive);/* set up the controller registers */ ide_pktcmd_tf_load (drive,IDE_TFLAG_OUT_NSECT |IDE_TFLAG_OUT_LBAL , - xferlen, info->dma); + xferlen, drive->dma);if (drive->atapi_flags &IDE_AFLAG_DRQ_INTERRUPT ) {/* waiting for CDB interrupt, not DMA yet. */ -if (info->dma) +if (drive->dma) drive->waiting_for_dma =0 ;/* packet command */
@@ -598,7 +597,6 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, {ide_hwif_t *hwif = drive->hwif;int cmd_len; -struct cdrom_info *info = drive->driver_data;ide_startstop_t startstop;ide_debug_log (IDE_DBG_PC ,"Call %s\n" , __func__);
@@ -614,7 +612,7 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive,return ide_stopped;/* ok, next interrupt will be DMA interrupt */ -if (info->dma) +if (drive->dma) drive->waiting_for_dma =1 ; }else {/* otherwise, we must wait for DRQ to get set */
@@ -635,7 +633,7 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, hwif->tp_ops->output_data (drive,NULL , rq->cmd, cmd_len);/* start the DMA if need be */ -if (info->dma) +if (drive->dma) hwif->dma_ops->dma_start (drive);return ide_started;
@@ -949,7 +947,6 @@ static int cdrom_newpc_intr_dummy_cb(struct request *rq)static ide_startstop_t cdrom_newpc_intr (ide_drive_t *drive) {ide_hwif_t *hwif = drive->hwif; -struct cdrom_info *info = drive->driver_data;struct request *rq =HWGROUP (drive)->rq;xfer_func_t *xferfunc;ide_expiry_t *expiry =NULL ;
@@ -963,9 +960,9 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) __func__, rq->cmd[0], write);/* check for errors */ - dma = info->dma; + dma = drive->dma;if (dma) { - info->dma =0 ; + drive->dma =0 ; dma_error = hwif->dma_ops->dma_end (drive);if (dma_error) { printk(KERN_ERR PFX "%s: DMA %s error\n", drive->name,
@@ -1198,9 +1195,9 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)cdrom_end_request (drive,0 );return ide_stopped; } - cd->dma =0 ; + drive->dma =0 ; }else - cd->dma = !!(drive->dev_flags &IDE_DFLAG_USING_DMA ); + drive->dma = !!(drive->dev_flags &IDE_DFLAG_USING_DMA );if (write) cd->devinfo.media_written =1 ;
@@ -1217,7 +1214,6 @@ static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive)static void cdrom_do_block_pc (ide_drive_t *drive,struct request *rq) { -struct cdrom_info *info = drive->driver_data;ide_debug_log (IDE_DBG_PC ,"Call %s, rq->cmd_type: 0x%x\n" , __func__, rq->cmd_type);
@@ -1227,7 +1223,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)else rq->cmd_flags &= ~REQ_FAILED ; - info->dma =0 ; + drive->dma =0 ;/* sg request */ if (rq->bio || ((rq->cmd_type ==REQ_TYPE_ATA_PC ) && rq->data_len)) {
@@ -1240,7 +1236,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)else buf = rq->data; - info->dma = !!(drive->dev_flags &IDE_DFLAG_USING_DMA ); + drive->dma = !!(drive->dev_flags &IDE_DFLAG_USING_DMA );/* * check if dma is safe
@@ -1251,7 +1247,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) alignment =queue_dma_alignment (q) | q->dma_pad_mask;if ((unsigned long )buf & alignment || rq->data_len & alignment ||object_is_on_stack (buf)) - info->dma =0 ; + drive->dma =0 ; } }
@@ -1292,7 +1288,7 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, xferlen =0 ; fn = cdrom_start_seek_continuation; - info->dma =0 ; + drive->dma =0 ; info->start_seek = jiffies;ide_cd_prepare_seek_request (drive, rq);
drivers/ide/ide-cd.h +0 -1
@@ -88,7 +88,6 @@ struct cdrom_info {struct request_sense sense_data;struct request request_sense_request; -int dma;unsigned long last_block;unsigned long start_seek;
Signature · 1 line
1.5.5.1
Bartlomiej Zolnierkiewicz
AppliedRe: [PATCH 02/10] ide-cd: move cdrom_info.dma to ide_drive_t.dma
Quoted 3 lines · On Sunday 14 September 2008 13:35:50 Borislav Petkov wrote:
There should be no functionality change resulting from this patch.
Signed-off-by Borislav Petkov <[email protected]>
applied
PATCH 3/10 ide-atapi: teach ide atapi about drive->waiting_for_dma
In reply to Borislav PetkovThis is in preparation for converting ide-cd to generic code. The actual rewiring will be done later after the issue_pc/transfer_pc code knows all about ide-cd.
There should be no functional change resulting from this patch.
--- drivers/ide/ide-atapi.c | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)
drivers/ide/ide-atapi.c +13 -3
@@ -487,7 +487,13 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)ide_startstop_t startstop;u8 ireason; -if (ide_wait_stat (&startstop, drive,ATA_DRQ ,ATA_BUSY ,WAIT_READY )) { +if ((drive->media == ide_cdrom || drive->media == ide_optical) && + (drive->atapi_flags &IDE_AFLAG_DRQ_INTERRUPT )) { +if (drive->dma) + drive->waiting_for_dma =1 ; + } +else if (ide_wait_stat (&startstop, drive,ATA_DRQ ,ATA_BUSY , +WAIT_READY )) {printk (KERN_ERR "%s: Strange, packet command initiated yet " "DRQ isn't asserted\n" , drive->name);return startstop;
@@ -562,8 +568,10 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,ide_dma_off (drive); } -if ((pc->flags &PC_FLAG_DMA_OK ) && - (drive->dev_flags &IDE_DFLAG_USING_DMA )) { +if (((pc->flags &PC_FLAG_DMA_OK ) && + (drive->dev_flags &IDE_DFLAG_USING_DMA )) || + ((drive->media == ide_cdrom || drive->media == ide_optical) && + drive->dma)) {if (scsi) hwif->sg_mapped =1 ; drive->dma = !hwif->dma_ops->dma_setup (drive);
@@ -579,6 +587,8 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,/* Issue the packet command */ if (drive->atapi_flags &IDE_AFLAG_DRQ_INTERRUPT ) { +if (drive->dma) + drive->waiting_for_dma =0 ;ide_execute_command (drive,ATA_CMD_PACKET , ide_transfer_pc, timeout,NULL );return ide_started;
Signature · 1 line
1.5.5.1
Re: [PATCH 03/10] ide-atapi: teach ide atapi about drive->waiting_for_dma
Quoted 16 lines · On Sunday 14 September 2008 13:35:51 Borislav Petkov wrote:
This is in preparation for converting ide-cd to generic code. The actual rewiring will be done later after the issue_pc/transfer_pc code knows all about ide-cd.
There should be no functional change resulting from this patch.
Signed-off-by Borislav Petkov <[email protected]>--- drivers/ide/ide-atapi.c | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)drivers/ide/ide-atapi.c +0
-0
drivers/ide/ide-atapi.c static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) · line 494
Quoted 9 lines
drivers/ide/ide-atapi.c +5
-1@@ -487,7 +487,13 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)ide_startstop_t startstop;u8 ireason; -if (ide_wait_stat (&startstop, drive,ATA_DRQ ,ATA_BUSY ,WAIT_READY )) { +if ((drive->media == ide_cdrom || drive->media == ide_optical) && + (drive->atapi_flags &IDE_AFLAG_DRQ_INTERRUPT )) { +if (drive->dma) + drive->waiting_for_dma =1 ; + }
We really want to do this for all ATAPI devices (as a bugfix).
drivers/ide/ide-atapi.c static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) · line 496
Quoted 2 lines
drivers/ide/ide-atapi.c +2
-0+else if (ide_wait_stat (&startstop, drive,ATA_DRQ ,ATA_BUSY , +WAIT_READY )) {
IIRC similar check was removed from ide-cd so maybe this one is also unnecessary?
drivers/ide/ide-atapi.c ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout, · line 574
Quoted 13 lines
drivers/ide/ide-atapi.c +4
-2printk (KERN_ERR "%s: Strange, packet command initiated yet " "DRQ isn't asserted\n" , drive->name);return startstop;@@ -562,8 +568,10 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,ide_dma_off (drive); } -if ((pc->flags &PC_FLAG_DMA_OK ) && - (drive->dev_flags &IDE_DFLAG_USING_DMA )) { +if (((pc->flags &PC_FLAG_DMA_OK ) && + (drive->dev_flags &IDE_DFLAG_USING_DMA )) || + ((drive->media == ide_cdrom || drive->media == ide_optical) && + drive->dma)) {
drive->dma is only set by ide-cd so no need to check for media type, also I think that it better fits in some later patch.
drivers/ide/ide-atapi.c ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout, · line 594
Quoted 12 lines
drivers/ide/ide-atapi.c +2
-0if (scsi) hwif->sg_mapped =1 ; drive->dma = !hwif->dma_ops->dma_setup (drive);@@ -579,6 +587,8 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,/* Issue the packet command */ if (drive->atapi_flags &IDE_AFLAG_DRQ_INTERRUPT ) { +if (drive->dma) + drive->waiting_for_dma =0 ;ide_execute_command (drive,ATA_CMD_PACKET , ide_transfer_pc, timeout,NULL );return ide_started;
Please recast the patch to have only ->waiting_for_dma change. Thanks.
Re: [PATCH 03/10] ide-atapi: teach ide atapi about drive->waiting_for_dma
Hi,
Quoted 29 lines · Bartlomiej Zolnierkiewicz
Quoted 16 lines · On Sunday 14 September 2008 13:35:51 Borislav Petkov wrote:
This is in preparation for converting ide-cd to generic code. The actual rewiring will be done later after the issue_pc/transfer_pc code knows all about ide-cd.
There should be no functional change resulting from this patch.
Signed-off-by Borislav Petkov <[email protected]>--- drivers/ide/ide-atapi.c | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)drivers/ide/ide-atapi.c +0
-0drivers/ide/ide-atapi.c static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) · line 494
Quoted 9 lines
drivers/ide/ide-atapi.c +5
-1@@ -487,7 +487,13 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)ide_startstop_t startstop;u8 ireason; -if (ide_wait_stat (&startstop, drive,ATA_DRQ ,ATA_BUSY ,WAIT_READY )) { +if ((drive->media == ide_cdrom || drive->media == ide_optical) && + (drive->atapi_flags &IDE_AFLAG_DRQ_INTERRUPT )) { +if (drive->dma) + drive->waiting_for_dma =1 ; + }We really want to do this for all ATAPI devices (as a bugfix).
Quoted 5 lines
drivers/ide/ide-atapi.c static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) · line 496
Quoted 2 lines
drivers/ide/ide-atapi.c +2
-0+else if (ide_wait_stat (&startstop, drive,ATA_DRQ ,ATA_BUSY , +WAIT_READY )) {IIRC similar check was removed from ide-cd so maybe this one is also unnecessary?
Well, according to SFF8020, this chunk is for drives which don't support the "Accelerated DRQ" command packet DRQ type and those drives can set the DRQ bit as late as 10ms after receiving the PACKET command and I guess those are really old. I don't know whether it will be completely safe to remove it - for that decision i'm too early in the game :). Anyways, a quick google scan returns several bug reports in the past hitting that with ide-scsi, ide-floppy and ide-tape but those are either _really_ old or hint at hardware problems with the device...
Signature · 2 lines
Regards/Gruss,
Boris.Re: [PATCH 03/10] ide-atapi: teach ide atapi about drive->waiting_for_dma
Quoted 37 lines · On Wednesday 17 September 2008 03:05:12 Borislav Petkov wrote:
Hi,
Quoted 34 lines · Bartlomiej Zolnierkiewicz
Quoted 16 lines · On Sunday 14 September 2008 13:35:51 Borislav Petkov wrote:
This is in preparation for converting ide-cd to generic code. The actual rewiring will be done later after the issue_pc/transfer_pc code knows all about ide-cd.
There should be no functional change resulting from this patch.
Signed-off-by Borislav Petkov <[email protected]>--- drivers/ide/ide-atapi.c | 16 +++++++++++++--- 1 files changed, 13 insertions(+), 3 deletions(-)drivers/ide/ide-atapi.c +0
-0drivers/ide/ide-atapi.c static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) · line 494
Quoted 9 lines
drivers/ide/ide-atapi.c +5
-1@@ -487,7 +487,13 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)ide_startstop_t startstop;u8 ireason; -if (ide_wait_stat (&startstop, drive,ATA_DRQ ,ATA_BUSY ,WAIT_READY )) { +if ((drive->media == ide_cdrom || drive->media == ide_optical) && + (drive->atapi_flags &IDE_AFLAG_DRQ_INTERRUPT )) { +if (drive->dma) + drive->waiting_for_dma =1 ; + }We really want to do this for all ATAPI devices (as a bugfix).
drivers/ide/ide-atapi.c static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) · line 496
Quoted 2 lines
drivers/ide/ide-atapi.c +2
-0+else if (ide_wait_stat (&startstop, drive,ATA_DRQ ,ATA_BUSY , +WAIT_READY )) {IIRC similar check was removed from ide-cd so maybe this one is also unnecessary?
[ actually, I mistook it for cdrom_start_packet_command() check ]
Quoted 4 lines
Well, according to SFF8020, this chunk is for drives which don't support the "Accelerated DRQ" command packet DRQ type and those drives can set the DRQ bit as late as 10ms after receiving the PACKET command and I guess those are really old. I don't know whether it will be completely safe to remove it - for that
In this case we may as well do the wait on ide-cd devices.
Thanks,
Bart
PATCH 4/10 ide-atapi: assign taskfile flags per device type
In reply to Borislav PetkovThere should be no functional change resulting from this patch.
--- drivers/ide/ide-atapi.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
drivers/ide/ide-atapi.c +9 -2
@@ -550,6 +550,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout, {struct ide_atapi_pc *pc = drive->pc;ide_hwif_t *hwif = drive->hwif; +u32 tf_flags;u16 bcount;u8 scsi = !!(drive->dev_flags &IDE_DFLAG_SCSI );
@@ -582,8 +583,14 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,if (!drive->dma) pc->flags &= ~PC_FLAG_DMA_OK ; -ide_pktcmd_tf_load (drive, scsi ?0 :IDE_TFLAG_OUT_DEVICE , bcount, - drive->dma); +if (scsi) + tf_flags =0 ; +else if (drive->media == ide_cdrom || drive->media == ide_optical) + tf_flags =IDE_TFLAG_OUT_NSECT |IDE_TFLAG_OUT_LBAL ; +else + tf_flags =IDE_TFLAG_OUT_DEVICE ; + +ide_pktcmd_tf_load (drive, tf_flags, bcount, drive->dma);/* Issue the packet command */ if (drive->atapi_flags &IDE_AFLAG_DRQ_INTERRUPT ) {
Signature · 1 line
1.5.5.1
Bartlomiej Zolnierkiewicz
AppliedRe: [PATCH 04/10] ide-atapi: assign taskfile flags per device type
Quoted 3 lines · On Sunday 14 September 2008 13:35:52 Borislav Petkov wrote:
There should be no functional change resulting from this patch.
Signed-off-by Borislav Petkov <[email protected]>
applied
PATCH 5/10 ide-atapi: accomodate transfer length to ide-cd
In reply to Borislav PetkovThere should be no functional change resulting from this patch.
--- drivers/ide/ide-atapi.c | 4 +++- drivers/ide/ide-floppy.c | 2 +- drivers/ide/ide-tape.c | 2 +- drivers/scsi/ide-scsi.c | 3 ++- include/linux/ide.h | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-)
drivers/ide/ide-atapi.c +3 -1
@@ -546,7 +546,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) }ide_startstop_t ide_issue_pc (ide_drive_t *drive,unsigned int timeout, -ide_expiry_t *expiry) +ide_expiry_t *expiry,int xferlen) {struct ide_atapi_pc *pc = drive->pc;ide_hwif_t *hwif = drive->hwif;
@@ -561,6 +561,8 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,/* Request to transfer the entire buffer at once */ if (drive->media == ide_tape && scsi ==0 ) bcount = pc->req_xfer; +else if (drive->media == ide_cdrom || drive->media == ide_optical) + bcount = xferlen;else bcount =min (pc->req_xfer,63 *1024 );
drivers/ide/ide-floppy.c +1 -1
@@ -246,7 +246,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, pc->retries++; -return ide_issue_pc (drive,WAIT_FLOPPY_CMD ,NULL ); +return ide_issue_pc (drive,WAIT_FLOPPY_CMD ,NULL ,0 ); }void ide_floppy_create_read_capacity_cmd (struct ide_atapi_pc *pc)
drivers/ide/ide-tape.c +1 -1
@@ -694,7 +694,7 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, pc->retries++; -return ide_issue_pc (drive,WAIT_TAPE_CMD ,NULL ); +return ide_issue_pc (drive,WAIT_TAPE_CMD ,NULL ,0 ); }/* A mode sense command is used to "sense" tape parameters. */
drivers/scsi/ide-scsi.c +2 -1
@@ -315,7 +315,8 @@ static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive,/* Set the current packet command */ drive->pc = pc; -return ide_issue_pc (drive,ide_scsi_get_timeout (pc), ide_scsi_expiry); +return ide_issue_pc (drive,ide_scsi_get_timeout (pc), + ide_scsi_expiry,0 ); }/*
include/linux/ide.h +1 -1
@@ -1233,7 +1233,7 @@ static inline unsigned long ide_scsi_get_timeout(struct ide_atapi_pc *pc)int ide_scsi_expiry (ide_drive_t *); -ide_startstop_t ide_issue_pc (ide_drive_t *,unsigned int ,ide_expiry_t *); +ide_startstop_t ide_issue_pc (ide_drive_t *,unsigned int ,ide_expiry_t *,int );ide_startstop_t do_rw_taskfile (ide_drive_t *,ide_task_t *);
Signature · 1 line
1.5.5.1
Re: [PATCH 05/10] ide-atapi: accomodate transfer length to ide-cd
Quoted 25 lines · On Sunday 14 September 2008 13:35:53 Borislav Petkov wrote:
There should be no functional change resulting from this patch.
Signed-off-by Borislav Petkov <[email protected]>--- drivers/ide/ide-atapi.c | 4 +++- drivers/ide/ide-floppy.c | 2 +- drivers/ide/ide-tape.c | 2 +- drivers/scsi/ide-scsi.c | 3 ++- include/linux/ide.h | 2 +- 5 files changed, 8 insertions(+), 5 deletions(-)drivers/ide/ide-atapi.c +1
-1@@ -546,7 +546,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) }ide_startstop_t ide_issue_pc (ide_drive_t *drive,unsigned int timeout, -ide_expiry_t *expiry) +ide_expiry_t *expiry,int xferlen) {struct ide_atapi_pc *pc = drive->pc;ide_hwif_t *hwif = drive->hwif;
drivers/ide/ide-atapi.c ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout, · line 567
Quoted 7 lines
drivers/ide/ide-atapi.c +2
-0@@ -561,6 +561,8 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,/* Request to transfer the entire buffer at once */ if (drive->media == ide_tape && scsi ==0 ) bcount = pc->req_xfer; +else if (drive->media == ide_cdrom || drive->media == ide_optical) + bcount = xferlen;else bcount =min (pc->req_xfer,63 *1024 );
If you move info->last_block to ide_drive_t it is possible to factor out xferlen setup from ide_cd_do_request() to a separate handler and move it here. Then xferlen argument to ide_issue_pc() won't be necessary.
How's about it?
PATCH 6/10 ide-atapi: add a DEV_IS_IDECD macro
In reply to Borislav PetkovThis is a short-term-use one and will be removed later - it is added to solely improve readability.
There should be no functional change resulting from this patch.
--- drivers/ide/ide-atapi.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-)
drivers/ide/ide-atapi.c +7 -5
@@ -477,6 +477,9 @@ static int ide_delayed_transfer_pc(ide_drive_t *drive)return WAIT_FLOPPY_CMD ; } +#define DEV_IS_IDECD (drive) \ + (drive->media == ide_cdrom || drive->media == ide_optical) +static ide_startstop_t ide_transfer_pc (ide_drive_t *drive) {struct ide_atapi_pc *pc = drive->pc;
@@ -487,7 +490,7 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)ide_startstop_t startstop;u8 ireason; -if ((drive->media == ide_cdrom || drive->media == ide_optical) && +if (DEV_IS_IDECD (drive) && (drive->atapi_flags &IDE_AFLAG_DRQ_INTERRUPT )) {if (drive->dma) drive->waiting_for_dma =1 ;
@@ -561,7 +564,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,/* Request to transfer the entire buffer at once */ if (drive->media == ide_tape && scsi ==0 ) bcount = pc->req_xfer; -else if (drive->media == ide_cdrom || drive->media == ide_optical) +else if (DEV_IS_IDECD (drive)) bcount = xferlen;else bcount =min (pc->req_xfer,63 *1024 );
@@ -573,8 +576,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,if (((pc->flags &PC_FLAG_DMA_OK ) && (drive->dev_flags &IDE_DFLAG_USING_DMA )) || - ((drive->media == ide_cdrom || drive->media == ide_optical) && - drive->dma)) { + (DEV_IS_IDECD (drive) && drive->dma)) {if (scsi) hwif->sg_mapped =1 ; drive->dma = !hwif->dma_ops->dma_setup (drive);
@@ -587,7 +589,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,if (scsi) tf_flags =0 ; -else if (drive->media == ide_cdrom || drive->media == ide_optical) +else if (DEV_IS_IDECD (drive)) tf_flags =IDE_TFLAG_OUT_NSECT |IDE_TFLAG_OUT_LBAL ;else tf_flags =IDE_TFLAG_OUT_DEVICE ;
Signature · 1 line
1.5.5.1
Re: [PATCH 06/10] ide-atapi: add a DEV_IS_IDECD macro
Quoted 15 lines · On Sunday 14 September 2008 13:35:54 Borislav Petkov wrote:
This is a short-term-use one and will be removed later - it is added to solely improve readability.
There should be no functional change resulting from this patch.
Signed-off-by Borislav Petkov <[email protected]>--- drivers/ide/ide-atapi.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-)drivers/ide/ide-atapi.c +0
-0
drivers/ide/ide-atapi.c static int ide_delayed_transfer_pc(ide_drive_t *drive) · line 482
Quoted 6 lines
drivers/ide/ide-atapi.c +3
-0@@ -477,6 +477,9 @@ static int ide_delayed_transfer_pc(ide_drive_t *drive)return WAIT_FLOPPY_CMD ; } +#define DEV_IS_IDECD (drive) \ + (drive->media == ide_cdrom || drive->media == ide_optical) +
This needs to check for drive->scsi or the subtle bugs will happen.
Also why not use dev_is_idecd() static inline function instead?
PATCH 7/10 ide-atapi: prepare ide-cd expiry handler
In reply to Borislav PetkovPush ide-cd expiry handler into the ide-cd header. Also, pass expiry handler to ide_execute_command() in ide_issue_pc() for later.
There should be no functional change resulting from this patch.
--- drivers/ide/ide-atapi.c | 6 +++++- drivers/ide/ide-cd.c | 32 -------------------------------- drivers/ide/ide-cd.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 33 deletions(-)
drivers/ide/ide-atapi.c +5 -1
@@ -7,6 +7,8 @@#include <linux/ide.h> #include <scsi/scsi.h> +#include "ide-cd.h" +#ifdef DEBUG #define debug_log(fmt, args...) \ printk(KERN_INFO "ide: " fmt, ## args)
@@ -600,8 +602,10 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,if (drive->atapi_flags &IDE_AFLAG_DRQ_INTERRUPT ) {if (drive->dma) drive->waiting_for_dma =0 ; +ide_execute_command (drive,ATA_CMD_PACKET , ide_transfer_pc, - timeout,NULL ); + timeout, expiry); +return ide_started; }else {ide_execute_pkt_cmd (drive);
drivers/ide/ide-cd.c +0 -32
@@ -512,38 +512,6 @@ end_request:return 1 ; } -static int cdrom_timer_expiry (ide_drive_t *drive) -{ -struct request *rq =HWGROUP (drive)->rq; -unsigned long wait =0 ; - -ide_debug_log (IDE_DBG_RQ ,"Call %s: rq->cmd[0]: 0x%x\n" , __func__, - rq->cmd[0 ]); - -/* -* Some commands are *slow* and normally take a long time to complete. -* Usually we can use the ATAPI "disconnect" to bypass this, but not all -* commands/drives support that. Let ide_timer_expiry keep polling us -* for these. -*/ -switch (rq->cmd[0 ]) { -case GPCMD_BLANK : -case GPCMD_FORMAT_UNIT : -case GPCMD_RESERVE_RZONE_TRACK : -case GPCMD_CLOSE_TRACK : -case GPCMD_FLUSH_CACHE : - wait =ATAPI_WAIT_PC ; -break ; -default : -if (!(rq->cmd_flags &REQ_QUIET )) - printk(KERN_INFO PFX "cmd 0x%x timed out\n", - rq->cmd[0 ]); - wait =0 ; -break ; - } -return wait; -} -/* * Set up the device registers for transferring a packet command on DEV, * expecting to later transfer XFERLEN bytes. HANDLER is the routine
drivers/ide/ide-cd.h +29 -0
@@ -126,4 +126,33 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi);int ide_cdrom_audio_ioctl (struct cdrom_device_info *,unsigned int ,void *);int ide_cdrom_packet (struct cdrom_device_info *,struct packet_command *); +static inline int cdrom_timer_expiry (ide_drive_t *drive) +{ +struct request *rq = drive->hwif->hwgroup->rq; +unsigned long wait =0 ; + +/* +* Some commands are *slow* and normally take a long time to complete. +* Usually we can use the ATAPI "disconnect" to bypass this, but not all +* commands/drives support that. Let ide_timer_expiry keep polling us +* for these. +*/ +switch (rq->cmd[0 ]) { +case GPCMD_BLANK : +case GPCMD_FORMAT_UNIT : +case GPCMD_RESERVE_RZONE_TRACK : +case GPCMD_CLOSE_TRACK : +case GPCMD_FLUSH_CACHE : + wait =ATAPI_WAIT_PC ; +break ; +default : +if (!(rq->cmd_flags &REQ_QUIET )) +printk (KERN_INFO "ide-cd: cmd 0x%x timed out\n" , + rq->cmd[0 ]); + wait =0 ; +break ; + } +return wait; +} +#endif /* _IDE_CD_H */
Signature · 1 line
1.5.5.1
Re: [PATCH 07/10] ide-atapi: prepare ide-cd expiry handler
Quoted 2 lines · On Sunday 14 September 2008 13:35:55 Borislav Petkov wrote:
Push ide-cd expiry handler into the ide-cd header. Also, pass expiry handler to
ide_execute_command()inide_issue_pc()for later.
Uh, no. Please don't include "ide-cd.h" in ide-atapi.c. Instead just move the expiry handler to ide-atapi.c like it was done with ide_scsi_expiry().
It also seems that 'expiry' argument is not needed and expiry handler to use can be deduced from drive->media and drive->scsi.
patches #8-10 look OK on the quick look but since they depend on earlier changes they also need to be updated.
PATCH 8/10 ide-atapi: accomodate to ide-cd-specific handlers
In reply to Borislav Petkov.. for the next phase of ide command execution. Thus, export ide_transfer_pc for the generic users.
There should be no functional change resulting from this patch.
--- drivers/ide/ide-atapi.c | 10 ++++++---- drivers/ide/ide-floppy.c | 2 +- drivers/ide/ide-tape.c | 2 +- drivers/scsi/ide-scsi.c | 2 +- include/linux/ide.h | 4 +++- 5 files changed, 12 insertions(+), 8 deletions(-)
drivers/ide/ide-atapi.c +6 -4
@@ -482,7 +482,7 @@ static int ide_delayed_transfer_pc(ide_drive_t *drive)#define DEV_IS_IDECD (drive) \ (drive->media == ide_cdrom || drive->media == ide_optical) -static ide_startstop_t ide_transfer_pc (ide_drive_t *drive) +ide_startstop_t ide_transfer_pc (ide_drive_t *drive) {struct ide_atapi_pc *pc = drive->pc;ide_hwif_t *hwif = drive->hwif;
@@ -549,9 +549,11 @@ static ide_startstop_t ide_transfer_pc(ide_drive_t *drive)return ide_started; } +EXPORT_SYMBOL_GPL (ide_transfer_pc);ide_startstop_t ide_issue_pc (ide_drive_t *drive,unsigned int timeout, -ide_expiry_t *expiry,int xferlen) +ide_expiry_t *expiry,int xferlen, +ide_handler_t *handler) {struct ide_atapi_pc *pc = drive->pc;ide_hwif_t *hwif = drive->hwif;
@@ -603,13 +605,13 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,if (drive->dma) drive->waiting_for_dma =0 ; -ide_execute_command (drive,ATA_CMD_PACKET , ide_transfer_pc, +ide_execute_command (drive,ATA_CMD_PACKET , handler, timeout, expiry);return ide_started; }else {ide_execute_pkt_cmd (drive); -return ide_transfer_pc (drive); +return (*handler)(drive); } }EXPORT_SYMBOL_GPL (ide_issue_pc);
drivers/ide/ide-floppy.c +1 -1
@@ -246,7 +246,7 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, pc->retries++; -return ide_issue_pc (drive,WAIT_FLOPPY_CMD ,NULL ,0 ); +return ide_issue_pc (drive,WAIT_FLOPPY_CMD ,NULL ,0 , ide_transfer_pc); }void ide_floppy_create_read_capacity_cmd (struct ide_atapi_pc *pc)
drivers/ide/ide-tape.c +1 -1
@@ -694,7 +694,7 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, pc->retries++; -return ide_issue_pc (drive,WAIT_TAPE_CMD ,NULL ,0 ); +return ide_issue_pc (drive,WAIT_TAPE_CMD ,NULL ,0 , ide_transfer_pc); }/* A mode sense command is used to "sense" tape parameters. */
drivers/scsi/ide-scsi.c +1 -1
@@ -316,7 +316,7 @@ static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive, drive->pc = pc;return ide_issue_pc (drive,ide_scsi_get_timeout (pc), - ide_scsi_expiry,0 ); + ide_scsi_expiry,0 , ide_transfer_pc); }/*
include/linux/ide.h +3 -1
@@ -1233,7 +1233,9 @@ static inline unsigned long ide_scsi_get_timeout(struct ide_atapi_pc *pc)int ide_scsi_expiry (ide_drive_t *); -ide_startstop_t ide_issue_pc (ide_drive_t *,unsigned int ,ide_expiry_t *,int ); +ide_startstop_t ide_issue_pc (ide_drive_t *,unsigned int ,ide_expiry_t *,int , +ide_handler_t *); +ide_startstop_t ide_transfer_pc (ide_drive_t *);ide_startstop_t do_rw_taskfile (ide_drive_t *,ide_task_t *);
Signature · 1 line
1.5.5.1
PATCH 9/10 ide-atapi: protect ide_atapi_pc pointer from ide-cd code path
In reply to Borislav Petkov... since it is undefined.
There should be no functional change resulting from this patch.
--- drivers/ide/ide-atapi.c | 27 +++++++++++++++------------ 1 files changed, 15 insertions(+), 12 deletions(-)
drivers/ide/ide-atapi.c +15 -12
@@ -561,9 +561,16 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,u16 bcount;u8 scsi = !!(drive->dev_flags &IDE_DFLAG_SCSI ); -/* We haven't transferred any data yet */ - pc->xferred =0 ; - pc->cur_pos = pc->buf; +if (!DEV_IS_IDECD (drive)) { +/* We haven't transferred any data yet */ + pc->xferred =0 ; + pc->cur_pos = pc->buf; + +if (pc->flags &PC_FLAG_DMA_ERROR ) { + pc->flags &= ~PC_FLAG_DMA_ERROR ; +ide_dma_off (drive); + } + }/* Request to transfer the entire buffer at once */ if (drive->media == ide_tape && scsi ==0 )
@@ -573,14 +580,10 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout,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->dev_flags &IDE_DFLAG_USING_DMA )) || - (DEV_IS_IDECD (drive) && drive->dma)) { +if (drive->dma || + (!DEV_IS_IDECD (drive) && + (pc->flags &PC_FLAG_DMA_OK ) && + (drive->dev_flags &IDE_DFLAG_USING_DMA ))) {if (scsi) hwif->sg_mapped =1 ; drive->dma = !hwif->dma_ops->dma_setup (drive);
@@ -588,7 +591,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout, hwif->sg_mapped =0 ; } -if (!drive->dma) +if (!drive->dma && !DEV_IS_IDECD (drive)) pc->flags &= ~PC_FLAG_DMA_OK ;if (scsi)
Signature · 1 line
1.5.5.1
PATCH 10/10 ide-cd: use generic ide_issue_pc
In reply to Borislav Petkov... and remove cdrom_start_packet_command.
There should be no functional change resulting from this patch.
--- drivers/ide/ide-cd.c | 48 ++++-------------------------------------------- 1 files changed, 4 insertions(+), 44 deletions(-)
drivers/ide/ide-cd.c +4 -44
@@ -513,50 +513,9 @@ end_request: }/* -* Set up the device registers for transferring a packet command on DEV, -* expecting to later transfer XFERLEN bytes. HANDLER is the routine -* which actually transfers the command to the drive. If this is a -* drq_interrupt device, this routine will arrange for HANDLER to be -* called when the interrupt from the drive arrives. Otherwise, HANDLER -* will be called immediately after the drive is prepared for the transfer. -*/ -static ide_startstop_t cdrom_start_packet_command (ide_drive_t *drive, -int xferlen, -ide_handler_t *handler) -{ -ide_hwif_t *hwif = drive->hwif; - -ide_debug_log (IDE_DBG_PC ,"Call %s, xferlen: %d\n" , __func__, xferlen); - -/* FIXME: for Virtual DMA we must check harder */ -if (drive->dma) - drive->dma = !hwif->dma_ops->dma_setup (drive); - -/* set up the controller registers */ -ide_pktcmd_tf_load (drive,IDE_TFLAG_OUT_NSECT |IDE_TFLAG_OUT_LBAL , - xferlen, drive->dma); - -if (drive->atapi_flags &IDE_AFLAG_DRQ_INTERRUPT ) { -/* waiting for CDB interrupt, not DMA yet. */ -if (drive->dma) - drive->waiting_for_dma =0 ; - -/* packet command */ -ide_execute_command (drive,ATA_CMD_PACKET , handler, -ATAPI_WAIT_PC , cdrom_timer_expiry); -return ide_started; - }else { -ide_execute_pkt_cmd (drive); - -return (*handler) (drive); - } -} - -/* * Send a packet command to DRIVE described by CMD_BUF and CMD_LEN. The device -* registers must have already been prepared by cdrom_start_packet_command. -* HANDLER is the interrupt handler to call when the command completes or -* there's data ready. +* registers must have already been prepared by ide_issue_pc. HANDLER is the +* interrupt handler to call when the command completes or there's data ready. */ #define ATAPI_MIN_CDB_BYTES 12 static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive,
@@ -1290,7 +1249,8 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,return ide_stopped; } -return cdrom_start_packet_command (drive, xferlen, fn); +return ide_issue_pc (drive,ATAPI_WAIT_PC , cdrom_timer_expiry, + xferlen, fn); }/*
Signature · 1 line
1.5.5.1
Hi,
Quoted 5 lines · On Sunday 14 September 2008 13:35:48 Borislav Petkov wrote:
Hi Bart,
here are some patches converting ide-cd to using
ide_issue_pc. Next is replacingcdrom_transfer_packet_commandwithide_transfer_pc.
Quoted 8 lines
drivers/ide/ide-atapi.c | 71 ++++++++++++++++++++++--------- drivers/ide/ide-cd.c | 104 ++++++--------------------------------------- drivers/ide/ide-cd.h | 30 +++++++++++++- drivers/ide/ide-floppy.c | 2 +- drivers/ide/ide-tape.c | 2 +- drivers/scsi/ide-scsi.c | 3 +- include/linux/ide.h | 5 ++- 7 files changed, 102 insertions(+), 115 deletions(-)
Thanks for finding time to work on this. Overall it looks good and I applied some patches already (#1/2/4) but the rest would need some final recasting/polishing before they can go in (please see the individual replies for details).
Bart