Re: [PATCH v3 3/9] arm/arm64: KVM: vgic: Parametrize VGIC_NR_SHARED_IRQS

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

 



On Tue, Jul 08, 2014 at 12:09:02PM +0100, Marc Zyngier wrote:
> Having a dynamic number of supported interrupts means that we
> cannot relly on VGIC_NR_SHARED_IRQS being fixed anymore.
> 
> Instead, make it take the distributor structure as a parameter,
> so it can return the right value.
> 
> Signed-off-by: Marc Zyngier <marc.zyngier@xxxxxxx>
> ---
>  include/kvm/arm_vgic.h |  1 -
>  virt/kvm/arm/vgic.c    | 16 +++++++++++-----
>  2 files changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
> index 2246f4c..b8a6337 100644
> --- a/include/kvm/arm_vgic.h
> +++ b/include/kvm/arm_vgic.h
> @@ -29,7 +29,6 @@
>  #define VGIC_NR_SGIS		16
>  #define VGIC_NR_PPIS		16
>  #define VGIC_NR_PRIVATE_IRQS	(VGIC_NR_SGIS + VGIC_NR_PPIS)
> -#define VGIC_NR_SHARED_IRQS	(VGIC_NR_IRQS - VGIC_NR_PRIVATE_IRQS)
>  #define VGIC_MAX_CPUS		KVM_MAX_VCPUS
>  
>  #define VGIC_V2_MAX_LRS		(1 << 6)
> diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
> index 754d1cd..6f7cf85 100644
> --- a/virt/kvm/arm/vgic.c
> +++ b/virt/kvm/arm/vgic.c
> @@ -995,11 +995,17 @@ static void vgic_dispatch_sgi(struct kvm_vcpu *vcpu, u32 reg)
>  	}
>  }
>  
> +static int vgic_nr_shared_irqs(struct vgic_dist *dist)
> +{
> +	return dist->nr_irqs - VGIC_NR_PRIVATE_IRQS;
> +}
> +
>  static int compute_pending_for_cpu(struct kvm_vcpu *vcpu)
>  {
>  	struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
>  	unsigned long *pending, *enabled, *pend_percpu, *pend_shared;
>  	unsigned long pending_private, pending_shared;
> +	int shared = vgic_nr_shared_irqs(dist);

nit: prefer nr_shared

>  	int vcpu_id;
>  
>  	vcpu_id = vcpu->vcpu_id;
> @@ -1012,15 +1018,15 @@ static int compute_pending_for_cpu(struct kvm_vcpu *vcpu)
>  
>  	pending = vgic_bitmap_get_shared_map(&dist->irq_state);
>  	enabled = vgic_bitmap_get_shared_map(&dist->irq_enabled);
> -	bitmap_and(pend_shared, pending, enabled, VGIC_NR_SHARED_IRQS);
> +	bitmap_and(pend_shared, pending, enabled, shared);
>  	bitmap_and(pend_shared, pend_shared,
>  		   vgic_bitmap_get_shared_map(&dist->irq_spi_target[vcpu_id]),
> -		   VGIC_NR_SHARED_IRQS);
> +		   shared);
>  
>  	pending_private = find_first_bit(pend_percpu, VGIC_NR_PRIVATE_IRQS);
> -	pending_shared = find_first_bit(pend_shared, VGIC_NR_SHARED_IRQS);
> +	pending_shared = find_first_bit(pend_shared, shared);
>  	return (pending_private < VGIC_NR_PRIVATE_IRQS ||
> -		pending_shared < VGIC_NR_SHARED_IRQS);
> +		pending_shared < vgic_nr_shared_irqs(dist));
>  }
>  
>  /*
> @@ -1277,7 +1283,7 @@ static void __kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu)
>  	}
>  
>  	/* SPIs */
> -	for_each_set_bit(i, vgic_cpu->pending_shared, VGIC_NR_SHARED_IRQS) {
> +	for_each_set_bit(i, vgic_cpu->pending_shared, vgic_nr_shared_irqs(dist)) {
>  		if (!vgic_queue_hwirq(vcpu, i + VGIC_NR_PRIVATE_IRQS))
>  			overflow = 1;
>  	}
> -- 
> 2.0.0
> 

There are a number of places in patch 2 where you do "nr_irqs -
VGIC_NR_PRIVATE_IRQS" which you could change to use this as well now.

Otherwise:

Reviewed-by: Christoffer Dall <christoffer.dall@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux