545 Commits

Author SHA1 Message Date
Roland Xu
3ff99de219 rtmutex: Drop rt_mutex::wait_lock before scheduling
commit d33d26036a0274b472299d7dcdaa5fb34329f91b upstream.

rt_mutex_handle_deadlock() is called with rt_mutex::wait_lock held.  In the
good case it returns with the lock held and in the deadlock case it emits a
warning and goes into an endless scheduling loop with the lock held, which
triggers the 'scheduling in atomic' warning.

Unlock rt_mutex::wait_lock in the dead lock case before issuing the warning
and dropping into the schedule for ever loop.

[ tglx: Moved unlock before the WARN(), removed the pointless comment,
  	massaged changelog, added Fixes tag ]

Fixes: 3d5c9340d1 ("rtmutex: Handle deadlock detection smarter")
Signed-off-by: Roland Xu <mu001999@outlook.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/ME0P300MB063599BEF0743B8FA339C2CECC802@ME0P300MB0635.AUSP300.PROD.OUTLOOK.COM
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 432efdbe7da5ecfcbc0c2180cfdbab1441752a38)
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
2025-12-24 11:21:43 +00:00
Peter Zijlstra
4c0ef9bc36 locking/rtmutex: Handle non enqueued waiters gracefully in remove_waiter()
In -RT task_blocks_on_rt_mutex() may return with -EAGAIN due to
(->pi_blocked_on == PI_WAKEUP_INPROGRESS) before it added itself as a
waiter. In such a case remove_waiter() must not be called because without a
waiter it will trigger the BUG_ON() statement.

This was initially reported by Yimin Deng. Thomas Gleixner fixed it then
with an explicit check for waiters before calling remove_waiter().

Instead of an explicit NULL check before calling rt_mutex_top_waiter() make
the function return NULL if there are no waiters. With that fixed the now
pointless NULL check is removed from rt_mutex_slowlock().

Reported-and-debugged-by: Yimin Deng <yimin11.deng@gmail.com>
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/CAAh1qt=DCL9aUXNxanP5BKtiPp3m+qj4yB+gDohhXPVFCxWwzg@mail.gmail.com
Link: https://lkml.kernel.org/r/20180327121438.sss7hxg3crqy4ecd@linutronix.de
(cherry picked from commit c28d62cf52d791ba5f6db7ce525ed06b86291c82)
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
2025-12-24 11:21:43 +00:00
Sarthak Roy
0cc7dcc78d treewide: Drop OPLUS_FEATURE_HUNG_TASK_ENHANCE
Signed-off-by: Sarthak Roy <sarthakroy2002@gmail.com>
Change-Id: Ia9b0a927bb57e89df512738c0a4a721b7d894943
2024-03-05 23:02:35 +05:30
SamarV-121
d22154e2a7 Merge '4.14.331' of https://android.googlesource.com/kernel/common into lineage-20
Change-Id: Idf696db6575569265e0f206c32674b411bb9ef5a
2023-12-20 08:34:16 +05:30
John Stultz
d4d37c9e6a locking/ww_mutex/test: Fix potential workqueue corruption
[ Upstream commit bccdd808902f8c677317cec47c306e42b93b849e ]

In some cases running with the test-ww_mutex code, I was seeing
odd behavior where sometimes it seemed flush_workqueue was
returning before all the work threads were finished.

Often this would cause strange crashes as the mutexes would be
freed while they were being used.

Looking at the code, there is a lifetime problem as the
controlling thread that spawns the work allocates the
"struct stress" structures that are passed to the workqueue
threads. Then when the workqueue threads are finished,
they free the stress struct that was passed to them.

Unfortunately the workqueue work_struct node is in the stress
struct. Which means the work_struct is freed before the work
thread returns and while flush_workqueue is waiting.

It seems like a better idea to have the controlling thread
both allocate and free the stress structures, so that we can
be sure we don't corrupt the workqueue by freeing the structure
prematurely.

So this patch reworks the test to do so, and with this change
I no longer see the early flush_workqueue returns.

Signed-off-by: John Stultz <jstultz@google.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20230922043616.19282-3-jstultz@google.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-11-28 16:45:42 +00:00
SamarV-121
07eb1dacec Merge '4.14.322' of https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git into lineage-20
Change-Id: Iae282739fd6ae5ca8e9d4cbeda6743632529fb63
2023-08-20 12:32:54 +05:30
Kees Cook
d68627697d treewide: Remove uninitialized_var() usage
commit 3f649ab728cda8038259d8f14492fe400fbab911 upstream.

Using uninitialized_var() is dangerous as it papers over real bugs[1]
(or can in the future), and suppresses unrelated compiler warnings
(e.g. "unused variable"). If the compiler thinks it is uninitialized,
either simply initialize the variable or make compiler changes.

In preparation for removing[2] the[3] macro[4], remove all remaining
needless uses with the following script:

git grep '\buninitialized_var\b' | cut -d: -f1 | sort -u | \
	xargs perl -pi -e \
		's/\buninitialized_var\(([^\)]+)\)/\1/g;
		 s:\s*/\* (GCC be quiet|to make compiler happy) \*/$::g;'

drivers/video/fbdev/riva/riva_hw.c was manually tweaked to avoid
pathological white-space.

No outstanding warnings were found building allmodconfig with GCC 9.3.0
for x86_64, i386, arm64, arm, powerpc, powerpc64le, s390x, mips, sparc64,
alpha, and m68k.

[1] https://lore.kernel.org/lkml/20200603174714.192027-1-glider@google.com/
[2] https://lore.kernel.org/lkml/CA+55aFw+Vbj0i=1TGqCR5vQkCzWJ0QxK6CernOU6eedsudAixw@mail.gmail.com/
[3] https://lore.kernel.org/lkml/CA+55aFwgbgqhbp1fkxvRKEpzyR5J8n1vKT1VZdz9knmPuXhOeg@mail.gmail.com/
[4] https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=yVJu65TpLgN_ybYNv0VEOKA@mail.gmail.com/

Reviewed-by: Leon Romanovsky <leonro@mellanox.com> # drivers/infiniband and mlx4/mlx5
Acked-by: Jason Gunthorpe <jgg@mellanox.com> # IB
Acked-by: Kalle Valo <kvalo@codeaurora.org> # wireless drivers
Reviewed-by: Chao Yu <yuchao0@huawei.com> # erofs
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-08-11 11:33:32 +02:00
SamarV-121
2a336c668c Merge branch 'android-4.14-stable' of https://android.googlesource.com/kernel/common into lineage-19.0
Signed-off-by: SamarV-121 <samarvispute121@pm.me>
Change-Id: I26530a14b3cf6acfacd310d46d1e45b03ecaeff9
2022-01-03 23:21:18 +05:30
Pranaya Deomani
597842aef6 kernel: Import oplus changes
Change-Id: Ia97972540645d4b40cffaafd92189546a7be2805
Signed-off-by: Pranaya Deomani <pranayadeomani@protonmail.com>
2021-12-25 18:05:37 +05:30
Peter Zijlstra
d9c4367a7e locking/lockdep: Avoid RCU-induced noinstr fail
[ Upstream commit ce0b9c805dd66d5e49fd53ec5415ae398f4c56e6 ]

vmlinux.o: warning: objtool: look_up_lock_class()+0xc7: call to rcu_read_lock_any_held() leaves .noinstr.text section

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20210624095148.311980536@infradead.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-11-26 11:40:26 +01:00
Thomas Gleixner
348a99a76b rtmutex: Remove unused argument from rt_mutex_proxy_unlock()
commit 2156ac1934166d6deb6cd0f6ffc4c1076ec63697 upstream

Nothing uses the argument. Remove it as preparation to use
pi_state_update_owner().

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:31:16 +01:00
Cheng Jui Wang
de2d06f5ab [ALPS05382757] lockdep: disable held locks aee dump
Disable "held locks too much" AEE dump.
This type of AEE dump is not common and may not be a real problem.

MTK-Commit-Id: 91037109341b886cd3ff9a84d3445b2fc34a1cc8

Change-Id: I5a1d95a7c676fbddfe8e5d1efeff40aa0bf1a351
Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>
CR-Id: ALPS05382757
Feature: [Module]Lockdep
(cherry picked from commit 4587e78d4410fd1889bfc2ac87a10c3c50ac73ca)
2020-10-20 16:08:56 +08:00
Chris Wilson
1cd492f839 locking/lockdep: Fix overflow in presentation of average lock-time
[ Upstream commit a7ef9b28aa8d72a1656fa6f0a01bbd1493886317 ]

Though the number of lock-acquisitions is tracked as unsigned long, this
is passed as the divisor to div_s64() which interprets it as a s32,
giving nonsense values with more than 2 billion acquisitons. E.g.

  acquisitions   holdtime-min   holdtime-max holdtime-total   holdtime-avg
  -------------------------------------------------------------------------
    2350439395           0.07         353.38   649647067.36          0.-32

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20200725185110.11588-1-chris@chris-wilson.co.uk
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-09-03 11:22:27 +02:00
Cheng Jui Wang
88ffba5587 [ALPS05224425] lockdep: fix lockdep warning
Its a bad idea to do anything while the IRQ events are not match
with the CPU IRQ status. Lets fix it.

MTK-Commit-Id: b2a5405af7ff0e3e364854ded34b96608365182d

Change-Id: Ib56becc7abe66dad4de4d071964182b7caa9489d
Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>
CR-Id: ALPS05224425
Feature: [Module]Lockdep
2020-07-16 23:55:07 +08:00
Kobe Wu
45e8a7edd5 [ALPS05144018] lockdep: fix build error
Fix build error in kasan/ubsan load.

MTK-Commit-Id: df0792699dd0261955a7ab836bc74dca9cf4b82e

Change-Id: If40d4874dc948936c03fe15250ee28cc7f0e5a7c
CR-Id: ALPS05144018
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-06-05 16:00:05 +08:00
Kobe Wu
58d87ed38a [ALPS05139516] lockdep: lock monitor detect lock owner
Improve lock monitor to differentiate between lock owner
and others automatically and enhance test cases for this
modification.

MTK-Commit-Id: ecce08578297309430203934b995c73d50f5a796

Change-Id: I5de23c5f5a0c204ebdb0cd06886c44783b477da1
CR-Id: ALPS05139516
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-06-05 16:00:00 +08:00
Kobe Wu
5d78d31038 [ALPS05125151] lockdep: fix Coverity Scanned Code Defect
Add error handling for CERT-C Error Handling:9297314.

MTK-Commit-Id: 7d0ed7bf7dbe202d98a2c30b7f655b8823e9db2b

Change-Id: I09922ef88e6d5bc4ad520daa731f457f23b118ab
CR-Id: ALPS05125151
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-05-22 20:19:39 +08:00
Kobe Wu
1ea0e1a40a [ALPS05125618] lockdep: fix Coverity Scanned Code Defect
Add error handling for CERT-C Error Handling:9880007.

MTK-Commit-Id: 7aafb4f62e4488085cbe2cd491612bc9f29495df

Change-Id: Ia014c3d77cf54a6bcbde069a262d4057e4d553c0
CR-Id: ALPS05125618
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-05-22 20:19:29 +08:00
skylake.huang
5d895079a9 [ALPS05116835] [Do NOT Sync]Merge branch android-4.14-stable into alps-trunk-r0.basic
[Detail]
	Parent: 32bc956bc2
		Merge 4.14.174 into android-4.14
	Start: 9affadc76e
		ANDROID: UPSTREAM: bpf: Explicitly memset the bpf_attr structure
	Target: 10557abb61
		Merge 4.14.179 into android-4.14-stable

MTK-Commit-Id: 571bd9ed6e169c9210bedd85d5835daf73f9950a

Feature: Others
Change-Id: I0f577ffe6e316fc803adc0a83636b335af891ff5
CR-Id: ALPS05116835
Signed-off-by: Breeze.Li <breeze.li@mediatek.com>
2020-05-22 20:18:31 +08:00
Kobe Wu
0d6004fec4 [ALPS05100325] lockdep: change method to dump task stack
The new method to dump task stack is not stable.
So we revert the function to the old method.

MTK-Commit-Id: 549d7b6565122f069474a20b28f988267de31d56

Change-Id: I74d615e69d0ef0c64ace3d294faa71d869edd6d3
CR-Id: ALPS05100325
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-05-09 10:04:41 +08:00
Paul E. McKenney
7c1449d4e8 locktorture: Print ratio of acquisitions, not failures
commit 80c503e0e68fbe271680ab48f0fe29bc034b01b7 upstream.

The __torture_print_stats() function in locktorture.c carefully
initializes local variable "min" to statp[0].n_lock_acquired, but
then compares it to statp[i].n_lock_fail.  Given that the .n_lock_fail
field should normally be zero, and given the initialization, it seems
reasonable to display the maximum and minimum number acquisitions
instead of miscomputing the maximum and minimum number of failures.
This commit therefore switches from failures to acquisitions.

And this turns out to be not only a day-zero bug, but entirely my
own fault.  I hate it when that happens!

Fixes: 0af3fe1efa ("locktorture: Add a lock-torture kernel module")
Reported-by: Will Deacon <will@kernel.org>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Acked-by: Will Deacon <will@kernel.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Josh Triplett <josh@joshtriplett.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-24 08:01:23 +02:00
Boqun Feng
105d88c02f locking/lockdep: Avoid recursion in lockdep_count_{for,back}ward_deps()
[ Upstream commit 25016bd7f4caf5fc983bbab7403d08e64cba3004 ]

Qian Cai reported a bug when PROVE_RCU_LIST=y, and read on /proc/lockdep
triggered a warning:

  [ ] DEBUG_LOCKS_WARN_ON(current->hardirqs_enabled)
  ...
  [ ] Call Trace:
  [ ]  lock_is_held_type+0x5d/0x150
  [ ]  ? rcu_lockdep_current_cpu_online+0x64/0x80
  [ ]  rcu_read_lock_any_held+0xac/0x100
  [ ]  ? rcu_read_lock_held+0xc0/0xc0
  [ ]  ? __slab_free+0x421/0x540
  [ ]  ? kasan_kmalloc+0x9/0x10
  [ ]  ? __kmalloc_node+0x1d7/0x320
  [ ]  ? kvmalloc_node+0x6f/0x80
  [ ]  __bfs+0x28a/0x3c0
  [ ]  ? class_equal+0x30/0x30
  [ ]  lockdep_count_forward_deps+0x11a/0x1a0

The warning got triggered because lockdep_count_forward_deps() call
__bfs() without current->lockdep_recursion being set, as a result
a lockdep internal function (__bfs()) is checked by lockdep, which is
unexpected, and the inconsistency between the irq-off state and the
state traced by lockdep caused the warning.

Apart from this warning, lockdep internal functions like __bfs() should
always be protected by current->lockdep_recursion to avoid potential
deadlocks and data inconsistency, therefore add the
current->lockdep_recursion on-and-off section to protect __bfs() in both
lockdep_count_forward_deps() and lockdep_count_backward_deps()

Reported-by: Qian Cai <cai@lca.pw>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200312151258.128036-1-boqun.feng@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-04-24 08:00:29 +02:00
Cheng Jui Wang
79fd50f274 [ALPS05095852] lockdep: fix warning of irq off tracer
The trace_hardirqs_off_time() and trace_hardirqs_on_time()
called before trace_hardirqs_off_caller and
trace_hardirqs_on_caller will generate warning when testing
current->hardirqs_enabled flag in arm architecture
Move xxx_time() to the next line of xxx_caller()

MTK-Commit-Id: 71051fa7b93e414e1f1181690bb425e8a48b283a

Change-Id: I156096a95d3b6f9a19660c779bc44c55708e1b74
CR-Id: ALPS05095852
Feature: [Module]Lockdep
Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>
2020-04-23 18:16:46 +08:00
Kobe Wu
907fce2338 [ALPS05081866] lockdep: fix build error
Include the correct header file to fix build error.

MTK-Commit-Id: ebf39a326a9bc2b53294b904dbb82d5d6477865d

Change-Id: Ibaee0ddc1f91211cfee8d48819ac4813894d0cad
CR-Id: ALPS05081866
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-04-16 17:06:03 +08:00
skylake.huang
2f9c776ac2 [ALPS05077885] [Do NOT Sync]Merge branch android-4.14 into alps-trunk-r0.basic
[Detail]
	Parent: 234de92896
		Merge 4.14.150 into android-4.14
	Start: 7d642373db
		ANDROID: refactor build.config files to remove duplication
	Target: 32bc956bc2
		Merge 4.14.174 into android-4.14

MTK-Commit-Id: 73aee9b6172d4865b3b10bd396f7cfa40e7207b1

Feature: Others
Change-Id: Id09b858cd9f7f12db63cdb0bea42254d233a9fbd
CR-Id: ALPS05077885
Signed-off-by: Breeze.Li <breeze.li@mediatek.com>
2020-04-16 17:06:03 +08:00
Kobe Wu
3d3f72d7bb [ALPS04994668] lockdep: adjust the dependency of lock debugging
Spinlock debugging is bundled to CONFIG_DEBUG_SPINLOCK.
Lock monitor is bundled to CONFIG_LOCKDEP.

CONFIG_DEBUG_LOCK_ALLOC is the basic option to enable
CONFIG_LOCKDEP (Lock monitor). The other choices are
CONFIG_LOCK_STAT and CONFIG_PROVE_LOCKING.

MTK-Commit-Id: 58b4cd9af33bdfd797320eb147d8bb7b726667ee

Change-Id: Ie50a28a379b4174e75c018a7d0481255c7d30231
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
CR-Id: ALPS04994668
Feature: [Module]Lockdep
2020-04-16 16:31:21 +08:00
Kobe Wu
faa9199bc3 [ALPS04994668] lockdep: refine debug function
Limit debug functions to be used in arm/arm64 platform.

MTK-Commit-Id: 0d167f83ed0c357a040afcbafd0f699a4f24b7ce

Change-Id: Id203d7e63cc2bf67cb9eef60bc0f963d03711c3d
CR-Id: ALPS04994668
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-04-09 10:02:50 +08:00
Kobe Wu
68bb89cfce [ALPS04994668] lockdep: fix build error
Fix build error in 32-bit projects

/alps/DailyBuild/CodeBase/alps/kernel-4.14/kernel/locking/
lockdep.c:5945:29: error: use of undeclared identifier
dump_backtrace

MTK-Commit-Id: 9cc6c42f1617a466f84070051eb24c210f1cda57

Change-Id: Iac35db7739605cb50fbb8b3d1c4b42ac0061411d
CR-Id: ALPS04994668
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-04-09 10:02:41 +08:00
Kobe Wu
2334f7dd85 [ALPS04994668] lockdep: improve lockdep debugging
1. set a limitation to prevent from log too much
2. add aee dump on held lock too much
3. ignore performance warning on KASAN/UBSAN load
4. increase size of lockdep chain buffer
5. refine function to dump task stack
6. refine mt_aee_dump_held_locks

MTK-Commit-Id: 5d2ddb79008c3919483973c2e5459e1405f70a30

Change-Id: I8c5d6c467873cdb9be896089cd2d8100b16f11c1
CR-Id: ALPS04994668
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-04-09 10:02:39 +08:00
JianMin Liu
b5d6afbe08 [ALPS04791510] task-turbo: Turbo ability inheritance
Promote normal task to turbo task while turbo-task blocked.
   1) Speedup binder call via infecting turbo ability to binder thread
   2) Speedup sempahores owner if turbo waiting for
   3) Turbo task can preempt others in futex/sempahore waiting queue

   Related trace event:
   a. echo 1 > /d/tracing/events/task_turbo/turbo_set/enable
     - Tracking task set turbo

   b. echo 1 > /d/tracing/events/task_turbo/turbo_inherit_start/enable
      echo 1 > /d/tracing/events/task_turbo/ turbo_inherit_end/enable
     - Tracking task start or end inherit turbo

MTK-Commit-Id: 73406f24e745b0a4c26b5d8c06e9ef6616ada80d

Change-Id: Idb3da6b5f201fa5ee60443d00ac49d7afa93a2c6
Signed-off-by: JianMin Liu <jian-min.liu@mediatek.com>
CR-Id: ALPS04791510
Feature: System Performance
2020-04-09 10:01:07 +08:00
Kobe Wu
23e7aae629 [ALPS04993096] sched_mon: implement schedule monitor v2
refactor schedule monitor functions into four domains
- irq processing time tracer (CONFIG_MTK_SCHED_MONITOR)
- irq count status tracer (CONFIG_MTK_IRQ_COUNT_TRACER)
- irq off tracer (CONFIG_MTK_IRQ_OFF_TRACER)
- preempt off tracer (CONFIG_MTK_PREEMPT_TRACER)

The major changes
- support debug in user load
- support preempt off detection
- support default setting in device tree
- refactor /proc/mtmon architecture
- refactor debug information for aee dump
- move mtk_sched_mon.h to drivers/misc/mediatek/include/mt-plat

MTK-Commit-Id: 16ecf23a9a75a442c612422b5e7648fd5fa04394

Change-Id: Id506d0c76efc99c78ef854c3b54d83650c060a22
CR-Id: ALPS04993096
Feature: [Module]Schedule Monitor
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-22 19:33:11 +08:00
skylake.huang
ed6188ccce [ALPS05012802] [Do NOT Sync]Merge branch android-4.14 into alps-trunk-r0.basic
[Detail]
	Parent: 54236917c6
		Merge 4.14.141 into android-4.14
	Start: a9d0871a56
		ANDROID: fiq_debugger: remove
	Target: 234de92896
		Merge 4.14.150 into android-4.14

MTK-Commit-Id: 2787c355dfe4c7cb54fdbdb5b5099245ff4502b3

Feature: Others
Change-Id: I77184a925c03fcfd29597e0fbf526580e346f90e
CR-Id: ALPS05012802
Signed-off-by: Breeze.Li <breeze.li@mediatek.com>
2020-03-11 18:04:31 +08:00
Kobe Wu
251fb9016b [ALPS04854897] lockdep: add items to critical lock list
add items to critical lock list to avoid deadlock when
invoking aee functions

MTK-Commit-Id: c8d1c73a8679f78586dee3c4467f7f3902d85c5e

Change-Id: Ib38b17160dccb5c3a82e8fe8c6a137683263acc3
CR-Id: ALPS04854897
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-03 04:11:57 +08:00
Kobe Wu
02beb0ad8c [ALPS04810076] locking: fix KE at spinlock_debug
sdi = per_cpu_ptr(&sp_dbg, owner_cpu);
sdi->detector_cpu = -1;

If the lock is already released, owner_cpu would be -1 and
result in kernel exception when access sdi pointer.

MTK-Commit-Id: 58a071c37566f21de74559ec28a94b6e32c011ca

Change-Id: Ic126afcbbfa267ecaffb61b7a5a93717336cd03e
CR-Id: ALPS04810076
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-03 04:11:28 +08:00
skylake.huang
dcfa42e329 [ALPS04748062] [Do NOT Sync]Merge branch android-4.14-q into alps-mp-q0.mp1
[Detail]
	Parent: 574ebb217d
		Merge 4.14.132 into android-4.14-q
	Start: 05206de4e9
		Bluetooth: Fix faulty expression for minimum encryption key size check
	Target: 4a8056990f
		Merge 4.14.138 into android-4.14-q

MTK-Commit-Id: 04610ce90568963b66a378f68a5eeda1d2094668

Feature: Others
Change-Id: I26b26b3970f0dfe231ed6f3de104ea7be0d1a063
CR-Id: ALPS04748062
Signed-off-by: Breeze.Li <breeze.li@mediatek.com>
2020-03-03 04:09:15 +08:00
Kobe Wu
e8a99cb67d [ALPS04715249] lockdep: add port_lock_key to filter
Lockdep should not use printk when port_lock_key is held by
current task. Otherwise it will result in deadlock. Lockdep
will print warning message to trace event when port_lock_key
is already held by current task.

MTK-Commit-Id: af6dd0b10758cb9b0cb30992bd7fb7ba78b79306

Change-Id: I5df76b92df0aa525019deb2fd07eb1eda634f236
CR-Id: ALPS04715249
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-03 04:07:17 +08:00
Kobe Wu
832453cb58 [ALPS04680210] lockdep: fix build error
Fix build error when aee feature is not enabled.

MTK-Commit-Id: 7d416e62fab9593e2277dc8a2faf09a8e31f6ef2

Change-Id: I4aad1d80ea10f55e5a065e8ef614f35b2b4cf504
CR-Id: ALPS04680210
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-03 04:05:25 +08:00
Kobe Wu
1cf50eb7ae [ALPS04683647] lockdep: fix Coverity Scanned Code Defect:8255793
Fix potential integer overflow.

MTK-Commit-Id: a71bad14a38c3aa6392fda1d036fa92d76c4278a

Change-Id: I109b9c5f943dcd0b88c3696f4c960aa2655e1f70
CR-Id: ALPS04683647
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-03 04:05:20 +08:00
Kobe Wu
0298776480 [ALPS04677019] lockdep: introduce spinlock debugger v2
Because the old spinlock debugger might result in rq->lock
lockup in schedule flow. (only occurred on mt6771 Android Q)
We introduce the spinlock debugger v2 to avoid this problem.

The new version wouldnt show warnings when a task is spinning
for a spinlock. It only shows the holding time, spinning time,
and stack trace when a lock is released by the owner and above
the threshold. It wouldnt show magic number and raw_lock value.

MTK-Commit-Id: 1ef4259a053b21af07a6d33d66d629994d90c79e

Change-Id: Ib89b0b9456daa3188c8b8f05a5697849ef5db3ce
CR-Id: ALPS04677019
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-03 04:05:03 +08:00
Kobe Wu
b373b2d100 [ALPS04670617] lockdep: disable spin time warning
This is a temporary patch to disable spinlock debugger
warning on spin time. The root cause of spin time warning
on rq->lock is still under tracking.

MTK-Commit-Id: 1fa36bd2112a6ee68ebf1d0e95054a0d5c42857d

Change-Id: I375b27c2c46883eb0760c5dff532f9c6d8b7e87c
CR-Id: ALPS04670617
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-03 04:04:54 +08:00
Kobe Wu
3b003d22ac [ALPS04659845] lockdep: reduce warning messages
Reduce warning messages of spinlock debugger and lock monitor.
Only trigger aee dump once while more than one task are spinning
for the same spinlock. Remove backtrace of spinning tasks.

MTK-Commit-Id: 732bcd60d3237229bbc614c53f511284dfbe83ac

Change-Id: I25769faede5f49203e5232dd441e1123904dfa3f
CR-Id: ALPS04659845
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-03 04:04:39 +08:00
Kobe Wu
08a13191bb [ALPS04657041] lockdep: enhance spinlock debugger on warning message
Because a spinlock could be held by a task and other tasks are
waiting for it. If each task waiting for the spinlock triggers
an aee dump. It will make system very busy and many similar
warning messages will be shown in kernel log. This patch make
sure that aee dump will be triggered once under some conditions.

MTK-Commit-Id: 5d2505a40d384124ffd53f20b4ff3e3da5e62a27

Change-Id: I0bc3cb6416767758292c6ce63138fed15f89ab69
CR-Id: ALPS04657041
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-03 04:04:18 +08:00
Kobe Wu
93acc1b4e7 [ALPS04655435] lockdep: Fix Coverity Scanned Code Defect: 5470961
check null return from kmalloc

MTK-Commit-Id: 8c7d32162963286d0134e57970be4b10648d366c

Change-Id: I6b9f7284c08b5284bfe28e6251b64bd72a0d7aa8
CR-Id: ALPS04655435
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-03 04:04:17 +08:00
Kobe Wu
5ff521c846 [ALPS04503017] lockdep: fix KE when checking lock->owner
Because locks are acquired and released anytime. If we reserve
lock->owner information without using atomic operation. The
information could be invalid at that moment and results in
kernel exception when reading the information.

We will check the lock->owner information after reserving it
to a local variable. To see the information is valid or not.

MTK-Commit-Id: a314923a1dd34a4da86c1bfc4b9f03065929dbf2

Change-Id: I7150ab58bce45d68505e286e5179a04dc0c26638
CR-Id: ALPS04503017
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-03 04:04:10 +08:00
Kobe Wu
52b3bf2d24 [ALPS04644130] lockdep: enhance spinlock debugger
Before we trigger aee dump in the call flow of spinning task.
Now we trigger aee dump in the call flow of lock owner.
This is helpful to find correct owner directly.

MTK-Commit-Id: ab41c7d331a3f19fd99ec4f4a81721b15f98e682

Change-Id: I8190ffc7e434774409bb3ca0597a367452b396f3
CR-Id: ALPS04644130
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-03 04:03:51 +08:00
Kobe Wu
659f961633 [ALPS04592735] lockdep: fix coverity scanned code defect: 5460745
Fix out-of-bounds read warning.

MTK-Commit-Id: ea87d23a9e6aba007b10fd3b3847af3455aa648a

Change-Id: I286d832a9bd21337eb2356c24115ebb52a509ca2
CR-Id: ALPS04592735
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-03 04:03:42 +08:00
chienwei.chang
17776fea6a [ALPS04522325] [Do NOT Sync]Merge branch android-4.14-q into alps-trunk-q0.basic
[Detail]
	Parent: d5d9c959f5
		Merge 4.14.111 into android-4.14-q
	Start: 94ba035a31
		ANDROID: cuttlefish_defconfig: Enable CONFIG_FUSE_FS
	Target: 817de622e8
		Merge 4.14.121 into android-4.14-q

MTK-Commit-Id: 94ec3d9378bfd9f8bc9d53e6ee6c6b8e864fcf7e

Feature: Others
Change-Id: I5afb6bab1012c807ecc00f37fcf8c90fd867050c
CR-Id: ALPS04522325
Signed-off-by: Breeze.Li <breeze.li@mediatek.com>
2020-03-03 04:03:38 +08:00
Kobe Wu
85bc4a9129 [ALPS04532107] lockdep: add more aee dump
Trigger aee dump on lockdep warnings, then we can be aware of them.

MTK-Commit-Id: 0db5f4acc192b82a7cd15cb15ddf0c9483ab2bea

Change-Id: I3a58b83a61cee9e53874b3a48eeb340721a29d9e
CR-Id: ALPS04532107
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-03 04:02:50 +08:00
Kobe Wu
be79430637 [ALPS04425783] lockdep: add works_lock to critical_lock_list
Lockdep will trigger aee dump when a warning happened. aee dump
works based on workqueue and works_lock is needed by workqueue.
So it should not trigger aee dump when works_lock is already
held by the current task. Otherwise it will result in deadlock.
Add works_lock to checklist and check the list before trigger
aee dump.

MTK-Commit-Id: f948d020881f268a18354c1676c80d5647fbfee3

Change-Id: I0ccf127ca1a8bb928495df563459eddee97daf5e
CR-Id: ALPS04425783
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2020-03-03 04:02:24 +08:00
chienwei.chang
db1c920e12 [ALPS04413516] [Do NOT Sync]Merge branch android-4.14-q into alps-trunk-q0.basic
[Detail]
	Parent: 4344de2f79
		Merge 4.14.108 into android-4.14
	Start: 02b2463554
		ANDROID: dm-bow: Add dm-bow feature
	Target: d5d9c959f5
		Merge 4.14.111 into android-4.14-q

MTK-Commit-Id: ed06e09c1713bb3e2b97245198dbfdae8669f4d8

Feature: Others
Change-Id: Ib81f191c6e12e7812313bddfcc7de94b3770156c
CR-Id: ALPS04413516
2020-03-03 02:11:07 +08:00