Fix for crashes with dma enabled using pci-6143. Based on patch from
authorFrank Mori Hess <fmhess@speakeasy.net>
Wed, 26 Mar 2008 14:10:02 +0000 (14:10 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Wed, 26 Mar 2008 14:10:02 +0000 (14:10 +0000)
Terry Barnaby <terry1@beam.ltd.uk>, who also identified and located the
source of the problem.

comedi/drivers/mite.c

index 2094b9c90b5175f4abf580d9c57832f1a24209ec..c0d1fa2d745c41e39ae7e7d140a32094c89147eb 100644 (file)
@@ -268,14 +268,15 @@ void mite_release_channel(struct mite_channel *mite_chan)
        // spin lock to prevent races with mite_request_channel
        comedi_spin_lock_irqsave(&mite->lock, flags);
        if (mite->channel_allocated[mite_chan->channel]) {
-               // disable all channel's interrupts
+               mite_dma_disarm(mite_chan);
+               mite_dma_reset(mite_chan);
+/* disable all channel's interrupts (do it after disarm/reset so
+MITE_CHCR reg isn't changed while dma is still active!) */
                writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE |
                        CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE |
                        CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
                        CHCR_CLR_LC_IE | CHCR_CLR_CONT_RB_IE,
                        mite->mite_io_addr + MITE_CHCR(mite_chan->channel));
-               mite_dma_disarm(mite_chan);
-               mite_dma_reset(mite_chan);
                mite->channel_allocated[mite_chan->channel] = 0;
                mite_chan->ring = NULL;
                mmiowb();