Skip to content

Commit 775912b

Browse files
author
Jacopo Mondi
committed
media: pisp_be: Fix pm_runtime underrun in probe
During the probe() routine, the driver needs to power up the interface in order to identify and initialize the hardware and it later suspends it at the end of probe(). The driver erroneously resumes the interface by calling the pispbe_runtime_resume() function directly but suspends it by calling pm_runtime_put_autosuspend(). This causes a PM usage count imbalance at probe time, notified by the runtime_pm framework with the below message in the system log: pispbe 1000880000.pisp_be: Runtime PM usage count underflow! Fix this by suspending the interface using pm_runtime_idle() which doesn't decrease the pm_runtime usage count and inform the PM framework that the device is active by calling pm_runtime_set_active(). Adjust the pispbe_remove() function as well to disable the pm_runtime in the correct order. Signed-off-by: Jacopo Mondi <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> --- v4->v5: - Indent with tabs :/ v3->v4: - Instead of using pm_runtime for resuming, suspend using pm_runtime_idle() to support !CONFIG_PM v2->v3: - Mark pispbe_runtime_resume() as __maybe_unused as reported by the kernel test robot <[email protected]>
1 parent 0ea92dc commit 775912b

File tree

1 file changed

+11
-13
lines changed
  • drivers/media/platform/raspberrypi/pisp_be

1 file changed

+11
-13
lines changed

drivers/media/platform/raspberrypi/pisp_be/pisp_be.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,19 +1768,15 @@ static int pispbe_probe(struct platform_device *pdev)
17681768
"Failed to get clock");
17691769

17701770
/* Hardware initialisation */
1771-
pm_runtime_set_autosuspend_delay(pispbe->dev, 200);
1772-
pm_runtime_use_autosuspend(pispbe->dev);
1773-
pm_runtime_enable(pispbe->dev);
1774-
17751771
ret = pispbe_runtime_resume(pispbe->dev);
17761772
if (ret)
1777-
goto pm_runtime_disable_err;
1773+
return ret;
17781774

17791775
pispbe->hw_busy = false;
17801776
spin_lock_init(&pispbe->hw_lock);
17811777
ret = pispbe_hw_init(pispbe);
17821778
if (ret)
1783-
goto pm_runtime_suspend_err;
1779+
goto runtime_suspend_err;
17841780

17851781
/*
17861782
* Initialise and register devices for each node_group, including media
@@ -1794,19 +1790,19 @@ static int pispbe_probe(struct platform_device *pdev)
17941790
goto disable_nodes_err;
17951791
}
17961792

1797-
pm_runtime_mark_last_busy(pispbe->dev);
1798-
pm_runtime_put_autosuspend(pispbe->dev);
1793+
pm_runtime_set_autosuspend_delay(pispbe->dev, 200);
1794+
pm_runtime_use_autosuspend(pispbe->dev);
1795+
pm_runtime_set_active(pispbe->dev);
1796+
pm_runtime_enable(pispbe->dev);
1797+
pm_runtime_idle(pispbe->dev);
17991798

18001799
return 0;
18011800

18021801
disable_nodes_err:
18031802
while (num_groups-- > 0)
18041803
pispbe_destroy_node_group(&pispbe->node_group[num_groups]);
1805-
pm_runtime_suspend_err:
1804+
runtime_suspend_err:
18061805
pispbe_runtime_suspend(pispbe->dev);
1807-
pm_runtime_disable_err:
1808-
pm_runtime_dont_use_autosuspend(pispbe->dev);
1809-
pm_runtime_disable(pispbe->dev);
18101806

18111807
return ret;
18121808
}
@@ -1818,9 +1814,11 @@ static int pispbe_remove(struct platform_device *pdev)
18181814
for (int i = PISPBE_NUM_NODE_GROUPS - 1; i >= 0; i--)
18191815
pispbe_destroy_node_group(&pispbe->node_group[i]);
18201816

1821-
pispbe_runtime_suspend(pispbe->dev);
18221817
pm_runtime_dont_use_autosuspend(pispbe->dev);
18231818
pm_runtime_disable(pispbe->dev);
1819+
if (!pm_runtime_status_suspended(pispbe->dev))
1820+
pispbe_runtime_suspend(pispbe->dev);
1821+
pm_runtime_set_suspended(pispbe->dev);
18241822

18251823
return 0;
18261824
}

0 commit comments

Comments
 (0)