kern_cpu.c (167905) | kern_cpu.c (170307) |
---|---|
1/*- 2 * Copyright (c) 2004-2007 Nate Lawson (SDG) 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2004-2007 Nate Lawson (SDG) 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/kern/kern_cpu.c 167905 2007-03-26 18:03:29Z njl $"); | 28__FBSDID("$FreeBSD: head/sys/kern/kern_cpu.c 170307 2007-06-05 00:00:57Z jeff $"); |
29 30#include <sys/param.h> 31#include <sys/bus.h> 32#include <sys/cpu.h> 33#include <sys/eventhandler.h> 34#include <sys/kernel.h> 35#include <sys/lock.h> 36#include <sys/malloc.h> --- 256 unchanged lines hidden (view full) --- 293 error = ENXIO; 294 goto out; 295 } 296 297 /* Bind to the target CPU before switching, if necessary. */ 298 cpu_id = PCPU_GET(cpuid); 299 pc = cpu_get_pcpu(set->dev); 300 if (cpu_id != pc->pc_cpuid) { | 29 30#include <sys/param.h> 31#include <sys/bus.h> 32#include <sys/cpu.h> 33#include <sys/eventhandler.h> 34#include <sys/kernel.h> 35#include <sys/lock.h> 36#include <sys/malloc.h> --- 256 unchanged lines hidden (view full) --- 293 error = ENXIO; 294 goto out; 295 } 296 297 /* Bind to the target CPU before switching, if necessary. */ 298 cpu_id = PCPU_GET(cpuid); 299 pc = cpu_get_pcpu(set->dev); 300 if (cpu_id != pc->pc_cpuid) { |
301 mtx_lock_spin(&sched_lock); | 301 thread_lock(curthread); |
302 sched_bind(curthread, pc->pc_cpuid); | 302 sched_bind(curthread, pc->pc_cpuid); |
303 mtx_unlock_spin(&sched_lock); | 303 thread_unlock(curthread); |
304 } 305 CF_DEBUG("setting abs freq %d on %s (cpu %d)\n", set->freq, 306 device_get_nameunit(set->dev), PCPU_GET(cpuid)); 307 error = CPUFREQ_DRV_SET(set->dev, set); 308 if (cpu_id != pc->pc_cpuid) { | 304 } 305 CF_DEBUG("setting abs freq %d on %s (cpu %d)\n", set->freq, 306 device_get_nameunit(set->dev), PCPU_GET(cpuid)); 307 error = CPUFREQ_DRV_SET(set->dev, set); 308 if (cpu_id != pc->pc_cpuid) { |
309 mtx_lock_spin(&sched_lock); | 309 thread_lock(curthread); |
310 sched_unbind(curthread); | 310 sched_unbind(curthread); |
311 mtx_unlock_spin(&sched_lock); | 311 thread_unlock(curthread); |
312 } 313 if (error) { 314 goto out; 315 } 316 } 317 318 /* Next, set any/all relative frequencies via their drivers. */ 319 for (i = 0; i < level->rel_count; i++) { 320 set = &level->rel_set[i]; 321 if (!device_is_attached(set->dev)) { 322 error = ENXIO; 323 goto out; 324 } 325 326 /* Bind to the target CPU before switching, if necessary. */ 327 cpu_id = PCPU_GET(cpuid); 328 pc = cpu_get_pcpu(set->dev); 329 if (cpu_id != pc->pc_cpuid) { | 312 } 313 if (error) { 314 goto out; 315 } 316 } 317 318 /* Next, set any/all relative frequencies via their drivers. */ 319 for (i = 0; i < level->rel_count; i++) { 320 set = &level->rel_set[i]; 321 if (!device_is_attached(set->dev)) { 322 error = ENXIO; 323 goto out; 324 } 325 326 /* Bind to the target CPU before switching, if necessary. */ 327 cpu_id = PCPU_GET(cpuid); 328 pc = cpu_get_pcpu(set->dev); 329 if (cpu_id != pc->pc_cpuid) { |
330 mtx_lock_spin(&sched_lock); | 330 thread_lock(curthread); |
331 sched_bind(curthread, pc->pc_cpuid); | 331 sched_bind(curthread, pc->pc_cpuid); |
332 mtx_unlock_spin(&sched_lock); | 332 thread_unlock(curthread); |
333 } 334 CF_DEBUG("setting rel freq %d on %s (cpu %d)\n", set->freq, 335 device_get_nameunit(set->dev), PCPU_GET(cpuid)); 336 error = CPUFREQ_DRV_SET(set->dev, set); 337 if (cpu_id != pc->pc_cpuid) { | 333 } 334 CF_DEBUG("setting rel freq %d on %s (cpu %d)\n", set->freq, 335 device_get_nameunit(set->dev), PCPU_GET(cpuid)); 336 error = CPUFREQ_DRV_SET(set->dev, set); 337 if (cpu_id != pc->pc_cpuid) { |
338 mtx_lock_spin(&sched_lock); | 338 thread_lock(curthread); |
339 sched_unbind(curthread); | 339 sched_unbind(curthread); |
340 mtx_unlock_spin(&sched_lock); | 340 thread_unlock(curthread); |
341 } 342 if (error) { 343 /* XXX Back out any successful setting? */ 344 goto out; 345 } 346 } 347 348skip: --- 689 unchanged lines hidden --- | 341 } 342 if (error) { 343 /* XXX Back out any successful setting? */ 344 goto out; 345 } 346 } 347 348skip: --- 689 unchanged lines hidden --- |