From owner-svn-src-stable-9@FreeBSD.ORG Thu Oct 10 03:35:31 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id DE34CFAB; Thu, 10 Oct 2013 03:35:31 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id AFB1D2A3F; Thu, 10 Oct 2013 03:35:31 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9A3ZVPC030861; Thu, 10 Oct 2013 03:35:31 GMT (envelope-from jhibbits@svn.freebsd.org) Received: (from jhibbits@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9A3ZVoj030860; Thu, 10 Oct 2013 03:35:31 GMT (envelope-from jhibbits@svn.freebsd.org) Message-Id: <201310100335.r9A3ZVoj030860@svn.freebsd.org> From: Justin Hibbits Date: Thu, 10 Oct 2013 03:35:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r256250 - stable/9/sys/powerpc/ofw X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Oct 2013 03:35:32 -0000 Author: jhibbits Date: Thu Oct 10 03:35:30 2013 New Revision: 256250 URL: http://svnweb.freebsd.org/changeset/base/256250 Log: MFC r252115,255378 Cache the Open Firmware CPU properties at attach time, so we don't always enter it at runtime to get static data. Modified: stable/9/sys/powerpc/ofw/ofw_cpu.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/powerpc/ofw/ofw_cpu.c ============================================================================== --- stable/9/sys/powerpc/ofw/ofw_cpu.c Thu Oct 10 01:20:18 2013 (r256249) +++ stable/9/sys/powerpc/ofw/ofw_cpu.c Thu Oct 10 03:35:30 2013 (r256250) @@ -133,6 +133,11 @@ static int ofw_cpu_attach(device_t); static int ofw_cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result); +struct ofw_cpu_softc { + struct pcpu *sc_cpu_pcpu; + uint32_t sc_nominal_mhz; +}; + static device_method_t ofw_cpu_methods[] = { /* Device interface */ DEVMETHOD(device_probe, ofw_cpu_probe), @@ -153,7 +158,7 @@ static device_method_t ofw_cpu_methods[] static driver_t ofw_cpu_driver = { "cpu", ofw_cpu_methods, - 0 + sizeof(struct ofw_cpu_softc) }; static devclass_t ofw_cpu_devclass; @@ -175,6 +180,15 @@ ofw_cpu_probe(device_t dev) static int ofw_cpu_attach(device_t dev) { + struct ofw_cpu_softc *sc; + uint32_t cell; + + sc = device_get_softc(dev); + OF_getprop(ofw_bus_get_node(dev), "reg", &cell, sizeof(cell)); + sc->sc_cpu_pcpu = pcpu_find(cell); + OF_getprop(ofw_bus_get_node(dev), "clock-frequency", &cell, sizeof(cell)); + sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */ + bus_generic_probe(dev); return (bus_generic_attach(dev)); } @@ -182,19 +196,16 @@ ofw_cpu_attach(device_t dev) static int ofw_cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) { - uint32_t cell; + struct ofw_cpu_softc *sc; + + sc = device_get_softc(dev); switch (index) { case CPU_IVAR_PCPU: - OF_getprop(ofw_bus_get_node(dev), "reg", &cell, sizeof(cell)); - *result = (uintptr_t)(pcpu_find(cell)); + *result = (uintptr_t)sc->sc_cpu_pcpu; return (0); case CPU_IVAR_NOMINAL_MHZ: - cell = 0; - OF_getprop(ofw_bus_get_node(dev), "clock-frequency", - &cell, sizeof(cell)); - cell /= 1000000; /* convert to MHz */ - *result = (uintptr_t)(cell); + *result = (uintptr_t)sc->sc_nominal_mhz; return (0); }