blob: 6491c6ceccd64d7c435fc9fbbcff3cb6ea1b2294 [file] [log] [blame]
Rohit Gupta5e4358c2014-07-18 16:16:02 -07001/*
Santosh Mardi19f4e0d2017-05-25 18:11:42 +05302 * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
Rohit Gupta5e4358c2014-07-18 16:16:02 -07003 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
Santosh Mardi19f4e0d2017-05-25 18:11:42 +053014#ifndef _GOVERNOR_MEMLAT_H
15#define _GOVERNOR_MEMLAT_H
Rohit Gupta5e4358c2014-07-18 16:16:02 -070016
17#include <linux/kernel.h>
18#include <linux/devfreq.h>
19
20/**
21 * struct dev_stats - Device stats
22 * @inst_count: Number of instructions executed.
23 * @mem_count: Number of memory accesses made.
24 * @freq: Effective frequency of the device in the
25 * last interval.
26 */
27struct dev_stats {
28 int id;
29 unsigned long inst_count;
30 unsigned long mem_count;
31 unsigned long freq;
Saravana Kannan83f28462017-09-26 19:45:15 -070032 unsigned long stall_pct;
Rohit Gupta5e4358c2014-07-18 16:16:02 -070033};
34
Rohit Gupta870b1802016-04-13 16:55:04 -070035struct core_dev_map {
36 unsigned int core_mhz;
37 unsigned int target_freq;
38};
39
Rohit Gupta5e4358c2014-07-18 16:16:02 -070040/**
41 * struct memlat_hwmon - Memory Latency HW monitor info
42 * @start_hwmon: Start the HW monitoring
43 * @stop_hwmon: Stop the HW monitoring
44 * @get_cnt: Return the number of intructions executed,
45 * memory accesses and effective frequency
46 * @dev: Pointer to device that this HW monitor can
47 * monitor.
48 * @of_node: OF node of device that this HW monitor can
49 * monitor.
50 * @df: Devfreq node that this HW monitor is being
51 * used for. NULL when not actively in use and
52 * non-NULL when in use.
53 * @num_cores: Number of cores that are monitored by the
54 * hardware monitor.
55 * @core_stats: Array containing instruction count, memory
56 * accesses and effective frequency for each core.
57 *
58 * One of dev or of_node needs to be specified for a successful registration.
59 *
60 */
61struct memlat_hwmon {
62 int (*start_hwmon)(struct memlat_hwmon *hw);
63 void (*stop_hwmon)(struct memlat_hwmon *hw);
64 unsigned long (*get_cnt)(struct memlat_hwmon *hw);
65 struct device *dev;
66 struct device_node *of_node;
67
68 unsigned int num_cores;
69 struct dev_stats *core_stats;
70
71 struct devfreq *df;
Rohit Gupta870b1802016-04-13 16:55:04 -070072 struct core_dev_map *freq_map;
Rohit Gupta5e4358c2014-07-18 16:16:02 -070073};
74
75#ifdef CONFIG_DEVFREQ_GOV_MEMLAT
76int register_memlat(struct device *dev, struct memlat_hwmon *hw);
Jonathan Avilae71f95f2017-10-12 15:15:47 -070077int register_compute(struct device *dev, struct memlat_hwmon *hw);
Rohit Gupta5e4358c2014-07-18 16:16:02 -070078int update_memlat(struct memlat_hwmon *hw);
79#else
80static inline int register_memlat(struct device *dev,
Jonathan Avilae71f95f2017-10-12 15:15:47 -070081 struct memlat_hwmon *hw)
82{
83 return 0;
84}
85static inline int register_compute(struct device *dev,
86 struct memlat_hwmon *hw)
Rohit Gupta5e4358c2014-07-18 16:16:02 -070087{
88 return 0;
89}
90static inline int update_memlat(struct memlat_hwmon *hw)
91{
92 return 0;
93}
94#endif
95
96#endif /* _GOVERNOR_BW_HWMON_H */