From 91ea86d7e821b34d0d2c5c8a6a0c9537cbc1b3fa Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Mon, 5 Jul 2004 20:37:42 +0000 Subject: [PATCH] Something funny happened on the way to the floppy driver today... When two drivers share an ISA DMA channel, they both call isa_dmainit() and the second call fails if DIAGNOSTIC is on. If isa_dmainit() was already called successfully, just return silently. This only works if both drivers agree on the bounce buffer size, but since sharing DMA is usually only possible on very special hardware and then typically only for devices of the same type (which would have multiple instances of the same device driver), this is not a problem in practice. --- sys/i386/isa/isa_dma.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sys/i386/isa/isa_dma.c b/sys/i386/isa/isa_dma.c index b203666a616..23dc07de097 100644 --- a/sys/i386/isa/isa_dma.c +++ b/sys/i386/isa/isa_dma.c @@ -101,12 +101,20 @@ isa_dmainit(chan, bouncebufsize) { void *buf; + /* + * If a DMA channel is shared, both drivers have to call isa_dmainit + * since they don't know that the other driver will do it. + * Just return if we're already set up good. + * XXX: this only works if they agree on the bouncebuf size. This + * XXX: is typically the case since they are multiple instances of + * XXX: the same driver. + */ + if (dma_bouncebuf[chan] != NULL) + return; + #ifdef DIAGNOSTIC if (chan & ~VALID_DMA_MASK) panic("isa_dmainit: channel out of range"); - - if (dma_bouncebuf[chan] != NULL) - panic("isa_dmainit: impossible request"); #endif dma_bouncebufsize[chan] = bouncebufsize;