Skip to content

Commit 30a0ce9

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: vgic-its: Get rid of vgic_copy_lpi_list()
The last user has been transitioned to walking the LPI xarray directly. Cut the wart off, and get rid of the now unneeded lpi_count while doing so. Signed-off-by: Oliver Upton <oliver.upton@linux.dev> Link: https://lore.kernel.org/r/20240422200158.2606761-7-oliver.upton@linux.dev Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 85d3ccc commit 30a0ce9

4 files changed

Lines changed: 0 additions & 51 deletions

File tree

arch/arm64/kvm/vgic/vgic-its.c

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,8 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,
8686
if (ret) {
8787
xa_release(&dist->lpi_xa, intid);
8888
kfree(irq);
89-
goto out_unlock;
9089
}
9190

92-
atomic_inc(&dist->lpi_count);
93-
9491
out_unlock:
9592
raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
9693

@@ -316,51 +313,6 @@ static int update_lpi_config(struct kvm *kvm, struct vgic_irq *irq,
316313
return 0;
317314
}
318315

319-
/*
320-
* Create a snapshot of the current LPIs targeting @vcpu, so that we can
321-
* enumerate those LPIs without holding any lock.
322-
* Returns their number and puts the kmalloc'ed array into intid_ptr.
323-
*/
324-
int vgic_copy_lpi_list(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 **intid_ptr)
325-
{
326-
struct vgic_dist *dist = &kvm->arch.vgic;
327-
XA_STATE(xas, &dist->lpi_xa, GIC_LPI_OFFSET);
328-
struct vgic_irq *irq;
329-
unsigned long flags;
330-
u32 *intids;
331-
int irq_count, i = 0;
332-
333-
/*
334-
* There is an obvious race between allocating the array and LPIs
335-
* being mapped/unmapped. If we ended up here as a result of a
336-
* command, we're safe (locks are held, preventing another
337-
* command). If coming from another path (such as enabling LPIs),
338-
* we must be careful not to overrun the array.
339-
*/
340-
irq_count = atomic_read(&dist->lpi_count);
341-
intids = kmalloc_array(irq_count, sizeof(intids[0]), GFP_KERNEL_ACCOUNT);
342-
if (!intids)
343-
return -ENOMEM;
344-
345-
raw_spin_lock_irqsave(&dist->lpi_list_lock, flags);
346-
rcu_read_lock();
347-
348-
xas_for_each(&xas, irq, VGIC_LPI_MAX_INTID) {
349-
if (i == irq_count)
350-
break;
351-
/* We don't need to "get" the IRQ, as we hold the list lock. */
352-
if (vcpu && irq->target_vcpu != vcpu)
353-
continue;
354-
intids[i++] = irq->intid;
355-
}
356-
357-
rcu_read_unlock();
358-
raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
359-
360-
*intid_ptr = intids;
361-
return i;
362-
}
363-
364316
static int update_affinity(struct vgic_irq *irq, struct kvm_vcpu *vcpu)
365317
{
366318
int ret = 0;

arch/arm64/kvm/vgic/vgic.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ void vgic_put_irq(struct kvm *kvm, struct vgic_irq *irq)
126126
__xa_erase(&dist->lpi_xa, irq->intid);
127127
xa_unlock_irqrestore(&dist->lpi_xa, flags);
128128

129-
atomic_dec(&dist->lpi_count);
130129
kfree_rcu(irq, rcu);
131130
}
132131

arch/arm64/kvm/vgic/vgic.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ static inline bool vgic_dist_overlap(struct kvm *kvm, gpa_t base, size_t size)
331331
}
332332

333333
bool vgic_lpis_enabled(struct kvm_vcpu *vcpu);
334-
int vgic_copy_lpi_list(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 **intid_ptr);
335334
int vgic_its_resolve_lpi(struct kvm *kvm, struct vgic_its *its,
336335
u32 devid, u32 eventid, struct vgic_irq **irq);
337336
struct vgic_its *vgic_msi_to_its(struct kvm *kvm, struct kvm_msi *msi);

include/kvm/arm_vgic.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ struct vgic_dist {
279279

280280
#define LPI_XA_MARK_DEBUG_ITER XA_MARK_0
281281
struct xarray lpi_xa;
282-
atomic_t lpi_count;
283282

284283
/* LPI translation cache */
285284
struct list_head lpi_translation_cache;

0 commit comments

Comments
 (0)