Skip to contentSkip to conversation

Staging: comedi: Add DMA preparation before mite_dma_arm().

PATCH In review Wentao Liang 2 participants 2 messages Apr 3, 2025 Comedi drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: comedi: Add DMA preparation before mite_dma_arm().

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")
---
 drivers/comedi/drivers/ni_tiocmd.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/comedi/drivers/ni_tiocmd.c +3 -2
index ab6d9e8269f3..b943836ccf1a 100644
@@ -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)
Signature · 1 line
2.42.0.windows.2
maintainer
#1 lore raw
Quoted 19 lines · Wentao Liang

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")
---
  drivers/comedi/drivers/ni_tiocmd.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/comedi/drivers/ni_tiocmd.c +0 -0
index ab6d9e8269f3..b943836ccf1a 100644
@@ -84,9 +84,10 @@ static int ni_tio_input_inttrig(struct comedi_device *dev,
  		return -EINVAL;
 

drivers/comedi/drivers/ni_tiocmd.c static int ni_tio_input_inttrig(struct comedi_device *dev, · line 93

Quoted 10 lines
drivers/comedi/drivers/ni_tiocmd.c +3 -2
  	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().

Signature · 4 lines
-=( Ian Abbott <[email protected]> || 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 )=-