All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: xen-devel@lists.xen.org
Cc: "Viresh Kumar" <viresh.kumar@linaro.org>,
	"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>,
	"Oleksandr Tyshchenko" <olekstysh@gmail.com>,
	"Wei Liu" <wl@xen.org>, "Juergen Gross" <jgross@suse.com>,
	"Julien Grall" <julien@xen.org>,
	"Oleksandr Tyshchenko" <oleksandr_tyshchenko@epam.com>
Subject: [PATCH V2 3/6] libxl: arm: Create alloc_virtio_mmio_params()
Date: Tue, 10 May 2022 11:34:48 +0530	[thread overview]
Message-ID: <32fa4a77c76187f68b074ff1cc81d8de5f683638.1652162646.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <cover.1652162646.git.viresh.kumar@linaro.org>

Create a separate routine to allocate base and irq for a device as the
same code will be required for each device type.

Suggested-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 tools/libs/light/libxl_arm.c | 41 +++++++++++++++++++++++-------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
index 37403a2cebb1..6b95ded82dc3 100644
--- a/tools/libs/light/libxl_arm.c
+++ b/tools/libs/light/libxl_arm.c
@@ -48,6 +48,24 @@ static uint32_t alloc_virtio_mmio_irq(libxl__gc *gc, uint32_t *virtio_mmio_irq)
     return irq;
 }
 
+static int alloc_virtio_mmio_params(libxl__gc *gc, uint64_t *base,
+                                    uint32_t *irq, uint64_t *virtio_mmio_base,
+                                    uint32_t *virtio_mmio_irq)
+{
+    *base = alloc_virtio_mmio_base(gc, virtio_mmio_base);
+    if (!*base)
+        return ERROR_FAIL;
+
+    *irq = alloc_virtio_mmio_irq(gc, virtio_mmio_irq);
+    if (!*irq)
+        return ERROR_FAIL;
+
+    LOG(DEBUG, "Allocate Virtio MMIO params: IRQ %u BASE 0x%"PRIx64, *irq,
+        *base);
+
+    return 0;
+}
+
 static const char *gicv_to_string(libxl_gic_version gic_version)
 {
     switch (gic_version) {
@@ -85,25 +103,18 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
         libxl_device_disk *disk = &d_config->disks[i];
 
         if (disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO) {
-            disk->base = alloc_virtio_mmio_base(gc, &virtio_mmio_base);
-            if (!disk->base)
-                return ERROR_FAIL;
-
-            disk->irq = alloc_virtio_mmio_irq(gc, &virtio_mmio_irq);
-            if (!disk->irq)
-                return ERROR_FAIL;
-
-            if (virtio_irq < disk->irq)
-                virtio_irq = disk->irq;
-            virtio_enabled = true;
-
-            LOG(DEBUG, "Allocate Virtio MMIO params for Vdev %s: IRQ %u BASE 0x%"PRIx64,
-                disk->vdev, disk->irq, disk->base);
+            int rc = alloc_virtio_mmio_params(gc, &disk->base, &disk->irq,
+                    &virtio_mmio_base, &virtio_mmio_irq);
+            if (rc)
+                return rc;
         }
     }
 
-    if (virtio_enabled)
+    if (virtio_mmio_irq != GUEST_VIRTIO_MMIO_SPI_FIRST) {
+        virtio_irq = virtio_mmio_irq - 1;
         nr_spis += (virtio_irq - 32) + 1;
+        virtio_enabled = true;
+    }
 
     for (i = 0; i < d_config->b_info.num_irqs; i++) {
         uint32_t irq = d_config->b_info.irqs[i];
-- 
2.31.1.272.g89b43f80a514



  parent reply	other threads:[~2022-05-10  6:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10  6:04 [PATCH V2 0/6] Virtio toolstack support for I2C and GPIO on Arm Viresh Kumar
2022-05-10  6:04 ` [PATCH V2 1/6] libxl: Add support for Virtio I2C device Viresh Kumar
2022-05-10  6:04 ` [PATCH V2 2/6] libxl: Add support for Virtio GPIO device Viresh Kumar
2022-05-10  6:04 ` Viresh Kumar [this message]
2022-05-10  6:04 ` [PATCH V2 4/6] libxl: arm: Split make_virtio_mmio_node() Viresh Kumar
2022-05-10  6:04 ` [PATCH V2 5/6] libxl: Allocate MMIO params for I2c device and update DT Viresh Kumar
2022-05-10  6:04 ` [PATCH V2 6/6] libxl: Allocate MMIO params for GPIO " Viresh Kumar
2022-05-10  6:07 ` [PATCH V2 0/6] Virtio toolstack support for I2C and GPIO on Arm Viresh Kumar

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=32fa4a77c76187f68b074ff1cc81d8de5f683638.1652162646.git.viresh.kumar@linaro.org \
    --to=viresh.kumar@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=jgross@suse.com \
    --cc=julien@xen.org \
    --cc=mathieu.poirier@linaro.com \
    --cc=mike.holmes@linaro.org \
    --cc=oleksandr_tyshchenko@epam.com \
    --cc=olekstysh@gmail.com \
    --cc=stefano.stabellini@xilinx.com \
    --cc=stratos-dev@op-lists.linaro.org \
    --cc=vincent.guittot@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.