From owner-svn-src-head@freebsd.org Wed Feb 14 02:51:28 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 A1ECDF1AA8A; Wed, 14 Feb 2018 02:51:28 +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 557307FB88; Wed, 14 Feb 2018 02:51:28 +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 5081919AD; Wed, 14 Feb 2018 02:51:28 +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 w1E2pSpW074476; Wed, 14 Feb 2018 02:51:28 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1E2pSoA074475; Wed, 14 Feb 2018 02:51:28 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201802140251.w1E2pSoA074475@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Wed, 14 Feb 2018 02:51:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329258 - head/sys/powerpc/pseries X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/powerpc/pseries X-SVN-Commit-Revision: 329258 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.25 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, 14 Feb 2018 02:51:28 -0000 Author: jhibbits Date: Wed Feb 14 02:51:28 2018 New Revision: 329258 URL: https://svnweb.freebsd.org/changeset/base/329258 Log: PPC64: Get the timestap from the proper OF field Summary: After revision rS328534('PPC64: use hwref instead of cpuid'), FreeBSD on powerpc64 virtual machine panics since it is unable to read the timebase, showing the following error: get-property for timebase-frequency on zero phandle panic: Unable to determine timebase frequency! With the change above, cpuref->cr_hwref does not contain the phandle anymore, thus, it never reads the proper CPU entry in OF. Submitted by: Breno Leitao Differential Revision: https://reviews.freebsd.org/D14204 Modified: head/sys/powerpc/pseries/platform_chrp.c Modified: head/sys/powerpc/pseries/platform_chrp.c ============================================================================== --- head/sys/powerpc/pseries/platform_chrp.c Wed Feb 14 02:48:27 2018 (r329257) +++ head/sys/powerpc/pseries/platform_chrp.c Wed Feb 14 02:51:28 2018 (r329258) @@ -285,12 +285,24 @@ chrp_real_maxaddr(platform_t plat) static u_long chrp_timebase_freq(platform_t plat, struct cpuref *cpuref) { - phandle_t phandle; + phandle_t cpus, cpunode; int32_t ticks = -1; + int res; + char buf[8]; - phandle = cpuref->cr_hwref; + cpus = OF_finddevice("/cpus"); + if (cpus <= 0) + panic("CPU tree not found on Open Firmware\n"); - OF_getencprop(phandle, "timebase-frequency", &ticks, sizeof(ticks)); + for (cpunode = OF_child(cpus); cpunode != 0; cpunode = OF_peer(cpunode)) { + res = OF_getprop(cpunode, "device_type", buf, sizeof(buf)); + if (res > 0 && strcmp(buf, "cpu") == 0) + break; + } + if (cpunode <= 0) + panic("CPU node not found on Open Firmware\n"); + + OF_getencprop(cpunode, "timebase-frequency", &ticks, sizeof(ticks)); if (ticks <= 0) panic("Unable to determine timebase frequency!");