All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleksandr <olekstysh@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>, xen-devel@lists.xen.org
Cc: "Vincent Guittot" <vincent.guittot@linaro.org>,
	stratos-dev@op-lists.linaro.org,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Stefano Stabellini" <stefano.stabellini@xilinx.com>,
	"Mathieu Poirier" <mathieu.poirier@linaro.com>,
	"Mike Holmes" <mike.holmes@linaro.org>, "Wei Liu" <wl@xen.org>,
	"Juergen Gross" <jgross@suse.com>,
	"Julien Grall" <julien@xen.org>
Subject: Re: [PATCH V3 4/6] libxl: arm: Split make_virtio_mmio_node()
Date: Mon, 8 Aug 2022 22:32:43 +0300	[thread overview]
Message-ID: <43fd61cf-b66f-b45a-c501-2b68e40c004a@gmail.com> (raw)
In-Reply-To: <ae20b87d583b981302905059d157a03400cd8eb2.1659596139.git.viresh.kumar@linaro.org>


On 04.08.22 10:01, Viresh Kumar wrote:

Hello Viresh

> make_virtio_mmio_node() creates the DT node for simple MMIO devices
> currently, i.e. the ones that don't require any additional properties.
>
> In order to allow using it for other complex device types, split the
> functionality into two, one where the fdt node isn't closed and the
> other one to create a simple DT node.
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>   tools/libs/light/libxl_arm.c | 24 ++++++++++++++----------
>   1 file changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
> index 2f64b9f0ebee..6a8c4d042bd9 100644
> --- a/tools/libs/light/libxl_arm.c
> +++ b/tools/libs/light/libxl_arm.c
> @@ -900,9 +900,8 @@ static int make_xen_iommu_node(libxl__gc *gc, void *fdt)
>       return 0;
>   }
>   
> -static int make_virtio_mmio_node(libxl__gc *gc, void *fdt,
> -                                 uint64_t base, uint32_t irq,
> -                                 uint32_t backend_domid)
> +static int make_virtio_mmio_node_common(libxl__gc *gc, void *fdt, uint64_t base,
> +                                        uint32_t irq)
>   {
>       int res;
>       gic_interrupt intr;
> @@ -922,7 +921,15 @@ static int make_virtio_mmio_node(libxl__gc *gc, void *fdt,
>       res = fdt_property_interrupts(gc, fdt, &intr, 1);
>       if (res) return res;
>   
> -    res = fdt_property(fdt, "dma-coherent", NULL, 0);
> +    return fdt_property(fdt, "dma-coherent", NULL, 0);
> +}
> +
> +static int make_virtio_mmio_node_simple(libxl__gc *gc, void *fdt, uint64_t base,
> +                                        uint32_t irq, uint32_t backend_domid)
> +{
> +    int res;
> +
> +    res = make_virtio_mmio_node_common(gc, fdt, base, irq);
>       if (res) return res;
>   
>       if (backend_domid != LIBXL_TOOLSTACK_DOMID) {
> @@ -935,10 +942,7 @@ static int make_virtio_mmio_node(libxl__gc *gc, void *fdt,
>           if (res) return res;
>       }
>   
> -    res = fdt_end_node(fdt);
> -    if (res) return res;
> -
> -    return 0;
> +    return fdt_end_node(fdt);
>   }
>   
>   static const struct arch_info *get_arch_info(libxl__gc *gc,
> @@ -1261,8 +1265,8 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_config *d_config,
>                       iommu_created = true;
>                   }
>   
> -                FDT( make_virtio_mmio_node(gc, fdt, disk->base, disk->irq,
> -                                           disk->backend_domid) );
> +                FDT( make_virtio_mmio_node_simple(gc, fdt, disk->base,
> +                                            disk->irq, disk->backend_domid) );
>               }
>           }

[I failed to find a better place where to make a comment]


I think that the following chunk should be also moved to 
make_virtio_mmio_node_common() since it is not a virtio disk specific 
action, this "iommus" property pointing to "xen,grant-dma" IOMMU node is 
used to inform a guest that restricted memory access using Xen grant 
mappings needs to be enabled for the virtio device if it's backend is 
going to run in a non hardware domain, which I assume also applies for 
virtio i2c, etc.


     if (backend_domid != LIBXL_TOOLSTACK_DOMID) {
         uint32_t iommus_prop[2];

         iommus_prop[0] = cpu_to_fdt32(GUEST_PHANDLE_IOMMU);
         iommus_prop[1] = cpu_to_fdt32(backend_domid);

         res = fdt_property(fdt, "iommus", iommus_prop, 
sizeof(iommus_prop));
         if (res) return res;
     }


This means that "uint32_t backend_domid" should be also passed as 
argument to make_virtio_mmio_node_common()


Something like the diff on top of current patch below (not tested):

diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
index a98cfe708b..1a6ace3d8d 100644
--- a/tools/libs/light/libxl_arm.c
+++ b/tools/libs/light/libxl_arm.c
@@ -900,7 +900,7 @@ static int make_xen_iommu_node(libxl__gc *gc, void *fdt)
  }

  static int make_virtio_mmio_node_common(libxl__gc *gc, void *fdt, 
uint64_t base,
-                                        uint32_t irq)
+                                        uint32_t irq, uint32_t 
backend_domid)
  {
      int res;
      gic_interrupt intr;
@@ -920,15 +920,7 @@ static int make_virtio_mmio_node_common(libxl__gc 
*gc, void *fdt, uint64_t base,
      res = fdt_property_interrupts(gc, fdt, &intr, 1);
      if (res) return res;

-    return fdt_property(fdt, "dma-coherent", NULL, 0);
-}
-
-static int make_virtio_mmio_node_simple(libxl__gc *gc, void *fdt, 
uint64_t base,
-                                        uint32_t irq, uint32_t 
backend_domid)
-{
-    int res;
-
-    res = make_virtio_mmio_node_common(gc, fdt, base, irq);
+    res = fdt_property(fdt, "dma-coherent", NULL, 0);
      if (res) return res;

      if (backend_domid != LIBXL_TOOLSTACK_DOMID) {
@@ -941,6 +933,17 @@ static int make_virtio_mmio_node_simple(libxl__gc 
*gc, void *fdt, uint64_t base,
          if (res) return res;
      }

+    return res;
+}
+
+static int make_virtio_mmio_node_simple(libxl__gc *gc, void *fdt, 
uint64_t base,
+                                        uint32_t irq, uint32_t 
backend_domid)
+{
+    int res;
+
+    res = make_virtio_mmio_node_common(gc, fdt, base, irq, backend_domid);
+    if (res) return res;
+
      return fdt_end_node(fdt);
  }


Other changes look good.


>   

-- 
Regards,

Oleksandr Tyshchenko



  reply	other threads:[~2022-08-08 19:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04  7:01 [PATCH V3 0/6] Virtio toolstack support for I2C and GPIO on Arm Viresh Kumar
2022-08-04  7:01 ` [PATCH V3 1/6] libxl: Add support for Virtio I2C device Viresh Kumar
2022-08-04  7:01 ` [PATCH V3 2/6] libxl: Add support for Virtio GPIO device Viresh Kumar
2022-08-04  7:01 ` [PATCH V3 3/6] libxl: arm: Create alloc_virtio_mmio_params() Viresh Kumar
2022-08-08 18:39   ` Oleksandr
2022-08-09  4:29     ` Viresh Kumar
2022-08-09  5:35       ` Viresh Kumar
2022-08-04  7:01 ` [PATCH V3 4/6] libxl: arm: Split make_virtio_mmio_node() Viresh Kumar
2022-08-08 19:32   ` Oleksandr [this message]
2022-08-04  7:01 ` [PATCH V3 5/6] libxl: Allocate MMIO params for I2c device and update DT Viresh Kumar
2022-08-08 20:18   ` Oleksandr
2022-08-04  7:01 ` [PATCH V3 6/6] libxl: Allocate MMIO params for GPIO " Viresh Kumar
2022-08-08 21:09   ` Oleksandr
2022-08-08 21:16 ` [PATCH V3 0/6] Virtio toolstack support for I2C and GPIO on Arm Oleksandr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=43fd61cf-b66f-b45a-c501-2b68e40c004a@gmail.com \
    --to=olekstysh@gmail.com \
    --cc=alex.bennee@linaro.org \
    --cc=jgross@suse.com \
    --cc=julien@xen.org \
    --cc=mathieu.poirier@linaro.com \
    --cc=mike.holmes@linaro.org \
    --cc=stefano.stabellini@xilinx.com \
    --cc=stratos-dev@op-lists.linaro.org \
    --cc=vincent.guittot@linaro.org \
    --cc=viresh.kumar@linaro.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.