From ecb0dbed04159ed62444de74b9ca795d9fa73ecc Mon Sep 17 00:00:00 2001 From: Ryan McCann Date: Wed, 31 May 2023 10:17:27 -0700 Subject: [PATCH] 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 --- msm/sde_dbg.c | 6 +++--- msm/sde_dbg.h | 2 +- msm/sde_dbg_evtlog.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/msm/sde_dbg.c b/msm/sde_dbg.c index a6cc07d96d..4e46c3fd5a 100644 --- a/msm/sde_dbg.c +++ b/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; } diff --git a/msm/sde_dbg.h b/msm/sde_dbg.h index 89397cb0fa..59e4baea4d 100644 --- a/msm/sde_dbg.h +++ b/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; diff --git a/msm/sde_dbg_evtlog.c b/msm/sde_dbg_evtlog.c index ecd2fc529b..8459693029 100644 --- a/msm/sde_dbg_evtlog.c +++ b/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;