[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH V4 3/6] libxl: arm: Create alloc_virtio_mmio_params()


  • To: Viresh Kumar <viresh.kumar@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxx>
  • From: Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>
  • Date: Thu, 18 Aug 2022 20:23:34 +0000
  • Accept-language: en-US, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=r9DWcifWU+G3Zh2A62u8zbbaWoeAyndDyjxsBaQK+ac=; b=nsDJslhGaClLUdOGexBKtnifh4e53WLJzTSEjniPWN0MCcZCsRAwfK3XTiJf3geKDV5PAfs/1XXCUxyWe9UyR+tZuSmBTT1zTWoYBzl5KesntJ3XOCP+Ze+OpyaZu1Wbsqd5mCapfr5EMVbOjk8x59djMy16hVMeBsnTeYVQoTVOAYvqLGD9BFotRwOA2CWHv5oZypeNDLS0IGghzJw6Y9m7YmmhlVPTCXC77Wvt1N9Vru8tuzN+XDZYvuQKHUVhZx9buzcyC6ZFqFQsHytOHTLle5mcvveTgYElP5mWWLlEUZJq+VQPxSIp2zOUYAEC725hgVj6h8URVyYvZ5l7fw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EFV0Y8B1cDu7VZtXlCnxAJt7liSEatxK/rQG+e3VI/PQLspBY2x1tfGdj/tyv/eTQqLQQbN1gBpFudITFTSCIiCXZjBr12Owb7n6Zk4bIT7hSoGV1bPYPdHj3IlXg/OG8T6fPu/wBQPGh+LLq01isLYdmDNHQ/NWAPX4kg+xMPxXbkjPK1bKCFcDSMF6BfTy163KUupkOTLvtbg3pt9l2R6qxdWCy7F3f9evMxhY3wX7VFtWvNH6h6mOgXDkn3p+3IxFI8OkljjIqtF9/A8SHz1X9Jjgi8tizAXgAhoomqqFLLqy2Wi5wel7cXDMCRmNSZS1BMT4s+VGZOqR3xv4hQ==
  • Cc: Vincent Guittot <vincent.guittot@xxxxxxxxxx>, "stratos-dev@xxxxxxxxxxxxxxxxxxx" <stratos-dev@xxxxxxxxxxxxxxxxxxx>, Alex Bennée <alex.bennee@xxxxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>, Mathieu Poirier <mathieu.poirier@xxxxxxxxxx>, Mike Holmes <mike.holmes@xxxxxxxxxx>, Oleksandr Tyshchenko <olekstysh@xxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Julien Grall <julien@xxxxxxx>
  • Delivery-date: Thu, 18 Aug 2022 20:24:06 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHYq7HHxdH3vCIKzUyor6bJAooA4621KSKA
  • Thread-topic: [PATCH V4 3/6] libxl: arm: Create alloc_virtio_mmio_params()

On 09.08.22 08:34, Viresh Kumar wrote:

Hello Viresh

> 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@xxxxxxxx>
> Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
> ---
>   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 1a3ac1646e94..4a750852b671 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,20 +103,10 @@ 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);

Nit: Something wrong with the indentation and looks like the blank line 
is needed here.


> +            if (rc)
> +                return rc;
>           }
>       }
>   
> @@ -107,8 +115,11 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
>        * present, make sure that we allocate enough SPIs for them.
>        * The resulting "nr_spis" needs to cover the highest possible SPI.
>        */
> -    if (virtio_enabled)
> +    if (virtio_mmio_irq != GUEST_VIRTIO_MMIO_SPI_FIRST) {
> +        virtio_enabled = true;
> +        virtio_irq = virtio_mmio_irq - 1;


Well, here we assume that "virtio_mmio_irq" is always the highest 
allocated irq, currently it is true because we increment the counter in 
alloc_virtio_mmio_irq(),

but this logic might be changed in future. So I would probably add a 
comment in code about that assumption.


>           nr_spis = max(nr_spis, virtio_irq - 32 + 1);
> +    }
>   
>       for (i = 0; i < d_config->b_info.num_irqs; i++) {
>           uint32_t irq = d_config->b_info.irqs[i];


With above fixed:

Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>

-- 
Regards,

Oleksandr Tyshchenko

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.