Re: [PATCH] ide-floppy: use scatterlists for pio transfers

Previous thread: Re: [PATCH 3/5] libata: Implement disk shock protection support by Robert Hancock on Monday, August 4, 2008 - 9:16 pm. (2 messages)

Next thread: [PATCH] X86 Architecture: HPET Rework for SB700A12 by crane cai on Monday, August 4, 2008 - 11:20 pm. (1 message)
From: Borislav Petkov
Date: Monday, August 4, 2008 - 10:11 pm

Hi Bart,

here's my first stab at using scatterlists in ide-floppy. I've adapted your
ide-scsi version to fit in here. The change here is that i use pc->b_count as
a sort-of completion counter to know when i'm at the end of the sg element and
be able to switch to the next/finish transfer. I've tested the patch with the
Iomega ZIP drive i have here - it works. We should do some more testing first
though, before sending it upstream.

---
From: Borislav Petkov <petkovbb@gmail.com>
Date: Tue, 5 Aug 2008 06:57:44 +0200
Subject: [PATCH] ide-floppy: use scatterlists for pio transfers

Use hwif->sg_table for pio transfers instead of fumbling
with block layer internals in the driver. Also, make debug
statements more informative in .._do_request() while at it.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
 drivers/ide/ide-floppy.c |   58 +++++++++++++++++++++++++++------------------
 1 files changed, 35 insertions(+), 23 deletions(-)

diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index de8d42b..5820d3a 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -224,29 +224,37 @@ static void ide_floppy_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc,
 				  unsigned int bcount, int direction)
 {
 	ide_hwif_t *hwif = drive->hwif;
-	struct request *rq = pc->rq;
-	struct req_iterator iter;
-	struct bio_vec *bvec;
-	unsigned long flags;
+	const struct ide_tp_ops *tp_ops = hwif->tp_ops;
+	xfer_func_t *xf = direction ? tp_ops->output_data : tp_ops->input_data;
+	struct scatterlist *sg = hwif->sg_table;
+	char *buf;
 	int count, done = 0;
-	char *data;
 
-	rq_for_each_segment(bvec, rq, iter) {
-		if (!bcount)
-			break;
+	while (bcount) {
 
-		count = min(bvec->bv_len, bcount);
-
-		data = bvec_kmap_irq(bvec, &flags);
-		if (direction)
-			hwif->tp_ops->output_data(drive, NULL, data, count);
-		else
-			hwif->tp_ops->input_data(drive, NULL, data, count);
-		bvec_kunmap_irq(data, &flags);
+		count = min(sg->length - ...
From: Bartlomiej Zolnierkiewicz
Date: Wednesday, August 6, 2008 - 9:05 am

Hi,



Don't we also need to zero pc->b_count in idefloppy_blockpc_cmd()?

[ idefloppy_init_pc() clears whole pc so ->b_count assignment
  to zero is not strictly necessary ]

Except that it looks all good, thanks for working on it.
--

From: Borislav Petkov
Date: Wednesday, August 6, 2008 - 12:30 pm

We probably should and i should've probably hit that during testing and maybe
hit an OOPS along that path but we don't do REQ_TYPE_BLOCK_PC in ide-floppy
yet, as it appears, and since idefloppy_blockpc_cmd() is only called when
blk_pc_request(rq) that's why this one doesn't matter here. We should consider
it though when we convert to using BLOCK_PC type rq's.

-- 
Regards/Gruss,
    Boris.
--

From: Bartlomiej Zolnierkiewicz
Date: Thursday, August 7, 2008 - 9:57 am

Unless somebody tries to use SG_IO ioctl (however I don't know if anybody has
actually ever tried so it as well may be that it hasn't worked before...).

Anyway I applied the patch and fixed pc->b_count while at it (just-in-case).
--

Previous thread: Re: [PATCH 3/5] libata: Implement disk shock protection support by Robert Hancock on Monday, August 4, 2008 - 9:16 pm. (2 messages)

Next thread: [PATCH] X86 Architecture: HPET Rework for SB700A12 by crane cai on Monday, August 4, 2008 - 11:20 pm. (1 message)