xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <Ian.Campbell@citrix.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	"Tim (Xen.org)" <tim@xen.org>
Subject: Re: [PATCH 1/7] xen/arm: fix rank calculation in vgic_vcpu_inject_irq
Date: Fri, 26 Oct 2012 21:47:20 +0100	[thread overview]
Message-ID: <1351284440.12176.9.camel@dagon.hellion.org.uk> (raw)
In-Reply-To: <alpine.DEB.2.02.1210261940300.2689@kaball.uk.xensource.com>

On Fri, 2012-10-26 at 19:42 +0100, Stefano Stabellini wrote:
> I think that the problem is the usage of vgic_irq_rank with registers
> that have 1 bit per interrupt.

That's very plausible indeed.

> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> index 3c3983f..92731b6 100644
> --- a/xen/arch/arm/vgic.c
> +++ b/xen/arch/arm/vgic.c
> @@ -42,13 +42,7 @@
>   */
>  static inline int REG_RANK_NR(int b, uint32_t n)
>  {
> -    switch ( b )
> -    {
> -    case 8: return n >> 3;
> -    case 4: return n >> 2;
> -    case 2: return n >> 1;
> -    default: BUG();
> -    }
> +    return n / b;

All the infrastructure will fall apart if b isn't a power of two, that's
why I used the switch. Can you just add the appropriate case 1 instead?
Probably the bug should be a call to an undefined function to make this
a compile time rather than runtime failure too.

> @@ -577,9 +571,9 @@ struct pending_irq *irq_to_pending(struct vcpu *v, unsigned int irq)
>  
>  void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq, int virtual)

The changes to this function are all unnecessary, since it was already
consistent within itself. If you want to change it please add a helper
which takes an irq and hides the shifts.

I'd be inclined to rename the existing vgic_irq_rank to vgic_reg_rank
and then call the new helper vgic_irq_rank since that would better
reflect the purpose of both.

>  {
> -    int idx = irq >> 2, byte = irq & 0x3;
> +    int byte = irq & 0x3;

byte isn't actually needed either.

>      uint8_t priority;
> -    struct vgic_irq_rank *rank = vgic_irq_rank(v, 8, idx);
> +    struct vgic_irq_rank *rank = vgic_irq_rank(v, 1, irq / 32);
>      struct pending_irq *iter, *n = irq_to_pending(v, irq);
>      unsigned long flags;
>  
> @@ -587,7 +581,7 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq, int virtual)
>      if (!list_empty(&n->inflight))
>          return;
>  
> -    priority = byte_read(rank->ipriority[REG_RANK_INDEX(8, idx)], 0, byte);
> +    priority = byte_read(rank->ipriority[REG_RANK_INDEX(8, irq / 4)], 0, byte);
>  
>      n->irq = irq;
>      n->priority = priority;

  reply	other threads:[~2012-10-26 20:47 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-24 15:03 [PATCH 0/7] xen/arm: run on real hardware Stefano Stabellini
2012-10-24 15:03 ` [PATCH 1/7] xen/arm: fix rank calculation in vgic_vcpu_inject_irq Stefano Stabellini
2012-10-25  9:27   ` Ian Campbell
2012-10-26 16:33     ` Stefano Stabellini
2012-10-26 16:40       ` Ian Campbell
2012-10-26 18:42         ` Stefano Stabellini
2012-10-26 20:47           ` Ian Campbell [this message]
2012-10-27 10:09             ` Tim Deegan
2012-10-27 10:44               ` Ian Campbell
2012-11-13 11:57               ` Stefano Stabellini
2012-11-13 12:00                 ` Ian Campbell
2012-11-13 12:23                   ` Stefano Stabellini
2012-10-24 15:03 ` [PATCH 2/7] xen/arm: setup the fixmap in head.S Stefano Stabellini
2012-10-24 15:27   ` Tim Deegan
2012-10-24 15:37     ` Stefano Stabellini
2012-10-25  9:33   ` Ian Campbell
2012-10-25 11:00     ` Stefano Stabellini
2012-10-24 15:03 ` [PATCH 3/7] pl011: set baud and clock_hz to the right defaults for Versatile Express Stefano Stabellini
2012-10-25  9:37   ` Ian Campbell
2012-10-25 10:57     ` Stefano Stabellini
2012-10-25 11:00       ` Ian Campbell
2012-10-24 15:03 ` [PATCH 4/7] xen/arm: set the SMP bit in the ACTLR register Stefano Stabellini
2012-10-25  9:52   ` Ian Campbell
2012-10-25 11:57     ` Stefano Stabellini
2012-10-25 12:04       ` Ian Campbell
2012-10-26  8:56         ` Tim Deegan
2012-10-26  8:59           ` Ian Campbell
2012-10-24 15:03 ` [PATCH 5/7] xen/arm: wake up secondary cpus Stefano Stabellini
2012-10-24 15:38   ` Tim Deegan
2012-10-24 15:59     ` Stefano Stabellini
2012-10-24 16:05       ` Tim Deegan
2012-10-25  9:59   ` Ian Campbell
2012-10-25 17:45     ` Stefano Stabellini
2012-10-26  7:30       ` Ian Campbell
2012-10-26 11:18         ` Stefano Stabellini
2012-10-26 12:16           ` Ian Campbell
2012-10-26 15:24             ` Stefano Stabellini
2012-10-26 15:32               ` Ian Campbell
2012-10-24 15:03 ` [PATCH 6/7] xen/arm: flush D-cache and I-cache when appropriate Stefano Stabellini
2012-10-24 15:59   ` Tim Deegan
2012-10-24 16:05     ` Ian Campbell
2012-10-24 16:17       ` Tim Deegan
2012-10-24 17:35     ` Stefano Stabellini
2012-10-26  9:01       ` Tim Deegan
2012-10-26 15:53         ` Stefano Stabellini
2012-10-26 15:55           ` Stefano Stabellini
2012-10-26 16:03             ` Stefano Stabellini
2012-10-26 16:55               ` Tim Deegan
2012-10-26 18:40                 ` Stefano Stabellini
2012-10-27 10:44                   ` Tim Deegan
2012-10-27 11:54                     ` Tim Deegan
2012-10-29  9:53                       ` Stefano Stabellini
2012-10-29  9:52                     ` Stefano Stabellini
2012-11-13 12:01                     ` Stefano Stabellini
2012-11-13 12:15                       ` Tim Deegan
2012-10-26 16:45           ` Tim Deegan
2012-10-24 15:03 ` [PATCH 7/7] xen/arm: get the number of cpus from device tree Stefano Stabellini
2012-10-25 10:02   ` Ian Campbell
2012-10-24 16:02 ` [PATCH 0/7] xen/arm: run on real hardware Tim Deegan

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=1351284440.12176.9.camel@dagon.hellion.org.uk \
    --to=ian.campbell@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xensource.com \
    /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).