This series extends original patch and makes rproc_put() work
for clusters along with rprog_get_by_phandle().
Changes in v3:
- remove module_put call that was introduced in the patch by mistake
- remove redundant check in rproc_put
- Add inline comments in rproc_put that explains functionality
Changes in v2:
- Introduce patch to fix rproc_put as per modified rproc_get_by_phandle
v1 is here: https://lore.kernel.org/all/[email protected]/
Mathieu Poirier (1):
remoteproc: Make rproc_get_by_phandle() work for clusters
Tanmay Shah (1):
remoteproc: enhance rproc_put() for clusters
drivers/remoteproc/remoteproc_core.c | 45 ++++++++++++++++++++++++++--
1 file changed, 43 insertions(+), 2 deletions(-)
base-commit: e19967994d342a5986d950a1bfddf19d7e1191b7
--
2.25.1
This patch enhances rproc_put() to support remoteproc clusters
with multiple child nodes as in rproc_get_by_phandle().
Reported-by: kernel test robot <[email protected]>
Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Tarak Reddy <[email protected]>
Signed-off-by: Tanmay Shah <[email protected]>
---
Changes in v3:
- remove module_put call that was introduced in the patch by mistake
- remove redundant check in rproc_put
- Add inline comments in rproc_put that explains functionality
Changes in v2:
- Introduce this patch to fix rproc_put as per modified rproc_get_by_phandle
drivers/remoteproc/remoteproc_core.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index a3e7c8798381..d8f28c6fe3a3 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);
--
2.25.1
On Tue, Mar 28, 2023 at 09:49:24AM -0700, Tanmay Shah wrote:
> This patch enhances rproc_put() to support remoteproc clusters
> with multiple child nodes as in rproc_get_by_phandle().
>
> Reported-by: kernel test robot <[email protected]>
> Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
> Signed-off-by: Tarak Reddy <[email protected]>
> Signed-off-by: Tanmay Shah <[email protected]>
> ---
>
> Changes in v3:
> - remove module_put call that was introduced in the patch by mistake
> - remove redundant check in rproc_put
> - Add inline comments in rproc_put that explains functionality
>
> Changes in v2:
> - Introduce this patch to fix rproc_put as per modified rproc_get_by_phandle
>
> drivers/remoteproc/remoteproc_core.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> index a3e7c8798381..d8f28c6fe3a3 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);
> + }
> + }
> +
This looks good to me now.
Bjorn, please have a look at this set when you have a minute.
Thanks,
Mathieu
> put_device(&rproc->dev);
> }
> EXPORT_SYMBOL(rproc_put);
> --
> 2.25.1
>