浏览代码

disp: msm: sde: check power event before set clk rate

Clock rate can be set from debugfs, and this can attempt to
set clock rate even when display power is not enabled.
Set clock rate should check the last power event first.

Change-Id: Ibf01753a288e5a3003928664c99aa6dbf26350d6
Signed-off-by: Nilaan Gunabalachandran <[email protected]>
Nilaan Gunabalachandran 5 年之前
父节点
当前提交
42b9fb5937
共有 3 个文件被更改,包括 18 次插入4 次删除
  1. 3 2
      msm/sde/sde_core_perf.c
  2. 13 1
      msm/sde_power_handle.c
  3. 2 1
      msm/sde_power_handle.h

+ 3 - 2
msm/sde/sde_core_perf.c

@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
  */
 
 #define pr_fmt(fmt)	"[drm:%s:%d] " fmt, __func__, __LINE__
@@ -1041,7 +1041,8 @@ static ssize_t _sde_core_perf_mode_write(struct file *file,
 			SDE_ERROR("failed to set %s clock rate %llu\n",
 					perf->clk_name,
 					perf->max_core_clk_rate);
-		DRM_INFO("minimum performance mode\n");
+		else
+			DRM_INFO("minimum performance mode\n");
 	} else if (perf_mode == SDE_PERF_MODE_NORMAL) {
 		/* reset the perf tune params to 0 */
 		perf->perf_tune.min_core_clk = 0;

+ 13 - 1
msm/sde_power_handle.c

@@ -48,8 +48,10 @@ static void sde_power_event_trigger_locked(struct sde_power_handle *phandle,
 	struct sde_power_event *event;
 
 	list_for_each_entry(event, &phandle->event_list, list) {
-		if (event->event_type & event_type)
+		if (event->event_type & event_type) {
 			event->cb_fnc(event_type, event->usr);
+			phandle->last_event_handled = event_type;
+		}
 	}
 }
 
@@ -768,6 +770,15 @@ int sde_power_clk_set_rate(struct sde_power_handle *phandle, char *clock_name,
 		pr_err("invalid input power handle\n");
 		return -EINVAL;
 	}
+
+	mutex_lock(&phandle->phandle_lock);
+	if (phandle->last_event_handled & SDE_POWER_EVENT_POST_DISABLE) {
+		pr_debug("invalid power state %u\n",
+				phandle->last_event_handled);
+		mutex_unlock(&phandle->phandle_lock);
+		return -EINVAL;
+	}
+
 	mp = &phandle->mp;
 
 	for (i = 0; i < mp->num_clk; i++) {
@@ -781,6 +792,7 @@ int sde_power_clk_set_rate(struct sde_power_handle *phandle, char *clock_name,
 			break;
 		}
 	}
+	mutex_unlock(&phandle->phandle_lock);
 
 	return rc;
 }

+ 2 - 1
msm/sde_power_handle.h

@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
  */
 
 #ifndef _SDE_POWER_HANDLE_H_
@@ -154,6 +154,7 @@ struct sde_power_handle {
 	struct sde_power_data_bus_handle data_bus_handle
 		[SDE_POWER_HANDLE_DBUS_ID_MAX];
 	struct list_head event_list;
+	u32 last_event_handled;
 	struct sde_rsc_client *rsc_client;
 	bool rsc_client_init;
 };