aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2009-02-17 09:29:30 -0500
committerIngo Molnar <mingo@elte.hu>2009-02-17 11:52:50 -0500
commit7da18ed924b182f8174de243c55a323c56398675 (patch)
treeab036a38e73298aa4db41d38cc38d251204adcff
parent352887d1c9d99d4c2f0fbac6176ef0cd4fe7a820 (diff)
x86, es7000: misc cleanups
These are cleanups that change the md5 signature: - asm/ => linux/ include conversion - simplify the code flow of find_unisys_acpi_oem_table() - move ACPI methods into one #ifdef block - remove 0/NULL initialization of statics - simplify/standardize printouts - update copyrights - more cleanups, pointed out by checkpatch arch/x86/kernel/es7000_32.o: text data bss dec hex filename 2693 192 44 2929 b71 es7000_32.o.before 2688 192 44 2924 b6c es7000_32.o.after Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/kernel/es7000_32.c170
1 files changed, 90 insertions, 80 deletions
diff --git a/arch/x86/kernel/es7000_32.c b/arch/x86/kernel/es7000_32.c
index 03acbe95d2b5..3519f8cab708 100644
--- a/arch/x86/kernel/es7000_32.c
+++ b/arch/x86/kernel/es7000_32.c
@@ -1,10 +1,14 @@
1/* 1/*
2 * Written by: Garry Forsgren, Unisys Corporation 2 * Written by: Garry Forsgren, Unisys Corporation
3 * Natalie Protasevich, Unisys Corporation 3 * Natalie Protasevich, Unisys Corporation
4 *
4 * This file contains the code to configure and interface 5 * This file contains the code to configure and interface
5 * with Unisys ES7000 series hardware system manager. 6 * with Unisys ES7000 series hardware system manager.
6 * 7 *
7 * Copyright (c) 2003 Unisys Corporation. All Rights Reserved. 8 * Copyright (c) 2003 Unisys Corporation.
9 * Copyright (C) 2009, Red Hat, Inc., Ingo Molnar
10 *
11 * All Rights Reserved.
8 * 12 *
9 * This program is free software; you can redistribute it and/or modify it 13 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of version 2 of the GNU General Public License as 14 * under the terms of version 2 of the GNU General Public License as
@@ -35,7 +39,9 @@
35#include <linux/errno.h> 39#include <linux/errno.h>
36#include <linux/acpi.h> 40#include <linux/acpi.h>
37#include <linux/init.h> 41#include <linux/init.h>
42#include <linux/nmi.h>
38#include <linux/smp.h> 43#include <linux/smp.h>
44#include <linux/io.h>
39 45
40#include <asm/apicdef.h> 46#include <asm/apicdef.h>
41#include <asm/atomic.h> 47#include <asm/atomic.h>
@@ -44,9 +50,6 @@
44#include <asm/setup.h> 50#include <asm/setup.h>
45#include <asm/apic.h> 51#include <asm/apic.h>
46#include <asm/ipi.h> 52#include <asm/ipi.h>
47#include <asm/nmi.h>
48#include <asm/smp.h>
49#include <asm/io.h>
50 53
51/* 54/*
52 * ES7000 chipsets 55 * ES7000 chipsets
@@ -93,22 +96,28 @@ struct psai {
93}; 96};
94 97
95#ifdef CONFIG_ACPI 98#ifdef CONFIG_ACPI
99
96struct es7000_oem_table { 100struct es7000_oem_table {
97 struct acpi_table_header Header; 101 struct acpi_table_header Header;
98 u32 OEMTableAddr; 102 u32 OEMTableAddr;
99 u32 OEMTableSize; 103 u32 OEMTableSize;
100}; 104};
105
106static unsigned long oem_addrX;
107static unsigned long oem_size;
108
101#endif 109#endif
102 110
103/* 111/*
104 * ES7000 Globals 112 * ES7000 Globals
105 */ 113 */
106 114
107static volatile unsigned long *psai = NULL; 115static volatile unsigned long *psai;
108static struct mip_reg *mip_reg; 116static struct mip_reg *mip_reg;
109static struct mip_reg *host_reg; 117static struct mip_reg *host_reg;
110static int mip_port; 118static int mip_port;
111static unsigned long mip_addr, host_addr; 119static unsigned long mip_addr;
120static unsigned long host_addr;
112 121
113int es7000_plat; 122int es7000_plat;
114 123
@@ -252,31 +261,35 @@ static int __init parse_unisys_oem(char *oemptr)
252} 261}
253 262
254#ifdef CONFIG_ACPI 263#ifdef CONFIG_ACPI
255
256static unsigned long oem_addrX;
257static unsigned long oem_size;
258
259static int __init find_unisys_acpi_oem_table(unsigned long *oem_addr) 264static int __init find_unisys_acpi_oem_table(unsigned long *oem_addr)
260{ 265{
261 struct acpi_table_header *header = NULL; 266 struct acpi_table_header *header = NULL;
262 int i = 0; 267 struct es7000_oem_table *table;
263 acpi_size tbl_size; 268 acpi_size tbl_size;
269 acpi_status ret;
270 int i = 0;
264 271
265 while (ACPI_SUCCESS(acpi_get_table_with_size("OEM1", i++, &header, &tbl_size))) { 272 for (;;) {
266 if (!memcmp((char *) &header->oem_id, "UNISYS", 6)) { 273 ret = acpi_get_table_with_size("OEM1", i++, &header, &tbl_size);
267 struct es7000_oem_table *t = (void *)header; 274 if (!ACPI_SUCCESS(ret))
275 return -1;
268 276
269 oem_addrX = t->OEMTableAddr; 277 if (!memcmp((char *) &header->oem_id, "UNISYS", 6))
270 oem_size = t->OEMTableSize; 278 break;
271 early_acpi_os_unmap_memory(header, tbl_size);
272 279
273 *oem_addr = (unsigned long)__acpi_map_table(oem_addrX,
274 oem_size);
275 return 0;
276 }
277 early_acpi_os_unmap_memory(header, tbl_size); 280 early_acpi_os_unmap_memory(header, tbl_size);
278 } 281 }
279 return -1; 282
283 table = (void *)header;
284
285 oem_addrX = table->OEMTableAddr;
286 oem_size = table->OEMTableSize;
287
288 early_acpi_os_unmap_memory(header, tbl_size);
289
290 *oem_addr = (unsigned long)__acpi_map_table(oem_addrX, oem_size);
291
292 return 0;
280} 293}
281 294
282static void __init unmap_unisys_acpi_oem_table(unsigned long oem_addr) 295static void __init unmap_unisys_acpi_oem_table(unsigned long oem_addr)
@@ -286,7 +299,47 @@ static void __init unmap_unisys_acpi_oem_table(unsigned long oem_addr)
286 299
287 __acpi_unmap_table((char *)oem_addr, oem_size); 300 __acpi_unmap_table((char *)oem_addr, oem_size);
288} 301}
289#endif 302
303static int es7000_check_dsdt(void)
304{
305 struct acpi_table_header header;
306
307 if (ACPI_SUCCESS(acpi_get_table_header(ACPI_SIG_DSDT, 0, &header)) &&
308 !strncmp(header.oem_id, "UNISYS", 6))
309 return 1;
310 return 0;
311}
312
313/* Hook from generic ACPI tables.c */
314static int __init es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
315{
316 unsigned long oem_addr = 0;
317 int check_dsdt;
318 int ret = 0;
319
320 /* check dsdt at first to avoid clear fix_map for oem_addr */
321 check_dsdt = es7000_check_dsdt();
322
323 if (!find_unisys_acpi_oem_table(&oem_addr)) {
324 if (check_dsdt) {
325 ret = parse_unisys_oem((char *)oem_addr);
326 } else {
327 setup_unisys();
328 ret = 1;
329 }
330 /*
331 * we need to unmap it
332 */
333 unmap_unisys_acpi_oem_table(oem_addr);
334 }
335 return ret;
336}
337#else /* !CONFIG_ACPI: */
338static int __init es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
339{
340 return 0;
341}
342#endif /* !CONFIG_ACPI */
290 343
291static void es7000_spin(int n) 344static void es7000_spin(int n)
292{ 345{
@@ -305,7 +358,7 @@ es7000_mip_write(struct mip_reg *mip_reg)
305 spin = MIP_SPIN; 358 spin = MIP_SPIN;
306 while ((host_reg->off_0x38 & MIP_VALID) != 0) { 359 while ((host_reg->off_0x38 & MIP_VALID) != 0) {
307 if (--spin <= 0) { 360 if (--spin <= 0) {
308 printk("es7000_mip_write: Timeout waiting for Host Valid Flag"); 361 WARN(1, "Timeout waiting for Host Valid Flag\n");
309 return -1; 362 return -1;
310 } 363 }
311 es7000_spin(MIP_SPIN); 364 es7000_spin(MIP_SPIN);
@@ -318,7 +371,7 @@ es7000_mip_write(struct mip_reg *mip_reg)
318 371
319 while ((mip_reg->off_0x38 & MIP_VALID) == 0) { 372 while ((mip_reg->off_0x38 & MIP_VALID) == 0) {
320 if (--spin <= 0) { 373 if (--spin <= 0) {
321 printk("es7000_mip_write: Timeout waiting for MIP Valid Flag"); 374 WARN(1, "Timeout waiting for MIP Valid Flag\n");
322 return -1; 375 return -1;
323 } 376 }
324 es7000_spin(MIP_SPIN); 377 es7000_spin(MIP_SPIN);
@@ -338,15 +391,13 @@ static void __init es7000_enable_apic_mode(void)
338 if (!es7000_plat) 391 if (!es7000_plat)
339 return; 392 return;
340 393
341 printk("ES7000: Enabling APIC mode.\n"); 394 printk(KERN_INFO "ES7000: Enabling APIC mode.\n");
342 memset(&es7000_mip_reg, 0, sizeof(struct mip_reg)); 395 memset(&es7000_mip_reg, 0, sizeof(struct mip_reg));
343 es7000_mip_reg.off_0x00 = MIP_SW_APIC; 396 es7000_mip_reg.off_0x00 = MIP_SW_APIC;
344 es7000_mip_reg.off_0x38 = MIP_VALID; 397 es7000_mip_reg.off_0x38 = MIP_VALID;
345 398
346 while ((mip_status = es7000_mip_write(&es7000_mip_reg)) != 0) { 399 while ((mip_status = es7000_mip_write(&es7000_mip_reg)) != 0)
347 printk("es7000_enable_apic_mode: command failed, status = %x\n", 400 WARN(1, "Command failed, status = %x\n", mip_status);
348 mip_status);
349 }
350} 401}
351 402
352static void es7000_vector_allocation_domain(int cpu, cpumask_t *retmask) 403static void es7000_vector_allocation_domain(int cpu, cpumask_t *retmask)
@@ -377,18 +428,6 @@ static unsigned int es7000_get_apic_id(unsigned long x)
377 return (x >> 24) & 0xFF; 428 return (x >> 24) & 0xFF;
378} 429}
379 430
380#ifdef CONFIG_ACPI
381static int es7000_check_dsdt(void)
382{
383 struct acpi_table_header header;
384
385 if (ACPI_SUCCESS(acpi_get_table_header(ACPI_SIG_DSDT, 0, &header)) &&
386 !strncmp(header.oem_id, "UNISYS", 6))
387 return 1;
388 return 0;
389}
390#endif
391
392static void es7000_send_IPI_mask(const struct cpumask *mask, int vector) 431static void es7000_send_IPI_mask(const struct cpumask *mask, int vector)
393{ 432{
394 default_send_IPI_mask_sequence_phys(mask, vector); 433 default_send_IPI_mask_sequence_phys(mask, vector);
@@ -466,10 +505,12 @@ static void es7000_init_apic_ldr(void)
466static void es7000_setup_apic_routing(void) 505static void es7000_setup_apic_routing(void)
467{ 506{
468 int apic = per_cpu(x86_bios_cpu_apicid, smp_processor_id()); 507 int apic = per_cpu(x86_bios_cpu_apicid, smp_processor_id());
469 printk("Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n", 508
509 printk(KERN_INFO
510 "Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n",
470 (apic_version[apic] == 0x14) ? 511 (apic_version[apic] == 0x14) ?
471 "Physical Cluster" : "Logical Cluster", 512 "Physical Cluster" : "Logical Cluster",
472 nr_ioapics, cpus_addr(*es7000_target_cpus())[0]); 513 nr_ioapics, cpus_addr(*es7000_target_cpus())[0]);
473} 514}
474 515
475static int es7000_apicid_to_node(int logical_apicid) 516static int es7000_apicid_to_node(int logical_apicid)
@@ -488,13 +529,14 @@ static int es7000_cpu_present_to_apicid(int mps_cpu)
488 return BAD_APICID; 529 return BAD_APICID;
489} 530}
490 531
532static int cpu_id;
533
491static physid_mask_t es7000_apicid_to_cpu_present(int phys_apicid) 534static physid_mask_t es7000_apicid_to_cpu_present(int phys_apicid)
492{ 535{
493 static int id = 0;
494 physid_mask_t mask; 536 physid_mask_t mask;
495 537
496 mask = physid_mask_of_physid(id); 538 mask = physid_mask_of_physid(cpu_id);
497 ++id; 539 ++cpu_id;
498 540
499 return mask; 541 return mask;
500} 542}
@@ -547,7 +589,7 @@ es7000_cpu_mask_to_apicid_cluster(const struct cpumask *cpumask)
547 int new_apicid = es7000_cpu_to_logical_apicid(cpu); 589 int new_apicid = es7000_cpu_to_logical_apicid(cpu);
548 590
549 if (APIC_CLUSTER(apicid) != APIC_CLUSTER(new_apicid)) { 591 if (APIC_CLUSTER(apicid) != APIC_CLUSTER(new_apicid)) {
550 printk("%s: Not a valid mask!\n", __func__); 592 WARN(1, "Not a valid mask!");
551 593
552 return 0xFF; 594 return 0xFF;
553 } 595 }
@@ -648,38 +690,6 @@ es7000_mps_oem_check(struct mpc_table *mpc, char *oem, char *productid)
648 return 0; 690 return 0;
649} 691}
650 692
651#ifdef CONFIG_ACPI
652/* Hook from generic ACPI tables.c */
653static int __init es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
654{
655 unsigned long oem_addr = 0;
656 int check_dsdt;
657 int ret = 0;
658
659 /* check dsdt at first to avoid clear fix_map for oem_addr */
660 check_dsdt = es7000_check_dsdt();
661
662 if (!find_unisys_acpi_oem_table(&oem_addr)) {
663 if (check_dsdt) {
664 ret = parse_unisys_oem((char *)oem_addr);
665 } else {
666 setup_unisys();
667 ret = 1;
668 }
669 /*
670 * we need to unmap it
671 */
672 unmap_unisys_acpi_oem_table(oem_addr);
673 }
674 return ret;
675}
676#else
677static int __init es7000_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
678{
679 return 0;
680}
681#endif
682
683 693
684struct genapic apic_es7000 = { 694struct genapic apic_es7000 = {
685 695