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 6/6] libxl: Allocate MMIO params for GPIO device and update DT
Date: Tue, 9 Aug 2022 00:09:53 +0300 [thread overview]
Message-ID: <6b7cc481-78a1-e979-351e-e8135c5afa21@gmail.com> (raw)
In-Reply-To: <20af3a836d0ddd0d73024f8c10f7325e89ef19d8.1659596139.git.viresh.kumar@linaro.org>
On 04.08.22 10:01, Viresh Kumar wrote:
Hello Viresh
> This patch allocates Virtio MMIO params (IRQ and memory region) and pass
> them to the backend, also update Guest device-tree based on Virtio GPIO
> DT bindings [1].
>
> [1] https://www.kernel.org/doc/Documentation/devicetree/bindings/gpio/gpio-virtio.yaml
>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> tools/libs/light/libxl_arm.c | 47 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 47 insertions(+)
>
> diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
> index 08a1499c9523..14b95087f027 100644
> --- a/tools/libs/light/libxl_arm.c
> +++ b/tools/libs/light/libxl_arm.c
> @@ -121,6 +121,15 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
> return rc;
> }
>
> + for (i = 0; i < d_config->num_gpios; i++) {
> + libxl_device_gpio *gpio = &d_config->gpios[i];
> +
> + int rc = alloc_virtio_mmio_params(gc, &gpio->base, &gpio->irq,
> + &virtio_mmio_base, &virtio_mmio_irq);
> + if (rc)
> + return rc;
> + }
> +
> /*
> * Every virtio-mmio device uses one emulated SPI. If Virtio devices are
> * present, make sure that we allocate enough SPIs for them.
> @@ -974,6 +983,38 @@ static int make_virtio_mmio_node_i2c(libxl__gc *gc, void *fdt, uint64_t base,
> return fdt_end_node(fdt);
> }
>
> +static int make_virtio_mmio_node_gpio(libxl__gc *gc, void *fdt, uint64_t base,
> + uint32_t irq)
> +{
> + int res;
> +
> + res = make_virtio_mmio_node_common(gc, fdt, base, irq);
> + if (res) return res;
> +
> + res = fdt_begin_node(fdt, "gpio");
> + if (res) return res;
> +
> + res = fdt_property_compat(gc, fdt, 1, "virtio,device29");
> + if (res) return res;
> +
> + res = fdt_property(fdt, "gpio-controller", NULL, 0);
> + if (res) return res;
> +
> + res = fdt_property_cell(fdt, "#gpio-cells", 2);
> + if (res) return res;
> +
> + res = fdt_property(fdt, "interrupt-controller", NULL, 0);
> + if (res) return res;
> +
> + res = fdt_property_cell(fdt, "#interrupt-cells", 2);
> + if (res) return res;
> +
> + res = fdt_end_node(fdt);
> + if (res) return res;
> +
> + return fdt_end_node(fdt);
> +}
> +
> static const struct arch_info *get_arch_info(libxl__gc *gc,
> const struct xc_dom_image *dom)
> {
> @@ -1305,6 +1346,12 @@ static int libxl__prepare_dtb(libxl__gc *gc, libxl_domain_config *d_config,
> FDT( make_virtio_mmio_node_i2c(gc, fdt, i2c->base, i2c->irq) );
> }
>
> + for (i = 0; i < d_config->num_gpios; i++) {
> + libxl_device_gpio *gpio = &d_config->gpios[i];
> +
> + FDT( make_virtio_mmio_node_gpio(gc, fdt, gpio->base, gpio->irq) );
> + }
> +
> if (pfdt)
> FDT( copy_partial_fdt(gc, fdt, pfdt) );
I think that patch needs to be updated taking into the account
suggestions provided for two previous patches (of course, if you agree
with them).
If so, the make_virtio_mmio_node_gpio() should gain "uint32_t
backend_domid" argument, etc. And we need to make sure that
make_xen_iommu_node() will be called for virtio gpio.
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 9bd8d49f3c..54756b3dd5 100644
--- a/tools/libs/light/libxl_arm.c
+++ b/tools/libs/light/libxl_arm.c
@@ -986,11 +986,11 @@ static int make_virtio_mmio_node_i2c(libxl__gc
*gc, void *fdt, uint64_t base,
}
static int make_virtio_mmio_node_gpio(libxl__gc *gc, void *fdt,
uint64_t base,
- uint32_t irq)
+ uint32_t irq, uint32_t backend_domid)
{
int res;
- res = make_virtio_mmio_node_common(gc, fdt, base, irq);
+ res = make_virtio_mmio_node_common(gc, fdt, base, irq, backend_domid);
if (res) return res;
res = fdt_begin_node(fdt, "gpio");
@@ -1350,8 +1350,11 @@ next_resize:
for (i = 0; i < d_config->num_gpios; i++) {
libxl_device_gpio *gpio = &d_config->gpios[i];
+ if (gpio->backend_domid != LIBXL_TOOLSTACK_DOMID)
+ iommu_needed = true;
- FDT( make_virtio_mmio_node_gpio(gc, fdt, gpio->base,
gpio->irq) );
+ FDT( make_virtio_mmio_node_gpio(gc, fdt, gpio->base, gpio->irq,
+ gpio->backend_domid) );
}
/*
Other changes look good.
>
--
Regards,
Oleksandr Tyshchenko
next prev parent reply other threads:[~2022-08-08 21:10 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
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 [this message]
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=6b7cc481-78a1-e979-351e-e8135c5afa21@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.