From owner-svn-src-head@freebsd.org Tue Jul 28 13:16:09 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 85D369ACC27; Tue, 28 Jul 2015 13:16:09 +0000 (UTC) (envelope-from zbb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 75A82A3F; Tue, 28 Jul 2015 13:16:09 +0000 (UTC) (envelope-from zbb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6SDG9ne014966; Tue, 28 Jul 2015 13:16:09 GMT (envelope-from zbb@FreeBSD.org) Received: (from zbb@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6SDG9If014965; Tue, 28 Jul 2015 13:16:09 GMT (envelope-from zbb@FreeBSD.org) Message-Id: <201507281316.t6SDG9If014965@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: zbb set sender to zbb@FreeBSD.org using -f From: Zbigniew Bodek Date: Tue, 28 Jul 2015 13:16:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r285957 - head/sys/dev/ofw X-SVN-Group: head 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.20 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: Tue, 28 Jul 2015 13:16:09 -0000 Author: zbb Date: Tue Jul 28 13:16:08 2015 New Revision: 285957 URL: https://svnweb.freebsd.org/changeset/base/285957 Log: Limit ofw_cpu_early_foreach() to CPUs only On some platforms, the /cpus node contains cpu-to-cluster map which deffinitely is not a CPU node. Its presence was causing incrementing of "id" variable and reporting more CPUs available than it should. To make "id" valid, increment it only when an entry really is a CPU device. Reviewed by: andrew Obtained from: Semihalf Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3216 Modified: head/sys/dev/ofw/ofw_cpu.c Modified: head/sys/dev/ofw/ofw_cpu.c ============================================================================== --- head/sys/dev/ofw/ofw_cpu.c Tue Jul 28 13:11:31 2015 (r285956) +++ head/sys/dev/ofw/ofw_cpu.c Tue Jul 28 13:16:08 2015 (r285957) @@ -281,11 +281,13 @@ ofw_cpu_early_foreach(ofw_cpu_foreach_cb phandle_t node, child; pcell_t addr_cells, reg[2]; char status[16]; - u_int id; + char device_type[16]; + u_int id, next_id; int count, rv; count = 0; id = 0; + next_id = 0; node = OF_finddevice("/cpus"); if (node == -1) @@ -296,7 +298,21 @@ ofw_cpu_early_foreach(ofw_cpu_foreach_cb sizeof(addr_cells)) < 0) return (-1); - for (child = OF_child(node); child != 0; child = OF_peer(child), id++) { + for (child = OF_child(node); child != 0; child = OF_peer(child), + id = next_id) { + + /* Check if child is a CPU */ + memset(device_type, 0, sizeof(device_type)); + rv = OF_getprop(child, "device_type", device_type, + sizeof(device_type) - 1); + if (rv < 0) + continue; + if (strcmp(device_type, "cpu") != 0) + continue; + + /* We're processing CPU, update next_id used in the next iteration */ + next_id++; + /* * If we are filtering by runnable then limit to only * those that have been enabled.