# Error "timecounter TSC must not be in use when changing frequencies; change denied"



## cosmos (Jan 22, 2009)

Hello all,

I had a Pentium-4 based system running FreeBSD 7.0. 7.0 when installed when it was released; till 7.1 I did not perform any cvsup upgrade operations.

On 7.0 I had cpufreq enabled in kernel:

```
device cpufreq
```

Additionally, powerd was enabled in /etc/rc.conf:

```
powerd_enable="YES"
```

With those in place, my system cpu succesfully changed frequency, according to system load. Some dev.cpu variables are listed below:

```
dev.cpu.0.%desc: ACPI CPU
dev.cpu.0.%driver: cpu
dev.cpu.0.%location: handle=\_PR_.CPU0
dev.cpu.0.%pnpinfo: _HID=none _UID=0
dev.cpu.0.%parent: acpi0
dev.cpu.0.freq: 374
dev.cpu.0.freq_levels: 2999/-1 2624/-1 2249/-1 1874/-1 1499/-1 1124/-1 749/-1 374/-1
dev.cpu.0.cx_supported: C1/0
dev.cpu.0.cx_lowest: C1
dev.cpu.0.cx_usage: 100.00%
```

Compared to the kernel I had in place, the only changes I did are the additions of the following lines:

```
options 	SCTP	# Had it disabled in 7.0
```

Finally some more info from the running system:

```
# uname -a
mail[/root]# uname -a
FreeBSD my.rig 7.1-RELEASE-p2 FreeBSD 7.1-RELEASE-p2 #1: Wed Jan 21 08:42:14 EET 2009     root@my.rig:/usr/obj/usr/src/sys/FIRST  i386

# dmesg
Copyright (c) 1992-2009 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 7.1-RELEASE-p2 #1: Wed Jan 21 08:42:14 EET 2009
    root@my.rig:/usr/obj/usr/src/sys/FIRST
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: Intel(R) Pentium(R) 4 CPU 3.00GHz (3014.51-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0xf34  Stepping = 4
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0x441d<SSE3,DTES64,MON,DS_CPL,CNXT-ID,xTPR>
  Logical CPUs per core: 2
real memory  = 1073676288 (1023 MB)
avail memory = 1041489920 (993 MB)
ACPI APIC Table: <GBT    AWRDACPI>
ioapic0: Changing APIC ID to 2
ioapic0 <Version 2.0> irqs 0-23 on motherboard
kbd1 at kbdmux0
acpi0: <GBT AWRDACPI> on motherboard
acpi0: [ITHREAD]
acpi0: Power Button (fixed)
acpi0: reservation of 0, a0000 (3) failed
acpi0: reservation of 100000, 3fef0000 (3) failed
acpi_button0: <Power Button> on acpi0
acpi_button1: <Sleep Button> on acpi0
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff,0x1000-0x10bf on acpi0
pci0: <ACPI PCI bus> on pcib0
agp0: <Intel 82865 host to AGP bridge> on hostb0
pcib1: <PCI-PCI bridge> at device 1.0 on pci0
pci1: <PCI bus> on pcib1
vgapci0: <VGA-compatible display> mem 0xf8000000-0xf8ffffff,0xf0000000-0xf7ffffff irq 16 at device 0.0 on pci1
pci0: <serial bus, USB> at device 29.0 (no driver attached)
pci0: <serial bus, USB> at device 29.1 (no driver attached)
pci0: <serial bus, USB> at device 29.2 (no driver attached)
pci0: <serial bus, USB> at device 29.3 (no driver attached)
pci0: <serial bus, USB> at device 29.7 (no driver attached)
pcib2: <ACPI PCI-PCI bridge> at device 30.0 on pci0
pci2: <ACPI PCI bus> on pcib2
skc0: <Marvell Gigabit Ethernet> port 0x9000-0x90ff mem 0xfb000000-0xfb003fff irq 20 at device 9.0 on pci2
skc0: Marvell Yukon Lite Gigabit Ethernet rev. A3(0x7)
sk0: <Marvell Semiconductor, Inc. Yukon> on skc0
sk0: Ethernet address: 00:0f:ea:5b:03:39
miibus0: <MII bus> on sk0
e1000phy0: <Marvell 88E1011 Gigabit PHY> PHY 0 on miibus0
e1000phy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseTX-FDX, auto
skc0: [ITHREAD]
isab0: <PCI-ISA bridge> at device 31.0 on pci0
isa0: <ISA bus> on isab0
atapci0: <Intel ICH5 UDMA100 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376,0xf000-0xf00f at device 31.1 on pci0
ata0: <ATA channel 0> on atapci0
ata0: [ITHREAD]
ata1: <ATA channel 1> on atapci0
ata1: [ITHREAD]
pci0: <serial bus, SMBus> at device 31.3 (no driver attached)
acpi_tz0: <Thermal Zone> on acpi0
sio0: <16550A-compatible COM port> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
sio0: type 16550A
sio0: [FILTER]
atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
atkbd0: <AT Keyboard> irq 1 on atkbdc0
kbd0 at atkbd0
atkbd0: [GIANT-LOCKED]
atkbd0: [ITHREAD]
cpu0: <ACPI CPU> on acpi0
p4tcc0: <CPU Frequency Thermal Control> on cpu0
pmtimer0 on isa0
orm0: <ISA Option ROM> at iomem 0xc0000-0xcf7ff pnpid ORM0000 on isa0
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
sio1: configured irq 3 not in bitmap of probed irqs 0
sio1: port may not be enabled
Timecounter "TSC" frequency 3014505900 Hz quality 800
Timecounters tick every 1.000 msec
ad0: 19092MB <WDC WD200BB-00CFC0 02.08B02> at ata0-master UDMA100
acd0: CDRW <SONY CD-RW CRX230ED/4YS1> at ata1-master UDMA33
Trying to mount root from ufs:/dev/ad0s1a
sk0: link state changed to UP
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
timecounter TSC must not be in use when changing frequencies; change denied
```

And in the last lines lies my problem. After the switch to 7.1, my system can not switch operating frequencies. The "timecounter TSC..." errors fill up my system logs.


I can see that this line is produced by the tsc.c source file. From the same source code it seems that when the timecounter is TSC, frequency changes (by cpufreq for example) are prohibited. What buffles is me is why this used to work perfectly in 7.0! Was it that another clock source was used back then? BTW, ntpd had been running since the days this system had FreeBSD 4.0 on it... :\

Any information provided will be appreciated. 

BTW, some sysctl values that might be useful:

```
dev.cpu.0.%desc: ACPI CPU
dev.cpu.0.%driver: cpu
dev.cpu.0.%location: handle=\_PR_.CPU0
dev.cpu.0.%pnpinfo: _HID=none _UID=0
dev.cpu.0.%parent: acpi0
dev.cpu.0.freq: 2999
dev.cpu.0.freq_levels: 2999/-1 2624/-1 2249/-1 1874/-1 1499/-1 1124/-1 749/-1 374/-1
dev.cpu.0.cx_supported: C1/0
dev.cpu.0.cx_lowest: C1
dev.cpu.0.cx_usage: 100.00%

kern.timecounter.tick: 1
kern.timecounter.choice: TSC(800) i8254(0) dummy(-1000000)
kern.timecounter.hardware: TSC
kern.timecounter.nsetclock: 3
kern.timecounter.ngetmicrotime: 552744
kern.timecounter.ngetnanotime: 1
kern.timecounter.ngetbintime: 0
kern.timecounter.ngetmicrouptime: 9863325
kern.timecounter.ngetnanouptime: 54953
kern.timecounter.ngetbinuptime: 356852
kern.timecounter.nmicrotime: 1280093
kern.timecounter.nnanotime: 20733
kern.timecounter.nbintime: 1324404
kern.timecounter.nmicrouptime: 5337
kern.timecounter.nnanouptime: 3473
kern.timecounter.nbinuptime: 2786031
kern.timecounter.stepwarnings: 0
kern.timecounter.tc.i8254.mask: 65535
kern.timecounter.tc.i8254.counter: 20726
kern.timecounter.tc.i8254.frequency: 1193182
kern.timecounter.tc.i8254.quality: 0
kern.timecounter.tc.TSC.mask: 4294967295
kern.timecounter.tc.TSC.counter: 2941560308
kern.timecounter.tc.TSC.frequency: 3014505900
kern.timecounter.tc.TSC.quality: 800

dev.acpi.0.%desc: GBT AWRDACPI
dev.acpi.0.%driver: acpi
dev.acpi.0.%parent: nexus0
```


----------



## cosmos (Jan 22, 2009)

```
#
# GENERIC -- Generic kernel configuration file for FreeBSD/i386
#
# For more information on this file, please read the handbook section on
# Kernel Configuration Files:
#
#    [url]http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html[/url]
#
# The handbook is also available locally in /usr/share/doc/handbook
# if you've installed the doc distribution, otherwise always see the
# FreeBSD World Wide Web server ([url]http://www.FreeBSD.org/[/url]) for the
# latest information.
#
# An exhaustive list of options and more detailed explanations of the
# device lines is also present in the ../../conf/NOTES and NOTES files.
# If you are in doubt as to the purpose or necessity of a line, check first
# in NOTES.
#
# $FreeBSD: src/sys/i386/conf/GENERIC,v 1.474.2.15.2.1 2008/11/25 02:59:29 kensmith Exp $

machine		i386
cpu		I686_CPU
ident		FIRST

# To statically compile in device wiring instead of /boot/device.hints
#hints		"GENERIC.hints"		# Default places to look for devices.

#makeoptions	DEBUG=-g		# Build kernel with gdb(1) debug symbols

options 	SCHED_4BSD		# 4BSD scheduler
options 	PREEMPTION		# Enable kernel thread preemption
options 	INET			# InterNETworking
# options 	INET6			# IPv6 communications protocols
options 	SCTP			# Stream Control Transmission Protocol
options 	FFS			# Berkeley Fast Filesystem
options 	SOFTUPDATES		# Enable FFS soft updates support
options 	UFS_ACL			# Support for access control lists
options 	UFS_DIRHASH		# Improve performance on big directories
options 	UFS_GJOURNAL		# Enable gjournal-based UFS journaling
options 	MD_ROOT			# MD is a potential root device
options 	MSDOSFS			# MSDOS Filesystem
options 	CD9660			# ISO 9660 Filesystem
options 	PROCFS			# Process filesystem (requires PSEUDOFS)
options 	PSEUDOFS		# Pseudo-filesystem framework
options 	GEOM_PART_GPT		# GUID Partition Tables.
options 	GEOM_LABEL		# Provides labelization
options 	COMPAT_43TTY		# BSD 4.3 TTY compat [KEEP THIS!]
options 	COMPAT_FREEBSD4		# Compatible with FreeBSD4
options 	COMPAT_FREEBSD5		# Compatible with FreeBSD5
options 	COMPAT_FREEBSD6		# Compatible with FreeBSD6
options 	SCSI_DELAY=5000		# Delay (in ms) before probing SCSI
options 	KTRACE			# ktrace(1) support
options 	STACK			# stack(9) support
options 	SYSVSHM			# SYSV-style shared memory
options 	SYSVMSG			# SYSV-style message queues
options 	SYSVSEM			# SYSV-style semaphores
options 	_KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
options 	KBD_INSTALL_CDEV	# install a CDEV entry in /dev
options 	ADAPTIVE_GIANT		# Giant mutex is adaptive.
options 	STOP_NMI		# Stop CPUS using NMI instead of IPI
options 	AUDIT			# Security event auditing
#options 	KDTRACE_HOOKS		# Kernel DTrace hooks

# To make an SMP kernel, the next two lines are needed
#options 	SMP			# Symmetric MultiProcessor Kernel
device		apic			# I/O APIC

# CPU frequency control
device		cpufreq

# Bus support.
device		pci

# Floppy drives
device		fdc

# ATA and ATAPI devices
device		ata
device		atadisk			# ATA disk drives
device		atapicd			# ATAPI CDROM drives
device		atapifd			# ATAPI floppy drives
device		atapist			# ATAPI tape drives
options 	ATA_STATIC_ID		#Static device numbering

# atkbdc0 controls both the keyboard and the PS/2 mouse
device		atkbdc		# AT keyboard controller
device		atkbd		# AT keyboard
device		psm		# PS/2 mouse

device		kbdmux		# keyboard multiplexer

device		vga		# VGA video card driver

device		splash		# Splash screen and screen saver support

# syscons is the default console driver, resembling an SCO console
device		sc

device		agp		# support several AGP chipsets

# Power management support (see NOTES for more options)
#device		apm
# Add suspend/resume support for the i8254.
device		pmtimer

# PCI Ethernet NICs that use the common MII bus controller code.
# NOTE: Be sure to keep the 'device miibus' line in order to use these NICs!
device		miibus		# MII bus support
device		rl		# RealTek 8129/8139
device		sk		# SysKonnect SK-984x & SK-982x gigabit Ethernet

# Pseudo devices.
device		loop		# Network loopback
device		random		# Entropy device
device		ether		# Ethernet support
device		pty		# Pseudo-ttys (telnet etc)
device		md		# Memory "disks"

# The `bpf' device enables the Berkeley Packet Filter.
# Be aware of the administrative consequences of enabling this!
# Note that 'bpf' is required for DHCP.
device		bpf		# Berkeley packet filter

# USB support
#device		uhci		# UHCI PCI->USB interface
device		ohci		# OHCI PCI->USB interface
device		usb		# USB Bus (required)
#device		udbp		# USB Double Bulk Pipe devices
device		ugen		# Generic
device		uhid		# "Human Interface Devices"
device		ums		# Mouse

options         SC_DISABLE_REBOOT
device 		sio
```


----------



## cosmos (Jan 22, 2009)

Alas, the forum has a character limit per post so I split info, but in the process I failed to mention why this problem arised. And I can't edit my first post. So I'm writing it here:

"In the last few days I've upgraded to 7.1. On 7.1 I did not switch to the new ULE scheduler, I sticked with the old one. Also note that the SMP option is missing, as well as a lot of networking options and the like." (Note the current 7.1 kernel config is in the previous post, above)"


----------



## cosmos (Jan 27, 2009)

(bump)

Any ideas on the problem? Someone?


----------



## Minifig (Jul 28, 2009)

I'm having this same problem... :/


----------



## Minifig (Jul 28, 2009)

I am using PCBSD with KDE, if that means anything.
Also, the error "timecounter TSC must not be in use when changing frequencies; change denied" appears in the terminal after I click the log out button. I just installed gnome, and was wanting to try it.  Is there a way I can fix this problem, or another way to switch to using gnome?


----------



## Minifig (Jul 29, 2009)

Oops, I just realized that this was from January, not July. :\


----------



## ncpnc (Sep 20, 2010)

Hello there 
I know this thread is over a year old, but I just cought the same problem and I found a solution. Original thread author probably don't need it anymore, but google showed me this topic at first place, so maybe someone else will find my solution useful.

At the beginning check output of:


```
# sysctl kern.timecounter.choice
```

It will show you timecounters available on this machine.
In addition


```
sysctl kern.timecounter.hardware
```

will show you which one of them FreeBSD choosed to use. By default it should be the one with highest number between brackets (higher number = higher TC quality). Here's example output of my system:


```
kern.timecounter.choice: TSC(800) i8254(0) dummy(-1000000)
kern.timecounter.hardware: TSC
```

If TSC has highest number and we want to use powerd on the same machine, we should manually force different choice, because TSC seems to be based on fixed CPU frequency. Probably best choice will be the second one with highest number, i8254 in example above.

So whole solution in this case is:


```
# sysctl kern.timecounter.hardware=i8254
# echo "kern.timecounter.hardware=i8254" >> /boot/loader.conf
```

Now powerd works like a charm.

p.s. With low quality rated timecounter you should also consider running ntpd besides powerd.


----------



## cosmos (Sep 22, 2010)

Thx for the info. Indd, I am no longer experiencing the issue for some reason, however I've kept your post for future reference


----------



## aLiEnMuNkEe (Oct 29, 2010)

Thank you for this info. It has worked a treat for me also.

If I could ask a question please [newbie here]: when I reboot the server the error comes back up. Is there a way I can hardcode this in or get it write during system startup at all?


----------



## richardpl (Oct 30, 2010)

`# echo "kern.timecounter.hardware=i8254" >> /boot/loader.conf`


----------



## aLiEnMuNkEe (Nov 2, 2010)

richardpl said:
			
		

> `# echo "kern.timecounter.hardware=i8254" >> /boot/loader.conf`



Thanks but ncpnc has already posted that information.

I have the embedded installation, as far as I can see it needs to go to /cf/boot/loader.conf but when I add the value to that file it is not liked at all.


----------



## fire (Jan 30, 2011)

Hi, sorry to revive an old topic, but I am having the same issue. I can temporarily solve it using the following command (through the WebGUI):
`sysctl kern.timecounter.hardware=i8254`

This solves the issue, and then allows the CPU frequency to drop (from 2900Mhz to 730Mhz). I have manually edited and saved the /cf/boot/loader.conf (as I am running embedded) and added the line: 
	
	



```
kern.timecounter.hardware=i8254
```

I was hoping this solves the issue, so that the error doesnt come up every time the NAS is booted. But instead, nothing happens.. I also noticed if I turn off "power daemon" in advanced settings, the error doesnt come up (because its not trying to change the frequency). Am I missing something in getting this working?


----------



## fire (Jan 30, 2011)

Never mind, I worked it out.. Here's how:

I had to place the code:

```
kern.timecounter.hardware=i8254
```
 in /etc/sysctl.conf.

To do this (as I am running FreeNAS.. go to "System --> Advanced --> sysctl.conf, and add in the code there.

Works a charm on embedded installations; and now my 2.93GHZ Celeron clocks down to 700Mhz pretty much all the time. CPU temps have dropped 2 degrees too (passive cooling)


----------

