linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Neil Conway" <nconway_kernel@yahoo.co.uk>
To: Marcelo Tosatti <marcelo@conectiva.com.br>,
	Andre Hedrick <andre@linux-ide.org>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] 2.4.18 IDE corruption (update)
Date: Thu, 9 May 2002 23:53:25 +0100 (BST)	[thread overview]
Message-ID: <20020509225325.10104.qmail@web21506.mail.yahoo.com> (raw)

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

Hi...  This is a slightly "improved" version of the patch I first
floated last week (uses the spinlock now).

Summary: if a channel is shared by a DMA-using disk and a DMA-capable
CD, then loading the ide-cd or ide-scsi modules is liable to kill any
DMA transfers in flight on the disk while initialising the CDROM.  This
can cause serious disk corruption (has on my machine).

(Unless of course I've totally missed the point.)

Andre - can you check that this seems sane to you?

cheers
Neil
PS: bug also exists in 2.5.14, patch for that will go direct to Marcin.


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

[-- Attachment #2: ide_patch_2.4.18_090502.txt --]
[-- Type: text/plain, Size: 1771 bytes --]

--- ide-features.c.orig	Fri Feb  9 19:40:02 2001
+++ ide-features.c	Thu May  9 23:13:29 2002
@@ -281,12 +281,31 @@
  */
 int ide_config_drive_speed (ide_drive_t *drive, byte speed)
 {
+	ide_hwgroup_t *hwgroup = HWGROUP(drive);
 	ide_hwif_t *hwif = HWIF(drive);
 	int	i, error = 1;
-	byte stat;
+	byte stat,unit;
+	unsigned long flags;
+
+	spin_lock_irqsave(&io_request_lock, flags);
+	/*
+	 * The next test is a band-aid.  This is because it's possible to
+	 * enter this routine during DMA transfers, and as soon as we issued
+	 * the SELECT_DRIVE() command below, any such transfer would be hosed.
+	 * The RIGHT way to deal with this is probably either to queue the
+	 * call for execution when the hwgroup isn't busy, OR (dodgy?) to sleep
+	 * right here in this routine until it isn't busy.  We also now have
+	 * to use the io_request_lock spinlock to keep SMP systems honest.
+	 * This lot is temporary, pending a real fix.  NJC 9/5/02
+	 */
+	if (hwgroup->busy) {
+		spin_unlock_irqrestore(&io_request_lock, flags);
+		printk("Argh: hwgroup is busy in ide_config_drive_speed\n");
+		return error;
+	}
 
 #if defined(CONFIG_BLK_DEV_IDEDMA) && !defined(CONFIG_DMA_NONPCI)
-	byte unit = (drive->select.b.unit & 0x01);
+	unit = (drive->select.b.unit & 0x01);
 	outb(inb(hwif->dma_base+2) & ~(1<<(5+unit)), hwif->dma_base+2);
 #endif /* (CONFIG_BLK_DEV_IDEDMA) && !(CONFIG_DMA_NONPCI) */
 
@@ -347,6 +366,7 @@
 	enable_irq(hwif->irq);
 
 	if (error) {
+		spin_unlock_irqrestore(&io_request_lock, flags);
 		(void) ide_dump_status(drive, "set_drive_speed_status", stat);
 		return error;
 	}
@@ -380,6 +400,7 @@
 		case XFER_SW_DMA_0: drive->id->dma_1word |= 0x0101; break;
 		default: break;
 	}
+	spin_unlock_irqrestore(&io_request_lock, flags);
 	return error;
 }
 

                 reply	other threads:[~2002-05-09 22:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20020509225325.10104.qmail@web21506.mail.yahoo.com \
    --to=nconway_kernel@yahoo.co.uk \
    --cc=andre@linux-ide.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    /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).