KVM: arm64: vgic-v4: Use helper function irq_get_irq_data()
PATCH 1/1 KVM: arm64: vgic-v4: Use helper function irq_get_irq_data()
The returned value of irq_to_desc() is only used to get the irq_data by calling irq_desc_get_irq_data(), and there is a helper function irq_get_irq_data() which has already provided the functionality. So, use irq_get_irq_data() to make the code more simple.
--- arch/arm64/kvm/vgic/vgic-v4.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/arm64/kvm/vgic/vgic-v4.c +2 -6
@@ -124,7 +124,6 @@ static void vgic_v4_enable_vsgis(struct kvm_vcpu *vcpu)*/ for (i =0 ; i <VGIC_NR_SGIS ; i++) {struct vgic_irq *irq =vgic_get_irq (vcpu->kvm, vcpu, i); -struct irq_desc *desc;unsigned long flags;int ret;
@@ -138,8 +137,7 @@ static void vgic_v4_enable_vsgis(struct kvm_vcpu *vcpu)/* Transfer the full irq state to the vPE */ vgic_v4_sync_sgi_config (vpe, irq); - desc =irq_to_desc (irq->host_irq); - ret =irq_domain_activate_irq (irq_desc_get_irq_data (desc), + ret =irq_domain_activate_irq (irq_get_irq_data (irq->host_irq), false);if (!WARN_ON (ret)) {/* Transfer pending state */
@@ -161,7 +159,6 @@ static void vgic_v4_disable_vsgis(struct kvm_vcpu *vcpu)for (i =0 ; i <VGIC_NR_SGIS ; i++) {struct vgic_irq *irq =vgic_get_irq (vcpu->kvm, vcpu, i); -struct irq_desc *desc;unsigned long flags;int ret;
@@ -176,8 +173,7 @@ static void vgic_v4_disable_vsgis(struct kvm_vcpu *vcpu) &irq->pending_latch);WARN_ON (ret); - desc =irq_to_desc (irq->host_irq); -irq_domain_deactivate_irq (irq_desc_get_irq_data (desc)); +irq_domain_deactivate_irq (irq_get_irq_data (irq->host_irq)); unlock:raw_spin_unlock_irqrestore (&irq->irq_lock, flags);vgic_put_irq (vcpu->kvm, irq);
Signature · 1 line
2.17.1
Marc Zyngier
maintainerQuoted 5 lines · Zhang Zekun
The returned value of
irq_to_desc()is only used to get theirq_databy callingirq_desc_get_irq_data(), and there is a helper functionirq_get_irq_data()which has already provided the functionality. So, useirq_get_irq_data()to make the code more simple.
Unfortunately, simpler doesn't equate to better.
Quoted 19 lines
Signed-off-by Zhang Zekun <[email protected]>--- arch/arm64/kvm/vgic/vgic-v4.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)arch/arm64/kvm/vgic/vgic-v4.c +0
-1@@ -124,7 +124,6 @@ static void vgic_v4_enable_vsgis(struct kvm_vcpu *vcpu)*/ for (i =0 ; i <VGIC_NR_SGIS ; i++) {struct vgic_irq *irq =vgic_get_irq (vcpu->kvm, vcpu, i); -struct irq_desc *desc;unsigned long flags;int ret;
arch/arm64/kvm/vgic/vgic-v4.c static void vgic_v4_enable_vsgis(struct kvm_vcpu *vcpu) · line 141
Quoted 7 lines
arch/arm64/kvm/vgic/vgic-v4.c +1
-2@@ -138,8 +137,7 @@ static void vgic_v4_enable_vsgis(struct kvm_vcpu *vcpu)/* Transfer the full irq state to the vPE */ vgic_v4_sync_sgi_config (vpe, irq); - desc =irq_to_desc (irq->host_irq); - ret =irq_domain_activate_irq (irq_desc_get_irq_data (desc), + ret =irq_domain_activate_irq (irq_get_irq_data (irq->host_irq), false);
And you are still performing two lookups (one in the domain, one in the mapple tree), when everything could be solve with one:
arch/arm64/kvm/vgic/vgic-v4.c +1 -2
@@ -134,11 +134,10 @@ static void vgic_v4_enable_vsgis(struct kvm_vcpu *vcpu) goto unlock; irq->hw = true; - irq->host_irq =irq_find_mapping (vpe->sgi_domain, i); + desc =__irq_resolve_mapping (vpe->sgi_domain, i, &irq->host_irq);/* Transfer the full irq state to the vPE */ vgic_v4_sync_sgi_config (vpe, irq); - desc =irq_to_desc (irq->host_irq); ret =irq_domain_activate_irq (irq_desc_get_irq_data (desc), false);if (!WARN_ON (ret)) {
So no, I'm not going to change this just to drop a local variable. If we are going to change something, it is to improve the *result*.
Thanks,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.