diff options
| -rw-r--r-- | drivers/dma/imx-sdma.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index e7db24c67030..ccd03c3cedfe 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c | |||
| @@ -338,6 +338,7 @@ struct sdma_channel { | |||
| 338 | unsigned int chn_real_count; | 338 | unsigned int chn_real_count; |
| 339 | struct tasklet_struct tasklet; | 339 | struct tasklet_struct tasklet; |
| 340 | struct imx_dma_data data; | 340 | struct imx_dma_data data; |
| 341 | bool enabled; | ||
| 341 | }; | 342 | }; |
| 342 | 343 | ||
| 343 | #define IMX_DMA_SG_LOOP BIT(0) | 344 | #define IMX_DMA_SG_LOOP BIT(0) |
| @@ -596,7 +597,14 @@ static int sdma_config_ownership(struct sdma_channel *sdmac, | |||
| 596 | 597 | ||
| 597 | static void sdma_enable_channel(struct sdma_engine *sdma, int channel) | 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 | writel(BIT(channel), sdma->regs + SDMA_H_START); | 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 | struct sdma_buffer_descriptor *bd; | 693 | struct sdma_buffer_descriptor *bd; |
| 686 | int error = 0; | 694 | int error = 0; |
| 687 | enum dma_status old_status = sdmac->status; | 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 | * loop mode. Iterate over descriptors, re-setup them and | 706 | * loop mode. Iterate over descriptors, re-setup them and |
| @@ -938,10 +954,15 @@ static int sdma_disable_channel(struct dma_chan *chan) | |||
| 938 | struct sdma_channel *sdmac = to_sdma_chan(chan); | 954 | struct sdma_channel *sdmac = to_sdma_chan(chan); |
| 939 | struct sdma_engine *sdma = sdmac->sdma; | 955 | struct sdma_engine *sdma = sdmac->sdma; |
| 940 | int channel = sdmac->channel; | 956 | int channel = sdmac->channel; |
| 957 | unsigned long flags; | ||
| 941 | 958 | ||
| 942 | writel_relaxed(BIT(channel), sdma->regs + SDMA_H_STATSTOP); | 959 | writel_relaxed(BIT(channel), sdma->regs + SDMA_H_STATSTOP); |
| 943 | sdmac->status = DMA_ERROR; | 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 | return 0; | 966 | return 0; |
| 946 | } | 967 | } |
| 947 | 968 | ||
