linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: christoffer.dall@linaro.org (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 6/9] arm/arm64: KVM: vgic: kill VGIC_NR_IRQS
Date: Tue, 5 Aug 2014 15:58:56 +0200	[thread overview]
Message-ID: <20140805135856.GJ524@cbox> (raw)
In-Reply-To: <1404817748-31302-7-git-send-email-marc.zyngier@arm.com>

On Tue, Jul 08, 2014 at 12:09:05PM +0100, Marc Zyngier wrote:
> Nuke VGIC_NR_IRQS entierly, now that the distributor instance
> contains the number of IRQ allocated to this GIC.
> 
> Also add VGIC_NR_IRQS_LEGACY to preserve the current API.
> 
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
>  include/kvm/arm_vgic.h |  6 +++---
>  virt/kvm/arm/vgic.c    | 17 +++++++++++------
>  2 files changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
> index 98ab604..9feb7fe 100644
> --- a/include/kvm/arm_vgic.h
> +++ b/include/kvm/arm_vgic.h
> @@ -25,7 +25,7 @@
>  #include <linux/spinlock.h>
>  #include <linux/types.h>
>  
> -#define VGIC_NR_IRQS		256
> +#define VGIC_NR_IRQS_LEGACY	256
>  #define VGIC_NR_SGIS		16
>  #define VGIC_NR_PPIS		16
>  #define VGIC_NR_PRIVATE_IRQS	(VGIC_NR_SGIS + VGIC_NR_PPIS)
> @@ -39,11 +39,11 @@
>  #error	Invalid number of CPU interfaces
>  #endif
>  
> -#if (VGIC_NR_IRQS & 31)
> +#if (VGIC_NR_IRQS_LEGACY & 31)
>  #error "VGIC_NR_IRQS must be a multiple of 32"
>  #endif
>  
> -#if (VGIC_NR_IRQS > VGIC_MAX_IRQS)
> +#if (VGIC_NR_IRQS_LEGACY > VGIC_MAX_IRQS)
>  #error "VGIC_NR_IRQS must be <= 1024"
>  #endif
>  
> diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
> index b2ef7ff..47a14a1 100644
> --- a/virt/kvm/arm/vgic.c
> +++ b/virt/kvm/arm/vgic.c
> @@ -395,7 +395,7 @@ static bool handle_mmio_misc(struct kvm_vcpu *vcpu,
>  
>  	case 4:			/* GICD_TYPER */
>  		reg  = (atomic_read(&vcpu->kvm->online_vcpus) - 1) << 5;
> -		reg |= (VGIC_NR_IRQS >> 5) - 1;
> +		reg |= (vcpu->kvm->arch.vgic.nr_irqs >> 5) - 1;
>  		vgic_reg_access(mmio, &reg, word_offset,
>  				ACCESS_READ_VALUE | ACCESS_WRITE_IGNORED);
>  		break;
> @@ -1186,13 +1186,14 @@ static void vgic_retire_disabled_irqs(struct kvm_vcpu *vcpu)
>  static bool vgic_queue_irq(struct kvm_vcpu *vcpu, u8 sgi_source_id, int irq)
>  {
>  	struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
> +	struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
>  	struct vgic_lr vlr;
>  	int lr;
>  
>  	/* Sanitize the input... */
>  	BUG_ON(sgi_source_id & ~7);
>  	BUG_ON(sgi_source_id && irq >= VGIC_NR_SGIS);
> -	BUG_ON(irq >= VGIC_NR_IRQS);
> +	BUG_ON(irq >= dist->nr_irqs);
>  
>  	kvm_debug("Queue IRQ%d\n", irq);
>  
> @@ -1409,7 +1410,7 @@ static void __kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu)
>  
>  		vlr = vgic_get_lr(vcpu, lr);
>  
> -		BUG_ON(vlr.irq >= VGIC_NR_IRQS);
> +		BUG_ON(vlr.irq >= dist->nr_irqs);
>  		vgic_cpu->vgic_irq_lr_map[vlr.irq] = LR_EMPTY;
>  	}
>  
> @@ -1620,7 +1621,7 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu)
>  	if (vcpu->vcpu_id >= dist->nr_cpus)
>  		return -EBUSY;
>  
> -	for (i = 0; i < VGIC_NR_IRQS; i++) {
> +	for (i = 0; i < dist->nr_irqs; i++) {
>  		if (i < VGIC_NR_PPIS)
>  			vgic_bitmap_set_irq_val(&dist->irq_enabled,
>  						vcpu->vcpu_id, i, 1);
> @@ -1759,7 +1760,11 @@ static int vgic_init_maps(struct kvm *kvm)
>  	int ret, i;
>  
>  	nr_cpus = dist->nr_cpus = KVM_MAX_VCPUS;
> -	nr_irqs = dist->nr_irqs = VGIC_NR_IRQS;
> +
> +	if (!dist->nr_irqs)
> +		dist->nr_irqs = VGIC_NR_IRQS_LEGACY;
> +
> +	nr_irqs = dist->nr_irqs;
>  
>  	ret  = vgic_init_bitmap(&dist->irq_enabled, nr_cpus, nr_irqs);
>  	ret |= vgic_init_bitmap(&dist->irq_state, nr_cpus, nr_irqs);
> @@ -1841,7 +1846,7 @@ int kvm_vgic_init(struct kvm *kvm)
>  		goto out;
>  	}
>  
> -	for (i = VGIC_NR_PRIVATE_IRQS; i < VGIC_NR_IRQS; i += 4)
> +	for (i = VGIC_NR_PRIVATE_IRQS; i < kvm->arch.vgic.nr_irqs; i += 4)
>  		vgic_set_target_reg(kvm, 0, i);
>  
>  	kvm->arch.vgic.ready = true;
> -- 
> 2.0.0
> 

Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>

  reply	other threads:[~2014-08-05 13:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-08 11:08 [PATCH v3 0/9] arm/arm64: KVM: dynamic VGIC sizing Marc Zyngier
2014-07-08 11:09 ` [PATCH v3 1/9] KVM: ARM: vgic: plug irq injection race Marc Zyngier
2014-07-08 11:09 ` [PATCH v3 2/9] arm/arm64: KVM: vgic: switch to dynamic allocation Marc Zyngier
2014-08-05 13:39   ` Christoffer Dall
2014-07-08 11:09 ` [PATCH v3 3/9] arm/arm64: KVM: vgic: Parametrize VGIC_NR_SHARED_IRQS Marc Zyngier
2014-08-05 13:42   ` Christoffer Dall
2014-07-08 11:09 ` [PATCH v3 4/9] arm/arm64: KVM: vgic: kill VGIC_MAX_CPUS Marc Zyngier
2014-08-05 13:49   ` Christoffer Dall
2014-07-08 11:09 ` [PATCH v3 5/9] arm/arm64: KVM: vgic: handle out-of-range MMIO accesses Marc Zyngier
2014-08-05 13:56   ` Christoffer Dall
2014-07-08 11:09 ` [PATCH v3 6/9] arm/arm64: KVM: vgic: kill VGIC_NR_IRQS Marc Zyngier
2014-08-05 13:58   ` Christoffer Dall [this message]
2014-07-08 11:09 ` [PATCH v3 7/9] arm/arm64: KVM: vgic: delay vgic allocation until init time Marc Zyngier
2014-08-05 15:34   ` Christoffer Dall
2014-07-08 11:09 ` [PATCH v3 8/9] arm/arm64: KVM: vgic: make number of irqs a configurable attribute Marc Zyngier
2014-08-05 15:39   ` Christoffer Dall
2014-07-08 11:09 ` [PATCH v3 9/9] arm64: KVM: vgic: deal with GIC sub-page alignment Marc Zyngier
2014-08-05 15:43   ` Christoffer Dall

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=20140805135856.GJ524@cbox \
    --to=christoffer.dall@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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).