arm/gic-v3: Use acpi_table_parse_madt() to parse MADT subtables
PATCH v3 1/10 arm/gic-v3: Use acpi_table_parse_madt() to parse MADT subtables
The function acpi_table_parse_madt() does the same functionality as function acpi_parse_entries() expect it takes a few arguments.
--- xen/arch/arm/gic-v3.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-)
xen/arch/arm/gic-v3.c +6 -21
@@ -1390,28 +1390,15 @@ gic_acpi_get_madt_redistributor_num(struct acpi_subtable_header *header,static void __init gicv3_acpi_init (void ) { -struct acpi_table_header *table;struct rdist_region *rdist_regs; -acpi_status status;int count, i; - status =acpi_get_table (ACPI_SIG_MADT ,0 , &table); - -if (ACPI_FAILURE (status) ) - { -const char *msg =acpi_format_exception (status); - -panic ("GICv3: Failed to get MADT table, %s" , msg); - } -/* * Find distributor base address. We expect one distributor entry since * ACPI 5.0 spec neither support multi-GIC instances nor GIC cascade. */ - count =acpi_parse_entries (ACPI_SIG_MADT ,sizeof (struct acpi_table_madt ), - gic_acpi_parse_madt_distributor, table, -ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR ,0 ); - + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR , + gic_acpi_parse_madt_distributor,0 );if ( count <=0 )panic ("GICv3: No valid GICD entries exists" );
@@ -1420,9 +1407,8 @@ static void __init gicv3_acpi_init(void) dbase);/* Get number of redistributor */ - count =acpi_parse_entries (ACPI_SIG_MADT ,sizeof (struct acpi_table_madt ), - gic_acpi_get_madt_redistributor_num, table, -ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR ,0 ); + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR , + gic_acpi_get_madt_redistributor_num,0 );if ( count <=0 )panic ("GICv3: No valid GICR entries exists" );
@@ -1458,9 +1444,8 @@ static void __init gicv3_acpi_init(void) gicv3.rdist_regions= rdist_regs;/* Collect CPU base addresses */ - count =acpi_parse_entries (ACPI_SIG_MADT ,sizeof (struct acpi_table_madt ), - gic_acpi_parse_madt_cpu, table, -ACPI_MADT_TYPE_GENERIC_INTERRUPT ,0 ); + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_INTERRUPT , + gic_acpi_parse_madt_cpu,0 );if ( count <=0 )panic ("GICv3: No valid GICC entries exists" );
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
PATCH v3 2/10 arm/gic-v3: Do early GICD ioremap and clean up
For ACPI based XEN boot, the GICD region needs to be accessed inside the function gicv3_acpi_init() in later patch. There is a duplicate panic() message, one in the DTS probe and second one in the ACPI probe path. For these two reasons, move the code that validates the GICD base address and does the region ioremap to a separate function. The following patch accesses the GICD region inside gicv3_acpi_init() for finding per CPU Redistributor size.
---
Changes sicne v1:
Edited commit text.
xen/arch/arm/gic-v3.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
xen/arch/arm/gic-v3.c +13 -10
@@ -1169,6 +1169,17 @@ static void __init gicv3_init_v2(void)vgic_v2_setup_hw (dbase, cbase, csize, vbase,0 ); } +static void __init gicv3_ioremap_distributor (paddr_t dist_paddr) +{ +if ( dist_paddr & ~PAGE_MASK ) +panic ("GICv3: Found unaligned distributor address %" PRIpaddr"" , + dbase); + + gicv3.map_dbase =ioremap_nocache (dist_paddr,SZ_64K ); +if ( !gicv3.map_dbase ) +panic ("GICv3: Failed to ioremap for GIC distributor\n" ); +} +static void __init gicv3_dt_init (void ) {struct rdist_region *rdist_regs;
@@ -1179,9 +1190,7 @@ static void __init gicv3_dt_init(void)if ( res )panic ("GICv3: Cannot find a valid distributor address" ); -if ( (dbase & ~PAGE_MASK ) ) -panic ("GICv3: Found unaligned distributor address %" PRIpaddr"" , - dbase); +gicv3_ioremap_distributor (dbase);if ( !dt_property_read_u32 (node,"#redistributor-regions" , &gicv3.rdist_count) )
@@ -1402,9 +1411,7 @@ static void __init gicv3_acpi_init(void)if ( count <=0 )panic ("GICv3: No valid GICD entries exists" ); -if ( (dbase & ~PAGE_MASK ) ) -panic ("GICv3: Found unaligned distributor address %" PRIpaddr"" , - dbase); +gicv3_ioremap_distributor (dbase);/* Get number of redistributor */ count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR,
@@ -1476,10 +1483,6 @@ static int __init gicv3_init(void)else gicv3_acpi_init (); - gicv3.map_dbase =ioremap_nocache (dbase,SZ_64K ); -if ( !gicv3.map_dbase ) -panic ("GICv3: Failed to ioremap for GIC distributor\n" ); - reg =readl_relaxed (GICD +GICD_PIDR2 ) &GIC_PIDR2_ARCH_MASK ;if ( reg != GIC_PIDR2_ARCH_GICv3 && reg != GIC_PIDR2_ARCH_GICv4 )panic ("GICv3: no distributor detected\n" );
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
PATCH v3 3/10 arm/gic-v3: Move GICR subtable parsing into a new function
In reply to Shanker DonthineniAdd a new function to parse GICR subtable and move the code that is specific to GICR table to a new function without changing the function gicv3_acpi_init() behavior.
---
Changes since v2:
Changed function gic_acpi_add_rdist_region() protoype.
Removed the address validation check in gic_acpi_parse_madt_redistributor(). Edited commit text.
Changes since v1:
Removed the unnecessary GICR ioremap operation inside GICR table parse code.
xen/arch/arm/gic-v3.c | 56 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 22 deletions(-)
xen/arch/arm/gic-v3.c +34 -22
@@ -1282,6 +1282,14 @@ static int gicv3_iomem_deny_access(const struct domain *d) }#ifdef CONFIG_ACPI +static void __init gic_acpi_add_rdist_region (paddr_t base,paddr_t size) +{ +unsigned int idx = gicv3.rdist_count++; + + gicv3.rdist_regions[idx].base = base; + gicv3.rdist_regions[idx].size = size; +} +static int gicv3_make_hwdom_madt (const struct domain *d,u32 offset) {struct acpi_subtable_header *header;
@@ -1387,6 +1395,22 @@ gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,return 0 ; } + +static int __init +gic_acpi_parse_madt_redistributor (struct acpi_subtable_header *header, +const unsigned long end) +{ +struct acpi_madt_generic_redistributor *rdist; + + rdist = (struct acpi_madt_generic_redistributor *)header; +if (BAD_MADT_ENTRY (rdist, end) ) +return -EINVAL ; + +gic_acpi_add_rdist_region (rdist->base_address, rdist->length); + +return 0 ; +} +static int __init gic_acpi_get_madt_redistributor_num (struct acpi_subtable_header *header,const unsigned long end)
@@ -1400,7 +1424,7 @@ gic_acpi_get_madt_redistributor_num(struct acpi_subtable_header *header,static void __init gicv3_acpi_init (void ) {struct rdist_region *rdist_regs; -int count, i; +int count;/* * Find distributor base address. We expect one distributor entry since
@@ -1419,37 +1443,25 @@ static void __init gicv3_acpi_init(void)if ( count <=0 )panic ("GICv3: No valid GICR entries exists" ); - gicv3.rdist_count = count; - -if ( gicv3.rdist_count >MAX_RDIST_COUNT ) +if ( count >MAX_RDIST_COUNT )panic ("GICv3: Number of redistributor regions is more than" "%d (Increase MAX_RDIST_COUNT!!)\n" ,MAX_RDIST_COUNT ); - rdist_regs = xzalloc_array(struct rdist_region, gicv3.rdist_count); + rdist_regs = xzalloc_array(struct rdist_region, count);if ( !rdist_regs )panic ("GICv3: Failed to allocate memory for rdist regions\n" ); -for ( i =0 ; i < gicv3.rdist_count; i++ ) - { -struct acpi_subtable_header *header; -struct acpi_madt_generic_redistributor *gic_rdist; - - header =acpi_table_get_entry_madt (ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR , - i); -if ( !header ) -panic ("GICv3: Can't get GICR entry" ); - - gic_rdist = - container_of(header, struct acpi_madt_generic_redistributor, header); - rdist_regs[i].base = gic_rdist->base_address; - rdist_regs[i].size = gic_rdist->length; - } + gicv3.rdist_regions = rdist_regs; + +/* Parse always-on power domain Re-distributor entries */ + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR , + gic_acpi_parse_madt_redistributor, count); +if ( count <=0 ) +panic ("GICv3: Can't get Redistributor entry" );/* The vGIC code requires the region to be sorted */ sort (rdist_regs, gicv3.rdist_count,sizeof (*rdist_regs), cmp_rdist,NULL ); - gicv3.rdist_regions= rdist_regs; -/* Collect CPU base addresses */ count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_INTERRUPT , gic_acpi_parse_madt_cpu,0 );
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
PATCH v3 4/10 arm/gic-v3: Parse per-cpu redistributor entry in GICC subtable
In reply to Shanker DonthineniThe redistributor address can be specified either as part of GICC or GICR subtable depending on the power domain. The current driver doesn't support parsing redistributor entry that is defined in GICC subtable. The GIC CPU subtable entry holds the associated Redistributor base address if it is not on always-on power domain.
The per CPU Redistributor size is not defined in ACPI specification. Set the GICR region size to SZ_256K if the GIC hardware is capable of Direct Virtual LPI Injection feature, SZ_128K otherwise.
This patch adds necessary code to handle both types of Redistributors base addresses.
---
Changes since v2:
Removed the unnecessary validation checks and edited commit text.
xen/arch/arm/gic-v3.c | 68 +++++++++++++++++++++++++++++++++++---- xen/include/asm-arm/gic.h | 1 + xen/include/asm-arm/gic_v3_defs.h | 1 + 3 files changed, 63 insertions(+), 7 deletions(-)
xen/arch/arm/gic-v3.c +61 -7
@@ -659,6 +659,10 @@ static int __init gicv3_populate_rdist(void) smp_processor_id(), i, ptr);return 0 ; } + +if ( gicv3.rdist_regions[i].single_rdist ) +break ; +if ( gicv3.rdist_stride ) ptr += gicv3.rdist_stride;else
@@ -1282,14 +1286,21 @@ static int gicv3_iomem_deny_access(const struct domain *d) }#ifdef CONFIG_ACPI -static void __init gic_acpi_add_rdist_region (paddr_t base,paddr_t size) +static void __init +gic_acpi_add_rdist_region (paddr_t base,paddr_t size,bool single_rdist) {unsigned int idx = gicv3.rdist_count++; + gicv3.rdist_regions[idx].single_rdist = single_rdist; gicv3.rdist_regions[idx].base = base; gicv3.rdist_regions[idx].size = size; } +static inline bool gic_dist_supports_dvis (void ) +{ +return !!(readl_relaxed (GICD +GICD_TYPER ) &GICD_TYPER_DVIS ); +} +static int gicv3_make_hwdom_madt (const struct domain *d,u32 offset) {struct acpi_subtable_header *header;
@@ -1397,6 +1408,36 @@ gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header, }static int __init +gic_acpi_parse_cpu_redistributor (struct acpi_subtable_header *header, +const unsigned long end) +{ +struct acpi_madt_generic_interrupt *processor; +u32 size; + + processor = (struct acpi_madt_generic_interrupt *)header; +if ( !(processor->flags &ACPI_MADT_ENABLED ) ) +return 0 ; + + size =gic_dist_supports_dvis () ?4 *SZ_64K :2 *SZ_64K ; +gic_acpi_add_rdist_region (processor->gicr_base_address, size, true); + +return 0 ; +} + +static int __init +gic_acpi_get_madt_cpu_num (struct acpi_subtable_header *header, +const unsigned long end) +{ +struct acpi_madt_generic_interrupt *cpuif; + + cpuif = (struct acpi_madt_generic_interrupt *)header; +if (BAD_MADT_ENTRY (cpuif, end) || !cpuif->gicr_base_address ) +return -EINVAL ; + +return 0 ; +} + +static int __init gic_acpi_parse_madt_redistributor (struct acpi_subtable_header *header,const unsigned long end) {
@@ -1406,7 +1447,7 @@ gic_acpi_parse_madt_redistributor(struct acpi_subtable_header *header,if (BAD_MADT_ENTRY (rdist, end) )return -EINVAL ; -gic_acpi_add_rdist_region (rdist->base_address, rdist->length); +gic_acpi_add_rdist_region (rdist->base_address, rdist->length, false);return 0 ; }
@@ -1424,6 +1465,7 @@ gic_acpi_get_madt_redistributor_num(struct acpi_subtable_header *header,static void __init gicv3_acpi_init (void ) {struct rdist_region *rdist_regs; +bool gicr_table = true;int count;/*
@@ -1440,8 +1482,15 @@ static void __init gicv3_acpi_init(void)/* Get number of redistributor */ count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR , gic_acpi_get_madt_redistributor_num,0 ); -if ( count <=0 ) -panic ("GICv3: No valid GICR entries exists" ); +/* Count the total number of CPU interface entries */ +if ( count <=0 ) { + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_INTERRUPT , + gic_acpi_get_madt_cpu_num,0 ); +if (count <=0 ) +panic ("GICv3: No valid GICR entries exists" ); + + gicr_table = false; + }if ( count >MAX_RDIST_COUNT ) panic("GICv3: Number of redistributor regions is more than"
@@ -1453,9 +1502,14 @@ static void __init gicv3_acpi_init(void) gicv3.rdist_regions = rdist_regs; -/* Parse always-on power domain Re-distributor entries */ - count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR , - gic_acpi_parse_madt_redistributor, count); +if ( gicr_table ) +/* Parse always-on power domain Re-distributor entries */ + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR , + gic_acpi_parse_madt_redistributor, count); +else +/* Parse Re-distributor entries described in CPU interface table */ + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_INTERRUPT , + gic_acpi_parse_cpu_redistributor, count);if ( count <=0 )panic ("GICv3: Can't get Redistributor entry" );
xen/include/asm-arm/gic.h +1 -0
@@ -101,6 +101,7 @@#define GICD_TYPE_CPUS_SHIFT 5#define GICD_TYPE_CPUS 0x0e0#define GICD_TYPE_SEC 0x400 +#define GICD_TYPER_DVIS (1U << 18)#define GICC_CTL_ENABLE 0x1#define GICC_CTL_EOI (0x1 << 9)
xen/include/asm-arm/gic_v3_defs.h +1 -0
@@ -141,6 +141,7 @@ struct rdist_region {paddr_t base;paddr_t size;void __iomem *map_base; + bool single_rdist; };#endif /* __ASM_ARM_GIC_V3_DEFS_H__ */
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
PATCH v3 5/10 xen/arm: vgic: Use dynamic memory allocation for vgic_rdist_region
In reply to Shanker DonthineniThe number of Redistributor regions allowed for dom0 is hardcoded to a define MAX_RDIST_COUNT which is 4. Some systems, especially latest server chips, may have more than 4 redistributors. Either we have to increase MAX_RDIST_COUNT to a bigger number or allocate memory based on the number of redistributors that are found in MADT table. In the worst case scenario, the macro MAX_RDIST_COUNT should be equal to CONFIG_NR_CPUS in order to support per CPU Redistributors.
Increasing MAX_RDIST_COUNT has a effect, it blows 'struct domain' size and hits BUILD_BUG_ON() in domain build code path.
struct domain *alloc_domain_struct(void)
{
struct domain *d;
BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE);
d = alloc_xenheap_pages(0, 0);
if ( d == NULL )
return NULL;...
This patch uses the second approach to fix the BUILD_BUG().
---
Changes sicne v2:
Edited commit text.
xen/arch/arm/vgic-v2.c | 6 ++++++ xen/arch/arm/vgic-v3.c | 27 ++++++++++++++++++++++++--- xen/arch/arm/vgic.c | 1 + xen/include/asm-arm/domain.h | 2 +- xen/include/asm-arm/vgic.h | 2 ++ 5 files changed, 34 insertions(+), 4 deletions(-)
xen/arch/arm/vgic-v2.c +6 -0
@@ -699,9 +699,15 @@ static int vgic_v2_domain_init(struct domain *d)return 0 ; } +static void vgic_v2_domain_free (struct domain *d) +{ +/* Nothing to be cleanup for this driver */ +} +static const struct vgic_ops vgic_v2_ops = { .vcpu_init = vgic_v2_vcpu_init, .domain_init = vgic_v2_domain_init, + .domain_free = vgic_v2_domain_free, .max_vcpus =8 , };
xen/arch/arm/vgic-v3.c +24 -3
@@ -1391,9 +1391,26 @@ static int vgic_v3_vcpu_init(struct vcpu *v)return 0 ; } +static inline unsigned int vgic_v3_rdist_count (struct domain *d) +{ +return is_hardware_domain (d) ? vgic_v3_hw.nr_rdist_regions : +GUEST_GICV3_RDIST_REGIONS ; +} +static int vgic_v3_domain_init (struct domain *d) { -int i; +struct vgic_rdist_region *rdist_regions; +int rdist_count, i; + +/* Allocate memory for Re-distributor regions */ + rdist_count =vgic_v3_rdist_count (d); + + rdist_regions = xzalloc_array(struct vgic_rdist_region, rdist_count); +if ( !rdist_regions ) +return -ENOMEM ; + + d->arch.vgic.nr_regions = rdist_count; + d->arch.vgic.rdist_regions = rdist_regions;/* * Domain 0 gets the hardware address.
@@ -1426,7 +1443,6 @@ static int vgic_v3_domain_init(struct domain *d) first_cpu += size / d->arch.vgic.rdist_stride; } - d->arch.vgic.nr_regions = vgic_v3_hw.nr_rdist_regions; }else {
@@ -1435,7 +1451,6 @@ static int vgic_v3_domain_init(struct domain *d)/* XXX: Only one Re-distributor region mapped for the guest */ BUILD_BUG_ON (GUEST_GICV3_RDIST_REGIONS !=1 ); - d->arch.vgic.nr_regions =GUEST_GICV3_RDIST_REGIONS ; d->arch.vgic.rdist_stride =GUEST_GICV3_RDIST_STRIDE ;/* The first redistributor should contain enough space for all CPUs */
@@ -1467,9 +1482,15 @@ static int vgic_v3_domain_init(struct domain *d)return 0 ; } +static void vgic_v3_domain_free (struct domain *d) +{ +xfree (d->arch.vgic.rdist_regions); +} +static const struct vgic_ops v3_ops = { .vcpu_init = vgic_v3_vcpu_init, .domain_init = vgic_v3_domain_init, + .domain_free = vgic_v3_domain_free, .emulate_sysreg = vgic_v3_emulate_sysreg,/* * We use both AFF1 and AFF0 in (v)MPIDR. Thus, the max number of CPU
xen/arch/arm/vgic.c +1 -0
@@ -177,6 +177,7 @@ void domain_vgic_free(struct domain *d) } } + d->arch.vgic.handler->domain_free (d);xfree (d->arch.vgic.shared_irqs);xfree (d->arch.vgic.pending_irqs);xfree (d->arch.vgic.allocated_irqs);
xen/include/asm-arm/domain.h +1 -1
@@ -107,7 +107,7 @@ struct arch_domainpaddr_t base;/* Base address */ paddr_t size;/* Size */ unsigned int first_cpu; /* First CPU handled */ - } rdist_regions[MAX_RDIST_COUNT ]; + } *rdist_regions;int nr_regions;/* Number of rdist regions */ uint32_t rdist_stride;/* Re-Distributor stride */ #endif
xen/include/asm-arm/vgic.h +2 -0
@@ -128,6 +128,8 @@ struct vgic_ops {int (*vcpu_init)(struct vcpu *v);/* Domain specific initialization of vGIC */ int (*domain_init)(struct domain *d); +/* Release resources that were allocated by domain_init */ +void (*domain_free)(struct domain *d);/* vGIC sysreg emulation */ int (*emulate_sysreg)(struct cpu_user_regs *regs,union hsr hsr);/* Maximum number of vCPU supported */
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
PATCH v3 6/10 arm/gic-v3: Remove an unused macro MAX_RDIST_COUNT
In reply to Shanker DonthineniThe macro MAX_RDIST_COUNT is not being used after converting code to handle number of redistributor dynamically. So remove it from header file and the two other panic() messages that are not valid anymore.
--- xen/arch/arm/gic-v3.c | 8 -------- xen/include/asm-arm/gic.h | 1 - 2 files changed, 9 deletions(-)
xen/arch/arm/gic-v3.c +0 -8
@@ -1200,10 +1200,6 @@ static void __init gicv3_dt_init(void) &gicv3.rdist_count) ) gicv3.rdist_count =1 ; -if ( gicv3.rdist_count >MAX_RDIST_COUNT ) -panic ("GICv3: Number of redistributor regions is more than" -"%d (Increase MAX_RDIST_COUNT!!)\n" ,MAX_RDIST_COUNT ); - rdist_regs = xzalloc_array(struct rdist_region, gicv3.rdist_count);if ( !rdist_regs )panic ("GICv3: Failed to allocate memory for rdist regions\n" );
@@ -1492,10 +1488,6 @@ static void __init gicv3_acpi_init(void) gicr_table = false; } -if ( count >MAX_RDIST_COUNT ) -panic ("GICv3: Number of redistributor regions is more than" -"%d (Increase MAX_RDIST_COUNT!!)\n" ,MAX_RDIST_COUNT ); - rdist_regs = xzalloc_array(struct rdist_region, count);if ( !rdist_regs )panic ("GICv3: Failed to allocate memory for rdist regions\n" );
xen/include/asm-arm/gic.h +0 -1
@@ -20,7 +20,6 @@#define NR_GIC_LOCAL_IRQS NR_LOCAL_IRQS#define NR_GIC_SGI 16 -#define MAX_RDIST_COUNT 4#define GICD_CTLR (0x000)#define GICD_TYPER (0x004)
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
PATCH v3 7/10 arm: vgic: Split vgic_domain_init() functionality into two functions
In reply to Shanker DonthineniSeparate the code logic that does the registration of vgic_v3/v2 ops to a new function domain_vgic_register(). The intention of this separation is to record the required mmio count in vgic_v3/v2_init() and pass it to function domain_io_init() in a follow-up patch patch.
---
Changes since v2:
Edited commit text.
xen/arch/arm/vgic.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-)
xen/arch/arm/vgic.c +21 -12
@@ -88,19 +88,8 @@ static void vgic_rank_init(struct vgic_irq_rank *rank, uint8_t index, rank->vcpu[i] = vcpu; } -int domain_vgic_init (struct domain *d,unsigned int nr_spis) +static int domain_vgic_register (struct domain *d) { -int i; -int ret; - - d->arch.vgic.ctlr =0 ; - -/* Limit the number of virtual SPIs supported to (1020 - 32) = 988 */ -if ( nr_spis > (1020 -NR_LOCAL_IRQS ) ) -return -EINVAL ; - - d->arch.vgic.nr_spis = nr_spis; -switch ( d->arch.vgic.version ) {#ifdef CONFIG_HAS_GICV3
@@ -119,6 +108,26 @@ int domain_vgic_init(struct domain *d, unsigned int nr_spis)return -ENODEV ; } +return 0 ; +} + +int domain_vgic_init (struct domain *d,unsigned int nr_spis) +{ +int i; +int ret; + + d->arch.vgic.ctlr =0 ; + +/* Limit the number of virtual SPIs supported to (1020 - 32) = 988 */ +if ( nr_spis > (1020 -NR_LOCAL_IRQS ) ) +return -EINVAL ; + + d->arch.vgic.nr_spis = nr_spis; + + ret =domain_vgic_register (d); +if ( ret <0 ) +return ret; +spin_lock_init (&d->arch.vgic.lock); d->arch.vgic.shared_irqs =
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
PATCH v3 8/10 arm/io: Use separate memory allocation for mmio handlers
In reply to Shanker DonthineniThe number of mmio handlers are limited to a compile time macro MAX_IO_HANDLER which is 16. This number is not at all sufficient to support per CPU distributor regions. Either it needs to be increased to a bigger number, at least CONFIG_NR_CPUS+16, or allocate a separate memory for mmio handlers dynamically during domain build.
This patch uses the dynamic allocation strategy to reduce memory footprint for 'struct domain' instead of static allocation.
---
Changes since v1:
Moved registration of vgic_v3/v2 functionality to a new domain_vgic_register().
xen/arch/arm/domain.c | 6 ++++-- xen/arch/arm/io.c | 14 ++++++++++++-- xen/include/asm-arm/mmio.h | 6 ++++-- 3 files changed, 20 insertions(+), 6 deletions(-)
xen/arch/arm/domain.c +4 -2
@@ -527,7 +527,7 @@ void vcpu_destroy(struct vcpu *v)int arch_domain_create (struct domain *d,unsigned int domcr_flags,struct xen_arch_domainconfig *config) { -int rc; +int rc, count; d->arch.relmem = RELMEM_not_started;
@@ -550,7 +550,8 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,share_xen_page_with_guest (virt_to_page (d->shared_info), d, XENSHARE_writable); -if ( (rc =domain_io_init (d)) !=0 ) + count =MAX_IO_HANDLER ; +if ( (rc =domain_io_init (d, count)) !=0 ) goto fail;if ( (rc =p2m_alloc_table (d)) !=0 )
@@ -644,6 +645,7 @@ void arch_domain_destroy(struct domain *d)free_xenheap_pages (d->arch.efi_acpi_table,get_order_from_bytes (d->arch.efi_acpi_len));#endif +domain_io_free (d); }void arch_domain_shutdown (struct domain *d)
xen/arch/arm/io.c +12 -2
@@ -102,7 +102,7 @@ void register_mmio_handler(struct domain *d,struct vmmio *vmmio = &d->arch.vmmio;struct mmio_handler *handler; -BUG_ON (vmmio->num_entries >=MAX_IO_HANDLER ); +BUG_ON (vmmio->num_entries >= vmmio->max_num_entries);spin_lock (&vmmio->lock);
@@ -125,14 +125,24 @@ void register_mmio_handler(struct domain *d,spin_unlock (&vmmio->lock); } -int domain_io_init (struct domain *d) +int domain_io_init (struct domain *d,int max_count) {spin_lock_init (&d->arch.vmmio.lock); d->arch.vmmio.num_entries =0 ; + d->arch.vmmio.max_num_entries = max_count; + d->arch.vmmio.handlers = xzalloc_array(struct mmio_handler, max_count); +if ( !d->arch.vmmio.handlers ) +return -ENOMEM ; +return 0 ; } +void domain_io_free (struct domain *d) +{ +xfree (d->arch.vmmio.handlers); +} +/* * Local variables: * mode: C
xen/include/asm-arm/mmio.h +4 -2
@@ -51,15 +51,17 @@ struct mmio_handler {struct vmmio {int num_entries; +int max_num_entries;spinlock_t lock; -struct mmio_handler handlers[MAX_IO_HANDLER ]; +struct mmio_handler *handlers; };extern int handle_mmio (mmio_info_t *info);void register_mmio_handler (struct domain *d,const struct mmio_handler_ops *ops,paddr_t addr,paddr_t size,void *priv); -int domain_io_init (struct domain *d); +int domain_io_init (struct domain *d,int max_count); +void domain_io_free (struct domain *d);#endif /* __ASM_ARM_MMIO_H__ */
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
PATCH v3 9/10 xen/arm: io: Use binary search for mmio handler lookup
In reply to Shanker DonthineniAs the number of I/O handlers increase, the overhead associated with linear lookup also increases. The system might have maximum of 144 (assuming CONFIG_NR_CPUS=128) mmio handlers. In worst case scenario, it would require 144 iterations for finding a matching handler. Now it is time for us to change from linear (complexity O(n)) to a binary search (complexity O(log n) for reducing mmio handler lookup overhead.
---
Changes since v2:
Converted mmio lookup code to a critical section. Copied the function bsreach() from Linux kernel.
xen/arch/arm/io.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 84 insertions(+), 13 deletions(-)
xen/arch/arm/io.c +84 -13
@@ -20,9 +20,50 @@#include <xen/lib.h> #include <xen/spinlock.h> #include <xen/sched.h> +#include <xen/sort.h> #include <asm/current.h> #include <asm/mmio.h> +/* +* bsearch - binary search an array of elements +* @key: pointer to item being searched for +* @base: pointer to first element to search +* @num: number of elements +* @size: size of each element +* @cmp: pointer to comparison function +* +* This function does a binary search on the given array. The +* contents of the array should already be in ascending sorted order +* under the provided comparison function. +* +* Note that the key need not have the same type as the elements in +* the array, e.g. key could be a string and the comparison function +* could compare the string with the struct's name field. However, if +* the key and elements in the array are of the same type, you can use +* the same comparison function for both sort() and bsearch(). +*/ +static void *bsearch (const void *key,const void *base,size_t num,size_t size, +int (*cmp)(const void *key,const void *elt)) +{ +size_t start =0 , end = num; +int result; + +while ( start < end ) + { +size_t mid = start + (end - start) /2 ; + + result =cmp (key, base + mid * size); +if ( result <0 ) + end = mid; +else if ( result >0 ) + start = mid +1 ; +else +return (void *)base + mid * size; + } + +return NULL ; +} +static int handle_read (const struct mmio_handler *handler,struct vcpu *v,mmio_info_t *info) {
@@ -70,23 +111,41 @@ static int handle_write(const struct mmio_handler *handler, struct vcpu *v, handler->priv); } -int handle_mmio (mmio_info_t *info) +static int match_mmio_handler (const void *key,const void *elem) { -struct vcpu *v = current; -int i; -const struct mmio_handler *handler =NULL ; -const struct vmmio *vmmio = &v->domain->arch.vmmio; +const struct mmio_handler *handler = elem; +paddr_t addr = (paddr_t )key; -for ( i =0 ; i < vmmio->num_entries; i++ ) - { - handler = &vmmio->handlers[i]; +if ( addr < handler->addr ) +return -1 ; -if ( (info->gpa >= handler->addr) && - (info->gpa < (handler->addr + handler->size)) ) -break ; - } +if ( addr > (handler->addr + handler->size) ) +return 1 ; + +return 0 ; +} -if ( i == vmmio->num_entries ) +static const struct mmio_handler * +find_mmio_handler (struct vcpu *v,paddr_t addr) +{ +struct vmmio *vmmio = &v->domain->arch.vmmio; +const struct mmio_handler *handler; + +spin_lock (&vmmio->lock); + handler =bsearch ((const void *)addr, vmmio->handlers, vmmio->num_entries, +sizeof (*handler), match_mmio_handler); +spin_unlock (&vmmio->lock); + +return handler; +} + +int handle_mmio (mmio_info_t *info) +{ +const struct mmio_handler *handler; +struct vcpu *v = current; + + handler =find_mmio_handler (v, info->gpa); +if ( !handler )return 0 ;if ( info->dabt.write )
@@ -95,6 +154,14 @@ int handle_mmio(mmio_info_t *info)return handle_read (handler, v, info); } +static int cmp_mmio_handler (const void *key,const void *elem) +{ +const struct mmio_handler *handler0 = key; +const struct mmio_handler *handler1 = elem; + +return (handler0->addr < handler1->addr) ?-1 :0 ; +} +void register_mmio_handler (struct domain *d,const struct mmio_handler_ops *ops,paddr_t addr,paddr_t size,void *priv)
@@ -122,6 +189,10 @@ void register_mmio_handler(struct domain *d, vmmio->num_entries++; +/* Sort mmio handlers in ascending order based on base address */ +sort (vmmio->handlers, vmmio->num_entries,sizeof (struct mmio_handler ), + cmp_mmio_handler,NULL ); +spin_unlock (&vmmio->lock); }
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
PATCH v3 10/10 arm/vgic: Change fixed number of mmio handlers to variable number
In reply to Shanker DonthineniRecord the number of mmio handlers that are required for vGICv3/2 in variable 'arch_domain.vgic.mmio_count' in vgic_v3/v2_init(). Augment this variable number to a fixed number MAX_IO_HANDLER and pass it to domain_io_init() to allocate enough memory for handlers.
New code path:
domain_vgic_register()
count = MAX_IO_HANDLER + d->arch.vgic.mmio_count; domain_io_init(count)
domain_vgic_init()
--- xen/arch/arm/domain.c | 11 +++++++---- xen/arch/arm/vgic-v2.c | 1 + xen/arch/arm/vgic-v3.c | 3 +++ xen/arch/arm/vgic.c | 6 +----- xen/include/asm-arm/domain.h | 1 + xen/include/asm-arm/vgic.h | 1 + 6 files changed, 14 insertions(+), 9 deletions(-)
xen/arch/arm/domain.c +7 -4
@@ -550,10 +550,6 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,share_xen_page_with_guest (virt_to_page (d->shared_info), d, XENSHARE_writable); - count =MAX_IO_HANDLER ; -if ( (rc =domain_io_init (d, count)) !=0 ) - goto fail; -if ( (rc =p2m_alloc_table (d)) !=0 ) goto fail;
@@ -590,6 +586,13 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags, goto fail; } +if ( (rc =domain_vgic_register (d)) !=0 ) + goto fail; + + count =MAX_IO_HANDLER + d->arch.vgic.mmio_count; +if ( (rc =domain_io_init (d, count)) !=0 ) + goto fail; +if ( (rc =domain_vgic_init (d, config->nr_spis)) !=0 ) goto fail;
xen/arch/arm/vgic-v2.c +1 -0
@@ -721,6 +721,7 @@ int vgic_v2_init(struct domain *d)return -ENODEV ; } + d->arch.vgic.mmio_count =1 ;/* Only GICD region */ register_vgic_ops (d, &vgic_v2_ops);return 0 ;
xen/arch/arm/vgic-v3.c +3 -0
@@ -1509,6 +1509,9 @@ int vgic_v3_init(struct domain *d)return -ENODEV ; } +/* GICD region + number of Re-distributors */ + d->arch.vgic.mmio_count =vgic_v3_rdist_count (d) +1 ; +register_vgic_ops (d, &v3_ops);return 0 ;
xen/arch/arm/vgic.c +1 -5
@@ -88,7 +88,7 @@ static void vgic_rank_init(struct vgic_irq_rank *rank, uint8_t index, rank->vcpu[i] = vcpu; } -static int domain_vgic_register (struct domain *d) +int domain_vgic_register (struct domain *d) {switch ( d->arch.vgic.version ) {
@@ -124,10 +124,6 @@ int domain_vgic_init(struct domain *d, unsigned int nr_spis) d->arch.vgic.nr_spis = nr_spis; - ret =domain_vgic_register (d); -if ( ret <0 ) -return ret; -spin_lock_init (&d->arch.vgic.lock); d->arch.vgic.shared_irqs =
xen/include/asm-arm/domain.h +1 -0
@@ -111,6 +111,7 @@ struct arch_domainint nr_regions;/* Number of rdist regions */ uint32_t rdist_stride;/* Re-Distributor stride */ #endif +uint32_t mmio_count;/* Number of mmio handlers */ } vgic;struct vuart {
xen/include/asm-arm/vgic.h +1 -0
@@ -307,6 +307,7 @@ 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); +extern int domain_vgic_register (struct domain *d);extern int vcpu_vgic_free (struct vcpu *v); extern int vgic_to_sgi(struct vcpu *v, register_t sgir, enum gic_sgi_mode irqmode, int virq,
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
Re: [PATCH V3 09/10] xen/arm: io: Use binary search for mmio handler lookup
In reply to Shanker DonthineniHi Shanker,
Quoted 6 lines · Shanker Donthineni
As the number of I/O handlers increase, the overhead associated with linear lookup also increases. The system might have maximum of 144 (assuming
CONFIG_NR_CPUS=128) mmio handlers. In worst case scenario, it would require 144 iterations for finding a matching handler. Now it is time for us to change from linear (complexity O(n)) to a binary search (complexity O(log n) for reducing mmio handler lookup overhead.
However, you will add contention because the code is using a spinlock. I am planning to send the following patch as a prerequisite of this series to switch from spinlock to read-write lock:
commit b69e975ce25b2c94f7205b0b8329f351327fbcf7
Author: Julien Grall <[email protected]> Date: Tue Jun 28 11:04:11 2016 +0100
xen/arm: io: Protect the handlers with a read-write lock
Currently, accessing the I/O handlers does not require to take a lock because new handlers are always added at the end of the array. In a follow-up patch, this array will be sort to optimize the look up.
Given that most of the time the I/O handlers will not be modify, using a spinlock will add contention when multiple vCPU are accessing the emulated MMIOs. So use a read-write lock to protected the handlers.
Finally, take the opportunity to re-indent correctly domain_io_init.
xen/arch/arm/io.c +28 -19
@@ -70,23 +70,39 @@ static int handle_write(const struct mmio_handler *handler, struct vcpu *v, handler->priv); } -int handle_mmio (mmio_info_t *info) +static const struct mmio_handler *find_mmio_handler (struct domain *d, +paddr_t gpa) { -struct vcpu *v = current; -int i; -const struct mmio_handler *handler =NULL ; -const struct vmmio *vmmio = &v->domain->arch.vmmio; +const struct mmio_handler *handler; +unsigned int i; +struct vmmio *vmmio = &d->arch.vmmio; + +read_lock (&vmmio->lock);for ( i =0 ; i < vmmio->num_entries; i++ ) { handler = &vmmio->handlers[i]; -if ( (info->gpa >= handler->addr) && - (info->gpa < (handler->addr + handler->size)) ) +if ( (gpa >= handler->addr) && + (gpa < (handler->addr + handler->size)) )break ; }if ( i == vmmio->num_entries ) + handler =NULL ; + +read_unlock (&vmmio->lock); + +return handler; +} + +int handle_mmio (mmio_info_t *info) +{ +struct vcpu *v = current; +const struct mmio_handler *handler =NULL ; + + handler =find_mmio_handler (v->domain, info->gpa); +if ( !handler )return 0 ;if ( info->dabt.write )
@@ -104,7 +120,7 @@ void register_mmio_handler(struct domain *d,BUG_ON (vmmio->num_entries >=MAX_IO_HANDLER ); -spin_lock (&vmmio->lock); +write_lock (&vmmio->lock); handler = &vmmio->handlers[vmmio->num_entries];
@@ -113,24 +129,17 @@ void register_mmio_handler(struct domain *d, handler->size = size; handler->priv = priv; -/* -* handle_mmio is not using the lock to avoid contention. -* Make sure the other processors see the new handler before -* updating the number of entries -*/ -dsb (ish); - vmmio->num_entries++; -spin_unlock (&vmmio->lock); +write_unlock (&vmmio->lock); }int domain_io_init (struct domain *d) { -spin_lock_init (&d->arch.vmmio.lock); - d->arch.vmmio.num_entries =0 ; +rwlock_init (&d->arch.vmmio.lock); + d->arch.vmmio.num_entries =0 ; -return 0 ; +return 0 ; }/*
xen/include/asm-arm/mmio.h +2 -1
@@ -20,6 +20,7 @@#define __ASM_ARM_MMIO_H__#include <xen/lib.h> +#include <xen/rwlock.h> #include <asm/processor.h> #include <asm/regs.h>
@@ -51,7 +52,7 @@ struct mmio_handler {struct vmmio {int num_entries; -spinlock_t lock; +rwlock_t lock;struct mmio_handler handlers[MAX_IO_HANDLER ]; };
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Hi Shanker,
Quoted 4 lines · Shanker Donthineni
The function
acpi_table_parse_madt()does the same functionality as functionacpi_parse_entries()expect it takes a few arguments.Signed-off-by Shanker Donthineni <[email protected]>
Regards,
Quoted 64 lines
--- xen/arch/arm/gic-v3.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-)xen/arch/arm/gic-v3.c +6
-21@@ -1390,28 +1390,15 @@ gic_acpi_get_madt_redistributor_num(struct acpi_subtable_header *header,static void __init gicv3_acpi_init (void ) { -struct acpi_table_header *table;struct rdist_region *rdist_regs; -acpi_status status;int count, i; - status =acpi_get_table (ACPI_SIG_MADT ,0 , &table); - -if (ACPI_FAILURE (status) ) - { -const char *msg =acpi_format_exception (status); - -panic ("GICv3: Failed to get MADT table, %s" , msg); - } -/* * Find distributor base address. We expect one distributor entry since * ACPI 5.0 spec neither support multi-GIC instances nor GIC cascade. */ - count =acpi_parse_entries (ACPI_SIG_MADT ,sizeof (struct acpi_table_madt ), - gic_acpi_parse_madt_distributor, table, -ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR ,0 ); - + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR , + gic_acpi_parse_madt_distributor,0 );if ( count <=0 )panic ("GICv3: No valid GICD entries exists" );@@ -1420,9 +1407,8 @@ static void __init gicv3_acpi_init(void) dbase);/* Get number of redistributor */ - count =acpi_parse_entries (ACPI_SIG_MADT ,sizeof (struct acpi_table_madt ), - gic_acpi_get_madt_redistributor_num, table, -ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR ,0 ); + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR , + gic_acpi_get_madt_redistributor_num,0 );if ( count <=0 )panic ("GICv3: No valid GICR entries exists" );@@ -1458,9 +1444,8 @@ static void __init gicv3_acpi_init(void) gicv3.rdist_regions= rdist_regs;/* Collect CPU base addresses */ - count =acpi_parse_entries (ACPI_SIG_MADT ,sizeof (struct acpi_table_madt ), - gic_acpi_parse_madt_cpu, table, -ACPI_MADT_TYPE_GENERIC_INTERRUPT ,0 ); + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_INTERRUPT , + gic_acpi_parse_madt_cpu,0 );if ( count <=0 )panic ("GICv3: No valid GICC entries exists" );
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH V3 03/10] arm/gic-v3: Move GICR subtable parsing into a new function
In reply to Shanker DonthineniHi Shanker,
Quoted 5 lines · Shanker Donthineni
Add a new function to parse GICR subtable and move the code that is specific to GICR table to a new function without changing the function
gicv3_acpi_init()behavior.Signed-off-by Shanker Donthineni <[email protected]>
Regards,
Quoted 112 lines
---
Changes since v2:
Changed functiongic_acpi_add_rdist_region()protoype.
Removed the address validation check ingic_acpi_parse_madt_redistributor(). Edited commit text.Changes since v1:
Removed the unnecessary GICR ioremap operation inside GICR table parse code.xen/arch/arm/gic-v3.c | 56 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 22 deletions(-)xen/arch/arm/gic-v3.c +34
-22@@ -1282,6 +1282,14 @@ static int gicv3_iomem_deny_access(const struct domain *d) }#ifdef CONFIG_ACPI +static void __init gic_acpi_add_rdist_region (paddr_t base,paddr_t size) +{ +unsigned int idx = gicv3.rdist_count++; + + gicv3.rdist_regions[idx].base = base; + gicv3.rdist_regions[idx].size = size; +} +static int gicv3_make_hwdom_madt (const struct domain *d,u32 offset) {struct acpi_subtable_header *header;@@ -1387,6 +1395,22 @@ gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header,return 0 ; } + +static int __init +gic_acpi_parse_madt_redistributor (struct acpi_subtable_header *header, +const unsigned long end) +{ +struct acpi_madt_generic_redistributor *rdist; + + rdist = (struct acpi_madt_generic_redistributor *)header; +if (BAD_MADT_ENTRY (rdist, end) ) +return -EINVAL ; + +gic_acpi_add_rdist_region (rdist->base_address, rdist->length); + +return 0 ; +} +static int __init gic_acpi_get_madt_redistributor_num (struct acpi_subtable_header *header,const unsigned long end)@@ -1400,7 +1424,7 @@ gic_acpi_get_madt_redistributor_num(struct acpi_subtable_header *header,static void __init gicv3_acpi_init (void ) {struct rdist_region *rdist_regs; -int count, i; +int count;/* * Find distributor base address. We expect one distributor entry since @@ -1419,37 +1443,25 @@ static void __init gicv3_acpi_init(void)if ( count <=0 )panic ("GICv3: No valid GICR entries exists" ); - gicv3.rdist_count = count; - -if ( gicv3.rdist_count >MAX_RDIST_COUNT ) +if ( count >MAX_RDIST_COUNT )panic ("GICv3: Number of redistributor regions is more than" "%d (Increase MAX_RDIST_COUNT!!)\n" ,MAX_RDIST_COUNT ); - rdist_regs = xzalloc_array(struct rdist_region, gicv3.rdist_count); + rdist_regs = xzalloc_array(struct rdist_region, count);if ( !rdist_regs )panic ("GICv3: Failed to allocate memory for rdist regions\n" ); -for ( i =0 ; i < gicv3.rdist_count; i++ ) - { -struct acpi_subtable_header *header; -struct acpi_madt_generic_redistributor *gic_rdist; - - header =acpi_table_get_entry_madt (ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR , - i); -if ( !header ) -panic ("GICv3: Can't get GICR entry" ); - - gic_rdist = - container_of(header, struct acpi_madt_generic_redistributor, header); - rdist_regs[i].base = gic_rdist->base_address; - rdist_regs[i].size = gic_rdist->length; - } + gicv3.rdist_regions = rdist_regs; + +/* Parse always-on power domain Re-distributor entries */ + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR , + gic_acpi_parse_madt_redistributor, count); +if ( count <=0 ) +panic ("GICv3: Can't get Redistributor entry" );/* The vGIC code requires the region to be sorted */ sort (rdist_regs, gicv3.rdist_count,sizeof (*rdist_regs), cmp_rdist,NULL ); - gicv3.rdist_regions= rdist_regs; -/* Collect CPU base addresses */ count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_INTERRUPT , gic_acpi_parse_madt_cpu,0 );
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH V3 04/10] arm/gic-v3: Parse per-cpu redistributor entry in GICC subtable
In reply to Shanker DonthineniHello Shanker,
xen/arch/arm/gic-v3.c gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header, · line 1419
Quoted 13 lines · Shanker Donthineni
xen/arch/arm/gic-v3.c +9
-0@@ -1397,6 +1408,36 @@ gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header, }static int __init +gic_acpi_parse_cpu_redistributor (struct acpi_subtable_header *header, +const unsigned long end) +{ +struct acpi_madt_generic_interrupt *processor; +u32 size; + + processor = (struct acpi_madt_generic_interrupt *)header; +if ( !(processor->flags &ACPI_MADT_ENABLED ) ) +return 0 ;
You did not answer to my question on previous version of this patch. You said that "Disabled GICC entries should be skipped because its Redistributor region is not always-on power domain." However from my understanding, an usable CPU may have his Redistributor in the not always-on power domain. So the issue would the same, correct?
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH V3 05/10] xen/arm: vgic: Use dynamic memory allocation for vgic_rdist_region
In reply to Shanker DonthineniHi Shanker,
Quoted 18 lines · Shanker Donthineni
The number of Redistributor regions allowed for dom0 is hardcoded to a define
MAX_RDIST_COUNTwhich is 4. Some systems, especially latest server chips, may have more than 4 redistributors. Either we have to increaseMAX_RDIST_COUNTto a bigger number or allocate memory based on the number of redistributors that are found in MADT table. In the worst case scenario, the macroMAX_RDIST_COUNTshould be equal toCONFIG_NR_CPUSin order to support per CPU Redistributors.Increasing
MAX_RDIST_COUNThas a effect, it blows 'struct domain' size and hitsBUILD_BUG_ON()in domain build code path.struct domain
*alloc_domain_struct(void){ struct domain *d; BUILD_BUG_ON(sizeof(*d) > PAGE_SIZE); d = alloc_xenheap_pages(0, 0); if ( d == NULL ) return NULL;
Quoted 5 lines
...
This patch uses the second approach to fix the
BUILD_BUG().Signed-off-by Shanker Donthineni <[email protected]>
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH V3 07/10] arm: vgic: Split vgic_domain_init() functionality into two functions
In reply to Shanker DonthineniHi Shanker,
Quoted 6 lines · Shanker Donthineni
Separate the code logic that does the registration of vgic_v3/v2 ops to a new function
domain_vgic_register(). The intention of this separation is to record the required mmio count in vgic_v3/v2_init() and pass it to functiondomain_io_init()in a follow-up patch patch.Signed-off-by Shanker Donthineni <[email protected]>
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH V3 09/10] xen/arm: io: Use binary search for mmio handler lookup
In reply to Shanker DonthineniHi Shanker,
Quoted 38 lines · Shanker Donthineni
As the number of I/O handlers increase, the overhead associated with linear lookup also increases. The system might have maximum of 144 (assuming
CONFIG_NR_CPUS=128) mmio handlers. In worst case scenario, it would require 144 iterations for finding a matching handler. Now it is time for us to change from linear (complexity O(n)) to a binary search (complexity O(log n) for reducing mmio handler lookup overhead.Signed-off-by Shanker Donthineni <[email protected]>---
Changes since v2:
Converted mmio lookup code to a critical section. Copied the functionbsreach()from Linux kernel.xen/arch/arm/io.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 84 insertions(+), 13 deletions(-)xen/arch/arm/io.c +11
-0@@ -20,9 +20,50 @@#include <xen/lib.h> #include <xen/spinlock.h> #include <xen/sched.h> +#include <xen/sort.h> #include <asm/current.h> #include <asm/mmio.h> +/* +* bsearch - binary search an array of elements +* @key: pointer to item being searched for +* @base: pointer to first element to search +* @num: number of elements +* @size: size of each element +* @cmp: pointer to comparison function +* +* This function does a binary search on the given array. The +* contents of the array should already be in ascending sorted order
xen/arch/arm/io.c line 46
Quoted 10 lines
xen/arch/arm/io.c +10
-0+* under the provided comparison function. +* +* Note that the key need not have the same type as the elements in +* the array, e.g. key could be a string and the comparison function +* could compare the string with the struct's name field. However, if +* the key and elements in the array are of the same type, you can use +* the same comparison function for both sort() and bsearch(). +*/ +static void *bsearch (const void *key,const void *base,size_t num,size_t size, +int (*cmp)(const void *key,const void *elt))
This function is not specific to I/O handlers. So this should be moved to common code. Also please mention in the commit message where the code came from.
Quoted 52 lines
xen/arch/arm/io.c +30
-12+{ +size_t start =0 , end = num; +int result; + +while ( start < end ) + { +size_t mid = start + (end - start) /2 ; + + result =cmp (key, base + mid * size); +if ( result <0 ) + end = mid; +else if ( result >0 ) + start = mid +1 ; +else +return (void *)base + mid * size; + } + +return NULL ; +} +static int handle_read (const struct mmio_handler *handler,struct vcpu *v,mmio_info_t *info) {@@ -70,23 +111,41 @@ static int handle_write(const struct mmio_handler *handler, struct vcpu *v, handler->priv); } -int handle_mmio (mmio_info_t *info) +static int match_mmio_handler (const void *key,const void *elem) { -struct vcpu *v = current; -int i; -const struct mmio_handler *handler =NULL ; -const struct vmmio *vmmio = &v->domain->arch.vmmio; +const struct mmio_handler *handler = elem; +paddr_t addr = (paddr_t )key; -for ( i =0 ; i < vmmio->num_entries; i++ ) - { - handler = &vmmio->handlers[i]; +if ( addr < handler->addr ) +return -1 ; -if ( (info->gpa >= handler->addr) && - (info->gpa < (handler->addr + handler->size)) ) -break ; - } +if ( addr > (handler->addr + handler->size) ) +return 1 ; + +return 0 ; +}
xen/arch/arm/io.c static int handle_write(const struct mmio_handler *handler, struct vcpu *v, · line 135
Quoted 10 lines
xen/arch/arm/io.c +8
-1-if ( i == vmmio->num_entries ) +static const struct mmio_handler * +find_mmio_handler (struct vcpu *v,paddr_t addr) +{ +struct vmmio *vmmio = &v->domain->arch.vmmio; +const struct mmio_handler *handler; + +spin_lock (&vmmio->lock); + handler = bsearch((const void *)addr, vmmio->handlers, vmmio->num_entries,
paddr_t is always 64-bit regardless the architecture (ARM64 vs ARM32). So the cast will lead to a compilation error on ARM32.
Please try to at least compile test your patch with ARM64, ARM32 and x86 (when you touch common code).
Anyway, I would try to merge the two compare functions (match_mmio_handler, cmp_mmio_handler) which have very similar behavior.
Quoted 33 lines
xen/arch/arm/io.c +21
-0+ sizeof(*handler), match_mmio_handler); +spin_unlock (&vmmio->lock); + +return handler; +} + +int handle_mmio (mmio_info_t *info) +{ +const struct mmio_handler *handler; +struct vcpu *v = current; + + handler =find_mmio_handler (v, info->gpa); +if ( !handler )return 0 ;if ( info->dabt.write )@@ -95,6 +154,14 @@ int handle_mmio(mmio_info_t *info)return handle_read (handler, v, info); } +static int cmp_mmio_handler (const void *key,const void *elem) +{ +const struct mmio_handler *handler0 = key; +const struct mmio_handler *handler1 = elem; + +return (handler0->addr < handler1->addr) ?-1 :0 ; +} +void register_mmio_handler (struct domain *d,const struct mmio_handler_ops *ops,paddr_t addr,paddr_t size,void *priv)
xen/arch/arm/io.c void register_mmio_handler(struct domain *d, · line 198
Quoted 10 lines
xen/arch/arm/io.c +4
-0@@ -122,6 +189,10 @@ void register_mmio_handler(struct domain *d, vmmio->num_entries++; +/* Sort mmio handlers in ascending order based on base address */ +sort (vmmio->handlers, vmmio->num_entries,sizeof (struct mmio_handler ), + cmp_mmio_handler,NULL ); +spin_unlock (&vmmio->lock); }
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH V3 09/10] xen/arm: io: Use binary search for mmio handler lookup
Hi Julien,
Quoted 52 lines · Julien Grall
Hi Shanker,
Quoted 7 lines · Shanker Donthineni
As the number of I/O handlers increase, the overhead associated with linear lookup also increases. The system might have maximum of 144 (assuming
CONFIG_NR_CPUS=128) mmio handlers. In worst case scenario, it would require 144 iterations for finding a matching handler. Now it is time for us to change from linear (complexity O(n)) to a binary search (complexity O(log n) for reducing mmio handler lookup overhead.Quoted 7 lines
Signed-off-by Shanker Donthineni <[email protected]>---
Changes since v2:
Converted mmio lookup code to a critical section. Copied the functionbsreach()from Linux kernel.xen/arch/arm/io.c | 97+++++++++++++++++++++++++++++++++++++++++++++++--------
Quoted 23 lines
1 file changed, 84 insertions(+), 13 deletions(-)xen/arch/arm/io.c +10
-0@@ -20,9 +20,50 @@#include <xen/lib.h> #include <xen/spinlock.h> #include <xen/sched.h> +#include <xen/sort.h> #include <asm/current.h> #include <asm/mmio.h> +/* +* bsearch - binary search an array of elements +* @key: pointer to item being searched for +* @base: pointer to first element to search +* @num: number of elements +* @size: size of each element +* @cmp: pointer to comparison function +* +* This function does a binary search on the given array. The xen/arch/arm/io.c line 45
Quoted 10 lines
xen/arch/arm/io.c +10
-0+* contents of the array should already be in ascending sorted order +* under the provided comparison function. +* +* Note that the key need not have the same type as the elements in +* the array, e.g. key could be a string and the comparison function +* could compare the string with the struct's name field. However, if +* the key and elements in the array are of the same type, you can use +* the same comparison function for both sort() and bsearch(). +*/ +static void *bsearch(const void *key, const void *base, size_t num,
size_tsize,
Quoted 4 lines
xen/arch/arm/io.c line 46
Quoted 1 line
xen/arch/arm/io.c +1
-0+ int (*cmp)(const void *key, const void *elt))This function is not specific to I/O handlers. So this should be moved to common code. Also please mention in the commit message where the code came from.
Should I move to xen/arch/arm folder?
Quoted 66 lines
Quoted 11 lines
xen/arch/arm/io.c +11
-0+{ +size_t start =0 , end = num; +int result; + +while ( start < end ) + { +size_t mid = start + (end - start) /2 ; + + result =cmp (key, base + mid * size); +if ( result <0 ) + end = mid;xen/arch/arm/io.c
Quoted 10 lines
xen/arch/arm/io.c +9
-0+else if ( result >0 ) + start = mid +1 ; +else +return (void *)base + mid * size; + } + +return NULL ; +} + static int handle_read(const struct mmio_handler *handler, struct vcpu*v,
xen/arch/arm/io.c static int handle_write(const struct mmio_handler
Quoted 3 lines
xen/arch/arm/io.c +0
-0mmio_info_t *info) {@@ -70,23 +111,41 @@ static int handle_write(const struct mmio_handler*handler, struct vcpu *v,
Quoted 28 lines
xen/arch/arm/io.c +10
-12handler->priv); } -int handle_mmio (mmio_info_t *info) +static int match_mmio_handler (const void *key,const void *elem) { -struct vcpu *v = current; -int i; -const struct mmio_handler *handler =NULL ; -const struct vmmio *vmmio = &v->domain->arch.vmmio; +const struct mmio_handler *handler = elem; +paddr_t addr = (paddr_t )key; -for ( i =0 ; i < vmmio->num_entries; i++ ) - { - handler = &vmmio->handlers[i]; +if ( addr < handler->addr ) +return -1 ; -if ( (info->gpa >= handler->addr) && - (info->gpa < (handler->addr + handler->size)) ) -break ; - } +if ( addr > (handler->addr + handler->size) ) +return 1 ; + +return 0 ; +}xen/arch/arm/io.c static int handle_write(const struct mmio_handler *handler, struct vcpu *v,
Quoted 10 lines
xen/arch/arm/io.c +8
-1-if ( i == vmmio->num_entries ) +static const struct mmio_handler * +find_mmio_handler (struct vcpu *v,paddr_t addr) +{ +struct vmmio *vmmio = &v->domain->arch.vmmio; +const struct mmio_handler *handler; + +spin_lock (&vmmio->lock); + handler = bsearch((const void *)addr, vmmio->handlers,
vmmio->num_entries,
Quoted 2 lines
paddr_tis always 64-bit regardless the architecture (ARM64 vs ARM32). So the cast will lead to a compilation error on ARM32.
I'll fix.
Quoted 2 lines
Please try to at least compile test your patch with ARM64, ARM32 and x86 (when you touch common code).
Thanks, I'll follow next time.
Quoted 2 lines
Anyway, I would try to merge the two compare functions (
match_mmio_handler,cmp_mmio_handler) which have very similar behavior.
Yes, they are not exactly same. One compares only start address and other one compares the range.
Quoted 47 lines
Quoted 32 lines
xen/arch/arm/io.c +21
-0+ sizeof(*handler), match_mmio_handler); +spin_unlock (&vmmio->lock); + +return handler; +} + +int handle_mmio (mmio_info_t *info) +{ +const struct mmio_handler *handler; +struct vcpu *v = current; + + handler =find_mmio_handler (v, info->gpa); +if ( !handler )return 0 ;if ( info->dabt.write )@@ -95,6 +154,14 @@ int handle_mmio(mmio_info_t *info)return handle_read (handler, v, info); } +static int cmp_mmio_handler (const void *key,const void *elem) +{ +const struct mmio_handler *handler0 = key; +const struct mmio_handler *handler1 = elem; + +return (handler0->addr < handler1->addr) ?-1 :0 ; +} +void register_mmio_handler (struct domain *d,const struct mmio_handler_ops *ops,paddr_t addr,paddr_t size,void *priv)xen/arch/arm/io.c void register_mmio_handler(struct domain *d, · line 193
Quoted 5 lines
xen/arch/arm/io.c +2
-0@@ -122,6 +189,10 @@ void register_mmio_handler(struct domain *d, vmmio->num_entries++; +/* Sort mmio handlers in ascending order based on base address */ + sort(vmmio->handlers, vmmio->num_entries, sizeof(struct
mmio_handler),xen/arch/arm/io.c void register_mmio_handler(struct domain *d, · line 198
Quoted 6 lines
xen/arch/arm/io.c +2
-0+ cmp_mmio_handler, NULL); +spin_unlock (&vmmio->lock); }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
Re: [PATCH V3 09/10] xen/arm: io: Use binary search for mmio handler lookup
Quoted 51 lines · Shanker Donthineni
Quoted 50 lines · Julien Grall
Quoted 7 lines · Shanker Donthineni
As the number of I/O handlers increase, the overhead associated with linear lookup also increases. The system might have maximum of 144 (assuming
CONFIG_NR_CPUS=128) mmio handlers. In worst case scenario, it would require 144 iterations for finding a matching handler. Now it is time for us to change from linear (complexity O(n)) to a binary search (complexity O(log n) for reducing mmio handler lookup overhead.Quoted 7 lines
Signed-off-by Shanker Donthineni <[email protected]>---
Changes since v2:
Converted mmio lookup code to a critical section. Copied the functionbsreach()from Linux kernel.xen/arch/arm/io.c | 97+++++++++++++++++++++++++++++++++++++++++++++++--------
Quoted 23 lines
1 file changed, 84 insertions(+), 13 deletions(-)xen/arch/arm/io.c +10
-0@@ -20,9 +20,50 @@#include <xen/lib.h> #include <xen/spinlock.h> #include <xen/sched.h> +#include <xen/sort.h> #include <asm/current.h> #include <asm/mmio.h> +/* +* bsearch - binary search an array of elements +* @key: pointer to item being searched for +* @base: pointer to first element to search +* @num: number of elements +* @size: size of each element +* @cmp: pointer to comparison function +* +* This function does a binary search on the given array. The xen/arch/arm/io.c line 45
Quoted 10 lines
xen/arch/arm/io.c +10
-0+* contents of the array should already be in ascending sorted order +* under the provided comparison function. +* +* Note that the key need not have the same type as the elements in +* the array, e.g. key could be a string and the comparison function +* could compare the string with the struct's name field. However, if +* the key and elements in the array are of the same type, you can use +* the same comparison function for both sort() and bsearch(). +*/ +static void *bsearch(const void *key, const void *base, size_t num,
size_tsize,
Quoted 8 lines
Quoted 6 lines
xen/arch/arm/io.c line 46
Quoted 1 line
xen/arch/arm/io.c +1
-0+ int (*cmp)(const void *key, const void *elt))This function is not specific to I/O handlers. So this should be moved to common code. Also please mention in the commit message where the code came from.
Should I move to xen/arch/arm folder?
To xen/common/
[...]
Quoted 6 lines
Quoted 3 lines
Anyway, I would try to merge the two compare functions (
match_mmio_handler,cmp_mmio_handler) which have very similar behavior.Yes, they are not exactly same. One compares only start address and other one compares the range.
I don't think this will be an issue to compare the range for both and it will avoid to duplicate the code.
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH V3 04/10] arm/gic-v3: Parse per-cpu redistributor entry in GICC subtable
In reply to Julien GrallHi Julien,
Quoted 7 lines · Julien Grall
Hello Shanker,
Review gic_acpi_parse_madt_distributor(struct
Quoted 1 line · Shanker Donthineni
(quoted diff) +0
-0@@ -1397,6 +1408,36 @@ gic_acpi_parse_madt_distributor(struct
acpi_subtable_header*header,Quoted 2 lines
(quoted diff) +0
-0}
Quoted 13 lines
xen/arch/arm/gic-v3.c gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header, · line 1419
Quoted 10 lines
xen/arch/arm/gic-v3.c +9
-0static int __init +gic_acpi_parse_cpu_redistributor (struct acpi_subtable_header *header, +const unsigned long end) +{ +struct acpi_madt_generic_interrupt *processor; +u32 size; + + processor = (struct acpi_madt_generic_interrupt *)header; +if ( !(processor->flags &ACPI_MADT_ENABLED ) ) +return 0 ;You did not answer to my question on previous version of this patch. You said that "Disabled GICC entries should be skipped because its Redistributor region is not always-on power domain." However from my understanding, an usable CPU may have his Redistributor in the not always-on power domain. So the issue would the same, correct?
The gicv3_populate_rdist() is not supposed to read GICR registers if the the associated hardware GICR block is in power-off state. The CPU accesses to disabled GICR region leads to either a system hang or an unexpected behavior.
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
Re: [PATCH V3 04/10] arm/gic-v3: Parse per-cpu redistributor entry in GICC subtable
Quoted 25 lines · Shanker Donthineni
Hi Julien,
Quoted 7 lines · Julien Grall
Hello Shanker,
Review gic_acpi_parse_madt_distributor(struct
Quoted 1 line · Shanker Donthineni
(quoted diff) +0
-0@@ -1397,6 +1408,36 @@ gic_acpi_parse_madt_distributor(struct
acpi_subtable_header*header,Quoted 2 lines
(quoted diff) +0
-0}Quoted 13 lines
xen/arch/arm/gic-v3.c gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header, · line 1419
Quoted 10 lines
xen/arch/arm/gic-v3.c +9
-0static int __init +gic_acpi_parse_cpu_redistributor (struct acpi_subtable_header *header, +const unsigned long end) +{ +struct acpi_madt_generic_interrupt *processor; +u32 size; + + processor = (struct acpi_madt_generic_interrupt *)header; +if ( !(processor->flags &ACPI_MADT_ENABLED ) ) +return 0 ;You did not answer to my question on previous version of this patch. You said that "Disabled GICC entries should be skipped because its Redistributor region is not always-on power domain." However from my understanding, an usable CPU may have his Redistributor in the not always-on power domain. So the issue would the same, correct?
Quoted 3 lines
The
gicv3_populate_rdist()is not supposed to read GICR registers if the the associated hardware GICR block is in power-off state. The CPU accesses to disabled GICR region leads to either a system hang or an unexpected behavior.
The description of flag ACPI_MADT_ENABLED in ACPI-6.1 says "If zero, this processor in unusable, and the operating system support will not attempt to use it".
Quoted 3 lines
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
Re: [PATCH V3 04/10] arm/gic-v3: Parse per-cpu redistributor entry in GICC subtable
Hi Shanker,
Quoted 38 lines · Shanker Donthineni
Quoted 29 lines · Shanker Donthineni
Hi Julien,
Quoted 7 lines · Julien Grall
Hello Shanker,
Review gic_acpi_parse_madt_distributor(struct
Quoted 1 line · Shanker Donthineni
(quoted diff) +0
-0@@ -1397,6 +1408,36 @@ gic_acpi_parse_madt_distributor(struct
acpi_subtable_header*header,Quoted 2 lines
(quoted diff) +0
-0}Quoted 17 lines
xen/arch/arm/gic-v3.c gic_acpi_parse_madt_distributor(struct acpi_subtable_header *header, · line 1419
Quoted 10 lines
xen/arch/arm/gic-v3.c +9
-0static int __init +gic_acpi_parse_cpu_redistributor (struct acpi_subtable_header *header, +const unsigned long end) +{ +struct acpi_madt_generic_interrupt *processor; +u32 size; + + processor = (struct acpi_madt_generic_interrupt *)header; +if ( !(processor->flags &ACPI_MADT_ENABLED ) ) +return 0 ;You did not answer to my question on previous version of this patch. You said that "Disabled GICC entries should be skipped because its Redistributor region is not always-on power domain." However from my understanding, an usable CPU may have his Redistributor in the not always-on power domain. So the issue would the same, correct?
Quoted 6 lines
The
gicv3_populate_rdist()is not supposed to read GICR registers if the the associated hardware GICR block is in power-off state. The CPU accesses to disabled GICR region leads to either a system hang or an unexpected behavior.
Quoted 3 lines
The description of flag
ACPI_MADT_ENABLEDin ACPI-6.1 says "If zero, this processor in unusable, and the operating system support will not attempt to use it".
Ok. The patch looks good to me then.
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH V3 04/10] arm/gic-v3: Parse per-cpu redistributor entry in GICC subtable
In reply to Shanker DonthineniHi Shanker,
Quoted 6 lines · Shanker Donthineni
The redistributor address can be specified either as part of GICC or GICR subtable depending on the power domain. The current driver doesn't support parsing redistributor entry that is defined in GICC subtable. The GIC CPU subtable entry holds the associated Redistributor base address if it is not on always-on power domain.
Quoted 8 lines
The per CPU Redistributor size is not defined in ACPI specification. Set the GICR region size to
SZ_256Kif the GIC hardware is capable of Direct Virtual LPI Injection feature,SZ_128Kotherwise.This patch adds necessary code to handle both types of Redistributors base addresses.
Signed-off-by Shanker Donthineni <[email protected]>
Based on the discussion, this patch looks good to me:
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 4 lines · Shanker Donthineni
The function
acpi_table_parse_madt()does the same functionality as functionacpi_parse_entries()expect it takes a few arguments.Signed-off-by Shanker Donthineni <[email protected]>
I committed patches 1 to 7
Quoted 67 lines
xen/arch/arm/gic-v3.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-)xen/arch/arm/gic-v3.c +6
-21@@ -1390,28 +1390,15 @@ gic_acpi_get_madt_redistributor_num(struct acpi_subtable_header *header,static void __init gicv3_acpi_init (void ) { -struct acpi_table_header *table;struct rdist_region *rdist_regs; -acpi_status status;int count, i; - status =acpi_get_table (ACPI_SIG_MADT ,0 , &table); - -if (ACPI_FAILURE (status) ) - { -const char *msg =acpi_format_exception (status); - -panic ("GICv3: Failed to get MADT table, %s" , msg); - } -/* * Find distributor base address. We expect one distributor entry since * ACPI 5.0 spec neither support multi-GIC instances nor GIC cascade. */ - count =acpi_parse_entries (ACPI_SIG_MADT ,sizeof (struct acpi_table_madt ), - gic_acpi_parse_madt_distributor, table, -ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR ,0 ); - + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR , + gic_acpi_parse_madt_distributor,0 );if ( count <=0 )panic ("GICv3: No valid GICD entries exists" );@@ -1420,9 +1407,8 @@ static void __init gicv3_acpi_init(void) dbase);/* Get number of redistributor */ - count =acpi_parse_entries (ACPI_SIG_MADT ,sizeof (struct acpi_table_madt ), - gic_acpi_get_madt_redistributor_num, table, -ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR ,0 ); + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR , + gic_acpi_get_madt_redistributor_num,0 );if ( count <=0 )panic ("GICv3: No valid GICR entries exists" );@@ -1458,9 +1444,8 @@ static void __init gicv3_acpi_init(void) gicv3.rdist_regions= rdist_regs;/* Collect CPU base addresses */ - count =acpi_parse_entries (ACPI_SIG_MADT ,sizeof (struct acpi_table_madt ), - gic_acpi_parse_madt_cpu, table, -ACPI_MADT_TYPE_GENERIC_INTERRUPT ,0 ); + count =acpi_table_parse_madt (ACPI_MADT_TYPE_GENERIC_INTERRUPT , + gic_acpi_parse_madt_cpu,0 );if ( count <=0 )panic ("GICv3: No valid GICC entries exists" );Signature · 3 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]
https://lists.xen.org/xen-devel
Hi Stefano/Juilen
Quoted 7 lines · Stefano Stabellini
Quoted 4 lines · Shanker Donthineni
The function
acpi_table_parse_madt()does the same functionality as functionacpi_parse_entries()expect it takes a few arguments.Signed-off-by Shanker Donthineni <[email protected]>I committed patches 1 to 7
Thanks, I'll post the remaining patches for code review.
Signature · 9 lines
Shanker Donthineni Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project. _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel