xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@citrix.com>
To: vijay.kilari@gmail.com, Ian.Campbell@citrix.com,
	stefano.stabellini@eu.citrix.com, stefano.stabellini@citrix.com,
	tim@xen.org, xen-devel@lists.xen.org
Cc: Prasun.Kapoor@caviumnetworks.com,
	Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>,
	manish.jaggi@caviumnetworks.com
Subject: Re: [PATCH v4 12/17] xen/arm: ITS: Initialize LPI irq descriptors and route
Date: Thu, 16 Jul 2015 10:37:02 +0200	[thread overview]
Message-ID: <55A76D2E.4020707@citrix.com> (raw)
In-Reply-To: <1436514172-3263-13-git-send-email-vijay.kilari@gmail.com>

Hi Vijay,

On 10/07/2015 09:42, vijay.kilari@gmail.com wrote:
> diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
> index 3806d98..c8ea627 100644
> --- a/xen/arch/arm/irq.c
> +++ b/xen/arch/arm/irq.c

[...]

>   int __init arch_init_one_irq_desc(struct irq_desc *desc)
> @@ -88,6 +97,15 @@ static int __init init_irq_data(void)
>           desc->action  = NULL;
>       }
>
> +#ifdef CONFIG_ARM_64
> +    for ( irq = NR_GIC_LPI; irq < MAX_LPI; irq++ )

NR_GIC_LPI = 4096 which is the maximum number of LPIs supported you've 
hardcoded.

Here you want to use FIRST_GIC_LPI.

> +    {
> +        struct irq_desc *desc = irq_to_desc(irq);
> +        init_one_irq_desc(desc);
> +        desc->irq = irq;
> +        desc->action  = NULL;
> +    }
> +#endif
>       return 0;
>   }
>
> @@ -208,7 +226,7 @@ int request_irq(unsigned int irq, unsigned int irqflags,
>        * which interrupt is which (messes up the interrupt freeing
>        * logic etc).
>        */
> -    if ( irq >= nr_irqs )
> +    if ( irq >= nr_irqs && !is_lpi(irq) )

It's expecting that nr_irqs will encompass SPIs, LPIs...

In this particular case, you want to use gic_is_valid_irq.

> @@ -436,7 +459,8 @@ err:
>   bool_t is_assignable_irq(unsigned int irq)
>   {
>       /* For now, we can only route SPIs to the guest */
> -    return ((irq >= NR_LOCAL_IRQS) && (irq < gic_number_lines()));
> +    return (((irq >= NR_LOCAL_IRQS) && (irq < gic_number_lines())) ||
> +              is_lpi(irq));
>   }
>
>   /*
> @@ -452,7 +476,7 @@ int route_irq_to_guest(struct domain *d, unsigned int virq,

It's not right to re-use route_irq_to_guest for a completely different 
meaning. The virq stands for virtual IRQ and not eventID.

For more details, please see my remarks on patch #8, #5 and the feature 
freeze thread.

IHMO, the prototype to route an LPI to a guest should be

route_lpi_to_guest(struct domain *d, unsigned int lpi);

[...]

>       spin_unlock_irqrestore(&desc->lock, flags);
>

[...]

> diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c
> index 25b69a0..4e14439 100644
> --- a/xen/arch/arm/vgic-v3.c
> +++ b/xen/arch/arm/vgic-v3.c
> @@ -1111,12 +1111,19 @@ static const struct mmio_handler_ops vgic_distr_mmio_handler = {
>
>   static int vgic_v3_get_irq_priority(struct vcpu *v, unsigned int irq)
>   {
> -    int priority;
> -    struct vgic_irq_rank *rank = vgic_rank_irq(v, irq);
> +    int priority = 0;
> +    struct vgic_irq_rank *rank;
>
> -    ASSERT(spin_is_locked(&rank->lock));
> -    priority = vgic_byte_read(rank->ipriority[REG_RANK_INDEX(8,
> +    if ( !is_lpi(irq) )

is_lpi is checking the validity of the host LPI not the guest LPI.

> +    {
> +        rank = vgic_rank_irq(v, irq);
> +
> +        ASSERT(spin_is_locked(&rank->lock));
> +        priority = vgic_byte_read(rank->ipriority[REG_RANK_INDEX(8,
>                                                 irq, DABT_WORD)], 0, irq & 0x3);
> +    }
> +    if ( is_lpi(irq) && gic_lpi_supported() )
> +        priority = vgic_its_get_priority(v, irq);

I'm wondering how you tested the series... To get the priority in the 
LPI configuration table, you have to use substract 8192 before reading 
in the config table. But, here you are directly using the value to read 
in the table.

>
>       return priority;
>   }
> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> index a5f66f6..8190a46 100644
> --- a/xen/arch/arm/vgic.c
> +++ b/xen/arch/arm/vgic.c
> @@ -30,6 +30,7 @@
>
>   #include <asm/mmio.h>
>   #include <asm/gic.h>
> +#include <asm/gic-its.h>

I'm not in favor to see any include of the gic-its.h in the common code. 
It will likely means that the build on arm32 is broken...

>   #include <asm/vgic.h>
>
>   static inline struct vgic_irq_rank *vgic_get_rank(struct vcpu *v, int rank)
> @@ -111,6 +112,15 @@ int domain_vgic_init(struct domain *d, unsigned int nr_spis)
>       for (i=0; i<d->arch.vgic.nr_spis; i++)
>           vgic_init_pending_irq(&d->arch.vgic.pending_irqs[i], i + 32);
>
> +#ifdef CONFIG_ARM_64
> +    d->arch.vgic.pending_lpis = xzalloc_array(struct pending_irq, NR_GIC_LPI);
> +    if ( d->arch.vgic.pending_lpis == NULL )
> +        return -ENOMEM;
> +
> +    for ( i = 0; i < NR_GIC_LPI; i++ )
> +        vgic_init_pending_irq(&d->arch.vgic.pending_lpis[i], i);
> +#endif
> +

This should go in the vITS code.

>       for (i=0; i<DOMAIN_NR_RANKS(d); i++)
>           spin_lock_init(&d->arch.vgic.shared_irqs[i].lock);
>
> @@ -157,6 +167,7 @@ void domain_vgic_free(struct domain *d)
>   #ifdef CONFIG_ARM_64
>       free_xenheap_pages(d->arch.vits->prop_page,
>                          get_order_from_bytes(d->arch.vits->prop_size));
> +    xfree(d->arch.vgic.pending_lpis);
>   #endif
>   }
>
> @@ -381,13 +392,17 @@ int vgic_to_sgi(struct vcpu *v, register_t sgir, enum gic_sgi_mode irqmode, int
>
>   struct pending_irq *irq_to_pending(struct vcpu *v, unsigned int irq)
>   {
> -    struct pending_irq *n;
> +    struct pending_irq *n = NULL;
>       /* Pending irqs allocation strategy: the first vgic.nr_spis irqs
>        * are used for SPIs; the rests are used for per cpu irqs */

Please update this comment.

>       if ( irq < 32 )
>           n = &v->arch.vgic.pending_irqs[irq];
> -    else
> +    else if ( irq < NR_IRQS )

You should use vgic_num_irqs and not NR_IRQS which is Xen specific.

>           n = &v->domain->arch.vgic.pending_irqs[irq - 32];
> +#ifdef CONFIG_ARM_64
> +    else if ( is_lpi(irq) )

You helper is_lpi is checking that the irq is valid based of the number 
of LPIs supported by the host.

In the case of the guest, the number of LPIs may be different. Please 
check this irq against the virtual gic.

> +        n = &v->domain->arch.vgic.pending_lpis[irq - FIRST_GIC_LPI];
> +#endif

Please add ASSERT(n != NULL) given that with your change, it may be 
possible to return NULL.

>       return n;
>   }
>
> @@ -413,14 +428,20 @@ void vgic_clear_pending_irqs(struct vcpu *v)
>   void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int virq)
>   {
>       uint8_t priority;
> -    struct vgic_irq_rank *rank = vgic_rank_irq(v, virq);
> +    struct vgic_irq_rank *rank;
>       struct pending_irq *iter, *n = irq_to_pending(v, virq);
>       unsigned long flags;
>       bool_t running;
>
> -    vgic_lock_rank(v, rank, flags);
> -    priority = v->domain->arch.vgic.handler->get_irq_priority(v, virq);
> -    vgic_unlock_rank(v, rank, flags);
> +    if ( virq < NR_GIC_LPI )
> +    {
> +        rank = vgic_rank_irq(v, virq);
> +        vgic_lock_rank(v, rank, flags);
> +        priority = v->domain->arch.vgic.handler->get_irq_priority(v, virq);
> +        vgic_unlock_rank(v, rank, flags);
> +    }
> +    else
> +        priority = v->domain->arch.vgic.handler->get_irq_priority(v, virq);

Why didn't you push vgic_rank_* call in get_irq_priority?

IHMO, a function should be called the same way for all the arguments 
rather than taking a lock depending on the value of the argument.

Regards,

-- 
Julien Grall

  parent reply	other threads:[~2015-07-16  8:37 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-10  7:42 [PATCH v4 00/17] Add ITS support vijay.kilari
2015-07-10  7:42 ` [PATCH v4 01/17] xen/arm: Add bitmap_find_next_zero_area helper function vijay.kilari
2015-07-10  9:01   ` Jan Beulich
2015-07-10  9:28     ` Vijay Kilari
2015-07-10  9:30       ` Vijay Kilari
2015-07-10  9:45     ` Vijay Kilari
2015-07-10 10:07       ` Jan Beulich
2015-07-10  7:42 ` [PATCH v4 02/17] xen: Add log2 functionality vijay.kilari
2015-07-10  7:42 ` [PATCH v4 03/17] xen/arm: ITS: Port ITS driver to Xen vijay.kilari
2015-07-10 13:01   ` Ian Campbell
2015-07-15 10:23   ` Julien Grall
2015-07-10  7:42 ` [PATCH v4 04/17] xen/arm: ITS: Add helper functions to manage its_devices vijay.kilari
2015-07-10 13:05   ` Ian Campbell
2015-07-15 10:37   ` Julien Grall
2015-07-15 14:21     ` Vijay Kilari
2015-07-15 14:28       ` Julien Grall
2015-07-10  7:42 ` [PATCH v4 05/17] xen/arm: ITS: implement hw_irq_controller for LPIs vijay.kilari
2015-07-10 13:46   ` Ian Campbell
2015-07-11 14:40     ` Vijay Kilari
2015-07-11 18:08       ` Julien Grall
2015-07-13  9:17       ` Ian Campbell
2015-07-13 21:18   ` Julien Grall
2015-07-15  7:16     ` Vijay Kilari
2015-07-15  8:26       ` Julien Grall
2015-07-15  9:32         ` Ian Campbell
2015-07-15  9:49           ` Julien Grall
2015-07-15 10:01             ` Ian Campbell
2015-07-15 14:15           ` Vijay Kilari
2015-07-15 14:22             ` Julien Grall
2015-07-15 14:28             ` Ian Campbell
2015-07-15 17:01               ` Vijay Kilari
2015-07-16 14:49                 ` Ian Campbell
2015-07-16 15:21                   ` Marc Zyngier
2015-07-16 16:18                     ` Ian Campbell
2015-07-16 16:27                       ` Marc Zyngier
2015-07-16 16:37                         ` Ian Campbell
2015-07-18 10:13           ` Julien Grall
2015-07-20 11:52             ` Ian Campbell
2015-07-20 12:22             ` Ian Campbell
2015-07-15 18:19   ` Julien Grall
2015-07-10  7:42 ` [PATCH v4 06/17] xen/arm: ITS: Add virtual ITS driver vijay.kilari
2015-07-10 13:54   ` Ian Campbell
2015-07-11 14:48     ` Vijay Kilari
2015-07-13  9:27       ` Ian Campbell
2015-07-10 14:15   ` Ian Campbell
2015-07-11 14:48     ` Vijay Kilari
2015-07-13  9:25       ` Ian Campbell
2015-07-15 12:17   ` Julien Grall
2015-07-10  7:42 ` [PATCH v4 07/17] xen/arm: ITS: Add virtual ITS commands support vijay.kilari
2015-07-10 14:35   ` Ian Campbell
2015-07-11 14:49     ` Vijay Kilari
2015-07-13  9:22       ` Ian Campbell
2015-07-13 11:15         ` Vijay Kilari
2015-07-13 11:37           ` Ian Campbell
2015-07-17 15:01             ` Vijay Kilari
2015-07-15 13:02     ` Julien Grall
2015-07-15 13:56       ` Ian Campbell
2015-07-15 12:57   ` Julien Grall
2015-07-17 14:12     ` Vijay Kilari
2015-07-17 15:15       ` Julien Grall
2015-07-17 15:34         ` Ian Campbell
2015-07-17 15:44           ` Julien Grall
2015-07-10  7:42 ` [PATCH v4 08/17] xen/arm: ITS: Add APIs to add and assign device vijay.kilari
2015-07-10 14:52   ` Ian Campbell
2015-07-15 13:14     ` Julien Grall
2015-07-16 13:40       ` Vijay Kilari
2015-07-16 14:38         ` Julien Grall
2015-07-15 14:15   ` Julien Grall
2015-07-18  9:44     ` Vijay Kilari
2015-07-18 10:06       ` Julien Grall
2015-07-10  7:42 ` [PATCH v4 09/17] xen/arm: ITS: Add GITS registers emulation vijay.kilari
2015-07-10 14:56   ` Ian Campbell
2015-07-15 16:13   ` Julien Grall
2015-07-10  7:42 ` [PATCH v4 10/17] xen/arm: ITS: Enable physical and virtual ITS driver compilation vijay.kilari
2015-07-15 16:16   ` Julien Grall
2015-07-10  7:42 ` [PATCH v4 11/17] xen/arm: ITS: Add GICR register emulation vijay.kilari
2015-07-10 15:10   ` Ian Campbell
2015-07-11 18:25     ` Julien Grall
2015-07-13  9:28       ` Ian Campbell
2015-07-13  9:53         ` Ian Campbell
2015-07-13 16:53   ` Stefano Stabellini
2015-07-15 17:32   ` Julien Grall
2015-07-16 14:15     ` Vijay Kilari
2015-07-16 14:41       ` Julien Grall
2015-07-16 14:46         ` Vijay Kilari
2015-07-16 14:58           ` Julien Grall
2015-07-10  7:42 ` [PATCH v4 12/17] xen/arm: ITS: Initialize LPI irq descriptors and route vijay.kilari
2015-07-10 15:30   ` Ian Campbell
2015-07-20 13:07     ` Vijay Kilari
2015-07-20 13:25       ` Julien Grall
2015-07-22 13:31     ` Vijay Kilari
2015-07-22 13:39       ` Julien Grall
2015-07-22 14:17         ` Julien Grall
2015-07-13 17:03   ` Stefano Stabellini
2015-07-13 17:13   ` Stefano Stabellini
2015-07-13 17:36     ` Julien Grall
2015-07-15 18:13   ` Julien Grall
2015-07-16  8:06     ` Julien Grall
2015-07-16  8:37   ` Julien Grall [this message]
2015-07-10  7:42 ` [PATCH v4 13/17] xen/arm: ITS: Initialize physical ITS vijay.kilari
2015-07-13 17:06   ` Stefano Stabellini
2015-07-10  7:42 ` [PATCH v4 14/17] xen/arm: ITS: Add domain specific ITS initialization vijay.kilari
2015-07-10 15:41   ` Ian Campbell
2015-07-15 17:41   ` Julien Grall
2015-07-10  7:42 ` [PATCH v4 15/17] xen/arm: ITS: Map ITS translation space vijay.kilari
2015-07-10 15:43   ` Ian Campbell
2015-07-15  9:01   ` Julien Grall
2015-07-10  7:42 ` [PATCH v4 16/17] xen/arm: ITS: Generate ITS node for Dom0 vijay.kilari
2015-07-13 16:32   ` Stefano Stabellini
2015-07-13 17:31     ` Julien Grall
2015-07-13 17:36       ` Stefano Stabellini
2015-07-10  7:42 ` [PATCH v4 17/17] xen/arm: ITS: Add pci devices in ThunderX vijay.kilari
2015-07-10 15:45   ` Ian Campbell

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=55A76D2E.4020707@citrix.com \
    --to=julien.grall@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Prasun.Kapoor@caviumnetworks.com \
    --cc=Vijaya.Kumar@caviumnetworks.com \
    --cc=manish.jaggi@caviumnetworks.com \
    --cc=stefano.stabellini@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=vijay.kilari@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).