mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <htejun@gmail.com>
To: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>,
	lkml <linux-kernel@vger.kernel.org>,
	linux-ide <linux-ide@vger.kernel.org>,
	Jeff Garzik <jgarzik@pobox.com>
Subject: Re: [PATCH 2.6.11-rc3 05/11] ide: fixes io_32bit race in ide_taskfile_ioctl()
Date: Thu, 10 Feb 2005 17:38:34 +0900 (KST)	[thread overview]
Message-ID: <20050210083829.8739C4AB@htj.dyndns.org> (raw)
In-Reply-To: <20050210083808.48E9DD1A@htj.dyndns.org>


05_ide_ATA_TFLAG_IO_16BIT.patch

	In ide_taskfile_ioctl(), there was a race condition involving
	drive->io_32bit.  It was cleared and restored during ioctl
	requests but there was no synchronization with other requests.
	So, other requests could execute with the altered io_32bit
	setting or updated drive->io_32bit could be overwritten by
	ide_taskfile_ioctl().

	This patch adds ATA_TFLAG_IO_16BIT flag to indicate to
	ide_pio_datablock() that 16bit IO is needed regardless of
	drive->io_32bit settting.

Signed-off-by: Tejun Heo <htejun@gmail.com>

 drivers/ide/ide-taskfile.c |   14 ++++++++++----
 include/linux/ata.h        |    1 +
 2 files changed, 11 insertions(+), 4 deletions(-)

Index: linux-ide/drivers/ide/ide-taskfile.c
===================================================================
--- linux-ide.orig/drivers/ide/ide-taskfile.c	2005-02-10 17:38:01.172900876 +0900
+++ linux-ide/drivers/ide/ide-taskfile.c	2005-02-10 17:38:01.539839336 +0900
@@ -315,8 +315,15 @@ static void ide_pio_multi(ide_drive_t *d
 static inline void ide_pio_datablock(ide_drive_t *drive, struct request *rq,
 				     unsigned int write)
 {
+	int saved_io_32bit = drive->io_32bit;
+
 	if (rq->bio)	/* fs request */
 		rq->errors = 0;
+	if (rq->flags & REQ_DRIVE_TASKFILE) {
+		ide_task_t *task = rq->special;
+		if (task->flags & ATA_TFLAG_IO_16BIT)
+			drive->io_32bit = 0;
+	}
 
 	switch (drive->hwif->data_phase) {
 	case TASKFILE_MULTI_IN:
@@ -327,6 +334,8 @@ static inline void ide_pio_datablock(ide
 		ide_pio_sector(drive, write);
 		break;
 	}
+
+	drive->io_32bit = saved_io_32bit;
 }
 
 static ide_startstop_t task_error(ide_drive_t *drive, struct request *rq,
@@ -520,7 +529,6 @@ int ide_taskfile_ioctl (ide_drive_t *dri
 	int tasksize		= sizeof(struct ide_task_request_s);
 	int taskin		= 0;
 	int taskout		= 0;
-	u8 io_32bit		= drive->io_32bit;
 	char __user *buf = (char __user *)arg;
 
 //	printk("IDE Taskfile ...\n");
@@ -573,10 +581,10 @@ int ide_taskfile_ioctl (ide_drive_t *dri
 	args.data_phase   = req_task->data_phase;
 	args.command_type = req_task->req_cmd;
 
+	args.flags = ATA_TFLAG_IO_16BIT;
 	if (drive->addressing == 1)
 		args.flags |= ATA_TFLAG_LBA48;
 
-	drive->io_32bit = 0;
 	switch(req_task->data_phase) {
 		case TASKFILE_OUT_DMAQ:
 		case TASKFILE_OUT_DMA:
@@ -656,8 +664,6 @@ abort:
 
 //	printk("IDE Taskfile ioctl ended. rc = %i\n", err);
 
-	drive->io_32bit = io_32bit;
-
 	return err;
 }
 
Index: linux-ide/include/linux/ata.h
===================================================================
--- linux-ide.orig/include/linux/ata.h	2005-02-10 17:31:48.610711131 +0900
+++ linux-ide/include/linux/ata.h	2005-02-10 17:38:01.540839168 +0900
@@ -174,6 +174,7 @@ enum {
 	ATA_TFLAG_ISADDR	= (1 << 1), /* enable r/w to nsect/lba regs */
 	ATA_TFLAG_DEVICE	= (1 << 2), /* enable r/w to device reg */
 	ATA_TFLAG_WRITE		= (1 << 3), /* data dir: host->dev==1 (write) */
+	ATA_TFLAG_IO_16BIT	= (1 << 4), /* force 16bit pio */
 };
 
 enum ata_tf_protocols {

  parent reply	other threads:[~2005-02-10  8:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-10  8:38 [PATCH 2.6.11-rc3 00/11] ide: ide driver updates series 2, round 2 Tejun Heo
2005-02-10  8:38 ` [PATCH 2.6.11-rc3 01/11] ide: task_end_request() fix Tejun Heo
2005-02-24 15:58   ` Bartlomiej Zolnierkiewicz
2005-02-27  6:49     ` Tejun Heo
2005-03-01 14:30       ` Bartlomiej Zolnierkiewicz
2005-03-01 16:49         ` Tejun Heo
2005-03-02 16:15           ` Bartlomiej Zolnierkiewicz
2005-03-02  5:56         ` Jeff Garzik
2005-03-02 16:07           ` Bartlomiej Zolnierkiewicz
2005-02-10  8:38 ` [PATCH 2.6.11-rc3 02/11] ide: ide_init_drive_cmd() now defaults to REQ_DRIVE_TASKFILE Tejun Heo
2005-02-10  8:38 ` [PATCH 2.6.11-rc3 03/11] ide: ide_diag_taskfile() rq initialization fix Tejun Heo
2005-02-10  8:38 ` [PATCH 2.6.11-rc3 04/11] ide: removes unneeded HOB access using ATA_TFLAG_LBA48 flag Tejun Heo
2005-02-10  8:38 ` Tejun Heo [this message]
2005-02-11 21:16   ` [PATCH 2.6.11-rc3 05/11] ide: fixes io_32bit race in ide_taskfile_ioctl() Bartlomiej Zolnierkiewicz
2005-02-10  8:38 ` [PATCH 2.6.11-rc3 06/11] ide: make disk flush functions use TASKFILE instead of TASK Tejun Heo
2005-02-10  8:38 ` [PATCH 2.6.11-rc3 07/11] ide: make ide_task_ioctl() use TASKFILE Tejun Heo
2005-02-10  8:38 ` [PATCH 2.6.11-rc3 08/11] ide: remove REQ_DRIVE_TASK handling Tejun Heo
2005-02-24 15:45   ` Bartlomiej Zolnierkiewicz
2005-02-10  8:38 ` [PATCH 2.6.11-rc3 09/11] ide: convert uses of REQ_DRIVE_CMD to REQ_DRIVE_TASKFILE Tejun Heo
2005-02-10  8:38 ` [PATCH 2.6.11-rc3 10/11] ide: make ide_cmd_ioctl() use TASKFILE Tejun Heo
2005-02-24 15:50   ` Bartlomiej Zolnierkiewicz
2005-02-27  6:53     ` Tejun Heo
2005-02-27  7:41       ` Jeff Garzik
2005-02-10  8:39 ` [PATCH 2.6.11-rc3 11/11] ide: remove REQ_DRIVE_CMD handling Tejun Heo

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=20050210083829.8739C4AB@htj.dyndns.org \
    --to=htejun@gmail.com \
    --cc=bzolnier@gmail.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®