Skip to contentSkip to conversation

arm/gic-v3: Fix driver probe fail on GICv4 hardware

PATCH Superseded Shanker Donthineni 2 participants 6 messages May 26, 2016 – May 27, 2016

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm/gic-v3: Fix driver probe fail on GICv4 hardware

The current driver probe fails on hardware which has GICv4 version, even though it is fully compatible to GICv3. This patch fixes the issue by registering the same probe function for GICv4 hardware.

---
 xen/arch/arm/gic-v3.c     | 13 +++++++++++++
 xen/include/asm-arm/gic.h |  1 +
 2 files changed, 14 insertions(+)
xen/arch/arm/gic-v3.c +13 -0
index a095064..594cf6e 100644
@@ -1604,10 +1604,23 @@ static int __init gicv3_acpi_preinit(const void *data)
     return 0;
 }
 
+static int __init gicv4_acpi_preinit(const void *data)
+{
+    gicv3_info.hw_version = GIC_V4;
+    register_gic_ops(&gicv3_ops);
+
+    return 0;
+}
+
 ACPI_DEVICE_START(agicv3, "GICv3", DEVICE_GIC)
         .class_type = ACPI_MADT_GIC_VERSION_V3,
         .init = gicv3_acpi_preinit,
 ACPI_DEVICE_END
+
+ACPI_DEVICE_START(agicv4, "GICv4", DEVICE_GIC)
+        .class_type = ACPI_MADT_GIC_VERSION_V4,
+        .init = gicv4_acpi_preinit,
+ACPI_DEVICE_END
 #endif
 
 /*
xen/include/asm-arm/gic.h +1 -0
index cd97bb2..5be814a 100644
@@ -218,6 +218,7 @@ struct gic_lr {
 enum gic_version {
     GIC_V2,
     GIC_V3,
+    GIC_V4,
 };
 
 extern enum gic_version gic_hw_version(void);
Signature · 9 lines
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc. 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, 
a Linux Foundation Collaborative Project


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw

Hello Shanker,

Please mention in the title and the commit message that is patch is ACPI only.

Quoted 15 lines · Shanker Donthineni

The current driver probe fails on hardware which has GICv4 version, even though it is fully compatible to GICv3. This patch fixes the issue by registering the same probe function for GICv4 hardware.

---
  xen/arch/arm/gic-v3.c     | 13 +++++++++++++
  xen/include/asm-arm/gic.h |  1 +
  2 files changed, 14 insertions(+)
xen/arch/arm/gic-v3.c +0 -0
index a095064..594cf6e 100644

xen/arch/arm/gic-v3.c static int __init gicv3_acpi_preinit(const void *data) · line 1609

Quoted 6 lines
xen/arch/arm/gic-v3.c +3 -0
@@ -1604,10 +1604,23 @@ static int __init gicv3_acpi_preinit(const void *data)
      return 0;
  }
 
+static int __init gicv4_acpi_preinit(const void *data)
+{
+    gicv3_info.hw_version = GIC_V4;

It will crash Xen as soon as DOM0 is created (see the BUG() in arch_domain_create). Please test any patch before sending on the ML.

Anyway, there is no support of GICv4 in Xen. Instead Xen will drive it using the GICv3 driver. So the hardware version should be GIC_V3 here.

Quoted 23 lines
xen/arch/arm/gic-v3.c +10 -0
+    register_gic_ops(&gicv3_ops);
+
+    return 0;
+}
+
  ACPI_DEVICE_START(agicv3, "GICv3", DEVICE_GIC)
          .class_type = ACPI_MADT_GIC_VERSION_V3,
          .init = gicv3_acpi_preinit,
  ACPI_DEVICE_END
+
+ACPI_DEVICE_START(agicv4, "GICv4", DEVICE_GIC)
+        .class_type = ACPI_MADT_GIC_VERSION_V4,
+        .init = gicv4_acpi_preinit,
+ACPI_DEVICE_END
  #endif
 
  /*
xen/include/asm-arm/gic.h +0 -0
index cd97bb2..5be814a 100644

xen/include/asm-arm/gic.h struct gic_lr { · line 224

Quoted 7 lines
xen/include/asm-arm/gic.h +1 -0
@@ -218,6 +218,7 @@ struct gic_lr {
  enum gic_version {
      GIC_V2,
      GIC_V3,
+    GIC_V4,
  };
 
  extern enum gic_version gic_hw_version(void);

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#2 lore raw

Hi Julien,

Quoted 4 lines · Julien Grall

Hello Shanker,

Please mention in the title and the commit message that is patch is ACPI only.

I'll change commit text.

Quoted 19 lines · Shanker Donthineni
Quoted 18 lines

The current driver probe fails on hardware which has GICv4 version, even though it is fully compatible to GICv3. This patch fixes the issue by registering the same probe function for GICv4 hardware.

---
  xen/arch/arm/gic-v3.c     | 13 +++++++++++++
  xen/include/asm-arm/gic.h |  1 +
  2 files changed, 14 insertions(+)
xen/arch/arm/gic-v3.c +0 -0
index a095064..594cf6e 100644
@@ -1604,10 +1604,23 @@ static int __init gicv3_acpi_preinit(const void *data)
      return 0;
  }
 
Quoted 8 lines

xen/arch/arm/gic-v3.c static int __init gicv3_acpi_preinit(const void *data) · line 1609

Quoted 3 lines
xen/arch/arm/gic-v3.c +3 -0
+static int __init gicv4_acpi_preinit(const void *data)
+{
+    gicv3_info.hw_version = GIC_V4;

It will crash Xen as soon as DOM0 is created (see the BUG() in arch_domain_create). Please test any patch before sending on the ML.

Anyway, there is no support of GICv4 in Xen. Instead Xen will drive it using the GICv3 driver. So the hardware version should be GIC_V3 here.

Yes, I know I am going to fix in a separate to fix dom0 boot issue some thing like below.

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 1365b4a..56a47f5 100644

xen/arch/arm/domain.c +5 -0
@@ -571,6 +571,11 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
             d->arch.vgic.version = GIC_V3;
             break;
 
+        case GIC_V4:
+            config->gic_version = XEN_DOMCTL_CONFIG_GIC_V3;
+            d->arch.vgic.version = GIC_V3;
+            break;
+
         default:
             BUG();
         }
Signature · 9 lines
Shanker Donthineni
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#3 lore raw
Quoted 1 line · Shanker Donthineni

Hi Julien,

Hello Shanker,

Quoted 26 lines · Julien Grall
Quoted 25 lines · Shanker Donthineni
Quoted 15 lines

The current driver probe fails on hardware which has GICv4 version, even though it is fully compatible to GICv3. This patch fixes the issue by registering the same probe function for GICv4 hardware.

---
   xen/arch/arm/gic-v3.c     | 13 +++++++++++++
   xen/include/asm-arm/gic.h |  1 +
   2 files changed, 14 insertions(+)
xen/arch/arm/gic-v3.c +0 -0
index a095064..594cf6e 100644

xen/arch/arm/gic-v3.c static int __init gicv3_acpi_preinit(const void *data) · line 1609

Quoted 6 lines
xen/arch/arm/gic-v3.c +3 -0
@@ -1604,10 +1604,23 @@ static int __init gicv3_acpi_preinit(const void *data)
       return 0;
   }
 
+static int __init gicv4_acpi_preinit(const void *data)
+{
+    gicv3_info.hw_version = GIC_V4;

It will crash Xen as soon as DOM0 is created (see the BUG() in arch_domain_create). Please test any patch before sending on the ML.

Quoted 3 lines
Quoted 2 lines

Anyway, there is no support of GICv4 in Xen. Instead Xen will drive it using the GICv3 driver. So the hardware version should be GIC_V3 here.

Yes, I know I am going to fix in a separate to fix dom0 boot issue some thing like below.

This should have been in the same patch or before. There is no point to have a patch adding support for GICv4 with ACPI which will lead to an obscure crash (a BUG() rather than a panic with a nice message).

xen/arch/arm/domain.c int arch_domain_create(struct domain *d, unsigned int domcr_flags, · line 577

Quoted 12 lines

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 1365b4a..56a47f5 100644

xen/arch/arm/domain.c +4 -0
@@ -571,6 +571,11 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
              d->arch.vgic.version = GIC_V3;
              break;
 
+        case GIC_V4:
+            config->gic_version = XEN_DOMCTL_CONFIG_GIC_V3;
+            d->arch.vgic.version = GIC_V3;
+            break;

As mentioned in my previous mail, there is no support of GICv4 in Xen. Although the GICv3 driver is supporting this hardware.So we should not advertise GIC_V4 outside of the driver until Xen will get enough knowledge of GICv4 which will require sensible change in the generic code.

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#4 lore raw
Quoted 33 lines · Julien Grall
Quoted 1 line · Shanker Donthineni

Hi Julien,

Hello Shanker,

Quoted 26 lines · Julien Grall
Quoted 25 lines · Shanker Donthineni
Quoted 15 lines

The current driver probe fails on hardware which has GICv4 version, even though it is fully compatible to GICv3. This patch fixes the issue by registering the same probe function for GICv4 hardware.

---
   xen/arch/arm/gic-v3.c     | 13 +++++++++++++
   xen/include/asm-arm/gic.h |  1 +
   2 files changed, 14 insertions(+)
xen/arch/arm/gic-v3.c +0 -0
index a095064..594cf6e 100644

xen/arch/arm/gic-v3.c static int __init gicv3_acpi_preinit(const void *data) · line 1609

Quoted 6 lines
xen/arch/arm/gic-v3.c +3 -0
@@ -1604,10 +1604,23 @@ static int __init gicv3_acpi_preinit(const void *data)
       return 0;
   }
 
+static int __init gicv4_acpi_preinit(const void *data)
+{
+    gicv3_info.hw_version = GIC_V4;

It will crash Xen as soon as DOM0 is created (see the BUG() in arch_domain_create). Please test any patch before sending on the ML.

Quoted 6 lines
Quoted 3 lines
Quoted 2 lines

Anyway, there is no support of GICv4 in Xen. Instead Xen will drive it using the GICv3 driver. So the hardware version should be GIC_V3 here.

Yes, I know I am going to fix in a separate to fix dom0 boot issue some thing like below.

This should have been in the same patch or before. There is no point to have a patch adding support for GICv4 with ACPI which will lead to an obscure crash (a BUG() rather than a panic with a nice message).

Sure, I'll do it in a single patch.

Quoted 8 lines
Quoted 8 lines

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 1365b4a..56a47f5 100644

xen/arch/arm/domain.c +0 -0
@@ -571,6 +571,11 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
              d->arch.vgic.version = GIC_V3;
              break;
 
Quoted 7 lines

xen/arch/arm/domain.c int arch_domain_create(struct domain *d, unsigned int domcr_flags, · line 577

Quoted 4 lines
xen/arch/arm/domain.c +4 -0
+        case GIC_V4:
+            config->gic_version = XEN_DOMCTL_CONFIG_GIC_V3;
+            d->arch.vgic.version = GIC_V3;
+            break;

As mentioned in my previous mail, there is no support of GICv4 in Xen. Although the GICv3 driver is supporting this hardware.So we should not advertise GIC_V4 outside of the driver until Xen will get enough knowledge of GICv4 which will require sensible change in the generic code.

GICv4 hardware is fully compatible to GICv3 and has an additional feature vLPI. We don't need any special driver or changes to current driver to support GICv4 for SPIs/LPIs in Xen just like Linux kernel.

Confused, you are expecting gic_hw_version() should return GIC version number '3' on on GICv4 hardware, right?

        switch ( gic_hw_version () )
        {
        case GIC_V2:
            config->gic_version = XEN_DOMCTL_CONFIG_GIC_V2;
            d->arch.vgic.version = GIC_V2;
            break;
        case GIC_V3:
            config->gic_version = XEN_DOMCTL_CONFIG_GIC_V3;
            d->arch.vgic.version = GIC_V3;
            break;
Quoted 2 lines

Regards,

Signature · 9 lines
Shanker Donthineni
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#5 lore raw

Hello Shanker,

Quoted 15 lines · Shanker Donthineni
Quoted 8 lines
Quoted 8 lines
   diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c

index 1365b4a..56a47f5 100644

xen/arch/arm/domain.c +0 -0
@@ -571,6 +571,11 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
               d->arch.vgic.version = GIC_V3;
               break;
 
Quoted 7 lines

xen/arch/arm/domain.c int arch_domain_create(struct domain *d, unsigned int domcr_flags, · line 577

Quoted 4 lines
xen/arch/arm/domain.c +4 -0
+        case GIC_V4:
+            config->gic_version = XEN_DOMCTL_CONFIG_GIC_V3;
+            d->arch.vgic.version = GIC_V3;
+            break;

As mentioned in my previous mail, there is no support of GICv4 in Xen. Although the GICv3 driver is supporting this hardware.So we should not advertise GIC_V4 outside of the driver until Xen will get enough knowledge of GICv4 which will require sensible change in the generic code.

Quoted 3 lines

GICv4 hardware is fully compatible to GICv3 and has an additional feature vLPI. We don't need any special driver or changes to current driver to support GICv4 for SPIs/LPIs in Xen just like Linux kernel.

Confused, you are expecting gic_hw_version() should return GIC version number '3' on on GICv4 hardware, right?

Because the function is misnamed. It returns the version of GIC supported by the driver to find the associated vGIC. Currently we only support GICv3 and GICv2. If other GIC version are supported, it is only because they are compatible.

This is a choice of the driver and should not be exposed/spread outside of the drivers until it is strictly necessary.

Anyway, Stefano may have a different opinion on this.

Regards,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel