• 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);
264@@ -2001,8 +2001,7 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops,
265 	if (nsops > ns->sc_semopm)
266 		return -E2BIG;
267 	if (nsops > SEMOPM_FAST) {
268-		sops = kvmalloc_array(nsops, sizeof(*sops),
269-				      GFP_KERNEL_ACCOUNT);
270+		sops = kvmalloc_array(nsops, sizeof(*sops), GFP_KERNEL);
271 		if (sops == NULL)
272 			return -ENOMEM;
273 	}
274diff --git a/ipc/shm.c b/ipc/shm.c
275index b418731d6..471ac3e74 100644
276--- a/ipc/shm.c
277+++ b/ipc/shm.c
278@@ -711,7 +711,7 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
279 			ns->shm_tot + numpages > ns->shm_ctlall)
280 		return -ENOSPC;
281
282-	shp = kvmalloc(sizeof(*shp), GFP_KERNEL_ACCOUNT);
283+	shp = kvmalloc(sizeof(*shp), GFP_KERNEL);
284 	if (unlikely(!shp))
285 		return -ENOMEM;
286
287diff --git a/ipc/util.c b/ipc/util.c
288index 7c3601dad..bbb5190af 100644
289--- a/ipc/util.c
290+++ b/ipc/util.c
291@@ -754,13 +754,21 @@ struct pid_namespace *ipc_seq_pid_ns(struct seq_file *s)
292 static struct kern_ipc_perm *sysvipc_find_ipc(struct ipc_ids *ids, loff_t pos,
293 					      loff_t *new_pos)
294 {
295-	struct kern_ipc_perm *ipc = NULL;
296-	int max_idx = ipc_get_maxidx(ids);
297+	struct kern_ipc_perm *ipc;
298+	int total, id;
299+
300+	total = 0;
301+	for (id = 0; id < pos && total < ids->in_use; id++) {
302+		ipc = idr_find(&ids->ipcs_idr, id);
303+		if (ipc != NULL)
304+			total++;
305+	}
306
307-	if (max_idx == -1 || pos > max_idx)
308+	ipc = NULL;
309+	if (total >= ids->in_use)
310 		goto out;
311
312-	for (; pos <= max_idx; pos++) {
313+	for (; pos < ipc_mni; pos++) {
314 		ipc = idr_find(&ids->ipcs_idr, pos);
315 		if (ipc != NULL) {
316 			rcu_read_lock();
317diff --git a/make-boot.sh b/make-boot.sh
318new file mode 100755
319index 000000000..d512e8a88
320--- /dev/null
321+++ b/make-boot.sh
322@@ -0,0 +1,33 @@
323+#!/bin/bash
324+
325+set -e
326+
327+root_path=$(cd $(dirname $0); pwd)
328+root_out_dir=${root_path%kernel*}
329+BOOT_LINUX=${root_out_dir}/kernel/src_tmp/linux-5.10
330+OUT_IMAGE=${root_out_dir}/yangfan/packages/phone/images/
331+IMAGE_SIZE=64  # 64M
332+IMAGE_BLOCKS=4096
333+
334+BUILD_PATH=boot_linux
335+EXTLINUX_PATH=${BUILD_PATH}/extlinux
336+EXTLINUX_CONF=${EXTLINUX_PATH}/extlinux.conf
337+
338+function make_boot_image()
339+{
340+        blocks=${IMAGE_BLOCKS}
341+        block_size=$((${IMAGE_SIZE} * 1024 * 1024 / ${blocks}))
342+        echo "blocks = ${blocks}  block_size ${block_size}"
343+        if [ "`uname -m`" == "aarch64" ]; then
344+                echo y | sudo mke2fs -b ${block_size} -d boot_linux -i 8192 -t ext2 boot_linux.img ${blocks}
345+        else
346+                genext2fs -B ${blocks} -b ${block_size} -d boot_linux -i 8192 -U boot_linux.img
347+        fi
348+
349+        return $?
350+}
351+
352+cd ${BOOT_LINUX}
353+make_boot_image
354+cd -
355+cp ${BOOT_LINUX}/boot_linux.img ${OUT_IMAGE}
356diff --git a/make-ohos.sh b/make-ohos.sh
357new file mode 100755
358index 000000000..8f4a4e4d7
359--- /dev/null
360+++ b/make-ohos.sh
361@@ -0,0 +1,138 @@
362+#!/bin/bash
363+
364+set -e
365+
366+real_path=$(cd $(dirname $0); pwd)
367+
368+export PRODUCT_PATH=vendor/isoftstone/yangfan
369+export KERNEL_SOURCE_PATH=${real_path%out*}${PRODUCT_PATH}/kernel_core
370+export PATH=${real_path%out*}prebuilts/clang/ohos/linux-x86_64/llvm/bin/:$PATH
371+IMAGE_SIZE=64  # 64M
372+IMAGE_BLOCKS=4096
373+
374+CPUs=`sed -n "N;/processor/p" /proc/cpuinfo|wc -l`
375+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-"
376+BUILD_PATH=boot_linux
377+EXTLINUX_PATH=${BUILD_PATH}/extlinux
378+EXTLINUX_CONF=${EXTLINUX_PATH}/extlinux.conf
379+SAPPHIRE_DTB=sapphire.dtb
380+
381+MCU_LIB_FILE=${real_path%out*}device/board/isoftstone/yangfan/kernel/src/mcu/*.o
382+MCU_OBJ_PATCH=drivers/char
383+if [ ${KBUILD_OUTPUT} ]; then
384+	OBJ_PATH=${KBUILD_OUTPUT}/
385+fi
386+
387+ID_MODEL=1
388+ID_ARCH=2
389+ID_UART=3
390+ID_DTB=4
391+ID_IMAGE=5
392+ID_CONF=6
393+model_list=(
394+	"TB-RK3568X0   arm64 0xfe660000 rk3568-toybrick-x0-linux  Image rockchip_linux_defconfig"
395+	"sapphire-rk3399 arm64 0xff1a0000 rk3399-sapphire-excavator-linux  Image rockchip_linux_defconfig"
396+	"sapphire-rk3399T arm64 0xff1a0000 rk3399-sapphire-excavator-linux-3399t  Image rockchip_linux_defconfig"
397+)
398+
399+
400+function help()
401+{
402+	echo "Usage: ./make-ohos.sh {BOARD_NAME} KBUILD_OUTPUT=../../OBJ/linux-5.10"
403+	echo "e.g."
404+	for i in "${model_list[@]}"; do
405+		echo "  ./make-ohos.sh $(echo $i | awk '{print $1}') KBUILD_OUTPUT=../../OBJ/linux-5.10"
406+	done
407+}
408+
409+
410+function make_extlinux_conf()
411+{
412+	dtb_path=$1
413+	uart=$2
414+	image=$3
415+
416+	echo "label rockchip-kernel-5.10" > ${EXTLINUX_CONF}
417+	echo "	kernel /extlinux/${image}" >> ${EXTLINUX_CONF}
418+	echo "	fdt /extlinux/${SAPPHIRE_DTB}" >> ${EXTLINUX_CONF}
419+	cmdline="append earlycon=uart8250,mmio32,${uart} root=PARTUUID=614e0000-0000-4b53-8000-1d28000054a9 rw rootwait rootfstype=ext4"
420+	echo "  ${cmdline}" >> ${EXTLINUX_CONF}
421+}
422+
423+function make_kernel_image()
424+{
425+	arch=$1
426+	conf=$2
427+	dtb=$3
428+
429+	${MAKE} ARCH=${arch} ${conf}
430+	if [ $? -ne 0 ]; then
431+		echo "FAIL: ${MAKE} ARCH=${arch} ${conf}"
432+		return -1
433+	fi
434+
435+	${MAKE} ARCH=${arch} ${dtb}.img -j${CPUs}
436+	if [ $? -ne 0 ]; then
437+		echo "FAIL: ${MAKE} ARCH=${arch} ${dtb}.img"
438+		return -2
439+	fi
440+
441+	return 0
442+}
443+
444+function make_ext2_image()
445+{
446+	blocks=${IMAGE_BLOCKS}
447+	block_size=$((${IMAGE_SIZE} * 1024 * 1024 / ${blocks}))
448+
449+	if [ "`uname -m`" == "aarch64" ]; then
450+		echo y | sudo mke2fs -b ${block_size} -d boot_linux -i 8192 -t ext2 boot_linux.img ${blocks}
451+	else
452+		genext2fs -B ${blocks} -b ${block_size} -d boot_linux -i 8192 -U boot_linux.img
453+	fi
454+
455+	return $?
456+}
457+
458+function make_boot_linux()
459+{
460+	arch=${!ID_ARCH}
461+	uart=${!ID_UART}
462+	dtb=${!ID_DTB}
463+	image=${!ID_IMAGE}
464+	conf=${!ID_CONF}
465+	if [ ${arch} == "arm" ]; then
466+		dtb_path=arch/arm/boot/dts
467+	else
468+		dtb_path=arch/arm64/boot/dts/rockchip
469+	fi
470+
471+	rm -rf ${BUILD_PATH}
472+	mkdir -p ${EXTLINUX_PATH}
473+
474+	make_kernel_image ${arch} ${conf} ${dtb}
475+	if [ $? -ne 0 ]; then
476+		exit 1
477+	fi
478+	make_extlinux_conf ${dtb_path} ${uart} ${image}
479+	cp -f ${OBJ_PATH}arch/${arch}/boot/${image} ${EXTLINUX_PATH}/
480+	cp -f ${OBJ_PATH}${dtb_path}/${dtb}.dtb ${EXTLINUX_PATH}/${SAPPHIRE_DTB}
481+	cp -f logo*.bmp ${BUILD_PATH}/
482+	if [ "enable_ramdisk" != "${ramdisk_flag}" ]; then
483+		make_ext2_image
484+	fi
485+}
486+
487+ramdisk_flag=$2
488+found=0
489+cp -arf ${MCU_LIB_FILE} ${MCU_OBJ_PATCH}/
490+for i in "${model_list[@]}"; do
491+	if [ "$(echo $i | awk '{print $1}')" == "$1" ]; then
492+		make_boot_linux $i
493+		found=1
494+	fi
495+done
496+
497+if [ ${found} -eq 0 ]; then
498+	help
499+fi
500diff --git a/mm/hugetlb.c b/mm/hugetlb.c
501index 4ecf9a062..20277864c 100644
502--- a/mm/hugetlb.c
503+++ b/mm/hugetlb.c
504@@ -3932,7 +3932,6 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
505 	struct hstate *h = hstate_vma(vma);
506 	unsigned long sz = huge_page_size(h);
507 	struct mmu_notifier_range range;
508-	bool force_flush = false;
509
510 	WARN_ON(!is_vm_hugetlb_page(vma));
511 	BUG_ON(start & ~huge_page_mask(h));
512@@ -3961,8 +3960,10 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
513 		ptl = huge_pte_lock(h, mm, ptep);
514 		if (huge_pmd_unshare(mm, vma, &address, ptep)) {
515 			spin_unlock(ptl);
516-			tlb_flush_pmd_range(tlb, address & PUD_MASK, PUD_SIZE);
517-			force_flush = true;
518+			/*
519+			 * We just unmapped a page of PMDs by clearing a PUD.
520+			 * The caller's TLB flush range should cover this area.
521+			 */
522 			continue;
523 		}
524
525@@ -4019,22 +4020,6 @@ void __unmap_hugepage_range(struct mmu_gather *tlb, struct vm_area_struct *vma,
526 	}
527 	mmu_notifier_invalidate_range_end(&range);
528 	tlb_end_vma(tlb, vma);
529-
530-	/*
531-	 * If we unshared PMDs, the TLB flush was not recorded in mmu_gather. We
532-	 * could defer the flush until now, since by holding i_mmap_rwsem we
533-	 * guaranteed that the last refernece would not be dropped. But we must
534-	 * do the flushing before we return, as otherwise i_mmap_rwsem will be
535-	 * dropped and the last reference to the shared PMDs page might be
536-	 * dropped as well.
537-	 *
538-	 * In theory we could defer the freeing of the PMD pages as well, but
539-	 * huge_pmd_unshare() relies on the exact page_count for the PMD page to
540-	 * detect sharing, so we cannot defer the release of the page either.
541-	 * Instead, do flush now.
542-	 */
543-	if (force_flush)
544-		tlb_flush_mmu_tlbonly(tlb);
545 }
546
547 void __unmap_hugepage_range_final(struct mmu_gather *tlb,
548diff --git a/mm/memblock.c b/mm/memblock.c
549index faa4de579..3f3254627 100644
550--- a/mm/memblock.c
551+++ b/mm/memblock.c
552@@ -97,6 +97,26 @@ struct pglist_data __refdata contig_page_data;
553 EXPORT_SYMBOL(contig_page_data);
554 #endif
555
556+#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT
557+static unsigned long defer_start __initdata;
558+static unsigned long defer_end __initdata;
559+
560+#define DEFAULT_DEFER_FREE_BLOCK_SIZE SZ_256M
561+static unsigned long defer_free_block_size __initdata =
562+	DEFAULT_DEFER_FREE_BLOCK_SIZE;
563+
564+static int __init early_defer_free_block_size(char *p)
565+{
566+	defer_free_block_size = memparse(p, &p);
567+
568+	pr_debug("defer_free_block_size = 0x%lx\n", defer_free_block_size);
569+
570+	return 0;
571+}
572+
573+early_param("defer_free_block_size", early_defer_free_block_size);
574+#endif
575+
576 unsigned long max_low_pfn;
577 unsigned long min_low_pfn;
578 unsigned long max_pfn;
579@@ -1907,6 +1927,28 @@ static void __init __free_pages_memory(unsigned long start, unsigned long end)
580 	}
581 }
582
583+#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT
584+int __init defer_free_memblock(void *unused)
585+{
586+	if (defer_start == 0)
587+		return 0;
588+
589+	pr_debug("start = %ld, end = %ld\n", defer_start, defer_end);
590+
591+	__free_pages_memory(defer_start, defer_end);
592+
593+	totalram_pages_add(defer_end - defer_start);
594+
595+	pr_info("%s: size %luM free %luM [%luM - %luM] total %luM\n", __func__,
596+		defer_free_block_size >> 20,
597+		(defer_end - defer_start) >> (20 - PAGE_SHIFT),
598+		defer_end >> (20 - PAGE_SHIFT),
599+		defer_start >> (20 - PAGE_SHIFT),
600+		totalram_pages() >> (20 - PAGE_SHIFT));
601+	return 0;
602+}
603+#endif
604+
605 static unsigned long __init __free_memory_core(phys_addr_t start,
606 				 phys_addr_t end)
607 {
608@@ -1917,6 +1959,15 @@ static unsigned long __init __free_memory_core(phys_addr_t start,
609 	if (start_pfn >= end_pfn)
610 		return 0;
611
612+#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT
613+	if ((end - start) > defer_free_block_size) {
614+		defer_start = start_pfn;
615+		defer_end = end_pfn;
616+
617+		return 0;
618+	}
619+#endif
620+
621 	__free_pages_memory(start_pfn, end_pfn);
622
623 	return end_pfn - start_pfn;
624diff --git a/mm/page_alloc.c b/mm/page_alloc.c
625index 85e48479c..dbfb65fb7 100644
626--- a/mm/page_alloc.c
627+++ b/mm/page_alloc.c
628@@ -1445,9 +1445,15 @@ static void free_one_page(struct zone *zone,
629 }
630
631 static void __meminit __init_single_page(struct page *page, unsigned long pfn,
632-				unsigned long zone, int nid)
633+				unsigned long zone, int nid,
634+				bool zero_page_struct __maybe_unused)
635 {
636+#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT
637+	if (zero_page_struct)
638+		mm_zero_struct_page(page);
639+#else
640 	mm_zero_struct_page(page);
641+#endif
642 	set_page_links(page, zone, nid, pfn);
643 	init_page_count(page);
644 	page_mapcount_reset(page);
645@@ -1480,7 +1486,7 @@ static void __meminit init_reserved_page(unsigned long pfn)
646 		if (pfn >= zone->zone_start_pfn && pfn < zone_end_pfn(zone))
647 			break;
648 	}
649-	__init_single_page(pfn_to_page(pfn), pfn, zid, nid);
650+	__init_single_page(pfn_to_page(pfn), pfn, zid, nid, true);
651 }
652 #else
653 static inline void init_reserved_page(unsigned long pfn)
654@@ -1794,7 +1800,7 @@ static unsigned long  __init deferred_init_pages(struct zone *zone,
655 		} else {
656 			page++;
657 		}
658-		__init_single_page(page, pfn, zid, nid);
659+		__init_single_page(page, pfn, zid, nid, true);
660 		nr_pages++;
661 	}
662 	return (nr_pages);
663@@ -6169,6 +6175,11 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
664 	}
665 #endif
666
667+#ifdef CONFIG_ROCKCHIP_THUNDER_BOOT
668+	/* Zero all page struct in advance */
669+	memset(pfn_to_page(start_pfn), 0, sizeof(struct page) * size);
670+#endif
671+
672 	for (pfn = start_pfn; pfn < end_pfn; ) {
673 		/*
674 		 * There can be holes in boot-time mem_map[]s handed to this
675@@ -6182,7 +6193,7 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
676 		}
677
678 		page = pfn_to_page(pfn);
679-		__init_single_page(page, pfn, zone, nid);
680+		__init_single_page(page, pfn, zone, nid, false);
681 		if (context == MEMINIT_HOTPLUG)
682 			__SetPageReserved(page);
683
684@@ -6228,7 +6239,7 @@ void __ref memmap_init_zone_device(struct zone *zone,
685 	for (pfn = start_pfn; pfn < end_pfn; pfn++) {
686 		struct page *page = pfn_to_page(pfn);
687
688-		__init_single_page(page, pfn, zone_idx, nid);
689+		__init_single_page(page, pfn, zone_idx, nid, true);
690
691 		/*
692 		 * Mark page reserved as it will need to wait for onlining
693@@ -6313,7 +6324,7 @@ static void __init init_unavailable_range(unsigned long spfn,
694 				+ pageblock_nr_pages - 1;
695 			continue;
696 		}
697-		__init_single_page(pfn_to_page(pfn), pfn, zone, node);
698+		__init_single_page(pfn_to_page(pfn), pfn, zone, node, true);
699 		__SetPageReserved(pfn_to_page(pfn));
700 		pgcnt++;
701 	}
702diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
703index 53aa3e18c..7ca0ddfa6 100644
704--- a/scripts/Makefile.lib
705+++ b/scripts/Makefile.lib
706@@ -318,8 +318,9 @@ $(obj)/%.dtb.S: $(obj)/%.dtb FORCE
707 	$(call if_changed,dt_S_dtb)
708
709 quiet_cmd_dtc = DTC     $@
710-cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
711-	$(DTC) -O $(patsubst .%,%,$(suffix $@)) -o $@ -b 0 \
712+cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
713+      $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
714+      $(DTC) -O dtb -o $@ -b 0 \
715 		$(addprefix -i,$(dir $<) $(DTC_INCLUDE)) $(DTC_FLAGS) \
716 		-d $(depfile).dtc.tmp $(dtc-tmp) ; \
717 	cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
718diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c
719index 17cb6890d..913fb08af 100644
720--- a/scripts/dtc/checks.c
721+++ b/scripts/dtc/checks.c
722@@ -649,6 +649,24 @@ static void fixup_omit_unused_nodes(struct check *c, struct dt_info *dti,
723 		return;
724 	if (node->omit_if_unused && !node->is_referenced)
725 		delete_node(node);
726+
727+	if (node->deleted) {
728+		struct node *parent = node->parent;
729+		struct node *child;
730+		struct label *label;
731+		struct property *prop;
732+
733+		for_each_label(parent->labels, label)
734+			return;
735+
736+		for_each_property(parent, prop)
737+			return;
738+
739+		for_each_child(parent, child)
740+			return;
741+
742+		delete_node(parent);
743+	}
744 }
745 ERROR(omit_unused_nodes, fixup_omit_unused_nodes, NULL, &phandle_references, &path_references);
746
747diff --git a/security/Kconfig.hardening b/security/Kconfig.hardening
748index 269967c4f..9eb73dc1b 100644
749--- a/security/Kconfig.hardening
750+++ b/security/Kconfig.hardening
751@@ -29,7 +29,7 @@ choice
752 	prompt "Initialize kernel stack variables at function entry"
753 	default GCC_PLUGIN_STRUCTLEAK_BYREF_ALL if COMPILE_TEST && GCC_PLUGINS
754 	default INIT_STACK_ALL_PATTERN if COMPILE_TEST && CC_HAS_AUTO_VAR_INIT_PATTERN
755-	default INIT_STACK_NONE
756+	default INIT_STACK_ALL_ZERO
757 	help
758 	  This option enables initialization of stack variables at
759 	  function entry time. This has the possibility to have the
760@@ -190,6 +190,7 @@ config STACKLEAK_RUNTIME_DISABLE
761
762 config INIT_ON_ALLOC_DEFAULT_ON
763 	bool "Enable heap memory zeroing on allocation by default"
764+	default y
765 	help
766 	  This has the effect of setting "init_on_alloc=1" on the kernel
767 	  command line. This can be disabled with "init_on_alloc=0".
768diff --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
769index aaca1f44e..8643beaf2 100644
770--- a/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c
771+++ b/tools/usb/ffs-aio-example/multibuff/device_app/aio_multibuff.c
772@@ -57,16 +57,30 @@ static const struct {
773 	struct usb_functionfs_descs_head_v2 header;
774 	__le32 fs_count;
775 	__le32 hs_count;
776+	__le32 ss_count;
777+	__le32 os_count;
778 	struct {
779 		struct usb_interface_descriptor intf;
780 		struct usb_endpoint_descriptor_no_audio bulk_sink;
781 		struct usb_endpoint_descriptor_no_audio bulk_source;
782 	} __attribute__ ((__packed__)) fs_descs, hs_descs;
783+	struct {
784+		struct usb_interface_descriptor intf;
785+		struct usb_endpoint_descriptor_no_audio sink;
786+		struct usb_ss_ep_comp_descriptor sink_comp;
787+		struct usb_endpoint_descriptor_no_audio source;
788+		struct usb_ss_ep_comp_descriptor source_comp;
789+	} __attribute__ ((__packed__)) ss_descs;
790+	struct usb_os_desc_header os_header;
791+	struct usb_ext_compat_desc os_desc;
792+
793 } __attribute__ ((__packed__)) descriptors = {
794 	.header = {
795 		.magic = htole32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2),
796 		.flags = htole32(FUNCTIONFS_HAS_FS_DESC |
797-				     FUNCTIONFS_HAS_HS_DESC),
798+				 FUNCTIONFS_HAS_HS_DESC |
799+				 FUNCTIONFS_HAS_SS_DESC |
800+				 FUNCTIONFS_HAS_MS_OS_DESC),
801 		.length = htole32(sizeof(descriptors)),
802 	},
803 	.fs_count = htole32(3),
804@@ -115,6 +129,58 @@ static const struct {
805 			.wMaxPacketSize = htole16(512),
806 		},
807 	},
808+	.ss_count = htole32(5),
809+	.ss_descs = {
810+		.intf = {
811+			.bLength = sizeof(descriptors.ss_descs.intf),
812+			.bDescriptorType = USB_DT_INTERFACE,
813+			.bInterfaceNumber = 0,
814+			.bNumEndpoints = 2,
815+			.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
816+			.iInterface = 1,
817+		},
818+		.sink = {
819+			.bLength = sizeof(descriptors.ss_descs.sink),
820+			.bDescriptorType = USB_DT_ENDPOINT,
821+			.bEndpointAddress = 1 | USB_DIR_IN,
822+			.bmAttributes = USB_ENDPOINT_XFER_BULK,
823+			.wMaxPacketSize = htole16(1024),
824+		},
825+		.sink_comp = {
826+			.bLength = sizeof(descriptors.ss_descs.sink_comp),
827+			.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
828+			.bMaxBurst = 4,
829+		},
830+		.source = {
831+			.bLength = sizeof(descriptors.ss_descs.source),
832+			.bDescriptorType = USB_DT_ENDPOINT,
833+			.bEndpointAddress = 2 | USB_DIR_OUT,
834+			.bmAttributes = USB_ENDPOINT_XFER_BULK,
835+			.wMaxPacketSize = htole16(1024),
836+		},
837+		.source_comp = {
838+			.bLength = sizeof(descriptors.ss_descs.source_comp),
839+			.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
840+			.bMaxBurst = 4,
841+		},
842+	},
843+	.os_count = htole32(1),
844+	.os_header = {
845+		.interface = htole32(1),
846+		.dwLength = htole32(sizeof(descriptors.os_header) +
847+			    sizeof(descriptors.os_desc)),
848+		.bcdVersion = htole32(1),
849+		.wIndex = htole32(4),
850+		.bCount = htole32(1),
851+		.Reserved = htole32(0),
852+	},
853+	.os_desc = {
854+		.bFirstInterfaceNumber = 0,
855+		.Reserved1 = htole32(1),
856+		.CompatibleID = {0},
857+		.SubCompatibleID = {0},
858+		.Reserved2 = {0},
859+	},
860 };
861
862 #define STR_INTERFACE "AIO Test"
863diff --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
864index 1f44a2981..51574379f 100644
865--- a/tools/usb/ffs-aio-example/simple/device_app/aio_simple.c
866+++ b/tools/usb/ffs-aio-example/simple/device_app/aio_simple.c
867@@ -55,16 +55,30 @@ static const struct {
868 	struct usb_functionfs_descs_head_v2 header;
869 	__le32 fs_count;
870 	__le32 hs_count;
871+	__le32 ss_count;
872+	__le32 os_count;
873 	struct {
874 		struct usb_interface_descriptor intf;
875 		struct usb_endpoint_descriptor_no_audio bulk_sink;
876 		struct usb_endpoint_descriptor_no_audio bulk_source;
877 	} __attribute__ ((__packed__)) fs_descs, hs_descs;
878+	struct {
879+		struct usb_interface_descriptor intf;
880+		struct usb_endpoint_descriptor_no_audio sink;
881+		struct usb_ss_ep_comp_descriptor sink_comp;
882+		struct usb_endpoint_descriptor_no_audio source;
883+		struct usb_ss_ep_comp_descriptor source_comp;
884+	} __attribute__ ((__packed__)) ss_descs;
885+	struct usb_os_desc_header os_header;
886+	struct usb_ext_compat_desc os_desc;
887+
888 } __attribute__ ((__packed__)) descriptors = {
889 	.header = {
890 		.magic = htole32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2),
891 		.flags = htole32(FUNCTIONFS_HAS_FS_DESC |
892-				     FUNCTIONFS_HAS_HS_DESC),
893+				 FUNCTIONFS_HAS_HS_DESC |
894+				 FUNCTIONFS_HAS_SS_DESC |
895+				 FUNCTIONFS_HAS_MS_OS_DESC),
896 		.length = htole32(sizeof(descriptors)),
897 	},
898 	.fs_count = htole32(3),
899@@ -113,6 +127,58 @@ static const struct {
900 			.wMaxPacketSize = htole16(512),
901 		},
902 	},
903+	.ss_count = htole32(5),
904+	.ss_descs = {
905+		.intf = {
906+			.bLength = sizeof(descriptors.ss_descs.intf),
907+			.bDescriptorType = USB_DT_INTERFACE,
908+			.bInterfaceNumber = 0,
909+			.bNumEndpoints = 2,
910+			.bInterfaceClass = USB_CLASS_VENDOR_SPEC,
911+			.iInterface = 1,
912+		},
913+		.sink = {
914+			.bLength = sizeof(descriptors.ss_descs.sink),
915+			.bDescriptorType = USB_DT_ENDPOINT,
916+			.bEndpointAddress = 1 | USB_DIR_IN,
917+			.bmAttributes = USB_ENDPOINT_XFER_BULK,
918+			.wMaxPacketSize = htole16(1024),
919+		},
920+		.sink_comp = {
921+			.bLength = sizeof(descriptors.ss_descs.sink_comp),
922+			.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
923+			.bMaxBurst = 4,
924+		},
925+		.source = {
926+			.bLength = sizeof(descriptors.ss_descs.source),
927+			.bDescriptorType = USB_DT_ENDPOINT,
928+			.bEndpointAddress = 2 | USB_DIR_OUT,
929+			.bmAttributes = USB_ENDPOINT_XFER_BULK,
930+			.wMaxPacketSize = htole16(1024),
931+		},
932+		.source_comp = {
933+			.bLength = sizeof(descriptors.ss_descs.source_comp),
934+			.bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
935+			.bMaxBurst = 4,
936+		},
937+	},
938+	.os_count = htole32(1),
939+	.os_header = {
940+		.interface = htole32(1),
941+		.dwLength = htole32(sizeof(descriptors.os_header) +
942+			    sizeof(descriptors.os_desc)),
943+		.bcdVersion = htole32(1),
944+		.wIndex = htole32(4),
945+		.bCount = htole32(1),
946+		.Reserved = htole32(0),
947+	},
948+	.os_desc = {
949+		.bFirstInterfaceNumber = 0,
950+		.Reserved1 = htole32(1),
951+		.CompatibleID = {0},
952+		.SubCompatibleID = {0},
953+		.Reserved2 = {0},
954+	},
955 };
956
957 #define STR_INTERFACE "AIO Test"
958