xen/arm: Add support for Huawei hip04-d01 platform
PATCH v3 1/1 xen/arm: Add support for Huawei hip04-d01 platform
This set of patches add Xen support for hip04-d01 platform (see https://wiki.linaro.org/Boards/D01 for details).
Changes from v2:
- rewrote DTS fix patch (Ian Campbell);
- use is_hip04 macro instead of doing explicit test (Julien Grall);
- do not use quirks to distinguish this platform (Ian Cambell);
- move some GIC constants to C files instead of header (Julien Grall);
- minor changes (Julien Grall).
Changes from v1:
- style (Julien Grall);
- make gicv2_send_SGI faster (Julien Grall);
- cleanup correctly if hip04_smp_init fails (Julien Grall);
- remove quirks using compatibility (Ian Campbell);
- other minor suggestions by Julien Grall.
PATCH v3 1/8 xen/device_tree: Add new helper to read arrays from a DTB
From: Zoltan Kiss <[email protected]>
--- xen/common/device_tree.c | 13 ++++++++++--- xen/include/xen/device_tree.h | 11 +++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-)
xen/common/device_tree.c +10 -3
@@ -160,14 +160,21 @@ const void *dt_get_property(const struct dt_device_node *np,bool_t dt_property_read_u32 (const struct dt_device_node *np,const char *name,u32 *out_value) { -u32 len; +return dt_property_read_u32_array (np, name, out_value,1 ); +} + +bool_t dt_property_read_u32_array (const struct dt_device_node *np, +const char *name,u32 *out_value,u16 out_len) +{ +u32 len, i;const __be32 *val; val =dt_get_property (np, name, &len); -if ( !val || len <sizeof (*out_value) ) +if ( !val || len <sizeof (*out_value) * out_len )return 0 ; - *out_value =be32_to_cpup (val); +for ( i =0 ; i < out_len; i++, val++ ) + out_value[i] =be32_to_cpup (val);return 1 ; }
xen/include/xen/device_tree.h +11 -0
@@ -346,6 +346,17 @@ const struct dt_property *dt_find_property(const struct dt_device_node *np,bool_t dt_property_read_u32 (const struct dt_device_node *np,const char *name,u32 *out_value);/** +* dt_property_read_u32_array - Helper to read a u32 array property. +* @np: node to get the value +* @name: name of the property +* @out_value: pointer to return value +* @out_len: length of the array +* +* Return true if get the desired value. +*/ +bool_t dt_property_read_u32_array (const struct dt_device_node *np, +const char *name,u32 *out_value,u16 out_len); +/** * dt_property_read_u64 - Helper to read a u64 property. * @np: node to get the value * @name: name of the property
Signature · 1 line
1.9.1
PATCH v3 2/8 xen/arm: Implement hip04-d01 platform
In reply to Frediano ZiglioAdd this new platform to Xen.
This platform requires specific code to initialize CPUs.
--- xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/hip04.c | 300 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 301 insertions(+) create mode 100644 xen/arch/arm/platforms/hip04.c
xen/arch/arm/platforms/Makefile +1 -0
@@ -5,4 +5,5 @@ obj-$(CONFIG_ARM_32) += midway.o obj-$(CONFIG_ARM_32) += omap5.o obj-$(CONFIG_ARM_32) += sunxi.o obj-$(CONFIG_ARM_64) += seattle.o +obj-$(CONFIG_ARM_32) += hip04.o obj-$(CONFIG_ARM_64) += xgene-storm.o
xen/arch/arm/platforms/hip04.c new file +300 -0
300 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v3 3/8 xen/arm: Make gic-v2 code handle hip04-d01 platform
In reply to Frediano ZiglioThe GIC in this platform is mainly compatible with the standard GICv2 beside:
- ITARGET is extended to 16 bit to support 16 CPUs;
- SGI mask is extended to support 16 CPUs;
- maximum supported interrupt is 510.
Use nr_lines to check for maximum irq supported. hip04-d01 support less interrupts due to some field restriction. Any value above this is already an error.
--- xen/arch/arm/gic-v2.c | 85 ++++++++++++++++++++++++++++++++++++++--------- xen/arch/arm/gic.c | 3 +- xen/include/asm-arm/gic.h | 4 ++- 3 files changed, 75 insertions(+), 17 deletions(-)
xen/arch/arm/gic-v2.c +70 -15
@@ -79,16 +79,25 @@ static struct gic_info gicv2_info;* logical CPU numbering. Let's use mapping as returned by the GIC * itself */ -static DEFINE_PER_CPU(u8, gic_cpu_id); +static DEFINE_PER_CPU(u16, gic_cpu_id);/* Maximum cpu interface per GIC */ -#define NR_GIC_CPU_IF 8 +static unsigned int nr_gic_cpu_if =8 ; +static unsigned int gicd_sgi_target_shift =GICD_SGI_TARGET_SHIFT ; +static unsigned int gic_cpu_mask =0xff ; + +#define is_hip04 () (nr_gic_cpu_if == 16)static inline void writeb_gicd (uint8_t val,unsigned int offset) {writeb_relaxed (val, gicv2.map_dbase + offset); } +static inline void writew_gicd (uint16_t val,unsigned int offset) +{ +writew_relaxed (val, gicv2.map_dbase + offset); +} +static inline void writel_gicd (uint32_t val,unsigned int offset) {writel_relaxed (val, gicv2.map_dbase + offset);
@@ -132,7 +141,7 @@ static unsigned int gicv2_cpu_mask(const cpumask_t *cpumask)cpumask_and (&possible_mask, cpumask, &cpu_possible_map);for_each_cpu ( cpu, &possible_mask ) { -ASSERT (cpu <NR_GIC_CPU_IF ); +ASSERT (cpu < nr_gic_cpu_if); mask |=per_cpu (gic_cpu_id, cpu); }
@@ -203,6 +212,15 @@ static unsigned int gicv2_read_irq(void)return (readl_gicc (GICC_IAR ) &GICC_IA_IRQ ); } +/* Set target CPU mask (RAZ/WI on uniprocessor) */ +static void gicv2_set_irq_mask (int irq,unsigned int mask) +{ +if (is_hip04 () ) +writew_gicd (mask,GICD_ITARGETSR + irq *2 ); +else +writeb_gicd (mask,GICD_ITARGETSR + irq); +} +/* * needs to be called with a valid cpu_mask, ie each cpu in the mask has * already called gic_cpu_init
@@ -230,7 +248,7 @@ static void gicv2_set_irq_properties(struct irq_desc *desc,writel_gicd (cfg,GICD_ICFGR + (irq /16 ) *4 );/* Set target CPU mask (RAZ/WI on uniprocessor) */ -writeb_gicd (mask,GICD_ITARGETSR + irq); +gicv2_set_irq_mask (irq, mask);/* Set priority */ writeb_gicd (priority,GICD_IPRIORITYR + irq);
@@ -244,16 +262,21 @@ static void __init gicv2_dist_init(void)uint32_t gic_cpus;int i; - cpumask =readl_gicd (GICD_ITARGETSR ) &0xff ; - cpumask |= cpumask <<8 ; - cpumask |= cpumask <<16 ; + cpumask =readl_gicd (GICD_ITARGETSR ) & gic_cpu_mask;/* Disable the distributor */ writel_gicd (0 ,GICD_CTLR ); type =readl_gicd (GICD_TYPER ); gicv2_info.nr_lines =32 * ((type &GICD_TYPE_LINES ) +1 ); - gic_cpus =1 + ((type &GICD_TYPE_CPUS ) >>5 ); +if (is_hip04 () ) + { + gic_cpus =16 ; + } +else + { + gic_cpus =1 + ((type &GICD_TYPE_CPUS ) >>5 ); + } printk("GICv2: %d lines, %d cpu%s%s (IID %8.8x).\n", gicv2_info.nr_lines, gic_cpus, (gic_cpus == 1) ? "" : "s", (type & GICD_TYPE_SEC) ? ", secure" : "",
@@ -264,8 +287,19 @@ static void __init gicv2_dist_init(void)writel_gicd (0x0 ,GICD_ICFGR + (i /16 ) *4 );/* Route all global IRQs to this CPU */ -for ( i =32 ; i < gicv2_info.nr_lines; i +=4 ) -writel_gicd (cpumask,GICD_ITARGETSR + (i /4 ) *4 ); +if (is_hip04 () ) + { + cpumask |= cpumask <<16 ; +for ( i =32 ; i < gicv2_info.nr_lines; i +=2 ) +writel_gicd (cpumask,GICD_ITARGETSR + (i /2 ) *4 ); + } +else + { + cpumask |= cpumask <<8 ; + cpumask |= cpumask <<16 ; +for ( i =32 ; i < gicv2_info.nr_lines; i +=4 ) +writel_gicd (cpumask,GICD_ITARGETSR + (i /4 ) *4 ); + }/* Default priority for global interrupts */ for ( i =32 ; i < gicv2_info.nr_lines; i +=4 )
@@ -285,7 +319,7 @@ static void __cpuinit gicv2_cpu_init(void) {int i; -this_cpu (gic_cpu_id) =readl_gicd (GICD_ITARGETSR ) &0xff ; +this_cpu (gic_cpu_id) =readl_gicd (GICD_ITARGETSR ) & gic_cpu_mask;/* The first 32 interrupts (PPI and SGI) are banked per-cpu, so * even though they are controlled with GICD registers, they must
@@ -366,7 +400,7 @@ static void gicv2_send_SGI(enum gic_sgi sgi, enum gic_sgi_mode irqmode,cpumask_and (&online_mask, cpu_mask, &cpu_online_map); mask =gicv2_cpu_mask (&online_mask);writel_gicd (GICD_SGI_TARGET_LIST | - (mask <<GICD_SGI_TARGET_SHIFT ) | sgi, + (mask << gicd_sgi_target_shift) | sgi,GICD_SGIR );break ;default :
@@ -581,7 +615,7 @@ static void gicv2_irq_set_affinity(struct irq_desc *desc, const cpumask_t *cpu_m mask =gicv2_cpu_mask (cpu_mask);/* Set target CPU mask (RAZ/WI on uniprocessor) */ -writeb_gicd (mask,GICD_ITARGETSR + desc->irq); +gicv2_set_irq_mask (desc->irq, mask);spin_unlock (&gicv2.lock); }
@@ -684,7 +718,7 @@ const static struct gic_hw_operations gicv2_ops = { };/* Set up the GIC */ -static int __init gicv2_init (struct dt_device_node *node,const void *data) +static int __init gicv2_init_default (struct dt_device_node *node,const void *data) {int res;
@@ -764,6 +798,15 @@ static int __init gicv2_init(struct dt_device_node *node, const void *data)return 0 ; } +static int __init hip04_gicv2_init (struct dt_device_node *node,const void *data) +{ + nr_gic_cpu_if =16 ; + gicd_sgi_target_shift =8 ; + gic_cpu_mask =0xffff ; + +return gicv2_init_default (node, data); +} +static const char *const gicv2_dt_compat[]__initconst = {DT_COMPAT_GIC_CORTEX_A15 ,
@@ -774,9 +817,21 @@ static const char * const gicv2_dt_compat[] __initconst =DT_DEVICE_START (gicv2,"GICv2:" ,DEVICE_GIC ) .compatible = gicv2_dt_compat, - .init = gicv2_init, + .init = gicv2_init_default, DT_DEVICE_END +static const char *const hip04_gicv2_dt_compat[]__initconst = +{ +DT_COMPAT_GIC_HIP04 , +NULL +}; + +DT_DEVICE_START (hip04_gicv2,"GICv2:" ,DEVICE_GIC ) + .compatible = hip04_gicv2_dt_compat, + .init = hip04_gicv2_init, +DT_DEVICE_END + +/* * Local variables: * mode: C
xen/arch/arm/gic.c +2 -1
@@ -563,12 +563,13 @@ static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi)void gic_interrupt (struct cpu_user_regs *regs,int is_fiq) {unsigned int irq; +unsigned int max_irq = gic_hw_ops->info->nr_lines; do { /* Reading IRQ will ACK it */ irq = gic_hw_ops->read_irq(); - if ( likely(irq >= 16 && irq < 1021) ) + if ( likely(irq >= 16 && irq < max_irq) ) { local_irq_enable(); do_IRQ(regs, irq, is_fiq);
xen/include/asm-arm/gic.h +3 -1
@@ -155,10 +155,12 @@#define DT_COMPAT_GIC_400 "arm,gic-400"#define DT_COMPAT_GIC_CORTEX_A15 "arm,cortex-a15-gic"#define DT_COMPAT_GIC_CORTEX_A7 "arm,cortex-a7-gic" +#define DT_COMPAT_GIC_HIP04 "hisilicon,hip04-gic"#define DT_MATCH_GIC_V2 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A15), \ DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A7), \ - DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400) + DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400), \ + DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04)#define DT_COMPAT_GIC_V3 "arm,gic-v3"
Signature · 1 line
1.9.1
PATCH v3 4/8 xen/arm: Add support for DTBs with strange names of Hip04 GICv2
In reply to Frediano ZiglioThis name can appear in some Linux kernel repos. Not very fortunate, but to avoid others spending an hour to spot that few characters difference it worth to work around it.
--- xen/arch/arm/gic-v2.c | 1 + xen/include/asm-arm/gic.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)
xen/arch/arm/gic-v2.c +1 -0
@@ -823,6 +823,7 @@ DT_DEVICE_ENDstatic const char *const hip04_gicv2_dt_compat[]__initconst = {DT_COMPAT_GIC_HIP04 , +DT_COMPAT_GIC_HIP04_2 ,NULL };
xen/include/asm-arm/gic.h +3 -1
@@ -156,11 +156,13 @@#define DT_COMPAT_GIC_CORTEX_A15 "arm,cortex-a15-gic"#define DT_COMPAT_GIC_CORTEX_A7 "arm,cortex-a7-gic"#define DT_COMPAT_GIC_HIP04 "hisilicon,hip04-gic" +#define DT_COMPAT_GIC_HIP04_2 "hisilicon,hip04-intc"#define DT_MATCH_GIC_V2 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A15), \ DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A7), \ DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400), \ - DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04) + DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04), \ + DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04_2)#define DT_COMPAT_GIC_V3 "arm,gic-v3"
Signature · 1 line
1.9.1
Re: [PATCH v3 4/8] xen/arm: Add support for DTBs with strange names of Hip04 GICv2
Hi Frediano,
Quoted 3 lines · Frediano Ziglio
This name can appear in some Linux kernel repos. Not very fortunate, but to avoid others spending an hour to spot that few characters difference it worth to work around it.
Linux upstream is using "hisilicon,hip04-intc" to detect the hisilicon interrupt controller. So it's not a workaround.
Which kernel is using the "*,hip04-gic"?
Regards,
Quoted 38 lines
Signed-off-by Zoltan Kiss <[email protected]>--- xen/arch/arm/gic-v2.c | 1 + xen/include/asm-arm/gic.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)xen/arch/arm/gic-v2.c +1
-0@@ -823,6 +823,7 @@ DT_DEVICE_ENDstatic const char *const hip04_gicv2_dt_compat[]__initconst = {DT_COMPAT_GIC_HIP04 , +DT_COMPAT_GIC_HIP04_2 ,NULL };xen/include/asm-arm/gic.h +3
-1@@ -156,11 +156,13 @@#define DT_COMPAT_GIC_CORTEX_A15 "arm,cortex-a15-gic"#define DT_COMPAT_GIC_CORTEX_A7 "arm,cortex-a7-gic"#define DT_COMPAT_GIC_HIP04 "hisilicon,hip04-gic" +#define DT_COMPAT_GIC_HIP04_2 "hisilicon,hip04-intc"#define DT_MATCH_GIC_V2 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A15), \ DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A7), \ DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400), \ - DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04) + DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04), \ + DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04_2)#define DT_COMPAT_GIC_V3 "arm,gic-v3"
Signature · 1 line
Julien Grall
Re: [PATCH v3 4/8] xen/arm: Add support for DTBs with strange names of Hip04 GICv2
Quoted 11 lines · Julien Grall
Hi Frediano,
Quoted 3 lines · Frediano Ziglio
This name can appear in some Linux kernel repos. Not very fortunate, but to avoid others spending an hour to spot that few characters difference it worth to work around it.
Linux upstream is using "hisilicon,hip04-intc" to detect the hisilicon interrupt controller. So it's not a workaround.
Which kernel is using the "*,hip04-gic"?
Good question, but what really matters is the string that u-boot (or any other firmware/bootloader) is going to use, right? So, which one is it?
Quoted 43 lines
Quoted 38 lines
Signed-off-by Zoltan Kiss <[email protected]>--- xen/arch/arm/gic-v2.c | 1 + xen/include/asm-arm/gic.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)xen/arch/arm/gic-v2.c +1
-0@@ -823,6 +823,7 @@ DT_DEVICE_ENDstatic const char *const hip04_gicv2_dt_compat[]__initconst = {DT_COMPAT_GIC_HIP04 , +DT_COMPAT_GIC_HIP04_2 ,NULL };xen/include/asm-arm/gic.h +3
-1@@ -156,11 +156,13 @@#define DT_COMPAT_GIC_CORTEX_A15 "arm,cortex-a15-gic"#define DT_COMPAT_GIC_CORTEX_A7 "arm,cortex-a7-gic"#define DT_COMPAT_GIC_HIP04 "hisilicon,hip04-gic" +#define DT_COMPAT_GIC_HIP04_2 "hisilicon,hip04-intc"#define DT_MATCH_GIC_V2 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A15), \ DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A7), \ DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400), \ - DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04) + DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04), \ + DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04_2)#define DT_COMPAT_GIC_V3 "arm,gic-v3"Signature · 1 line
Julien Grall
Re: [PATCH v3 4/8] xen/arm: Add support for DTBs with strange names of Hip04 GICv2
Quoted 8 lines · Stefano Stabellini
Quoted 7 lines · Julien Grall
Hi Frediano,
Quoted 3 lines · Frediano Ziglio
This name can appear in some Linux kernel repos. Not very fortunate, but to avoid others spending an hour to spot that few characters difference it worth to work around it.
Quoted 7 lines
Quoted 4 lines
Linux upstream is using "hisilicon,hip04-intc" to detect the hisilicon interrupt controller. So it's not a workaround.
Which kernel is using the "*,hip04-gic"?
Good question, but what really matters is the string that u-boot (or any other
firmware/bootloader) is going to use, right? So, which one is it?
We are using the DTB from the kernel source, even when loading a bare metal kernel. I've looked around, the *gic version seems to exist only in internal repos, as far as I can see. Including the one Frediano started to use for porting. Therefore, I don't insist to keep both, but as I mentioned in the commit message, it would still provide some benefit, and given that it's just a 3 line change which just extend a few listings, I think we should keep it. Of course with a different commit message, which clears that this is the official name of it.
Zoli
Quoted 52 lines
Quoted 38 lines
Quoted 38 lines
Signed-off-by Zoltan Kiss <[email protected]>--- xen/arch/arm/gic-v2.c | 1 + xen/include/asm-arm/gic.h | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-)xen/arch/arm/gic-v2.c +1
-0@@ -823,6 +823,7 @@ DT_DEVICE_ENDstatic const char *const hip04_gicv2_dt_compat[]__initconst = {DT_COMPAT_GIC_HIP04 , +DT_COMPAT_GIC_HIP04_2 ,NULL };xen/include/asm-arm/gic.h +3
-1@@ -156,11 +156,13 @@#define DT_COMPAT_GIC_CORTEX_A15 "arm,cortex-a15-gic"#define DT_COMPAT_GIC_CORTEX_A7 "arm,cortex-a7-gic"#define DT_COMPAT_GIC_HIP04 "hisilicon,hip04-gic" +#define DT_COMPAT_GIC_HIP04_2 "hisilicon,hip04-intc"#define DT_MATCH_GIC_V2 DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A15), \ DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_CORTEX_A7), \ DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_400), \ - DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04) + DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04), \ + DT_MATCH_COMPATIBLE(DT_COMPAT_GIC_HIP04_2)Quoted 8 lines
xen/include/asm-arm/gic.h line 168
Quoted 3 lines
xen/include/asm-arm/gic.h +0
-0#define DT_COMPAT_GIC_V3 "arm,gic-v3"--
Julien Grall_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 4/8] xen/arm: Add support for DTBs with strange names of Hip04 GICv2
Hi Zoltan,
Quoted 18 lines · Zoltan Kiss
Quoted 8 lines · Stefano Stabellini
Quoted 7 lines · Julien Grall
Hi Frediano,
Quoted 3 lines · Frediano Ziglio
This name can appear in some Linux kernel repos. Not very fortunate, but to avoid others spending an hour to spot that few characters difference it worth to work around it.
Quoted 7 lines
Quoted 4 lines
Linux upstream is using "hisilicon,hip04-intc" to detect the hisilicon interrupt controller. So it's not a workaround.
Which kernel is using the "*,hip04-gic"?
Good question, but what really matters is the string that u-boot (or any other
firmware/bootloader) is going to use, right? So, which one is it?
Quoted 7 lines
We are using the DTB from the kernel source, even when loading a bare metal kernel. I've looked around, the *gic version seems to exist only in internal repos, as far as I can see. Including the one Frediano started to use for porting. Therefore, I don't insist to keep both, but as I mentioned in the commit message, it would still provide some benefit, and given that it's just a 3 line change which just extend a few listings, I think we should keep it.
In general, Xen should respect the binding that has been agreed by the device tree team. Anything different should not be upstream, hence it's for only internal purpose.
Quoted 2 lines
Of course with a different commit message, which clears that this is the official name of it.
If it happens that both compatible are upstream. I would prefer that you define the *-intc one in the patch #3 and *-gic in #4.
It's more logical than defining first the non-official and then the official.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v3 4/8] xen/arm: Add support for DTBs with strange names of Hip04 GICv2
Quoted 35 lines
Hi Zoltan,
Quoted 11 lines · Zoltan Kiss
Quoted 8 lines · Stefano Stabellini
Quoted 7 lines · Julien Grall
Hi Frediano,
Quoted 3 lines · Frediano Ziglio
This name can appear in some Linux kernel repos. Not very fortunate, but to avoid others spending an hour to spot that few characters difference it worth to work around it.
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Linux upstream is using "hisilicon,hip04-intc" to detect the hisilicon interrupt controller. So it's not a workaround.
Which kernel is using the "*,hip04-gic"?
Good question, but what really matters is the string that u-boot (or any other
firmware/bootloader) is going to use, right? So, which oneis it?
Quoted 2 lines
We are using the DTB from the kernel source, even when loading a bare metal kernel. I've looked around, the *gic version seems to exist
only
Quoted 5 lines
in internal repos, as far as I can see. Including the one Frediano started to use for porting. Therefore, I don't insist to keep both, but as I mentioned in the commit message, it would still provide some benefit, and given that it's just a 3 line change which just extend a few listings, I think we should keep it.
In general, Xen should respect the binding that has been agreed by the device tree team. Anything different should not be upstream, hence it's for only internal purpose.
Quoted 9 lines
Quoted 2 lines
Of course with a different commit message, which clears that this is the official name of it.
If it happens that both compatible are upstream. I would prefer that you define the *-intc one in the patch #3 and *-gic in #4.
It's more logical than defining first the non-official and then the official.
Done
Quoted 2 lines
Regards,
Sent version 4.
Frediano
Re: [PATCH v3 4/8] xen/arm: Add support for DTBs with strange names of Hip04 GICv2
In reply to Zoltan KissHi Zoltan,
Quoted 18 lines · Zoltan Kiss
Quoted 8 lines · Stefano Stabellini
Quoted 7 lines · Julien Grall
Hi Frediano,
Quoted 3 lines · Frediano Ziglio
This name can appear in some Linux kernel repos. Not very fortunate, but to avoid others spending an hour to spot that few characters difference it worth to work around it.
Quoted 7 lines
Quoted 4 lines
Linux upstream is using "hisilicon,hip04-intc" to detect the hisilicon interrupt controller. So it's not a workaround.
Which kernel is using the "*,hip04-gic"?
Good question, but what really matters is the string that u-boot (or any other
firmware/bootloader) is going to use, right? So, which one is it?
Quoted 9 lines
We are using the DTB from the kernel source, even when loading a bare metal kernel. I've looked around, the *gic version seems to exist only in internal repos, as far as I can see. Including the one Frediano started to use for porting. Therefore, I don't insist to keep both, but as I mentioned in the commit message, it would still provide some benefit, and given that it's just a 3 line change which just extend a few listings, I think we should keep it.
Of course with a different commit message, which clears that this is the official name of it.
If it's only used in your internal repo, we shouldn't support this compatible string in Xen.
Nothing prevent someone in the future to use this compatible for a completely different purpose (for instance a different GIC driver).
We aim to support only official bindings to avoid a such issue.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v3 4/8] xen/arm: Add support for DTBs with strange names of Hip04 GICv2
Quoted 36 lines
Hi Zoltan,
Quoted 11 lines · Zoltan Kiss
Quoted 8 lines · Stefano Stabellini
Quoted 7 lines · Julien Grall
Hi Frediano,
Quoted 3 lines · Frediano Ziglio
This name can appear in some Linux kernel repos. Not very fortunate, but to avoid others spending an hour to spot that few characters difference it worth to work around it.
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Linux upstream is using "hisilicon,hip04-intc" to detect the hisilicon interrupt controller. So it's not a workaround.
Which kernel is using the "*,hip04-gic"?
Good question, but what really matters is the string that u-boot (or any other
firmware/bootloader) is going to use, right? So, which oneis it?
Quoted 2 lines
We are using the DTB from the kernel source, even when loading a bare metal kernel. I've looked around, the *gic version seems to exist
only
Quoted 7 lines
in internal repos, as far as I can see. Including the one Frediano started to use for porting. Therefore, I don't insist to keep both, but as I mentioned in the commit message, it would still provide some benefit, and given that it's just a 3 line change which just extend a few listings, I think we should keep it.
Of course with a different commit message, which clears that this is the official name of it.If it's only used in your internal repo, we shouldn't support this compatible string in Xen.
Quoted 7 lines
Nothing prevent someone in the future to use this compatible for a completely different purpose (for instance a different GIC driver).
We aim to support only official bindings to avoid a such issue.
Regards,
Now all changes for old development compatible string are in a single patch so feel free to drop it.
Regards,
Frediano
PATCH v3 5/8 xen/arm: handle GICH register changes for hip04-d01 platform
In reply to Frediano ZiglioThe GICH in this platform is mainly compatible with the standard GICv2 beside APR and LR register offsets.
--- xen/arch/arm/gic-v2.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
xen/arch/arm/gic-v2.c +17 -10
@@ -61,6 +61,9 @@#define GICH_V2_VMCR_PRIORITY_MASK 0x1f#define GICH_V2_VMCR_PRIORITY_SHIFT 27 +#define HIP04_GICH_APR 0x70 +#define HIP04_GICH_LR 0x80 +/* Global state */ static struct { paddr_t dbase; /* Address of distributor registers */
@@ -85,6 +88,8 @@ static DEFINE_PER_CPU(u16, gic_cpu_id);static unsigned int nr_gic_cpu_if =8 ;static unsigned int gicd_sgi_target_shift =GICD_SGI_TARGET_SHIFT ;static unsigned int gic_cpu_mask =0xff ; +static unsigned int gich_apr =GICH_APR ; +static unsigned int gich_lr =GICH_LR ;#define is_hip04 () (nr_gic_cpu_if == 16)
@@ -157,9 +162,9 @@ static void gicv2_save_state(struct vcpu *v)* accessed simultaneously by another pCPU. */ for ( i =0 ; i < gicv2_info.nr_lrs; i++ ) - v->arch.gic.v2.lr[i] =readl_gich (GICH_LR + i *4 ); + v->arch.gic.v2.lr[i] =readl_gich (gich_lr + i *4 ); - v->arch.gic.v2.apr =readl_gich (GICH_APR ); + v->arch.gic.v2.apr =readl_gich (gich_apr); v->arch.gic.v2.vmcr =readl_gich (GICH_VMCR );/* Disable until next VCPU scheduled */ writel_gich (0 ,GICH_HCR );
@@ -170,9 +175,9 @@ static void gicv2_restore_state(const struct vcpu *v)int i;for ( i =0 ; i < gicv2_info.nr_lrs; i++ ) -writel_gich (v->arch.gic.v2.lr[i],GICH_LR + i *4 ); +writel_gich (v->arch.gic.v2.lr[i], gich_lr + i *4 ); -writel_gich (v->arch.gic.v2.apr,GICH_APR ); +writel_gich (v->arch.gic.v2.apr, gich_apr);writel_gich (v->arch.gic.v2.vmcr,GICH_VMCR );writel_gich (GICH_HCR_EN ,GICH_HCR ); }
@@ -185,7 +190,7 @@ static void gicv2_dump_state(const struct vcpu *v) {for ( i =0 ; i < gicv2_info.nr_lrs; i++ )printk (" HW_LR[%d]=%x\n" , i, -readl_gich (GICH_LR + i *4 )); +readl_gich (gich_lr + i *4 )); } else {
@@ -439,12 +444,12 @@ static void gicv2_update_lr(int lr, const struct pending_irq *p, << GICH_V2_LR_PHYSICAL_SHIFT); } -writel_gich (lr_reg,GICH_LR + lr *4 ); +writel_gich (lr_reg, gich_lr + lr *4 ); }static void gicv2_clear_lr (int lr) { -writel_gich (0 ,GICH_LR + lr *4 ); +writel_gich (0 , gich_lr + lr *4 ); }static int gicv2v_setup (struct domain *d)
@@ -494,7 +499,7 @@ static void gicv2_read_lr(int lr, struct gic_lr *lr_reg) {uint32_t lrv; - lrv =readl_gich (GICH_LR + lr *4 ); + lrv =readl_gich (gich_lr + lr *4 ); lr_reg->pirq = (lrv >>GICH_V2_LR_PHYSICAL_SHIFT ) &GICH_V2_LR_PHYSICAL_MASK ; lr_reg->virq = (lrv >>GICH_V2_LR_VIRTUAL_SHIFT ) &GICH_V2_LR_VIRTUAL_MASK ; lr_reg->priority = (lrv >>GICH_V2_LR_PRIORITY_SHIFT ) &GICH_V2_LR_PRIORITY_MASK ;
@@ -517,7 +522,7 @@ static void gicv2_write_lr(int lr, const struct gic_lr *lr_reg) << GICH_V2_LR_HW_SHIFT) | ((uint32_t)(lr_reg->grp & GICH_V2_LR_GRP_MASK) << GICH_V2_LR_GRP_SHIFT) ); -writel_gich (lrv,GICH_LR + lr *4 ); +writel_gich (lrv, gich_lr + lr *4 ); }static void gicv2_hcr_status (uint32_t flag,bool_t status)
@@ -540,7 +545,7 @@ static unsigned int gicv2_read_vmcr_priority(void)static unsigned int gicv2_read_apr (int apr_reg) { -return readl_gich (GICH_APR ); +return readl_gich (gich_apr); }static void gicv2_irq_enable (struct irq_desc *desc)
@@ -803,6 +808,8 @@ static int __init hip04_gicv2_init(struct dt_device_node *node, const void *data nr_gic_cpu_if =16 ; gicd_sgi_target_shift =8 ; gic_cpu_mask =0xffff ; + gich_apr =HIP04_GICH_APR ; + gich_lr =HIP04_GICH_LR ;return gicv2_init_default (node, data); }
Signature · 1 line
1.9.1
PATCH v3 6/8 xen/arm: Force dom0 to use normal GICv2 driver on Hip04 platform
In reply to Frediano ZiglioUntil vGIC support is not implemented and tested, this will prevent guest kernels to use their Hip04 driver, or crash when they don't have any.
--- xen/arch/arm/gic-v2.c | 6 ++++++ 1 file changed, 6 insertions(+)
xen/arch/arm/gic-v2.c +6 -0
@@ -641,6 +641,12 @@ static int gicv2_make_dt_node(const struct domain *d,return -FDT_ERR_XEN (ENOENT ); } +if (is_hip04 () ) + { + compatible =DT_COMPAT_GIC_CORTEX_A15 ; + len =strlen ((char *) compatible) +1 ; + } + res =fdt_begin_node (fdt,"interrupt-controller" );if ( res )return res;
Signature · 1 line
1.9.1
PATCH v3 7/8 xen/device_tree: Add dt_device_get_address_raw
In reply to Frediano ZiglioAllow to read untranslated address from device node.
--- xen/common/device_tree.c | 34 ++++++++++++++++++++++++++++++++++ xen/include/xen/device_tree.h | 11 +++++++++++ 2 files changed, 45 insertions(+)
xen/common/device_tree.c +34 -0
@@ -711,6 +711,40 @@ int dt_device_get_address(const struct dt_device_node *dev, int index,return 0 ; } +/* dt_device_get_address_raw - Returns address not translated */ +int dt_device_get_address_raw (const struct dt_device_node *dev,int index, +u64 *addr) +{ +const __be32 *addrp; +const struct dt_device_node *parent; +const struct dt_bus *bus; +int na, ns; + +if ( !addr ) +return -EINVAL ; + + addrp =dt_get_address (dev, index,NULL ,NULL ); +if ( addrp ==NULL ) +return -EINVAL ; + +/* Get parent & match bus type */ + parent =dt_get_parent (dev); +if ( parent ==NULL ) +return -EINVAL ; + bus =dt_match_bus (parent); +if ( !bus ) +return -EINVAL ; + +/* Count address cells & copy address locally */ + bus->count_cells (dev, &na, &ns); +if ( !DT_CHECK_ADDR_COUNT (na) ) +return -EINVAL ; + + *addr =dt_read_number (addrp, na); +return 0 ; +} + +/** * dt_find_node_by_phandle - Find a node given a phandle * @handle: phandle of the node to find
xen/include/xen/device_tree.h +11 -0
@@ -475,6 +475,17 @@ int dt_device_get_address(const struct dt_device_node *dev, int index, u64 *addr, u64 *size);/** +* dt_device_get_address_raw - Get an address for a device +* @device: the device whose address is to be resolved +* @index: index of the address to resolve +* @addr: address filled by this function +* +* This function get a raw (unresolved) address. It returns 0 on success. +*/ +int dt_device_get_address_raw (const struct dt_device_node *dev,int index, +u64 *addr); + +/** * dt_number_of_irq - Get the number of IRQ for a device * @device: the device whose number of interrupt is to be retrieved *
Signature · 1 line
1.9.1
Re: [PATCH v3 7/8] xen/device_tree: Add dt_device_get_address_raw
Hi Frediano,
I will made a global comment here for patch #7 and #8.
Quoted 13 lines · Frediano Ziglio
Allow to read untranslated address from device node.
Signed-off-by Frediano Ziglio <[email protected]>--- xen/common/device_tree.c | 34 ++++++++++++++++++++++++++++++++++ xen/include/xen/device_tree.h | 11 +++++++++++ 2 files changed, 45 insertions(+)xen/common/device_tree.c +0
-0
xen/common/device_tree.c int dt_device_get_address(const struct dt_device_node *dev, int index, · line 716
Quoted 6 lines
xen/common/device_tree.c +3
-0@@ -711,6 +711,40 @@ int dt_device_get_address(const struct dt_device_node *dev, int index,return 0 ; } +/* dt_device_get_address_raw - Returns address not translated */ +int dt_device_get_address_raw (const struct dt_device_node *dev,int index, +u64 *addr)
This is wrong to assume that the untranslated address will fit in a 64 bits value.
Technically an untranslated address could be encoded on up to 4 cells (though it has been hardcoded).
In any case, I don't think this is the right solution to the problem. As DOM0 will always have the same layout as the hardware for the GIC, we should copy "regs" and strip the unecessary regions (such as the GICH and GICV).
Regards,
Signature · 1 line
Julien Grall
PATCH v3 8/8 xen/arm: Handle translated addresses for hardware domains
In reply to Frediano ZiglioTranslated address could have an offset applied to them. Replicate same value for device node to avoid improper address computation in the OS.
--- xen/arch/arm/gic-v2.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
xen/arch/arm/gic-v2.c +21 -2
@@ -67,8 +67,10 @@/* Global state */ static struct { paddr_t dbase; /* Address of distributor registers */ + paddr_t dbase_raw; /* Untranslated address of distributor registers */ void __iomem * map_dbase; /* IO mapped Address of distributor registers */ paddr_t cbase; /* Address of CPU interface registers */ + paddr_t cbase_raw; /* Untranslated address of CPU interface registers */ void __iomem * map_cbase[2]; /* IO mapped Address of CPU interface registers */ paddr_t hbase; /* Address of virtual interface registers */ void __iomem * map_hbase; /* IO Address of virtual interface registers */
@@ -671,8 +673,17 @@ static int gicv2_make_dt_node(const struct domain *d,return -FDT_ERR_XEN (ENOMEM ); tmp = new_cells; -dt_set_range (&tmp, node, d->arch.vgic.dbase,PAGE_SIZE ); -dt_set_range (&tmp, node, d->arch.vgic.cbase,PAGE_SIZE *2 ); + +if (is_hardware_domain (d) ) + { +dt_set_range (&tmp, node, gicv2.dbase_raw,PAGE_SIZE ); +dt_set_range (&tmp, node, gicv2.cbase_raw,PAGE_SIZE *2 ); + } +else + { +dt_set_range (&tmp, node, d->arch.vgic.dbase,PAGE_SIZE ); +dt_set_range (&tmp, node, d->arch.vgic.cbase,PAGE_SIZE *2 ); + } res =fdt_property (fdt,"reg" , new_cells, len);xfree (new_cells);
@@ -739,10 +750,18 @@ static int __init gicv2_init_default(struct dt_device_node *node, const void *daif ( res || !gicv2.dbase || (gicv2.dbase & ~PAGE_MASK ) )panic ("GICv2: Cannot find a valid address for the distributor" ); + res =dt_device_get_address_raw (node,0 , &gicv2.dbase_raw); +if ( res ) +panic ("GICv2: Cannot find a valid address for the distributor" ); + res =dt_device_get_address (node,1 , &gicv2.cbase,NULL );if ( res || !gicv2.cbase || (gicv2.cbase & ~PAGE_MASK ) )panic ("GICv2: Cannot find a valid address for the CPU" ); + res =dt_device_get_address_raw (node,1 , &gicv2.cbase_raw); +if ( res ) +panic ("GICv2: Cannot find a valid address for the CPU" ); + res =dt_device_get_address (node,2 , &gicv2.hbase,NULL );if ( res || !gicv2.hbase || (gicv2.hbase & ~PAGE_MASK ) )panic ("GICv2: Cannot find a valid address for the hypervisor" );
Signature · 1 line
1.9.1
Re: [PATCH v3 8/8] xen/arm: Handle translated addresses for hardware domains
Hi Frediano,
Quoted 25 lines · Frediano Ziglio
Translated address could have an offset applied to them. Replicate same value for device node to avoid improper address computation in the OS.
Signed-off-by Frediano Ziglio <[email protected]>--- xen/arch/arm/gic-v2.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)xen/arch/arm/gic-v2.c +2
-0@@ -67,8 +67,10 @@/* Global state */ static struct { paddr_t dbase; /* Address of distributor registers */ + paddr_t dbase_raw; /* Untranslated address of distributor registers */ void __iomem * map_dbase; /* IO mapped Address of distributor registers */ paddr_t cbase; /* Address of CPU interface registers */ + paddr_t cbase_raw; /* Untranslated address of CPU interface registers */ void __iomem * map_cbase[2]; /* IO mapped Address of CPU interface registers */ paddr_t hbase; /* Address of virtual interface registers */ void __iomem * map_hbase; /* IO Address of virtual interface registers */
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct domain *d, · line 678
Quoted 8 lines
xen/arch/arm/gic-v2.c +3
-2@@ -671,8 +673,17 @@ static int gicv2_make_dt_node(const struct domain *d,return -FDT_ERR_XEN (ENOMEM ); tmp = new_cells; -dt_set_range (&tmp, node, d->arch.vgic.dbase,PAGE_SIZE ); -dt_set_range (&tmp, node, d->arch.vgic.cbase,PAGE_SIZE *2 ); + +if (is_hardware_domain (d) ) + {
This check is pointless, as said on an earlier version of this series, gicv2_make_dt_node is only used to create DOM0 (hardware domain) device tree.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v3 8/8] xen/arm: Handle translated addresses for hardware domains
Hi,
Quoted 3 lines · Julien Grall
This check is pointless, as said on an earlier version of this series,
gicv2_make_dt_nodeis only used to create DOM0 (hardware domain) device tree.
Btw. where is the guest DTB created? Quickly checking the code I couldn't find it.
Thanks,
Zoli
Re: [PATCH v3 8/8] xen/arm: Handle translated addresses for hardware domains
Quoted 9 lines · Zoltan Kiss
Hi,
Quoted 3 lines · Julien Grall
This check is pointless, as said on an earlier version of this series,
gicv2_make_dt_nodeis only used to create DOM0 (hardware domain) device tree.Btw. where is the guest DTB created? Quickly checking the code I couldn't find it.
The guest DTB is created in by the toolstack:
tools/libxl/libxl_arm.c
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v3 8/8] xen/arm: Handle translated addresses for hardware domains
In reply to Julien GrallQuoted 44 lines
Hi Frediano,
Quoted 14 lines · Frediano Ziglio
Translated address could have an offset applied to them. Replicate same value for device node to avoid improper address computation in the OS.
Signed-off-by Frediano Ziglio <[email protected]>--- xen/arch/arm/gic-v2.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)xen/arch/arm/gic-v2.c index renamed from xen/arch/arm/gic-v2.c +0
-02f6bbd5..271074d 100644
xen/arch/arm/gic-v2.c line 70
Quoted 4 lines
xen/arch/arm/gic-v2.c +1
-0@@ -67,8 +67,10 @@/* Global state */ static struct { paddr_t dbase; /* Address of distributor registers */ + paddr_t dbase_raw; /* Untranslated address of distributorregisters */
xen/arch/arm/gic-v2.c line 71
Quoted 1 line
xen/arch/arm/gic-v2.c +0
-0void __iomem * map_dbase;/* IO mapped Address of distributor registers */
xen/arch/arm/gic-v2.c line 72
Quoted 1 line
xen/arch/arm/gic-v2.c +0
-0paddr_t cbase;/* Address of CPU interface registers */
xen/arch/arm/gic-v2.c line 73
Quoted 1 line
xen/arch/arm/gic-v2.c +1
-0+paddr_t cbase_raw;/* Untranslated address of CPU interface registers */
xen/arch/arm/gic-v2.c line 74
Quoted 1 line
xen/arch/arm/gic-v2.c +0
-0void __iomem * map_cbase[2 ];/* IO mapped Address of CPU interface registers */
xen/arch/arm/gic-v2.c line 75
Quoted 1 line
xen/arch/arm/gic-v2.c +0
-0paddr_t hbase;/* Address of virtual interface registers */
Quoted 2 lines
xen/arch/arm/gic-v2.c +0
-0void __iomem * map_hbase;/* IO Address of virtual interface registers */ @@ -671,8 +673,17 @@ static int gicv2_make_dt_node(const
struct domain *d,
xen/arch/arm/gic-v2.c
Quoted 8 lines
return -FDT_ERR_XEN(ENOMEM); tmp = new_cells;xen/arch/arm/gic-v2.c +3
-2-dt_set_range (&tmp, node, d->arch.vgic.dbase,PAGE_SIZE ); -dt_set_range (&tmp, node, d->arch.vgic.cbase,PAGE_SIZE *2 ); + +if (is_hardware_domain (d) ) + {
Quoted 8 lines
This check is pointless, as said on an earlier version of this series,
gicv2_make_dt_nodeis only used to create DOM0 (hardware domain) device tree.Regards,
--
Julien Grall
How does sound something like this (already tested, it's working). Perhaps just to be paranoid a test on len after reading reg property would be perfect.
xen/arch/arm/gic-v2.c +17 -5
@@ -632,7 +632,7 @@ static int gicv2_make_dt_node(const struct domain *d,const void *compatible =NULL ;u32 len;__be32 *new_cells, *tmp; -int res =0 ; +int res =0 , na, ns; compatible =dt_get_property (gic,"compatible" , &len);if ( !compatible )
@@ -664,15 +664,27 @@ static int gicv2_make_dt_node(const struct domain *d,if ( res )return res; - len =dt_cells_to_size (dt_n_addr_cells (node) +dt_n_size_cells (node)); +/* copy GICC and GICD regions */ + na =dt_n_addr_cells (node); + ns =dt_n_size_cells (node); + +if ( na !=dt_n_addr_cells (gic) || ns !=dt_n_size_cells (gic) ) +return -FDT_ERR_XEN (EINVAL ); + + tmp = (__be32 *)dt_get_property (gic,"reg" , &len); +if ( !tmp ) + { +dprintk (XENLOG_ERR ,"Can't find reg property for the gic node\n" ); +return -FDT_ERR_XEN (ENOENT ); + } + + len =dt_cells_to_size (na + ns); len *=2 ;/* GIC has two memory regions: Distributor + CPU interface */ new_cells =xzalloc_bytes (len);if ( new_cells ==NULL )return -FDT_ERR_XEN (ENOMEM ); - tmp = new_cells; -dt_set_range (&tmp, node, d->arch.vgic.dbase,PAGE_SIZE ); -dt_set_range (&tmp, node, d->arch.vgic.cbase,PAGE_SIZE *2 ); +memcpy (new_cells, tmp, len); res =fdt_property (fdt,"reg" , new_cells, len);xfree (new_cells);
Signature · 3 lines
1.9.1 Frediano
Re: [PATCH v3 8/8] xen/arm: Handle translated addresses for hardware domains
Quoted 1 line · Frediano Ziglio
How does sound something like this (already tested, it's working).
The idea looks good to me. Few comments below.
Also, I'm wondering if we could create a generic function for this purpose. The code of the GICv3 suffers of the same problem.
Quoted 1 line
Perhaps just to be paranoid a test on len after reading reg property
would be perfect.
The property/node has been validated in the GICv2 initialization. Checking again here is not necessary.
Quoted 15 lines
xen/arch/arm/gic-v2.c +1
-1@@ -632,7 +632,7 @@ static int gicv2_make_dt_node(const struct domain *d,const void *compatible =NULL ;u32 len;__be32 *new_cells, *tmp; -int res =0 ; +int res =0 , na, ns; compatible =dt_get_property (gic,"compatible" , &len);if ( !compatible )
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct domain *d, · line 672
Quoted 10 lines
xen/arch/arm/gic-v2.c +6
-1@@ -664,15 +664,27 @@ static int gicv2_make_dt_node(const struct domain *d,if ( res )return res; - len =dt_cells_to_size (dt_n_addr_cells (node) +dt_n_size_cells (node)); +/* copy GICC and GICD regions */ + na =dt_n_addr_cells (node); + ns =dt_n_size_cells (node); + +if ( na !=dt_n_addr_cells (gic) || ns !=dt_n_size_cells (gic) ) +return -FDT_ERR_XEN (EINVAL );
Not necessary, the caller of this function already check that gic (i.e dt_interrupt_controller) == node.
If you really to be safe, I would add ASSERT(gic == node);
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct domain *d, · line 674
Quoted 2 lines
xen/arch/arm/gic-v2.c +2
-0+ + tmp = (__be32 *)dt_get_property (gic,"reg" , &len);
The cast is not necessary.
Quoted 6 lines
xen/arch/arm/gic-v2.c +6
-0+if ( !tmp ) + { +dprintk (XENLOG_ERR ,"Can't find reg property for the gic node\n" ); +return -FDT_ERR_XEN (ENOENT ); + } +
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct domain *d, · line 687
Quoted 10 lines
xen/arch/arm/gic-v2.c +2
-3+ len =dt_cells_to_size (na + ns); len *=2 ;/* GIC has two memory regions: Distributor + CPU interface */ new_cells =xzalloc_bytes (len);if ( new_cells ==NULL )return -FDT_ERR_XEN (ENOMEM ); - tmp = new_cells; -dt_set_range (&tmp, node, d->arch.vgic.dbase,PAGE_SIZE ); -dt_set_range (&tmp, node, d->arch.vgic.cbase,PAGE_SIZE *2 ); +memcpy (new_cells, tmp, len);
You don't need to copy the data in the temporary variable. You can directly use fdt_property with the right len. Smth like:
fdt_property(fdt, "reg", tmp, len);
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v3 8/8] xen/arm: Handle translated addresses for hardware domains
Quoted 75 lines · Frediano Ziglio
Quoted 1 line
How does sound something like this (already tested, it's working).
The idea looks good to me. Few comments below.
Also, I'm wondering if we could create a generic function for this purpose. The code of the GICv3 suffers of the same problem.
Quoted 1 line
Perhaps just to be paranoid a test on len after reading reg property
would be perfect.
The property/node has been validated in the GICv2 initialization. Checking again here is not necessary.
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct domain
Quoted 6 lines
xen/arch/arm/gic-v2.c index renamed from xen/arch/arm/gic-v2.c +0
-02f6bbd5..2c4d097 100644
xen/arch/arm/gic-v2.c +0
-0@@ -632,7 +632,7 @@ static int gicv2_make_dt_node(const struct domain*d,
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct
Quoted 9 lines
xen/arch/arm/gic-v2.c +1
-1const void *compatible =NULL ;u32 len;__be32 *new_cells, *tmp; -int res =0 ; +int res =0 , na, ns; compatible =dt_get_property (gic,"compatible" , &len);if ( !compatible )@@ -664,15 +664,27 @@ static int gicv2_make_dt_node(const structdomain *d,
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct · line 667
Quoted 4 lines
xen/arch/arm/gic-v2.c +0
-1if ( res )return res; - len = dt_cells_to_size(dt_n_addr_cells(node) +
dt_n_size_cells(node));xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct · line 672
Quoted 6 lines
xen/arch/arm/gic-v2.c +6
-0+/* copy GICC and GICD regions */ + na =dt_n_addr_cells (node); + ns =dt_n_size_cells (node); + +if ( na !=dt_n_addr_cells (gic) || ns !=dt_n_size_cells (gic) ) +return -FDT_ERR_XEN (EINVAL );Not necessary, the caller of this function already check that gic (i.e
dt_interrupt_controller) == node.If you really to be safe, I would add ASSERT(gic == node);
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct · line 674
Quoted 2 lines
xen/arch/arm/gic-v2.c +2
-0+ + tmp = (__be32 *)dt_get_property (gic,"reg" , &len);The cast is not necessary.
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct · line 677
Quoted 3 lines
xen/arch/arm/gic-v2.c +3
-0+if ( !tmp ) + { + dprintk(XENLOG_ERR, "Can't find reg property for the gicnode\n");
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct · line 682
Quoted 5 lines
xen/arch/arm/gic-v2.c +4
-0+return -FDT_ERR_XEN (ENOENT ); + } + + len =dt_cells_to_size (na + ns); len *=2 ;/* GIC has two memory regions: Distributor + CPU interface */
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct · line 687
Quoted 8 lines
xen/arch/arm/gic-v2.c +1
-3new_cells =xzalloc_bytes (len);if ( new_cells ==NULL )return -FDT_ERR_XEN (ENOMEM ); - tmp = new_cells; -dt_set_range (&tmp, node, d->arch.vgic.dbase,PAGE_SIZE ); -dt_set_range (&tmp, node, d->arch.vgic.cbase,PAGE_SIZE *2 ); +memcpy (new_cells, tmp, len);You don't need to copy the data in the temporary variable. You can directly use
fdt_propertywith the right len. Smth like:
Quoted 6 lines
fdt_property(fdt, "reg", tmp, len);Regards,
--
Julien Grall
This then should look much better.
xen/arch/arm/gic-v2.c +10 -11
@@ -629,9 +629,8 @@ static int gicv2_make_dt_node(const struct domain *d, const struct dt_device_node *node, void *fdt) { const struct dt_device_node *gic = dt_interrupt_controller; -const void *compatible =NULL ; +const void *compatible =NULL , *tmp;u32 len; -__be32 *new_cells, *tmp;int res =0 ; compatible =dt_get_property (gic,"compatible" , &len);
@@ -664,18 +663,18 @@ static int gicv2_make_dt_node(const struct domain *d,if ( res )return res; +/* copy GICC and GICD regions */ + tmp =dt_get_property (gic,"reg" , &len); +if ( !tmp ) + { +dprintk (XENLOG_ERR ,"Can't find reg property for the gic node\n" ); +return -FDT_ERR_XEN (ENOENT ); + } + len =dt_cells_to_size (dt_n_addr_cells (node) +dt_n_size_cells (node)); len *=2 ;/* GIC has two memory regions: Distributor + CPU interface */ - new_cells =xzalloc_bytes (len); -if ( new_cells ==NULL ) -return -FDT_ERR_XEN (ENOMEM ); - - tmp = new_cells; -dt_set_range (&tmp, node, d->arch.vgic.dbase,PAGE_SIZE ); -dt_set_range (&tmp, node, d->arch.vgic.cbase,PAGE_SIZE *2 ); - res =fdt_property (fdt,"reg" , new_cells, len); -xfree (new_cells); + res =fdt_property (fdt,"reg" , tmp, len);return res; }
Signature · 3 lines
1.9.1 Frediano
Re: [PATCH v3 8/8] xen/arm: Handle translated addresses for hardware domains
Quoted 89 lines · Frediano Ziglio
Quoted 75 lines · Frediano Ziglio
Quoted 1 line
How does sound something like this (already tested, it's working).
The idea looks good to me. Few comments below.
Also, I'm wondering if we could create a generic function for this purpose. The code of the GICv3 suffers of the same problem.
Quoted 1 line
Perhaps just to be paranoid a test on len after reading reg property
would be perfect.
The property/node has been validated in the GICv2 initialization. Checking again here is not necessary.
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct domain
Quoted 6 lines
xen/arch/arm/gic-v2.c index renamed from xen/arch/arm/gic-v2.c +0
-02f6bbd5..2c4d097 100644
xen/arch/arm/gic-v2.c +0
-0@@ -632,7 +632,7 @@ static int gicv2_make_dt_node(const struct domain*d,
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct
Quoted 9 lines
xen/arch/arm/gic-v2.c +1
-1const void *compatible =NULL ;u32 len;__be32 *new_cells, *tmp; -int res =0 ; +int res =0 , na, ns; compatible =dt_get_property (gic,"compatible" , &len);if ( !compatible )@@ -664,15 +664,27 @@ static int gicv2_make_dt_node(const structdomain *d,
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct domain *d,
Quoted 4 lines
xen/arch/arm/gic-v2.c +0
-1if ( res )return res; - len = dt_cells_to_size(dt_n_addr_cells(node) +
dt_n_size_cells(node));xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct · line 672
Quoted 6 lines
xen/arch/arm/gic-v2.c +6
-0+/* copy GICC and GICD regions */ + na =dt_n_addr_cells (node); + ns =dt_n_size_cells (node); + +if ( na !=dt_n_addr_cells (gic) || ns !=dt_n_size_cells (gic) ) +return -FDT_ERR_XEN (EINVAL );Not necessary, the caller of this function already check that gic (i.e
dt_interrupt_controller) == node.If you really to be safe, I would add ASSERT(gic == node);
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct · line 674
Quoted 2 lines
xen/arch/arm/gic-v2.c +2
-0+ + tmp = (__be32 *)dt_get_property (gic,"reg" , &len);The cast is not necessary.
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct domain *d,
Quoted 3 lines
xen/arch/arm/gic-v2.c +3
-0+if ( !tmp ) + { + dprintk(XENLOG_ERR, "Can't find reg property for the gicnode\n");
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct domain *d,
Quoted 5 lines
xen/arch/arm/gic-v2.c +4
-0+return -FDT_ERR_XEN (ENOENT ); + } + + len =dt_cells_to_size (na + ns); len *=2 ;/* GIC has two memory regions: Distributor + CPU interface */
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct domain *d,
Quoted 8 lines
xen/arch/arm/gic-v2.c +1
-3new_cells =xzalloc_bytes (len);if ( new_cells ==NULL )return -FDT_ERR_XEN (ENOMEM ); - tmp = new_cells; -dt_set_range (&tmp, node, d->arch.vgic.dbase,PAGE_SIZE ); -dt_set_range (&tmp, node, d->arch.vgic.cbase,PAGE_SIZE *2 ); +memcpy (new_cells, tmp, len);You don't need to copy the data in the temporary variable. You can directly use
fdt_propertywith the right len. Smth like:Quoted 6 lines
fdt_property(fdt, "reg", tmp, len);Regards,
--
Julien GrallThis then should look much better.
xen/arch/arm/gic-v2.c +0
-0
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct domain *d, · line 634
Quoted 7 lines
xen/arch/arm/gic-v2.c +1
-2@@ -629,9 +629,8 @@ static int gicv2_make_dt_node(const struct domain *d, const struct dt_device_node *node, void *fdt) { const struct dt_device_node *gic = dt_interrupt_controller; -const void *compatible =NULL ; +const void *compatible =NULL , *tmp;u32 len; -__be32 *new_cells, *tmp;
I would prefer if you keep tmp as __be32 *. It documents the real type of the data. Also, for clarity, I would rename it to cells.
BTW, the commit title/message wasn't really clear. It make thinks you are fixing the problem for everyone and not only the GICv2.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v3 8/8] xen/arm: Handle translated addresses for hardware domains
Quoted 7 lines · Julien Grall
Quoted 7 lines
xen/arch/arm/gic-v2.c +0
-0@@ -629,9 +629,8 @@ static int gicv2_make_dt_node(const struct domain *d, const struct dt_device_node *node, void *fdt) {
Quoted 8 lines
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct domain *d, · line 634
Quoted 5 lines
xen/arch/arm/gic-v2.c +1
-2const struct dt_device_node *gic = dt_interrupt_controller; -const void *compatible =NULL ; +const void *compatible =NULL , *tmp;u32 len; -__be32 *new_cells, *tmp;I would prefer if you keep tmp as
__be32*. It documents the real type of the data. Also, for clarity, I would rename it to cells.
s/cells/regs/. Sorry
Signature · 1 line
Julien Grall
Re: [PATCH v3 8/8] xen/arm: Handle translated addresses for hardware domains
Quoted 15 lines · Julien Grall
Quoted 5 lines
xen/arch/arm/gic-v2.c static int gicv2_make_dt_node(const struct
Quoted 5 lines
xen/arch/arm/gic-v2.c index renamed from xen/arch/arm/gic-v2.c +0
-02f6bbd5..9b9e696 100644
xen/arch/arm/gic-v2.c +0
-0@@ -629,9 +629,8 @@ static int gicv2_make_dt_node(const structdomain *d,
Quoted 8 lines
Quoted 7 lines
xen/arch/arm/gic-v2.c +1
-2const struct dt_device_node *node, void *fdt) { const struct dt_device_node *gic = dt_interrupt_controller; -const void *compatible =NULL ; +const void *compatible =NULL , *tmp;u32 len; -__be32 *new_cells, *tmp;
Quoted 8 lines
Quoted 1 line
I would prefer if you keep tmp as
__be32*. It documents the realtype
Quoted 1 line
of the data. Also, for clarity, I would rename it to cells.
s/cells/regs/. Sorry
--
Julien Grall
This version should be perfect then.
Subject: [PATCH 7/7] xen/arm: Handle translated addresses for hardware domains in GICv2
Translated address could have an offset applied to them. Replicate same value for device node to avoid improper address computation in the OS.
--- xen/arch/arm/gic-v2.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
xen/arch/arm/gic-v2.c +10 -10
@@ -631,7 +631,7 @@ static int gicv2_make_dt_node(const struct domain *d,const struct dt_device_node *gic = dt_interrupt_controller;const void *compatible =NULL ;u32 len; -__be32 *new_cells, *tmp; +const __be32 *regs;int res =0 ; compatible =dt_get_property (gic,"compatible" , &len);
@@ -664,18 +664,18 @@ static int gicv2_make_dt_node(const struct domain *d,if ( res )return res; +/* copy GICC and GICD regions */ + regs =dt_get_property (gic,"reg" , &len); +if ( !regs ) + { +dprintk (XENLOG_ERR ,"Can't find reg property for the gic node\n" ); +return -FDT_ERR_XEN (ENOENT ); + } + len =dt_cells_to_size (dt_n_addr_cells (node) +dt_n_size_cells (node)); len *=2 ;/* GIC has two memory regions: Distributor + CPU interface */ - new_cells =xzalloc_bytes (len); -if ( new_cells ==NULL ) -return -FDT_ERR_XEN (ENOMEM ); - - tmp = new_cells; -dt_set_range (&tmp, node, d->arch.vgic.dbase,PAGE_SIZE ); -dt_set_range (&tmp, node, d->arch.vgic.cbase,PAGE_SIZE *2 ); - res =fdt_property (fdt,"reg" , new_cells, len); -xfree (new_cells); + res =fdt_property (fdt,"reg" , regs, len);return res; }
Signature · 1 line
1.9.1
Hi Frediano,
Thank you for adding support to this board.
Could you provide the instruction to boot Xen on this board?
It might be interesting to add a wiki page with them and link to:
http://wiki.xen.org/wiki/Xen_ARM_with_Virtualization_Extensions
Regards,
Quoted 18 lines · Frediano Ziglio
This set of patches add Xen support for hip04-d01 platform (see https://wiki.linaro.org/Boards/D01 for details).
Changes from v2:
- rewrote DTS fix patch (Ian Campbell);
- useis_hip04macro instead of doing explicit test (Julien Grall);
- do not use quirks to distinguish this platform (Ian Cambell);
- move some GIC constants to C files instead of header (Julien Grall);
- minor changes (Julien Grall).Changes from v1:
- style (Julien Grall);
- makegicv2_send_SGIfaster (Julien Grall);
- cleanup correctly ifhip04_smp_initfails (Julien Grall);
- remove quirks using compatibility (Ian Campbell);
- other minor suggestions by Julien Grall.
Signature · 1 line
Julien Grall