summaryrefslogtreecommitdiff
path: root/drivers/edp/edp_internal.h
blob: 37d64ee65c3b86842f52b95f46453d8d8c914310 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
 * Copyright (c) 2012-2013, NVIDIA CORPORATION.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _EDP_INTERNAL_H
#define _EDP_INTERNAL_H

#include <linux/kernel.h>
#include <linux/edp.h>

struct loan_client {
	struct list_head link;
	struct edp_client *client;
	unsigned int size;
};

static inline unsigned int cur_level(struct edp_client *c)
{
	return c->cur ? *c->cur : 0;
}

static inline unsigned int req_level(struct edp_client *c)
{
	return c->req ? *c->req : 0;
}

static inline unsigned int e0_level(struct edp_client *c)
{
	return c->states[c->e0_index];
}

static inline unsigned int cur_index(struct edp_client *c)
{
	return c->cur ? c->cur - c->states : c->num_states;
}

static inline unsigned int req_index(struct edp_client *c)
{
	return c->req ? c->req - c->states : c->num_states;
}

extern struct mutex edp_lock;
extern struct list_head edp_governors;

int register_client(struct edp_manager *m, struct edp_client *c);
int unregister_client(struct edp_client *c);

int edp_update_client_request_unlocked(struct edp_client *client,
		unsigned int req, int *approved);
int edp_update_loan_threshold_unlocked(struct edp_client *client,
		unsigned int threshold);
struct edp_governor *edp_find_governor_unlocked(const char *s);
int edp_set_governor_unlocked(struct edp_manager *mgr,
		struct edp_governor *gov);

void edp_manager_add_kobject(struct edp_manager *mgr);
void edp_manager_remove_kobject(struct edp_manager *mgr);
void edp_client_add_kobject(struct edp_client *client);
void edp_client_remove_kobject(struct edp_client *client);
void edp_default_update_request(struct edp_client *client,
		const unsigned int *req,
		void (*throttle)(struct edp_client *));
void edp_default_update_loans(struct edp_client *lender);
unsigned int edp_throttling_point(struct edp_client *c, unsigned int deficit);
unsigned int edp_promotion_point(struct edp_client *c, unsigned int step);

void manager_add_dentry(struct edp_manager *m);
void manager_remove_dentry(struct edp_manager *m);
void client_add_dentry(struct edp_client *c);
void client_remove_dentry(struct edp_client *c);
void schedule_promotion(struct edp_manager *m);
unsigned int e0_current_sum(struct edp_manager *mgr);

#endif