blob: d84f025ae6762d0f2594b87cc292e6a22e1e391d [file] [log] [blame]
xf.li1867bfa2024-08-20 02:32:16 -07001diff --git a/esdk/layers/meta-zxic/recipes-core/busybox/busybox/busybox-1.33.1/0103-syslogd-data-encryption.patch b/esdk/layers/meta-zxic/recipes-core/busybox/busybox/busybox-1.33.1/0103-syslogd-data-encryption.patch
2new file mode 100755
3index 0000000..32a47fa
4--- /dev/null
5+++ b/esdk/layers/meta-zxic/recipes-core/busybox/busybox/busybox-1.33.1/0103-syslogd-data-encryption.patch
6@@ -0,0 +1,32 @@
7+From 8e37145dcc28a46f9c1ebc85c8c2df269635677c Mon Sep 17 00:00:00 2001
8+From: =?UTF-8?q?=E5=AE=8B=E4=BA=91=E9=9C=9E0318000489?=
9+ <song.yunxia@sanechips.com.cn>
10+Date: Thu, 18 Apr 2024 21:40:23 +0800
11+Subject: [PATCH] syslogd data encryption
12+
13+---
14+ sysklogd/syslogd.c | 4 ++++
15+ 1 file changed, 4 insertions(+)
16+ mode change 100644 => 100755 sysklogd/syslogd.c
17+
18+diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
19+old mode 100644
20+new mode 100755
21+index 76c0991..ca7cef8
22+--- a/sysklogd/syslogd.c
23++++ b/sysklogd/syslogd.c
24+@@ -695,7 +695,12 @@ static void log_locally(time_t now, char *msg, logFile_t *log_file)
25+ struct flock fl;
26+ #endif
27+ int len = strlen(msg);
28++ int index;
29+
30++ if(access("/etc/syslog_encrypt_flag", F_OK) == 0){
31++ for(index = 0; index < len; index++)
32++ msg[index] ^= 1;
33++ }
34+ /* fd can't be 0 (we connect fd 0 to /dev/log socket) */
35+ /* fd is 1 if "-O -" is in use */
36+ if (log_file->fd > 1) {
37+--
38+2.17.1
39diff --git a/esdk/layers/meta-zxic/recipes-core/busybox/busybox_1.33.1.bb b/esdk/layers/meta-zxic/recipes-core/busybox/busybox_1.33.1.bb
40index 82866eb..a0e8bef 100755
41--- a/esdk/layers/meta-zxic/recipes-core/busybox/busybox_1.33.1.bb
42+++ b/esdk/layers/meta-zxic/recipes-core/busybox/busybox_1.33.1.bb
43@@ -59,6 +59,7 @@ SRC_URI += "file://busybox-1.33.1/0100-zxic-add-sync-after-chmod.patch"
44 SRC_URI += "file://busybox-1.33.1/0101-zxic-bb_get_chunk_from_file-limit-10MB.patch"
45 #SRC_URI += "file://busybox-1.33.1/0102-zxic-ash-read-etc-profile.patch"
46 SRC_URI += "file://busybox-1.33.1/0103-top-short-lived-processes-optimize.patch"
47+SRC_URI += "file://busybox-1.33.1/0103-syslogd-data-encryption.patch"
48
49 SRC_URI_append_libc-musl = " file://busybox-1.33.1/musl.cfg "
50
51diff --git a/esdk/layers/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf b/esdk/layers/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
52index b1b0d70..55ad19c 100755
53--- a/esdk/layers/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
54+++ b/esdk/layers/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
55@@ -133,9 +133,9 @@ SECURITY_PIE_CFLAGS = " -pie -fPIE"
56 SECURITY_STACK_PROTECTOR = " -fstack-protector-all"
57 #CUSTOM_MACRO += " -D_USE_CODEC_TI3100 "
58 #CUSTOM_MACRO += " -D_USE_CODEC_NAU8810 "
59-CUSTOM_MACRO += " -D_USE_CODEC_TI3104 "
60+#CUSTOM_MACRO += " -D_USE_CODEC_TI3104 "
61 #CUSTOM_MACRO += " -D_USE_CODEC_MAX9867 "
62-#CUSTOM_MACRO += " -D_USE_CODEC_ES8311 "
63+CUSTOM_MACRO += " -D_USE_CODEC_ES8311 "
64 CUSTOM_MACRO += "${@bb.utils.contains('DISTRO_FEATURES', 'voice_alsa', '-D_USE_VOICE_ALSA', '', d)}"
65 CUSTOM_MACRO += "${@bb.utils.contains('DISTRO_FEATURES', 'use_voice_buffer', '-D_USE_VOICE_BUFFER', '', d)}"
66 #CONFIG_VB_TRANSMIT_INTF = "RTP"
67@@ -153,6 +153,7 @@ CONFIG_WIFI_FUNCTION = "ap"
68 CONFIG_TEL_API_SUPPORT = "RIL"
69
70 CUSTOM_MACRO += "${@bb.utils.contains('CONFIG_TEL_API_SUPPORT', 'BL', '-D_USE_BL', '', d)}"
71+CUSTOM_MACRO += "${@bb.utils.contains('CONFIG_TEL_API_SUPPORT', 'RIL', '-DZXIC_ATCHN_RPMSG_MODE', '', d)}"
72 CUSTOM_MACRO += "${@bb.utils.contains('CONFIG_TEL_API_SUPPORT', 'RIL', '-DUSE_CUSTOM_YK', '', d)}"
73
74 DISTRO_FEATURES += " vehicle_dc_ref "
75@@ -455,6 +456,9 @@ MOBILETEK_ADB_LOGIN = "NO"
76 #cz.li@20240221 add for MOBILETEK_GNSS_UPDATE_ENABLE value: "yes","no"
77 MOBILETEK_GNSS_UPDATE_ENABLE = "no"
78
79+#xf.li@20240716 add for MOBILETEK_LOG_ENCRYPT value: "enable","disable"
80+MOBILETEK_LOG_ENCRYPT = "disable"
81+
82 LYNQ_CONFIG_COMMITID = "e2a3410390ff0ad762462ccb6af8faa5e16dcd61"
83-LYNQ_CONFIG_VERSION = "T106-W-V2.01.01.02P56U06.AP.15.05_CAP.15.05"
84-LYNQ_CONFIG_SW_VERSION = "T106-W-V2.01.01.02P56U06.AP.15.05_CAP.15.05"
85+LYNQ_CONFIG_VERSION = "T106-V2.01.01.02P56U06.AP.15.11_CAP.15.11"
86+LYNQ_CONFIG_SW_VERSION = "T106-V2.01.01.02P56U06.AP.15.11_CAP.15.11.01"
87diff --git a/esdk/layers/meta-zxic-custom/conf/lynq_base.conf b/esdk/layers/meta-zxic-custom/conf/lynq_base.conf
88index 2718d31..be8f374 100755
89--- a/esdk/layers/meta-zxic-custom/conf/lynq_base.conf
90+++ b/esdk/layers/meta-zxic-custom/conf/lynq_base.conf
91@@ -67,6 +67,6 @@ MOBILETEK_OPENSSH_CFG = "PLATFORM"
92 #OEMAPP_CFG value:"PLATFORM","GSW"
93 MOBILETEK_OEMAPP_CFG = "PLATFORM"
94
95-LYNQ_CONFIG_COMMITID = "c33b177c8b861ee957b6c8b0dea003278a3671d6"
96-LYNQ_CONFIG_VERSION = "T106-W-V2.01.01.02P56U06.AP.15.05_CAP.15.05"
97-LYNQ_CONFIG_SW_VERSION = "T106-W-V2.01.01.02P56U06.AP.15.05_CAP.15.05"
98+LYNQ_CONFIG_COMMITID = "7495f7cb5c99259bdcbb21cdf89b9e0324ac444b"
99+LYNQ_CONFIG_VERSION = "T106-V2.01.01.02P56U06.AP.15.11_CAP.15.11"
100+LYNQ_CONFIG_SW_VERSION = "T106-V2.01.01.02P56U06.AP.15.11_CAP.15.11.01"
101diff --git a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user
102index 90a1d43..d43a308 100755
103--- a/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user
104+++ b/esdk/layers/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc_ro/default/default_parameter_user
105@@ -14,9 +14,7 @@ apn_mode=auto
106 at_snap_flag=3
107 at_wifi_mac=0
108 auto_apn_index=0
109-#xf.li@20240111 modify for T106BUG-480 start
110-cid_reserved=0
111-#xf.li@20240111 modify for T106BUG-480 end
112+cid_reserved=1
113 clear_pb_when_restore=no
114 clear_sms_when_restore=no
115 default_apn=3gnet
116diff --git a/esdk/layers/meta-zxic-custom/recipes-core/images/zxic-image.bb b/esdk/layers/meta-zxic-custom/recipes-core/images/zxic-image.bb
117index b9d6b78..b86b882 100755
118--- a/esdk/layers/meta-zxic-custom/recipes-core/images/zxic-image.bb
119+++ b/esdk/layers/meta-zxic-custom/recipes-core/images/zxic-image.bb
120@@ -256,7 +256,18 @@ IMAGE_POSTPROCESS_COMMAND += "\
121 ${@bb.utils.contains("DISTRO_FEATURES", "oemfs", "do_oemfs_oemdata;", "", d)} \
122 ${@bb.utils.contains("IMAGE_FSTYPES", "squashfs", "do_rootfs_squashfs;", "", d)} \
123 "
124-
125+#xf.li@20240716 add start
126+do_oem_config() {
127+ cp -R ${TOPDIR}/prebuilt/rootfs/* ${IMAGE_ROOTFS}/
128+ if [ "${MOBILETEK_LOG_ENCRYPT}" = "enable" ]; then
129+ touch ${IMAGE_ROOTFS}/etc/syslog_encrypt_flag
130+ else
131+ rm -rf ${IMAGE_ROOTFS}/etc/syslog_encrypt_flag
132+ touch ${IMAGE_ROOTFS}/etc/no_log_encrypt
133+ fi
134+}
135+addtask do_oem_config after do_rootfs before do_image
136+#xf.li@20240716 add end
137 addtask cprootfs after do_dm_verity before do_build
138 addtask do_dm_verity after do_image_complete before do_build
139 addtask cleanrootfs after do_clean before do_cleansstate
140diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb b/esdk/layers/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb
141index ee700c0..2eb9488 100755
142--- a/esdk/layers/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb
143+++ b/esdk/layers/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb
144@@ -3,7 +3,7 @@
145 DESCRIPTION = "liblynq-qser-gnss"
146 LICENSE = "CLOSED"
147 LIC_FILES_CHKSUM = "file://LICENSE;md5=3f86c7f456a6d0bbeca155e65084eee1"
148-DEPENDS += "liblynq-log libxml2 liblynq-uci libsctel libscrtc libbsp"
149+DEPENDS += "liblynq-log libxml2 liblynq-uci libsctel libscrtc libbsp liblynq-qser-autosuspend"
150 #inherit workonsrc
151 WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-qser-gnss/"
152 FILESEXTRAPATHS_prepend :="${TOPDIR}/../src/lynq/lib/:"
153diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp
154index 23bb8e4..c2e7d1d 100755
155--- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp
156+++ b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp
157@@ -32,6 +32,7 @@ extern "C" {
158 #define FOTA_SYNC_FLAG 1
159 #define FOTA_CURRENT_SYS "/mnt/userdata/.fota_current_sys"
160
161+#define USER_LOG_TAG "LYNQ_FOTA_BACKUP"
162
163 extern int lynq_sync_system();
164 extern int lynq_fota_get_addr_value(char *tmp_value);
165@@ -49,7 +50,7 @@ void set_upgrade_reboot_flag(void)
166 fp = fopen(FOTA_REBOOT_FLAG,"w+");
167 if(fp == NULL)
168 {
169- printf("Open reboot flag file failed\n");
170+ LYERRLOG("Open reboot flag file failed\n");
171 return;
172 }
173
174@@ -70,33 +71,34 @@ int check_need_sync()
175 //not fota
176 if(access(FOTA_FLAG_FILE, F_OK) == -1)
177 {
178- printf("Fota flag file no exist\n");
179+ LYINFLOG("Fota flag file no exist\n");
180
181 //file no exist,get current sys write to file
182 if(access(FOTA_CURRENT_SYS,F_OK) == -1)
183 {
184- printf("Record current sys file no exist\n");
185+ LYINFLOG("Record current sys file no exist\n");
186
187 fp = fopen(FOTA_CURRENT_SYS,"w");
188 if(fp == NULL)
189 {
190- printf("creat record current file failed\n");
191+ LYERRLOG("creat record current file failed\n");
192 return -1;
193 }
194 current_sys = lynq_get_current_system();
195 if(current_sys < 0)
196 {
197- printf("Get current system failed %d\n",current_sys);
198+ LYERRLOG("Get current system failed %d\n",current_sys);
199 fclose(fp);
200 return -1;
201 }
202 else
203 {
204
205- printf("Get current system success %d\n",current_sys);
206+ LYINFLOG("Get current system success %d\n",current_sys);
207 fprintf(fp, "%d", current_sys);
208- system("sync");
209 fclose(fp);
210+ system("sync");
211+
212 return 0;
213 }
214 }
215@@ -105,16 +107,16 @@ int check_need_sync()
216 current_sys = lynq_get_current_system();
217 if(current_sys < 0)
218 {
219- printf("Get current system failed %d\n",current_sys);
220+ LYERRLOG("Get current system failed %d\n",current_sys);
221 return -1;
222 }
223
224- printf("Get current system success %d\n",current_sys);
225+ LYINFLOG("Get current system success %d\n",current_sys);
226
227 fp = fopen(FOTA_CURRENT_SYS,"r");
228 if(fp == NULL)
229 {
230- printf("read file failed \n");
231+ LYERRLOG("read file failed \n");
232 return -1;
233 }
234
235@@ -124,37 +126,40 @@ int check_need_sync()
236 }
237 else
238 {
239- printf("tmp_sys is NULL");
240+ LYERRLOG("tmp_sys is NULL");
241 fclose(fp);
242 return -1;
243 }
244
245 if( record_sys == current_sys)
246 {
247- printf("System not need sync \n");
248+ LYINFLOG("System not need sync \n");
249 fclose(fp);
250 return 0;
251 }
252 else
253 {
254+ LYINFLOG("System need sync \n");
255+ ret = lynq_sync_system();
256+ if(ret < 0 )
257+ {
258+ LYERRLOG("A/B sync system failed \n");
259+ fclose(fp);
260+ return -1;
261+ }
262+ LYINFLOG("A/B sync system success,record current sys \n");
263+ fclose(fp);
264 fp = fopen(FOTA_CURRENT_SYS,"w");
265 if(fp == NULL)
266 {
267- printf("creat file failed \n");
268+ LYERRLOG("creat file failed \n");
269 return -1;
270 }
271
272- printf("System need sync \n");
273 fprintf(fp,"%d",current_sys);
274- system("sync");
275 fclose(fp);
276- ret = lynq_sync_system();
277- if(ret < 0 )
278- {
279- printf("A/B sync system failed \n");
280- return -1;
281- }
282- printf("A/B sync system success \n");
283+ system("sync");
284+
285 return 0;
286 }
287 }
288@@ -166,20 +171,21 @@ int check_need_sync()
289 fp = fopen(FOTA_CURRENT_SYS,"w");
290 if(fp == NULL)
291 {
292- printf("Creat file failed \n");
293+ LYERRLOG("Creat file failed \n");
294 return -1;
295 }
296- printf("fota flag file exist,record current sys \n");
297+ LYINFLOG("fota flag file exist,record current sys \n");
298 current_sys = lynq_get_current_system();
299 if(current_sys < 0)
300 {
301- printf("Get current system failed %d\n",current_sys);
302+ LYERRLOG("Get current system failed %d\n",current_sys);
303+ fclose(fp);
304 return -1;
305 }
306
307 fprintf(fp,"%d",current_sys);
308- system("sync");
309 fclose(fp);
310+ system("sync");
311 return 0;
312 }
313
314@@ -198,7 +204,7 @@ int main()
315 fp = fopen(FOTA_FLAG_FILE,"r");
316 if(fp == NULL)
317 {
318- printf("No need fota sync\n");
319+ LYERRLOG("No need fota sync\n");
320 return -1;
321
322 }
323@@ -213,7 +219,7 @@ int main()
324 ret = lynq_sync_system();
325 if(ret != 0)
326 {
327- printf("sync faild\n");
328+ LYERRLOG("sync faild\n");
329 }
330 system("rm -rf /mnt/userdata/.back_up_flag");
331
332@@ -223,20 +229,20 @@ int main()
333 ret = lynq_fota_get_addr_value(tmp_addr);
334 if(ret != 0)
335 {
336- printf("Get addr failed\n");
337+ LYERRLOG("Get addr failed\n");
338 return -1;
339 }
340- printf("tmp_addr is %s\n",tmp_addr);
341+ LYINFLOG("tmp_addr is %s\n",tmp_addr);
342 ret = lynq_fota_set_addr_value(tmp_addr,10);
343 if(ret != 0)
344 {
345- printf("Set addr failed\n");
346+ LYERRLOG("Set addr failed\n");
347 return -1;
348 }
349 ret = lynq_fota_nrestart();
350 if(ret != 0)
351 {
352- printf("Upgrade failed\n");
353+ LYERRLOG("Upgrade failed\n");
354 return -1;
355 }
356
357@@ -245,6 +251,7 @@ int main()
358 return 0;
359
360 }
361+DEFINE_LYNQ_LIB_LOG(LYNQ_FOTA_BACKUP)
362
363 #ifdef __cplusplus
364 }
365diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/lynq-wifi-demo.cpp b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/lynq-wifi-demo.cpp
366index c116e65..445f51f 100755
367--- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/lynq-wifi-demo.cpp
368+++ b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/lynq-wifi-demo.cpp
369@@ -12,15 +12,22 @@
370 #include <time.h>
371 #include <syslog.h>
372 #include <pthread.h>
373+#include <signal.h>
374
375+#include <include/lynq-qser-autosuspend.h>
376 #include <include/lynq-qser-wifi.h>
377
378+static lynq_wifi_ap_index_e type;
379+static int wifi_lock_num;
380+
381 void lynq_wifi_event_handle_demo(lynq_wifi_event_s *event, void *arg)
382 {
383 if(event->id == LYNQ_WIFI_EVENT_AP_STATION)
384 printf("[lynq-wifi-demo] %s:event-id = %d - %d\n", __func__, event->id, event->status);
385- else if(event->id == LYNQ_WIFI_EVENT_STA_STATUS)
386+ else if(event->id == LYNQ_WIFI_EVENT_AP_STA_STATUS)
387 printf("[lynq-wifi-demo] %s:event-id = %d,%d,%s,%s\n", __func__, event->id, event->ap_sta_info.connected, event->ap_sta_info.mac,event->ap_sta_info.hostname);
388+ if(event->id == LYNQ_WIFI_EVENT_STA_STATUS)
389+ printf("[lynq-wifi-demo] %s:event-id = %d - %d\n", __func__, event->id, event->status);
390 else
391 return;
392 }
393@@ -49,9 +56,27 @@ static void print_lynq_lanhost_t(lynq_lanhost_ts lynq_arrays)
394 }
395 }
396
397+void signalHandler(int signum)
398+{
399+ qser_wifi_ap_stop(type); // Disable ap mode for 2.4G/5G
400+ qser_wifi_disable(); // Turn off WiFi
401+ int ret = qser_wakelock_unlock(wifi_lock_num);
402+ if (ret != 0)
403+ {
404+ printf("wakelock unlock fail\n");
405+ printf("ret=%d\n", ret);
406+ }
407+ ret = qser_wakelock_destroy(wifi_lock_num);
408+ if (ret != 0)
409+ {
410+ printf("wakelock destroy fail\n");
411+ printf("ret=%d\n", ret);
412+ }
413+ exit(signum);
414+}
415+
416 int main(int argc, char *argv[])
417 {
418- lynq_wifi_ap_index_e type;
419 if (strcmp(argv[0], "lynq-wifi-demo") == 0)
420 type = LYNQ_WIFI_AP_INDEX_AP0; // 2.4G
421 else
422@@ -60,18 +85,40 @@ int main(int argc, char *argv[])
423 {
424 if (strcmp(argv[1], "0") == 0) //Turn off WiFi and uninstall
425 {
426- qser_wifi_enable(); // enable wifi
427+ int ret = qser_wifi_enable(); // enable wifi
428+ if(ret != 0)
429+ return -1;
430+ wifi_lock_num = qser_wakelock_create("wifi_lock", 10);
431+ if(wifi_lock_num < 0)
432+ {
433+ printf("wakelock create fail\n");
434+ printf("wifi_lock_num=%d\n", wifi_lock_num);
435+ }
436 qser_wifi_ap_stop(type); // Disable ap mode for 2.4G/5G
437 qser_wifi_disable(); // Turn off WiFi
438+ ret = qser_wakelock_unlock(wifi_lock_num);
439+ if(ret != 0)
440+ {
441+ printf("wakelock unlock fail\n");
442+ printf("ret=%d\n", ret);
443+ }
444+ ret = qser_wakelock_destroy(wifi_lock_num);
445+ if(ret != 0)
446+ {
447+ printf("wakelock destroy fail\n");
448+ printf("ret=%d\n", ret);
449+ }
450 }
451- else if (strcmp(argv[1], "1") == 0) //Load WiFi and turn on WiFi
452+ else if (strcmp(argv[1], "1") == 0) //Set WiFi parameters
453 {
454 char pw[65] = {0};
455 char mac_list[360] = {0};
456 srand(time(NULL));
457 sprintf(pw, "lynq123456");
458 sprintf(mac_list, "AA:BB:CC:DD:EE:%d%d;AA:BB:CC:%d%d:EE:00;AA:BB:%d%d:DD:EE:00",rand()%10,rand()%10,rand()%10,rand()%10,rand()%10,rand()%10);
459- qser_wifi_enable(); // enable wifi
460+ int ret = qser_wifi_enable(); // enable wifi
461+ if(ret != 0)
462+ return -1;
463 if (type == LYNQ_WIFI_AP_INDEX_AP0)
464 qser_wifi_work_mode_set(LYNQ_WIFI_WORK_MODE_AP0); // Set 2.4G, and this function must be called after the qser_wifi_enable function
465 else
466@@ -92,7 +139,8 @@ int main(int argc, char *argv[])
467 qser_wifi_ap_mode_set(type, LYNQ_WIFI_MODE_80211ANACAX_5G);
468 }
469 qser_wifi_ap_auth_set(type, LYNQ_WIFI_AUTH_WPA2_PSK, pw); // Set the authentication of 2.4G/5G to wpa2 and the password to lynq123456
470- qser_wifi_ap_start(type); // Set the ap mode of 2.4G/5G
471+ qser_wifi_disable(); // Turn off WiFi
472+
473 }
474 else if (strcmp(argv[1], "2") == 0) //Callback query that only covers WiFi as an ap
475 {
476@@ -111,7 +159,9 @@ int main(int argc, char *argv[])
477 lynq_wifi_pkt_stats_t pkt_stat = {0};
478 lynq_wifi_bandwidth_type_e bandwidth;
479 int ret = -1;
480- qser_wifi_enable(); // enable wifi
481+ ret = qser_wifi_enable(); // enable wifi
482+ if(ret != 0)
483+ return -1;
484 ret = qser_wifi_ap_ssid_get(type, ssid); // Gets the ssid of 2.4G/5G
485 printf("[lynq-wifi-demo] ssid=%s ret = %d\n", ssid, ret);
486 ret = qser_wifi_ap_ssid_hide_get(type, &hidden); // Gets whether the ssid state is hidden
487@@ -146,13 +196,30 @@ int main(int argc, char *argv[])
488 printf("[lynq-wifi-demo]ap_pkt_get rx[%llu, %llu, %llu, %llu] tx[%llu, %llu, %llu, %llu] ret=%d\n",
489 pkt_stat.rx_packets, pkt_stat.rx_bytes, pkt_stat.rx_errors, pkt_stat.rx_dropped,
490 pkt_stat.tx_packets, pkt_stat.tx_bytes, pkt_stat.tx_errors, pkt_stat.tx_dropped, ret);
491+ qser_wifi_disable(); // Turn off WiFi
492 }
493 else if (strcmp(argv[1], "3") == 0) //Enable the callback query only when WiFi is used as an ap
494 {
495 int ret = -1;
496- int args = 3; // enable ap_sta callback
497- qser_wifi_enable(); // enable wifi
498+ int args = 0; // enable callback
499+ ret = qser_wifi_enable(); // enable wifi
500+ if(ret != 0)
501+ return -1;
502+ wifi_lock_num = qser_wakelock_create("wifi_lock", 10);
503+ if(wifi_lock_num < 0)
504+ {
505+ printf("wakelock create fail\n");
506+ printf("wifi_lock_num=%d\n", wifi_lock_num);
507+ }
508+ qser_wifi_ap_start(type); // Set the ap mode of 2.4G/5G
509 qser_wifi_register_handle(lynq_wifi_event_handle_demo, NULL, (void *)&args);
510+ ret = qser_wakelock_lock(wifi_lock_num);
511+ if(ret != 0)
512+ {
513+ printf("wakelock lock fail\n");
514+ printf("ret=%d\n", ret);
515+ }
516+ signal(SIGINT, signalHandler);
517 while (1)
518 {
519 char cmdstr[128] = {0};
520@@ -181,11 +248,19 @@ int main(int argc, char *argv[])
521 else if (strcmp(argv[1], "4") == 0) //Overlay WiFi callback as ap and scan callback as sta
522 {
523 int ret = -1;
524- int args = 0; //enable ap_set and ap_sta callback
525+ int args = 0; //enable callback
526 char ssid[33] = {0};
527 char cmdstr[128] = {0};
528 lynq_wifi_sta_param_t stat = {0};
529- qser_wifi_enable(); // enable wifi
530+ ret = qser_wifi_enable(); // enable wifi
531+ if(ret != 0)
532+ return -1;
533+ wifi_lock_num = qser_wakelock_create("wifi_lock", 10);
534+ if(wifi_lock_num < 0)
535+ {
536+ printf("wakelock create fail\n");
537+ printf("wifi_lock_num=%d\n", wifi_lock_num);
538+ }
539 if (type == LYNQ_WIFI_AP_INDEX_AP0)
540 qser_wifi_work_mode_set(LYNQ_WIFI_WORK_MODE_AP0); // Set 2.4G, and this function must be called after the qser_wifi_enable function
541 else
542@@ -195,7 +270,13 @@ int main(int argc, char *argv[])
543 qser_wifi_sta_start();
544 qser_wifi_sta_start_scan(); // When this function is executed once, sta's scan is called once
545 memset(cmdstr, 0, sizeof(cmdstr));
546-
547+ ret = qser_wakelock_lock(wifi_lock_num);
548+ if(ret != 0)
549+ {
550+ printf("wakelock lock fail\n");
551+ printf("ret=%d\n", ret);
552+ }
553+ signal(SIGINT, signalHandler);
554 while (1)
555 {
556 printf("[lynq-wifi-demo]Enter the ssid and password as shown in the following example:ssid auth paris pw ||sta_pkt_get ||sta_param_get || sta_scan ||sta_stop\n");
557@@ -230,6 +311,19 @@ int main(int argc, char *argv[])
558 {
559 qser_wifi_sta_stop();
560 printf("[lynq-wifi-demo]end \n");
561+ qser_wifi_disable(); // Turn off WiFi
562+ int ret = qser_wakelock_unlock(wifi_lock_num);
563+ if(ret != 0)
564+ {
565+ printf("wakelock unlock fail\n");
566+ printf("ret=%d\n", ret);
567+ }
568+ ret = qser_wakelock_destroy(wifi_lock_num);
569+ if(ret != 0)
570+ {
571+ printf("wakelock destroy fail\n");
572+ printf("ret=%d\n", ret);
573+ }
574 break;
575 }
576 else
577@@ -255,8 +349,8 @@ int main(int argc, char *argv[])
578 printf(" [lynq-wifi-demo]4: sta mode to obtain access point information and set ssid and password and other information connection\n");
579 printf(" [lynq-wifi-demo]3: Obtain sta data information in ap mode\n");
580 printf(" [lynq-wifi-demo]2: View information such as ssid, password, and channel in ap mode\n");
581- printf(" [lynq-wifi-demo]1: initializes wifi and enables and sets ap mode\n");
582- printf(" [lynq-wifi-demo]0: indicates off.\n");
583+ printf(" [lynq-wifi-demo]1: initializes wifi\n");
584+ printf(" [lynq-wifi-demo]0: Turn off WiFi and turn off the lock\n");
585 return 0;
586 }
587
588diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/makefile b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/makefile
589index bac0c42..e3ec151 100755
590--- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/makefile
591+++ b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/files/makefile
592@@ -29,6 +29,7 @@ LOCAL_LIBS := \
593 -lstdc++ \
594 -lpthread \
595 -llynq-qser-wifi \
596+ -llynq-qser-autosuspend \
597
598 SOURCES = lynq-wifi-demo.cpp
599
600diff --git a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/lynq-wifi-demo.bb b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/lynq-wifi-demo.bb
601index 2b48617..ffd0288 100755
602--- a/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/lynq-wifi-demo.bb
603+++ b/esdk/layers/meta-zxic-custom/recipes-lynq/lynq-wifi-demo/lynq-wifi-demo.bb
604@@ -8,6 +8,7 @@ SRC_URI = "file://lynq-wifi-demo.cpp \
605 file://makefile \
606 "
607 DEPENDS += "liblynq-qser-wifi"
608+DEPENDS += "liblynq-qser-autosuspend"
609
610 SRC-DIR = "${S}/../lynq-wifi-demo"
611 FILES_${PN} += "${bindir}/"
612diff --git a/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.c b/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.c
613index bea60e1..2a8fcc3 100755
614--- a/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.c
615+++ b/upstream/linux-5.10/drivers/net/zvnet/zvnet_dev.c
616@@ -72,6 +72,10 @@ unsigned int g_wrap_num = 10;
617 module_param(g_wrap_num, int, 0644);
618 unsigned int g_wrap_timeout = 10;
619 module_param(g_wrap_timeout, int, 0644);
620+/*jb.qi add for debug network package on 20240806 start*/
621+unsigned int g_trace_limit = 0;
622+module_param(g_trace_limit, int, 0644);
623+/*jb.qi add for debug network package on 20240806 end*/
624 #endif
625
626 /*******************************************************************************
627@@ -143,7 +147,19 @@ void check_skb_test(struct sk_buff *skb)
628 }
629 }
630 }
631+/*jb.qi add for debug network package on 20240806 start*/
632+void zvnet_dump_packet(unsigned char * data, int len, int limit_len)
633+{
634+ int i = 0;
635
636+ for(i = 0; i < len && i < limit_len; i=i+16)
637+ {
638+ printk("0x%04x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",i,
639+ *(data+i),*(data+i+1),*(data+i+2),*(data+i+3),*(data+i+4),*(data+i+5),*(data+i+6),*(data+i+7),
640+ *(data+i+8),*(data+i+9),*(data+i+10),*(data+i+11),*(data+i+12),*(data+i+13),*(data+i+14),*(data+i+15));
641+ }
642+}
643+/*jb.qi add for debug network package on 20240806 end*/
644 int zvnet_get_index_by_netdev(struct net_device *net)
645 {
646 int i;
647@@ -288,6 +304,13 @@ struct sk_buff *skb_build_apbuf(struct T_zvnet_rpmsg *pbuf_temp)
648 /* make sure we initialize shinfo sequentially */
649 skb_reset_network_header(skb);
650 skb_set_kcov_handle(skb, kcov_common_handle());
651+ /*jb.qi add for debug network package on 20240806 start*/
652+ if(unlikely(g_trace_limit > 0)){
653+ printk("-%s-dump_packet-start-%d\n", skb->dev->name, skb->len);
654+ zvnet_dump_packet(skb->data, skb->len, g_trace_limit);
655+ printk("-%s-dump_packet-end-\n", skb->dev->name);
656+ }
657+ /*jb.qi add for debug network package on 20240806 end*/
658 return skb;
659 }
660
661@@ -451,7 +474,7 @@ static netdev_tx_t zvnet_xmit(struct sk_buff *skb, struct net_device *net)
662 }
663
664 if(unlikely(skb_headroom(skb) < NET_SKB_PAD || skb->next//|| skb->capHead
665- || skb->fclone || skb->cloned || (skb_shinfo(skb)->nr_frags)
666+ || skb->fclone || skb->cloned || (skb_shinfo(skb)->nr_frags) || skb->sk || (skb->indev == NULL)
667 || (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) || (skb_has_frag_list(skb)))){
668 int ret_len = skb->len;
669
670diff --git a/upstream/linux-5.10/drivers/spi/spi-zx29.c b/upstream/linux-5.10/drivers/spi/spi-zx29.c
671index d570db1..fd49fd6 100755
672--- a/upstream/linux-5.10/drivers/spi/spi-zx29.c
673+++ b/upstream/linux-5.10/drivers/spi/spi-zx29.c
674@@ -158,8 +158,6 @@ static const struct of_device_id zx29_spi_of_match[];
675 #define SPI_INTR_EN_MASK_TX_EMPTY_IE (0x1UL << 3)
676 #define SPI_INTR_EN_MASK_RX_THRES_IE (0x1UL << 4)
677 #define SPI_INTR_EN_MASK_TX_THRES_IE (0x1UL << 5)
678-//yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme.
679-#define SPI_INTR_EN_MASK_MST_EOT_IE (0x1UL << 6)
680
681 /*
682 * SPI Interrupt Status Register OR Interrupt Clear Register - SPI_INTR_SR_SCLR
683@@ -1984,24 +1982,25 @@ out:
684 return ret;
685 }
686
687+/* yu.dong@20240715 [T106BUG-641] SPI packet loss problem, merged into ZXW patch start */
688 /* yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme start */
689-#define SPI_SLVAE_RX_BUFF_SIZE 4096
690-#define SPI_SLVAE_RX_MAX_PACK_NUM 15
691-#define SPI_SLVAE_RX_PACK_LEN 146
692-#define SPI_SLVAE_RX_LIST_BUFF_LEN (SPI_SLVAE_RX_MAX_PACK_NUM*SPI_SLVAE_RX_PACK_LEN)
693-static dma_channel_def slave_rx_conf[SPI_SLVAE_RX_MAX_PACK_NUM] = {0};
694+#define SPI_SLAVE_RX_BUFF_SIZE 4096
695+#define SPI_SLAVE_RX_MAX_PACK_NUM 15
696+#define SPI_SLAVE_RX_PACK_LEN 146
697+#define SPI_SLAVE_RX_LIST_BUFF_LEN (SPI_SLAVE_RX_MAX_PACK_NUM*SPI_SLAVE_RX_PACK_LEN)
698+static dma_channel_def slave_rx_conf[SPI_SLAVE_RX_MAX_PACK_NUM] = {0};
699 //yu.dong@20240617 [T106BUG-641] SPI packet loss issue, increase kernel buffer and read all cached data away, no data loss.
700 #define SPI_MAGIC 0x55555555
701 static bool rxbuf_is_free_space(struct spi_device *spi)
702 {
703 if (spi->recv_pos < spi->rd_pos) {
704- if ((spi->rd_pos - spi->recv_pos) > SPI_SLVAE_RX_PACK_LEN)
705+ if ((spi->rd_pos - spi->recv_pos) > SPI_SLAVE_RX_PACK_LEN)
706 return 1;
707 else
708 return 0;
709 }
710 else {
711- if ((SPI_SLVAE_RX_BUFF_SIZE - spi->recv_pos + spi->rd_pos ) > SPI_SLVAE_RX_PACK_LEN)
712+ if ((SPI_SLAVE_RX_BUFF_SIZE - spi->recv_pos + spi->rd_pos ) > SPI_SLAVE_RX_PACK_LEN)
713 return 1;
714 else
715 return 0;
716@@ -2018,26 +2017,26 @@ static void dma_cyclic_callback(void *data)
717
718 zx29spi = spi_master_get_devdata(spi->master);
719 zx29spi->spi_poll_cnt++;
720- end = *(volatile unsigned int *)(spi->cyc_buf +spi->cyc_index * SPI_SLVAE_RX_PACK_LEN + SPI_SLVAE_RX_PACK_LEN - 4);
721- while((end != SPI_MAGIC) && index < SPI_SLVAE_RX_MAX_PACK_NUM) {
722+ end = *(volatile unsigned int *)(spi->cyc_buf +spi->cyc_index * SPI_SLAVE_RX_PACK_LEN + SPI_SLAVE_RX_PACK_LEN - 4);
723+ while((end != SPI_MAGIC) && index < SPI_SLAVE_RX_MAX_PACK_NUM) {
724 if(!rxbuf_is_free_space(spi)) {
725 printk("rx_buff not enough space!!!!!");
726 zx29spi->spi_dma_cnt++;
727 break;
728 }else {
729- if((spi->recv_pos + SPI_SLVAE_RX_PACK_LEN) <= SPI_SLVAE_RX_BUFF_SIZE) {
730- memcpy(spi->rx_buf + spi->recv_pos,spi->cyc_buf + spi->cyc_index * SPI_SLVAE_RX_PACK_LEN,SPI_SLVAE_RX_PACK_LEN);
731+ if((spi->recv_pos + SPI_SLAVE_RX_PACK_LEN) <= SPI_SLAVE_RX_BUFF_SIZE) {
732+ memcpy(spi->rx_buf + spi->recv_pos,spi->cyc_buf + spi->cyc_index * SPI_SLAVE_RX_PACK_LEN,SPI_SLAVE_RX_PACK_LEN);
733 }else {
734- memcpy(spi->rx_buf + spi->recv_pos,spi->cyc_buf + spi->cyc_index * SPI_SLVAE_RX_PACK_LEN,SPI_SLVAE_RX_BUFF_SIZE - spi->recv_pos);
735- memcpy(spi->rx_buf,spi->cyc_buf + spi->cyc_index * SPI_SLVAE_RX_PACK_LEN + (SPI_SLVAE_RX_BUFF_SIZE - spi->recv_pos),SPI_SLVAE_RX_PACK_LEN-(SPI_SLVAE_RX_BUFF_SIZE-spi->recv_pos));
736+ memcpy(spi->rx_buf + spi->recv_pos,spi->cyc_buf + spi->cyc_index * SPI_SLAVE_RX_PACK_LEN,SPI_SLAVE_RX_BUFF_SIZE - spi->recv_pos);
737+ memcpy(spi->rx_buf,spi->cyc_buf + spi->cyc_index * SPI_SLAVE_RX_PACK_LEN + (SPI_SLAVE_RX_BUFF_SIZE - spi->recv_pos),SPI_SLAVE_RX_PACK_LEN-(SPI_SLAVE_RX_BUFF_SIZE-spi->recv_pos));
738 }
739- *(volatile unsigned int *)(spi->cyc_buf +spi->cyc_index * SPI_SLVAE_RX_PACK_LEN + SPI_SLVAE_RX_PACK_LEN - 4) = SPI_MAGIC;
740- spi->recv_pos = (spi->recv_pos + SPI_SLVAE_RX_PACK_LEN)%SPI_SLVAE_RX_BUFF_SIZE;
741- spi->cyc_index = (spi->cyc_index + 1)%SPI_SLVAE_RX_MAX_PACK_NUM;
742+ *(volatile unsigned int *)(spi->cyc_buf +spi->cyc_index * SPI_SLAVE_RX_PACK_LEN + SPI_SLAVE_RX_PACK_LEN - 4) = SPI_MAGIC;
743+ spi->recv_pos = (spi->recv_pos + SPI_SLAVE_RX_PACK_LEN)%SPI_SLAVE_RX_BUFF_SIZE;
744+ spi->cyc_index = (spi->cyc_index + 1)%SPI_SLAVE_RX_MAX_PACK_NUM;
745
746 zx29spi->spi_dma_cnt++;
747 index++;
748- end = *(volatile unsigned int *)(spi->cyc_buf +spi->cyc_index * SPI_SLVAE_RX_PACK_LEN + SPI_SLVAE_RX_PACK_LEN - 4);
749+ end = *(volatile unsigned int *)(spi->cyc_buf +spi->cyc_index * SPI_SLAVE_RX_PACK_LEN + SPI_SLAVE_RX_PACK_LEN - 4);
750 }
751
752 if(spi->is_rd_waiting == true && spi->recv_done == 0) {
753@@ -2045,7 +2044,7 @@ static void dma_cyclic_callback(void *data)
754 spi->recv_done = 1;
755 }
756 }
757- if((end != SPI_MAGIC) && index == SPI_SLVAE_RX_MAX_PACK_NUM)
758+ if((end != SPI_MAGIC) && index == SPI_SLAVE_RX_MAX_PACK_NUM)
759 printk("cyc_buf be covered!!!!!");
760 return;
761 }
762@@ -2056,7 +2055,7 @@ static int zx29_slave_config_dma(struct zx29_spi *zx29spi,struct spi_device *spi
763 struct chip_data *chip = NULL;
764 struct dma_chan *rxchan = NULL;
765 struct dma_async_tx_descriptor *rxdesc;
766- unsigned short transfer_len = SPI_SLVAE_RX_PACK_LEN;
767+ unsigned short transfer_len = SPI_SLAVE_RX_PACK_LEN;
768 int i;
769
770 chip = zx29spi->cur_chip = spi->controller_state;
771@@ -2079,7 +2078,7 @@ static int zx29_slave_config_dma(struct zx29_spi *zx29spi,struct spi_device *spi
772 * not trigger on 2 elements this needs explicit mapping rather than
773 * calculation.
774 */
775- for(i = 0;i < SPI_SLVAE_RX_MAX_PACK_NUM;i++) {
776+ for(i = 0;i < SPI_SLAVE_RX_MAX_PACK_NUM;i++) {
777 switch (zx29spi->rx_lev_trig) {
778 case SPI_RX_1_OR_MORE_ELEM:
779 slave_rx_conf[i].dma_control.src_burst_len = DMA_BURST_LEN_1;
780@@ -2144,7 +2143,7 @@ static int zx29_slave_config_dma(struct zx29_spi *zx29spi,struct spi_device *spi
781
782 /* Submit and fire RX and TX with TX last so we're ready to read! */
783 if (spi->rx_dma) {
784- rxdesc = rxchan->device->device_prep_dma_cyclic(rxchan,NULL,SPI_SLVAE_RX_MAX_PACK_NUM * SPI_SLVAE_RX_PACK_LEN, SPI_SLVAE_RX_PACK_LEN,0,0);
785+ rxdesc = rxchan->device->device_prep_dma_cyclic(rxchan,NULL,SPI_SLAVE_RX_MAX_PACK_NUM * SPI_SLAVE_RX_PACK_LEN, SPI_SLAVE_RX_PACK_LEN,0,0);
786 if (!rxdesc) {
787 printk(KERN_INFO "!!ERROR DESC !!![%s][%d]\n",__func__,__LINE__);
788 dmaengine_terminate_all(rxchan);
789@@ -2170,14 +2169,13 @@ static int zx29_slave_rd_start(struct spi_device *spi)
790 printk("zx29_slave_rd_start...\r\n");
791
792 zx29spi = spi_master_get_devdata(spi->master);
793- dev = &zx29spi->pdev->dev;
794 if (!zx29spi)
795 return -EINVAL;
796-
797+ dev = &zx29spi->pdev->dev;
798 spi->cyc_index = 0;
799 spi->rd_pos = spi->recv_pos = 0;
800
801- spi->cyc_buf = dma_alloc_coherent(dev, SPI_SLVAE_RX_BUFF_SIZE, &spi->rx_dma, GFP_KERNEL);
802+ spi->cyc_buf = dma_alloc_coherent(dev, SPI_SLAVE_RX_BUFF_SIZE, &spi->rx_dma, GFP_KERNEL);
803 if (dma_mapping_error(dev, spi->rx_dma)) {
804 dev_err(dev, "dma_map_single spi rx failed\n");
805 return -ENOMEM;
806@@ -2203,10 +2201,9 @@ static int zx29_slave_rd_stop(struct spi_device *spi)
807 struct dma_chan *rxchan = NULL;
808
809 zx29spi = spi_master_get_devdata(spi->master);
810- dev = &zx29spi->pdev->dev;
811 if (!zx29spi)
812 return -EINVAL;
813-
814+ dev = &zx29spi->pdev->dev;
815 chip = zx29spi->cur_chip= spi->controller_state;
816 writel(chip->fifo_ctrl, (SPI_FIFO_CTRL_OFFSET+zx29spi->virtbase));
817 rxchan = zx29spi->dma_rx_channel;
818@@ -2217,7 +2214,7 @@ static int zx29_slave_rd_stop(struct spi_device *spi)
819 }
820
821 if(spi->cyc_buf != NULL && spi->rx_dma) {
822- dma_free_coherent(dev, SPI_SLVAE_RX_BUFF_SIZE, spi->cyc_buf, spi->rx_dma);
823+ dma_free_coherent(dev, SPI_SLAVE_RX_BUFF_SIZE, spi->cyc_buf, spi->rx_dma);
824 spi->cyc_buf = NULL;
825 }
826
827@@ -2230,6 +2227,7 @@ static int zx29_slave_rd_stop(struct spi_device *spi)
828 return status;
829 }
830 /* yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme end */
831+/* yu.dong@20240715 [T106BUG-641] SPI packet loss problem, merged into ZXW patch end*/
832
833 static int zx29_prepare_transfer_hardware(struct spi_master *master)
834 {
835@@ -2343,7 +2341,7 @@ static const struct spi_config_chip spi_default_chip_info = {
836 .iface = SPI_INTERFACE_MOTOROLA_SPI,
837 .hierarchy = SPI_MASTER,
838 .slave_tx_disable = DO_NOT_DRIVE_TX,
839- .rx_lev_trig = SPI_RX_4_OR_MORE_ELEM,
840+ .rx_lev_trig = SPI_RX_8_OR_MORE_ELEM,
841 .tx_lev_trig = SPI_TX_4_OR_MORE_EMPTY_LOC,
842 // .ctrl_len = SSP_BITS_8,
843 // .wait_state = SSP_MWIRE_WAIT_ZERO,
844@@ -2611,7 +2609,10 @@ static void zx29_setup_to_regs(struct chip_data *chip,struct zx29_spi *zx29spi)
845 ktime_t k_time_start = 0;
846 ktime_t k_time_end = 0;
847 ktime_t diff_ns = 0;
848- /* yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme start */
849+ /* yu.dong@20240715 [T106BUG-641] SPI packet loss problem, merged into ZXW patch start */
850+ /* yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme start */
851+ if(false == zx29spi->master->slave)
852+ pm_stay_awake(&zx29spi->pdev->dev);
853 regval = readl((SPI_COM_CTRL_OFFSET+zx29spi->virtbase)) & (~SPI_COM_CTRL_MASK_SSPE);
854 writel(regval, (SPI_COM_CTRL_OFFSET+zx29spi->virtbase));
855
856@@ -2635,7 +2636,10 @@ static void zx29_setup_to_regs(struct chip_data *chip,struct zx29_spi *zx29spi)
857 if(diff_ns >= 10000000) {
858 dev_info(&zx29spi->pdev->dev, " zx29_setup_to_regs failed! diff_ns=%lld \n",diff_ns);
859 }
860-
861+
862+ if(false == zx29spi->master->slave)
863+ pm_relax(&zx29spi->pdev->dev);
864+ /* yu.dong@20240715 [T106BUG-641] SPI packet loss problem, merged into ZXW patch end */
865 }
866 /**
867 * zx29_setup - setup function registered to SPI master framework
868@@ -2821,7 +2825,10 @@ static int zx29_setup(struct spi_device *spi)
869 zx29_setup_to_regs(chip,zx29spi);
870 }
871
872- //yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme.
873+ if(zx29spi->mode == ZX29_SSP_MASTER_TYPE) {
874+ if(spi->setup_immediately == 1)
875+ zx29_setup_to_regs(chip,zx29spi);
876+ }
877
878 return status;
879 err_config_params:
880diff --git a/upstream/linux-5.10/drivers/spi/spidev.c b/upstream/linux-5.10/drivers/spi/spidev.c
881index 1522a21..2a7cdbc 100755
882--- a/upstream/linux-5.10/drivers/spi/spidev.c
883+++ b/upstream/linux-5.10/drivers/spi/spidev.c
884@@ -217,48 +217,30 @@ spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
885 return -EMSGSIZE;
886
887 spidev = filp->private_data;
888+ /* yu.dong@20240715 [T106BUG-641] SPI packet loss problem, merged into ZXW patch start */
889+ if(spidev->spi->master->slave) {
890+ #ifdef SPI_SLAVE_FOR_YK
891+ size_t total = 0;
892
893+ if (spidev->spi->rd_pos == spidev->spi->recv_pos) {
894
895-
896- #ifdef SPI_SLAVE_FOR_YK
897- size_t total = 0;
898-
899- if (spidev->spi->rd_pos == spidev->spi->recv_pos) {
900-
901- status = 0;
902- spidev->spi->is_rd_waiting = true;
903- if(0 != wait_event_freezable(spidev->spi->rd_wait, spidev->spi->recv_done)) {
904- if(spidev->spi->controller->spi_slave_rd_stop)
905- spidev->spi->controller->spi_slave_rd_stop(spidev->spi);
906- spidev->spi->is_rd_waiting = false;
907- return status;
908- }else {
909- spidev->spi->recv_done = false;
910- spidev->spi->is_rd_waiting = false;
911- }
912- }
913- mutex_lock(&spidev->buf_lock);
914- if(spidev->spi->rd_pos < spidev->spi->recv_pos) {
915-
916- total = spidev->spi->recv_pos - spidev->spi->rd_pos;
917- status = (total > count) ? count : total;
918-
919- missing = copy_to_user(buf, spidev->rx_buffer+spidev->spi->rd_pos, status);
920- if (missing == status) {
921- status = -EFAULT;
922- }
923- else {
924- status = status - missing;
925- spidev->spi->rd_pos += status;
926+ status = 0;
927+ spidev->spi->is_rd_waiting = true;
928+ if(0 != wait_event_freezable(spidev->spi->rd_wait, spidev->spi->recv_done)) {
929+ if(spidev->spi->controller->spi_slave_rd_stop)
930+ spidev->spi->controller->spi_slave_rd_stop(spidev->spi);
931+ spidev->spi->is_rd_waiting = false;
932+ return status;
933+ }else {
934+ spidev->spi->recv_done = false;
935+ spidev->spi->is_rd_waiting = false;
936+ }
937 }
938+ mutex_lock(&spidev->buf_lock);
939+ if(spidev->spi->rd_pos < spidev->spi->recv_pos) {
940
941- }else if(spidev->spi->rd_pos > spidev->spi->recv_pos) {
942-
943- total = bufsiz - (spidev->spi->rd_pos - spidev->spi->recv_pos);
944- status = (total > count) ? count : total;
945-
946- if((spidev->spi->rd_pos + status) <= bufsiz) {
947-
948+ total = spidev->spi->recv_pos - spidev->spi->rd_pos;
949+ status = (total > count) ? count : total;
950 missing = copy_to_user(buf, spidev->rx_buffer+spidev->spi->rd_pos, status);
951 if (missing == status) {
952 status = -EFAULT;
953@@ -266,48 +248,81 @@ spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
954 else {
955 status = status - missing;
956 spidev->spi->rd_pos += status;
957- spidev->spi->rd_pos = spidev->spi->rd_pos%bufsiz;
958 }
959- }else {
960
961- unsigned long first,rest;
962+ }else if(spidev->spi->rd_pos > spidev->spi->recv_pos) {
963
964- first = bufsiz - spidev->spi->rd_pos;
965- missing = copy_to_user(buf, spidev->rx_buffer+spidev->spi->rd_pos, first);
966- if (missing == first) {
967- status = -EFAULT;
968- } else {
969- status = status - missing;
970+ total = bufsiz - (spidev->spi->rd_pos - spidev->spi->recv_pos);
971+ status = (total > count) ? count : total;
972+
973+ if((spidev->spi->rd_pos + status) <= bufsiz) {
974+
975+ missing = copy_to_user(buf, spidev->rx_buffer+spidev->spi->rd_pos, status);
976+ if (missing == status) {
977+ status = -EFAULT;
978+ }
979+ else {
980+ status = status - missing;
981+ spidev->spi->rd_pos += status;
982+ spidev->spi->rd_pos = spidev->spi->rd_pos%bufsiz;
983+ }
984+ }else {
985+
986+ unsigned long first,rest;
987+
988+ first = bufsiz - spidev->spi->rd_pos;
989+ missing = copy_to_user(buf, spidev->rx_buffer+spidev->spi->rd_pos, first);
990+ if (missing == first) {
991+ status = -EFAULT;
992+ } else {
993+ status = status - missing;
994+ }
995+
996+ rest = status-first;
997+ missing = copy_to_user(buf+first, spidev->rx_buffer, rest);
998+ if (missing == rest) {
999+ status = -EFAULT;
1000+ } else {
1001+ status = status - missing;
1002+ }
1003+ spidev->spi->rd_pos = rest;
1004 }
1005+ }
1006+ #else
1007+ mutex_lock(&spidev->buf_lock);
1008+ if(spidev->rd_from_rx_buffer)
1009+ status = count;
1010+ else
1011+ status = spidev_sync_read(spidev, count);
1012+
1013+ if (status > 0) {
1014
1015- rest = status-first;
1016- missing = copy_to_user(buf+first, spidev->rx_buffer, rest);
1017- if (missing == rest) {
1018+ missing = copy_to_user(buf, spidev->rx_buffer, status);
1019+ if (missing == status)
1020 status = -EFAULT;
1021- } else {
1022+ else
1023 status = status - missing;
1024- }
1025- spidev->spi->rd_pos = rest;
1026 }
1027- }
1028- #else
1029- mutex_lock(&spidev->buf_lock);
1030- if(spidev->rd_from_rx_buffer)
1031- status = count;
1032- else
1033- status = spidev_sync_read(spidev, count);
1034-
1035- if (status > 0) {
1036+ #endif
1037+ mutex_unlock(&spidev->buf_lock);
1038+ }else {
1039+ mutex_lock(&spidev->buf_lock);
1040
1041- missing = copy_to_user(buf, spidev->rx_buffer, status);
1042- if (missing == status)
1043- status = -EFAULT;
1044+ if(spidev->rd_from_rx_buffer)
1045+ status = count;
1046 else
1047- status = status - missing;
1048- }
1049- #endif
1050- mutex_unlock(&spidev->buf_lock);
1051+ status = spidev_sync_read(spidev, count);
1052
1053+ if(status > 0) {
1054+ missing = copy_to_user(buf, spidev->rx_buffer, status);
1055+ if (missing == status)
1056+ status = -EFAULT;
1057+ else
1058+ status = status - missing;
1059+ }
1060+ mutex_unlock(&spidev->buf_lock);
1061+ }
1062+ /* yu.dong@20240715 [T106BUG-641] SPI packet loss problem, merged into ZXW patch end */
1063 return status;
1064 }
1065 /* yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme end*/
1066@@ -783,15 +798,19 @@ static int spidev_open(struct inode *inode, struct file *filp)
1067 }
1068 }
1069
1070- /* yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme start */
1071- #ifdef SPI_SLAVE_FOR_YK
1072- if(spidev->rx_buffer) {
1073- spidev->spi->rx_buf = spidev->rx_buffer;
1074- if(spidev->spi->controller->spi_slave_rd_start)
1075- spidev->spi->controller->spi_slave_rd_start(spidev->spi);
1076- }
1077- #endif
1078- /* yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme end */
1079+ /* yu.dong@20240715 [T106BUG-641] SPI packet loss problem, merged into ZXW patch start */
1080+ /* yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme start */
1081+ if(spidev->spi->master->slave) {
1082+ #ifdef SPI_SLAVE_FOR_YK
1083+ if(spidev->rx_buffer) {
1084+ spidev->spi->rx_buf = spidev->rx_buffer;
1085+ if(spidev->spi->controller->spi_slave_rd_start)
1086+ spidev->spi->controller->spi_slave_rd_start(spidev->spi);
1087+ }
1088+ #endif
1089+ }
1090+ /* yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme end */
1091+ /* yu.dong@20240715 [T106BUG-641] SPI packet loss problem, merged into ZXW patch end */
1092 spidev->users++;
1093 filp->private_data = spidev;
1094 stream_open(inode, filp);
1095@@ -838,14 +857,18 @@ static int spidev_release(struct inode *inode, struct file *filp)
1096 spi = spi_dev_get(spidev->spi);
1097 spin_unlock_irq(&spidev->spi_lock);
1098
1099- /* yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme start */
1100- #ifdef SPI_SLAVE_FOR_YK
1101- if(spidev->rx_buffer) {
1102- if(spi->controller->spi_slave_rd_stop)
1103- spi->controller->spi_slave_rd_stop(spi);
1104- }
1105- #endif
1106- /* yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme end */
1107+ /* yu.dong@20240715 [T106BUG-641] SPI packet loss problem, merged into ZXW patch start */
1108+ /* yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme start */
1109+ if(spidev->spi->master->slave) {
1110+ #ifdef SPI_SLAVE_FOR_YK
1111+ if(spidev->rx_buffer) {
1112+ if(spi->controller->spi_slave_rd_stop)
1113+ spi->controller->spi_slave_rd_stop(spi);
1114+ }
1115+ #endif
1116+ }
1117+ /* yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme end */
1118+ /* yu.dong@20240715 [T106BUG-641] SPI packet loss problem, merged into ZXW patch end*/
1119 if(spi && spi->master->slave)
1120 pm_relax(&spi->dev);
1121 kfree(spidev->tx_buffer);
1122@@ -2257,7 +2280,14 @@ static int spidev_probe(struct spi_device *spi)
1123 dev_info(&spi->dev,"trans_gap_num = 0x%x",val);
1124 }
1125
1126- // yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme.
1127+ if (device_property_read_u32(&spi->dev, "setup-immediately",&val)) {
1128+ spi->setup_immediately = 0;
1129+ dev_err(&spi->dev,"setup-immediately get failed");
1130+ }
1131+ else {
1132+ spi->setup_immediately = val;
1133+ dev_info(&spi->dev,"setup-immediately = 0x%x",val);
1134+ }
1135
1136 /* If we can allocate a minor number, hook up this device.
1137 * Reusing minors is fine so long as udev or mdev is working.
1138diff --git a/upstream/linux-5.10/drivers/tty/serial/zx29_uart.c b/upstream/linux-5.10/drivers/tty/serial/zx29_uart.c
1139index 60629b6..b29437a 100755
1140--- a/upstream/linux-5.10/drivers/tty/serial/zx29_uart.c
1141+++ b/upstream/linux-5.10/drivers/tty/serial/zx29_uart.c
1142@@ -124,6 +124,7 @@ struct zx29_dmatx_data {
1143 bool queued;
1144 atomic_t count;
1145 };
1146+#define UART_DEBUG_RECORDER_BYTE 0
1147 #define UART_DMA_CYCLE_RX_CONFIG_COUNT 5
1148 struct zx29_dma_cycle_data{
1149 int id;
1150@@ -140,8 +141,13 @@ struct zx29_dma_cycle_data{
1151 int cnt_th;
1152 struct zx29_sgbuf sgbuf[UART_DMA_CYCLE_RX_CONFIG_COUNT];
1153 dma_channel_def rxdef[UART_DMA_CYCLE_RX_CONFIG_COUNT];
1154+ bool enter_throttle;
1155+ bool from_unthrottle;
1156+ bool used;
1157+ unsigned int cnt_throttle;
1158+ unsigned int cnt_unthrottle;
1159 };
1160-struct zx29_dma_cycle_data uart_dma_cycle[5];
1161+struct zx29_dma_cycle_data uart_dma_cycle[6];
1162 #endif
1163
1164
1165@@ -279,27 +285,29 @@ typedef struct __UART_STATIC{
1166 unsigned int ris;
1167 }uart_static;
1168 #define STATIC_UART_ID 0
1169-uart_static g_uart_static[256] = {0};
1170-int g_uart_static_cnt = 0;
1171-void test_uart_static(int uart_id, char *buf, int cnt, int steps)
1172+#define UART_STATIC_COUNT 512
1173+#define UART_STATIC_NUM 4
1174+uart_static g_uart_static[UART_STATIC_NUM][UART_STATIC_COUNT] = {0};
1175+int g_uart_static_cnt[UART_STATIC_NUM] = {0};
1176+void test_uart_static(int uart_id, char *buf, unsigned int cnt, int steps)
1177 {
1178- if(uart_id != STATIC_UART_ID)
1179- return;
1180+ //if(uart_id != STATIC_UART_ID)
1181+ // return;
1182 if(buf){
1183 if(cnt >= 16){
1184- strncpy(g_uart_static[g_uart_static_cnt].head, buf, 16);
1185+ memcpy(g_uart_static[uart_id][g_uart_static_cnt[uart_id]].head, buf, 16);
1186 }else{
1187- memcpy(g_uart_static[g_uart_static_cnt].head, buf, cnt);
1188+ memcpy(g_uart_static[uart_id][g_uart_static_cnt[uart_id]].head, buf, cnt);
1189 }
1190 }
1191- g_uart_static[g_uart_static_cnt].cnt = cnt;
1192- g_uart_static[g_uart_static_cnt].s_time = local_clock();
1193- g_uart_static[g_uart_static_cnt].func_step = steps;
1194- g_uart_static[g_uart_static_cnt].fr = UART_GET_FR(&zx29_uart_ports[uart_id].port);
1195- g_uart_static[g_uart_static_cnt].ris = UART_GET_RIS(&zx29_uart_ports[uart_id].port);
1196+ g_uart_static[uart_id][g_uart_static_cnt[uart_id]].cnt = cnt;
1197+ g_uart_static[uart_id][g_uart_static_cnt[uart_id]].s_time = local_clock();
1198+ g_uart_static[uart_id][g_uart_static_cnt[uart_id]].func_step = steps;
1199+ g_uart_static[uart_id][g_uart_static_cnt[uart_id]].fr = UART_GET_FR(&zx29_uart_ports[uart_id].port);
1200+ g_uart_static[uart_id][g_uart_static_cnt[uart_id]].ris = UART_GET_RIS(&zx29_uart_ports[uart_id].port);
1201
1202- if(++g_uart_static_cnt >= 256)
1203- g_uart_static_cnt = 0;
1204+ if(++g_uart_static_cnt[uart_id] >= UART_STATIC_COUNT)
1205+ g_uart_static_cnt[uart_id] = 0;
1206 }
1207
1208
1209@@ -975,6 +983,19 @@ struct zx29_uart_port *zup = container_of(port, struct zx29_uart_port, port);
1210 }
1211
1212 #if CONFIG_SERIAL_ZX29_DMA
1213+#if UART_DEBUG_RECORDER_BYTE
1214+#define UART_DRIVER_DEBUG_COUNT (4*1024*1024)
1215+u32 cnt_uart_driver_debug = 0;
1216+u8 uart_driver_debug[UART_DRIVER_DEBUG_COUNT]={};
1217+void uart_debug(char *debug_buf, u32 count){
1218+ if(cnt_uart_driver_debug > (UART_DRIVER_DEBUG_COUNT-1)){
1219+ cnt_uart_driver_debug = 0;
1220+ }else{
1221+ memcpy(uart_driver_debug+cnt_uart_driver_debug,debug_buf,count);
1222+ cnt_uart_driver_debug = cnt_uart_driver_debug+count;
1223+ }
1224+}
1225+#endif
1226 int dma_complete_thread_use_dma_cyclic(void *ptr)
1227 {
1228 unsigned long flags;
1229@@ -986,8 +1007,14 @@ int dma_complete_thread_use_dma_cyclic(void *ptr)
1230 int uart_id = zup->port.line;
1231 while(down_interruptible(&zup->sema_cyclic) == 0)
1232 {
1233+ if(uart_dma_cycle[zup->port.line].cnt_callback > 0)
1234+ uart_id = zup->port.line;
1235+ else if(uart_dma_cycle[zup->port.line+3].cnt_callback > 0)
1236+ uart_id = zup->port.line + 3;
1237+
1238 if(zup->port_close || !uart_dma_cycle[uart_id].sgbuf[uart_dma_cycle[uart_id].flg_enter_th].dma_addr)
1239 break;
1240+
1241 spin_lock_irqsave(&zup->port.lock, flags);
1242 uart_dma_cycle[uart_id].cnt_th_total++;
1243 uart_dma_cycle[uart_id].cnt_th++;
1244@@ -1005,6 +1032,10 @@ int dma_complete_thread_use_dma_cyclic(void *ptr)
1245 spin_unlock_irqrestore(&zup->port.lock, flags);
1246 dma_count = tty_insert_flip_string(&zup->port.state->port,
1247 zup->sg2tty->buf, pending);
1248+ test_uart_static(zup->port.line, zup->sg2tty->buf, uart_dma_cycle[zup->port.line].used, 27);
1249+#if UART_DEBUG_RECORDER_BYTE
1250+ uart_debug(zup->sg2tty->buf, pending);
1251+#endif
1252 tty_flip_buffer_push(&zup->port.state->port);
1253 spin_lock_irqsave(&zup->port.lock, flags);
1254 dma_sync_sg_for_device(dev, &zup->sg2tty->sg, 1, DMA_FROM_DEVICE);
1255@@ -1591,6 +1622,10 @@ static int zx29_dma_rx_trigger_dma_use_dma_cyclic(struct zx29_uart_port *zup)
1256 printk("[%s][%d]\n",__func__,__LINE__);
1257 return -EIO;
1258 }
1259+
1260+ if(uart_dma_cycle[zup->port.line].used)
1261+ uart_id = uart_id + 3;
1262+
1263 dmaengine_slave_config(rxchan, (struct dma_slave_config*)&uart_dma_cycle[uart_id].rxdef);
1264 desc = rxchan->device->device_prep_dma_cyclic(rxchan,NULL,(ZX29_DMA_BUFFER_SIZE *5) , ZX29_DMA_BUFFER_SIZE,0,0);
1265 if (!desc) {
1266@@ -1607,6 +1642,14 @@ static int zx29_dma_rx_trigger_dma_use_dma_cyclic(struct zx29_uart_port *zup)
1267 zup->dmacr |= UART_RXDMAE;
1268 UART_PUT_DMACR(&zup->port, zup->dmacr);
1269 uart_dma_cycle[uart_id].flg_enter_th = 0;
1270+ if(uart_dma_cycle[zup->port.line].used){
1271+ uart_dma_cycle[zup->port.line].used = false;
1272+ uart_dma_cycle[zup->port.line+3].used = true;
1273+ }else{
1274+ uart_dma_cycle[zup->port.line].used = true;
1275+ uart_dma_cycle[zup->port.line+3].used = false;
1276+ }
1277+
1278 zup->dmarx.running = true;
1279 zup->dmarx.used = true;
1280 zup->imr &= ~(UART_RXIM | UART_RTIM);
1281@@ -1692,6 +1735,8 @@ void uart_dma_rx_callback_use_dma_cyclic(void *data)
1282 unsigned int ris_status;
1283 int uart_id = zup->port.line;
1284 spin_lock_irqsave(&zup->port.lock, flags);
1285+ if(!uart_dma_cycle[zup->port.line].used)
1286+ uart_id = uart_id + 3;
1287 uart_dma_cycle[uart_id].cnt_callback_total++;
1288 uart_dma_cycle[uart_id].cnt_callback++;
1289 ris_status = UART_GET_RIS(&zup->port);
1290@@ -2050,6 +2095,9 @@ static void zx29_uart_deal_dma_fifo_rx_chars_cyclic(struct zx29_uart_port *zup,
1291 dma_count = tty_insert_flip_string(&zup->port.state->port,
1292 sgbuf->buf, pending);
1293 test_uart_static(zup->port.line, sgbuf->buf, pending, 6);
1294+#if UART_DEBUG_RECORDER_BYTE
1295+ uart_debug(sgbuf->buf, pending);
1296+#endif
1297 spin_lock_irqsave(&zup->port.lock, *flags);
1298 dma_sync_sg_for_device(dev, &sgbuf->sg, 1, DMA_FROM_DEVICE);
1299 zup->port.icount.rx += dma_count;
1300@@ -2061,6 +2109,10 @@ static void zx29_uart_deal_dma_fifo_rx_chars_cyclic(struct zx29_uart_port *zup,
1301 spin_unlock_irqrestore(&zup->port.lock, *flags);
1302 fifo_count = tty_insert_flip_string(&zup->port.state->port,
1303 fifo_buf, fifo_len);
1304+ test_uart_static(zup->port.line, fifo_buf, fifo_len, 50);
1305+#if UART_DEBUG_RECORDER_BYTE
1306+ uart_debug(fifo_buf, fifo_len);
1307+#endif
1308 fifo_buf[0] = '\0';
1309 fifo_buf[1] = '\0';
1310 fifo_buf[2] = '\0';
1311@@ -2070,6 +2122,7 @@ static void zx29_uart_deal_dma_fifo_rx_chars_cyclic(struct zx29_uart_port *zup,
1312 if(((pending) && (pending != 4096)) || (fifo_len > 0)){
1313 spin_unlock(&zup->port.lock);
1314 tty_flip_buffer_push(&zup->port.state->port);
1315+ test_uart_static(zup->port.line, NULL, (fifo_count+dma_count), 51);
1316 spin_lock(&zup->port.lock);
1317 }
1318 }
1319@@ -2647,40 +2700,53 @@ enum hrtimer_restart zx29_uart_rx_dma_hrtimeout_cyclic(struct hrtimer *t)
1320 unsigned long flags;
1321 struct zx29_sgbuf *sgbuf = NULL;
1322 int uart_id = zup->port.line;
1323+
1324+
1325 if(!zx29_dma_rx_running(zup))
1326 return HRTIMER_NORESTART;
1327- if(uart_dma_cycle[uart_id].cnt_callback > 0){
1328+ raw_spin_lock_irqsave(&zup->port.lock, flags);
1329+
1330+ if((uart_dma_cycle[zup->port.line].cnt_callback > 0) || (uart_dma_cycle[zup->port.line+3].cnt_callback > 0)){
1331+ test_uart_static(zup->port.line, NULL, uart_dma_cycle[zup->port.line].used, 46);
1332+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
1333 return HRTIMER_NORESTART;
1334 }
1335
1336- spin_lock_irqsave(&zup->port.lock, flags);
1337+ if(!uart_dma_cycle[zup->port.line].used)
1338+ uart_id = uart_id + 3;
1339+
1340 sgbuf = &uart_dma_cycle[uart_id].sgbuf[uart_dma_cycle[uart_id].flg_enter_th];
1341 if(zup->port_close || (sgbuf == NULL)){
1342- spin_unlock_irqrestore(&zup->port.lock, flags);
1343- return HRTIMER_RESTART;
1344+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
1345+ return HRTIMER_NORESTART;
1346 }
1347 if(zup->sema_cyclic.count > 0){
1348 printk("uart has th not deal.\n");
1349- spin_unlock_irqrestore(&zup->port.lock, flags);
1350+ //test_uart_static(zup->port.line, NULL, uart_id, 11);
1351+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
1352+ hrtimer_forward_now(&zup->rx_dma_hrtimer, g_hr_interval);
1353 return HRTIMER_RESTART;
1354 }
1355+
1356 if((zup->sg2tty)){//dma not complete now, later check again
1357 printk("dmath_cyclic not end.\n");
1358- spin_unlock_irqrestore(&zup->port.lock, flags);
1359+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
1360 test_uart_static(zup->port.line, NULL, 0, 14);
1361 hrtimer_forward_now(&zup->rx_dma_hrtimer, g_hr_interval);
1362 return HRTIMER_RESTART;
1363 }
1364- if(zup->enter_suspend){
1365- spin_unlock_irqrestore(&zup->port.lock, flags);
1366+ if(zup->enter_suspend || uart_dma_cycle[uart_id].enter_throttle){
1367+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
1368 test_uart_static(zup->port.line, NULL, 0, 15);
1369 hrtimer_forward_now(&zup->rx_dma_hrtimer, g_hr_interval);
1370 return HRTIMER_RESTART;
1371 }
1372 dma_peripheral_id rx_id = uart_get_rx_dma_peripheral_id(zup);
1373 pending = sgbuf->sg.length - zx29_dma_get_transfer_num(rx_id);
1374- if(((pending == zup->pre_pending) && pending) || uart_dma_cycle[uart_id].from_resume){
1375+ if(((pending == zup->pre_pending) && pending) || uart_dma_cycle[uart_id].from_resume
1376+ || uart_dma_cycle[uart_id].from_unthrottle){
1377 uart_dma_cycle[uart_id].from_resume = 0;
1378+ uart_dma_cycle[uart_id].from_unthrottle = false;
1379 #if 0
1380 if(uart_dma_cycle[uart_id].flg_enter_th == 0)
1381 uart_dma_cycle[uart_id].flg_enter_to = 4;
1382@@ -2723,24 +2789,28 @@ enum hrtimer_restart zx29_uart_rx_dma_hrtimeout_cyclic(struct hrtimer *t)
1383 zup->dmacr &= ~UART_RXDMAE;
1384 UART_PUT_DMACR(&zup->port,zup->dmacr);
1385 dmaengine_terminate_all(rxchan);
1386- test_uart_static(zup->port.line, NULL, 0, 60);
1387 zup->dmarx.running = false;
1388 zup->dmarx.used = false;
1389+ tmp_len = sgbuf->sg.length - zx29_dma_get_transfer_num(rx_id);
1390+ if(tmp_len != pending){
1391+ pending = tmp_len;
1392+ //test_uart_static(zup->port.line, NULL, tmp_len, 48);
1393+ }
1394 wmb();
1395 int i = 0;
1396 for(i= 0;i < 3;i++){
1397 fr = UART_GET_FR(&zup->port);
1398 if((fr & UART_FR_RXFE) == 0){
1399- g_fifo_residue_buf[uart_id][i] = UART_GET_CHAR(&zup->port) | UART_DUMMY_DR_RX;
1400- g_fifo_residue_all[uart_id][g_fifo_cnt[uart_id]++] = g_fifo_residue_buf[uart_id][i];
1401- if(g_fifo_cnt[uart_id] >= 20) g_fifo_cnt[uart_id] = 0;
1402+ g_fifo_residue_buf[zup->port.line][i] = UART_GET_CHAR(&zup->port) | UART_DUMMY_DR_RX;
1403+ g_fifo_residue_all[zup->port.line][g_fifo_cnt[zup->port.line]++] = g_fifo_residue_buf[zup->port.line][i];
1404+ if(g_fifo_cnt[zup->port.line] >= 20) g_fifo_cnt[zup->port.line] = 0;
1405 }
1406 else
1407 break;
1408 }
1409 if(i){
1410- g_fifo_residue_all[uart_id][g_fifo_cnt[uart_id]++]=i;
1411- if(g_fifo_cnt[uart_id] >= 20) g_fifo_cnt[uart_id] = 0;
1412+ g_fifo_residue_all[zup->port.line][g_fifo_cnt[zup->port.line]++]=i;
1413+ if(g_fifo_cnt[zup->port.line] >= 20) g_fifo_cnt[zup->port.line] = 0;
1414 }
1415 if (zx29_dma_rx_trigger_dma_use_dma_cyclic(zup)) {
1416 printk("rx_dma_chars RXDMA start fail\n");
1417@@ -2748,20 +2818,21 @@ enum hrtimer_restart zx29_uart_rx_dma_hrtimeout_cyclic(struct hrtimer *t)
1418 UART_PUT_IMSC(&zup->port,zup->imr);
1419 }else{
1420 hrtimer_forward_now(&zup->rx_dma_hrtimer, g_hr_interval);
1421+ test_uart_static(zup->port.line, NULL, (pending+i), 49);
1422 zup->pre_pending = 0;
1423 zup->dmarx.used = true;
1424 zup->work_state = true;
1425 }
1426 if((pending && (pending != 4096)) || (i > 0)){
1427- zx29_uart_deal_dma_fifo_rx_chars_cyclic(zup, pending, sgbuf, &flags, g_fifo_residue_buf[uart_id],i);
1428+ zx29_uart_deal_dma_fifo_rx_chars_cyclic(zup, pending, sgbuf, &flags, g_fifo_residue_buf[zup->port.line],i);
1429 }
1430 uart_dma_cycle[uart_id].cnt_th = 0;
1431 uart_dma_cycle[uart_id].cnt_callback=0;
1432 deal_end:
1433- spin_unlock_irqrestore(&zup->port.lock, flags);
1434+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
1435 return HRTIMER_RESTART;
1436 }else{
1437- spin_unlock_irqrestore(&zup->port.lock, flags);
1438+ raw_spin_unlock_irqrestore(&zup->port.lock, flags);
1439 zup->pre_pending = pending;
1440 hrtimer_forward_now(&zup->rx_dma_hrtimer, g_hr_interval);
1441 test_uart_static(zup->port.line, NULL, zup->pre_pending, 22);
1442@@ -3005,14 +3076,34 @@ static int uart_dma_cycle_init(struct zx29_uart_port *zup)
1443 }
1444 return -1;
1445 }
1446+
1447+ ret = zx29_sgbuf_init(zup->dmarx.chan, &uart_dma_cycle[uart_id+3].sgbuf[i],DMA_FROM_DEVICE);
1448+ if(ret){
1449+ printk( "init uart_dma_cycle sgbuf failed,uart: %d,ret:%d\n", (zup->port.line+3), ret);
1450+ for(j=0;j<i;j++){
1451+ zx29_sgbuf_free(zup->dmarx.chan, &uart_dma_cycle[uart_id+3].sgbuf[j],DMA_FROM_DEVICE);
1452+ }
1453+ return -1;
1454+ }
1455 }
1456 for(i=0;i<UART_DMA_CYCLE_RX_CONFIG_COUNT;i++){
1457- if(zup->port.line == UART0)
1458+ if(zup->port.line == UART0){
1459 uart_dma_cycle[uart_id].rxdef[i].src_addr = ZX_UART0_BASE+zx29_UART_DR;
1460- else if(zup->port.line == UART1)
1461+ uart_dma_cycle[uart_id].used = false;
1462+ uart_dma_cycle[uart_id+3].rxdef[i].src_addr = ZX_UART0_BASE+zx29_UART_DR;
1463+ uart_dma_cycle[uart_id+3].used = false;
1464+ }
1465+ else if(zup->port.line == UART1){
1466 uart_dma_cycle[uart_id].rxdef[i].src_addr = ZX_UART1_BASE+zx29_UART_DR;
1467- else{
1468+ uart_dma_cycle[uart_id].used = false;
1469+ uart_dma_cycle[uart_id+3].rxdef[i].src_addr = ZX_UART1_BASE+zx29_UART_DR;
1470+ uart_dma_cycle[uart_id+3].used = false;
1471+ }
1472+ else if(zup->port.line == UART2){
1473 uart_dma_cycle[uart_id].rxdef[i].src_addr = ZX_UART2_BASE+zx29_UART_DR;
1474+ uart_dma_cycle[uart_id].used = false;
1475+ uart_dma_cycle[uart_id+3].rxdef[i].src_addr = ZX_UART2_BASE+zx29_UART_DR;
1476+ uart_dma_cycle[uart_id+3].used = false;
1477 }
1478 uart_dma_cycle[uart_id].rxdef[i].dest_addr = (unsigned int)(uart_dma_cycle[uart_id].sgbuf[i].dma_addr);
1479 uart_dma_cycle[uart_id].rxdef[i].dma_control.tran_mode = TRAN_PERI_TO_MEM;
1480@@ -3022,7 +3113,18 @@ static int uart_dma_cycle_init(struct zx29_uart_port *zup)
1481 uart_dma_cycle[uart_id].rxdef[i].dma_control.dest_burst_size = DMA_BURST_SIZE_8BIT;
1482 uart_dma_cycle[uart_id].rxdef[i].dma_control.dest_burst_len = DMA_BURST_LEN_4;
1483 uart_dma_cycle[uart_id].rxdef[i].dma_control.irq_mode = DMA_ALL_IRQ_ENABLE;
1484- uart_dma_cycle[uart_id].rxdef[i].link_addr = 1;
1485+ uart_dma_cycle[uart_id].rxdef[i].link_addr = 1;
1486+
1487+ uart_dma_cycle[uart_id+3].rxdef[i].dest_addr = (unsigned int)(uart_dma_cycle[uart_id+3].sgbuf[i].dma_addr);
1488+ uart_dma_cycle[uart_id+3].rxdef[i].dma_control.tran_mode = TRAN_PERI_TO_MEM;
1489+ uart_dma_cycle[uart_id+3].rxdef[i].dma_control.src_burst_len = DMA_BURST_LEN_4;
1490+ uart_dma_cycle[uart_id+3].rxdef[i].count = ZX29_DMA_BUFFER_SIZE;
1491+ uart_dma_cycle[uart_id+3].rxdef[i].dma_control.src_burst_size = DMA_BURST_SIZE_8BIT;
1492+ uart_dma_cycle[uart_id+3].rxdef[i].dma_control.dest_burst_size = DMA_BURST_SIZE_8BIT;
1493+ uart_dma_cycle[uart_id+3].rxdef[i].dma_control.dest_burst_len = DMA_BURST_LEN_4;
1494+ uart_dma_cycle[uart_id+3].rxdef[i].dma_control.irq_mode = DMA_ALL_IRQ_ENABLE;
1495+ uart_dma_cycle[uart_id+3].rxdef[i].link_addr = 1;
1496+
1497 }
1498 return 0;
1499 }
1500@@ -3032,8 +3134,10 @@ static void uart_dma_cycle_deinit(struct zx29_uart_port *zup)
1501 int uart_id = zup->port.line;
1502 for(i=0;i<UART_DMA_CYCLE_RX_CONFIG_COUNT;i++){
1503 zx29_sgbuf_free(zup->dmarx.chan, &uart_dma_cycle[uart_id].sgbuf[i],DMA_FROM_DEVICE);
1504+ zx29_sgbuf_free(zup->dmarx.chan, &uart_dma_cycle[uart_id+3].sgbuf[i],DMA_FROM_DEVICE);
1505 }
1506 memset(uart_dma_cycle[uart_id].rxdef, 0, sizeof(uart_dma_cycle[uart_id].rxdef));
1507+ memset(uart_dma_cycle[uart_id+3].rxdef, 0, sizeof(uart_dma_cycle[uart_id+3].rxdef));
1508 }
1509 static void uart_dma_startup(struct zx29_uart_port *zup)
1510 {
1511@@ -3461,6 +3565,9 @@ static void zx29_uart_shutdown(struct uart_port *port)
1512 //struct zx29_uart_platdata *pdata = pdev->dev.platform_data;
1513 #if CONFIG_SERIAL_ZX29_DMA
1514 zup->port_close = true;
1515+ if(zup->uart_power_mode)
1516+ up(&zup->sema_cyclic);
1517+ else
1518 up(&zup->sema);
1519 #endif
1520 int ret;
1521@@ -3762,11 +3869,25 @@ static void zx29_put_poll_char(struct uart_port *port, unsigned char ch)
1522 UART_PUT_CHAR(port, ch);
1523 }
1524 #endif /* CONFIG_CONSOLE_POLL */
1525+extern int tty_buffer_space_avail(struct tty_port *port);
1526 static void zx29_uart_throttle_rx(struct uart_port *port)
1527 {
1528+ test_uart_static(port->line, NULL, 0, 80);
1529 unsigned long flags;
1530+ int uart_id = port->line;
1531+
1532 struct zx29_uart_port *zup = container_of(port, struct zx29_uart_port, port);
1533 dma_peripheral_id rx_id = uart_get_rx_dma_peripheral_id(zup);
1534+ spin_lock_irqsave(&port->lock, flags);
1535+ if(!uart_dma_cycle[port->line].used)
1536+ uart_id = uart_id + 3;
1537+ if(!tty_buffer_space_avail(&port->state->port)){
1538+ zx29_dma_stop(DMA_CH_UART0_RX);
1539+ uart_dma_cycle[uart_id].enter_throttle = true;
1540+ uart_dma_cycle[uart_id].cnt_throttle++;
1541+ }
1542+ spin_unlock_irqrestore(&port->lock, flags);
1543+ #if 0
1544 while(zx29_dma_get_transfer_num(rx_id) != 4096)
1545 msleep(1);
1546 spin_lock_irqsave(&port->lock, flags);
1547@@ -3775,24 +3896,35 @@ static void zx29_uart_throttle_rx(struct uart_port *port)
1548 zx29_dma_stop(rx_id);
1549 zup->dmarx.running = false;
1550 zup->dmarx.used = false;
1551+ uart_dma_cycle[port->line].enter_throttle = true;
1552 spin_unlock_irqrestore(&port->lock, flags);
1553+ #endif
1554 }
1555 static void zx29_uart_unthrottle_rx(struct uart_port *port)
1556 {
1557+ test_uart_static(port->line, NULL, 0, 81);
1558 struct zx29_uart_port *zup = container_of(port, struct zx29_uart_port, port);
1559 unsigned long flags;
1560+ int uart_id = port->line;
1561 spin_lock_irqsave(&port->lock, flags);
1562- if (zx29_dma_rx_trigger_dma(zup)) {
1563+ if(!uart_dma_cycle[port->line].used)
1564+ uart_id = uart_id + 3;
1565+ uart_dma_cycle[uart_id].enter_throttle = false;
1566+ uart_dma_cycle[uart_id].from_unthrottle = true;
1567+ uart_dma_cycle[uart_id].cnt_unthrottle++;
1568+ #if 0
1569+ if (zx29_dma_rx_trigger_dma_use_dma_cyclic(zup)) {
1570 printk("rx_dma_chars RXDMA start fail\n");
1571 zup->imr |= (UART_RTIM|UART_RXIM);
1572 UART_PUT_IMSC(&zup->port,zup->imr);
1573 }else{
1574- uart_mod_timer(zup, &flags);
1575+ hrtimer_forward_now(&zup->rx_dma_hrtimer, g_hr_interval);
1576 zup->pre_pending = 0;
1577 zup->dmarx.used = true;
1578 zup->work_state = true;
1579 UART_PUT_ICR(&zup->port,(UART_RTIS|UART_RXIS));
1580 }
1581+ #endif
1582 spin_unlock_irqrestore(&port->lock, flags);
1583 }
1584
1585@@ -3839,9 +3971,7 @@ static int zx29_init_ports(struct zx29_uart_port *zx29_port,
1586 unsigned int offset=(unsigned int)(pdev->id);
1587 struct device_node *np = pdev->dev.of_node;
1588 unsigned int baud, ibrd, fbrd;
1589- /*cz.li add for uart1 2 change baudrate to 4M on 2023/8/15 start*/
1590- unsigned int max_bus_clk;
1591- /*cz.li add for uart1 2 change baudrate to 4M on 2023/8/15 end*/
1592+
1593 struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1594 //struct resource *irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1595
1596@@ -3865,12 +3995,6 @@ static int zx29_init_ports(struct zx29_uart_port *zx29_port,
1597 printk("failed to get zx29_port->wclk: %d\n", ret);
1598 return ret;
1599 }
1600- /*cz.li add for uart1 2 change baudrate to 4M on 2023/8/15 start*/
1601- if(0 == pdev->id || 2 == pdev->id){
1602- device_property_read_u32(&pdev->dev, "uart-max-bus-freq", &max_bus_clk);
1603- clk_set_rate(zx29_port->wclk, max_bus_clk);
1604- }
1605- /*cz.li add for uart1 2 change baudrate to 4M on 2023/8/15 end*/
1606 if(offset == 0){
1607 clk_set_rate(zx29_port->wclk, 104 * 1000000);
1608 }
1609@@ -3900,11 +4024,6 @@ static int zx29_init_ports(struct zx29_uart_port *zx29_port,
1610 //here is temple def
1611 if(port->uartclk == 0){
1612 printk("---zx29_init_ports, uartclk hard set to 26M\n");
1613- /*cz.li add for uart1 2 change baudrate to 4M on 2023/8/15 start*/
1614- if(0 == pdev->id || 2 == pdev->id)
1615- port->uartclk = 104000000;
1616- else
1617- /*cz.li add for uart1 2 change baudrate to 4M on 2023/8/15 end*/
1618 port->uartclk = 26000000;
1619 }
1620 printk("---zx29_init_ports, line:%d, irq:%d, membase:%08x, uartclk:%d\n", port->line, port->irq, port->membase, port->uartclk);
1621@@ -4196,6 +4315,8 @@ static int zx29_uart_resume(struct device *dev)
1622 if (!zup)
1623 return -EINVAL;
1624 int uart_id = zup->port.line;
1625+ if(!uart_dma_cycle[zup->port.line].used)
1626+ uart_id = uart_id + 3;
1627 if(zup->port.line == UART1)
1628 return 0;
1629 #if 1
1630diff --git a/upstream/linux-5.10/include/linux/spi/spi.h b/upstream/linux-5.10/include/linux/spi/spi.h
1631index 569ba92..6135a82 100755
1632--- a/upstream/linux-5.10/include/linux/spi/spi.h
1633+++ b/upstream/linux-5.10/include/linux/spi/spi.h
1634@@ -210,7 +210,8 @@ struct spi_device {
1635 u8 trans_gaped;
1636 u8 trans_gap_num;
1637 /* yu.dong@20240617 [T106BUG-641] SPI packet loss problem, add kernel buffer scheme start */
1638- u32 rd_pos;
1639+ u8 setup_immediately;
1640+ u32 rd_pos;
1641 u32 recv_pos;
1642 u8 * rx_buf;
1643 u8 * cyc_buf;
1644diff --git a/upstream/linux-5.10/sound/soc/codecs/es8311.c b/upstream/linux-5.10/sound/soc/codecs/es8311.c
1645index 0e9dab6..fef445f 100755
1646--- a/upstream/linux-5.10/sound/soc/codecs/es8311.c
1647+++ b/upstream/linux-5.10/sound/soc/codecs/es8311.c
1648@@ -894,6 +894,12 @@ static int es8311_set_bias_level(struct snd_soc_component *component,
1649 snd_soc_component_write(component, ES8311_ADC_REG1B, 0x0A);
1650 snd_soc_component_write(component, ES8311_ADC_REG1C, 0x6A);
1651 snd_soc_component_write(component, ES8311_DAC_REG37, 0x48);
1652+/* yu.dong@20240718[ZXW-277]Optimizing Recording in CODEC 8311 TDM Mode start*/
1653+#if defined(CONFIG_USE_TOP_TDM)
1654+ snd_soc_component_write(component, ES8311_CLK_MANAGER_REG01, 0x9f);
1655+ snd_soc_component_write(component, ES8311_ADC_REG15, 0x00);
1656+#endif
1657+/* yu.dong@20240718[ZXW-277]Optimizing Recording in CODEC 8311 TDM Mode end*/
1658 //snd_soc_component_write(component, ES8311_ADC_REG17, 0xBF);
1659 //snd_soc_component_write(component, ES8311_DAC_REG32, 0xBF);
1660 break;
1661@@ -1425,13 +1431,10 @@ static int component_open(struct snd_soc_component *component,
1662 }
1663 }
1664 /* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
1665-#ifdef CONFIG_USE_TOP_TDM
1666-#else
1667 ret = zx29_i2s_config_default_pin();
1668 if(ret < 0) {
1669 pr_err("%s select state failure %d !! \n", __func__, ret);
1670 }
1671-#endif
1672 es8311_reinit(component, info);
1673 /* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
1674 pr_info("%s:clk en end!\n",__func__);
1675@@ -1457,13 +1460,10 @@ static int component_close(struct snd_soc_component *component,
1676 }
1677 pr_info("%s:clk dis end!\n",__func__);
1678 /* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
1679-#ifdef CONFIG_USE_TOP_TDM
1680-#else
1681 ret = zx29_i2s_config_sleep_pin();
1682 if(ret < 0) {
1683 pr_err("%s select state failure %d !! \n", __func__, ret);
1684 }
1685-#endif
1686 /* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
1687 return ret;
1688 }
1689diff --git a/upstream/linux-5.10/sound/soc/sanechips/zx29_es83xx.c b/upstream/linux-5.10/sound/soc/sanechips/zx29_es83xx.c
1690index 3c755a6..1204542 100755
1691--- a/upstream/linux-5.10/sound/soc/sanechips/zx29_es83xx.c
1692+++ b/upstream/linux-5.10/sound/soc/sanechips/zx29_es83xx.c
1693@@ -1119,14 +1119,8 @@ static void zx29_i2s_top_pin_cfg(struct platform_device *pdev)
1694 info->s = s;
1695 info->s_sleep = s_sleep;
1696 }
1697-/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes start */
1698-#ifdef CONFIG_USE_TOP_TDM
1699- ret = pinctrl_select_state(p, s);
1700-#else
1701 //yu.dong@20240416[ZXW-268]Added codec re-initialization for power down and I2S default configuration adjustment start
1702 ret = pinctrl_select_state(p, s_sleep);
1703-#endif
1704-/* yu.dong@20240508[ZXW-277]Modified Platform CODEC ES8311 Compatible with I2S and TDM Modes end */
1705 if (ret < 0) {
1706 devm_pinctrl_put(p);
1707 dev_err(dev, " select state failure!!\n");