Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3f022f8 authored by Junjie Wu's avatar Junjie Wu
Browse files

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: default avatarJunjie Wu <junjiew@codeaurora.org>
parent fbe31fda
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -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) {
+8 −3
Original line number Diff line number Diff line
@@ -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;
};

+4 −4
Original line number Diff line number Diff line
@@ -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);