git: b7668d009e53 - stable/13 - Make CPU children explicitly share parent unit numbers.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 04 Jan 2022 18:03:28 UTC
The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=b7668d009e5343560109db7b004fed00c774589d commit b7668d009e5343560109db7b004fed00c774589d Author: Alexander Motin <mav@FreeBSD.org> AuthorDate: 2021-09-25 03:25:46 +0000 Commit: Alexander Motin <mav@FreeBSD.org> CommitDate: 2022-01-04 17:21:42 +0000 Make CPU children explicitly share parent unit numbers. Before this device unit number match was coincidental and broke if I disabled some CPU device(s). Aside of cosmetics, for some drivers (may be considered broken) it caused talking to wrong CPUs. (cherry picked from commit d3a8f98acbf51e728411f10c5f179a30b9ca683c) --- sys/dev/acpica/acpi_perf.c | 3 ++- sys/dev/acpica/acpi_throttle.c | 3 ++- sys/dev/amdtemp/amdtemp.c | 3 ++- sys/dev/coretemp/coretemp.c | 2 +- sys/dev/cpufreq/cpufreq_dt.c | 3 ++- sys/kern/kern_cpu.c | 2 +- sys/x86/cpufreq/est.c | 2 +- sys/x86/cpufreq/hwpstate_amd.c | 3 ++- sys/x86/cpufreq/hwpstate_intel.c | 8 +++----- sys/x86/cpufreq/p4tcc.c | 3 ++- sys/x86/cpufreq/powernow.c | 3 ++- sys/x86/cpufreq/smist.c | 3 ++- 12 files changed, 22 insertions(+), 16 deletions(-) diff --git a/sys/dev/acpica/acpi_perf.c b/sys/dev/acpica/acpi_perf.c index df0fa9a29b6e..5134bbaaa4dc 100644 --- a/sys/dev/acpica/acpi_perf.c +++ b/sys/dev/acpica/acpi_perf.c @@ -161,7 +161,8 @@ acpi_perf_identify(driver_t *driver, device_t parent) * We probe this child now so that other devices that depend * on it (i.e., for info about supported states) will see it. */ - if ((dev = BUS_ADD_CHILD(parent, 0, "acpi_perf", -1)) != NULL) + if ((dev = BUS_ADD_CHILD(parent, 0, "acpi_perf", + device_get_unit(parent))) != NULL) device_probe_and_attach(dev); else device_printf(parent, "add acpi_perf child failed\n"); diff --git a/sys/dev/acpica/acpi_throttle.c b/sys/dev/acpica/acpi_throttle.c index 883b5d34de09..a9cc2d77ecf9 100644 --- a/sys/dev/acpica/acpi_throttle.c +++ b/sys/dev/acpica/acpi_throttle.c @@ -157,7 +157,8 @@ acpi_throttle_identify(driver_t *driver, device_t parent) obj = (ACPI_OBJECT *)buf.Pointer; if ((obj->Processor.PblkAddress && obj->Processor.PblkLength >= 4) || ACPI_SUCCESS(AcpiEvaluateObject(handle, "_PTC", NULL, NULL))) { - if (BUS_ADD_CHILD(parent, 0, "acpi_throttle", -1) == NULL) + if (BUS_ADD_CHILD(parent, 0, "acpi_throttle", + device_get_unit(parent)) == NULL) device_printf(parent, "add throttle child failed\n"); } AcpiOsFree(obj); diff --git a/sys/dev/amdtemp/amdtemp.c b/sys/dev/amdtemp/amdtemp.c index 21227a47c513..c1d696d070a5 100644 --- a/sys/dev/amdtemp/amdtemp.c +++ b/sys/dev/amdtemp/amdtemp.c @@ -263,7 +263,8 @@ amdtemp_identify(driver_t *driver, device_t parent) return; if (amdtemp_match(parent, NULL)) { - child = device_add_child(parent, "amdtemp", -1); + child = device_add_child(parent, "amdtemp", + device_get_unit(parent)); if (child == NULL) device_printf(parent, "add amdtemp child failed\n"); } diff --git a/sys/dev/coretemp/coretemp.c b/sys/dev/coretemp/coretemp.c index bdc71b284ac7..251fb08b4c11 100644 --- a/sys/dev/coretemp/coretemp.c +++ b/sys/dev/coretemp/coretemp.c @@ -133,7 +133,7 @@ coretemp_identify(driver_t *driver, device_t parent) * We add a child for each CPU since settings must be performed * on each CPU in the SMP case. */ - child = device_add_child(parent, "coretemp", -1); + child = device_add_child(parent, "coretemp", device_get_unit(parent)); if (child == NULL) device_printf(parent, "add coretemp child failed\n"); } diff --git a/sys/dev/cpufreq/cpufreq_dt.c b/sys/dev/cpufreq/cpufreq_dt.c index 3beffeb7063a..4ab021a97d31 100644 --- a/sys/dev/cpufreq/cpufreq_dt.c +++ b/sys/dev/cpufreq/cpufreq_dt.c @@ -309,7 +309,8 @@ cpufreq_dt_identify(driver_t *driver, device_t parent) if (device_find_child(parent, "cpufreq_dt", -1) != NULL) return; - if (BUS_ADD_CHILD(parent, 0, "cpufreq_dt", -1) == NULL) + if (BUS_ADD_CHILD(parent, 0, "cpufreq_dt", device_get_unit(parent)) + == NULL) device_printf(parent, "add cpufreq_dt child failed\n"); } diff --git a/sys/kern/kern_cpu.c b/sys/kern/kern_cpu.c index 2f44405aef37..380849974a35 100644 --- a/sys/kern/kern_cpu.c +++ b/sys/kern/kern_cpu.c @@ -1103,7 +1103,7 @@ cpufreq_register(device_t dev) } /* Add the child device and possibly sysctls. */ - cf_dev = BUS_ADD_CHILD(cpu_dev, 0, "cpufreq", -1); + cf_dev = BUS_ADD_CHILD(cpu_dev, 0, "cpufreq", device_get_unit(cpu_dev)); if (cf_dev == NULL) return (ENOMEM); device_quiet(cf_dev); diff --git a/sys/x86/cpufreq/est.c b/sys/x86/cpufreq/est.c index 258a9c493d0f..cdca2fdfec5f 100644 --- a/sys/x86/cpufreq/est.c +++ b/sys/x86/cpufreq/est.c @@ -946,7 +946,7 @@ est_identify(driver_t *driver, device_t parent) * We add a child for each CPU since settings must be performed * on each CPU in the SMP case. */ - child = BUS_ADD_CHILD(parent, 10, "est", -1); + child = BUS_ADD_CHILD(parent, 10, "est", device_get_unit(parent)); if (child == NULL) device_printf(parent, "add est child failed\n"); } diff --git a/sys/x86/cpufreq/hwpstate_amd.c b/sys/x86/cpufreq/hwpstate_amd.c index ee67da43de53..3193cbd908cc 100644 --- a/sys/x86/cpufreq/hwpstate_amd.c +++ b/sys/x86/cpufreq/hwpstate_amd.c @@ -341,7 +341,8 @@ hwpstate_identify(driver_t *driver, device_t parent) if (resource_disabled("hwpstate", 0)) return; - if (BUS_ADD_CHILD(parent, 10, "hwpstate", -1) == NULL) + if (BUS_ADD_CHILD(parent, 10, "hwpstate", device_get_unit(parent)) + == NULL) device_printf(parent, "hwpstate: add child failed\n"); } diff --git a/sys/x86/cpufreq/hwpstate_intel.c b/sys/x86/cpufreq/hwpstate_intel.c index e3d17aa0bd1c..1ed1056024c1 100644 --- a/sys/x86/cpufreq/hwpstate_intel.c +++ b/sys/x86/cpufreq/hwpstate_intel.c @@ -352,11 +352,9 @@ intel_hwpstate_identify(driver_t *driver, device_t parent) if ((cpu_power_eax & CPUTPM1_HWP) == 0) return; - if (BUS_ADD_CHILD(parent, 10, "hwpstate_intel", -1) == NULL) - return; - - if (bootverbose) - device_printf(parent, "hwpstate registered\n"); + if (BUS_ADD_CHILD(parent, 10, "hwpstate_intel", device_get_unit(parent)) + == NULL) + device_printf(parent, "hwpstate_intel: add child failed\n"); } static int diff --git a/sys/x86/cpufreq/p4tcc.c b/sys/x86/cpufreq/p4tcc.c index 89bfef3f6930..4370da81cf06 100644 --- a/sys/x86/cpufreq/p4tcc.c +++ b/sys/x86/cpufreq/p4tcc.c @@ -135,7 +135,8 @@ p4tcc_identify(driver_t *driver, device_t parent) * of the IA32 Intel Architecture Software Developer's Manual, * Volume 3, for more info. */ - if (BUS_ADD_CHILD(parent, 10, "p4tcc", -1) == NULL) + if (BUS_ADD_CHILD(parent, 10, "p4tcc", device_get_unit(parent)) + == NULL) device_printf(parent, "add p4tcc child failed\n"); } diff --git a/sys/x86/cpufreq/powernow.c b/sys/x86/cpufreq/powernow.c index da5598557387..977798ab2f77 100644 --- a/sys/x86/cpufreq/powernow.c +++ b/sys/x86/cpufreq/powernow.c @@ -876,7 +876,8 @@ pn_identify(driver_t *driver, device_t parent) } if (device_find_child(parent, "powernow", -1) != NULL) return; - if (BUS_ADD_CHILD(parent, 10, "powernow", -1) == NULL) + if (BUS_ADD_CHILD(parent, 10, "powernow", device_get_unit(parent)) + == NULL) device_printf(parent, "powernow: add child failed\n"); } diff --git a/sys/x86/cpufreq/smist.c b/sys/x86/cpufreq/smist.c index 309b725d31ad..129ec2d4884b 100644 --- a/sys/x86/cpufreq/smist.c +++ b/sys/x86/cpufreq/smist.c @@ -310,7 +310,8 @@ smist_identify(driver_t *driver, device_t parent) if (device_find_child(parent, "smist", -1) != NULL) return; - if (BUS_ADD_CHILD(parent, 30, "smist", -1) == NULL) + if (BUS_ADD_CHILD(parent, 30, "smist", device_get_unit(parent)) + == NULL) device_printf(parent, "smist: add child failed\n"); }