[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 03/15] xen/arm: vGIC: Export vgic_vN ops rather than add an indirection



The function vgic_vN_init only calls register_vgic_ops. As it will never
contain anything else, domain initialization code should be in the
callback domain_init, remove them and directly use the VGIC ops in the
commmon vGIC code.

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

---
    Changes in v2:
        - Gate the vgic v3 ops with HAS_GICV3
        - Didn't retain Ian's ack for this change
---
 xen/arch/arm/vgic-v2.c     |  9 +--------
 xen/arch/arm/vgic-v3.c     |  9 +--------
 xen/arch/arm/vgic.c        | 11 ++---------
 xen/include/asm-arm/vgic.h | 11 ++++++++---
 4 files changed, 12 insertions(+), 28 deletions(-)

diff --git a/xen/arch/arm/vgic-v2.c b/xen/arch/arm/vgic-v2.c
index b5a8f29..9eecabc 100644
--- a/xen/arch/arm/vgic-v2.c
+++ b/xen/arch/arm/vgic-v2.c
@@ -539,20 +539,13 @@ static int vgic_v2_domain_init(struct domain *d)
     return 0;
 }
 
-static const struct vgic_ops vgic_v2_ops = {
+const struct vgic_ops vgic_v2_ops = {
     .vcpu_init   = vgic_v2_vcpu_init,
     .domain_init = vgic_v2_domain_init,
     .get_irq_priority = vgic_v2_get_irq_priority,
     .get_target_vcpu = vgic_v2_get_target_vcpu,
 };
 
-int vgic_v2_init(struct domain *d)
-{
-    register_vgic_ops(d, &vgic_v2_ops);
-
-    return 0;
-}
-
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c
index 4af5a84..2b9501c 100644
--- a/xen/arch/arm/vgic-v3.c
+++ b/xen/arch/arm/vgic-v3.c
@@ -1144,7 +1144,7 @@ static int vgic_v3_domain_init(struct domain *d)
     return 0;
 }
 
-static const struct vgic_ops v3_ops = {
+const struct vgic_ops vgic_v3_ops = {
     .vcpu_init   = vgic_v3_vcpu_init,
     .domain_init = vgic_v3_domain_init,
     .get_irq_priority = vgic_v3_get_irq_priority,
@@ -1152,13 +1152,6 @@ static const struct vgic_ops v3_ops = {
     .emulate_sysreg  = vgic_v3_emulate_sysreg,
 };
 
-int vgic_v3_init(struct domain *d)
-{
-    register_vgic_ops(d, &v3_ops);
-
-    return 0;
-}
-
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index dfd959a..c9676e0 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -84,13 +84,11 @@ int domain_vgic_init(struct domain *d, unsigned int nr_spis)
     {
 #ifdef HAS_GICV3
     case GIC_V3:
-        if ( vgic_v3_init(d) )
-           return -ENODEV;
+        d->arch.vgic.handler = &vgic_v3_ops;
         break;
 #endif
     case GIC_V2:
-        if ( vgic_v2_init(d) )
-            return -ENODEV;
+        d->arch.vgic.handler = &vgic_v2_ops;
         break;
     default:
         return -ENODEV;
@@ -128,11 +126,6 @@ int domain_vgic_init(struct domain *d, unsigned int 
nr_spis)
     return 0;
 }
 
-void register_vgic_ops(struct domain *d, const struct vgic_ops *ops)
-{
-   d->arch.vgic.handler = ops;
-}
-
 void domain_vgic_free(struct domain *d)
 {
     int i;
diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h
index 8d22532..4422a24 100644
--- a/xen/include/asm-arm/vgic.h
+++ b/xen/include/asm-arm/vgic.h
@@ -191,9 +191,14 @@ extern struct vgic_irq_rank *vgic_rank_irq(struct vcpu *v, 
unsigned int irq);
 extern int vgic_emulate(struct cpu_user_regs *regs, union hsr hsr);
 extern void vgic_disable_irqs(struct vcpu *v, uint32_t r, int n);
 extern void vgic_enable_irqs(struct vcpu *v, uint32_t r, int n);
-extern void register_vgic_ops(struct domain *d, const struct vgic_ops *ops);
-int vgic_v2_init(struct domain *d);
-int vgic_v3_init(struct domain *d);
+
+#define DEFINE_VGIC_OPS(version)                        \
+    extern const struct vgic_ops vgic_v##version##_ops;
+DEFINE_VGIC_OPS(2)
+#ifdef HAS_GICV3
+DEFINE_VGIC_OPS(3)
+#endif
+#undef DEFINE_VGIC_OPS
 
 extern int vcpu_vgic_free(struct vcpu *v);
 extern int vgic_to_sgi(struct vcpu *v, register_t sgir,
-- 
2.4.3


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.