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

Commit 6f6c0683 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "PM / devfreq: bw_hwmon: Fix a race condition in hwmon stop"

parents c33d4e8d c8a98a77
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2014-2017, 2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014-2018, 2019, The Linux Foundation. All rights reserved.
 */

#define pr_fmt(fmt) "arm-memlat-mon: " fmt
@@ -69,7 +69,7 @@ static unsigned long compute_freq(struct cpu_pmu_stats *cpustats,
{
	ktime_t ts;
	unsigned int diff;
	unsigned long freq = 0;
	uint64_t freq = 0;

	ts = ktime_get();
	diff = ktime_to_us(ktime_sub(ts, cpustats->prev_ts));
@@ -354,6 +354,7 @@ static struct platform_driver arm_memlat_mon_driver = {
	.driver = {
		.name = "arm-memlat-mon",
		.of_match_table = memlat_match_table,
		.suppress_bind_attrs = true,
	},
};

+1 −0
Original line number Diff line number Diff line
@@ -1133,6 +1133,7 @@ static struct platform_driver bimc_bwmon_driver = {
	.driver = {
		.name = "bimc-bwmon",
		.of_match_table = bimc_bwmon_match_table,
		.suppress_bind_attrs = true,
	},
};

+1 −0
Original line number Diff line number Diff line
@@ -213,6 +213,7 @@ static struct platform_driver devbw_driver = {
	.driver = {
		.name = "devbw",
		.of_match_table = devbw_match_table,
		.suppress_bind_attrs = true,
	},
};

+2 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2014-2015, 2017, 2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014-2015, 2017-2018, 2019, The Linux Foundation. All rights reserved.
 */

#define pr_fmt(fmt) "devfreq-simple-dev: " fmt
@@ -204,6 +204,7 @@ static struct platform_driver devfreq_clock_driver = {
	.driver = {
		.name = "devfreq-simple-dev",
		.of_match_table = devfreq_simple_match_table,
		.suppress_bind_attrs = true,
	},
};
module_platform_driver(devfreq_clock_driver);
+10 −3
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2013-2017, 2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2018, 2019, The Linux Foundation. All rights reserved.
 */

#define pr_fmt(fmt) "bw-hwmon: " fmt
@@ -66,6 +66,7 @@ struct hwmon_node {
	struct bw_hwmon *hw;
	struct devfreq_governor *gov;
	struct attribute_group *attr_grp;
	struct mutex mon_lock;
};

#define UP_WAKE 1
@@ -503,9 +504,11 @@ int update_bw_hwmon(struct bw_hwmon *hwmon)
	if (!node)
		return -ENODEV;

	if (!node->mon_started)
	mutex_lock(&node->mon_lock);
	if (!node->mon_started) {
		mutex_unlock(&node->mon_lock);
		return -EBUSY;

	}
	dev_dbg(df->dev.parent, "Got update request\n");
	devfreq_monitor_stop(df);

@@ -517,6 +520,7 @@ int update_bw_hwmon(struct bw_hwmon *hwmon)
	mutex_unlock(&df->lock);

	devfreq_monitor_start(df);
	mutex_unlock(&node->mon_lock);

	return 0;
}
@@ -564,7 +568,9 @@ static void stop_monitor(struct devfreq *df, bool init)
	struct hwmon_node *node = df->data;
	struct bw_hwmon *hw = node->hw;

	mutex_lock(&node->mon_lock);
	node->mon_started = false;
	mutex_unlock(&node->mon_lock);

	if (init) {
		devfreq_monitor_stop(df);
@@ -923,6 +929,7 @@ int register_bw_hwmon(struct device *dev, struct bw_hwmon *hwmon)
	node->mbps_zones[0] = 0;
	node->hw = hwmon;

	mutex_init(&node->mon_lock);
	mutex_lock(&list_lock);
	list_add_tail(&node->list, &hwmon_list);
	mutex_unlock(&list_lock);