diff mbox

[v2] arm/irq: Reorder check when the IRQ is already used by someone

Message ID 1480948573-22061-1-git-send-email-olekstysh@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Oleksandr Tyshchenko Dec. 5, 2016, 2:36 p.m. UTC
From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

Call irq_get_domain for the IRQ we are interested in
only after making sure that it is the guest IRQ to avoid
ASSERT(test_bit(_IRQ_GUEST, &desc->status)) triggering.

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Signed-off-by: Andrii Anisov <andrii_anisov@epam.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/irq.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

Comments

Julien Grall Dec. 6, 2016, 4:08 p.m. UTC | #1
Hi Oleksandr,

On 05/12/16 14:36, Oleksandr Tyshchenko wrote:
> From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
>
> Call irq_get_domain for the IRQ we are interested in
> only after making sure that it is the guest IRQ to avoid
> ASSERT(test_bit(_IRQ_GUEST, &desc->status)) triggering.
>
> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
> Signed-off-by: Andrii Anisov <andrii_anisov@epam.com>
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien.grall@arm.com>

Given that Stefano already queued the patch, I was asking if you could 
provide an increment of the patch to remove a layer of if.

Sorry if I was not clear.

Cheers,

> ---
>  xen/arch/arm/irq.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
> index 06d4843..6d7e44e 100644
> --- a/xen/arch/arm/irq.c
> +++ b/xen/arch/arm/irq.c
> @@ -477,26 +477,28 @@ int route_irq_to_guest(struct domain *d, unsigned int virq,
>       */
>      if ( desc->action != NULL )
>      {
> -        struct domain *ad = irq_get_domain(desc);
> -
> -        if ( test_bit(_IRQ_GUEST, &desc->status) && d == ad )
> +        if ( test_bit(_IRQ_GUEST, &desc->status) )
>          {
> -            if ( irq_get_guest_info(desc)->virq != virq )
> +            struct domain *ad = irq_get_domain(desc);
> +
> +            if ( d != ad )
> +            {
> +                printk(XENLOG_G_ERR "IRQ %u is already used by domain %u\n",
> +                       irq, ad->domain_id);
> +                retval = -EBUSY;
> +            } else if ( irq_get_guest_info(desc)->virq != virq )
>              {
>                  printk(XENLOG_G_ERR
>                         "d%u: IRQ %u is already assigned to vIRQ %u\n",
>                         d->domain_id, irq, irq_get_guest_info(desc)->virq);
>                  retval = -EBUSY;
>              }
> -            goto out;
>          }
> -
> -        if ( test_bit(_IRQ_GUEST, &desc->status) )
> -            printk(XENLOG_G_ERR "IRQ %u is already used by domain %u\n",
> -                   irq, ad->domain_id);
>          else
> +        {
>              printk(XENLOG_G_ERR "IRQ %u is already used by Xen\n", irq);
> -        retval = -EBUSY;
> +            retval = -EBUSY;
> +        }
>          goto out;
>      }
>
>
diff mbox

Patch

diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index 06d4843..6d7e44e 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -477,26 +477,28 @@  int route_irq_to_guest(struct domain *d, unsigned int virq,
      */
     if ( desc->action != NULL )
     {
-        struct domain *ad = irq_get_domain(desc);
-
-        if ( test_bit(_IRQ_GUEST, &desc->status) && d == ad )
+        if ( test_bit(_IRQ_GUEST, &desc->status) )
         {
-            if ( irq_get_guest_info(desc)->virq != virq )
+            struct domain *ad = irq_get_domain(desc);
+
+            if ( d != ad )
+            {
+                printk(XENLOG_G_ERR "IRQ %u is already used by domain %u\n",
+                       irq, ad->domain_id);
+                retval = -EBUSY;
+            } else if ( irq_get_guest_info(desc)->virq != virq )
             {
                 printk(XENLOG_G_ERR
                        "d%u: IRQ %u is already assigned to vIRQ %u\n",
                        d->domain_id, irq, irq_get_guest_info(desc)->virq);
                 retval = -EBUSY;
             }
-            goto out;
         }
-
-        if ( test_bit(_IRQ_GUEST, &desc->status) )
-            printk(XENLOG_G_ERR "IRQ %u is already used by domain %u\n",
-                   irq, ad->domain_id);
         else
+        {
             printk(XENLOG_G_ERR "IRQ %u is already used by Xen\n", irq);
-        retval = -EBUSY;
+            retval = -EBUSY;
+        }
         goto out;
     }