ソースを参照

disp: msm: sde: use atomic operator for evt log entries

To optimize evt log entries, spinlock is been removed and
used atomic operator for curr variable, due to which there
is mismatch of count values between curr and last variable during
xlog dump in kernel. So change the last variable to atomic to
avoid race condition between entries of evt logs.

Change-Id: Idf3e2b982261d77fec97985af1e8bf740a6f6197
Signed-off-by: Ryan McCann <[email protected]>
Ryan McCann 2 年 前
コミット
ecb0dbed04
3 ファイル変更8 行追加8 行削除
  1. 3 3
      msm/sde_dbg.c
  2. 1 1
      msm/sde_dbg.h
  3. 4 4
      msm/sde_dbg_evtlog.c

+ 3 - 3
msm/sde_dbg.c

@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  * Copyright (c) 2009-2021, The Linux Foundation. All rights reserved.
  */
 
@@ -1561,8 +1561,8 @@ static int sde_dbg_debugfs_open(struct inode *inode, struct file *file)
 	mutex_lock(&sde_dbg_base.mutex);
 	sde_dbg_base.cur_evt_index = 0;
 	sde_dbg_base.evtlog->first = (u32)atomic_add_return(0, &sde_dbg_base.evtlog->curr) + 1;
-	sde_dbg_base.evtlog->last =
-		sde_dbg_base.evtlog->first + SDE_EVTLOG_ENTRY;
+	atomic_set(&sde_dbg_base.evtlog->last,
+			(sde_dbg_base.evtlog->first + SDE_EVTLOG_ENTRY));
 	mutex_unlock(&sde_dbg_base.mutex);
 	return 0;
 }

+ 1 - 1
msm/sde_dbg.h

@@ -165,7 +165,7 @@ struct sde_dbg_evtlog_log {
 struct sde_dbg_evtlog {
 	struct sde_dbg_evtlog_log logs[SDE_EVTLOG_ENTRY];
 	u32 first;
-	u32 last;
+	atomic_t last;
 	u32 last_dump;
 	atomic_t curr;
 	u32 next;

+ 4 - 4
msm/sde_dbg_evtlog.c

@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
  */
 
@@ -89,7 +89,7 @@ void sde_evtlog_log(struct sde_dbg_evtlog *evtlog, const char *name, int line,
 	}
 	va_end(args);
 	log->data_cnt = i;
-	evtlog->last++;
+	atomic_inc_return(&evtlog->last);
 
 	trace_sde_evtlog(name, line, log->data_cnt, log->data);
 }
@@ -126,7 +126,7 @@ static bool _sde_evtlog_dump_calc_range(struct sde_dbg_evtlog *evtlog,
 	evtlog->first = evtlog->next;
 
 	if (update_last_entry)
-		evtlog->last_dump = evtlog->last;
+		evtlog->last_dump = (u32)atomic_read(&evtlog->last);
 
 	if (evtlog->last_dump == evtlog->first)
 		return false;
@@ -202,7 +202,7 @@ u32 sde_evtlog_count(struct sde_dbg_evtlog *evtlog)
 
 	first = evtlog->first;
 	next = evtlog->next;
-	last = evtlog->last;
+	last = (u32)atomic_read(&evtlog->last);
 	last_dump = evtlog->last_dump;
 
 	first = next;