diff mbox

[v3,55/62] arm/acpi: Route all Xen unused SPIs to Dom0

Message ID 1447753261-7552-56-git-send-email-shannon.zhao@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Shannon Zhao Nov. 17, 2015, 9:40 a.m. UTC
From: Shannon Zhao <shannon.zhao@linaro.org>

Route all SPIs to Dom0 except the interrupts that Xen uses. Since Xen
already uses the uart interrupt, the desc->action will not be NULL, so
it will skip it.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
---
 xen/arch/arm/domain_build.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

Comments

Julien Grall Nov. 17, 2015, 12:33 p.m. UTC | #1
Hi Shannon,

On 17/11/15 09:40, shannon.zhao@linaro.org wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Route all SPIs to Dom0 except the interrupts that Xen uses. Since Xen
> already uses the uart interrupt, the desc->action will not be NULL, so
> it will skip it.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 6d8536b..6945f89 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1360,6 +1360,35 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  #define ACPI_DOM0_FDT_MIN_SIZE 4096
>  
> +static int acpi_route_spi(struct domain *d)
> +{
> +    int i, res;
> +    struct irq_desc *desc;
> +
> +    /* Don't route Xen used interrupt to Dom0. Since Xen already uses the uart
> +     * interrupt, the desc->action will not be NULL, so it will skip it.
> +     */
> +    for( i = NR_LOCAL_IRQS; i < vgic_num_irqs(d); i++ )
> +    {
> +        /* Don't route uart interrupt to Dom0 */

Your comments are wrong. desc->action != NULL means Xen is using the
interrupt. It could be for the SMMU, the UART...

> +        desc = irq_to_desc(i);
> +        if( desc->action != NULL)

Coding style.

> +            continue;
> +
> +        vgic_reserve_virq(d, i);
> +        irq_set_type(i, ACPI_IRQ_TYPE_NONE);
> +        res = route_irq_to_guest(d, i, i, NULL);
> +        if ( res )
> +        {
> +            printk(XENLOG_ERR "Unable to route IRQ %u to domain %u\n",
> +                   i, d->domain_id);
> +            continue;
> +        }
> +    }
> +
> +    return 0;
> +}
> +

Regards,
Stefano Stabellini Nov. 27, 2015, 3:04 p.m. UTC | #2
On Tue, 17 Nov 2015, shannon.zhao@linaro.org wrote:

> From: Shannon Zhao <shannon.zhao@linaro.org>
> 
> Route all SPIs to Dom0 except the interrupts that Xen uses. Since Xen
> already uses the uart interrupt, the desc->action will not be NULL, so
> it will skip it.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> ---
>  xen/arch/arm/domain_build.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index 6d8536b..6945f89 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1360,6 +1360,35 @@ static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
>  #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
>  #define ACPI_DOM0_FDT_MIN_SIZE 4096
>  
> +static int acpi_route_spi(struct domain *d)
> +{
> +    int i, res;
> +    struct irq_desc *desc;
> +
> +    /* Don't route Xen used interrupt to Dom0. Since Xen already uses the uart
> +     * interrupt, the desc->action will not be NULL, so it will skip it.
> +     */
> +    for( i = NR_LOCAL_IRQS; i < vgic_num_irqs(d); i++ )
> +    {
> +        /* Don't route uart interrupt to Dom0 */
> +        desc = irq_to_desc(i);
> +        if( desc->action != NULL)
> +            continue;

Don't you need to call irq_permit_access too?


> +        vgic_reserve_virq(d, i);
> +        irq_set_type(i, ACPI_IRQ_TYPE_NONE);

I don't know if there is any point in setting the type to NONE. It's the
default, isn't it?


> +        res = route_irq_to_guest(d, i, i, NULL);
> +        if ( res )
> +        {
> +            printk(XENLOG_ERR "Unable to route IRQ %u to domain %u\n",
> +                   i, d->domain_id);
> +            continue;
> +        }
> +    }
> +
> +    return 0;
> +}
> +
>  static int make_chosen_node(const struct kernel_info *kinfo,
>                              struct membank tbl_add[])
>  {
> @@ -1897,6 +1926,10 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
>      if ( rc != 0 )
>          return rc;
>  
> +    rc = acpi_route_spi(d);
> +    if ( rc != 0 )
> +        return rc;
> +
>      return 0;
>  }
>  #else
> -- 
> 2.1.0
>
Julien Grall Nov. 30, 2015, 3:41 p.m. UTC | #3
On 27/11/15 15:04, Stefano Stabellini wrote:
>> +        vgic_reserve_virq(d, i);
>> +        irq_set_type(i, ACPI_IRQ_TYPE_NONE);
> 
> I don't know if there is any point in setting the type to NONE. It's the
> default, isn't it?

No, the default is *_IRQ_TYPE_INVALID.

Regards,
diff mbox

Patch

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 6d8536b..6945f89 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1360,6 +1360,35 @@  static int prepare_dtb(struct domain *d, struct kernel_info *kinfo)
 #define XEN_HYPERVISOR_ID 0x000058656E564D4D  /* "XenVMM" */
 #define ACPI_DOM0_FDT_MIN_SIZE 4096
 
+static int acpi_route_spi(struct domain *d)
+{
+    int i, res;
+    struct irq_desc *desc;
+
+    /* Don't route Xen used interrupt to Dom0. Since Xen already uses the uart
+     * interrupt, the desc->action will not be NULL, so it will skip it.
+     */
+    for( i = NR_LOCAL_IRQS; i < vgic_num_irqs(d); i++ )
+    {
+        /* Don't route uart interrupt to Dom0 */
+        desc = irq_to_desc(i);
+        if( desc->action != NULL)
+            continue;
+
+        vgic_reserve_virq(d, i);
+        irq_set_type(i, ACPI_IRQ_TYPE_NONE);
+        res = route_irq_to_guest(d, i, i, NULL);
+        if ( res )
+        {
+            printk(XENLOG_ERR "Unable to route IRQ %u to domain %u\n",
+                   i, d->domain_id);
+            continue;
+        }
+    }
+
+    return 0;
+}
+
 static int make_chosen_node(const struct kernel_info *kinfo,
                             struct membank tbl_add[])
 {
@@ -1897,6 +1926,10 @@  static int prepare_acpi(struct domain *d, struct kernel_info *kinfo)
     if ( rc != 0 )
         return rc;
 
+    rc = acpi_route_spi(d);
+    if ( rc != 0 )
+        return rc;
+
     return 0;
 }
 #else