From 60c6b104ef24df5d0b2934e5d6b0781a62bdab81 Mon Sep 17 00:00:00 2001 From: jhb Date: Wed, 3 Dec 2003 20:27:48 +0000 Subject: Update this driver to be more module friendly: - Dynamically allocate the cpu_softc[] array based on mp_maxid instead of using a statically sized array that depended on 'options SMP'. - Use mp_maxid rather than MAXCPU when walking all the CPUs looking for a match. - Always call smp_rendezvous() since UP kernels now provide this. - Use mp_ncpus rather than cpu_ndevices when determining if we need to disable C3 for SMP machines. Approved by: re (rwatson) Reviewed by: njl --- sys/dev/acpica/acpi_cpu.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'sys/dev/acpica') diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c index 0d3a4ac..a318ffc 100644 --- a/sys/dev/acpica/acpi_cpu.c +++ b/sys/dev/acpica/acpi_cpu.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -142,7 +143,7 @@ static char cpu_cx_supported[64]; static device_t *cpu_devices; static int cpu_ndevices; -static struct acpi_cpu_softc *cpu_softc[MAXCPU]; +static struct acpi_cpu_softc **cpu_softc; static struct sysctl_ctx_list acpi_cpu_sysctl_ctx; static struct sysctl_oid *acpi_cpu_sysctl_tree; @@ -192,6 +193,9 @@ 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); } @@ -300,7 +304,7 @@ acpi_pcpu_get_id(uint32_t idx, uint32_t *acpi_id, uint32_t *cpu_id) KASSERT(acpi_id != NULL, ("Null acpi_id")); KASSERT(cpu_id != NULL, ("Null cpu_id")); - for (i = 0; i < MAXCPU; i++) { + for (i = 0; i <= mp_maxid; i++) { if (CPU_ABSENT(i)) continue; pcpu_data = pcpu_find(i); @@ -332,10 +336,8 @@ acpi_cpu_shutdown(device_t dev) /* Disable any entry to the idle function. */ cpu_cx_count = 0; -#ifdef SMP /* Wait for all processors to exit acpi_cpu_idle(). */ smp_rendezvous(NULL, NULL, NULL, NULL); -#endif while (cpu_idle_busy > 0) DELAY(1); @@ -986,7 +988,7 @@ acpi_cpu_quirks(struct acpi_cpu_softc *sc) * C3 is not supported on multiple CPUs since this would require * flushing all caches which is currently too expensive. */ - if (cpu_ndevices > 1) + if (mp_ncpus > 1) cpu_quirks |= CPU_QUIRK_NO_C3; #ifdef notyet -- cgit v1.1