[Feature][T106_eSDK]update from T106-V2.01.01.02P56U09.AP.17.09_CAP.17.09.01 to T106-M42-PLXXXX-P56U11.AP.19.00_CAP.19.00.01 -- code

Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: I5eb7f586f78a987785b0f9885f1300c42bfd6819
diff --git a/upstream/linux-5.10/kernel/ramdump/ramdump_emmc.c b/upstream/linux-5.10/kernel/ramdump/ramdump_emmc.c
index 0c28f27..5054440 100755
--- a/upstream/linux-5.10/kernel/ramdump/ramdump_emmc.c
+++ b/upstream/linux-5.10/kernel/ramdump/ramdump_emmc.c
@@ -128,16 +128,28 @@
 int ramdump_emmc_write_data(ramdump_shmem_t *msg, ramdump_file_t *fp, unsigned int size)
 {
 	int ret = 0;
-	unsigned int buffer = RAMDUMP_EMMC_ADDR + ramdump_emmc_offset;
+	u64 buffer = RAMDUMP_EMMC_ADDR + ramdump_emmc_offset;
 
 	if (ramdump_device_file_cnt >= RAMDUMP_FILE_NUM_MAX)
 		return -1;
 
 	while(1){
 		if ((msg->core_flag == 1) && (msg->rw_flag == 2)){
-			if(msg->size >= (ramdump_emmc_size - fp->file_fp[ramdump_device_file_cnt].offset))
-				return -1;
+			/* Started by AICoder, pid:fe298k6b27edc1c14f9e0be2e0451e1abfc5830e */
+			if((ramdump_emmc_size < ramdump_emmc_offset)
+				|| (msg->size >= (ramdump_emmc_size - fp->file_fp[ramdump_device_file_cnt].offset)))
+			{
+				printk("[ramdump] No space left in emmc, Emmc_size is %ld,ramdump_emmc_offset is %d!\n", ramdump_emmc_size, ramdump_emmc_offset);
+				return -RAMDUMP_NO_FREE_SPACE;
+			}
 			ret = mmc_bwrite(buffer, msg->size, msg->buf);
+			if(ret < 0)
+			{
+				printk("[ramdump] ramdump_emmc_write_data Error.\n");
+				ramdump_wait_delay(0);
+				continue;
+			}
+			/* Ended by AICoder, pid:fe298k6b27edc1c14f9e0be2e0451e1abfc5830e */
 			ramdump_emmc_offset = ramdump_emmc_offset + roundup(msg->size, RAMDUMP_EMMC_ALIGN_SIZE);
 			msg->core_flag = 1;
 			msg->rw_flag = 1;