Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
coupled.c File Reference
#include <linux/kernel.h>
#include <linux/cpu.h>
#include <linux/cpuidle.h>
#include <linux/mutex.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include "cpuidle.h"

Go to the source code of this file.

Data Structures

struct  cpuidle_coupled
 

Macros

#define WAITING_BITS   16
 
#define MAX_WAITING_CPUS   (1 << WAITING_BITS)
 
#define WAITING_MASK   (MAX_WAITING_CPUS - 1)
 
#define READY_MASK   (~WAITING_MASK)
 
#define CPUIDLE_COUPLED_NOT_IDLE   (-1)
 

Functions

void cpuidle_coupled_parallel_barrier (struct cpuidle_device *dev, atomic_t *a)
 
bool cpuidle_state_is_coupled (struct cpuidle_device *dev, struct cpuidle_driver *drv, int state)
 
int cpuidle_enter_state_coupled (struct cpuidle_device *dev, struct cpuidle_driver *drv, int next_state)
 
int cpuidle_coupled_register_device (struct cpuidle_device *dev)
 
void cpuidle_coupled_unregister_device (struct cpuidle_device *dev)
 
 core_initcall (cpuidle_coupled_init)
 

Macro Definition Documentation

#define CPUIDLE_COUPLED_NOT_IDLE   (-1)

Definition at line 119 of file coupled.c.

#define MAX_WAITING_CPUS   (1 << WAITING_BITS)

Definition at line 115 of file coupled.c.

#define READY_MASK   (~WAITING_MASK)

Definition at line 117 of file coupled.c.

#define WAITING_BITS   16

Definition at line 114 of file coupled.c.

#define WAITING_MASK   (MAX_WAITING_CPUS - 1)

Definition at line 116 of file coupled.c.

Function Documentation

core_initcall ( cpuidle_coupled_init  )
void cpuidle_coupled_parallel_barrier ( struct cpuidle_device dev,
atomic_t a 
)

cpuidle_coupled_parallel_barrier - synchronize all online coupled cpus : cpuidle_device of the calling cpu : atomic variable to hold the barrier

No caller to this function will return from this function until all online cpus in the same coupled group have called this function. Once any caller has returned from this function, the barrier is immediately available for reuse.

The atomic variable a must be initialized to 0 before any cpu calls this function, will be reset to 0 before any cpu returns from this function.

Must only be called from within a coupled idle state handler (state.enter when state.flags has CPUIDLE_FLAG_COUPLED set).

Provides full smp barrier semantics before and after calling.

Definition at line 150 of file coupled.c.

int cpuidle_coupled_register_device ( struct cpuidle_device dev)

cpuidle_coupled_register_device - register a coupled cpuidle device : struct cpuidle_device for the current cpu

Called from cpuidle_register_device to handle coupled idle init. Finds the cpuidle_coupled struct for this set of coupled cpus, or creates one if none exists yet.

Definition at line 564 of file coupled.c.

void cpuidle_coupled_unregister_device ( struct cpuidle_device dev)

cpuidle_coupled_unregister_device - unregister a coupled cpuidle device : struct cpuidle_device for the current cpu

Called from cpuidle_unregister_device to tear down coupled idle. Removes the cpu from the coupled idle set, and frees the cpuidle_coupled_info struct if this was the last cpu in the set.

Definition at line 613 of file coupled.c.

int cpuidle_enter_state_coupled ( struct cpuidle_device dev,
struct cpuidle_driver drv,
int  next_state 
)

cpuidle_enter_state_coupled - attempt to enter a state with coupled cpus : struct cpuidle_device for the current cpu : struct cpuidle_driver for the platform : index of the requested state in drv->states

Coordinate with coupled cpus to enter the target state. This is a two stage process. In the first stage, the cpus are operating independently, and may call into cpuidle_enter_state_coupled at completely different times. To save as much power as possible, the first cpus to call this function will go to an intermediate state (the cpuidle_device's safe state), and wait for all the other cpus to call this function. Once all coupled cpus are idle, the second stage will start. Each coupled cpu will spin until all cpus have guaranteed that they will call the target_state.

This function must be called with interrupts disabled. It may enable interrupts while preparing for idle, and it will always return with interrupts enabled.

Definition at line 447 of file coupled.c.

bool cpuidle_state_is_coupled ( struct cpuidle_device dev,
struct cpuidle_driver drv,
int  state 
)

cpuidle_state_is_coupled - check if a state is part of a coupled set : struct cpuidle_device for the current cpu : struct cpuidle_driver for the platform : index of the target state in drv->states

Returns true if the target state is coupled with cpus besides this one

Definition at line 177 of file coupled.c.