Skip to content

Commit

Permalink
dmaengine: pl330: Fix unbalanced runtime PM
Browse files Browse the repository at this point in the history
This driver use runtime PM autosuspend mechanism to manager clk.

  pm_runtime_use_autosuspend(&adev->dev);
  pm_runtime_set_autosuspend_delay(&adev->dev, PL330_AUTOSUSPEND_DELAY);

So, after ref count reached to zero, it will enter suspend
after the delay time elapsed.

The unbalanced PM:

* May cause dmac the next start failed.
* May cause dmac read unexpected state.
* May cause dmac stall if power down happen at the middle of the transfer.
  e.g. may lose ack from AXI bus and stall.

Considering the following situation:

      DMA TERMINATE               TASKLET ROUTINE
            |                            |
            |                       issue_pending
            |                            |
            |                     pch->active = true
            |                       pm_runtime_get
  pm_runtime_put(if active)              |
    pch->active = false                  |
            |                      work_list empty
            |                            |
            |                     pm_runtime_put(force)
            |                            |

At this point, it's unbalanced(1 get / 2 put).

After this patch:

      DMA TERMINATE               TASKLET ROUTINE
            |                            |
            |                       issue_pending
            |                            |
            |                     pch->active = true
            |                       pm_runtime_get
  pm_runtime_put(if active)              |
    pch->active = false                  |
            |                      work_list empty
            |                            |
            |                   pm_runtime_put(if active)
            |                            |

Now, it's balanced(1 get / 1 put).

Fixes:
commit 5c9e6c2 ("dmaengine: pl330: Fix runtime PM support for terminated transfers")
commit ae43b32 ("ARM: 8202/1: dmaengine: pl330: Add runtime Power Management support v12")

Change-Id: Ib1feb508c16afb4bc9ced0c3660f2b6b4a19c068
Signed-off-by: Huibin Hong <[email protected]>
Signed-off-by: Sugar Zhang <[email protected]>
  • Loading branch information
Sugar Zhang authored and rkhuangtao committed Apr 21, 2022
1 parent c9c4664 commit 05cc2b4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/dma/pl330.c
Original file line number Diff line number Diff line change
Expand Up @@ -2086,7 +2086,7 @@ static void pl330_tasklet(struct tasklet_struct *t)
spin_lock(&pch->thread->dmac->lock);
_stop(pch->thread);
spin_unlock(&pch->thread->dmac->lock);
power_down = true;
power_down = pch->active;
pch->active = false;
} else {
/* Make sure the PL330 Channel thread is active */
Expand Down

0 comments on commit 05cc2b4

Please sign in to comment.