drivers/comedi/drivers/ni_tiocmd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
The ni_tio_input_inttrig() calls mite_dma_arm() without calling
mite_prep_dma() first. A proper implementation can be found in
ni_cdo_inttrig() in ni_mio_common.c.
Add mite_prep_dma() before mite_dma_arm().
Fixes: cb7859a90af1 ("Staging: comedi: add National Instruments infrastructure")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/comedi/drivers/ni_tiocmd.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/comedi/drivers/ni_tiocmd.c b/drivers/comedi/drivers/ni_tiocmd.c
index ab6d9e8269f3..b943836ccf1a 100644
--- a/drivers/comedi/drivers/ni_tiocmd.c
+++ b/drivers/comedi/drivers/ni_tiocmd.c
@@ -84,9 +84,10 @@ static int ni_tio_input_inttrig(struct comedi_device *dev,
return -EINVAL;
spin_lock_irqsave(&counter->lock, flags);
- if (counter->mite_chan)
+ if (counter->mite_chan) {
+ mite_prep_dma(counter->mite_chan, 32, 32);
mite_dma_arm(counter->mite_chan);
- else
+ } else
ret = -EIO;
spin_unlock_irqrestore(&counter->lock, flags);
if (ret < 0)
--
2.42.0.windows.2
On 2025-04-03 17:35, Wentao Liang wrote:
> The ni_tio_input_inttrig() calls mite_dma_arm() without calling
> mite_prep_dma() first. A proper implementation can be found in
> ni_cdo_inttrig() in ni_mio_common.c.
>
> Add mite_prep_dma() before mite_dma_arm().
>
> Fixes: cb7859a90af1 ("Staging: comedi: add National Instruments infrastructure")
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/comedi/drivers/ni_tiocmd.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/comedi/drivers/ni_tiocmd.c b/drivers/comedi/drivers/ni_tiocmd.c
> index ab6d9e8269f3..b943836ccf1a 100644
> --- a/drivers/comedi/drivers/ni_tiocmd.c
> +++ b/drivers/comedi/drivers/ni_tiocmd.c
> @@ -84,9 +84,10 @@ static int ni_tio_input_inttrig(struct comedi_device *dev,
> return -EINVAL;
>
> spin_lock_irqsave(&counter->lock, flags);
> - if (counter->mite_chan)
> + if (counter->mite_chan) {
> + mite_prep_dma(counter->mite_chan, 32, 32);
> mite_dma_arm(counter->mite_chan);
> - else
> + } else
> ret = -EIO;
> spin_unlock_irqrestore(&counter->lock, flags);
> if (ret < 0)
mite_prep_dma() will get called by ni_tio_input_cmd() at some arbitrary
time before ni_tio_input_inttrig() is called. (ni_tio_input_cmd() sets
up the software trigger function pointer that is called during
processing of a subsequent INSN_INTTRIG comedi instruction from
user-space. Also, the last two parameters of mite_prep_dma() are not
always 32 and 32 - it depends on the hardware, as can be seen in the
switch statement in ni_tio_input_cmd().
--
-=( Ian Abbott <abbotti@mev.co.uk> || MEV Ltd. is a company )=-
-=( registered in England & Wales. Regd. number: 02862268. )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-
© 2016 - 2026 Red Hat, Inc.