From owner-dev-commits-src-all@freebsd.org Sat Sep 25 03:32:09 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B4394679264; Sat, 25 Sep 2021 03:32:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HGZG14bbyz4vSx; Sat, 25 Sep 2021 03:32:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7DC19230B1; Sat, 25 Sep 2021 03:32:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 18P3W9jI008784; Sat, 25 Sep 2021 03:32:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 18P3W9UM008783; Sat, 25 Sep 2021 03:32:09 GMT (envelope-from git) Date: Sat, 25 Sep 2021 03:32:09 GMT Message-Id: <202109250332.18P3W9UM008783@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alexander Motin Subject: git: d3a8f98acbf5 - main - Make CPU children explicitly share parent unit numbers. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d3a8f98acbf51e728411f10c5f179a30b9ca683c Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Sep 2021 03:32:09 -0000 The branch main has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=d3a8f98acbf51e728411f10c5f179a30b9ca683c commit d3a8f98acbf51e728411f10c5f179a30b9ca683c Author: Alexander Motin AuthorDate: 2021-09-25 03:25:46 +0000 Commit: Alexander Motin CommitDate: 2021-09-25 03:31:51 +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. --- 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 f6e63fdeb854..d4d94cadab28 100644 --- a/sys/x86/cpufreq/hwpstate_intel.c +++ b/sys/x86/cpufreq/hwpstate_intel.c @@ -351,11 +351,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 f95939001ecb..fda7cb2f52bc 100644 --- a/sys/x86/cpufreq/smist.c +++ b/sys/x86/cpufreq/smist.c @@ -311,7 +311,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"); }