All of lore.kernel.org
 help / color / mirror / Atom feed
From: Glenn Wurster <gwurster@scs.carleton.ca>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org, alan@redhat.com, andre@linux-ide.org
Subject: [PATCH] ide-dma.c, ide.c, ide.h, kernel 2.4.24
Date: Fri, 23 Jan 2004 13:32:45 -0500	[thread overview]
Message-ID: <20040123183245.GB853@desktop> (raw)


Brief Synopsis:

IDE initialization on non-DMA controllers causes OOPS during boot
due to dereference of null function pointers.

Description:

This patch fixes an issue where null function pointers associated with
DMA are called during initialization of IDE hard drive controllers
(causing a kernel OOPS on boot).  The problem only occurs on
controllers which do not support DMA.  It has been tested successfuly
against a non-DMA IDE controller on x86.

I am not subscribed, so please CC me on any followup e-mails.

Glenn.

diff -Naur linux-2.4.24/drivers/ide/ide-dma.c linux-2.4.24-patched/drivers/ide/ide-dma.c
--- linux-2.4.24/drivers/ide/ide-dma.c	2003-08-25 11:44:41.000000000 +0000
+++ linux-2.4.24-patched/drivers/ide/ide-dma.c	2004-01-23 03:23:08.000000000 +0000
@@ -566,6 +566,33 @@
 }
 
 /**
+ *  __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_unsupported - Warning function for DMA operation.
+ *
+ *  Warning function for DMA operation on unsupported hardware.
+ */
+
+int __ide_dma_unsupported (ide_hwif_t *hwif)
+{
+	printk(KERN_WARNING "DMA not supported by %s\n", hwif->name );
+	return 1;
+}
+
+EXPORT_SYMBOL(__ide_dma_unsupported);
+
+/**
  *	__ide_dma_host_off	-	Generic DMA kill
  *	@drive: drive to control
  *
@@ -1214,3 +1241,17 @@
 }
 
 EXPORT_SYMBOL_GPL(ide_setup_dma);
+
+/*
+ * For IDE interfaces that do not support DMA, we still need to
+ * initialize some pointers to dummy functions during initialization.
+ */
+void default_hwif_dmaops (ide_hwif_t *hwif)
+{
+	hwif->ide_dma_on = __ide_dma_unsupported;
+	hwif->ide_dma_off_quietly = (int (*)(ide_drive_t *))&__ide_dma_no_op;
+	hwif->ide_dma_host_off = (int (*)(ide_drive_t *))&__ide_dma_no_op;
+	hwif->ide_dma_host_on = (int (*)(ide_drive_t *))&__ide_dma_no_op;
+}
+
+EXPORT_SYMBOL_GPL(default_hwif_dmaops);
diff -Naur linux-2.4.24/drivers/ide/ide.c linux-2.4.24-patched/drivers/ide/ide.c
--- linux-2.4.24/drivers/ide/ide.c	2003-11-28 18:26:20.000000000 +0000
+++ linux-2.4.24-patched/drivers/ide/ide.c	2004-01-23 03:32:24.000000000 +0000
@@ -251,6 +251,7 @@
 	hwif->sata = 0;			/* assume PATA */
 
 	default_hwif_iops(hwif);
+	default_hwif_dmaops(hwif);
 	default_hwif_transport(hwif);
 	for (unit = 0; unit < MAX_DRIVES; ++unit) {
 		ide_drive_t *drive = &hwif->drives[unit];
diff -Naur linux-2.4.24/include/linux/ide.h linux-2.4.24-patched/include/linux/ide.h
--- linux-2.4.24/include/linux/ide.h	2003-11-28 18:26:21.000000000 +0000
+++ linux-2.4.24-patched/include/linux/ide.h	2004-01-23 03:24:08.000000000 +0000
@@ -1691,8 +1691,12 @@
 extern void ide_destroy_dmatable(ide_drive_t *);
 extern ide_startstop_t ide_dma_intr(ide_drive_t *);
 extern int ide_release_dma(ide_hwif_t *);
+extern void default_hwif_dmaops(ide_hwif_t *);
 extern void ide_setup_dma(ide_hwif_t *, unsigned long, unsigned int);
+extern void ide_setup_dma_off(ide_hwif_t *);
 
+extern int __ide_dma_no_op(void);
+extern int __ide_dma_unsupported(ide_hwif_t *);
 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 *);
@@ -1712,6 +1716,7 @@
 extern int __ide_dma_lostirq(ide_drive_t *);
 extern int __ide_dma_timeout(ide_drive_t *);
 #else
+static inline void default_hwif_dmaops(ide_hwif_t *x) {;}
 static inline void ide_setup_dma(ide_hwif_t *x, unsigned long y, unsigned int z) {;}
 static inline void ide_release_dma(ide_hwif_t *x) {;}
 #endif

             reply	other threads:[~2004-01-23 18:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-23 18:32 Glenn Wurster [this message]
2004-01-23 21:33 ` [PATCH] ide-dma.c, ide.c, ide.h, kernel 2.4.24 Alan Cox
2004-01-23 22:09   ` Glenn Wurster
2004-01-23 23:45     ` Bartlomiej Zolnierkiewicz
2004-01-27  5:52       ` Glenn Wurster
2004-01-27 15:14         ` Bartlomiej Zolnierkiewicz
2004-01-27 16:41           ` Glenn Wurster

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=20040123183245.GB853@desktop \
    --to=gwurster@scs.carleton.ca \
    --cc=alan@redhat.com \
    --cc=andre@linux-ide.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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.