diff mbox

[Xen-devel,v2,08/16] xen/arm: IRQ Introduce irq_get_domain

Message ID 1396557727-19102-9-git-send-email-julien.grall@linaro.org
State Superseded, archived
Headers show

Commit Message

Julien Grall April 3, 2014, 8:41 p.m. UTC
This function retrieves a domain from an IRQ. It will be used in several
places (such as do_IRQ) to avoid duplicated code when multiple action will be
supported.

Signed-off-by: Julien Grall <julien.grall@linaro.org>

---
    Changes in v2:
        - Patch added
---
 xen/arch/arm/irq.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Ian Campbell April 7, 2014, 1:15 p.m. UTC | #1
On Thu, 2014-04-03 at 21:41 +0100, Julien Grall wrote:
> This function retrieves a domain from an IRQ. It will be used in several
> places (such as do_IRQ) to avoid duplicated code when multiple action will be
> supported.
> 
> Signed-off-by: Julien Grall <julien.grall@linaro.org>

Acked-by: Ian Campbell <ian.campbell@citrix.com>

> ---
>     Changes in v2:
>         - Patch added
> ---
>  xen/arch/arm/irq.c |   11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
> index f3a30bd..5111b90 100644
> --- a/xen/arch/arm/irq.c
> +++ b/xen/arch/arm/irq.c
> @@ -98,6 +98,15 @@ void __cpuinit init_secondary_IRQ(void)
>      BUG_ON(init_local_irq_data() < 0);
>  }
>  
> +static inline struct domain *irq_get_domain(struct irq_desc *desc)
> +{
> +    ASSERT(spin_is_locked(&desc->lock));
> +    ASSERT(desc->status & IRQ_GUEST);

I don't know if this will be helpful for any of the forthcoming callers
but you could return DOMID_XEN if this isn't the case.

> +    ASSERT(desc->action != NULL);
> +
> +    return desc->action->dev_id;
> +}
> +
>  int request_dt_irq(const struct dt_irq *irq,
>                     void (*handler)(int, void *, struct cpu_user_regs *),
>                     const char *devname, void *dev_id)
> @@ -156,7 +165,7 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq)
>  
>      if ( desc->status & IRQ_GUEST )
>      {
> -        struct domain *d = action->dev_id;
> +        struct domain *d = irq_get_domain(desc);
>  
>          desc->handler->end(desc);
>
Julien Grall April 7, 2014, 1:44 p.m. UTC | #2
On 04/07/2014 02:15 PM, Ian Campbell wrote:
> On Thu, 2014-04-03 at 21:41 +0100, Julien Grall wrote:
>> This function retrieves a domain from an IRQ. It will be used in several
>> places (such as do_IRQ) to avoid duplicated code when multiple action will be
>> supported.
>>
>> Signed-off-by: Julien Grall <julien.grall@linaro.org>
> 
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
> 
>> ---
>>     Changes in v2:
>>         - Patch added
>> ---
>>  xen/arch/arm/irq.c |   11 ++++++++++-
>>  1 file changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
>> index f3a30bd..5111b90 100644
>> --- a/xen/arch/arm/irq.c
>> +++ b/xen/arch/arm/irq.c
>> @@ -98,6 +98,15 @@ void __cpuinit init_secondary_IRQ(void)
>>      BUG_ON(init_local_irq_data() < 0);
>>  }
>>  
>> +static inline struct domain *irq_get_domain(struct irq_desc *desc)
>> +{
>> +    ASSERT(spin_is_locked(&desc->lock));
>> +    ASSERT(desc->status & IRQ_GUEST);
> 
> I don't know if this will be helpful for any of the forthcoming callers
> but you could return DOMID_XEN if this isn't the case.

This function was created to retrieve easily the domain (mainly when we
will switch to a list for the action).
As it's only used withing the file and it should only be called when
desc->status == IRQ_GUEST, I don't think we need to return DOMID_XEN.

Regards,
diff mbox

Patch

diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index f3a30bd..5111b90 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -98,6 +98,15 @@  void __cpuinit init_secondary_IRQ(void)
     BUG_ON(init_local_irq_data() < 0);
 }
 
+static inline struct domain *irq_get_domain(struct irq_desc *desc)
+{
+    ASSERT(spin_is_locked(&desc->lock));
+    ASSERT(desc->status & IRQ_GUEST);
+    ASSERT(desc->action != NULL);
+
+    return desc->action->dev_id;
+}
+
 int request_dt_irq(const struct dt_irq *irq,
                    void (*handler)(int, void *, struct cpu_user_regs *),
                    const char *devname, void *dev_id)
@@ -156,7 +165,7 @@  void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq)
 
     if ( desc->status & IRQ_GUEST )
     {
-        struct domain *d = action->dev_id;
+        struct domain *d = irq_get_domain(desc);
 
         desc->handler->end(desc);