| 
    
 [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH V5 3/6] libxl: arm: Create alloc_virtio_mmio_params()
 On Mon, Aug 22, 2022 at 02:45:15PM +0530, Viresh Kumar wrote:
> 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>
> Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
> Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
> ---
>  tools/libs/light/libxl_arm.c | 46 +++++++++++++++++++++++++-----------
>  1 file changed, 32 insertions(+), 14 deletions(-)
> 
> diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
> index 1a3ac1646e94..0e3051bac5e4 100644
> --- a/tools/libs/light/libxl_arm.c
> +++ b/tools/libs/light/libxl_arm.c
> @@ -85,20 +103,12 @@ 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;
> +            int rc = alloc_virtio_mmio_params(gc, &disk->base, &disk->irq,
> +                                              &virtio_mmio_base,
> +                                              &virtio_mmio_irq);
>  
> -            if (virtio_irq < disk->irq)
> -                virtio_irq = disk->irq;
> -            virtio_enabled = true;
This change to virtio_irq and virtio_enabled, as well as the chunck
below, isn't explained in the patch description.
> -
> -            LOG(DEBUG, "Allocate Virtio MMIO params for Vdev %s: IRQ %u BASE 
> 0x%"PRIx64,
> -                disk->vdev, disk->irq, disk->base);
> +            if (rc)
> +                return rc;
>          }
>      }
>  
> @@ -107,8 +117,16 @@ 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;
> +
> +        /*
> +         * Assumes that "virtio_mmio_irq" is the highest allocated irq, 
> which is
> +         * updated from alloc_virtio_mmio_irq() currently.
> +         */
> +        virtio_irq = virtio_mmio_irq - 1;
>          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];
Thanks,
-- 
Anthony PERARD
  | 
  
![]()  | 
            
         Lists.xenproject.org is hosted with RackSpace, monitoring our  |