Project

General

Profile

Bug #557 » acpi-test-3.diff

qhwt+dfly, 02/28/2007 11:58 AM

View differences:

acpi_cpu.c 28 Feb 2007 11:40:57 -0000
182 182
DRIVER_MODULE(cpu, acpi, acpi_cpu_driver, acpi_cpu_devclass, 0, 0);
183 183
MODULE_DEPEND(cpu, acpi, 1, 1, 1);
184 184

  
185
static int acpi_cpu_probe_debug_knob = 0;
186
TUNABLE_INT("debug.acpi.cpu.knob", &acpi_cpu_probe_debug_knob);
187
#define DEBUG_KNOB(n)	\
188
    if (acpi_cpu_probe_debug_knob == (n)) return(ENXIO)
189

  
185 190
static int
186 191
acpi_cpu_probe(device_t dev)
187 192
{
188
    int			   acpi_id, cpu_id, cx_count;
193
    int			   acpi_id, cpu_id, proc_id, cx_count;
189 194
    ACPI_BUFFER		   buf;
190 195
    ACPI_HANDLE		   handle;
191 196
    char		   msg[32];
......
196 201
	return (ENXIO);
197 202

  
198 203
    handle = acpi_get_handle(dev);
204
DEBUG_KNOB(1);
199 205
    if (cpu_softc == NULL)
200 206
	cpu_softc = kmalloc(sizeof(struct acpi_cpu_softc *) *
201 207
	    SMP_MAXCPU, M_TEMP /* XXX */, M_INTWAIT | M_ZERO);
202

  
208
DEBUG_KNOB(2);
203 209
    /* Get our Processor object. */
204 210
    buf.Pointer = NULL;
205 211
    buf.Length = ACPI_ALLOCATE_BUFFER;
206 212
    status = AcpiEvaluateObject(handle, NULL, NULL, &buf);
213
DEBUG_KNOB(3);
207 214
    if (ACPI_FAILURE(status)) {
208 215
	device_printf(dev, "probe failed to get Processor obj - %s\n",
209 216
		      AcpiFormatException(status));
......
221 228
     * ProcId as a key, however, some boxes do not have the same values
222 229
     * in their Processor object as the ProcId values in the MADT.
223 230
     */
224
    acpi_id = obj->Processor.ProcId;
231
    acpi_id = proc_id = obj->Processor.ProcId;
225 232
    AcpiOsFree(obj);
226
    if (acpi_pcpu_get_id(device_get_unit(dev), &acpi_id, &cpu_id) != 0)
233
DEBUG_KNOB(4);
234
    if (acpi_pcpu_get_id(device_get_unit(dev), &acpi_id, &cpu_id) != 0) {
235
	if (bootverbose)
236
	    device_printf(dev, "ProcId %d: can't find cpu_id\n", proc_id);
227 237
	return (ENXIO);
228

  
238
    }
239
    if (bootverbose) {
240
	device_printf(dev, "ProcId %d: acpi_id=%d, cpu_id=%d\n", proc_id,
241
		      acpi_id, cpu_id);
242
    }
229 243
    /*
230 244
     * Check if we already probed this processor.  We scan the bus twice
231 245
     * so it's possible we've already seen this one.
232 246
     */
233 247
    if (cpu_softc[cpu_id] != NULL)
234 248
	return (ENXIO);
235

  
249
DEBUG_KNOB(5);
236 250
    /* Get a count of Cx states for our device string. */
237 251
    cx_count = 0;
238 252
    buf.Pointer = NULL;
239 253
    buf.Length = ACPI_ALLOCATE_BUFFER;
240 254
    status = AcpiEvaluateObject(handle, "_CST", NULL, &buf);
255
DEBUG_KNOB(6);
241 256
    if (ACPI_SUCCESS(status)) {
242 257
	obj = (ACPI_OBJECT *)buf.Pointer;
243 258
	if (ACPI_PKG_VALID(obj, 2))
......
251 266
	if (cx_count > 0)
252 267
	    cx_count++;
253 268
    }
269
DEBUG_KNOB(7);
254 270
    if (cx_count > 0)
255 271
	ksnprintf(msg, sizeof(msg), "ACPI CPU (%d Cx states)", cx_count);
256 272
    else
257 273
	strlcpy(msg, "ACPI CPU", sizeof(msg));
274
DEBUG_KNOB(8);
258 275
    device_set_desc_copy(dev, msg);
276
DEBUG_KNOB(9);
259 277

  
260 278
    /* Mark this processor as in-use and save our derived id for attach. */
261 279
    cpu_softc[cpu_id] = (void *)1;
262 280
    acpi_set_magic(dev, cpu_id);
281
DEBUG_KNOB(10);
263 282

  
264 283
    return (0);
265 284
}
......
278 297

  
279 298
    ACPI_ASSERTLOCK;
280 299

  
300
DEBUG_KNOB(11);
281 301
    sc = device_get_softc(dev);
282 302
    sc->cpu_dev = dev;
283 303
    sc->cpu_handle = acpi_get_handle(dev);
......
326 346

  
327 347
    return_VALUE (0);
328 348
}
349
#undef DEBUG_KNOB
329 350

  
330 351
/*
331 352
 * Find the nth present CPU and return its pc_cpuid as well as set the
(7-7/8)