From owner-svn-src-head@freebsd.org Wed Jun 20 13:30:36 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 98F2D10198D0; Wed, 20 Jun 2018 13:30:36 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4B8967A981; Wed, 20 Jun 2018 13:30:36 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2E15E22CF5; Wed, 20 Jun 2018 13:30:36 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5KDUa48032814; Wed, 20 Jun 2018 13:30:36 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5KDUa5L032813; Wed, 20 Jun 2018 13:30:36 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201806201330.w5KDUa5L032813@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Wed, 20 Jun 2018 13:30:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335442 - head/sys/dev/ofw X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/dev/ofw X-SVN-Commit-Revision: 335442 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2018 13:30:36 -0000 Author: jhibbits Date: Wed Jun 20 13:30:35 2018 New Revision: 335442 URL: https://svnweb.freebsd.org/changeset/base/335442 Log: Attach dev.cpu nodes on powerpc SMT cores, using only the first found thread Summary: In order to use cpufreq(4), a dev.cpu attachment must be created. If the IBM property is found denoting SMT, attach only to the first thread setup, so that a cpufreq device can bind. Reviewed by: nwhitehorn Differential Revision: https://reviews.freebsd.org/D15921 Modified: head/sys/dev/ofw/ofw_cpu.c Modified: head/sys/dev/ofw/ofw_cpu.c ============================================================================== --- head/sys/dev/ofw/ofw_cpu.c Wed Jun 20 11:42:06 2018 (r335441) +++ head/sys/dev/ofw/ofw_cpu.c Wed Jun 20 13:30:35 2018 (r335442) @@ -191,10 +191,6 @@ ofw_cpu_probe(device_t dev) if (type == NULL || strcmp(type, "cpu") != 0) return (ENXIO); - /* Skip SMT CPUs, which we can't reasonably represent with this code */ - if (OF_hasprop(ofw_bus_get_node(dev), "ibm,ppc-interrupt-server#s")) - return (ENXIO); - device_set_desc(dev, "Open Firmware CPU"); return (0); } @@ -233,6 +229,43 @@ ofw_cpu_attach(device_t dev) } else sc->sc_reg_valid = true; +#ifdef __powerpc__ + /* + * On powerpc, "interrupt-servers" denotes a SMT CPU. Look for any + * thread on this CPU, and assign that. + */ + if (OF_hasprop(node, "ibm,ppc-interrupt-server#s")) { + struct cpuref cpuref; + cell_t *servers; + int i, nservers, rv; + + if ((nservers = OF_getencprop_alloc(node, + "ibm,ppc-interrupt-server#s", (void **)&servers)) < 0) + return (ENXIO); + nservers /= sizeof(cell_t); + for (i = 0; i < nservers; i++) { + for (rv = platform_smp_first_cpu(&cpuref); rv == 0; + rv = platform_smp_next_cpu(&cpuref)) { + if (cpuref.cr_hwref == servers[i]) { + sc->sc_cpu_pcpu = + pcpu_find(cpuref.cr_cpuid); + if (sc->sc_cpu_pcpu == NULL) { + OF_prop_free(servers); + return (ENXIO); + } + break; + } + } + if (rv != ENOENT) + break; + } + OF_prop_free(servers); + if (sc->sc_cpu_pcpu == NULL) { + device_printf(dev, "No CPU found for this device.\n"); + return (ENXIO); + } + } else +#endif sc->sc_cpu_pcpu = pcpu_find(device_get_unit(dev)); if (OF_getencprop(node, "clock-frequency", &cell, sizeof(cell)) < 0) {