Rename acpi_cpu to cpu. Change the probe routine to early on reject
devices it cannot attach to. This gets rid of extraneous but harmless device_probe_and_attach() errors. While I'm here, make the device description more useful. The !acpi case for cpu is handled by legacy0.
This commit is contained in:
parent
e9ec8dbd49
commit
d33cf3a8dd
@ -176,38 +176,106 @@ static device_method_t acpi_cpu_methods[] = {
|
||||
};
|
||||
|
||||
static driver_t acpi_cpu_driver = {
|
||||
"acpi_cpu",
|
||||
"cpu",
|
||||
acpi_cpu_methods,
|
||||
sizeof(struct acpi_cpu_softc),
|
||||
};
|
||||
|
||||
static devclass_t acpi_cpu_devclass;
|
||||
DRIVER_MODULE(acpi_cpu, acpi, acpi_cpu_driver, acpi_cpu_devclass, 0, 0);
|
||||
MODULE_DEPEND(acpi_cpu, acpi, 1, 1, 1);
|
||||
DRIVER_MODULE(cpu, acpi, acpi_cpu_driver, acpi_cpu_devclass, 0, 0);
|
||||
MODULE_DEPEND(cpu, acpi, 1, 1, 1);
|
||||
|
||||
static int
|
||||
acpi_cpu_probe(device_t dev)
|
||||
{
|
||||
if (!acpi_disabled("cpu") && acpi_get_type(dev) == ACPI_TYPE_PROCESSOR) {
|
||||
device_set_desc(dev, "CPU");
|
||||
if (cpu_softc == NULL)
|
||||
cpu_softc = malloc(sizeof(struct acpi_cpu_softc *) *
|
||||
(mp_maxid + 1), M_TEMP /* XXX */, M_WAITOK | M_ZERO);
|
||||
return (0);
|
||||
int acpi_id, cpu_id, cx_count;
|
||||
ACPI_BUFFER buf;
|
||||
ACPI_HANDLE handle;
|
||||
char msg[32];
|
||||
ACPI_OBJECT *obj;
|
||||
ACPI_STATUS status;
|
||||
|
||||
if (acpi_disabled("cpu") || acpi_get_type(dev) != ACPI_TYPE_PROCESSOR)
|
||||
return (ENXIO);
|
||||
|
||||
handle = acpi_get_handle(dev);
|
||||
if (cpu_softc == NULL)
|
||||
cpu_softc = malloc(sizeof(struct acpi_cpu_softc *) *
|
||||
(mp_maxid + 1), M_TEMP /* XXX */, M_WAITOK | M_ZERO);
|
||||
|
||||
/* Get our Processor object. */
|
||||
buf.Pointer = NULL;
|
||||
buf.Length = ACPI_ALLOCATE_BUFFER;
|
||||
status = AcpiEvaluateObject(handle, NULL, NULL, &buf);
|
||||
if (ACPI_FAILURE(status)) {
|
||||
device_printf(dev, "probe failed to get Processor obj - %s\n",
|
||||
AcpiFormatException(status));
|
||||
return (ENXIO);
|
||||
}
|
||||
obj = (ACPI_OBJECT *)buf.Pointer;
|
||||
if (obj->Type != ACPI_TYPE_PROCESSOR) {
|
||||
device_printf(dev, "Processor object has bad type %d\n", obj->Type);
|
||||
AcpiOsFree(obj);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
return (ENXIO);
|
||||
/*
|
||||
* Find the processor associated with our unit. We could use the
|
||||
* ProcId as a key, however, some boxes do not have the same values
|
||||
* in their Processor object as the ProcId values in the MADT.
|
||||
*/
|
||||
acpi_id = obj->Processor.ProcId;
|
||||
AcpiOsFree(obj);
|
||||
if (acpi_pcpu_get_id(device_get_unit(dev), &acpi_id, &cpu_id) != 0)
|
||||
return (ENXIO);
|
||||
|
||||
/*
|
||||
* Check if we already probed this processor. We scan the bus twice
|
||||
* so it's possible we've already seen this one.
|
||||
*/
|
||||
if (cpu_softc[cpu_id] != NULL)
|
||||
return (ENXIO);
|
||||
|
||||
/* Get a count of Cx states for our device string. */
|
||||
cx_count = 0;
|
||||
buf.Pointer = NULL;
|
||||
buf.Length = ACPI_ALLOCATE_BUFFER;
|
||||
status = AcpiEvaluateObject(handle, "_CST", NULL, &buf);
|
||||
if (ACPI_SUCCESS(status)) {
|
||||
obj = (ACPI_OBJECT *)buf.Pointer;
|
||||
if (ACPI_PKG_VALID(obj, 2))
|
||||
acpi_PkgInt32(obj, 0, &cx_count);
|
||||
AcpiOsFree(obj);
|
||||
} else {
|
||||
if (AcpiGbl_FADT->Plvl2Lat <= 100)
|
||||
cx_count++;
|
||||
if (AcpiGbl_FADT->Plvl3Lat <= 1000)
|
||||
cx_count++;
|
||||
if (cx_count > 0)
|
||||
cx_count++;
|
||||
}
|
||||
if (cx_count > 0)
|
||||
snprintf(msg, sizeof(msg), "ACPI CPU (%d Cx states)", cx_count);
|
||||
else
|
||||
strlcpy(msg, "ACPI CPU", sizeof(msg));
|
||||
device_set_desc_copy(dev, msg);
|
||||
|
||||
/* Mark this processor as in-use and save our derived id for attach. */
|
||||
cpu_softc[cpu_id] = (void *)1;
|
||||
acpi_set_magic(dev, cpu_id);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_cpu_attach(device_t dev)
|
||||
{
|
||||
ACPI_BUFFER buf;
|
||||
ACPI_OBJECT *obj;
|
||||
struct acpi_cpu_softc *sc;
|
||||
struct acpi_softc *acpi_sc;
|
||||
ACPI_OBJECT pobj;
|
||||
ACPI_BUFFER buf;
|
||||
ACPI_STATUS status;
|
||||
int thr_ret, cx_ret, cpu_id;
|
||||
int thr_ret, cx_ret;
|
||||
|
||||
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
|
||||
|
||||
@ -216,41 +284,21 @@ acpi_cpu_attach(device_t dev)
|
||||
sc = device_get_softc(dev);
|
||||
sc->cpu_dev = dev;
|
||||
sc->cpu_handle = acpi_get_handle(dev);
|
||||
cpu_softc[acpi_get_magic(dev)] = sc;
|
||||
|
||||
/* Get our Processor object. */
|
||||
buf.Pointer = &pobj;
|
||||
buf.Length = sizeof(pobj);
|
||||
buf.Pointer = NULL;
|
||||
buf.Length = ACPI_ALLOCATE_BUFFER;
|
||||
status = AcpiEvaluateObject(sc->cpu_handle, NULL, NULL, &buf);
|
||||
if (ACPI_FAILURE(status)) {
|
||||
device_printf(dev, "Couldn't get Processor object - %s\n",
|
||||
device_printf(dev, "attach failed to get Processor obj - %s\n",
|
||||
AcpiFormatException(status));
|
||||
return_VALUE (ENXIO);
|
||||
}
|
||||
if (pobj.Type != ACPI_TYPE_PROCESSOR) {
|
||||
device_printf(dev, "Processor object has bad type %d\n", pobj.Type);
|
||||
return_VALUE (ENXIO);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the processor associated with our unit. We could use the
|
||||
* ProcId as a key, however, some boxes do not have the same values
|
||||
* in their Processor object as the ProcId values in the MADT.
|
||||
*/
|
||||
sc->acpi_id = pobj.Processor.ProcId;
|
||||
if (acpi_pcpu_get_id(device_get_unit(dev), &sc->acpi_id, &cpu_id) != 0)
|
||||
return_VALUE (ENXIO);
|
||||
|
||||
/*
|
||||
* Check if we already probed this processor. We scan the bus twice
|
||||
* so it's possible we've already seen this one.
|
||||
*/
|
||||
if (cpu_softc[cpu_id] != NULL)
|
||||
return (ENXIO);
|
||||
cpu_softc[cpu_id] = sc;
|
||||
|
||||
/* Get various global values from the Processor object. */
|
||||
sc->cpu_p_blk = pobj.Processor.PblkAddress;
|
||||
sc->cpu_p_blk_len = pobj.Processor.PblkLength;
|
||||
}
|
||||
obj = (ACPI_OBJECT *)buf.Pointer;
|
||||
sc->cpu_p_blk = obj->Processor.PblkAddress;
|
||||
sc->cpu_p_blk_len = obj->Processor.PblkLength;
|
||||
sc->acpi_id = obj->Processor.ProcId;
|
||||
AcpiOsFree(obj);
|
||||
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "acpi_cpu%d: P_BLK at %#x/%d\n",
|
||||
device_get_unit(dev), sc->cpu_p_blk, sc->cpu_p_blk_len));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user