Skip to content

Commit 209be28

Browse files
tnmyshmathieupoirier
authored andcommitted
remoteproc: xlnx: Add shutdown callback
In case of kexec call, each driver's shutdown callback is called. Handle this call for rproc driver and shutdown/detach each core that was powered on before. This is needed for proper Life Cycle Management of remote processor. Otherwise on next linux boot, remote processor can't be started due to bad refcount of power-domain managed by platform management controller. Signed-off-by: Tanmay Shah <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mathieu Poirier <[email protected]>
1 parent 82a4277 commit 209be28

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

drivers/remoteproc/xlnx_r5_remoteproc.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,45 @@ static void zynqmp_r5_cluster_exit(void *data)
14671467
platform_set_drvdata(pdev, NULL);
14681468
}
14691469

1470+
/*
1471+
* zynqmp_r5_remoteproc_shutdown()
1472+
* Follow shutdown sequence in case of kexec call.
1473+
*
1474+
* @pdev: domain platform device for cluster
1475+
*
1476+
* Return: None.
1477+
*/
1478+
static void zynqmp_r5_remoteproc_shutdown(struct platform_device *pdev)
1479+
{
1480+
const char *rproc_state_str = NULL;
1481+
struct zynqmp_r5_cluster *cluster;
1482+
struct zynqmp_r5_core *r5_core;
1483+
struct rproc *rproc;
1484+
int i, ret = 0;
1485+
1486+
cluster = platform_get_drvdata(pdev);
1487+
1488+
for (i = 0; i < cluster->core_count; i++) {
1489+
r5_core = cluster->r5_cores[i];
1490+
rproc = r5_core->rproc;
1491+
1492+
if (rproc->state == RPROC_RUNNING) {
1493+
ret = rproc_shutdown(rproc);
1494+
rproc_state_str = "shutdown";
1495+
} else if (rproc->state == RPROC_ATTACHED) {
1496+
ret = rproc_detach(rproc);
1497+
rproc_state_str = "detach";
1498+
} else {
1499+
ret = 0;
1500+
}
1501+
1502+
if (ret) {
1503+
dev_err(cluster->dev, "failed to %s rproc %d\n",
1504+
rproc_state_str, rproc->index);
1505+
}
1506+
}
1507+
}
1508+
14701509
/*
14711510
* zynqmp_r5_remoteproc_probe()
14721511
* parse device-tree, initialize hardware and allocate required resources
@@ -1528,6 +1567,7 @@ static struct platform_driver zynqmp_r5_remoteproc_driver = {
15281567
.name = "zynqmp_r5_remoteproc",
15291568
.of_match_table = zynqmp_r5_remoteproc_match,
15301569
},
1570+
.shutdown = zynqmp_r5_remoteproc_shutdown,
15311571
};
15321572
module_platform_driver(zynqmp_r5_remoteproc_driver);
15331573

0 commit comments

Comments
 (0)