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

Commit 5f45ab5d authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "PM / devfreq: bw_hwmon: Take at least one sample per decision window"

parents 36927fa6 9b56fe1f
Loading
Loading
Loading
Loading
+24 −4
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ struct hwmon_node {
	unsigned int down_cnt;
	ktime_t prev_ts;
	ktime_t hist_max_ts;
	bool sampled;
	bool mon_started;
	struct list_head list;
	void *orig_data;
@@ -190,19 +191,18 @@ static unsigned int mbps_to_bytes(unsigned long mbps, unsigned int ms)
	return mbps;
}

int bw_hwmon_sample_end(struct bw_hwmon *hwmon)
static int __bw_hwmon_sample_end(struct bw_hwmon *hwmon)
{
	struct devfreq *df;
	struct hwmon_node *node;
	ktime_t ts;
	unsigned long bytes, mbps, flags;
	unsigned long bytes, mbps;
	unsigned int us;
	int wake = 0;

	df = hwmon->df;
	node = df->data;

	spin_lock_irqsave(&irq_lock, flags);
	ts = ktime_get();
	us = ktime_to_us(ktime_sub(ts, node->prev_ts));

@@ -230,7 +230,7 @@ int bw_hwmon_sample_end(struct bw_hwmon *hwmon)

	node->prev_ts = ts;
	node->wake = wake;
	spin_unlock_irqrestore(&irq_lock, flags);
	node->sampled = true;

	trace_bw_hwmon_meas(dev_name(df->dev.parent),
				mbps,
@@ -243,6 +243,18 @@ int bw_hwmon_sample_end(struct bw_hwmon *hwmon)
	return wake;
}

int bw_hwmon_sample_end(struct bw_hwmon *hwmon)
{
	unsigned long flags;
	int wake;

	spin_lock_irqsave(&irq_lock, flags);
	wake = __bw_hwmon_sample_end(hwmon);
	spin_unlock_irqrestore(&irq_lock, flags);

	return wake;
}

unsigned long to_mbps_zone(struct hwmon_node *node, unsigned long mbps)
{
	int i;
@@ -264,9 +276,17 @@ static unsigned long get_bw_and_set_irq(struct hwmon_node *node,
	unsigned long hist_lo_tol, hyst_lo_tol;
	struct bw_hwmon *hw = node->hw;
	unsigned int new_bw, io_percent;
	ktime_t ts;
	unsigned int ms;

	spin_lock_irqsave(&irq_lock, flags);

	ts = ktime_get();
	ms = ktime_to_ms(ktime_sub(ts, node->prev_ts));
	if (!node->sampled || ms >= node->sample_ms)
		__bw_hwmon_sample_end(node->hw);
	node->sampled = false;

	req_mbps = meas_mbps = node->max_mbps;
	node->max_mbps = 0;