Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Jul 2011 19:01:36 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r224387 - stable/8/sys/sparc64/pci
Message-ID:  <201107251901.p6PJ1aaC072477@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Mon Jul 25 19:01:36 2011
New Revision: 224387
URL: http://svn.freebsd.org/changeset/base/224387

Log:
  MFC: r223960
  
  - Current testing shows that (ab)using the JBC performance counter in bus
    cycle mode as timecounter just works fine. My best guess is that a firmware
    update has fixed this, so check at run-time whether it advances and use a
    positive quality if it does. The latter will cause this timecounter to be
    used instead of the tick counter based one, which just sucks for SMP.
  - Remove a redundant NULL assignment from the timecounter initialization.

Modified:
  stable/8/sys/sparc64/pci/fire.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/geom/label/   (props changed)

Modified: stable/8/sys/sparc64/pci/fire.c
==============================================================================
--- stable/8/sys/sparc64/pci/fire.c	Mon Jul 25 19:01:35 2011	(r224386)
+++ stable/8/sys/sparc64/pci/fire.c	Mon Jul 25 19:01:36 2011	(r224387)
@@ -664,9 +664,7 @@ fire_attach(device_t dev)
 
 	/*
 	 * Setup JBC/UBC performance counter 0 in bus cycle counting
-	 * mode as timecounter.  Unfortunately, at least with Fire all
-	 * JBus-driven performance counters just don't advance in bus
-	 * cycle counting mode.
+	 * mode as timecounter.
 	 */
 	if (device_get_unit(dev) == 0) {
 		FIRE_CTRL_SET(sc, FO_XBC_PRF_CNT0, 0);
@@ -674,19 +672,10 @@ fire_attach(device_t dev)
 		FIRE_CTRL_SET(sc, FO_XBC_PRF_CNT_SEL,
 		    (FO_XBC_PRF_CNT_NONE << FO_XBC_PRF_CNT_CNT1_SHFT) |
 		    (FO_XBC_PRF_CNT_XB_CLK << FO_XBC_PRF_CNT_CNT0_SHFT));
-#ifdef FIRE_DEBUG
-		device_printf(dev, "FO_XBC_PRF_CNT0 0x%016llx\n",
-		    (long long unsigned)FIRE_CTRL_READ_8(sc,
-		    FO_XBC_PRF_CNT0));
-		device_printf(dev, "FO_XBC_PRF_CNT0 0x%016llx\n",
-		    (long long unsigned)FIRE_CTRL_READ_8(sc,
-		    FO_XBC_PRF_CNT0));
-#endif
 		tc = malloc(sizeof(*tc), M_DEVBUF, M_NOWAIT | M_ZERO);
 		if (tc == NULL)
 			panic("%s: could not malloc timecounter", __func__);
 		tc->tc_get_timecount = fire_get_timecount;
-		tc->tc_poll_pps = NULL;
 		tc->tc_counter_mask = TC_COUNTER_MAX_MASK;
 		if (OF_getprop(OF_peer(0), "clock-frequency", &prop,
 		    sizeof(prop)) == -1)
@@ -694,8 +683,16 @@ fire_attach(device_t dev)
 			    __func__);
 		tc->tc_frequency = prop;
 		tc->tc_name = strdup(device_get_nameunit(dev), M_DEVBUF);
-		tc->tc_quality = -FIRE_PERF_CNT_QLTY;
 		tc->tc_priv = sc;
+		/*
+		 * Due to initial problems with the JBus-driven performance
+		 * counters not advancing which might be firmware dependent
+		 * ensure that it actually works.
+		 */
+		if (fire_get_timecount(tc) - fire_get_timecount(tc) != 0)
+			tc->tc_quality = FIRE_PERF_CNT_QLTY;
+		else
+			tc->tc_quality = -FIRE_PERF_CNT_QLTY;
 		tc_init(tc);
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107251901.p6PJ1aaC072477>