Skip to contentSkip to conversation

ACPI: eliminate duplicate MADT parsing and unused SBF definitions

PATCH In review Jan Beulich 1 participant 1 message Dec 12, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 ACPI: eliminate duplicate MADT parsing and unused SBF definitions

Use their proper counterparts in include/acpi/actbl*.h instead.

xen/arch/ia64/xen/dom_fw_common.c +7 -7
@@ -347,7 +347,7 @@ struct fake_acpi_tables {
 	struct acpi_table_header dsdt;
 	uint8_t aml[8 + 11 * MAX_VIRT_CPUS];
 	struct acpi_table_madt madt;
-	struct acpi_table_lsapic lsapic[MAX_VIRT_CPUS];
+	struct acpi_madt_local_sapic lsapic[MAX_VIRT_CPUS];
 	uint8_t pm1a_event_block[4];
 	uint8_t pm1a_control_block[1];
 	uint8_t pm_timer_block[4];
@@ -365,7 +365,7 @@ dom_fw_fake_acpi(domain_t *d, struct fak
 	struct acpi_table_facs *facs = &tables->facs;
 	struct acpi_table_header *dsdt = &tables->dsdt;
 	struct acpi_table_madt *madt = &tables->madt;
-	struct acpi_table_lsapic *lsapic = tables->lsapic;
+	struct acpi_madt_local_sapic *lsapic = tables->lsapic;
 	int i;
 	int aml_len;
 	int nbr_cpus;
@@ -492,18 +492,18 @@ dom_fw_fake_acpi(domain_t *d, struct fak
 	/* An LSAPIC entry describes a CPU.  */
 	nbr_cpus = 0;
 	for (i = 0; i < MAX_VIRT_CPUS; i++) {
-		lsapic[i].header.type = ACPI_MADT_LSAPIC;
-		lsapic[i].header.length = sizeof(struct acpi_table_lsapic);
-		lsapic[i].acpi_id = i;
+		lsapic[i].header.type = ACPI_MADT_TYPE_LOCAL_SAPIC;
+		lsapic[i].header.length = sizeof(lsapic[i]);
+		lsapic[i].processor_id = i;
 		lsapic[i].id = i;
 		lsapic[i].eid = 0;
 		if (xen_ia64_is_vcpu_allocated(d, i)) {
-			lsapic[i].flags.enabled = 1;
+			lsapic[i].lapic_flags = ACPI_MADT_ENABLED;
 			nbr_cpus++;
 		}
 	}
 	madt->header.length = sizeof(struct acpi_table_madt) +
-	                      nbr_cpus * sizeof(struct acpi_table_lsapic);
+	                      nbr_cpus * sizeof(*lsapic);
 	madt->header.checksum = -acpi_tb_checksum((u8*)madt,
 						  madt->header.length);
 	return;
xen/arch/ia64/xen/dom_fw_dom0.c +13 -11
@@ -53,11 +53,11 @@ static u32 lsapic_nbr;
 static int __init
 acpi_update_lsapic(struct acpi_subtable_header * header, const unsigned long end)
 {
-	struct acpi_table_lsapic *lsapic;
+	struct acpi_madt_local_sapic *lsapic =
+		container_of(header, struct acpi_madt_local_sapic, header);
 	int enable;
 
-	lsapic = (struct acpi_table_lsapic *)header;
-	if (!lsapic)
+	if (!header)
 		return -EINVAL;
 
 	if (lsapic_nbr < dom0->max_vcpus && dom0->vcpu[lsapic_nbr] != NULL)
@@ -65,14 +65,14 @@ acpi_update_lsapic(struct acpi_subtable_
 	else
 		enable = 0;
 
-	if (lsapic->flags.enabled && enable) {
+	if ((lsapic->lapic_flags & ACPI_MADT_ENABLED) && enable) {
 		printk("enable lsapic entry: 0x%lx\n", (u64) lsapic);
 		lsapic->id = lsapic_nbr;
 		lsapic->eid = 0;
 		lsapic_nbr++;
-	} else if (lsapic->flags.enabled) {
+	} else if (lsapic->lapic_flags & ACPI_MADT_ENABLED) {
 		printk("DISABLE lsapic entry: 0x%lx\n", (u64) lsapic);
-		lsapic->flags.enabled = 0;
+		lsapic->lapic_flags &= ~ACPI_MADT_ENABLED;
 		lsapic->id = 0;
 		lsapic->eid = 0;
 	}
@@ -83,10 +83,11 @@ static int __init
 acpi_patch_plat_int_src(struct acpi_subtable_header * header,
 			const unsigned long end)
 {
-	struct acpi_table_plat_int_src *plintsrc;
+	struct acpi_madt_interrupt_source *plintsrc =
+		container_of(header, struct acpi_madt_interrupt_source,
+			     header);
 
-	plintsrc = (struct acpi_table_plat_int_src *)header;
-	if (!plintsrc)
+	if (!header)
 		return -EINVAL;
 
 	if (plintsrc->type == ACPI_INTERRUPT_CPEI) {
@@ -193,12 +194,13 @@ static void __init touch_acpi_table(void
 	 */
 	acpi_table_parse(ACPI_SIG_MADT, acpi_backup_table);
 
-	if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_update_lsapic, 0) < 0)
+	if (acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
+				  acpi_update_lsapic, 0) < 0)
 		printk("Error parsing MADT - no LAPIC entries\n");
 
 	acpi_update_madt_checksum(madt);
 
-	if (acpi_table_parse_madt(ACPI_MADT_PLAT_INT_SRC,
+	if (acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_SOURCE,
 				  acpi_patch_plat_int_src, 0) < 0)
 		printk("Error parsing MADT - no PLAT_INT_SRC entries\n");
 
xen/arch/x86/acpi/boot.c +38 -39

165 lines not on this page · raw message

xen/arch/x86/srat.c +2 -1
@@ -396,7 +396,8 @@ void __init srat_parse_regions(u64 addr)
 		return;
 
 	srat_region_mask = fill_mask(addr - 1);
-	acpi_table_parse_srat(ACPI_SRAT_MEMORY_AFFINITY, srat_parse_region, 0);
+	acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY,
+			      srat_parse_region, 0);
 
 	for (mask = srat_region_mask, i = 0; mask && i < e820.nr_map; i++) {
 		if (e820.map[i].type != E820_RAM)
xen/drivers/acpi/numa.c +11 -10
@@ -46,7 +46,7 @@ void __init acpi_table_print_srat_entry(
 
 	switch (header->type) {
 
-	case ACPI_SRAT_PROCESSOR_AFFINITY:
+	case ACPI_SRAT_TYPE_CPU_AFFINITY:
 #ifdef ACPI_DEBUG_OUTPUT
 		{
 			struct acpi_srat_cpu_affinity *p =
@@ -68,7 +68,7 @@ void __init acpi_table_print_srat_entry(
 #endif				/* ACPI_DEBUG_OUTPUT */
 		break;
 
-	case ACPI_SRAT_MEMORY_AFFINITY:
+	case ACPI_SRAT_TYPE_MEMORY_AFFINITY:
 #ifdef ACPI_DEBUG_OUTPUT
 		{
 			struct acpi_srat_mem_affinity *p =
@@ -194,8 +194,8 @@ int __init acpi_parse_srat(struct acpi_t
 }
 
 int __init
-acpi_table_parse_srat(enum acpi_srat_entry_id id,
-		      acpi_madt_entry_handler handler, unsigned int max_entries)
+acpi_table_parse_srat(int id, acpi_madt_entry_handler handler,
+		      unsigned int max_entries)
 {
 	return acpi_table_parse_entries(ACPI_SIG_SRAT,
 					sizeof(struct acpi_table_srat), id,
@@ -206,12 +206,13 @@ int __init acpi_numa_init(void)
 {
 	/* SRAT: Static Resource Affinity Table */
 	if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) {
-		acpi_table_parse_srat(ACPI_SRAT_X2APIC_AFFINITY,
-				           acpi_parse_x2apic_affinity, NR_CPUS);
-		acpi_table_parse_srat(ACPI_SRAT_PROCESSOR_AFFINITY,
-					       acpi_parse_processor_affinity,
-					       NR_CPUS);
-		acpi_table_parse_srat(ACPI_SRAT_MEMORY_AFFINITY, acpi_parse_memory_affinity, NR_NODE_MEMBLKS);	// IA64 specific
+		acpi_table_parse_srat(ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY,
+				      acpi_parse_x2apic_affinity, NR_CPUS);
+		acpi_table_parse_srat(ACPI_SRAT_TYPE_CPU_AFFINITY,
+				      acpi_parse_processor_affinity, NR_CPUS);
+		acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY,
+				      acpi_parse_memory_affinity,
+				      NR_NODE_MEMBLKS);
 	}
 
 	/* SLIT: System Locality Information Table */
xen/include/xen/acpi.h +7 -153

180 lines not on this page · raw message

ACPI: eliminate duplicate MADT parsing and unused SBF definitions

Use their proper counterparts in include/acpi/actbl*.h instead.

xen/arch/ia64/xen/dom_fw_common.c +7 -7
@@ -347,7 +347,7 @@ struct fake_acpi_tables {
 	struct acpi_table_header dsdt;
 	uint8_t aml[8 + 11 * MAX_VIRT_CPUS];
 	struct acpi_table_madt madt;
-	struct acpi_table_lsapic lsapic[MAX_VIRT_CPUS];
+	struct acpi_madt_local_sapic lsapic[MAX_VIRT_CPUS];
 	uint8_t pm1a_event_block[4];
 	uint8_t pm1a_control_block[1];
 	uint8_t pm_timer_block[4];
@@ -365,7 +365,7 @@ dom_fw_fake_acpi(domain_t *d, struct fak
 	struct acpi_table_facs *facs = &tables->facs;
 	struct acpi_table_header *dsdt = &tables->dsdt;
 	struct acpi_table_madt *madt = &tables->madt;
-	struct acpi_table_lsapic *lsapic = tables->lsapic;
+	struct acpi_madt_local_sapic *lsapic = tables->lsapic;
 	int i;
 	int aml_len;
 	int nbr_cpus;
@@ -492,18 +492,18 @@ dom_fw_fake_acpi(domain_t *d, struct fak
 	/* An LSAPIC entry describes a CPU.  */
 	nbr_cpus = 0;
 	for (i = 0; i < MAX_VIRT_CPUS; i++) {
-		lsapic[i].header.type = ACPI_MADT_LSAPIC;
-		lsapic[i].header.length = sizeof(struct acpi_table_lsapic);
-		lsapic[i].acpi_id = i;
+		lsapic[i].header.type = ACPI_MADT_TYPE_LOCAL_SAPIC;
+		lsapic[i].header.length = sizeof(lsapic[i]);
+		lsapic[i].processor_id = i;
 		lsapic[i].id = i;
 		lsapic[i].eid = 0;
 		if (xen_ia64_is_vcpu_allocated(d, i)) {
-			lsapic[i].flags.enabled = 1;
+			lsapic[i].lapic_flags = ACPI_MADT_ENABLED;
 			nbr_cpus++;
 		}
 	}
 	madt->header.length = sizeof(struct acpi_table_madt) +
-	                      nbr_cpus * sizeof(struct acpi_table_lsapic);
+	                      nbr_cpus * sizeof(*lsapic);
 	madt->header.checksum = -acpi_tb_checksum((u8*)madt,
 						  madt->header.length);
 	return;
xen/arch/ia64/xen/dom_fw_dom0.c +13 -11
@@ -53,11 +53,11 @@ static u32 lsapic_nbr;
 static int __init
 acpi_update_lsapic(struct acpi_subtable_header * header, const unsigned long end)
 {
-	struct acpi_table_lsapic *lsapic;
+	struct acpi_madt_local_sapic *lsapic =
+		container_of(header, struct acpi_madt_local_sapic, header);
 	int enable;
 
-	lsapic = (struct acpi_table_lsapic *)header;
-	if (!lsapic)
+	if (!header)
 		return -EINVAL;
 
 	if (lsapic_nbr < dom0->max_vcpus && dom0->vcpu[lsapic_nbr] != NULL)
@@ -65,14 +65,14 @@ acpi_update_lsapic(struct acpi_subtable_
 	else
 		enable = 0;
 
-	if (lsapic->flags.enabled && enable) {
+	if ((lsapic->lapic_flags & ACPI_MADT_ENABLED) && enable) {
 		printk("enable lsapic entry: 0x%lx\n", (u64) lsapic);
 		lsapic->id = lsapic_nbr;
 		lsapic->eid = 0;
 		lsapic_nbr++;
-	} else if (lsapic->flags.enabled) {
+	} else if (lsapic->lapic_flags & ACPI_MADT_ENABLED) {
 		printk("DISABLE lsapic entry: 0x%lx\n", (u64) lsapic);
-		lsapic->flags.enabled = 0;
+		lsapic->lapic_flags &= ~ACPI_MADT_ENABLED;
 		lsapic->id = 0;
 		lsapic->eid = 0;
 	}
@@ -83,10 +83,11 @@ static int __init
 acpi_patch_plat_int_src(struct acpi_subtable_header * header,
 			const unsigned long end)
 {
-	struct acpi_table_plat_int_src *plintsrc;
+	struct acpi_madt_interrupt_source *plintsrc =
+		container_of(header, struct acpi_madt_interrupt_source,
+			     header);
 
-	plintsrc = (struct acpi_table_plat_int_src *)header;
-	if (!plintsrc)
+	if (!header)
 		return -EINVAL;
 
 	if (plintsrc->type == ACPI_INTERRUPT_CPEI) {
@@ -193,12 +194,13 @@ static void __init touch_acpi_table(void
 	 */
 	acpi_table_parse(ACPI_SIG_MADT, acpi_backup_table);
 
-	if (acpi_table_parse_madt(ACPI_MADT_LSAPIC, acpi_update_lsapic, 0) < 0)
+	if (acpi_table_parse_madt(ACPI_MADT_TYPE_LOCAL_SAPIC,
+				  acpi_update_lsapic, 0) < 0)
 		printk("Error parsing MADT - no LAPIC entries\n");
 
 	acpi_update_madt_checksum(madt);
 
-	if (acpi_table_parse_madt(ACPI_MADT_PLAT_INT_SRC,
+	if (acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_SOURCE,
 				  acpi_patch_plat_int_src, 0) < 0)
 		printk("Error parsing MADT - no PLAT_INT_SRC entries\n");
 
xen/arch/x86/acpi/boot.c +38 -39

165 lines not on this page · raw message

xen/arch/x86/srat.c +2 -1
@@ -396,7 +396,8 @@ void __init srat_parse_regions(u64 addr)
 		return;
 
 	srat_region_mask = fill_mask(addr - 1);
-	acpi_table_parse_srat(ACPI_SRAT_MEMORY_AFFINITY, srat_parse_region, 0);
+	acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY,
+			      srat_parse_region, 0);
 
 	for (mask = srat_region_mask, i = 0; mask && i < e820.nr_map; i++) {
 		if (e820.map[i].type != E820_RAM)
xen/drivers/acpi/numa.c +11 -10
@@ -46,7 +46,7 @@ void __init acpi_table_print_srat_entry(
 
 	switch (header->type) {
 
-	case ACPI_SRAT_PROCESSOR_AFFINITY:
+	case ACPI_SRAT_TYPE_CPU_AFFINITY:
 #ifdef ACPI_DEBUG_OUTPUT
 		{
 			struct acpi_srat_cpu_affinity *p =
@@ -68,7 +68,7 @@ void __init acpi_table_print_srat_entry(
 #endif				/* ACPI_DEBUG_OUTPUT */
 		break;
 
-	case ACPI_SRAT_MEMORY_AFFINITY:
+	case ACPI_SRAT_TYPE_MEMORY_AFFINITY:
 #ifdef ACPI_DEBUG_OUTPUT
 		{
 			struct acpi_srat_mem_affinity *p =
@@ -194,8 +194,8 @@ int __init acpi_parse_srat(struct acpi_t
 }
 
 int __init
-acpi_table_parse_srat(enum acpi_srat_entry_id id,
-		      acpi_madt_entry_handler handler, unsigned int max_entries)
+acpi_table_parse_srat(int id, acpi_madt_entry_handler handler,
+		      unsigned int max_entries)
 {
 	return acpi_table_parse_entries(ACPI_SIG_SRAT,
 					sizeof(struct acpi_table_srat), id,
@@ -206,12 +206,13 @@ int __init acpi_numa_init(void)
 {
 	/* SRAT: Static Resource Affinity Table */
 	if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) {
-		acpi_table_parse_srat(ACPI_SRAT_X2APIC_AFFINITY,
-				           acpi_parse_x2apic_affinity, NR_CPUS);
-		acpi_table_parse_srat(ACPI_SRAT_PROCESSOR_AFFINITY,
-					       acpi_parse_processor_affinity,
-					       NR_CPUS);
-		acpi_table_parse_srat(ACPI_SRAT_MEMORY_AFFINITY, acpi_parse_memory_affinity, NR_NODE_MEMBLKS);	// IA64 specific
+		acpi_table_parse_srat(ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY,
+				      acpi_parse_x2apic_affinity, NR_CPUS);
+		acpi_table_parse_srat(ACPI_SRAT_TYPE_CPU_AFFINITY,
+				      acpi_parse_processor_affinity, NR_CPUS);
+		acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY,
+				      acpi_parse_memory_affinity,
+				      NR_NODE_MEMBLKS);
 	}
 
 	/* SLIT: System Locality Information Table */
xen/include/xen/acpi.h +7 -153

180 lines not on this page · raw message

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