aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@arm.com>2015-03-24 10:02:46 -0400
committerWill Deacon <will.deacon@arm.com>2015-03-26 11:12:51 -0400
commit828aef376d7a129547bc4ebb949965040177e3da (patch)
treef4fd8bf12e062dfd646b139466e781d3d67c7c6b /drivers/acpi
parentfccb9a81fd08b61bed91ddef88341694f8ecbfd1 (diff)
ACPI / processor: Introduce phys_cpuid_t for CPU hardware ID
CPU hardware ID (phys_id) is defined as u32 in structure acpi_processor, but phys_id is used as int in acpi processor driver, so it will lead to some inconsistence for the drivers. Furthermore, to cater for ACPI arch ports that implement 64 bits CPU ids a generic CPU physical id type is required. So introduce typedef u32 phys_cpuid_t in a common file, and introduce a macro PHYS_CPUID_INVALID as (phys_cpuid_t)(-1) if it's not defined by other archs, this will solve the inconsistence in acpi processor driver, and will prepare for the ACPI on ARM64 for the 64 bit CPU hardware ID in the following patch. CC: Rafael J Wysocki <rjw@rjwysocki.net> Suggested-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Reviewed-by: Grant Likely <grant.likely@linaro.org> Acked-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> [hj: reworked cpu physid map return codes] Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpi_processor.c7
-rw-r--r--drivers/acpi/processor_core.c30
2 files changed, 19 insertions, 18 deletions
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index 1020b1b53a17..58f335ca2e75 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -170,7 +170,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr)
170 acpi_status status; 170 acpi_status status;
171 int ret; 171 int ret;
172 172
173 if (pr->phys_id == -1) 173 if (pr->phys_id == PHYS_CPUID_INVALID)
174 return -ENODEV; 174 return -ENODEV;
175 175
176 status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta); 176 status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
@@ -215,7 +215,8 @@ static int acpi_processor_get_info(struct acpi_device *device)
215 union acpi_object object = { 0 }; 215 union acpi_object object = { 0 };
216 struct acpi_buffer buffer = { sizeof(union acpi_object), &object }; 216 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
217 struct acpi_processor *pr = acpi_driver_data(device); 217 struct acpi_processor *pr = acpi_driver_data(device);
218 int phys_id, cpu_index, device_declaration = 0; 218 phys_cpuid_t phys_id;
219 int cpu_index, device_declaration = 0;
219 acpi_status status = AE_OK; 220 acpi_status status = AE_OK;
220 static int cpu0_initialized; 221 static int cpu0_initialized;
221 unsigned long long value; 222 unsigned long long value;
@@ -263,7 +264,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
263 } 264 }
264 265
265 phys_id = acpi_get_phys_id(pr->handle, device_declaration, pr->acpi_id); 266 phys_id = acpi_get_phys_id(pr->handle, device_declaration, pr->acpi_id);
266 if (phys_id < 0) 267 if (phys_id == PHYS_CPUID_INVALID)
267 acpi_handle_debug(pr->handle, "failed to get CPU physical ID.\n"); 268 acpi_handle_debug(pr->handle, "failed to get CPU physical ID.\n");
268 pr->phys_id = phys_id; 269 pr->phys_id = phys_id;
269 270
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 7962651cdbd4..51cc29909e08 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -32,7 +32,7 @@ static struct acpi_table_madt *get_madt_table(void)
32} 32}
33 33
34static int map_lapic_id(struct acpi_subtable_header *entry, 34static int map_lapic_id(struct acpi_subtable_header *entry,
35 u32 acpi_id, int *apic_id) 35 u32 acpi_id, phys_cpuid_t *apic_id)
36{ 36{
37 struct acpi_madt_local_apic *lapic = 37 struct acpi_madt_local_apic *lapic =
38 container_of(entry, struct acpi_madt_local_apic, header); 38 container_of(entry, struct acpi_madt_local_apic, header);
@@ -48,7 +48,7 @@ static int map_lapic_id(struct acpi_subtable_header *entry,
48} 48}
49 49
50static int map_x2apic_id(struct acpi_subtable_header *entry, 50static int map_x2apic_id(struct acpi_subtable_header *entry,
51 int device_declaration, u32 acpi_id, int *apic_id) 51 int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
52{ 52{
53 struct acpi_madt_local_x2apic *apic = 53 struct acpi_madt_local_x2apic *apic =
54 container_of(entry, struct acpi_madt_local_x2apic, header); 54 container_of(entry, struct acpi_madt_local_x2apic, header);
@@ -65,7 +65,7 @@ static int map_x2apic_id(struct acpi_subtable_header *entry,
65} 65}
66 66
67static int map_lsapic_id(struct acpi_subtable_header *entry, 67static int map_lsapic_id(struct acpi_subtable_header *entry,
68 int device_declaration, u32 acpi_id, int *apic_id) 68 int device_declaration, u32 acpi_id, phys_cpuid_t *apic_id)
69{ 69{
70 struct acpi_madt_local_sapic *lsapic = 70 struct acpi_madt_local_sapic *lsapic =
71 container_of(entry, struct acpi_madt_local_sapic, header); 71 container_of(entry, struct acpi_madt_local_sapic, header);
@@ -83,10 +83,10 @@ static int map_lsapic_id(struct acpi_subtable_header *entry,
83 return 0; 83 return 0;
84} 84}
85 85
86static int map_madt_entry(int type, u32 acpi_id) 86static phys_cpuid_t map_madt_entry(int type, u32 acpi_id)
87{ 87{
88 unsigned long madt_end, entry; 88 unsigned long madt_end, entry;
89 int phys_id = -1; /* CPU hardware ID */ 89 phys_cpuid_t phys_id = PHYS_CPUID_INVALID; /* CPU hardware ID */
90 struct acpi_table_madt *madt; 90 struct acpi_table_madt *madt;
91 91
92 madt = get_madt_table(); 92 madt = get_madt_table();
@@ -117,12 +117,12 @@ static int map_madt_entry(int type, u32 acpi_id)
117 return phys_id; 117 return phys_id;
118} 118}
119 119
120static int map_mat_entry(acpi_handle handle, int type, u32 acpi_id) 120static phys_cpuid_t map_mat_entry(acpi_handle handle, int type, u32 acpi_id)
121{ 121{
122 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 122 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
123 union acpi_object *obj; 123 union acpi_object *obj;
124 struct acpi_subtable_header *header; 124 struct acpi_subtable_header *header;
125 int phys_id = -1; 125 phys_cpuid_t phys_id = PHYS_CPUID_INVALID;
126 126
127 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer))) 127 if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
128 goto exit; 128 goto exit;
@@ -149,27 +149,27 @@ exit:
149 return phys_id; 149 return phys_id;
150} 150}
151 151
152int acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id) 152phys_cpuid_t acpi_get_phys_id(acpi_handle handle, int type, u32 acpi_id)
153{ 153{
154 int phys_id; 154 phys_cpuid_t phys_id;
155 155
156 phys_id = map_mat_entry(handle, type, acpi_id); 156 phys_id = map_mat_entry(handle, type, acpi_id);
157 if (phys_id == -1) 157 if (phys_id == PHYS_CPUID_INVALID)
158 phys_id = map_madt_entry(type, acpi_id); 158 phys_id = map_madt_entry(type, acpi_id);
159 159
160 return phys_id; 160 return phys_id;
161} 161}
162 162
163int acpi_map_cpuid(int phys_id, u32 acpi_id) 163int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id)
164{ 164{
165#ifdef CONFIG_SMP 165#ifdef CONFIG_SMP
166 int i; 166 int i;
167#endif 167#endif
168 168
169 if (phys_id == -1) { 169 if (phys_id == PHYS_CPUID_INVALID) {
170 /* 170 /*
171 * On UP processor, there is no _MAT or MADT table. 171 * On UP processor, there is no _MAT or MADT table.
172 * So above phys_id is always set to -1. 172 * So above phys_id is always set to PHYS_CPUID_INVALID.
173 * 173 *
174 * BIOS may define multiple CPU handles even for UP processor. 174 * BIOS may define multiple CPU handles even for UP processor.
175 * For example, 175 * For example,
@@ -190,7 +190,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id)
190 if (nr_cpu_ids <= 1 && acpi_id == 0) 190 if (nr_cpu_ids <= 1 && acpi_id == 0)
191 return acpi_id; 191 return acpi_id;
192 else 192 else
193 return phys_id; 193 return -1;
194 } 194 }
195 195
196#ifdef CONFIG_SMP 196#ifdef CONFIG_SMP
@@ -208,7 +208,7 @@ int acpi_map_cpuid(int phys_id, u32 acpi_id)
208 208
209int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id) 209int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
210{ 210{
211 int phys_id; 211 phys_cpuid_t phys_id;
212 212
213 phys_id = acpi_get_phys_id(handle, type, acpi_id); 213 phys_id = acpi_get_phys_id(handle, type, acpi_id);
214 214