dmaengine: ti: k3-udma: Use the channel direction in pause/resume functions
It should be possible to pause, resume and check the pause state of a
channel even if we do not have active transfer.
udma_is_chan_paused() can trigger NULL pointer reference in it's current
form when the status is checked while uc->desc is NULL.
Fixes: 25dcb5dd7b
("dmaengine: ti: New driver for K3 UDMA")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Link: https://lore.kernel.org/r/20200214091441.27535-6-peter.ujfalusi@ti.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
6cf668a4ef
commit
c7450bb211
|
@ -513,7 +513,7 @@ static bool udma_is_chan_paused(struct udma_chan *uc)
|
||||||
{
|
{
|
||||||
u32 val, pause_mask;
|
u32 val, pause_mask;
|
||||||
|
|
||||||
switch (uc->desc->dir) {
|
switch (uc->config.dir) {
|
||||||
case DMA_DEV_TO_MEM:
|
case DMA_DEV_TO_MEM:
|
||||||
val = udma_rchanrt_read(uc->rchan,
|
val = udma_rchanrt_read(uc->rchan,
|
||||||
UDMA_RCHAN_RT_PEER_RT_EN_REG);
|
UDMA_RCHAN_RT_PEER_RT_EN_REG);
|
||||||
|
@ -2835,11 +2835,8 @@ static int udma_pause(struct dma_chan *chan)
|
||||||
{
|
{
|
||||||
struct udma_chan *uc = to_udma_chan(chan);
|
struct udma_chan *uc = to_udma_chan(chan);
|
||||||
|
|
||||||
if (!uc->desc)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
/* pause the channel */
|
/* pause the channel */
|
||||||
switch (uc->desc->dir) {
|
switch (uc->config.dir) {
|
||||||
case DMA_DEV_TO_MEM:
|
case DMA_DEV_TO_MEM:
|
||||||
udma_rchanrt_update_bits(uc->rchan,
|
udma_rchanrt_update_bits(uc->rchan,
|
||||||
UDMA_RCHAN_RT_PEER_RT_EN_REG,
|
UDMA_RCHAN_RT_PEER_RT_EN_REG,
|
||||||
|
@ -2868,11 +2865,8 @@ static int udma_resume(struct dma_chan *chan)
|
||||||
{
|
{
|
||||||
struct udma_chan *uc = to_udma_chan(chan);
|
struct udma_chan *uc = to_udma_chan(chan);
|
||||||
|
|
||||||
if (!uc->desc)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
/* resume the channel */
|
/* resume the channel */
|
||||||
switch (uc->desc->dir) {
|
switch (uc->config.dir) {
|
||||||
case DMA_DEV_TO_MEM:
|
case DMA_DEV_TO_MEM:
|
||||||
udma_rchanrt_update_bits(uc->rchan,
|
udma_rchanrt_update_bits(uc->rchan,
|
||||||
UDMA_RCHAN_RT_PEER_RT_EN_REG,
|
UDMA_RCHAN_RT_PEER_RT_EN_REG,
|
||||||
|
|
Loading…
Reference in New Issue