PM / devfreq: cache_hwmon: Use array for reporting monitor stats

Using an array to report monitor stats instead of hard coded variable
names would allow for cleaner implementations of some cache hwmon
device drivers.

Change-Id: I787bdc12f10a0c8ff3c4195ce229a2987acdfce7
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
This commit is contained in:
Junjie Wu 2014-10-30 12:13:03 -07:00 committed by David Keitel
parent 95f77a9ab3
commit e6ce87f53c
3 changed files with 20 additions and 14 deletions

View file

@ -134,7 +134,8 @@ static unsigned long measure_mrps_and_set_irq(struct cache_hwmon_node *node,
dev_dbg(hw->df->dev.parent,
"stat H=%3lu, M=%3lu, T=%3lu, b=%3u, f=%4lu, us=%d\n",
stat->high, stat->med, stat->high + stat->med,
stat->mrps[HIGH], stat->mrps[MED],
stat->mrps[HIGH] + stat->mrps[MED],
stat->busy_percent, hw->df->previous_freq / 1000, us);
return 0;
@ -146,9 +147,9 @@ static void compute_cache_freq(struct cache_hwmon_node *node,
unsigned long new_mhz;
unsigned int busy;
new_mhz = mrps->high * node->cycles_per_high_req
+ mrps->med * node->cycles_per_med_req
+ mrps->low * node->cycles_per_low_req;
new_mhz = mrps->mrps[HIGH] * node->cycles_per_high_req
+ mrps->mrps[MED] * node->cycles_per_med_req
+ mrps->mrps[LOW] * node->cycles_per_low_req;
busy = max(node->min_busy, mrps->busy_percent);
busy = min(node->max_busy, busy);
@ -278,9 +279,9 @@ static int start_monitoring(struct devfreq *df)
node->prev_ts = ktime_get();
node->prev_mhz = 0;
mrps.high = (df->previous_freq / 1000) - node->guard_band_mhz;
mrps.high /= node->cycles_per_high_req;
mrps.med = mrps.low = 0;
mrps.mrps[HIGH] = (df->previous_freq / 1000) - node->guard_band_mhz;
mrps.mrps[HIGH] /= node->cycles_per_high_req;
mrps.mrps[MED] = mrps.mrps[LOW] = 0;
ret = hw->start_hwmon(hw, &mrps);
if (ret) {

View file

@ -17,10 +17,15 @@
#include <linux/kernel.h>
#include <linux/devfreq.h>
enum request_group {
HIGH,
MED,
LOW,
MAX_NUM_GROUPS,
};
struct mrps_stats {
unsigned long high;
unsigned long med;
unsigned long low;
unsigned long mrps[MAX_NUM_GROUPS];
unsigned int busy_percent;
};

View file

@ -328,9 +328,9 @@ static unsigned long meas_mrps_and_set_irq(struct cache_hwmon *hw,
mon_enable(L2_M_REQ_MON);
mon_enable(L2_CYC_MON);
mrps->high = t_mrps - m_mrps;
mrps->med = m_mrps;
mrps->low = 0;
mrps->mrps[HIGH] = t_mrps - m_mrps;
mrps->mrps[MED] = m_mrps;
mrps->mrps[LOW] = 0;
mrps->busy_percent = mult_frac(l2_cyc, 1000, us) * 100 / f;
return 0;
@ -363,7 +363,7 @@ static int start_mrps_hwmon(struct cache_hwmon *hw, struct mrps_stats *mrps)
mon_disable(L2_M_REQ_MON);
mon_disable(L2_CYC_MON);
limit = mrps_to_count(mrps->high, hw->df->profile->polling_ms, 0);
limit = mrps_to_count(mrps->mrps[HIGH], hw->df->profile->polling_ms, 0);
prev_req_start_val = mon_set_limit(L2_H_REQ_MON, limit);
mon_set_limit(L2_M_REQ_MON, 0xFFFFFFFF);
mon_set_limit(L2_CYC_MON, 0xFFFFFFFF);