diff options
author | Marc Zyngier <marc.zyngier@arm.com> | 2016-07-17 06:27:23 -0400 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2016-07-18 13:15:16 -0400 |
commit | d97594e6bc1b4aaad3ccae3ef678513b63dd5221 (patch) | |
tree | 921513cb42ad71bfb73eb1652d4158e3492f60df | |
parent | 8c828a535e29f50282f1a49a52c3b20ccaa039aa (diff) |
KVM: arm64: vgic-its: Generalize use of vgic_get_irq_kref
Instead of sprinkling raw kref_get() calls everytime we cannot
do a normal vgic_get_irq(), use the existing vgic_get_irq_kref(),
which does the same thing and is paired with a vgic_put_irq().
vgic_get_irq_kref is moved to vgic.h in order to be easily shared.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r-- | virt/kvm/arm/vgic/vgic-its.c | 2 | ||||
-rw-r--r-- | virt/kvm/arm/vgic/vgic.c | 10 | ||||
-rw-r--r-- | virt/kvm/arm/vgic/vgic.h | 8 |
3 files changed, 10 insertions, 10 deletions
diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index d8e8f14135b4..f427fa2f7263 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c | |||
@@ -80,7 +80,7 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid) | |||
80 | * call vgic_put_irq() on the returned pointer once it's | 80 | * call vgic_put_irq() on the returned pointer once it's |
81 | * finished with the IRQ. | 81 | * finished with the IRQ. |
82 | */ | 82 | */ |
83 | kref_get(&irq->refcount); | 83 | vgic_get_irq_kref(irq); |
84 | 84 | ||
85 | goto out_unlock; | 85 | goto out_unlock; |
86 | } | 86 | } |
diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index 424cb9ceebd9..39f3358c6d91 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c | |||
@@ -71,7 +71,7 @@ static struct vgic_irq *vgic_get_lpi(struct kvm *kvm, u32 intid) | |||
71 | * This increases the refcount, the caller is expected to | 71 | * This increases the refcount, the caller is expected to |
72 | * call vgic_put_irq() later once it's finished with the IRQ. | 72 | * call vgic_put_irq() later once it's finished with the IRQ. |
73 | */ | 73 | */ |
74 | kref_get(&irq->refcount); | 74 | vgic_get_irq_kref(irq); |
75 | goto out_unlock; | 75 | goto out_unlock; |
76 | } | 76 | } |
77 | irq = NULL; | 77 | irq = NULL; |
@@ -106,14 +106,6 @@ struct vgic_irq *vgic_get_irq(struct kvm *kvm, struct kvm_vcpu *vcpu, | |||
106 | return NULL; | 106 | return NULL; |
107 | } | 107 | } |
108 | 108 | ||
109 | static void vgic_get_irq_kref(struct vgic_irq *irq) | ||
110 | { | ||
111 | if (irq->intid < VGIC_MIN_LPI) | ||
112 | return; | ||
113 | |||
114 | kref_get(&irq->refcount); | ||
115 | } | ||
116 | |||
117 | /* | 109 | /* |
118 | * We can't do anything in here, because we lack the kvm pointer to | 110 | * We can't do anything in here, because we lack the kvm pointer to |
119 | * lock and remove the item from the lpi_list. So we keep this function | 111 | * lock and remove the item from the lpi_list. So we keep this function |
diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h index 9d40d7bb89f7..1d8e21d5c13f 100644 --- a/virt/kvm/arm/vgic/vgic.h +++ b/virt/kvm/arm/vgic/vgic.h | |||
@@ -64,6 +64,14 @@ int vgic_v2_map_resources(struct kvm *kvm); | |||
64 | int vgic_register_dist_iodev(struct kvm *kvm, gpa_t dist_base_address, | 64 | int vgic_register_dist_iodev(struct kvm *kvm, gpa_t dist_base_address, |
65 | enum vgic_type); | 65 | enum vgic_type); |
66 | 66 | ||
67 | static inline void vgic_get_irq_kref(struct vgic_irq *irq) | ||
68 | { | ||
69 | if (irq->intid < VGIC_MIN_LPI) | ||
70 | return; | ||
71 | |||
72 | kref_get(&irq->refcount); | ||
73 | } | ||
74 | |||
67 | #ifdef CONFIG_KVM_ARM_VGIC_V3 | 75 | #ifdef CONFIG_KVM_ARM_VGIC_V3 |
68 | void vgic_v3_process_maintenance(struct kvm_vcpu *vcpu); | 76 | void vgic_v3_process_maintenance(struct kvm_vcpu *vcpu); |
69 | void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu); | 77 | void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu); |