diff mbox series

[RESEND,v3,2/2] remoteproc: enhance rproc_put() for clusters

Message ID 20231014231548.637303-3-tanmay.shah@amd.com (mailing list archive)
State Superseded
Headers show
Series remoteproc: get rproc devices for clusters | expand

Commit Message

Tanmay Shah Oct. 14, 2023, 11:15 p.m. UTC
This patch enhances rproc_put() to support remoteproc clusters
with multiple child nodes as in rproc_get_by_phandle().

Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/oe-kbuild-all/202303221441.cuBnpvye-lkp@intel.com/
Signed-off-by: Tarak Reddy <tarak.reddy@amd.com>
Signed-off-by: Tanmay Shah <tanmay.shah@amd.com>
---
 drivers/remoteproc/remoteproc_core.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 3a8191803885..3d95543971b5 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -2559,7 +2559,22 @@  EXPORT_SYMBOL(rproc_free);
  */
 void rproc_put(struct rproc *rproc)
 {
-	module_put(rproc->dev.parent->driver->owner);
+	struct platform_device *cluster_pdev;
+
+	if (rproc->dev.parent->driver) {
+		module_put(rproc->dev.parent->driver->owner);
+	} else {
+		/*
+		 * If the remoteproc's parent does not have a driver,
+		 * driver is associated with the cluster.
+		 */
+		cluster_pdev = of_find_device_by_node(rproc->dev.parent->of_node->parent);
+		if (cluster_pdev) {
+			module_put(cluster_pdev->dev.driver->owner);
+			put_device(&cluster_pdev->dev);
+		}
+	}
+
 	put_device(&rproc->dev);
 }
 EXPORT_SYMBOL(rproc_put);