542 Commits

Author SHA1 Message Date
Matsvei Niaverau
ed2407d4a8 Merge branch 'android-4.14-stable' of https://android.googlesource.com/kernel/common into lineage-21 2023-12-29 13:52:39 +01:00
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
Matsvei Niaverau
c8c286e8e9 Merge branch 'android-4.14-stable' into lineage-20 2023-11-16 12:48:55 +01:00
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
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
ot_dick.yang
14cc5657fd [ALPS05894440] rtmutex: Remove unused argument from rt_mutex_proxy_unlock()
Nothing uses the argument. Remove it as preparation to use
pi_state_update_owner().

MTK-Commit-Id: 2ed5be187ffd3df7c09d2602d503d4d1d207fb1a

Change-Id: Ib6567d9da83a23f2381f5c3bdfeb4177fc991031
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>
Signed-off-by: ot_dick.yang <ot_dick.yang@mediatek.com>
Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>
CR-Id: ALPS05894440
Feature: Google Security Patch
(cherry picked from commit 4f4f5be764ba502072b2c4e1de8bba3e08d31a0f)
2021-07-14 12:03:31 +08:00
Cheng Jui Wang
aabbe08ba3 [ALPS05573895] lockdep: fix coding defect
handle kmalloc() failure in test function

MTK-Commit-Id: 2af3c0176582e3275c46b6c51cc08fcc354ac959

Change-Id: I06021af3c8516250445b50a4781be9aea7debf9e
CR-Id: ALPS05573895
Feature: [Module]Lockdep
Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>
(cherry picked from commit 29f98f9739d775d3176f6e9175eca2e68f2ce54d)
2021-03-05 11:15:41 +08: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
cd54a2452a [ALPS05361714] 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: 4587e78d4410fd1889bfc2ac87a10c3c50ac73ca

Change-Id: I5a1d95a7c676fbddfe8e5d1efeff40aa0bf1a351
Signed-off-by: Cheng Jui Wang <cheng-jui.wang@mediatek.com>
CR-Id: ALPS05361714
Feature: [Module]Lockdep
2021-01-29 02:23:42 +08:00
Cheng Jui Wang
350fc14903 [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
2021-01-29 02:18:04 +08:00
Kobe Wu
460888aed0 [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>
2021-01-29 02:14:26 +08:00
Kobe Wu
6c6e2bb111 [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>
2021-01-29 02:14:24 +08:00
Kobe Wu
5200982e2a [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>
2021-01-29 02:13:55 +08:00
Kobe Wu
c12056207b [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>
2021-01-29 02:13:53 +08:00
skylake.huang
f22b5719f5 [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>
2021-01-29 02:13:36 +08:00
Kobe Wu
39c1b988d3 [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>
2021-01-29 02:12:31 +08:00
Cheng Jui Wang
b712f0b3e6 [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>
2021-01-29 02:12:26 +08:00
Kobe Wu
8849721401 [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>
2021-01-29 02:12:11 +08:00
skylake.huang
b189fe3e50 [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>
2021-01-29 02:12:11 +08:00
Kobe Wu
73d13c69ca [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
2021-01-29 01:03:55 +08:00
Kobe Wu
700c251ea8 [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>
2021-01-29 01:03:44 +08:00
Kobe Wu
53a5caa7db [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>
2021-01-29 01:03:40 +08:00
Kobe Wu
95aa0968e9 [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>
2021-01-29 01:03:38 +08:00
JianMin Liu
104dbbc6d8 [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
2021-01-29 01:03:16 +08:00
Kobe Wu
8b363ab9af [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>
2021-01-29 01:02:47 +08:00
skylake.huang
dd8609f236 [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>
2021-01-29 01:02:10 +08:00
Kobe Wu
f0468207c9 [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>
2021-01-29 00:59:13 +08:00
Kobe Wu
621e1b42f1 [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>
2021-01-29 00:58:10 +08:00
skylake.huang
33fec9c28e [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>
2021-01-29 00:53:52 +08:00
Kobe Wu
fc57da3b52 [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>
2021-01-29 00:49:46 +08:00
Kobe Wu
44a6a9d51f [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>
2021-01-29 00:45:41 +08:00
Kobe Wu
de41dd4ad9 [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>
2021-01-29 00:45:29 +08:00
Kobe Wu
c877ab62f2 [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>
2021-01-29 00:44:49 +08:00
Kobe Wu
10657099bf [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>
2021-01-29 00:44:26 +08:00
Kobe Wu
235b9fc6d8 [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>
2021-01-29 00:43:54 +08:00
Kobe Wu
6997b3b952 [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>
2021-01-29 00:43:05 +08:00
Kobe Wu
6a5d68040c [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>
2021-01-29 00:43:02 +08:00
Kobe Wu
e060e84178 [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>
2021-01-29 00:42:49 +08:00
Kobe Wu
1d9342db26 [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>
2021-01-29 00:42:12 +08:00
Kobe Wu
d378a0c9a2 [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>
2021-01-29 00:41:53 +08:00
chienwei.chang
709ee0b62c [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>
2021-01-29 00:41:45 +08:00
Kobe Wu
f5d66babb8 [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>
2021-01-29 00:40:09 +08:00
Kobe Wu
6d67002599 [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>
2021-01-29 00:39:19 +08:00
chienwei.chang
eb4002a265 [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
2021-01-29 00:38:50 +08:00
Kobe Wu
c13317ef95 [ALPS04379940] lockdep: fix deadlock condition on pool->lock
When a possible circular locking dependency detected, lockdep
have to invoke kernel API dump to keep warning message. But kernel
API dump works based on workqueue and pool->lock is needed by
workqueue. If pool->lock is already held by current task, invoking
kernel API dump will result in deadlock on pool->lock.

The solution is to check if pool->lock is held by current task and
dont invoke kernel API dump to avoid deadlock.

MTK-Commit-Id: d6645694f271119aa2019b0407109850ec22ced6

Change-Id: I680dceed71e0e8d0677c2c42fea3c7657e5d72a7
CR-Id: ALPS04379940
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
(cherry picked from commit 1fd08092895a71a2972f92bdd7ae78c7738a4a54)
2021-01-29 00:37:49 +08:00
Kobe Wu
822cf70c5d [ALPS04355347] lockdep: enhance lock debugging function
1. verify lockdep lifetime
2. dump held locks when rcu stalls on CPU/task
3. adjust aee_dump position
4. improve lockdep selftest cases
5. print warning message to trace when printk is unusable
6. skip UBSAN checking in lockdep.c
7. add false alarm cases to filter

MTK-Commit-Id: a610ff8aa5a0d25a119898ceb69aae4cbb1213f6

Change-Id: Ieb7054ef94676f3b4d77c3c00706671d4e238826
CR-Id: ALPS04355347
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
2021-01-29 00:37:45 +08:00
chienwei.chang
8b95036430 [ALPS04364611] [Do NOT Sync]Merge branch android-4.14 into alps-trunk-q0.basic
[Detail]
	Parent: da2880fa47
		Merge 4.14.93 into android-4.14
	Start: 8a007427f6
		ANDROID: f2fs Complement android_fs tracepoint of read path
	Target: 4344de2f79
		Merge 4.14.108 into android-4.14

MTK-Commit-Id: bac56dd9552f982f7d0aad785bfb97de6f3e06e6

Feature: Others
Change-Id: Iff41f5ea1eb07b7571d29341653fec634b94a5ac
CR-Id: ALPS04364611
2021-01-29 00:37:28 +08:00
chienwei.chang
a606ae0065 [ALPS04262290] [Do NOT Sync]Merge branch android-4.14 into alps-dev-q0.bsp
[Detail]
	Parent: 4ee7197c44
		Merge 4.14.88 into android-4.14
	Start: da4b692991
		ipv4: ipv6: netfilter: Adjust the frag mem limit when truesize changes
	Target: 7d2d5fc1ac
		Merge 4.14.91 into android-4.14

MTK-Commit-Id: c1bea329c322f93b527a3248ff04076738197815

Feature: Others
Change-Id: I8a6def71372a7ba85e341d7d9c1b49b78d192bd1
CR-Id: ALPS04262290
2021-01-28 20:13:47 +08:00
chienwei.chang
6c70fc17f3 [ALPS04211977] [Do NOT Sync]Merge branch android-4.14 into alps-dev-q0.bsp
[Detail]
	Parent: 494c2659e6
		Merge 4.14.80 into android-4.14
	Start: 97c308ca40
		ANDROID: zram: set comp_len to PAGE_SIZE when page is huge
	Target: ea91d158d7
		Merge 4.14.83 into android-4.14

MTK-Commit-Id: 8c540dda2fc19800981e5230168877a8115181de

Feature: Others
Change-Id: I6ae42e29075e74b4ba12745df6c39776f0a5751e
CR-Id: ALPS04211977
2021-01-28 19:37:48 +08:00
Kobe Wu
d5eb0b95d0 [ALPS04182361] lockdep: prevent deadlock and improve spinlock log
1. prevent deadlock in aee_kernel_warning_api
2. prevent deadlock in smp_call_function_single
3. improve debug log in __spin_lock_debug

MTK-Commit-Id: b8563cc91f1bb81e7a03d31a0d2d8827fd572ea4

Change-Id: Ieb9f6536a6a1cd24b3999e32494f00baac478f8d
CR-Id: ALPS04182361
Feature: [Module]Lockdep
Signed-off-by: Kobe Wu <kobe-cp.wu@mediatek.com>
(cherry-pick from 650b2dad47e95d51b190afa1d3e1b8c04698b846)
2021-01-28 19:25:53 +08:00