linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/10] ide-cd: use generic ide_issue_pc
@ 2008-09-14 11:35 Borislav Petkov
  2008-09-14 11:35 ` [PATCH 01/10] ide: add ide_drive_t.dma flag Borislav Petkov
                   ` (10 more replies)
  0 siblings, 11 replies; 21+ messages in thread
From: Borislav Petkov @ 2008-09-14 11:35 UTC (permalink / raw)
  To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 01/10] ide: add ide_drive_t.dma flag
  2008-09-14 11:35 [PATCH 00/10] ide-cd: use generic ide_issue_pc Borislav Petkov
@ 2008-09-14 11:35 ` Borislav Petkov
  2008-09-15 17:51   ` Bartlomiej Zolnierkiewicz
  2008-09-14 11:35 ` [PATCH 02/10] ide-cd: move cdrom_info.dma to ide_drive_t.dma Borislav Petkov
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Borislav Petkov @ 2008-09-14 11:35 UTC (permalink / raw)
  To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov

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


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 02/10] ide-cd: move cdrom_info.dma to ide_drive_t.dma
  2008-09-14 11:35 [PATCH 00/10] ide-cd: use generic ide_issue_pc Borislav Petkov
  2008-09-14 11:35 ` [PATCH 01/10] ide: add ide_drive_t.dma flag Borislav Petkov
@ 2008-09-14 11:35 ` Borislav Petkov
  2008-09-15 17:54   ` Bartlomiej Zolnierkiewicz
  2008-09-14 11:35 ` [PATCH 03/10] ide-atapi: teach ide atapi about drive->waiting_for_dma Borislav Petkov
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Borislav Petkov @ 2008-09-14 11:35 UTC (permalink / raw)
  To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov

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, 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);
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h
index 61a4599..5882b9a 100644
--- a/drivers/ide/ide-cd.h
+++ b/drivers/ide/ide-cd.h
@@ -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;
 
-- 
1.5.5.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 03/10] ide-atapi: teach ide atapi about drive->waiting_for_dma
  2008-09-14 11:35 [PATCH 00/10] ide-cd: use generic ide_issue_pc Borislav Petkov
  2008-09-14 11:35 ` [PATCH 01/10] ide: add ide_drive_t.dma flag Borislav Petkov
  2008-09-14 11:35 ` [PATCH 02/10] ide-cd: move cdrom_info.dma to ide_drive_t.dma Borislav Petkov
@ 2008-09-14 11:35 ` Borislav Petkov
  2008-09-15 18:15   ` Bartlomiej Zolnierkiewicz
  2008-09-14 11:35 ` [PATCH 04/10] ide-atapi: assign taskfile flags per device type Borislav Petkov
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Borislav Petkov @ 2008-09-14 11:35 UTC (permalink / raw)
  To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov

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


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 04/10] ide-atapi: assign taskfile flags per device type
  2008-09-14 11:35 [PATCH 00/10] ide-cd: use generic ide_issue_pc Borislav Petkov
                   ` (2 preceding siblings ...)
  2008-09-14 11:35 ` [PATCH 03/10] ide-atapi: teach ide atapi about drive->waiting_for_dma Borislav Petkov
@ 2008-09-14 11:35 ` Borislav Petkov
  2008-09-15 17:54   ` Bartlomiej Zolnierkiewicz
  2008-09-14 11:35 ` [PATCH 05/10] ide-atapi: accomodate transfer length to ide-cd Borislav Petkov
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Borislav Petkov @ 2008-09-14 11:35 UTC (permalink / raw)
  To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov

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


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 05/10] ide-atapi: accomodate transfer length to ide-cd
  2008-09-14 11:35 [PATCH 00/10] ide-cd: use generic ide_issue_pc Borislav Petkov
                   ` (3 preceding siblings ...)
  2008-09-14 11:35 ` [PATCH 04/10] ide-atapi: assign taskfile flags per device type Borislav Petkov
@ 2008-09-14 11:35 ` Borislav Petkov
  2008-09-15 18:15   ` Bartlomiej Zolnierkiewicz
  2008-09-14 11:35 ` [PATCH 06/10] ide-atapi: add a DEV_IS_IDECD macro Borislav Petkov
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Borislav Petkov @ 2008-09-14 11:35 UTC (permalink / raw)
  To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov

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 sense command is used to "sense" tape parameters. */
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 8723182..825b890 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -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);
 }
 
 /*
diff --git a/include/linux/ide.h b/include/linux/ide.h
index 7c1b00a..e431e33 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -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 *);
 
-- 
1.5.5.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 06/10] ide-atapi: add a DEV_IS_IDECD macro
  2008-09-14 11:35 [PATCH 00/10] ide-cd: use generic ide_issue_pc Borislav Petkov
                   ` (4 preceding siblings ...)
  2008-09-14 11:35 ` [PATCH 05/10] ide-atapi: accomodate transfer length to ide-cd Borislav Petkov
@ 2008-09-14 11:35 ` Borislav Petkov
  2008-09-15 18:19   ` Bartlomiej Zolnierkiewicz
  2008-09-14 11:35 ` [PATCH 07/10] ide-atapi: prepare ide-cd expiry handler Borislav Petkov
                   ` (4 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Borislav Petkov @ 2008-09-14 11:35 UTC (permalink / raw)
  To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov

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,
 
 	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;
-- 
1.5.5.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 07/10] ide-atapi: prepare ide-cd expiry handler
  2008-09-14 11:35 [PATCH 00/10] ide-cd: use generic ide_issue_pc Borislav Petkov
                   ` (5 preceding siblings ...)
  2008-09-14 11:35 ` [PATCH 06/10] ide-atapi: add a DEV_IS_IDECD macro Borislav Petkov
@ 2008-09-14 11:35 ` Borislav Petkov
  2008-09-15 18:25   ` Bartlomiej Zolnierkiewicz
  2008-09-14 11:35 ` [PATCH 08/10] ide-atapi: accomodate to ide-cd-specific handlers Borislav Petkov
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 21+ messages in thread
From: Borislav Petkov @ 2008-09-14 11:35 UTC (permalink / raw)
  To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov

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 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
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h
index 5882b9a..69c456f 100644
--- a/drivers/ide/ide-cd.h
+++ b/drivers/ide/ide-cd.h
@@ -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 */
-- 
1.5.5.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 08/10] ide-atapi: accomodate to ide-cd-specific handlers
  2008-09-14 11:35 [PATCH 00/10] ide-cd: use generic ide_issue_pc Borislav Petkov
                   ` (6 preceding siblings ...)
  2008-09-14 11:35 ` [PATCH 07/10] ide-atapi: prepare ide-cd expiry handler Borislav Petkov
@ 2008-09-14 11:35 ` Borislav Petkov
  2008-09-14 11:35 ` [PATCH 09/10] ide-atapi: protect ide_atapi_pc pointer from ide-cd code path Borislav Petkov
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 21+ messages in thread
From: Borislav Petkov @ 2008-09-14 11:35 UTC (permalink / raw)
  To: bzolnier; +Cc: linux-kernel, linux-ide, 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.

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
+++ 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, 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)
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 0ab3766..f327a1b 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, 0);
+	return ide_issue_pc(drive, WAIT_TAPE_CMD, NULL, 0, ide_transfer_pc);
 }
 
 /* A mode sense command is used to "sense" tape parameters. */
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 825b890..737e369 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -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);
 }
 
 /*
diff --git a/include/linux/ide.h b/include/linux/ide.h
index e431e33..e6e8833 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -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 *);
 
-- 
1.5.5.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 09/10] ide-atapi: protect ide_atapi_pc pointer from ide-cd code path
  2008-09-14 11:35 [PATCH 00/10] ide-cd: use generic ide_issue_pc Borislav Petkov
                   ` (7 preceding siblings ...)
  2008-09-14 11:35 ` [PATCH 08/10] ide-atapi: accomodate to ide-cd-specific handlers Borislav Petkov
@ 2008-09-14 11:35 ` Borislav Petkov
  2008-09-14 11:35 ` [PATCH 10/10] ide-cd: use generic ide_issue_pc Borislav Petkov
  2008-09-15 18:30 ` [PATCH 00/10] " Bartlomiej Zolnierkiewicz
  10 siblings, 0 replies; 21+ messages in thread
From: Borislav Petkov @ 2008-09-14 11:35 UTC (permalink / raw)
  To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov

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


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 10/10] ide-cd: use generic ide_issue_pc
  2008-09-14 11:35 [PATCH 00/10] ide-cd: use generic ide_issue_pc Borislav Petkov
                   ` (8 preceding siblings ...)
  2008-09-14 11:35 ` [PATCH 09/10] ide-atapi: protect ide_atapi_pc pointer from ide-cd code path Borislav Petkov
@ 2008-09-14 11:35 ` Borislav Petkov
  2008-09-15 18:30 ` [PATCH 00/10] " Bartlomiej Zolnierkiewicz
  10 siblings, 0 replies; 21+ messages in thread
From: Borislav Petkov @ 2008-09-14 11:35 UTC (permalink / raw)
  To: bzolnier; +Cc: linux-kernel, linux-ide, Borislav Petkov

... 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 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);
 }
 
 /*
-- 
1.5.5.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 01/10] ide: add ide_drive_t.dma flag
  2008-09-14 11:35 ` [PATCH 01/10] ide: add ide_drive_t.dma flag Borislav Petkov
@ 2008-09-15 17:51   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-09-15 17:51 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel, linux-ide, Borislav Petkov

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 <petkovbb@gmail.com>

applied

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 02/10] ide-cd: move cdrom_info.dma to ide_drive_t.dma
  2008-09-14 11:35 ` [PATCH 02/10] ide-cd: move cdrom_info.dma to ide_drive_t.dma Borislav Petkov
@ 2008-09-15 17:54   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-09-15 17:54 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel, linux-ide, Borislav Petkov

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 <petkovbb@gmail.com>

applied

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 04/10] ide-atapi: assign taskfile flags per device type
  2008-09-14 11:35 ` [PATCH 04/10] ide-atapi: assign taskfile flags per device type Borislav Petkov
@ 2008-09-15 17:54   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-09-15 17:54 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel, linux-ide, Borislav Petkov

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 <petkovbb@gmail.com>

applied

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 05/10] ide-atapi: accomodate transfer length to ide-cd
  2008-09-14 11:35 ` [PATCH 05/10] ide-atapi: accomodate transfer length to ide-cd Borislav Petkov
@ 2008-09-15 18:15   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-09-15 18:15 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel, linux-ide, Borislav Petkov

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

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?

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 03/10] ide-atapi: teach ide atapi about drive->waiting_for_dma
  2008-09-14 11:35 ` [PATCH 03/10] ide-atapi: teach ide atapi about drive->waiting_for_dma Borislav Petkov
@ 2008-09-15 18:15   ` Bartlomiej Zolnierkiewicz
  2008-09-17 10:05     ` Borislav Petkov
  0 siblings, 1 reply; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-09-15 18:15 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel, linux-ide, Borislav Petkov

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 <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;
> +	}

We really want to do this for all ATAPI devices (as a bugfix).

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

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

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.

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

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 06/10] ide-atapi: add a DEV_IS_IDECD macro
  2008-09-14 11:35 ` [PATCH 06/10] ide-atapi: add a DEV_IS_IDECD macro Borislav Petkov
@ 2008-09-15 18:19   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-09-15 18:19 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel, linux-ide, Borislav Petkov

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

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

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 07/10] ide-atapi: prepare ide-cd expiry handler
  2008-09-14 11:35 ` [PATCH 07/10] ide-atapi: prepare ide-cd expiry handler Borislav Petkov
@ 2008-09-15 18:25   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-09-15 18:25 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel, linux-ide, Borislav Petkov

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() in ide_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.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 00/10] ide-cd: use generic ide_issue_pc
  2008-09-14 11:35 [PATCH 00/10] ide-cd: use generic ide_issue_pc Borislav Petkov
                   ` (9 preceding siblings ...)
  2008-09-14 11:35 ` [PATCH 10/10] ide-cd: use generic ide_issue_pc Borislav Petkov
@ 2008-09-15 18:30 ` Bartlomiej Zolnierkiewicz
  10 siblings, 0 replies; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-09-15 18:30 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: linux-kernel, linux-ide, Borislav Petkov


Hi,

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

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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 03/10] ide-atapi: teach ide atapi about drive->waiting_for_dma
  2008-09-15 18:15   ` Bartlomiej Zolnierkiewicz
@ 2008-09-17 10:05     ` Borislav Petkov
  2008-09-17 16:32       ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 21+ messages in thread
From: Borislav Petkov @ 2008-09-17 10:05 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: linux-kernel, linux-ide

Hi,

On Mon, Sep 15, 2008 at 08:15:51PM +0200, Bartlomiej Zolnierkiewicz wrote:
> 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 <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;
> > +	}
> 
> We really want to do this for all ATAPI devices (as a bugfix).
> 
> > +	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...

-- 
Regards/Gruss,
    Boris.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 03/10] ide-atapi: teach ide atapi about drive->waiting_for_dma
  2008-09-17 10:05     ` Borislav Petkov
@ 2008-09-17 16:32       ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 21+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-09-17 16:32 UTC (permalink / raw)
  To: petkovbb; +Cc: linux-kernel, linux-ide

On Wednesday 17 September 2008 03:05:12 Borislav Petkov wrote:
> Hi,
> 
> On Mon, Sep 15, 2008 at 08:15:51PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > 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 <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;
> > > +	}
> > 
> > We really want to do this for all ATAPI devices (as a bugfix).
> > 
> > > +	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 ]

> 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

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2008-09-17 16:32 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-14 11:35 [PATCH 00/10] ide-cd: use generic ide_issue_pc Borislav Petkov
2008-09-14 11:35 ` [PATCH 01/10] ide: add ide_drive_t.dma flag Borislav Petkov
2008-09-15 17:51   ` Bartlomiej Zolnierkiewicz
2008-09-14 11:35 ` [PATCH 02/10] ide-cd: move cdrom_info.dma to ide_drive_t.dma Borislav Petkov
2008-09-15 17:54   ` Bartlomiej Zolnierkiewicz
2008-09-14 11:35 ` [PATCH 03/10] ide-atapi: teach ide atapi about drive->waiting_for_dma Borislav Petkov
2008-09-15 18:15   ` Bartlomiej Zolnierkiewicz
2008-09-17 10:05     ` Borislav Petkov
2008-09-17 16:32       ` Bartlomiej Zolnierkiewicz
2008-09-14 11:35 ` [PATCH 04/10] ide-atapi: assign taskfile flags per device type Borislav Petkov
2008-09-15 17:54   ` Bartlomiej Zolnierkiewicz
2008-09-14 11:35 ` [PATCH 05/10] ide-atapi: accomodate transfer length to ide-cd Borislav Petkov
2008-09-15 18:15   ` Bartlomiej Zolnierkiewicz
2008-09-14 11:35 ` [PATCH 06/10] ide-atapi: add a DEV_IS_IDECD macro Borislav Petkov
2008-09-15 18:19   ` Bartlomiej Zolnierkiewicz
2008-09-14 11:35 ` [PATCH 07/10] ide-atapi: prepare ide-cd expiry handler Borislav Petkov
2008-09-15 18:25   ` Bartlomiej Zolnierkiewicz
2008-09-14 11:35 ` [PATCH 08/10] ide-atapi: accomodate to ide-cd-specific handlers Borislav Petkov
2008-09-14 11:35 ` [PATCH 09/10] ide-atapi: protect ide_atapi_pc pointer from ide-cd code path Borislav Petkov
2008-09-14 11:35 ` [PATCH 10/10] ide-cd: use generic ide_issue_pc Borislav Petkov
2008-09-15 18:30 ` [PATCH 00/10] " Bartlomiej Zolnierkiewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).