lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2ad011e7-e8e0-9e53-6062-7f922f8cbf43@amd.com>
Date:   Wed, 14 Dec 2022 14:27:46 -0800
From:   Ben Levinsky <ben.levinsky@....com>
To:     Mathieu Poirier <mathieu.poirier@...aro.org>, andersson@...nel.org
Cc:     linux-remoteproc@...r.kernel.org, linux-kernel@...r.kernel.org,
        "Shah, Tanmay" <tanmay.shah@....com>
Subject: Re: [PATCH] remoteproc: Make rproc_get_by_phandle() work for clusters

Tested-by: Ben Levinsky <ben.levinsky@....com>

On 12/14/22 2:16 PM, Mathieu Poirier wrote:
> CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.
> 
> 
> 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.
> 
> Reported-by: Ben Levinsky <ben.levinsky@...inx.com>
> Signed-off-by: Mathieu Poirier <mathieu.poirier@...aro.org>
> ---
>   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 <linux/idr.h>
>   #include <linux/elf.h>
>   #include <linux/crc32.h>
> +#include <linux/of_platform.h>
>   #include <linux/of_reserved_mem.h>
>   #include <linux/virtio_ids.h>
>   #include <linux/virtio_ring.h>
> @@ -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
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ