diff mbox

[Xen-devel,RFC,2/8] xen/arm: gic: Do not configure affinity for guest IRQ during routing

Message ID 1465318123-3090-3-git-send-email-julien.grall@arm.com
State New
Headers show

Commit Message

Julien Grall June 7, 2016, 4:48 p.m. UTC
The affinity of a guest IRQ is set every time the guest enable it (see
vgic_enable_irqs).

It is not necessary to set the affinity when the IRQ is routed to the
guest because Xen will never receive the IRQ until it hass been enabled
by the guest.

Signed-off-by: Julien grall <julien.grall@arm.com>
---
 xen/arch/arm/gic.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Comments

Julien Grall June 22, 2016, 11:19 a.m. UTC | #1
Hi Stefano,

On 22/06/16 11:54, Stefano Stabellini wrote:
> On Tue, 7 Jun 2016, Julien Grall wrote:
>> The affinity of a guest IRQ is set every time the guest enable it (see
>> vgic_enable_irqs).
>>
>> It is not necessary to set the affinity when the IRQ is routed to the
>> guest because Xen will never receive the IRQ until it hass been enabled
>> by the guest.
>>
>> Signed-off-by: Julien grall <julien.grall@arm.com>
>> ---
>>   xen/arch/arm/gic.c | 10 ++++------
>>   1 file changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
>> index 8a1087b..f25381f 100644
>> --- a/xen/arch/arm/gic.c
>> +++ b/xen/arch/arm/gic.c
>> @@ -97,17 +97,13 @@ void gic_restore_state(struct vcpu *v)
>>   }
>>
>>   /*
>> - * needs to be called with a valid cpu_mask, ie each cpu in the mask has
>> - * already called gic_cpu_init
>>    * - desc.lock must be held
>>    * - arch.type must be valid (i.e != IRQ_TYPE_INVALID)
>>    */
>>   static void gic_set_irq_properties(struct irq_desc *desc,
>> -                                   const cpumask_t *cpu_mask,
>>                                      unsigned int priority)
>>   {
>>       gic_hw_ops->set_irq_properties(desc, priority);
>> -    desc->handler->set_affinity(desc, cpu_mask);
>>   }
>>
>>   /* Program the GIC to route an interrupt to the host (i.e. Xen)
>> @@ -123,7 +119,9 @@ void gic_route_irq_to_xen(struct irq_desc *desc, const cpumask_t *cpu_mask,
>>
>>       desc->handler = gic_hw_ops->gic_host_irq_type;
>>
>> -    gic_set_irq_properties(desc, cpu_mask, priority);
>> +    desc->handler->set_affinity(desc, cpu_mask);
>
> You could call irq_set_affinity here, it might make for nicer code.
>
> Actually thinking more about this, I think it would be better to add the
> irq_set_affinity call to xen/arch/arm/irq.c:setup_irq, right after the
> call to gic_route_irq_to_xen.  That way both gic_route_irq_to_xen and
> gic_route_irq_to_guest would behave the same way: just setup the routing
> and not the affinity.
>
> What do you think?

I am fine to call irq_set_affinity from setup_irq. It makes more sense 
than calling the former from gic_route_irq_to_xen.

I will make the change in the next version.

Cheers,
diff mbox

Patch

diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index 8a1087b..f25381f 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -97,17 +97,13 @@  void gic_restore_state(struct vcpu *v)
 }
 
 /*
- * needs to be called with a valid cpu_mask, ie each cpu in the mask has
- * already called gic_cpu_init
  * - desc.lock must be held
  * - arch.type must be valid (i.e != IRQ_TYPE_INVALID)
  */
 static void gic_set_irq_properties(struct irq_desc *desc,
-                                   const cpumask_t *cpu_mask,
                                    unsigned int priority)
 {
     gic_hw_ops->set_irq_properties(desc, priority);
-    desc->handler->set_affinity(desc, cpu_mask);
 }
 
 /* Program the GIC to route an interrupt to the host (i.e. Xen)
@@ -123,7 +119,9 @@  void gic_route_irq_to_xen(struct irq_desc *desc, const cpumask_t *cpu_mask,
 
     desc->handler = gic_hw_ops->gic_host_irq_type;
 
-    gic_set_irq_properties(desc, cpu_mask, priority);
+    desc->handler->set_affinity(desc, cpu_mask);
+
+    gic_set_irq_properties(desc, priority);
 }
 
 /* Program the GIC to route an interrupt to a guest
@@ -155,7 +153,7 @@  int gic_route_irq_to_guest(struct domain *d, unsigned int virq,
     desc->handler = gic_hw_ops->gic_guest_irq_type;
     set_bit(_IRQ_GUEST, &desc->status);
 
-    gic_set_irq_properties(desc, cpumask_of(v_target->processor), priority);
+    gic_set_irq_properties(desc, priority);
 
     p->desc = desc;
     res = 0;