public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Glenn Wurster <gwurster@scs.carleton.ca>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] ide-dma.c, kernel 2.4.23
Date: Sun, 7 Dec 2003 18:00:49 -0500	[thread overview]
Message-ID: <20031207230049.GA1079@desktop> (raw)

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


Greetings.

Attached is a small patch to fix a serious Oops bug in the IDE/DMA
drivers.  It has been written against 2.4.23.  The problem stems from
a null function pointer which is called during configuration of the
IDE controller.  The function pointer is NULL iff DMA is not available
for the drive, so the problem will not be seen on DMA capable IDE
controllers.

I am not subscribed, so please CC me on any followup e-mails.  If you
need more information or wish changes to the patch, you can contact me
directly.  Furthermore, if another patch to fix the same problem has
already been discussed, I would be glad to test it if someone forwards
me a copy.

I can be reached at gwurster@scs.carleton.ca

The patch has been tested against both systems I own, both x86.  One
with a DMA capable IDE controller, the other one (which caused the
oops) without.

Glenn Wurster

[-- Attachment #2: README --]
[-- Type: text/plain, Size: 119 bytes --]

Glenn Wurster (gwurster@scs.carleton.ca)
Avoid NULL function pointer reference on IDE controllers without DMA support.

[-- Attachment #3: dma.patch --]
[-- Type: text/plain, Size: 2389 bytes --]

diff -Naur linux-2.4.23/drivers/ide/ide-dma.c linux/drivers/ide/ide-dma.c
--- linux-2.4.23/drivers/ide/ide-dma.c	Mon Aug 25 11:44:41 2003
+++ linux/drivers/ide/ide-dma.c	Sun Dec  7 04:21:33 2003
@@ -566,6 +566,20 @@
 }
 
 /**
+ *  __ide_dma_no_op  - Empty DMA function.
+ *
+ *  Empty DMA function for controllers that do not support DMA.
+ */
+
+int __ide_dma_no_op (void)
+{
+	return 0;
+}
+
+EXPORT_SYMBOL(__ide_dma_no_op);
+
+
+/**
  *	__ide_dma_host_off	-	Generic DMA kill
  *	@drive: drive to control
  *
@@ -1214,3 +1228,19 @@
 }
 
 EXPORT_SYMBOL_GPL(ide_setup_dma);
+
+/*
+ * For IDE interfaces that do not support DMA, we still need to
+ * initialize some pointers to dummy functions.
+ */
+void ide_setup_no_dma (ide_hwif_t *hwif)
+{
+	if (!hwif->ide_dma_off_quietly)
+		hwif->ide_dma_off_quietly = (int (*)(ide_drive_t *))&__ide_dma_no_op;
+	if (!hwif->ide_dma_host_off)
+		hwif->ide_dma_host_off = (int (*)(ide_drive_t *))&__ide_dma_no_op;
+	if (!hwif->ide_dma_host_on)
+		hwif->ide_dma_host_on = (int (*)(ide_drive_t *))&__ide_dma_no_op;
+}
+
+EXPORT_SYMBOL_GPL(ide_setup_no_dma);
diff -Naur linux-2.4.23/drivers/ide/setup-pci.c linux/drivers/ide/setup-pci.c
--- linux-2.4.23/drivers/ide/setup-pci.c	Mon Aug 25 11:44:41 2003
+++ linux/drivers/ide/setup-pci.c	Fri Dec  5 07:10:50 2003
@@ -507,6 +507,7 @@
 		} else {
 			printk(KERN_INFO "%s: %s Bus-Master DMA disabled "
 				"(BIOS)\n", hwif->name, d->name);
+			ide_setup_no_dma(hwif);
 		}
 	}
 }
diff -Naur linux-2.4.23/include/linux/ide.h linux/include/linux/ide.h
--- linux-2.4.23/include/linux/ide.h	Fri Nov 28 18:26:21 2003
+++ linux/include/linux/ide.h	Fri Dec  5 06:43:46 2003
@@ -1692,7 +1692,10 @@
 extern ide_startstop_t ide_dma_intr(ide_drive_t *);
 extern int ide_release_dma(ide_hwif_t *);
 extern void ide_setup_dma(ide_hwif_t *, unsigned long, unsigned int);
+extern void ide_setup_no_dma(ide_hwif_t *);
+extern void ide_setup_dma_off(ide_hwif_t *);
 
+extern int __ide_dma_no_op(void);
 extern int __ide_dma_host_off(ide_drive_t *);
 extern int __ide_dma_off_quietly(ide_drive_t *);
 extern int __ide_dma_off(ide_drive_t *);
@@ -1713,6 +1716,7 @@
 extern int __ide_dma_timeout(ide_drive_t *);
 #else
 static inline void ide_setup_dma(ide_hwif_t *x, unsigned long y, unsigned int z) {;}
+static inline void ide_setup_no_dma(ide_hwif_t *x) {;}
 static inline void ide_release_dma(ide_hwif_t *x) {;}
 #endif
 

                 reply	other threads:[~2003-12-07 23:00 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=20031207230049.GA1079@desktop \
    --to=gwurster@scs.carleton.ca \
    --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