• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git a/Makefile b/Makefile
2index 50696cff4..b49495d39 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -1236,9 +1236,15 @@ include/config/kernel.release: FORCE
6 # Carefully list dependencies so we do not try to build scripts twice
7 # in parallel
8 PHONY += scripts
9-scripts: scripts_basic scripts_dtc
10+scripts: scripts_basic scripts_dtc vendor_scripts
11 	$(Q)$(MAKE) $(build)=$(@)
12
13+ifdef CONFIG_ARCH_ROCKCHIP
14+PHONY += vendor_scripts
15+vendor_scripts:
16+	$(Q)$(MAKE) $(build)=$(KERNEL_SOURCE_PATH)/scripts
17+endif
18+
19 # Things we need to do before we recursively start building the kernel
20 # or the modules are listed in "prepare".
21 # A multi level approach is used. prepareN is processed before prepareN-1.
22@@ -1388,12 +1394,18 @@ kselftest-merge:
23
24 ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),)
25 dtstree := arch/$(SRCARCH)/boot/dts
26+vendortree := $(KERNEL_SOURCE_PATH)/arch/arm64/boot/dts
27+objdtstree := $(KBUILD_OUTPUT)/arch/arm64/boot/dts/rockchip
28 endif
29
30 ifneq ($(dtstree),)
31
32+ifneq ($(objdtstree),)
33+$(shell mkdir -p $(objdtstree))
34+
35 %.dtb: include/config/kernel.release scripts_dtc
36-	$(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@
37+	$(Q)$(MAKE) $(build)=$(vendortree) $(vendortree)/$@
38+endif
39
40 PHONY += dtbs dtbs_install dtbs_check
41 dtbs: include/config/kernel.release scripts_dtc
42diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c
43index f0d51dd21..c81fbe355 100644
44--- a/fs/ubifs/recovery.c
45+++ b/fs/ubifs/recovery.c
46@@ -662,10 +662,43 @@ struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum,
47 			offs += ret;
48 			buf += ret;
49 			len -= ret;
50-		} else if (ret == SCANNED_EMPTY_SPACE ||
51-			   ret == SCANNED_GARBAGE     ||
52-			   ret == SCANNED_A_BAD_PAD_NODE ||
53-			   ret == SCANNED_A_CORRUPT_NODE) {
54+		} else if (ret == SCANNED_A_CORRUPT_NODE) {
55+			dbg_rcvry("found corruption (%d) at %d:%d",
56+				  ret, lnum, offs);
57+			if (ubifs_check_node(c, buf, len, lnum, offs, 1, 1) == -EUCLEAN &&
58+			    !no_more_nodes(c, buf, len, lnum, offs)) {
59+				int skip;
60+				struct ubifs_ch *ch = buf;
61+
62+				/*
63+				 * If the flash voltage power down suddenly in the programming
64+				 * process, it may lead to abnormal data written by the flash
65+				 * in the low-voltage operation process, and the last data
66+				 * should be discarded.
67+				 */
68+				ubifs_msg(c, "recovery corrupt node\n");
69+				skip = ALIGN(offs + le32_to_cpu(ch->len), c->max_write_size) - offs;
70+				memset(buf + skip, 0xff, len - skip);
71+			}
72+
73+			break;
74+		} else if (ret == SCANNED_EMPTY_SPACE) {
75+			dbg_rcvry("found corruption (%d) at %d:%d",
76+				  ret, lnum, offs);
77+			if (!is_empty(buf, len) && !is_last_write(c, buf, offs)) {
78+				/*
79+				 * If the flash voltage power down suddenly in the programming
80+				 * process, it may lead to the data was programmed to the wroge
81+				 * page written by the flash in the low-voltage operation process,
82+				 * and the data should be discarded.
83+				 */
84+				ubifs_msg(c, "recovery empty space\n");
85+				memset(buf, 0xff, len);
86+			}
87+
88+			break;
89+		} else if (ret == SCANNED_GARBAGE     ||
90+			   ret == SCANNED_A_BAD_PAD_NODE) {
91 			dbg_rcvry("found corruption (%d) at %d:%d",
92 				  ret, lnum, offs);
93 			break;
94diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
95index 511c9363e..2bfbcf28b 100644
96--- a/fs/xfs/xfs_inode.c
97+++ b/fs/xfs/xfs_inode.c
98@@ -802,7 +802,6 @@ xfs_ialloc(
99 	xfs_buf_t	**ialloc_context,
100 	xfs_inode_t	**ipp)
101 {
102-	struct inode *dir = pip ? VFS_I(pip) : NULL;
103 	struct xfs_mount *mp = tp->t_mountp;
104 	xfs_ino_t	ino;
105 	xfs_inode_t	*ip;
106@@ -848,17 +847,18 @@ xfs_ialloc(
107 		return error;
108 	ASSERT(ip != NULL);
109 	inode = VFS_I(ip);
110+	inode->i_mode = mode;
111 	set_nlink(inode, nlink);
112+	inode->i_uid = current_fsuid();
113 	inode->i_rdev = rdev;
114 	ip->i_d.di_projid = prid;
115
116-	if (dir && !(dir->i_mode & S_ISGID) &&
117-			(mp->m_flags & XFS_MOUNT_GRPID)) {
118-		inode->i_uid = current_fsuid();
119-		inode->i_gid = dir->i_gid;
120-		inode->i_mode = mode;
121+	if (pip && XFS_INHERIT_GID(pip)) {
122+		inode->i_gid = VFS_I(pip)->i_gid;
123+		if ((VFS_I(pip)->i_mode & S_ISGID) && S_ISDIR(mode))
124+			inode->i_mode |= S_ISGID;
125 	} else {
126-		inode_init_owner(inode, dir, mode);
127+		inode->i_gid = current_fsgid();
128 	}
129
130 	/*
131diff --git a/init/Kconfig b/init/Kconfig
132index 7acf079f9..17d0151bb 100644
133--- a/init/Kconfig
134+++ b/init/Kconfig
135@@ -1348,6 +1348,12 @@ if BLK_DEV_INITRD
136
137 source "usr/Kconfig"
138
139+config INITRD_ASYNC
140+	bool "Initrd async"
141+	depends on NO_GKI
142+	help
143+	  Init ramdisk async, can reduce kernel init time.
144+
145 endif
146
147 config BOOT_CONFIG
148diff --git a/init/initramfs.c b/init/initramfs.c
149index 55b74d7e5..f4c4e2404 100644
150--- a/init/initramfs.c
151+++ b/init/initramfs.c
152@@ -12,6 +12,7 @@
153 #include <linux/file.h>
154 #include <linux/memblock.h>
155 #include <linux/namei.h>
156+#include <linux/initramfs.h>
157 #include <linux/init_syscalls.h>
158
159 static ssize_t __init xwrite(struct file *file, const char *p, size_t count,
160@@ -465,6 +466,9 @@ static char * __init unpack_to_rootfs(char *buf, unsigned long len)
161 	state = Start;
162 	this_header = 0;
163 	message = NULL;
164+#if defined(CONFIG_ROCKCHIP_THUNDER_BOOT) && defined(CONFIG_ROCKCHIP_HW_DECOMPRESS) && defined(CONFIG_INITRD_ASYNC)
165+	wait_initrd_hw_decom_done();
166+#endif
167 	while (!message && len) {
168 		loff_t saved_offset = this_header;
169 		if (*buf == '0' && !(this_header & 3)) {
170@@ -639,4 +643,23 @@ static int __init populate_rootfs(void)
171 	flush_delayed_fput();
172 	return 0;
173 }
174+
175+#if IS_BUILTIN(CONFIG_INITRD_ASYNC)
176+#include <linux/kthread.h>
177+#include <linux/async.h>
178+
179+static void __init unpack_rootfs_async(void *unused, async_cookie_t cookie)
180+{
181+	populate_rootfs();
182+}
183+
184+static int __init populate_rootfs_async(void)
185+{
186+	async_schedule(unpack_rootfs_async, NULL);
187+	return 0;
188+}
189+
190+pure_initcall(populate_rootfs_async);
191+#else
192 rootfs_initcall(populate_rootfs);
193+#endif
194diff --git a/init/main.c b/init/main.c
195index e8d5c6477..885ce026d 100644
196--- a/init/main.c
197+++ b/init/main.c
198@@ -1533,6 +1533,10 @@ static noinline void __init kernel_init_freeable(void)
199 	smp_init();
200 	sched_init_smp();
201
202+#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT
203+	kthread_run(defer_free_memblock, NULL, "defer_mem");
204+#endif
205+
206 	padata_init();
207 	page_alloc_init_late();
208 	/* Initialize page ext after all struct pages are initialized. */
209@@ -1542,6 +1546,10 @@ static noinline void __init kernel_init_freeable(void)
210
211 	kunit_run_all_tests();
212
213+#if IS_BUILTIN(CONFIG_INITRD_ASYNC)
214+	async_synchronize_full();
215+#endif
216+
217 	console_on_rootfs();
218
219 	/*
220diff --git a/ipc/msg.c b/ipc/msg.c
221index 8ded6b8f1..6e6c8e0c9 100644
222--- a/ipc/msg.c
223+++ b/ipc/msg.c
224@@ -147,7 +147,7 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params)
225 	key_t key = params->key;
226 	int msgflg = params->flg;
227
228-	msq = kvmalloc(sizeof(*msq), GFP_KERNEL_ACCOUNT);
229+	msq = kvmalloc(sizeof(*msq), GFP_KERNEL);
230 	if (unlikely(!msq))
231 		return -ENOMEM;
232
233diff --git a/ipc/sem.c b/ipc/sem.c
234index d3b9b73cd..7d9c06b0a 100644
235--- a/ipc/sem.c
236+++ b/ipc/sem.c
237@@ -511,7 +511,7 @@ static struct sem_array *sem_alloc(size_t nsems)
238 	if (nsems > (INT_MAX - sizeof(*sma)) / sizeof(sma->sems[0]))
239 		return NULL;
240
241-	sma = kvzalloc(struct_size(sma, sems, nsems), GFP_KERNEL_ACCOUNT);
242+	sma = kvzalloc(struct_size(sma, sems, nsems), GFP_KERNEL);
243 	if (unlikely(!sma))
244 		return NULL;
245
246@@ -1852,7 +1852,7 @@ static inline int get_undo_list(struct sem_undo_list **undo_listp)
247
248 	undo_list = current->sysvsem.undo_list;
249 	if (!undo_list) {
250-		undo_list = kzalloc(sizeof(*undo_list), GFP_KERNEL_ACCOUNT);
251+		undo_list = kzalloc(sizeof(*undo_list), GFP_KERNEL);
252 		if (undo_list == NULL)
253 			return -ENOMEM;
254 		spin_lock_init(&undo_list->lock);
255@@ -1937,7 +1937,7 @@ static struct sem_undo *find_alloc_undo(struct ipc_namespace *ns, int semid)
256 	rcu_read_unlock();
257
258 	/* step 2: allocate new undo structure */
259-	new = kzalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, GFP_KERNEL_ACCOUNT);
260+	new = kzalloc(sizeof(struct sem_undo) + sizeof(short)*nsems, GFP_KERNEL);
261 	if (!new) {
262 		ipc_rcu_putref(&sma->sem_perm, sem_rcu_free);
263 		return ERR_PTR(-ENOMEM);
264diff --git a/ipc/shm.c b/ipc/shm.c
265index b418731d6..471ac3e74 100644
266--- a/ipc/shm.c
267+++ b/ipc/shm.c
268@@ -711,7 +711,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
269 			ns->shm_tot + numpages > ns->shm_ctlall)
270 		return -ENOSPC;
271
272-	shp = kvmalloc(sizeof(*shp), GFP_KERNEL_ACCOUNT);
273+	shp = kvmalloc(sizeof(*shp), GFP_KERNEL);
274 	if (unlikely(!shp))
275 		return -ENOMEM;
276
277diff --git a/ipc/util.c b/ipc/util.c
278index 7c3601dad..bbb5190af 100644
279--- a/ipc/util.c
280+++ b/ipc/util.c
281@@ -754,13 +754,21 @@ struct pid_namespace *ipc_seq_pid_ns(struct seq_file *s)
282 static struct kern_ipc_perm *sysvipc_find_ipc(struct ipc_ids *ids, loff_t pos,
283 					      loff_t *new_pos)
284 {
285-	struct kern_ipc_perm *ipc = NULL;
286-	int max_idx = ipc_get_maxidx(ids);
287+	struct kern_ipc_perm *ipc;
288+	int total, id;
289+
290+	total = 0;
291+	for (id = 0; id < pos && total < ids->in_use; id++) {
292+		ipc = idr_find(&ids->ipcs_idr, id);
293+		if (ipc != NULL)
294+			total++;
295+	}
296
297-	if (max_idx == -1 || pos > max_idx)
298+	ipc = NULL;
299+	if (total >= ids->in_use)
300 		goto out;
301
302-	for (; pos <= max_idx; pos++) {
303+	for (; pos < ipc_mni; pos++) {
304 		ipc = idr_find(&ids->ipcs_idr, pos);
305 		if (ipc != NULL) {
306 			rcu_read_lock();
307diff --git a/make-boot.sh b/make-boot.sh
308new file mode 100755
309index 000000000..d512e8a88
310--- /dev/null
311+++ b/make-boot.sh
312@@ -0,0 +1,33 @@
313+#!/bin/bash
314+
315+set -e
316+
317+root_path=$(cd $(dirname $0); pwd)
318+root_out_dir=${root_path%kernel*}
319+BOOT_LINUX=${root_out_dir}/kernel/src_tmp/linux-5.10
320+OUT_IMAGE=${root_out_dir}/yangfan/packages/phone/images/
321+IMAGE_SIZE=64  # 64M
322+IMAGE_BLOCKS=4096
323+
324+BUILD_PATH=boot_linux
325+EXTLINUX_PATH=${BUILD_PATH}/extlinux
326+EXTLINUX_CONF=${EXTLINUX_PATH}/extlinux.conf
327+
328+function make_boot_image()
329+{
330+        blocks=${IMAGE_BLOCKS}
331+        block_size=$((${IMAGE_SIZE} * 1024 * 1024 / ${blocks}))
332+        echo "blocks = ${blocks}  block_size ${block_size}"
333+        if [ "`uname -m`" == "aarch64" ]; then
334+                echo y | sudo mke2fs -b ${block_size} -d boot_linux -i 8192 -t ext2 boot_linux.img ${blocks}
335+        else
336+                genext2fs -B ${blocks} -b ${block_size} -d boot_linux -i 8192 -U boot_linux.img
337+        fi
338+
339+        return $?
340+}
341+
342+cd ${BOOT_LINUX}
343+make_boot_image
344+cd -
345+cp ${BOOT_LINUX}/boot_linux.img ${OUT_IMAGE}
346diff --git a/make-ohos.sh b/make-ohos.sh
347new file mode 100755
348index 000000000..8f4a4e4d7
349--- /dev/null
350+++ b/make-ohos.sh
351@@ -0,0 +1,139 @@
352+#!/bin/bash
353+
354+set -e
355+
356+real_path=$(cd $(dirname $0); pwd)
357+
358+export PRODUCT_PATH=vendor/isoftstone/yangfan
359+export KERNEL_SOURCE_PATH=${real_path%out*}${PRODUCT_PATH}/kernel_core
360+export PATH=${real_path%out*}prebuilts/clang/ohos/linux-x86_64/llvm/bin/:$PATH
361+export KBUILD_OUTPUT=${real_path%out*}/out/kernel/OBJ/linux-5.10
362+IMAGE_SIZE=64  # 64M
363+IMAGE_BLOCKS=4096
364+
365+CPUs=`sed -n "N;/processor/p" /proc/cpuinfo|wc -l`
366+MAKE="make LLVM=1 LLVM_IAS=1 CROSS_COMPILE=../../../../prebuilts/gcc/linux-x86/aarch64/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-"
367+BUILD_PATH=boot_linux
368+EXTLINUX_PATH=${BUILD_PATH}/extlinux
369+EXTLINUX_CONF=${EXTLINUX_PATH}/extlinux.conf
370+SAPPHIRE_DTB=sapphire.dtb
371+
372+MCU_LIB_FILE=${real_path%out*}device/board/isoftstone/yangfan/kernel/src/mcu/*.o
373+MCU_OBJ_PATCH=drivers/char
374+if [ ${KBUILD_OUTPUT} ]; then
375+	OBJ_PATH=${KBUILD_OUTPUT}/
376+fi
377+
378+ID_MODEL=1
379+ID_ARCH=2
380+ID_UART=3
381+ID_DTB=4
382+ID_IMAGE=5
383+ID_CONF=6
384+model_list=(
385+	"TB-RK3568X0   arm64 0xfe660000 rk3568-toybrick-x0-linux  Image rockchip_linux_defconfig"
386+	"sapphire-rk3399 arm64 0xff1a0000 rk3399-sapphire-excavator-linux  Image rockchip_linux_defconfig"
387+	"sapphire-rk3399T arm64 0xff1a0000 rk3399-sapphire-excavator-linux-3399t  Image rockchip_linux_defconfig"
388+)
389+
390+
391+function help()
392+{
393+	echo "Usage: ./make-ohos.sh {BOARD_NAME} KBUILD_OUTPUT=../../OBJ/linux-5.10"
394+	echo "e.g."
395+	for i in "${model_list[@]}"; do
396+		echo "  ./make-ohos.sh $(echo $i | awk '{print $1}') KBUILD_OUTPUT=../../OBJ/linux-5.10"
397+	done
398+}
399+
400+
401+function make_extlinux_conf()
402+{
403+	dtb_path=$1
404+	uart=$2
405+	image=$3
406+
407+	echo "label rockchip-kernel-5.10" > ${EXTLINUX_CONF}
408+	echo "	kernel /extlinux/${image}" >> ${EXTLINUX_CONF}
409+	echo "	fdt /extlinux/${SAPPHIRE_DTB}" >> ${EXTLINUX_CONF}
410+	cmdline="append earlycon=uart8250,mmio32,${uart} root=PARTUUID=614e0000-0000-4b53-8000-1d28000054a9 rw rootwait rootfstype=ext4"
411+	echo "  ${cmdline}" >> ${EXTLINUX_CONF}
412+}
413+
414+function make_kernel_image()
415+{
416+	arch=$1
417+	conf=$2
418+	dtb=$3
419+
420+	${MAKE} ARCH=${arch} ${conf}
421+	if [ $? -ne 0 ]; then
422+		echo "FAIL: ${MAKE} ARCH=${arch} ${conf}"
423+		return -1
424+	fi
425+
426+	${MAKE} ARCH=${arch} ${dtb}.img -j${CPUs}
427+	if [ $? -ne 0 ]; then
428+		echo "FAIL: ${MAKE} ARCH=${arch} ${dtb}.img"
429+		return -2
430+	fi
431+
432+	return 0
433+}
434+
435+function make_ext2_image()
436+{
437+	blocks=${IMAGE_BLOCKS}
438+	block_size=$((${IMAGE_SIZE} * 1024 * 1024 / ${blocks}))
439+
440+	if [ "`uname -m`" == "aarch64" ]; then
441+		echo y | sudo mke2fs -b ${block_size} -d boot_linux -i 8192 -t ext2 boot_linux.img ${blocks}
442+	else
443+		genext2fs -B ${blocks} -b ${block_size} -d boot_linux -i 8192 -U boot_linux.img
444+	fi
445+
446+	return $?
447+}
448+
449+function make_boot_linux()
450+{
451+	arch=${!ID_ARCH}
452+	uart=${!ID_UART}
453+	dtb=${!ID_DTB}
454+	image=${!ID_IMAGE}
455+	conf=${!ID_CONF}
456+	if [ ${arch} == "arm" ]; then
457+		dtb_path=arch/arm/boot/dts
458+	else
459+		dtb_path=arch/arm64/boot/dts/rockchip
460+	fi
461+
462+	rm -rf ${BUILD_PATH}
463+	mkdir -p ${EXTLINUX_PATH}
464+
465+	make_kernel_image ${arch} ${conf} ${dtb}
466+	if [ $? -ne 0 ]; then
467+		exit 1
468+	fi
469+	make_extlinux_conf ${dtb_path} ${uart} ${image}
470+	cp -f ${OBJ_PATH}arch/${arch}/boot/${image} ${EXTLINUX_PATH}/
471+	cp -f ${OBJ_PATH}${dtb_path}/${dtb}.dtb ${EXTLINUX_PATH}/${SAPPHIRE_DTB}
472+	cp -f logo*.bmp ${BUILD_PATH}/
473+	if [ "enable_ramdisk" != "${ramdisk_flag}" ]; then
474+		make_ext2_image
475+	fi
476+}
477+
478+ramdisk_flag=$2
479+found=0
480+cp -arf ${MCU_LIB_FILE} ${MCU_OBJ_PATCH}/
481+for i in "${model_list[@]}"; do
482+	if [ "$(echo $i | awk '{print $1}')" == "$1" ]; then
483+		make_boot_linux $i
484+		found=1
485+	fi
486+done
487+
488+if [ ${found} -eq 0 ]; then
489+	help
490+fi
491diff --git a/mm/hugetlb.c b/mm/hugetlb.c
492index 4ecf9a062..20277864c 100644
493--- a/mm/hugetlb.c
494+++ b/mm/hugetlb.c
495@@ -3932,7 +3932,6 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
496 	struct hstate *h = hstate_vma(vma);
497 	unsigned long sz = huge_page_size(h);
498 	struct mmu_notifier_range range;
499-	bool force_flush = false;
500
501 	WARN_ON(!is_vm_hugetlb_page(vma));
502 	BUG_ON(start & ~huge_page_mask(h));
503@@ -3961,8 +3960,10 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
504 		ptl = huge_pte_lock(h, mm, ptep);
505 		if (huge_pmd_unshare(mm, vma, &address, ptep)) {
506 			spin_unlock(ptl);
507-			tlb_flush_pmd_range(tlb, address & PUD_MASK, PUD_SIZE);
508-			force_flush = true;
509+			/*
510+			 * We just unmapped a page of PMDs by clearing a PUD.
511+			 * The caller's TLB flush range should cover this area.
512+			 */
513 			continue;
514 		}
515
516@@ -4019,22 +4020,6 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
517 	}
518 	mmu_notifier_invalidate_range_end(&range);
519 	tlb_end_vma(tlb, vma);
520-
521-	/*
522-	 * If we unshared PMDs, the TLB flush was not recorded in mmu_gather. We
523-	 * could defer the flush until now, since by holding i_mmap_rwsem we
524-	 * guaranteed that the last refernece would not be dropped. But we must
525-	 * do the flushing before we return, as otherwise i_mmap_rwsem will be
526-	 * dropped and the last reference to the shared PMDs page might be
527-	 * dropped as well.
528-	 *
529-	 * In theory we could defer the freeing of the PMD pages as well, but
530-	 * huge_pmd_unshare() relies on the exact page_count for the PMD page to
531-	 * detect sharing, so we cannot defer the release of the page either.
532-	 * Instead, do flush now.
533-	 */
534-	if (force_flush)
535-		tlb_flush_mmu_tlbonly(tlb);
536 }
537
538 void __unmap_hugepage_range_final(struct mmu_gather *tlb,
539diff --git a/mm/memblock.c b/mm/memblock.c
540index faa4de579..3f3254627 100644
541--- a/mm/memblock.c
542+++ b/mm/memblock.c
543@@ -97,6 +97,26 @@ struct pglist_data __refdata contig_page_data;
544 EXPORT_SYMBOL(contig_page_data);
545 #endif
546
547+#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT
548+static unsigned long defer_start __initdata;
549+static unsigned long defer_end __initdata;
550+
551+#define DEFAULT_DEFER_FREE_BLOCK_SIZE SZ_256M
552+static unsigned long defer_free_block_size __initdata =
553+	DEFAULT_DEFER_FREE_BLOCK_SIZE;
554+
555+static int __init early_defer_free_block_size(char *p)
556+{
557+	defer_free_block_size = memparse(p, &p);
558+
559+	pr_debug("defer_free_block_size = 0x%lx\n", defer_free_block_size);
560+
561+	return 0;
562+}
563+
564+early_param("defer_free_block_size", early_defer_free_block_size);
565+#endif
566+
567 unsigned long max_low_pfn;
568 unsigned long min_low_pfn;
569 unsigned long max_pfn;
570@@ -1907,6 +1927,28 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)
571 	}
572 }
573
574+#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT
575+int __init defer_free_memblock(void *unused)
576+{
577+	if (defer_start == 0)
578+		return 0;
579+
580+	pr_debug("start = %ld, end = %ld\n", defer_start, defer_end);
581+
582+	__free_pages_memory(defer_start, defer_end);
583+
584+	totalram_pages_add(defer_end - defer_start);
585+
586+	pr_info("%s: size %luM free %luM [%luM - %luM] total %luM\n", __func__,
587+		defer_free_block_size >> 20,
588+		(defer_end - defer_start) >> (20 - PAGE_SHIFT),
589+		defer_end >> (20 - PAGE_SHIFT),
590+		defer_start >> (20 - PAGE_SHIFT),
591+		totalram_pages() >> (20 - PAGE_SHIFT));
592+	return 0;
593+}
594+#endif
595+
596 static unsigned long __init __free_memory_core(phys_addr_t start,
597 				 phys_addr_t end)
598 {
599@@ -1917,6 +1959,15 @@ static unsigned long __init __free_memory_core(phys_addr_t start,
600 	if (start_pfn >= end_pfn)
601 		return 0;
602
603+#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT
604+	if ((end - start) > defer_free_block_size) {
605+		defer_start = start_pfn;
606+		defer_end = end_pfn;
607+
608+		return 0;
609+	}
610+#endif
611+
612 	__free_pages_memory(start_pfn, end_pfn);
613
614 	return end_pfn - start_pfn;
615diff --git a/mm/page_alloc.c b/mm/page_alloc.c
616index 85e48479c..dbfb65fb7 100644
617--- a/mm/page_alloc.c
618+++ b/mm/page_alloc.c
619@@ -1445,9 +1445,15 @@ static void free_one_page(struct zone *zone,
620 }
621
622 static void __meminit __init_single_page(struct page *page, unsigned long pfn,
623-				unsigned long zone, int nid)
624+				unsigned long zone, int nid,
625+				bool zero_page_struct __maybe_unused)
626 {
627+#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT
628+	if (zero_page_struct)
629+		mm_zero_struct_page(page);
630+#else
631 	mm_zero_struct_page(page);
632+#endif
633 	set_page_links(page, zone, nid, pfn);
634 	init_page_count(page);
635 	page_mapcount_reset(page);
636@@ -1480,7 +1486,7 @@ static void __meminit init_reserved_page(unsigned long pfn)
637 		if (pfn >= zone->zone_start_pfn && pfn < zone_end_pfn(zone))
638 			break;
639 	}
640-	__init_single_page(pfn_to_page(pfn), pfn, zid, nid);
641+	__init_single_page(pfn_to_page(pfn), pfn, zid, nid, true);
642 }
643 #else
644 static inline void init_reserved_page(unsigned long pfn)
645@@ -1794,7 +1800,7 @@ static unsigned long  __init deferred_init_pages(struct zone *zone,
646 		} else {
647 			page++;
648 		}
649-		__init_single_page(page, pfn, zid, nid);
650+		__init_single_page(page, pfn, zid, nid, true);
651 		nr_pages++;
652 	}
653 	return (nr_pages);
654@@ -6169,6 +6175,11 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
655 	}
656 #endif
657
658+#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT
659+	/* Zero all page struct in advance */
660+	memset(pfn_to_page(start_pfn), 0, sizeof(struct page) * size);
661+#endif
662+
663 	for (pfn = start_pfn; pfn < end_pfn; ) {
664 		/*
665 		 * There can be holes in boot-time mem_map[]s handed to this
666@@ -6182,7 +6193,7 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
667 		}
668
669 		page = pfn_to_page(pfn);
670-		__init_single_page(page, pfn, zone, nid);
671+		__init_single_page(page, pfn, zone, nid, false);
672 		if (context == MEMINIT_HOTPLUG)
673 			__SetPageReserved(page);
674
675@@ -6228,7 +6239,7 @@ void __ref memmap_init_zone_device(struct zone *zone,
676 	for (pfn = start_pfn; pfn < end_pfn; pfn++) {
677 		struct page *page = pfn_to_page(pfn);
678
679-		__init_single_page(page, pfn, zone_idx, nid);
680+		__init_single_page(page, pfn, zone_idx, nid, true);
681
682 		/*
683 		 * Mark page reserved as it will need to wait for onlining
684@@ -6313,7 +6324,7 @@ static void __init init_unavailable_range(unsigned long spfn,
685 				+ pageblock_nr_pages - 1;
686 			continue;
687 		}
688-		__init_single_page(pfn_to_page(pfn), pfn, zone, node);
689+		__init_single_page(pfn_to_page(pfn), pfn, zone, node, true);
690 		__SetPageReserved(pfn_to_page(pfn));
691 		pgcnt++;
692 	}
693diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
694index 53aa3e18c..7ca0ddfa6 100644
695--- a/scripts/Makefile.lib
696+++ b/scripts/Makefile.lib
697@@ -318,8 +318,9 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
698 	$(call if_changed,dt_S_dtb)
699
700 quiet_cmd_dtc = DTC     $@
701-cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
702-	$(DTC) -O $(patsubst .%,%,$(suffix $@)) -o $@ -b 0 \
703+cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
704+      $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
705+      $(DTC) -O dtb -o $@ -b 0 \
706 		$(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \
707 		-d $(depfile).dtc.tmp $(dtc-tmp) ; \
708 	cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
709diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c
710index 17cb6890d..913fb08af 100644
711--- a/scripts/dtc/checks.c
712+++ b/scripts/dtc/checks.c
713@@ -649,6 +649,24 @@ static void fixup_omit_unused_nodes(struct check *c, struct dt_info *dti,
714 		return;
715 	if (node->omit_if_unused && !node->is_referenced)
716 		delete_node(node);
717+
718+	if (node->deleted) {
719+		struct node *parent = node->parent;
720+		struct node *child;
721+		struct label *label;
722+		struct property *prop;
723+
724+		for_each_label(parent->labels, label)
725+			return;
726+
727+		for_each_property(parent, prop)
728+			return;
729+
730+		for_each_child(parent, child)
731+			return;
732+
733+		delete_node(parent);
734+	}
735 }
736 ERROR(omit_unused_nodes, fixup_omit_unused_nodes, NULL, &phandle_references, &path_references);
737
738diff --git a/security/Kconfig.hardening b/security/Kconfig.hardening
739index 269967c4f..9eb73dc1b 100644
740--- a/security/Kconfig.hardening
741+++ b/security/Kconfig.hardening
742@@ -39,7 +39,7 @@ choice
743 	default GCC_PLUGIN_STRUCTLEAK_BYREF_ALL if COMPILE_TEST && GCC_PLUGINS
744 	default INIT_STACK_ALL_PATTERN if COMPILE_TEST && CC_HAS_AUTO_VAR_INIT_PATTERN
745 	default INIT_STACK_ALL_ZERO if CC_HAS_AUTO_VAR_INIT_ZERO
746-	default INIT_STACK_NONE
747+	default INIT_STACK_ALL_ZERO
748 	help
749 	  This option enables initialization of stack variables at
750 	  function entry time. This has the possibility to have the
751@@ -211,6 +211,7 @@ config STACKLEAK_RUNTIME_DISABLE
752
753 config INIT_ON_ALLOC_DEFAULT_ON
754 	bool "Enable heap memory zeroing on allocation by default"
755+	default y
756 	help
757 	  This has the effect of setting "init_on_alloc=1" on the kernel
758 	  command line. This can be disabled with "init_on_alloc=0".
759diff --git a/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c b/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c
760index aaca1f44e..8643beaf2 100644
761--- a/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c
762+++ b/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c
763@@ -57,16 +57,30 @@ static const struct {
764 	struct usb_functionfs_descs_head_v2 header;
765 	__le32 fs_count;
766 	__le32 hs_count;
767+	__le32 ss_count;
768+	__le32 os_count;
769 	struct {
770 		struct usb_interface_descriptor intf;
771 		struct usb_endpoint_descriptor_no_audio bulk_sink;
772 		struct usb_endpoint_descriptor_no_audio bulk_source;
773 	} __attribute__ ((__packed__)) fs_descs, hs_descs;
774+	struct {
775+		struct usb_interface_descriptor intf;
776+		struct usb_endpoint_descriptor_no_audio sink;
777+		struct usb_ss_ep_comp_descriptor sink_comp;
778+		struct usb_endpoint_descriptor_no_audio source;
779+		struct usb_ss_ep_comp_descriptor source_comp;
780+	} __attribute__ ((__packed__)) ss_descs;
781+	struct usb_os_desc_header os_header;
782+	struct usb_ext_compat_desc os_desc;
783+
784 } __attribute__ ((__packed__)) descriptors = {
785 	.header = {
786 		.magic = htole32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2),
787 		.flags = htole32(FUNCTIONFS_HAS_FS_DESC |
788-				     FUNCTIONFS_HAS_HS_DESC),
789+				 FUNCTIONFS_HAS_HS_DESC |
790+				 FUNCTIONFS_HAS_SS_DESC |
791+				 FUNCTIONFS_HAS_MS_OS_DESC),
792 		.length = htole32(sizeof(descriptors)),
793 	},
794 	.fs_count = htole32(3),
795@@ -115,6 +129,58 @@ static const struct {
796 			.wMaxPacketSize = htole16(512),
797 		},
798 	},
799+	.ss_count = htole32(5),
800+	.ss_descs = {
801+		.intf = {
802+			.bLength = sizeof(descriptors.ss_descs.intf),
803+			.bDescriptorType = USB_DT_INTERFACE,
804+			.bInterfaceNumber = 0,
805+			.bNumEndpoints = 2,
806+			.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
807+			.iInterface = 1,
808+		},
809+		.sink = {
810+			.bLength = sizeof(descriptors.ss_descs.sink),
811+			.bDescriptorType = USB_DT_ENDPOINT,
812+			.bEndpointAddress = 1 | USB_DIR_IN,
813+			.bmAttributes = USB_ENDPOINT_XFER_BULK,
814+			.wMaxPacketSize = htole16(1024),
815+		},
816+		.sink_comp = {
817+			.bLength = sizeof(descriptors.ss_descs.sink_comp),
818+			.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
819+			.bMaxBurst = 4,
820+		},
821+		.source = {
822+			.bLength = sizeof(descriptors.ss_descs.source),
823+			.bDescriptorType = USB_DT_ENDPOINT,
824+			.bEndpointAddress = 2 | USB_DIR_OUT,
825+			.bmAttributes = USB_ENDPOINT_XFER_BULK,
826+			.wMaxPacketSize = htole16(1024),
827+		},
828+		.source_comp = {
829+			.bLength = sizeof(descriptors.ss_descs.source_comp),
830+			.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
831+			.bMaxBurst = 4,
832+		},
833+	},
834+	.os_count = htole32(1),
835+	.os_header = {
836+		.interface = htole32(1),
837+		.dwLength = htole32(sizeof(descriptors.os_header) +
838+			    sizeof(descriptors.os_desc)),
839+		.bcdVersion = htole32(1),
840+		.wIndex = htole32(4),
841+		.bCount = htole32(1),
842+		.Reserved = htole32(0),
843+	},
844+	.os_desc = {
845+		.bFirstInterfaceNumber = 0,
846+		.Reserved1 = htole32(1),
847+		.CompatibleID = {0},
848+		.SubCompatibleID = {0},
849+		.Reserved2 = {0},
850+	},
851 };
852
853 #define STR_INTERFACE "AIO Test"
854diff --git a/tools/usb/ffs-aio-example/simple/device_app/aio_simple.c b/tools/usb/ffs-aio-example/simple/device_app/aio_simple.c
855index 1f44a2981..51574379f 100644
856--- a/tools/usb/ffs-aio-example/simple/device_app/aio_simple.c
857+++ b/tools/usb/ffs-aio-example/simple/device_app/aio_simple.c
858@@ -55,16 +55,30 @@ static const struct {
859 	struct usb_functionfs_descs_head_v2 header;
860 	__le32 fs_count;
861 	__le32 hs_count;
862+	__le32 ss_count;
863+	__le32 os_count;
864 	struct {
865 		struct usb_interface_descriptor intf;
866 		struct usb_endpoint_descriptor_no_audio bulk_sink;
867 		struct usb_endpoint_descriptor_no_audio bulk_source;
868 	} __attribute__ ((__packed__)) fs_descs, hs_descs;
869+	struct {
870+		struct usb_interface_descriptor intf;
871+		struct usb_endpoint_descriptor_no_audio sink;
872+		struct usb_ss_ep_comp_descriptor sink_comp;
873+		struct usb_endpoint_descriptor_no_audio source;
874+		struct usb_ss_ep_comp_descriptor source_comp;
875+	} __attribute__ ((__packed__)) ss_descs;
876+	struct usb_os_desc_header os_header;
877+	struct usb_ext_compat_desc os_desc;
878+
879 } __attribute__ ((__packed__)) descriptors = {
880 	.header = {
881 		.magic = htole32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2),
882 		.flags = htole32(FUNCTIONFS_HAS_FS_DESC |
883-				     FUNCTIONFS_HAS_HS_DESC),
884+				 FUNCTIONFS_HAS_HS_DESC |
885+				 FUNCTIONFS_HAS_SS_DESC |
886+				 FUNCTIONFS_HAS_MS_OS_DESC),
887 		.length = htole32(sizeof(descriptors)),
888 	},
889 	.fs_count = htole32(3),
890@@ -113,6 +127,58 @@ static const struct {
891 			.wMaxPacketSize = htole16(512),
892 		},
893 	},
894+	.ss_count = htole32(5),
895+	.ss_descs = {
896+		.intf = {
897+			.bLength = sizeof(descriptors.ss_descs.intf),
898+			.bDescriptorType = USB_DT_INTERFACE,
899+			.bInterfaceNumber = 0,
900+			.bNumEndpoints = 2,
901+			.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
902+			.iInterface = 1,
903+		},
904+		.sink = {
905+			.bLength = sizeof(descriptors.ss_descs.sink),
906+			.bDescriptorType = USB_DT_ENDPOINT,
907+			.bEndpointAddress = 1 | USB_DIR_IN,
908+			.bmAttributes = USB_ENDPOINT_XFER_BULK,
909+			.wMaxPacketSize = htole16(1024),
910+		},
911+		.sink_comp = {
912+			.bLength = sizeof(descriptors.ss_descs.sink_comp),
913+			.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
914+			.bMaxBurst = 4,
915+		},
916+		.source = {
917+			.bLength = sizeof(descriptors.ss_descs.source),
918+			.bDescriptorType = USB_DT_ENDPOINT,
919+			.bEndpointAddress = 2 | USB_DIR_OUT,
920+			.bmAttributes = USB_ENDPOINT_XFER_BULK,
921+			.wMaxPacketSize = htole16(1024),
922+		},
923+		.source_comp = {
924+			.bLength = sizeof(descriptors.ss_descs.source_comp),
925+			.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
926+			.bMaxBurst = 4,
927+		},
928+	},
929+	.os_count = htole32(1),
930+	.os_header = {
931+		.interface = htole32(1),
932+		.dwLength = htole32(sizeof(descriptors.os_header) +
933+			    sizeof(descriptors.os_desc)),
934+		.bcdVersion = htole32(1),
935+		.wIndex = htole32(4),
936+		.bCount = htole32(1),
937+		.Reserved = htole32(0),
938+	},
939+	.os_desc = {
940+		.bFirstInterfaceNumber = 0,
941+		.Reserved1 = htole32(1),
942+		.CompatibleID = {0},
943+		.SubCompatibleID = {0},
944+		.Reserved2 = {0},
945+	},
946 };
947
948 #define STR_INTERFACE "AIO Test"
949