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

Re: [Xen-devel] [PATCH 4/5] xen/vgic: vgic: support irq enable/disable



On Wed, 2012-06-06 at 12:22 +0100, Stefano Stabellini wrote:
> If vgic_vcpu_inject_irq is called (for example by a device emulator like
> vtimer.c) but the corresponding irq is not enabled in the virtual gicd
> just queue it in the inflight_irqs list.


> When the irq is enabled make sure to call gic_set_guest_irq.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>

I had to go reread the comments on inflight_irqs and lr_pending again
(I'm perpetually confused by that stuff) but I think this makes sense.

Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

> ---
>  xen/arch/arm/vgic.c |   23 ++++++++++++++++++++++-
>  1 files changed, 22 insertions(+), 1 deletions(-)
> 
> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> index 5a624bd..4cdfec5 100644
> --- a/xen/arch/arm/vgic.c
> +++ b/xen/arch/arm/vgic.c
> @@ -343,6 +343,22 @@ read_as_zero:
>      return 1;
>  }
>  
> +static void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n)
> +{
> +    struct pending_irq *p;
> +    unsigned int irq;
> +    int i = 0;
> +
> +    while ( (i = find_next_bit((const long unsigned int *) &r,
> +                        sizeof(uint32_t), i)) < sizeof(uint32_t) ) {
> +        irq = i + (32 * n);
> +        p = irq_to_pending(v, irq);
> +        if ( !list_empty(&p->inflight) )
> +            gic_set_guest_irq(v, irq, GICH_LR_PENDING, p->priority);
> +        i++;

what you have here is a for loop ;-)

> +    }
> +}
> +
>  static int vgic_distr_mmio_write(struct vcpu *v, mmio_info_t *info)
>  {
>      struct hsr_dabt dabt = info->dabt;
> @@ -351,6 +367,7 @@ static int vgic_distr_mmio_write(struct vcpu *v, 
> mmio_info_t *info)
>      struct vgic_irq_rank *rank;
>      int offset = (int)(info->gpa - VGIC_DISTR_BASE_ADDRESS);
>      int gicd_reg = REG(offset);
> +    uint32_t tr;
>  
>      switch ( gicd_reg )
>      {
> @@ -378,8 +395,10 @@ static int vgic_distr_mmio_write(struct vcpu *v, 
> mmio_info_t *info)
>          rank = vgic_irq_rank(v, 8, gicd_reg - GICD_ISENABLER);
>          if ( rank == NULL) goto write_ignore;
>          vgic_lock_rank(v, rank);
> +        tr = rank->ienable;
>          rank->ienable |= *r;
>          vgic_unlock_rank(v, rank);
> +        vgic_enable_irqs(v, (*r) & (~tr), gicd_reg - GICD_ISENABLER);
>          return 1;
>  
>      case GICD_ICENABLER ... GICD_ICENABLERN:
> @@ -569,7 +588,9 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int 
> irq, int virtual)
>      else
>          n->desc = NULL;
>  
> -    gic_set_guest_irq(v, irq, GICH_LR_PENDING, priority);
> +    /* the irq is enabled */
> +    if ( rank->ienable & (1 << (irq % 32)) )
> +        gic_set_guest_irq(v, irq, GICH_LR_PENDING, priority);
>  
>      spin_lock_irqsave(&v->arch.vgic.lock, flags);
>      list_for_each_entry ( iter, &v->arch.vgic.inflight_irqs, inflight )



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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