Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Feb 2005 17:11:27 GMT
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 72015 for review
Message-ID:  <200502271711.j1RHBRHA018478@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=72015

Change 72015 by rwatson@rwatson_paprika on 2005/02/27 17:10:41

	Further integration of netperf_socket:
	
	- cpufreq locking.

Affected files ...

.. //depot/projects/netperf_socket/sys/conf/files#60 integrate
.. //depot/projects/netperf_socket/sys/conf/options.arm#4 integrate
.. //depot/projects/netperf_socket/sys/dev/acpica/acpi_perf.c#2 integrate
.. //depot/projects/netperf_socket/sys/dev/cpufreq/ichss.c#2 integrate
.. //depot/projects/netperf_socket/sys/dev/fxp/if_fxp.c#17 integrate
.. //depot/projects/netperf_socket/sys/dev/zs/zs_sbus.c#5 delete
.. //depot/projects/netperf_socket/sys/i386/cpufreq/est.c#2 integrate
.. //depot/projects/netperf_socket/sys/i386/cpufreq/p4tcc.c#2 integrate
.. //depot/projects/netperf_socket/sys/kern/kern_cpu.c#2 integrate
.. //depot/projects/netperf_socket/sys/netinet/ip_carp.c#2 integrate
.. //depot/projects/netperf_socket/sys/pci/agp_ali.c#8 integrate
.. //depot/projects/netperf_socket/sys/sparc64/conf/GENERIC#18 integrate
.. //depot/projects/netperf_socket/sys/sparc64/conf/NOTES#11 integrate
.. //depot/projects/netperf_socket/sys/sys/param.h#34 integrate

Differences ...

==== //depot/projects/netperf_socket/sys/conf/files#60 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/conf/files,v 1.1000 2005/02/26 00:25:43 marius Exp $
+# $FreeBSD: src/sys/conf/files,v 1.1001 2005/02/27 15:23:57 marius Exp $
 #
 # The long compile-with and dependency lines are required because of
 # limitations in config: backslash-newline doesn't work in strings, and
@@ -881,8 +881,6 @@
 dev/xe/if_xe.c			optional xe
 dev/xe/if_xe_pccard.c		optional xe pccard
 dev/zs/zs.c			optional zs
-dev/zs/zs_sbus.c		optional zs fhc
-dev/zs/zs_sbus.c		optional zs sbus
 fs/deadfs/dead_vnops.c		standard
 fs/devfs/devfs_devs.c		standard
 fs/devfs/devfs_rule.c		standard

==== //depot/projects/netperf_socket/sys/conf/options.arm#4 (text+ko) ====

@@ -1,6 +1,7 @@
-#$FreeBSD: src/sys/conf/options.arm,v 1.3 2004/11/10 22:08:27 cognet Exp $
+#$FreeBSD: src/sys/conf/options.arm,v 1.4 2005/02/26 22:41:07 cognet Exp $
 ARM32_NEW_VM_LAYOUT	opt_vm.h
 ARM9_CACHE_WRITE_THROUGH	opt_global.h
+ARM_CACHE_LOCK_ENABLE	opt_global.h
 ARMFPE			opt_global.h
 CPU_SA1100		opt_global.h
 CPU_SA1110		opt_global.h

==== //depot/projects/netperf_socket/sys/dev/acpica/acpi_perf.c#2 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_perf.c,v 1.12 2005/02/22 06:34:53 njl Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_perf.c,v 1.14 2005/02/27 02:43:02 njl Exp $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -152,6 +152,11 @@
 		return;
 	if (ACPI_FAILURE(AcpiEvaluateObject(handle, "_PSS", NULL, NULL)))
 		return;
+
+	/*
+	 * Add a child to every CPU that has the right methods.  In future
+	 * versions of the ACPI spec, CPUs can have different settings.
+	 */
 	if (BUS_ADD_CHILD(parent, 0, "acpi_perf", -1) == NULL)
 		device_printf(parent, "add acpi_perf child failed\n");
 }
@@ -211,8 +216,9 @@
 	sc->px_curr_state = CPUFREQ_VAL_UNKNOWN;
 	if (acpi_perf_evaluate(dev) != 0)
 		return (ENXIO);
-	cpufreq_register(dev);
 	AcpiOsQueueForExecution(OSD_PRIORITY_LO, acpi_px_startup, NULL);
+	if (!sc->info_only)
+		cpufreq_register(dev);
 
 	return (0);
 }

==== //depot/projects/netperf_socket/sys/dev/cpufreq/ichss.c#2 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/cpufreq/ichss.c,v 1.7 2005/02/22 06:31:45 njl Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/cpufreq/ichss.c,v 1.8 2005/02/27 02:43:02 njl Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -166,7 +166,11 @@
 	if (devclass_get_device(ichss_devclass, 0))
 		return (ENXIO);
 
-	/* Add a child under the CPU parent. */
+	/*
+	 * Add a child under the CPU parent.  It appears that ICH SpeedStep
+	 * only requires a single CPU to set the value (since the chipset
+	 * is shared by all CPUs.)  Thus, we only add a child to cpu 0.
+	 */
 	parent = devclass_get_device(devclass_find("cpu"), 0);
 	KASSERT(parent != NULL, ("cpu parent is NULL"));
 	child = BUS_ADD_CHILD(parent, 0, "ichss", 0);

==== //depot/projects/netperf_socket/sys/dev/fxp/if_fxp.c#17 (text+ko) ====

@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/fxp/if_fxp.c,v 1.223 2005/02/15 17:47:57 ru Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/fxp/if_fxp.c,v 1.224 2005/02/27 15:12:50 mux Exp $");
 
 /*
  * Intel EtherExpress Pro/100B PCI Fast Ethernet driver
@@ -449,10 +449,19 @@
 	fxp_autosize_eeprom(sc);
 
 	/*
+	 * Find out the chip revision; lump all 82557 revs together.
+	 */
+	fxp_read_eeprom(sc, &data, 5, 1);
+	if ((data >> 8) == 1)
+		sc->revision = FXP_REV_82557;
+	else
+		sc->revision = pci_get_revid(dev);
+
+	/*
 	 * Determine whether we must use the 503 serial interface.
 	 */
 	fxp_read_eeprom(sc, &data, 6, 1);
-	if (sc->revision <= FXP_REV_82557 && (data & FXP_PHY_DEVICE_MASK) != 0
+	if (sc->revision == FXP_REV_82557 && (data & FXP_PHY_DEVICE_MASK) != 0
 	    && (data & FXP_PHY_SERIAL_ONLY))
 		sc->flags |= FXP_FLAG_SERIAL_MEDIA;
 
@@ -490,15 +499,6 @@
 	sc->rnr = 0;
 
 	/*
-	 * Find out the chip revision; lump all 82557 revs together.
-	 */
-	fxp_read_eeprom(sc, &data, 5, 1);
-	if ((data >> 8) == 1)
-		sc->revision = FXP_REV_82557;
-	else
-		sc->revision = pci_get_revid(dev);
-
-	/*
 	 * Enable workarounds for certain chip revision deficiencies.
 	 *
 	 * Systems based on the ICH2/ICH2-M chip from Intel, and possibly

==== //depot/projects/netperf_socket/sys/i386/cpufreq/est.c#2 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/cpufreq/est.c,v 1.3 2005/02/24 20:20:11 njl Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/cpufreq/est.c,v 1.4 2005/02/27 02:43:02 njl Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -582,6 +582,10 @@
 	if ((p[2] & 0x80) == 0)
 		return;
 
+	/*
+	 * We add a child for each CPU since settings must be performed
+	 * on each CPU in the SMP case.
+	 */
 	if (BUS_ADD_CHILD(parent, 0, "est", -1) == NULL)
 		device_printf(parent, "add est child failed\n");
 }

==== //depot/projects/netperf_socket/sys/i386/cpufreq/p4tcc.c#2 (text+ko) ====

@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/cpufreq/p4tcc.c,v 1.9 2005/02/23 16:42:56 njl Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/cpufreq/p4tcc.c,v 1.10 2005/02/27 02:43:02 njl Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -102,6 +102,17 @@
 
 	if ((cpu_feature & (CPUID_ACPI | CPUID_TM)) != (CPUID_ACPI | CPUID_TM))
 		return;
+
+	/* Make sure we're not being doubly invoked. */
+	if (device_find_child(parent, "p4tcc", -1) != NULL)
+		return;
+
+	/*
+	 * We attach a p4tcc child for every CPU since settings need to
+	 * be performed on every CPU in the SMP case.  See section 13.15.3
+	 * of the IA32 Intel Architecture Software Developer's Manual,
+	 * Volume 3, for more info.
+	 */
 	if (BUS_ADD_CHILD(parent, 0, "p4tcc", -1) == NULL)
 		device_printf(parent, "add p4tcc child failed\n");
 }

==== //depot/projects/netperf_socket/sys/kern/kern_cpu.c#2 (text+ko) ====

@@ -25,13 +25,14 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_cpu.c,v 1.10 2005/02/24 20:21:41 njl Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_cpu.c,v 1.12 2005/02/27 01:34:08 njl Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
 #include <sys/cpu.h>
 #include <sys/eventhandler.h>
 #include <sys/kernel.h>
+#include <sys/lock.h>
 #include <sys/malloc.h>
 #include <sys/module.h>
 #include <sys/proc.h>
@@ -40,6 +41,7 @@
 #include <sys/sysctl.h>
 #include <sys/systm.h>
 #include <sys/sbuf.h>
+#include <sys/sx.h>
 #include <sys/timetc.h>
 
 #include "cpufreq_if.h"
@@ -56,6 +58,7 @@
 #define CF_MAX_LEVELS	64
 
 struct cpufreq_softc {
+	struct sx			lock;
 	struct cf_level			curr_level;
 	int				curr_priority;
 	struct cf_level			saved_level;
@@ -75,6 +78,11 @@
 
 TAILQ_HEAD(cf_setting_lst, cf_setting_array);
 
+#define CF_MTX_INIT(x)		sx_init((x), "cpufreq lock")
+#define CF_MTX_LOCK(x)		sx_xlock((x))
+#define CF_MTX_UNLOCK(x)	sx_xunlock((x))
+#define CF_MTX_ASSERT(x)	sx_assert((x), SX_XLOCKED)
+
 static int	cpufreq_attach(device_t dev);
 static int	cpufreq_detach(device_t dev);
 static void	cpufreq_evaluate(void *arg);
@@ -109,7 +117,13 @@
 static devclass_t cpufreq_dc;
 DRIVER_MODULE(cpufreq, cpu, cpufreq_driver, cpufreq_dc, 0, 0);
 
-static eventhandler_tag cf_ev_tag;
+static eventhandler_tag	cf_ev_tag;
+
+static int		cf_lowest_freq;
+TUNABLE_INT("debug.cpufreq.lowest", &cf_lowest_freq);
+SYSCTL_NODE(_debug, OID_AUTO, cpufreq, CTLFLAG_RD, NULL, "cpufreq debugging");
+SYSCTL_INT(_debug_cpufreq, OID_AUTO, lowest, CTLFLAG_RW, &cf_lowest_freq, 1,
+    "Don't provide levels below this frequency.");
 
 static int
 cpufreq_attach(device_t dev)
@@ -123,6 +137,7 @@
 	sc->dev = dev;
 	sysctl_ctx_init(&sc->sysctl_ctx);
 	TAILQ_INIT(&sc->all_levels);
+	CF_MTX_INIT(&sc->lock);
 	sc->curr_level.total_set.freq = CPUFREQ_VAL_UNKNOWN;
 	sc->saved_level.total_set.freq = CPUFREQ_VAL_UNKNOWN;
 	sc->max_mhz = CPUFREQ_VAL_UNKNOWN;
@@ -182,6 +197,8 @@
 	int cpu_id, error, i;
 
 	sc = device_get_softc(dev);
+	error = 0;
+	set = NULL;
 
 	/*
 	 * Check that the TSC isn't being used as a timecounter.
@@ -197,18 +214,29 @@
 	 * If they did specify one, but the requested level has a lower
 	 * priority, don't allow the new level right now.
 	 */
+	CF_MTX_LOCK(&sc->lock);
 	if (level == NULL) {
 		if (sc->saved_level.total_set.freq != CPUFREQ_VAL_UNKNOWN) {
 			level = &sc->saved_level;
 			priority = sc->saved_priority;
-		} else
-			return (ENXIO);
-	} else if (priority < sc->curr_priority)
-		return (EPERM);
+		} else {
+			error = ENXIO;
+			goto out;
+		}
+	} else if (priority < sc->curr_priority) {
+		error = EPERM;
+		goto out;
+	}
+
+	/* Reject levels that are below our specified threshold. */
+	if (level->total_set.freq <= cf_lowest_freq) {
+		error = EINVAL;
+		goto out;
+	}
 
 	/* If already at this level, just return. */
 	if (CPUFREQ_CMP(sc->curr_level.total_set.freq, level->total_set.freq))
-		return (0);
+		goto out;
 
 	/* First, set the absolute frequency via its driver. */
 	set = &level->abs_set;
@@ -287,7 +315,8 @@
 	error = 0;
 
 out:
-	if (error)
+	CF_MTX_UNLOCK(&sc->lock);
+	if (error && set)
 		device_printf(set->dev, "set freq failed, err %d\n", error);
 	return (error);
 }
@@ -304,12 +333,15 @@
 	uint64_t rate;
 
 	sc = device_get_softc(dev);
-	curr_set = &sc->curr_level.total_set;
+	error = 0;
 	levels = NULL;
 
 	/* If we already know the current frequency, we're done. */
+	CF_MTX_LOCK(&sc->lock);
+	curr_set = &sc->curr_level.total_set;
 	if (curr_set->freq != CPUFREQ_VAL_UNKNOWN)
 		goto out;
+	CF_MTX_UNLOCK(&sc->lock);
 
 	/*
 	 * We need to figure out the current level.  Loop through every
@@ -324,11 +356,24 @@
 	if (error) {
 		if (error == E2BIG)
 			printf("cpufreq: need to increase CF_MAX_LEVELS\n");
-		goto out;
+		free(levels, M_TEMP);
+		return (error);
 	}
 	error = device_get_children(device_get_parent(dev), &devs, &numdevs);
-	if (error)
-		goto out;
+	if (error) {
+		free(levels, M_TEMP);
+		return (error);
+	}
+
+	/*
+	 * Reacquire the lock and search for the given level.
+	 *
+	 * XXX Note: this is not quite right since we really need to go
+	 * through each level and compare both absolute and relative
+	 * settings for each driver in the system before making a match.
+	 * The estimation code below catches this case though.
+	 */
+	CF_MTX_LOCK(&sc->lock);
 	for (i = 0; i < numdevs && curr_set->freq == CPUFREQ_VAL_UNKNOWN; i++) {
 		if (!device_is_attached(devs[i]))
 			continue;
@@ -365,10 +410,13 @@
 	}
 
 out:
+	if (error == 0)
+		*level = sc->curr_level;
+
+	CF_MTX_UNLOCK(&sc->lock);
 	if (levels)
 		free(levels, M_TEMP);
-	*level = sc->curr_level;
-	return (0);
+	return (error);
 }
 
 static int
@@ -399,6 +447,7 @@
 	}
 
 	/* Get settings from all cpufreq drivers. */
+	CF_MTX_LOCK(&sc->lock);
 	for (i = 0; i < numdevs; i++) {
 		/* Skip devices that aren't ready. */
 		if (!device_is_attached(devs[i]))
@@ -474,6 +523,12 @@
 	/* Finally, output the list of levels. */
 	i = 0;
 	TAILQ_FOREACH(lev, &sc->all_levels, link) {
+		/* Skip levels that have a frequency that is too low. */
+		if (lev->total_set.freq <= cf_lowest_freq) {
+			sc->all_count--;
+			continue;
+		}
+
 		levels[i] = *lev;
 		i++;
 	}
@@ -486,11 +541,13 @@
 		TAILQ_REMOVE(&sc->all_levels, lev, link);
 		free(lev, M_TEMP);
 	}
+	sc->all_count = 0;
+
+	CF_MTX_UNLOCK(&sc->lock);
 	while ((set_arr = TAILQ_FIRST(&rel_sets)) != NULL) {
 		TAILQ_REMOVE(&rel_sets, set_arr, link);
 		free(set_arr, M_TEMP);
 	}
-	sc->all_count = 0;
 	free(devs, M_TEMP);
 	free(sets, M_TEMP);
 	return (error);
@@ -508,6 +565,8 @@
 	struct cf_level *level, *search;
 	int i;
 
+	CF_MTX_ASSERT(&sc->lock);
+
 	list = &sc->all_levels;
 	for (i = 0; i < count; i++) {
 		level = malloc(sizeof(*level), M_TEMP, M_NOWAIT | M_ZERO);
@@ -543,6 +602,8 @@
 	struct cf_setting *set;
 	int i;
 
+	CF_MTX_ASSERT(&sc->lock);
+
 	TAILQ_FOREACH(search, &sc->all_levels, link) {
 		/* Skip this level if we've already modified it. */
 		for (i = 0; i < search->rel_count; i++) {
@@ -592,6 +653,8 @@
 	struct cf_setting *fill_set, *itr_set;
 	int i;
 
+	CF_MTX_ASSERT(&sc->lock);
+
 	/*
 	 * Create a new level, copy it from the old one, and update the
 	 * total frequency and power by the percentage specified in the

==== //depot/projects/netperf_socket/sys/netinet/ip_carp.c#2 (text+ko) ====

@@ -1,4 +1,4 @@
-/* 	$FreeBSD: src/sys/netinet/ip_carp.c,v 1.10 2005/02/26 13:55:07 glebius Exp $ */
+/* 	$FreeBSD: src/sys/netinet/ip_carp.c,v 1.11 2005/02/27 11:32:26 mlaier Exp $ */
 
 /*
  * Copyright (c) 2002 Michael Shalayeff. All rights reserved.
@@ -1118,7 +1118,7 @@
 }
 
 #ifdef INET6
-static struct ifaddr *
+struct ifaddr *
 carp_iamatch6(void *v, struct in6_addr *taddr)
 {
 	struct carp_if *cif = v;
@@ -1142,7 +1142,7 @@
 	return (NULL);
 }
 
-static void *
+void *
 carp_macmatch6(void *v, struct mbuf *m, const struct in6_addr *taddr)
 {
 	struct m_tag *mtag;

==== //depot/projects/netperf_socket/sys/pci/agp_ali.c#8 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/pci/agp_ali.c,v 1.16 2005/02/24 21:32:55 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/pci/agp_ali.c,v 1.17 2005/02/27 13:05:34 cognet Exp $");
 
 #include "opt_bus.h"
 
@@ -65,6 +65,8 @@
 		return NULL;
 
 	switch (pci_get_devid(dev)) {
+	case 0x167110b9:
+		return ("Ali M1671 host to AGP bridge");
 	case 0x154110b9:
 		return ("Ali M1541 host to AGP bridge");
 	case 0x162110b9:

==== //depot/projects/netperf_socket/sys/sparc64/conf/GENERIC#18 (text+ko) ====

@@ -18,7 +18,7 @@
 #
 # For hardware specific information check HARDWARE.TXT
 #
-# $FreeBSD: src/sys/sparc64/conf/GENERIC,v 1.88 2005/01/30 09:27:49 marcel Exp $
+# $FreeBSD: src/sys/sparc64/conf/GENERIC,v 1.89 2005/02/27 15:23:58 marius Exp $
 
 machine		sparc64
 cpu		SUN4U
@@ -136,7 +136,6 @@
 
 # Serial (COM) ports
 #device		sab		# Siemens SAB82532 based serial ports
-#device		zs		# Zilog 8530 based serial ports
 device		uart		# Multi-uart driver
 device		puc		# Multi-channel uarts
 

==== //depot/projects/netperf_socket/sys/sparc64/conf/NOTES#11 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/sys/sparc64/conf/NOTES,v 1.15 2005/01/14 13:16:13 ru Exp $
+# $FreeBSD: src/sys/sparc64/conf/NOTES,v 1.16 2005/02/27 15:23:58 marius Exp $
 #
 # This file contains machine dependent kernel configuration notes.  For
 # machine independent notes, look in /sys/conf/NOTES.
@@ -56,7 +56,6 @@
 option 		OFWCONS_POLL_HZ=4 # 20 or more works best on Ultra2
 
 device		sab		# Siemens SAB82532 based serial ports
-device		zs		# Zilog 8530 based serial ports
 
 
 #####################################################################

==== //depot/projects/netperf_socket/sys/sys/param.h#34 (text+ko) ====

@@ -32,7 +32,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)param.h	8.3 (Berkeley) 4/4/95
- * $FreeBSD: src/sys/sys/param.h,v 1.227 2005/02/25 19:46:41 brooks Exp $
+ * $FreeBSD: src/sys/sys/param.h,v 1.228 2005/02/26 21:47:54 ru Exp $
  */
 
 #ifndef _SYS_PARAM_H_
@@ -57,7 +57,7 @@
  *		is created, otherwise 1.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 600015	/* Master, propagated to newvers */
+#define __FreeBSD_version 600016	/* Master, propagated to newvers */
 
 #ifndef LOCORE
 #include <sys/types.h>



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