Commit Graph

1056196 Commits

Author SHA1 Message Date
Shawn Lin
855b2834d4 mmc: dw_mmc: Fix thunder boot support
Migrate to use new properties.

Fixes: af02b05e59 ("mmc: add thunder boot support")
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Change-Id: I26e1c5b65a994522fdfd5cbc54ed17909bbaa95f
2021-05-17 14:14:43 +08:00
Elaine Zhang
c44e5e04a4 rtc: rtc-rk808: use flag to distinguish chip differences
RK808\RK818 have November 31st,Other chips fixed the problem.

Fixes: f076ef44a4 ("rtc: rk808: Compensate for Rockchip calendar
deviation on November 31st")
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
Change-Id: I8977a14abcc3973728b5941951d17d493b3955d4
2021-05-14 17:36:53 +08:00
shengfei Xu
b3eba31466 rtc: rk808: check the rtc is available
Change-Id: I383c08cd5ad7cb282c0ec0aa12e9e84c9df52ba3
Signed-off-by: shengfei Xu <xsf@rock-chips.com>
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-14 17:36:25 +08:00
shengfei Xu
fd1a4a6389 regulator: rk809 & rk817: correct enable/disable for runtime
Change-Id: I4b4b29c6f31b3c877a3d74d791e14879620c6ff3
Signed-off-by: shengfei Xu <xsf@rock-chips.com>
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-14 15:48:06 +08:00
Joseph Chen
6902a2c176 regulator: rk808: optimise/fix for rk805/816
RK805:
- correct enable/disable for suspend and runtime;
- add individual ramp delay set;
- add of_map_mode definition;
- buck4 has 2 line range group;

RK816:
- clean code;

Other: Add set/get mode for BUCKs.

Change-Id: Ife49259cc57c47fa54d078041724a69a42b0faae
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-14 15:45:12 +08:00
Elaine Zhang
9e18438aa3 regulator: rk808: fix up the set voltage overshoot of Buck1/2
modify the rk808 max steps for increase voltage of Buck1/2,
equal 25mv.

Change-Id: Ic6c016e99ce67f5773d5f5df0b65fa1de10f557a
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-14 15:44:43 +08:00
Elaine Zhang
00ee69d479 mfd: rk808: add rk816 support
include sub modules: regulator, rtc, gpio, pwrkey

Change-Id: I5efedb2abe2be5335c467aaa91955cb7b9f56cfb
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-14 15:41:35 +08:00
shengfei Xu
0276e9624b clk: rockchip: rk3218: add rkclk_cpuclk_div_setting
fix up the RK816 setting voltage drop make the system crash.
Before adjusting voltage, increase clk_cpu div and reduce CPU frequency
Only support for RK312x chips.

Change-Id: Id327da9590f7d9d383450e79acd1b309e05cd024
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
Signed-off-by: shengfei Xu <xsf@rock-chips.com>
2021-05-14 15:40:15 +08:00
Yifeng Zhao
78a35286b8 soc: rockchip: vendor storage: make modules support
This submit supports to compile vendor storage into a module.

Change-Id: Id88bbee6ff44a75b2aa163a669098d410afaa921
Signed-off-by: Yifeng Zhao <zyf@rock-chips.com>
2021-05-14 15:18:06 +08:00
Huibin Hong
81cbaaf3f4 Bluetooth: hci_ldisc: fix race between open, close and send data
Fix the bug below, it may be reproduced after open and close bt about 7000 times:

<1>[73036.938137] Unable to handle kernel NULL pointer dereference at virtual address 0000001c
<1>[73036.939316] pgd = ffffff800886d000
<1>[73036.939627] [0000001c] *pgd=000000000fffe003, *pud=000000000fffe003, *pmd=0000000000000000
<0>[73036.940396] Internal error: Oops: 96000006 [#1] PREEMPT SMP
<4>[73036.940899] Modules linked in:
<4>[73036.941193] CPU: 2 PID: 2989 Comm: kworker/2:2 Not tainted 4.4.138 #3
<4>[73036.942409] Workqueue: events hci_uart_write_work
<4>[73036.942836] task: ffffffc00d688ac0 task.stack: ffffffc00b184000
<4>[73036.943365] PC is at _raw_spin_lock_irqsave+0x1c/0x50
<4>[73036.943815] LR is at skb_dequeue+0x20/0x74
<4>[73036.944185] pc : [<ffffff8008576398>] lr : [<ffffff800840f9a4>] pstate: 800001c5
<4>[73036.944832] sp : ffffffc00b187d00
<4>[73036.945127] x29: ffffffc00b187d00 x28: 0000000000000000
<4>[73036.945620] x27: 0000000000000000 x26: 0000000000000000
<4>[73036.946114] x25: ffffffc00e1280e0 x24: ffffffc00038d000
<4>[73036.946606] x23: ffffffc00e1271f8 x22: ffffffc00e127f00
<4>[73036.947099] x21: 000000000000001c x20: 0000000000000008
<4>[73036.947592] x19: 0000000000000000 x18: 0000000000000000
<4>[73036.948086] x17: 0000007fade08530 x16: ffffff80080e308c
<4>[73036.948579] x15: 0000000000000000 x14: 65736f6c63207568
<4>[73036.949073] x13: 205d303537373339 x12: 2e36333033375b0a
<4>[73036.949566] x11: 3220746e63666572 x10: 00000000000006f0
<4>[73036.950060] x9 : ffffffc00b187d30 x8 : ffffffc00d689210
<4>[73036.950553] x7 : 0000000000002d31 x6 : 0000000000000400
<4>[73036.951046] x5 : 0000000000113d82 x4 : 0000000000002f32
<4>[73036.951539] x3 : 0000000000000140 x2 : ffffffc00d688ac0
<4>[73036.952032] x1 : 0000000000000001 x0 : 000000000000001c
<4>[73037.068289] [<ffffff8008576398>] _raw_spin_lock_irqsave+0x1c/0x50
<4>[73037.068858] [<ffffff8008377094>] h4_dequeue+0x14/0x1c
<4>[73037.069335] [<ffffff8008376924>] hci_uart_write_work+0x50/0x12c
<4>[73037.069893] [<ffffff80080abbc8>] process_one_work+0x1b0/0x294
<4>[73037.070426] [<ffffff80080ac920>] worker_thread+0x2d8/0x398
<4>[73037.070935] [<ffffff80080b0f28>] kthread+0xc8/0xd8
<4>[73037.071388] [<ffffff8008082e80>] ret_from_fork+0x10/0x50

	thread0               		thread1
	   |				   |
	hci_uart_tty_close		hci_uart_write_work
	   |				   |
	h4_close			h4_dequeue
	   |				   |
	free (h4_struct) h4		   |
	   |             _raw_spin_lock_irqsave access h4 null pointer

Change-Id: I61d8ad5fb4c9349e0a304d2e87332681240f22e2
Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
2021-05-12 17:10:00 +08:00
Joseph Chen
a4f43f5dbf mfd: rk808: add sysfs debug node "/sys/rk8xx/rk8xx_dbg"
Change-Id: I197dc97b7337414a7d52426da0e0cb8c7480c917
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-12 15:05:19 +08:00
Elaine Zhang
d23601e505 mfd: rk808: close rtc int when power off
Change-Id: I1f1bfe3d6c106632c45b51bec3c18361572df865
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-12 14:18:10 +08:00
Elaine Zhang
efd02ec172 mfd: rk808: update pre_init_reg for rk805/rk818
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
Change-Id: I1bd9c99a544b4fbda23efc7b5540985048ca2f89
2021-05-12 14:18:10 +08:00
shengfei Xu
25fdb7ec91 mfd: rk808: modify the sequence of the sleep pin function and polarity
The sequence of operations is as follows:
1. disable the sleep pin function
2. modify the sleep pin polarity
3. delay 3 32k clock cycle
4. select the sleep pin function

Signed-off-by: shengfei Xu <xsf@rock-chips.com>
Change-Id: If6df2b2f190951abe9bb31fbd18d9af47e145038
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-12 14:18:10 +08:00
shengfei Xu
f26962f3fb mfd: rk808: update rk817 volatile reg range
Signed-off-by: shengfei Xu <xsf@rock-chips.com>
Change-Id: Ifeb89255a2e98d4d2af92b83726017c2f75ebc92
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-12 14:18:10 +08:00
Joseph Chen
f7bff6ccb3 mfd: rk808: add rk818 suspend/resume registers setting
set 3.4v interrupt signal assert when suspend, set 3.0v shutdown
signal assert when resume.

Change-Id: Id15b721bbdc9665a18cf9946b92c435a23f1666c
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-12 14:18:10 +08:00
shengfei Xu
b2df070509 mfd: rk808: use REGCACHE_RBTREE cache_type for rk817/809
Signed-off-by: shengfei Xu <xsf@rock-chips.com>
Change-Id: I83d6f5f3db906b74760fd32a1c072ac9e4fb956f
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-12 14:18:10 +08:00
Joseph Chen
5a363f34b8 pinctrl: rk805: add rk816 support
RK816 has 1 pin to be used as GPIO or TS function.
When used as GPIO function, the pin can be output or input.

Change-Id: I8607595826ac3125dfa2a4c7c483be6b084204c2
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-12 14:18:10 +08:00
Joseph Chen
e3e0d9035f mfd: rk808: remove rk805 buck1~4 initial setting
This setting will be added by ddr binary when necessary to
handle the high temperature-voltage issue on BUCK3.

Change-Id: Ief7d4954e459317ae571400496c4c5ef74f664af
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-12 14:18:10 +08:00
Joseph Chen
501f6ea1f5 mfd: rk808: add on/off source dump
Show the reason of this power on and last shutdown.

Change-Id: Id540433065859a0c3f4817ed66e295b7c6dfccb5
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-12 14:18:10 +08:00
Joseph Chen
3bb76af1a8 mfd: rk808: update rk818 volatile reg range
The registers relative with fuel gauge must be volatile.

Change-Id: I8e942e8f15f66dabf24ede48b81857947575fa23
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-12 14:18:09 +08:00
Tony Xie
a921d23418 mfd: rk808: Set only resetting pmic register for 817&809.
If the system needs hold register values when system will reboot.
need to set only resetting pmic register for 817&809 forcedly.

When system restart, there are two rst actions of PMIC sleep if
board hardware support:

- 0b'00: reset the PMIC itself completely.
- 0b'01: reset the 'RST' related register only.

In the case of 0b'00, PMIC reset itself which triggers SoC NPOR-reset
at the same time, so the command: reboot load/bootload/recovery, etc
is not effect any more.

We add a cmd list to check if this reboot cmd is what we expect for 0b'01.

Change-Id: Ib4b850c86ec3079cd7e374bc96460ee1532854a2
Signed-off-by: Tony Xie <tony.xie@rock-chips.com>
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-12 14:18:09 +08:00
Tony Xie
2dc862f592 pinctrl: support pinctrl driver for the RK817&RK809 PMIC
Change-Id: I9a24ee0d9266a000d582f8ffff8b0c872e3a0769
Signed-off-by: Tony Xie <tony.xie@rock-chips.com>
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-12 12:19:25 +08:00
Shengfei Xu
d061e5ed5b mfd: rk808: replace power key driver for rk805/rk809/rk817
remove the rk8xx-pwrkey.c file, it's function is same as rk805-pwerkey.c.

Change-Id: Ie8a0559c3a105ec9806f170d0c4d32c2691558c6
Signed-off-by: Shengfei Xu <xsf@rock-chips.com>
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-12 11:58:44 +08:00
Shunhua Lan
d66acca4b6 mfd: rk808: add rk817-codec cell
Change-Id: Ieea7bbeb01b5230e40285819e29f9be6e39cf8ec
Signed-off-by: Shunhua Lan <lsh@rock-chips.com>
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-12 11:58:44 +08:00
Elaine Zhang
262a88a9db regulator: rockchip: lp8752: support lp8752 regulator
updata lp8752 driver.
add devicetree bindings for lp8752.

Change-Id: I21cdbde985d4663862b56c28429c41d9d3c38c36
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
2021-05-11 17:27:34 +08:00
Zain Wang
d08a978984 regulator: mp8865: add regulator driver for MP8865
Change-Id: I5fa8423e5d1e301a008dcdfd60f93c442f6211a8
Signed-off-by: Zain Wang <wzz@rock-chips.com>
2021-05-11 17:22:16 +08:00
Tao Huang
00ff4411ab arm64: rockchip_defconfig: Enable CONFIG_LEDS_TRIGGER_HEARTBEAT
RK3566 EVB use this feature.

Change-Id: I04796360365cf5e06952df5f00e4c7eb8493ea91
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
2021-05-11 16:53:40 +08:00
Andy Yan
7b79b2a308 drm/rockchip: remove MEDIA_BUS_FMT_RGB666_1X7X3_JEIDA
This format is a definition from rockchip rk61x/rk62x
lvds, and has no application scenarios so far.

Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
Change-Id: Ifb139eaf35d5e83fa96579b1dfcf3762556a77a1
2021-05-11 11:54:37 +08:00
Andy Yan
cede6d9291 drm/rockchip: include drm_plane.h for rockchip_drm_vop.h
Fix the follow compile error:
In file included from drivers/gpu/drm/rockchip/rockchip_vop2_reg.c:10:
drivers/gpu/drm/rockchip/rockchip_drm_vop.h:196:22: error: field has
incomplete type 'enum drm_plane_type'
        enum drm_plane_type type;
                            ^
drivers/gpu/drm/rockchip/rockchip_drm_vop.h:196:7: note: forward
declaration of 'enum drm_plane_type'
        enum drm_plane_type type;

This is due to the remove of drmP.h:
commit 4e98f871bc ("drm: delete drmP.h + drm_os_linux.h")

Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
Change-Id: Ic7d1d58d5d4c9c032067c7686c76cef41a92a5d2
2021-05-11 10:25:06 +08:00
Jianqun Xu
fd0a8bdb75 pinctrl: rockchip: remove gpiochip related codes
Remove gpiochip related codes from pinctrl driver, but populate gpio
platform devices from device tree data.

Change-Id: I347acaac2998a972e4c3be5c8827f77f468a7ad2
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
2021-05-10 18:00:36 +08:00
Jianqun Xu
2a120a1f7d gpio: add gpio-rockchip driver
This gpio driver codes mostly are copied from pinctrl-rockchip.c with
module fixes. Also it supports the old dt nodes.

Change-Id: I7f26b5fe0827c16e2146a40e035a81de74284191
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
2021-05-10 18:00:30 +08:00
Tao Huang
30d770b62f soc: rockchip: Add NO_GKI config
Add a Kconfig flag to differentiate between a GKI and an Non GKI build.

Signed-off-by: Tao Huang <huangtao@rock-chips.com>
Change-Id: Ib0c57f7579f2cec06288ac9e063548c6395bf44c
2021-05-10 14:46:11 +08:00
Jianqun Xu
130424767e UPSTREAM: pinctrl: rockchip: do coding style for mux route struct
The mux route tables take many lines for each SoC, and it will be more
instances for newly SoC, that makes the file size increase larger.

This patch only do coding style for mux route struct, by adding a new
definition and replace the structs by script which supplied by
huangtao@rock-chips.com

sed -i -e "
/static struct rockchip_mux_route_data /bcheck
b
:append-next-line
N
:check
/^[^;]*$/bappend-next-line
s/[[:blank:]]*.bank_num = \([[:digit:]]*,\)\n/\tRK_MUXROUTE_SAME(\1/g
s/[[:blank:]]*.pin =[[:blank:]]*0,\n/ RK_PA0,/g
s/[[:blank:]]*.pin =[[:blank:]]*1,\n/ RK_PA1,/g
s/[[:blank:]]*.pin =[[:blank:]]*2,\n/ RK_PA2,/g
s/[[:blank:]]*.pin =[[:blank:]]*3,\n/ RK_PA3,/g
s/[[:blank:]]*.pin =[[:blank:]]*4,\n/ RK_PA4,/g
s/[[:blank:]]*.pin =[[:blank:]]*5,\n/ RK_PA5,/g
s/[[:blank:]]*.pin =[[:blank:]]*6,\n/ RK_PA6,/g
s/[[:blank:]]*.pin =[[:blank:]]*7,\n/ RK_PA7,/g
s/[[:blank:]]*.pin =[[:blank:]]*8,\n/ RK_PB0,/g
s/[[:blank:]]*.pin =[[:blank:]]*9,\n/ RK_PB1,/g
s/[[:blank:]]*.pin =[[:blank:]]*10,\n/ RK_PB2,/g
s/[[:blank:]]*.pin =[[:blank:]]*11,\n/ RK_PB3,/g
s/[[:blank:]]*.pin =[[:blank:]]*12,\n/ RK_PB4,/g
s/[[:blank:]]*.pin =[[:blank:]]*13,\n/ RK_PB5,/g
s/[[:blank:]]*.pin =[[:blank:]]*14,\n/ RK_PB6,/g
s/[[:blank:]]*.pin =[[:blank:]]*15,\n/ RK_PB7,/g
s/[[:blank:]]*.pin =[[:blank:]]*16,\n/ RK_PC0,/g
s/[[:blank:]]*.pin =[[:blank:]]*17,\n/ RK_PC1,/g
s/[[:blank:]]*.pin =[[:blank:]]*18,\n/ RK_PC2,/g
s/[[:blank:]]*.pin =[[:blank:]]*19,\n/ RK_PC3,/g
s/[[:blank:]]*.pin =[[:blank:]]*20,\n/ RK_PC4,/g
s/[[:blank:]]*.pin =[[:blank:]]*21,\n/ RK_PC5,/g
s/[[:blank:]]*.pin =[[:blank:]]*22,\n/ RK_PC6,/g
s/[[:blank:]]*.pin =[[:blank:]]*23,\n/ RK_PC7,/g
s/[[:blank:]]*.pin =[[:blank:]]*24,\n/ RK_PD0,/g
s/[[:blank:]]*.pin =[[:blank:]]*25,\n/ RK_PD1,/g
s/[[:blank:]]*.pin =[[:blank:]]*26,\n/ RK_PD2,/g
s/[[:blank:]]*.pin =[[:blank:]]*27,\n/ RK_PD3,/g
s/[[:blank:]]*.pin =[[:blank:]]*28,\n/ RK_PD4,/g
s/[[:blank:]]*.pin =[[:blank:]]*29,\n/ RK_PD5,/g
s/[[:blank:]]*.pin =[[:blank:]]*30,\n/ RK_PD6,/g
s/[[:blank:]]*.pin =[[:blank:]]*31,\n/ RK_PD7,/g
s/[[:blank:]]*.func = \([[:digit:]]*,\)\n/ \1/g
s/[[:blank:]]*.route_location =[[:blank:]]*\([[:print:]]*,\)\n//g
s/[[:blank:]]*.route_offset = \(0x[[:xdigit:]]*,\)\n/ \1/g
s/[[:blank:]]*.route_val =[[:blank:]]*\([[:print:]]*\),\n/ \1),/g
s/\t{\n//g
s/\t}, {\n//g
s/\t},//g
s/[[:blank:]]*\(\/\*[[:print:]]*\*\/\)\n[[:blank:]]*RK_MUXROUTE_SAME(\([[:print:]]*\)),\n/\tRK_MUXROUTE_SAME(\2), \1\n/g
s/[[:blank:]]*\(\/\*[[:print:]]*\*\/\)\n[[:blank:]]*RK_MUXROUTE_SAME(\([[:print:]]*\)),/\tRK_MUXROUTE_SAME(\2), \1\n/g
" drivers/pinctrl/pinctrl-rockchip.c

Change-Id: I13e11b67026c4e689cee567976c251bc92000a0d
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
Link: https://lore.kernel.org/r/20210420091240.1246429-1-jay.xu@rock-chips.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
(cherry picked from commit fe202ea8e5)
2021-05-10 14:13:52 +08:00
Liu, Changcheng
26004d2275 UPSTREAM: dts: remove cris & metag dts hard link file
arch cris & metag have been removed from supported archs.
The dts hard link files should also be removed, or the ctags
tool will give warning.

execute"ctags -R" or "gtags", output:
ctags: Warning: cannot open source file
"scripts/dtc/include-prefixes/cris" : No such file or directory
ctags: Warning: cannot open source file
"scripts/dtc/include-prefixes/metag" : No such file or directory

This patch was override by commit 9820464afd ("UPSTREAM:
devicetree: Move include prefixes from arch to separate
directory"), so apply it again.

Change-Id: I002617cde3f879bc8364f55502839b3c3cd2dd92
Signed-off-by: Liu Changcheng <changcheng.liu@intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
(cherry picked from commit 8d14f31ec9)
2021-05-08 20:58:44 +08:00
Tao Huang
88c22e1beb Merge remote branch 'android12-5.10' of https://android.googlesource.com/kernel/common
* android12-5.10: (966 commits)
  ANDROID: Support disabling symbol trimming
  ANDROID: Incremental fs: Fix pseudo-file attributes
  ANDROID: sched: Fix missing RQCF_UPDATED in migrate_tasks
  FROMLIST: mm, thp: Relax the VM_DENYWRITE constraint on file-backed THPs
  ANDROID: GKI: Update the generic symbol list
  ANDROID: ABI: Add symbols for crypto
  ANDROID: ABI: Update the ABI XML
  Revert "ANDROID: GKI: Change UCLAMP_BUCKETS_COUNT to 20"
  ANDROID: vendor_hooks: Add hook for binder
  UPSTREAM: crypto: arm/blake2s - fix for big endian
  UPSTREAM: crypto: arm/blake2b - drop unnecessary return statement
  FROMGIT: kasan, arm64: tests supports for HW_TAGS async mode
  FROMGIT: arm64: mte: Report async tag faults before suspend
  FROMGIT: arm64: mte: Enable async tag check fault
  FROMGIT: arm64: mte: Conditionally compile mte_enable_kernel_*()
  ANDROID: ABI: Update the ABI xml
  ANDROID: ABI: Update the generic symbol list
  ANDROID: selinux: add vendor hook in selinux
  FROMGIT: arm64: mte: Enable TCO in functions that can read beyond buffer limits
  ANDROID: sched: Add vendor hooks for update_load_avg
  ...

Change-Id: I74731b47c1f6cd67cea9622113833b3f8c994544
2021-05-03 19:52:23 +08:00
Will McVicker
7919cae0a9 ANDROID: Support disabling symbol trimming
Allow disabling symbol trimming on the command line when running
build.sh. This allows us to make GKI builds without trimming and without
modifying the build config. The main use case is when we want to update
the symbol list in a mixed build system.

Bug: 186549137
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: I16d1c348270b4dbb378f009857286acd7b6d8aa3
2021-04-28 23:52:33 +00:00
Paul Lawrence
327b2266d2 ANDROID: Incremental fs: Fix pseudo-file attributes
Prior change

ANDROID: Incremental fs: stat should return actual used blocks

adds blocks to getattr. Unfortunately the code always looks for the
backing file, and pseudo files don't have backing files, so getattr
fails for pseudo files.

Bug: 186567511
Test: incfs_test passes, can do incremental installs on test device
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: Ia3df87f3683e095d05c822b69747515963c95f1c
(cherry picked from commit 9d00e67d8b)
2021-04-28 22:07:07 +00:00
Stephen Dickey
a64f42d1df ANDROID: sched: Fix missing RQCF_UPDATED in migrate_tasks
Currently, the sched code checks if the rq clock has been
updated after its lock has been held when CONFIG_SCHED_DEBUG
is enabled. It tracks this by clearing the RQCF_UPDATED bit
when a lock is acquired and setting it upon a subsequent
update_rq_clock() call. It warns if rq clock is read without
RQCF_UPDATED flag indicating the code path missed updating
the clock.

When migrate_tasks() is called during a pause_cpus() event,
the local variable orf is updated with the contents of *rf,
prior to the call to update_rq_clock(). As a result, when
migrate_tasks() restores *rf from the local variable the
RQCF_UPDATED flag is lost. This clearing out of the
RQCF_UPDATED flag leads to a warning when the next task
is being pushed out.

For example in migrate_tasks()

   orf = rf; // save flags, RQCF_UPDATE cleared
   update_rq_clock() // set RQCF_UPDATE
   for()
      ...
      __migrate_task(dead_rq, new_cpu)
      ...
      --> if migration, restore dead_rq's flags with orf.
         --> We loose RQCF_UPDATE
	 rq_relock(dead_rq, orf)

This leaves the current cpu's rq clock_update_flags with the
RQCF_UPDATED flag cleared, an error condition with
CONFIG_SCHED_DEBUG enabled.

Fix the issue for by ensuring that the local variable orf
has the RQCF_UPDATED flag set, allowing the current
CPU's rq to have the flag set and leaving it in a good state
for future usage.

pause_cpus() is currently Android specific. As cpu_pause does
not rely on stop_machine_cpuslocked() like the regular
hotunplug path does, there's a risk for another CPU to
read the rq_clock, after we cleared RQCF_UPDATE, when using
pause_cpus(). This change will have little or no impact outside
of Android currently. If pause_cpus() or drain_rq_cpu_stop()
are merged upstream this change should be merged as well.

Bug: 186222712
Change-Id: Id241122e1449cdd4dcd15f94eb68735b40e3d6f5
Signed-off-by: Stephen Dickey <dickey@codeaurora.org>
2021-04-28 21:28:55 +00:00
Collin Fijalkovich
28b4b1588e FROMLIST: mm, thp: Relax the VM_DENYWRITE constraint on file-backed THPs
Transparent huge pages are supported for read-only non-shmem files,
but are only used for vmas with VM_DENYWRITE. This condition ensures that
file THPs are protected from writes while an application is running
(ETXTBSY).  Any existing file THPs are then dropped from the page cache
when a file is opened for write in do_dentry_open(). Since sys_mmap
ignores MAP_DENYWRITE, this constrains the use of file THPs to vmas
produced by execve().

Systems that make heavy use of shared libraries (e.g. Android) are unable
to apply VM_DENYWRITE through the dynamic linker, preventing them from
benefiting from the resultant reduced contention on the TLB.

This patch reduces the constraint on file THPs allowing use with any
executable mapping from a file not opened for write (see
inode_is_open_for_write()). It also introduces additional conditions to
ensure that files opened for write will never be backed by file THPs.

Restricting the use of THPs to executable mappings eliminates the risk that
a read-only file later opened for write would encounter significant
latencies due to page cache truncation.

The ld linker flag '-z max-page-size=(hugepage size)' can be used to
produce executables with the necessary layout. The dynamic linker must
map these file's segments at a hugepage size aligned vma for the mapping to
be backed with THPs.

Comparison of the performance characteristics of 4KB and 2MB-backed
libraries follows; the Android dex2oat tool was used to AOT compile an
example application on a single ARM core.

4KB Pages:
==========

count              event_name            # count / runtime
598,995,035,942    cpu-cycles            # 1.800861 GHz
 81,195,620,851    raw-stall-frontend    # 244.112 M/sec
347,754,466,597    iTLB-loads            # 1.046 G/sec
  2,970,248,900    iTLB-load-misses      # 0.854122% miss rate

Total test time: 332.854998 seconds.

2MB Pages:
==========

count              event_name            # count / runtime
592,872,663,047    cpu-cycles            # 1.800358 GHz
 76,485,624,143    raw-stall-frontend    # 232.261 M/sec
350,478,413,710    iTLB-loads            # 1.064 G/sec
    803,233,322    iTLB-load-misses      # 0.229182% miss rate

Total test time: 329.826087 seconds

A check of /proc/$(pidof dex2oat64)/smaps shows THPs in use:

/apex/com.android.art/lib64/libart.so
FilePmdMapped:      4096 kB

/apex/com.android.art/lib64/libart-compiler.so
FilePmdMapped:      2048 kB

Bug: 158135888
Link: https://lore.kernel.org/patchwork/patch/1408266/

Reviewed-by: William Kucharski <william.kucharski@oracle.com>
Acked-by: Hugh Dickins <hughd@google.com>
Acked-by: Song Liu <song@kernel.org>
Signed-off-by: Collin Fijalkovich <cfijalkovich@google.com>
Change-Id: I75c693a4b4e7526d374ef2c010bde3094233eef2
2021-04-28 18:41:35 +00:00
Saravana Kannan
c2c576792a ANDROID: GKI: Update the generic symbol list
Add a few more symbols.

Bug: 182844240
Signed-off-by: Saravana Kannan <saravanak@google.com>
Change-Id: Ide0ca453ff7819b17264adac6af2df574f8dbced
2021-04-27 21:51:14 -07:00
Elliot Berman
edc5c62da7 ANDROID: ABI: Add symbols for crypto
Add symbols for crypto engine.

Leaf changes summary: 19 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 19 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

19 Added functions:

  [A] 'function int crypto_ahash_digest(ahash_request*)'
  [A] 'function int crypto_ahash_setkey(crypto_ahash*, const u8*, unsigned int)'
  [A] 'function crypto_ahash* crypto_alloc_ahash(const char*, u32, u32)'
  [A] 'function crypto_sync_skcipher* crypto_alloc_sync_skcipher(const char*, u32, u32)'
  [A] 'function crypto_async_request* crypto_dequeue_request(crypto_queue*)'
  [A] 'function int crypto_enqueue_request(crypto_queue*, crypto_async_request*)'
  [A] 'function void crypto_init_queue(crypto_queue*, unsigned int)'
  [A] 'function int crypto_register_aead(aead_alg*)'
  [A] 'function int crypto_register_ahash(ahash_alg*)'
  [A] 'function int crypto_register_algs(crypto_alg*, int)'
  [A] 'function int crypto_register_skcipher(skcipher_alg*)'
  [A] 'function void crypto_unregister_aead(aead_alg*)'
  [A] 'function void crypto_unregister_ahash(ahash_alg*)'
  [A] 'function void crypto_unregister_algs(crypto_alg*, int)'
  [A] 'function void crypto_unregister_skcipher(skcipher_alg*)'
  [A] 'function scatterlist* scatterwalk_ffwd(scatterlist*, scatterlist*, unsigned int)'
  [A] 'function void scatterwalk_map_and_copy(void*, scatterlist*, unsigned int, unsigned int, int)'
  [A] 'function size_t sg_copy_from_buffer(scatterlist*, unsigned int, void*, size_t)'
  [A] 'function size_t sg_copy_to_buffer(scatterlist*, unsigned int, void*, size_t)'

Bug: 185467822
Change-Id: I6d7bf85324852f69c6d5d113ce38e23663523004
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
2021-04-27 15:15:07 -07:00
J. Avila
5a641fb83f ANDROID: ABI: Update the ABI XML
KMI_GENERATION bumped to 3.

Leaf changes summary: 3152 artifacts changed
Changed leaf types summary: 3 leaf types changed
Removed/Changed/Added functions summary: 0 Removed, 3094 Changed, 0 Added function
Removed/Changed/Added variables summary: 0 Removed, 55 Changed, 0 Added variable

Bug: 186415778
Signed-off-by: J. Avila <elavila@google.com>
Change-Id: Ib1b13031e83e293fb761bdd335e5450ae8df3445
2021-04-27 21:08:03 +00:00
J. Avila
39111fc404 Revert "ANDROID: GKI: Change UCLAMP_BUCKETS_COUNT to 20"
This reverts commit 327402e1e9.

Reason for revert: This patch causes us to hit the SCHED_WARN_ON in
uclamp_rq_dec_id. Revert until this is fixed appropriately.

Bug: 186415778
Change-Id: I5be50723b4058008ed24daa7ca303792ba81b567
Signed-off-by: J. Avila <elavila@google.com>
2021-04-27 21:08:02 +00:00
xieliujie
2337b9185a ANDROID: vendor_hooks: Add hook for binder
Add hook to support oem's performance feature.

Bug: 186482511

Signed-off-by: xieliujie <xieliujie@oppo.com>
Change-Id: Ib495e80e569cc293eaa98d87a050aee8915eb415
2021-04-27 19:18:56 +00:00
Eric Biggers
cf881c74d3 UPSTREAM: crypto: arm/blake2s - fix for big endian
The new ARM BLAKE2s code doesn't work correctly (fails the self-tests)
in big endian kernel builds because it doesn't swap the endianness of
the message words when loading them.  Fix this.

Fixes: 5172d322d3 ("crypto: arm/blake2s - add ARM scalar optimized BLAKE2s")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit d2f2516a38)
Bug: 178411248
Change-Id: Iff419963407eeb0435b9550ef126db4bf137a8a1
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-04-27 18:52:26 +00:00
Eric Biggers
0126a08dcd UPSTREAM: crypto: arm/blake2b - drop unnecessary return statement
Neither crypto_unregister_shashes() nor the module_exit function return
a value, so the explicit 'return' is unnecessary.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

(cherry picked from commit 6131e97077)
Bug: 178411248
Change-Id: I2b15c03f1d0379effdf3a2f1d16e79a5ada84362
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-04-27 18:52:16 +00:00
Andrey Konovalov
ccc8708bde FROMGIT: kasan, arm64: tests supports for HW_TAGS async mode
This change adds KASAN-KUnit tests support for the async HW_TAGS mode.

In async mode, tag fault aren't being generated synchronously when a
bad access happens, but are instead explicitly checked for by the kernel.

As each KASAN-KUnit test expect a fault to happen before the test is over,
check for faults as a part of the test handler.

Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lore.kernel.org/r/20210315132019.33202-10-vincenzo.frascino@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 170327579
Bug: 172318110
(cherry picked from commit e80a76aa1a
 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/
 for-next/mte-async-kernel-mode)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: I45a6bc351bce937797b1b08e9220a137225f9d55
2021-04-27 10:40:13 +02:00
Vincenzo Frascino
d5a19199c7 FROMGIT: arm64: mte: Report async tag faults before suspend
When MTE async mode is enabled TFSR_EL1 contains the accumulative
asynchronous tag check faults for EL1 and EL0.

During the suspend/resume operations the firmware might perform some
operations that could change the state of the register resulting in
a spurious tag check fault report.

Report asynchronous tag faults before suspend and clear the TFSR_EL1
register after resume to prevent this to happen.

Cc: Will Deacon <will@kernel.org>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Reviewed-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lore.kernel.org/r/20210315132019.33202-9-vincenzo.frascino@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 170327579
Bug: 172318110
(cherry picked from commit eab0e6e17d
 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/
 for-next/mte-async-kernel-mode)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: I16efc3a886e57ac2f0a4f8a1bc70afcf17a86f26
2021-04-27 10:40:13 +02:00
Vincenzo Frascino
27ecc98407 FROMGIT: arm64: mte: Enable async tag check fault
MTE provides a mode that asynchronously updates the TFSR_EL1 register
when a tag check exception is detected.

To take advantage of this mode the kernel has to verify the status of
the register at:
  1. Context switching
  2. Return to user/EL0 (Not required in entry from EL0 since the kernel
  did not run)
  3. Kernel entry from EL1
  4. Kernel exit to EL1

If the register is non-zero a trace is reported.

Add the required features for EL1 detection and reporting.

Note: ITFSB bit is set in the SCTLR_EL1 register hence it guaranties that
the indirect writes to TFSR_EL1 are synchronized at exception entry to
EL1. On the context switch path the synchronization is guarantied by the
dsb() in __switch_to().
The dsb(nsh) in mte_check_tfsr_exit() is provisional pending
confirmation by the architects.

Cc: Will Deacon <will@kernel.org>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Andrey Konovalov <andreyknvl@google.com>
Tested-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Link: https://lore.kernel.org/r/20210315132019.33202-8-vincenzo.frascino@arm.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 170327579
Bug: 172318110
(cherry picked from commit 65812c6921
 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git/
 for-next/mte-async-kernel-mode)
Signed-off-by: Alexander Potapenko <glider@google.com>
Change-Id: Ia3e8df665b1fd88a50c649a6eda6ee790e28a7d4
2021-04-27 10:40:13 +02:00