All of lore.kernel.org
 help / color / mirror / Atom feed
From: "rain.wang" <rain.wang@mic.com.tw>
To: Jens Axboe <axboe@suse.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andre Hedrick <andre@linux-ide.org>
Subject: PATCH RFC :ide_do_reset() fix for 2.5.66
Date: Thu, 03 Apr 2003 16:36:35 +0800	[thread overview]
Message-ID: <3E8BF293.2CC30C1F@mic.com.tw> (raw)
In-Reply-To: 20030403071620.GJ2072@suse.de

[-- Attachment #1: Type: text/plain, Size: 865 bytes --]

Jens Axboe wrote:

> On Thu, Apr 03 2003, rain.wang wrote:
> > Hi Alan,
> >     I found just changing ide_do_reset() to wait till completion can
> > handle the handler race. can this be enough?
>
> This is buggy for a number of reasons. Firstly, how do you make sure
> that someone else doesn't race with your hwif_data manipulation? This
> looks very suspect. By far the worst problem is that you are assuming
> that ide_do_reset() can sleep, when in fact it cannot (just follow the
> various paths into ide_do_request()). You even grab the ide_lock _and_
> disable interrupts yourself prior calling wait_for_completion(), this is
> incredibly broken.
>
> --
> Jens Axboe

Hi,
    Thank you, I'm too young. I should have put this in RFC.
please help me to replace using 'hwif-data', I mainly mean
to let drive reset wait for its clean up complete.

regards
rain.w

[-- Attachment #2: ide-iops.c.diff --]
[-- Type: text/plain, Size: 968 bytes --]

--- /usr/src/linux/drivers/ide/ide-iops.c	Thu Apr  3 14:13:51 2003
+++ ide-iops.c	Thu Apr  3 16:24:31 2003
@@ -1107,6 +1107,10 @@
 	}
 	/* done polling */
 	hwgroup->poll_timeout = 0;
+	
+	/* tell ide_do_reset it complete */
+	complete((struct completion *)hwif->hwif_data);
+
 	return ide_stopped;
 }
 
@@ -1171,6 +1175,10 @@
 		}
 	}
 	hwgroup->poll_timeout = 0;	/* done polling */
+
+	/* tell ide_do_reset it complete */
+	complete((struct completion *)hwif->hwif_data);
+
 	return ide_stopped;
 }
 
@@ -1307,7 +1315,25 @@
 
 ide_startstop_t ide_do_reset (ide_drive_t *drive)
 {
-	return do_reset1(drive, 0);
+	/* 
+	 * Waiting for completion needed.
+	 */
+	ide_hwif_t *hwif;
+	void *old_data;
+	DECLARE_COMPLETION(wait);
+	
+	hwif = HWIF(drive);
+	
+	old_data = hwif->hwif_data;
+	hwif->hwif_data = &wait;
+
+	(void) do_reset1(drive, 0);
+	
+	wait_for_completion(&wait);
+
+	hwif->hwif_data = old_data;
+	
+	return ide_stopped;
 }
 
 EXPORT_SYMBOL(ide_do_reset);

  reply	other threads:[~2003-04-03  8:25 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-22 14:03 2.5.65-ac2 -- hda/ide trouble on ICH4 Dominik Brodowski
2003-03-22 16:35 ` Alan Cox
2003-03-22 16:25   ` Dominik Brodowski
2003-03-22 17:42     ` Alan Cox
2003-03-22 16:39       ` Jan Dittmer
2003-03-23  1:03       ` Dominik Brodowski
2003-03-23 15:47         ` Alan Cox
2003-03-23 14:59           ` Dominik Brodowski
2003-03-23 18:41             ` Alan Cox
2003-03-23 18:15               ` Dominik Brodowski
2003-03-23 18:25                 ` ide: indeed, using list_for_each_entry_safe removes endless looping / hang [Was: Re: 2.5.65-ac2 -- hda/ide trouble on ICH4] Dominik Brodowski
2003-03-23 22:16                   ` Jan Dittmer
2003-03-24 11:08                     ` PROBLEM: linux-2.5.65-ac3 does not boot whith IDE-drivers Norbert Wolff
2003-03-24 13:54                       ` Alan Cox
2003-03-24  9:55                   ` ide: indeed, using list_for_each_entry_safe removes endless looping / hang [Was: Re: 2.5.65-ac2 -- hda/ide trouble on ICH4] Alexander Atanasov
2003-03-24 13:59                     ` Alan Cox
2003-03-24 16:01                       ` Alexander Atanasov
2003-03-24 17:40                         ` Alan Cox
2003-03-24 17:24                           ` Alexander Atanasov
2003-03-25  4:16                             ` Andre Hedrick
2003-03-25 13:59                               ` Alan Cox
2003-03-25 20:05                             ` Bartlomiej Zolnierkiewicz
2003-03-25 20:24                               ` Bartlomiej Zolnierkiewicz
2003-04-03  7:00                           ` PATCH:ide_do_reset() fix for 2.5.66 rain.wang
2003-04-03  7:16                             ` Jens Axboe
2003-04-03  8:36                               ` rain.wang [this message]
2003-04-10  3:37                                 ` [rfc][patch]: fix handler race in HDIO_DRIVE_RESET path for 2.5.67-ac1 rain.wang
2003-03-22 22:03     ` [PATCH] Re: 2.5.65-ac2 -- hda/ide trouble on ICH4 Bartlomiej Zolnierkiewicz
2003-03-22 23:27       ` Alan Cox
2003-03-22 22:33         ` Bartlomiej Zolnierkiewicz
2003-03-23  9:11       ` Dominik Brodowski

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=3E8BF293.2CC30C1F@mic.com.tw \
    --to=rain.wang@mic.com.tw \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=andre@linux-ide.org \
    --cc=axboe@suse.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.