Re: [PATCH 03/15] ARM: KVM: vgic: move bitmap/bytemap accessors into vgic.c

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

 



On Thu, Nov 29, 2012 at 12:16 PM, Marc Zyngier <marc.zyngier@xxxxxxx> wrote:
> The accessors for the various VGIC data structures don't need to
> be in the include file, as they only used by vgic.c.
>
> Move them where they belong.
>
> Signed-off-by: Marc Zyngier <marc.zyngier@xxxxxxx>
> ---
>  arch/arm/include/asm/kvm_vgic.h | 81 -----------------------------------------
>  arch/arm/kvm/vgic.c             | 81 +++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 81 insertions(+), 81 deletions(-)
>
> diff --git a/arch/arm/include/asm/kvm_vgic.h b/arch/arm/include/asm/kvm_vgic.h
> index 7a5e196..c222b49 100644
> --- a/arch/arm/include/asm/kvm_vgic.h
> +++ b/arch/arm/include/asm/kvm_vgic.h
> @@ -59,57 +59,6 @@ struct vgic_bitmap {
>         } shared;
>  };
>
> -static inline u32 *vgic_bitmap_get_reg(struct vgic_bitmap *x,
> -                                      int cpuid, u32 offset)
> -{
> -       offset >>= 2;
> -       BUG_ON(offset > (VGIC_NR_IRQS / 32));
> -       if (!offset)
> -               return x->percpu[cpuid].reg;
> -       else
> -               return x->shared.reg + offset - 1;
> -}
> -
> -static inline int vgic_bitmap_get_irq_val(struct vgic_bitmap *x,
> -                                        int cpuid, int irq)
> -{
> -       if (irq < 32)
> -               return test_bit(irq, x->percpu[cpuid].reg_ul);
> -
> -       return test_bit(irq - 32, x->shared.reg_ul);
> -}
> -
> -static inline void vgic_bitmap_set_irq_val(struct vgic_bitmap *x,
> -                                          int cpuid, int irq, int val)
> -{
> -       unsigned long *reg;
> -
> -       if (irq < 32)
> -               reg = x->percpu[cpuid].reg_ul;
> -       else {
> -               reg =  x->shared.reg_ul;
> -               irq -= 32;
> -       }
> -
> -       if (val)
> -               set_bit(irq, reg);
> -       else
> -               clear_bit(irq, reg);
> -}
> -
> -static inline unsigned long *vgic_bitmap_get_cpu_map(struct vgic_bitmap *x,
> -                                                    int cpuid)
> -{
> -       if (unlikely(cpuid >= VGIC_MAX_CPUS))
> -               return NULL;
> -       return x->percpu[cpuid].reg_ul;
> -}
> -
> -static inline unsigned long *vgic_bitmap_get_shared_map(struct vgic_bitmap *x)
> -{
> -       return x->shared.reg_ul;
> -}
> -
>  struct vgic_bytemap {
>         union {
>                 u32 reg[8];
> @@ -121,36 +70,6 @@ struct vgic_bytemap {
>         } shared;
>  };
>
> -static inline u32 *vgic_bytemap_get_reg(struct vgic_bytemap *x,
> -                                       int cpuid, u32 offset)
> -{
> -       offset >>= 2;
> -       BUG_ON(offset > (VGIC_NR_IRQS / 4));
> -       if (offset < 4)
> -               return x->percpu[cpuid].reg + offset;
> -       else
> -               return x->shared.reg + offset - 8;
> -}
> -
> -static inline int vgic_bytemap_get_irq_val(struct vgic_bytemap *x,
> -                                          int cpuid, int irq)
> -{
> -       u32 *reg, shift;
> -       shift = (irq & 3) * 8;
> -       reg = vgic_bytemap_get_reg(x, cpuid, irq);
> -       return (*reg >> shift) & 0xff;
> -}
> -
> -static inline void vgic_bytemap_set_irq_val(struct vgic_bytemap *x,
> -                                           int cpuid, int irq, int val)
> -{
> -       u32 *reg, shift;
> -       shift = (irq & 3) * 8;
> -       reg = vgic_bytemap_get_reg(x, cpuid, irq);
> -       *reg &= ~(0xff << shift);
> -       *reg |= (val & 0xff) << shift;
> -}
> -
>  struct vgic_dist {
>  #ifdef CONFIG_KVM_ARM_VGIC
>         spinlock_t              lock;
> diff --git a/arch/arm/kvm/vgic.c b/arch/arm/kvm/vgic.c
> index 6ac6b11..2976f2c 100644
> --- a/arch/arm/kvm/vgic.c
> +++ b/arch/arm/kvm/vgic.c
> @@ -94,6 +94,87 @@ static void vgic_dispatch_sgi(struct kvm_vcpu *vcpu, u32 reg);
>
>  static u32 vgic_nr_lr;
>
> +static inline u32 *vgic_bitmap_get_reg(struct vgic_bitmap *x,
> +                                      int cpuid, u32 offset)
> +{
> +       offset >>= 2;
> +       BUG_ON(offset > (VGIC_NR_IRQS / 32));
> +       if (!offset)
> +               return x->percpu[cpuid].reg;
> +       else
> +               return x->shared.reg + offset - 1;
> +}
> +
> +static inline int vgic_bitmap_get_irq_val(struct vgic_bitmap *x,
> +                                        int cpuid, int irq)
> +{
> +       if (irq < 32)
> +               return test_bit(irq, x->percpu[cpuid].reg_ul);
> +
> +       return test_bit(irq - 32, x->shared.reg_ul);
> +}
> +
> +static inline void vgic_bitmap_set_irq_val(struct vgic_bitmap *x,
> +                                          int cpuid, int irq, int val)
> +{
> +       unsigned long *reg;
> +
> +       if (irq < 32)
> +               reg = x->percpu[cpuid].reg_ul;
> +       else {
> +               reg =  x->shared.reg_ul;
> +               irq -= 32;
> +       }
> +
> +       if (val)
> +               set_bit(irq, reg);
> +       else
> +               clear_bit(irq, reg);
> +}
> +
> +static inline unsigned long *vgic_bitmap_get_cpu_map(struct vgic_bitmap *x,
> +                                                    int cpuid)
> +{
> +       if (unlikely(cpuid >= VGIC_MAX_CPUS))
> +               return NULL;
> +       return x->percpu[cpuid].reg_ul;
> +}
> +
> +static inline unsigned long *vgic_bitmap_get_shared_map(struct vgic_bitmap *x)
> +{
> +       return x->shared.reg_ul;
> +}
> +
> +static inline u32 *vgic_bytemap_get_reg(struct vgic_bytemap *x,
> +                                       int cpuid, u32 offset)
> +{
> +       offset >>= 2;
> +       BUG_ON(offset > (VGIC_NR_IRQS / 4));
> +       if (offset < 4)
> +               return x->percpu[cpuid].reg + offset;
> +       else
> +               return x->shared.reg + offset - 8;
> +}
> +
> +static inline int vgic_bytemap_get_irq_val(struct vgic_bytemap *x,
> +                                          int cpuid, int irq)
> +{
> +       u32 *reg, shift;
> +       shift = (irq & 3) * 8;
> +       reg = vgic_bytemap_get_reg(x, cpuid, irq);
> +       return (*reg >> shift) & 0xff;
> +}
> +
> +static inline void vgic_bytemap_set_irq_val(struct vgic_bytemap *x,
> +                                           int cpuid, int irq, int val)
> +{
> +       u32 *reg, shift;
> +       shift = (irq & 3) * 8;
> +       reg = vgic_bytemap_get_reg(x, cpuid, irq);
> +       *reg &= ~(0xff << shift);
> +       *reg |= (val & 0xff) << shift;
> +}
> +
>  static inline int vgic_irq_is_edge(struct vgic_dist *dist, int irq)
>  {
>         return vgic_bitmap_get_irq_val(&dist->irq_cfg, 0, irq);
> --
> 1.8.0.1
>
I'll nuke the inline keywords, but otherwise looks fine.

-Christoffer
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm


[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux