Re: [PATCH 04/10] ide-atapi: assign taskfile flags per device type

Previous thread: [PATCH] x86: simpler SYSVIPC_COMPAT definition by Alexey Dobriyan on Sunday, September 14, 2008 - 2:44 am. (2 messages)

Next thread: Kernel upgarde causes IPTABLES SAME not working for me by Wennie V. Lagmay on Sunday, September 14, 2008 - 5:04 am. (3 messages)
From: Borislav Petkov
Date: Sunday, September 14, 2008 - 4:35 am

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(-)
--

From: Borislav Petkov
Date: Sunday, September 14, 2008 - 4:35 am

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 <petkovbb@gmail.com>
---
 drivers/ide/ide-atapi.c |    9 +++++----
 include/linux/ide.h     |    1 +
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index a1d8c35..d557841 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -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) {
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 540959f..7c1b00a 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -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 */
-- 
1.5.5.1

--

From: Bartlomiej Zolnierkiewicz
Date: Monday, September 15, 2008 - 10:51 am

applied
--

From: Borislav Petkov
Date: Sunday, September 14, 2008 - 4:35 am

There should be no functionality change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
 drivers/ide/ide-cd.c |   32 ++++++++++++++------------------
 drivers/ide/ide-cd.h |    1 -
 2 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 24d1e69..6258c5f 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -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, ...
From: Bartlomiej Zolnierkiewicz
Date: Monday, September 15, 2008 - 10:54 am

applied
--

From: Borislav Petkov
Date: Sunday, September 14, 2008 - 4:35 am

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 <petkovbb@gmail.com>
---
 drivers/ide/ide-atapi.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index d557841..763acd7 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -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;
-- 
1.5.5.1

--

From: Bartlomiej Zolnierkiewicz
Date: Monday, September 15, 2008 - 11:15 am

IIRC similar check was removed from ide-cd so maybe this one

drive->dma is only set by ide-cd so no need to check for media type,

Please recast the patch to have only ->waiting_for_dma change.  Thanks.
--

From: Borislav Petkov
Date: Wednesday, September 17, 2008 - 3:05 am

Hi,


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...

-- 
Regards/Gruss,
    Boris.
--

From: Bartlomiej Zolnierkiewicz
Date: Wednesday, September 17, 2008 - 9:32 am

In this case we may as well do the wait on ide-cd devices.

Thanks,
Bart
--

From: Borislav Petkov
Date: Sunday, September 14, 2008 - 4:35 am

.. 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.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
 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(-)

diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 480b9f3..733a75a 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -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);
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 3a03e0c..4629e9a 100644
--- a/drivers/ide/ide-floppy.c
+++ ...
From: Borislav Petkov
Date: Sunday, September 14, 2008 - 4:35 am

There should be no functional change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
 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(-)

diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index df17401..7045d34 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -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);
 
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index cf0aa25..3a03e0c 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -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)
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 1ea9049..0ab3766 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -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 ...
From: Bartlomiej Zolnierkiewicz
Date: Monday, September 15, 2008 - 11:15 am

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?
--

From: Borislav Petkov
Date: Sunday, September 14, 2008 - 4:35 am

There should be no functional change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
 drivers/ide/ide-atapi.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 763acd7..df17401 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -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) {
-- 
1.5.5.1

--

From: Bartlomiej Zolnierkiewicz
Date: Monday, September 15, 2008 - 10:54 am

applied
--

From: Borislav Petkov
Date: Sunday, September 14, 2008 - 4:35 am

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 <petkovbb@gmail.com>
---
 drivers/ide/ide-atapi.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 7045d34..e1fa52d 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -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,
 
 ...
From: Bartlomiej Zolnierkiewicz
Date: Monday, September 15, 2008 - 11:19 am

This needs to check for drive->scsi or the subtle bugs will happen.

Also why not use dev_is_idecd() static inline function instead?
--

From: Borislav Petkov
Date: Sunday, September 14, 2008 - 4:35 am

... since it is undefined.

There should be no functional change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
 drivers/ide/ide-atapi.c |   27 +++++++++++++++------------
 1 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 733a75a..45e88a9 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -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)
-- 
1.5.5.1

--

From: Borislav Petkov
Date: Sunday, September 14, 2008 - 4:35 am

... and remove cdrom_start_packet_command.

There should be no functional change resulting from this patch.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
 drivers/ide/ide-cd.c |   48 ++++--------------------------------------------
 1 files changed, 4 insertions(+), 44 deletions(-)

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 29bd205..495e5bb 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -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 ...
From: Borislav Petkov
Date: Sunday, September 14, 2008 - 4:35 am

Push 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.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
 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(-)

diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index e1fa52d..480b9f3 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -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);
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 6258c5f..29bd205 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -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 ...
From: Bartlomiej Zolnierkiewicz
Date: Monday, September 15, 2008 - 11:25 am

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.
--

From: Bartlomiej Zolnierkiewicz
Date: Monday, September 15, 2008 - 11:30 am

Hi,


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
--

Previous thread: [PATCH] x86: simpler SYSVIPC_COMPAT definition by Alexey Dobriyan on Sunday, September 14, 2008 - 2:44 am. (2 messages)

Next thread: Kernel upgarde causes IPTABLES SAME not working for me by Wennie V. Lagmay on Sunday, September 14, 2008 - 5:04 am. (3 messages)