Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp3307124rwl; Tue, 27 Dec 2022 07:19:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXvK6H8hBCN0kEEzhxygCrm3kLHlC1Jd1YGJBS8/mRT8LH3wzT0FCjv7oJdXveqiIEvikyWs X-Received: by 2002:a05:6a20:6ca6:b0:aa:8086:4af9 with SMTP id em38-20020a056a206ca600b000aa80864af9mr23293733pzb.20.1672154352838; Tue, 27 Dec 2022 07:19:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672154352; cv=none; d=google.com; s=arc-20160816; b=MnBkOeqXfYl9XFFlnBPMOiG4s8kSELgR8t6CnejrmqWNMSqmGROoSoU83zyuCvR87N dlpd/Q8fbG2W+0Atar2ZI9AqLzsnWCfxhFzh4Txt+uYKPK+OWwFlSWaXukYL79Y3La/b K2HmAZJ1XWtnX8Imw6tGbLEdKxsBGygLSFqrSh/IC2dbRWl8Kmbpt+nFywpIUTRBcEBa zgRmXaiZRYeL7R/IPI/iVr9JdA0f+BvPbGV5NpNiof2jI8N9FbWZVjmDIjVcSUjOIFfV MTi9jD90C1z3OAG1d9qKvoLrBTOfgD6bHU//wAPgjPTmgTBoyz+tPRlklrImuv2i3J3V 26fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Oo/KkyGe55NH2QfXioW89GLVUgC+RKrjmUqTf7OrHY8=; b=nju3WkW26XJKsRisXHsgDUHGm2ENVX7977CWyQZuTO43DcLeHCwmJu+33hFSjHyvon cC5SIbgDgGMvm2v4A79AeI6byKGzhKRKNEswNJ+i610/GzLnbLrzkDfqHT5kAQnxtYog nlFghrXgAnrWr+/geDQBLWYhHH2spzAsCpEJ1OvMGqwLjhLkrNo29FOupC5O+DwmWGRv uZPB4PwsPCZQYfFgz+NSjWiAocwcHRjFD7W4CXf4YilKwCIoB+9/o24+xHGtHXiFNeoA cWf14tCg+Q/8OV/K1ZeQQjiM5mW9XtFX0r/25VJzTM7ruc34qHL7zOlsZZ4quxJQGJ32 RjLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k0cs3nNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w185-20020a6382c2000000b00478dfd40ef6si14434799pgd.768.2022.12.27.07.19.03; Tue, 27 Dec 2022 07:19:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=k0cs3nNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231613AbiL0PLh (ORCPT + 67 others); Tue, 27 Dec 2022 10:11:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231289AbiL0PLf (ORCPT ); Tue, 27 Dec 2022 10:11:35 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C37ACE60; Tue, 27 Dec 2022 07:11:34 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 571A16119F; Tue, 27 Dec 2022 15:11:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BFB9C433F0; Tue, 27 Dec 2022 15:11:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672153893; bh=DHLRnGECifdavsvYK5VFXIuHRMp7XChg8MchINFR/Nw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=k0cs3nNgJMh+lStCiVtmD4AqgBJSb18dB3d8fI0vne6+tEKmcZ+cuB2rKUbE5goJB puXU7zd3URnsyN8r1QwMr+Ceh8M+4R2bk1OJEyFEuvE/gd4EFgIwzAD3BuOCvF1RC3 Jfeik2yits8prTqa09xl+ZTS/eqdzXkekOD0xZyyuB7b9h/rAa/d2V48Y1dolHEHes wBq/kaeXKoSXqedq1uVSjuq3RWzb/n2d3gO1ShqYo1bZeykuEYouE/t0fv4uLD1Q8e OGosodtuPPM7bvWspAuqw6FozNWUCdu6sY5eUV/BItrkfqtbVvQ8o76AuIRKw4jOMB FOnx3JI8zakmg== Date: Tue, 27 Dec 2022 09:11:31 -0600 From: Bjorn Andersson To: Mathieu Poirier Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, ben.levinsky@xilinx.com Subject: Re: [PATCH] remoteproc: Make rproc_get_by_phandle() work for clusters Message-ID: <20221227151131.hkezt4j2om5volnu@builder.lan> References: <20221214221643.1286585-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221214221643.1286585-1-mathieu.poirier@linaro.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 14, 2022 at 03:16:43PM -0700, Mathieu Poirier wrote: > Multi-cluster remoteproc designs typically have the following DT > declaration: > > remoteproc_cluster { > compatible = "soc,remoteproc-cluster"; > > core0: core0 { > compatible = "soc,remoteproc-core" > memory-region; > sram; > }; > > core1: core1 { > compatible = "soc,remoteproc-core" > memory-region; > sram; > } > }; > > A driver exists for the cluster rather than the individual cores > themselves so that operation mode and HW specific configurations > applicable to the cluster can be made. > > Because the driver exists at the cluster level and not the individual > core level, function rproc_get_by_phandle() fails to return the > remoteproc associated with the phandled it is called for. > > This patch enhances rproc_get_by_phandle() by looking for the cluster's > driver when the driver for the immediate remoteproc's parent is not > found. > Can you please help me understand why zynqmp_r5_remoteproc_probe() invokes devm_of_platform_populate() to create platform_device instances for the clusters? Why can't the platform_device for the cluster be used as parent for both remoteprocs and then the driver deal with the subnodes within the driver? Regards, Bjorn > Reported-by: Ben Levinsky > Signed-off-by: Mathieu Poirier > --- > drivers/remoteproc/remoteproc_core.c | 28 +++++++++++++++++++++++++++- > 1 file changed, 27 insertions(+), 1 deletion(-) > > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > index 1cd4815a6dd1..91f82886add9 100644 > --- a/drivers/remoteproc/remoteproc_core.c > +++ b/drivers/remoteproc/remoteproc_core.c > @@ -33,6 +33,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -2110,7 +2111,9 @@ EXPORT_SYMBOL(rproc_detach); > #ifdef CONFIG_OF > struct rproc *rproc_get_by_phandle(phandle phandle) > { > + struct platform_device *cluster_pdev; > struct rproc *rproc = NULL, *r; > + struct device_driver *driver; > struct device_node *np; > > np = of_find_node_by_phandle(phandle); > @@ -2121,7 +2124,30 @@ struct rproc *rproc_get_by_phandle(phandle phandle) > list_for_each_entry_rcu(r, &rproc_list, node) { > if (r->dev.parent && device_match_of_node(r->dev.parent, np)) { > /* prevent underlying implementation from being removed */ > - if (!try_module_get(r->dev.parent->driver->owner)) { > + > + /* > + * If the remoteproc's parent has a driver, the > + * remoteproc is not part of a cluster and we can use > + * that driver. > + */ > + driver = r->dev.parent->driver; > + > + /* > + * If the remoteproc's parent does not have a driver, > + * look for the driver associated with the cluster. > + */ > + if (!driver) { > + cluster_pdev = of_find_device_by_node(np->parent); > + if (!cluster_pdev) { > + dev_err(&r->dev, "can't get parent\n"); > + break; > + } > + > + driver = cluster_pdev->dev.driver; > + put_device(&cluster_pdev->dev); > + } > + > + if (!try_module_get(driver->owner)) { > dev_err(&r->dev, "can't get owner\n"); > break; > } > -- > 2.25.1 >