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

Re: [Xen-devel] [PATCH v3 1/6] xen/arm: introduce handle_interrupts


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Fri, 9 Aug 2019 17:33:40 +0000
  • Accept-language: en-US
  • 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-SenderADCheck; bh=eWtFnyJJpyMOcKUC4Gr1rlvK0XxtLkiJK4EwXuouD90=; b=WzDTjpUKyDOFLsKJ2cU5VA3gqw1aECSe7ynO+yqLSQSzENGcZMlli8JsZ9zuWWoKbR4jadAwHhJ1DFKnFqatoxi7WTcCbxpWRKpbMYwIyEfGAghxgDK32QUMr7RvCWChr0gE3gqbTrwGwV+uXARx5qwfCigvuVzMaaF3hufxiHekarJ8wmoH5Pn06p8nRMh+9aS827gEkYR8n66PVVLpBP7Y0wxY0CqQoXIkjn4l0QpU2UDoVQ2qGyah+0GxfNGS/4zqHRmDmpI0awPPlOKr/zkuAKsNefSY6800G0gHCTiAyROzoEEtlDVVIl9jy/2094+i43qOpSH4OSSdusmUDA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T/1EqsmuCpP5Egs6jwHuBlGMWlfPmoei8U5QtUssqxzTWFXMRp6+qZjZ1OuA8s0tyVgxDiqDQxNyDi+JA9OokaWY75647NmxNd0M4DXQsFIZkGVH4c6pfc9qUsPXNSiyK+vwGMs3OJjE8AFYHpK10wGHrxHx0udrMa9gGqP1u25rlobpuuRANkhmEm9ggDG+IhK+OWfNqZdoYJIfwtpQz11yTmGOkJmWLg2HfmlEpUY07kt4ZfS6ABUuOUpb74crJJ1zK3B9X9t6ATyArhCEEtPh3Uf5lw3In7zwNXyq1EvDGuN3/2r+//rThT6xUzzIfFAoF5emXtEKdWRvAICQng==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Volodymyr_Babchuk@xxxxxxxx;
  • Cc: Stefano Stabellini <stefanos@xxxxxxxxxx>, Andrii Anisov <Andrii_Anisov@xxxxxxxx>, "Achin.Gupta@xxxxxxx" <Achin.Gupta@xxxxxxx>, "xen-devel@xxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxx>, "julien.grall@xxxxxxx" <julien.grall@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 09 Aug 2019 17:33:53 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHVTj7KzpUXXywUoU2ZhjZPPLmT4qbzFKwA
  • Thread-topic: [PATCH v3 1/6] xen/arm: introduce handle_interrupts

Hello Stefano,

Stefano Stabellini writes:

> Move the interrupt handling code out of handle_device to a new function
> so that it can be reused for dom0less VMs later.
>
> Signed-off-by: Stefano Stabellini <stefanos@xxxxxxxxxx>
> ---
> Changes in v3:
> - add patch
>
> The diff is hard to read but I just moved the interrupts related code
> from handle_devices to a new function handle_interrupts, and very little
> else.
> ---
>  xen/arch/arm/domain_build.c | 79 +++++++++++++++++++++++--------------
>  1 file changed, 49 insertions(+), 30 deletions(-)
>
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 4c8404155a..00ddb3b05d 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1220,41 +1220,19 @@ static int __init map_device_children(struct domain 
> *d,
>  }
>
>  /*
> - * For a given device node:
> - *  - Give permission to the guest to manage IRQ and MMIO range
> - *  - Retrieve the IRQ configuration (i.e edge/level) from device tree
> - * When the device is not marked for guest passthrough:
> - *  - Assign the device to the guest if it's protected by an IOMMU
> - *  - Map the IRQs and iomem regions to DOM0
> + * Return:
> + *   < 0 on error
> + *   0   on no mapping required
> + *   1   IRQ mapping done
>   */
Are this such returns values really needed? I don't see any code that
depends on return value 0 or 1.

> -static int __init handle_device(struct domain *d, struct dt_device_node *dev,
> -                                p2m_type_t p2mt)
> +static int __init handle_interrupts(struct domain *d,
> +                                    struct dt_device_node *dev,
> +                                    bool need_mapping)
>  {
> -    unsigned int nirq;
> -    unsigned int naddr;
> -    unsigned int i;
> -    int res;
> +    int i, nirq, res;
>      struct dt_raw_irq rirq;
> -    u64 addr, size;
> -    bool need_mapping = !dt_device_for_passthrough(dev);
>
>      nirq = dt_number_of_irq(dev);
> -    naddr = dt_number_of_address(dev);
> -
> -    dt_dprintk("%s passthrough = %d nirq = %d naddr = %u\n",
> -               dt_node_full_name(dev), need_mapping, nirq, naddr);
> -
> -    if ( dt_device_is_protected(dev) && need_mapping )
> -    {
> -        dt_dprintk("%s setup iommu\n", dt_node_full_name(dev));
> -        res = iommu_assign_dt_device(d, dev);
> -        if ( res )
> -        {
> -            printk(XENLOG_ERR "Failed to setup the IOMMU for %s\n",
> -                   dt_node_full_name(dev));
> -            return res;
> -        }
> -    }
>
>      /* Give permission and map IRQs */
>      for ( i = 0; i < nirq; i++ )
> @@ -1291,6 +1269,47 @@ static int __init handle_device(struct domain *d, 
> struct dt_device_node *dev,
>              return res;
>      }
>
> +    return !!(need_mapping && res == 0);
> +}
> +
> +/*
> + * For a given device node:
> + *  - Give permission to the guest to manage IRQ and MMIO range
> + *  - Retrieve the IRQ configuration (i.e edge/level) from device tree
> + * When the device is not marked for guest passthrough:
> + *  - Assign the device to the guest if it's protected by an IOMMU
> + *  - Map the IRQs and iomem regions to DOM0
> + */
> +static int __init handle_device(struct domain *d, struct dt_device_node *dev,
> +                                p2m_type_t p2mt)
> +{
> +    unsigned int naddr;
> +    unsigned int i;
> +    int res;
> +    u64 addr, size;
> +    bool need_mapping = !dt_device_for_passthrough(dev);
> +
> +    naddr = dt_number_of_address(dev);
> +
> +    dt_dprintk("%s passthrough = %d naddr = %u\n",
> +               dt_node_full_name(dev), need_mapping, naddr);
> +
> +    if ( dt_device_is_protected(dev) && need_mapping )
> +    {
> +        dt_dprintk("%s setup iommu\n", dt_node_full_name(dev));
> +        res = iommu_assign_dt_device(d, dev);
> +        if ( res )
> +        {
> +            printk(XENLOG_ERR "Failed to setup the IOMMU for %s\n",
> +                   dt_node_full_name(dev));
> +            return res;
> +        }
> +    }
> +
> +    res = handle_interrupts(d, dev, need_mapping);
> +    if ( res < 0 )
> +        return res;
> +
>      /* Give permission and map MMIOs */
>      for ( i = 0; i < naddr; i++ )
>      {


--
Volodymyr Babchuk at EPAM
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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