@@ -338,6 +338,7 @@ struct sdma_channel {
338
338
unsigned int chn_real_count ;
339
339
struct tasklet_struct tasklet ;
340
340
struct imx_dma_data data ;
341
+ bool enabled ;
341
342
};
342
343
343
344
#define IMX_DMA_SG_LOOP BIT(0)
@@ -596,7 +597,14 @@ static int sdma_config_ownership(struct sdma_channel *sdmac,
596
597
597
598
static void sdma_enable_channel (struct sdma_engine * sdma , int channel )
598
599
{
600
+ unsigned long flags ;
601
+ struct sdma_channel * sdmac = & sdma -> channel [channel ];
602
+
599
603
writel (BIT (channel ), sdma -> regs + SDMA_H_START );
604
+
605
+ spin_lock_irqsave (& sdmac -> lock , flags );
606
+ sdmac -> enabled = true;
607
+ spin_unlock_irqrestore (& sdmac -> lock , flags );
600
608
}
601
609
602
610
/*
@@ -685,6 +693,14 @@ static void sdma_update_channel_loop(struct sdma_channel *sdmac)
685
693
struct sdma_buffer_descriptor * bd ;
686
694
int error = 0 ;
687
695
enum dma_status old_status = sdmac -> status ;
696
+ unsigned long flags ;
697
+
698
+ spin_lock_irqsave (& sdmac -> lock , flags );
699
+ if (!sdmac -> enabled ) {
700
+ spin_unlock_irqrestore (& sdmac -> lock , flags );
701
+ return ;
702
+ }
703
+ spin_unlock_irqrestore (& sdmac -> lock , flags );
688
704
689
705
/*
690
706
* loop mode. Iterate over descriptors, re-setup them and
@@ -938,10 +954,15 @@ static int sdma_disable_channel(struct dma_chan *chan)
938
954
struct sdma_channel * sdmac = to_sdma_chan (chan );
939
955
struct sdma_engine * sdma = sdmac -> sdma ;
940
956
int channel = sdmac -> channel ;
957
+ unsigned long flags ;
941
958
942
959
writel_relaxed (BIT (channel ), sdma -> regs + SDMA_H_STATSTOP );
943
960
sdmac -> status = DMA_ERROR ;
944
961
962
+ spin_lock_irqsave (& sdmac -> lock , flags );
963
+ sdmac -> enabled = false;
964
+ spin_unlock_irqrestore (& sdmac -> lock , flags );
965
+
945
966
return 0 ;
946
967
}
947
968
0 commit comments