Skip to content

Commit a99a37f

Browse files
pcercueiandersson
authored andcommitted
remoteproc: Add support for runtime PM
Call pm_runtime_get_sync() before the firmware is loaded, and pm_runtime_put() after the remote processor has been stopped. Even though the remoteproc device has no PM callbacks, this allows the parent device's PM callbacks to be properly called. Signed-off-by: Paul Cercueil <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 4e399b3 commit a99a37f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

drivers/remoteproc/remoteproc_core.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/devcoredump.h>
3030
#include <linux/rculist.h>
3131
#include <linux/remoteproc.h>
32+
#include <linux/pm_runtime.h>
3233
#include <linux/iommu.h>
3334
#include <linux/idr.h>
3435
#include <linux/elf.h>
@@ -1382,6 +1383,12 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
13821383
if (ret)
13831384
return ret;
13841385

1386+
ret = pm_runtime_get_sync(dev);
1387+
if (ret < 0) {
1388+
dev_err(dev, "pm_runtime_get_sync failed: %d\n", ret);
1389+
return ret;
1390+
}
1391+
13851392
dev_info(dev, "Booting fw image %s, size %zd\n", name, fw->size);
13861393

13871394
/*
@@ -1391,7 +1398,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
13911398
ret = rproc_enable_iommu(rproc);
13921399
if (ret) {
13931400
dev_err(dev, "can't enable iommu: %d\n", ret);
1394-
return ret;
1401+
goto put_pm_runtime;
13951402
}
13961403

13971404
/* Prepare rproc for firmware loading if needed */
@@ -1445,6 +1452,8 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
14451452
rproc_unprepare_device(rproc);
14461453
disable_iommu:
14471454
rproc_disable_iommu(rproc);
1455+
put_pm_runtime:
1456+
pm_runtime_put(dev);
14481457
return ret;
14491458
}
14501459

@@ -1882,6 +1891,8 @@ void rproc_shutdown(struct rproc *rproc)
18821891

18831892
rproc_disable_iommu(rproc);
18841893

1894+
pm_runtime_put(dev);
1895+
18851896
/* Free the copy of the resource table */
18861897
kfree(rproc->cached_table);
18871898
rproc->cached_table = NULL;
@@ -2172,6 +2183,9 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
21722183

21732184
rproc->state = RPROC_OFFLINE;
21742185

2186+
pm_runtime_no_callbacks(&rproc->dev);
2187+
pm_runtime_enable(&rproc->dev);
2188+
21752189
return rproc;
21762190

21772191
put_device:
@@ -2191,6 +2205,7 @@ EXPORT_SYMBOL(rproc_alloc);
21912205
*/
21922206
void rproc_free(struct rproc *rproc)
21932207
{
2208+
pm_runtime_disable(&rproc->dev);
21942209
put_device(&rproc->dev);
21952210
}
21962211
EXPORT_SYMBOL(rproc_free);

0 commit comments

Comments
 (0)