linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH] 2.5.67-ac2 fix new PIO handlers
Date: Sun, 27 Apr 2003 20:38:45 +0200 (MET DST)	[thread overview]
Message-ID: <Pine.SOL.4.30.0304272011560.27252-200000@mion.elka.pw.edu.pl> (raw)

[-- Attachment #1: Type: TEXT/PLAIN, Size: 509 bytes --]


Hi,

During rewrite of bio walking patch to use rq->cbio instead
of rq->hard_bio I've realized I had screwed orig 2.5.66 patches :\

I somehow forgot to update task_map_rq(), it should use
__bio_kmap_irq(rq->bio, current_idx, flags) instead of
bio_kmap_irq(rq->bio, flags). The result is that you get
bio corruption (-> data corruption) when using PIO multiple
with sectors multiply > 8 (PAGE_SIZE == bio_vec size).

Attached patch fixes it and fixes TASKFILE ioctl.

Please apply to next -ac.
--
Bartlomiej

[-- Attachment #2: Type: TEXT/PLAIN, Size: 5226 bytes --]

# Fix PIO handlers (!).
#
# Detailed changelog:
# - introduce proper task_(un)map_rq() - critical fix
# - fix process_that_request_first() for rq->buffer (non-bio) based requests
# - set rq->hard_nr_sectors and rq->hard_cur_sectors in ide_diag_taskfile()
# - fix PIO handlers for rq->buffer based requests (TASKFILE ioctl)
# - revert ->prehandler() handling for flagged taskfiles as they have their
#   own PIO handlers
#
# Bartlomiej Zolnierkiewicz <bzolnier@elka.pw.edu.pl>

diff -uNr linux-2.5.67-ac2/drivers/block/ll_rw_blk.c linux/drivers/block/ll_rw_blk.c
--- linux-2.5.67-ac2/drivers/block/ll_rw_blk.c	Sun Apr 27 19:54:40 2003
+++ linux/drivers/block/ll_rw_blk.c	Sun Apr 27 19:54:58 2003
@@ -2265,9 +2265,11 @@
 		nsect = min_t(unsigned int, req->current_nr_sectors,
 			      nr_sectors);
 		req->current_nr_sectors -= nsect;
-		req->nr_bio_sectors -= nsect;
 		nr_sectors -= nsect;
-		blk_rq_next_segment(req);
+		if (req->bio) {
+			req->nr_bio_sectors -= nsect;
+			blk_rq_next_segment(req);
+		}
 	}
 	return 1;
 }
diff -uNr linux-2.5.67-ac2/drivers/ide/ide-taskfile.c linux/drivers/ide/ide-taskfile.c
--- linux-2.5.67-ac2/drivers/ide/ide-taskfile.c	Sun Apr 27 19:54:40 2003
+++ linux/drivers/ide/ide-taskfile.c	Sun Apr 27 19:58:41 2003
@@ -59,9 +59,6 @@
 #define DTF(x...)
 #endif
 
-#define task_map_rq(rq, flags)		ide_map_buffer((rq), (flags))
-#define task_unmap_rq(rq, buf, flags)	ide_unmap_buffer((rq), (buf), (flags))
-
 static void ata_bswap_data (void *buffer, int wcount)
 {
 	u16 *p = buffer;
@@ -406,6 +403,11 @@
 	while (rq->hard_bio != rq->bio)
 		if (!DRIVER(drive)->end_request(drive, 1, bio_sectors(rq->hard_bio)))
 			return ide_stopped;
+	/* Complete rq->buffer based request (ioctls). */
+	if (!rq->bio && !rq->nr_sectors) {
+		ide_end_drive_cmd(drive, stat, HWIF(drive)->INB(IDE_ERROR_REG));
+		return ide_stopped;
+	}
 
 	rq->errors = 0;
 	task_sectors(drive, rq, 1, PIO_IN);
@@ -452,6 +454,11 @@
 	while (rq->hard_bio != rq->bio)
 		if (!DRIVER(drive)->end_request(drive, 1, bio_sectors(rq->hard_bio)))
 			return ide_stopped;
+	/* Complete rq->buffer based request (ioctls). */
+	if (!rq->bio && !rq->nr_sectors) {
+		ide_end_drive_cmd(drive, stat, HWIF(drive)->INB(IDE_ERROR_REG));
+		return ide_stopped;
+	}
 
 	rq->errors = 0;
 	do {
@@ -510,6 +517,11 @@
 	while (rq->hard_bio != rq->bio)
 		if (!DRIVER(drive)->end_request(drive, 1, bio_sectors(rq->hard_bio)))
 			return ide_stopped;
+	/* Complete rq->buffer based request (ioctls). */
+	if (!rq->bio && !rq->nr_sectors) {
+		ide_end_drive_cmd(drive, stat, HWIF(drive)->INB(IDE_ERROR_REG));
+		return ide_stopped;
+	}
 
 	/* Still data left to transfer. */
 	ide_set_handler(drive, &task_out_intr, WAIT_WORSTCASE, NULL);
@@ -569,6 +581,11 @@
 	while (rq->hard_bio != rq->bio)
 		if (!DRIVER(drive)->end_request(drive, 1, bio_sectors(rq->hard_bio)))
 			return ide_stopped;
+	/* Complete rq->buffer based request (ioctls). */
+	if (!rq->bio && !rq->nr_sectors) {
+		ide_end_drive_cmd(drive, stat, HWIF(drive)->INB(IDE_ERROR_REG));
+		return ide_stopped;
+	}
 
 	/* Still data left to transfer. */
 	ide_set_handler(drive, &task_mulout_intr, WAIT_WORSTCASE, NULL);
@@ -952,11 +969,12 @@
 	 */
 	if (args->command_type != IDE_DRIVE_TASK_NO_DATA) {
 		if (data_size == 0)
-			rq.current_nr_sectors = rq.nr_sectors = (args->hobRegister[IDE_NSECTOR_OFFSET_HOB] << 8) | args->tfRegister[IDE_NSECTOR_OFFSET];
-		/*	rq.hard_cur_sectors	*/
+			rq.nr_sectors = (args->hobRegister[IDE_NSECTOR_OFFSET_HOB] << 8) | args->tfRegister[IDE_NSECTOR_OFFSET];
 		else
-			rq.current_nr_sectors = rq.nr_sectors = data_size / SECTOR_SIZE;
-		/*	rq.hard_cur_sectors	*/
+			rq.nr_sectors = data_size / SECTOR_SIZE;
+
+		rq.hard_nr_sectors = rq.nr_sectors;
+		rq.hard_cur_sectors = rq.current_nr_sectors = rq.nr_sectors;
 	}
 
 	if (args->tf_out_flags.all == 0) {
@@ -1549,14 +1567,10 @@
  			if (task->handler == NULL)
 				return ide_stopped;
 
-			if (task->prehandler != NULL) {
-				hwif->OUTBSYNC(drive, taskfile->command, IDE_COMMAND_REG);
-				ndelay(400);	/* FIXME */
-				return task->prehandler(drive, HWGROUP(drive)->rq);
-			}
-
 			/* Issue the command */
 			ide_execute_command(drive, taskfile->command, task->handler, WAIT_WORSTCASE, NULL);
+			if (task->prehandler != NULL)
+				return task->prehandler(drive, HWGROUP(drive)->rq);
 	}
 
 	return ide_started;
diff -uNr linux-2.5.67-ac2/include/linux/ide.h linux/include/linux/ide.h
--- linux-2.5.67-ac2/include/linux/ide.h	Sun Apr 27 19:54:40 2003
+++ linux/include/linux/ide.h	Sun Apr 27 20:00:28 2003
@@ -832,6 +832,26 @@
 	ide_startstop_t (*ide_dma_queued_start)(ide_drive_t *drive);
 } ide_dma_ops_t;
 
+static inline void *task_map_rq(struct request *rq, unsigned long *flags)
+{
+	/*
+	 * fs request
+	 */
+	if (rq->bio)
+		return rq_map_buffer(rq, flags);
+
+	/*
+	 * task request
+	 */
+	return rq->buffer + blk_rq_offset(rq);
+}
+
+static inline void task_unmap_rq(struct request *rq, char *buffer, unsigned long *flags)
+{
+	if (rq->bio)
+		rq_unmap_buffer(buffer, flags);
+}
+
 /*
  * mapping stuff, prepare for highmem...
  * 

             reply	other threads:[~2003-04-27 18:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-27 18:38 Bartlomiej Zolnierkiewicz [this message]
2003-04-28  1:45 ` [PATCH] 2.5.67-ac2 fix new PIO handlers Osamu Tomita
2003-04-28 13:10   ` Bartlomiej Zolnierkiewicz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.SOL.4.30.0304272011560.27252-200000@mion.elka.pw.edu.pl \
    --to=b.zolnierkiewicz@elka.pw.edu.pl \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).