Commit e3794b52 authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: ni_pcidio: Grab MITE spinlock while preparing DMA.

When setting up the DMA for 'read' streaming acquisition command, grab
the MITE channel spinlock before preparing and arming the DMA.

Change inspired by ni_ai_setup_MITE_dma() in ni_mio_common.c.
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 41add2e8
...@@ -436,6 +436,7 @@ static int ni_pcidio_request_di_mite_channel(struct comedi_device *dev) ...@@ -436,6 +436,7 @@ static int ni_pcidio_request_di_mite_channel(struct comedi_device *dev)
comedi_error(dev, "failed to reserve mite dma channel."); comedi_error(dev, "failed to reserve mite dma channel.");
return -EBUSY; return -EBUSY;
} }
devpriv->di_mite_chan->dir = COMEDI_INPUT;
writeb(primary_DMAChannel_bits(devpriv->di_mite_chan->channel) | writeb(primary_DMAChannel_bits(devpriv->di_mite_chan->channel) |
secondary_DMAChannel_bits(devpriv->di_mite_chan->channel), secondary_DMAChannel_bits(devpriv->di_mite_chan->channel),
devpriv->mite->daq_io_addr + DMA_Line_Control_Group1); devpriv->mite->daq_io_addr + DMA_Line_Control_Group1);
...@@ -1005,20 +1006,24 @@ static int ni_pcidio_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -1005,20 +1006,24 @@ static int ni_pcidio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
static int setup_mite_dma(struct comedi_device *dev, struct comedi_subdevice *s) static int setup_mite_dma(struct comedi_device *dev, struct comedi_subdevice *s)
{ {
int retval; int retval;
unsigned long flags;
retval = ni_pcidio_request_di_mite_channel(dev); retval = ni_pcidio_request_di_mite_channel(dev);
if (retval) if (retval)
return retval; return retval;
devpriv->di_mite_chan->dir = COMEDI_INPUT;
/* write alloc the entire buffer */ /* write alloc the entire buffer */
comedi_buf_write_alloc(s->async, s->async->prealloc_bufsz); comedi_buf_write_alloc(s->async, s->async->prealloc_bufsz);
spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
if (devpriv->di_mite_chan) {
mite_prep_dma(devpriv->di_mite_chan, 32, 32); mite_prep_dma(devpriv->di_mite_chan, 32, 32);
mite_dma_arm(devpriv->di_mite_chan); mite_dma_arm(devpriv->di_mite_chan);
return 0; } else
retval = -EIO;
spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
return retval;
} }
static int ni_pcidio_inttrig(struct comedi_device *dev, static int ni_pcidio_inttrig(struct comedi_device *dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment