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

Commit 7123adfc authored by Junjie Wu's avatar Junjie Wu Committed by Amir Vajid
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>
[avajid@codeaurora.org: made minor styling changes]
Signed-off-by: default avatarAmir Vajid <avajid@codeaurora.org>
parent 939d572b
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/devfreq.h>
#include <trace/events/power.h>
#include "governor.h"
#include "governor_cache_hwmon.h"

@@ -119,11 +120,9 @@ static unsigned long measure_mrps_and_set_irq(struct cache_hwmon_node *node,

	preempt_enable();

	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->busy_percent, hw->df->previous_freq / 1000, us);

	trace_cache_hwmon_meas(dev_name(hw->df->dev.parent), stat->mrps[HIGH],
			       stat->mrps[MED], stat->mrps[LOW],
			       stat->busy_percent, us);
	return 0;
}

@@ -133,9 +132,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);
@@ -152,6 +151,7 @@ static void compute_cache_freq(struct cache_hwmon_node *node,

	new_mhz += node->guard_band_mhz;
	*freq = new_mhz * 1000;
	trace_cache_hwmon_update(dev_name(node->hw->df->dev.parent), *freq);
}

#define TOO_SOON_US	(1 * USEC_PER_MSEC)
@@ -280,9 +280,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 < 0) {
+8 −3
Original line number Diff line number Diff line
@@ -9,10 +9,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;
};

+43 −0
Original line number Diff line number Diff line
@@ -585,6 +585,49 @@ TRACE_EVENT(bw_hwmon_update,
		__entry->down_thres)
);

TRACE_EVENT(cache_hwmon_meas,
	TP_PROTO(const char *name, unsigned long high_mrps,
		 unsigned long med_mrps, unsigned long low_mrps,
		 unsigned int busy_percent, unsigned int us),
	TP_ARGS(name, high_mrps, med_mrps, low_mrps, busy_percent, us),
	TP_STRUCT__entry(
		__string(name, name)
		__field(unsigned long, high_mrps)
		__field(unsigned long, med_mrps)
		__field(unsigned long, low_mrps)
		__field(unsigned long, total_mrps)
		__field(unsigned int, busy_percent)
		__field(unsigned int, us)
	),
	TP_fast_assign(
		__assign_str(name, name);
		__entry->high_mrps = high_mrps;
		__entry->med_mrps = med_mrps;
		__entry->low_mrps = low_mrps;
		__entry->total_mrps = high_mrps + med_mrps + low_mrps;
		__entry->busy_percent = busy_percent;
		__entry->us = us;
	),
	TP_printk("dev=%s H=%lu M=%lu L=%lu T=%lu busy_pct=%u period=%u",
		  __get_str(name), __entry->high_mrps, __entry->med_mrps,
		  __entry->low_mrps, __entry->total_mrps,
		  __entry->busy_percent, __entry->us)
);

TRACE_EVENT(cache_hwmon_update,
	TP_PROTO(const char *name, unsigned long freq_mhz),
	TP_ARGS(name, freq_mhz),
	TP_STRUCT__entry(
		__string(name, name)
		__field(unsigned long, freq)
	),
	TP_fast_assign(
		__assign_str(name, name);
		__entry->freq = freq_mhz;
	),
	TP_printk("dev=%s freq=%lu", __get_str(name), __entry->freq)
);

#endif /* _TRACE_POWER_H */

/* This part must be outside protection */