Commit Graph

1958 Commits

Author SHA1 Message Date
ligd
fe6aa4a874 sim: add loop thread to handle dev loops
For some dev loops will call sem_wait/sem_trywait

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-02 20:29:52 +09:00
Xiang Xiao
eb1cc02d09 sched/group: Move files_initlist/lib_stream_initialize to group_alloc
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-02 20:29:52 +09:00
Xiang Xiao
4a16cf71f9 Fix -Werror=nonnull-compare and -Werror=format-truncation=
Error: module/mod_insmod.c:203:3: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation]
  203 |   strncpy(modp->modname, modname, MODLIB_NAMEMAX);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

wqueue/kwork_thread.c: In function 'work_start_lowpri':
Error: wqueue/kwork_thread.c:212:22: error: '%lx' directive output may be truncated writing between 1 and 16 bytes into a region of size 14 [-Werror=format-truncation=]
  212 |   snprintf(args, 16, "0x%" PRIxPTR, (uintptr_t)wqueue);

local/local_sockif.c: In function 'local_getsockname':
Error: local/local_sockif.c:392:11: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
  392 |           strncpy(unaddr->sun_path, conn->lc_path, namelen);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

chip/esp32_wifi_utils.c: In function 'esp_wifi_scan_event_parse':
Error: chip/esp32_wifi_utils.c:373:37: error: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to dereference it? [-Werror=sizeof-pointer-memaccess]
   memset(ap_list_buffer, 0x0, sizeof(ap_list_buffer));
                                     ^

stdio/lib_fputs.c: In function 'fputs':
Error: stdio/lib_fputs.c:99:9: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s == NULL || stream == NULL)
         ^
Error: stdio/lib_fputs.c:99:27: error: nonnull argument 'stream' compared to NULL [-Werror=nonnull-compare]
   if (s == NULL || stream == NULL)
                           ^

stdio/lib_vfprintf.c: In function 'vfprintf':
Error: stdio/lib_vfprintf.c:40:6: error: nonnull argument 'stream' compared to NULL [-Werror=nonnull-compare]
   if (stream)
      ^

string/lib_strdup.c: In function 'strdup':
Error: string/lib_strdup.c:39:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s)
      ^

string/lib_strndup.c: In function 'strndup':
Error: string/lib_strndup.c:56:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s)
      ^

string/lib_strpbrk.c: In function 'strpbrk':
Error: string/lib_strpbrk.c:39:7: error: nonnull argument 'str' compared to NULL [-Werror=nonnull-compare]
   if (!str || !charset)
       ^~~~
Error: string/lib_strpbrk.c:39:15: error: nonnull argument 'charset' compared to NULL [-Werror=nonnull-compare]
   if (!str || !charset)
               ^~~~~~~~

string/lib_strrchr.c: In function 'strrchr':
Error: string/lib_strrchr.c:40:6: error: nonnull argument 's' compared to NULL [-Werror=nonnull-compare]
   if (s)
      ^

Error: time/lib_asctimer.c:73:50: error: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size between 0 and 12 [-Werror=format-truncation=]
   snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
                                                  ^~
time/lib_asctimer.c:73:21: note: directive argument in the range [-2147481748, 2147483647]
   snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
time/lib_asctimer.c:73:3: note: 'snprintf' output between 17 and 68 bytes into a destination of size 26
   snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            g_wday_name[tp->tm_wday], g_mon_name[tp->tm_mon],
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            tp->tm_mday, tp->tm_hour, tp->tm_min, tp->tm_sec,
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            1900 + tp->tm_year);
            ~~~~~~~~~~~~~~~~~~~

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-02 15:55:38 +08:00
Xiang Xiao
ddde41018a Revert "sched: Don't duplicate caller file handler when creating kernel thread"
since the temporary kernel spawn proxy need duplicate file handler
from caller, please reference the follow source code for more info:
sched/task/task_posixspawn.c
sched/task/task_spawn.c

This reverts commit 5c5f1dec08.
2022-03-01 12:26:49 +01:00
Xiang Xiao
da954956e7 Simplify DEFAULT_SMALL usage in Kconfig
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-01 03:15:01 +08:00
Masayuki Ishikawa
dcafd95971 sched: group: Fix dataabort when exiting task or pthread if ARCH_ADDRENV=y
Summary:
- I noticed that exiting task or pthread causes dataabort if ARCH_ADDRENV=y
- This commit fixes this issue by switching the addrenv correctly

Impact:
- CONFIG_ARCH_ADDRENV=y only

Testing:
- Tested with sabre-6quad:netknsh (not merged yet)

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
2022-02-28 16:10:10 +08:00
Petro Karashchenko
fa761a8a6a sched/timer: remove unused variable
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-02-27 12:27:35 -05:00
Huang Qi
e516c6247e sched: Implement task local storage
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-02-23 22:05:02 +08:00
zhanghu6
ebf751b16e xsched/note:add switch and dump instrumentation
Signed-off-by: zhanghu6 <zhanghu6@xiaomi.com>
2022-02-23 21:56:58 +08:00
ligd
61a0453e6e os init_state: add new state OSINIT_IDLELOOP
This is for distinguish we are in init idle or idle loop.
Use for assertion for sem_trywait & sem_wait

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-02-23 22:05:37 +09:00
Xiang Xiao
f1ed349dd9 sched/clock: Remove CLOCK_MONOTONIC option from Kconfig
here is the reason:
1.clock_systime_timespec(core function) always exist regardless the setting
2.CLOCK_MONOTONIC is a foundamental clock type required by many places

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-23 01:21:26 +08:00
Masayuki Ishikawa
fccdcf7011 Revert "os init_state: add new state OSINIT_IDLELOOP"
This reverts commit 051bb32010.
2022-02-22 10:56:14 +01:00
ligd
051bb32010 os init_state: add new state OSINIT_IDLELOOP
This is for distinguish we are in init idle or idle loop.
Use for assertion for sem_trywait & sem_wait

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-02-22 07:58:55 +01:00
Petro Karashchenko
9b02a91c72 libc/sched/task_setcanceltype: fix function name in comment
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-02-21 20:32:49 +08:00
Huang Qi
f452dd7ab4 sched: Mark pthread as non-cancelable to avoid additional calls to pthread_exit()
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-02-20 15:36:07 +01:00
Oki Minabe
682984e9ba add the kernel stack allocation in pthread create. 2022-02-19 19:32:21 +08:00
ligd
756c9fb60d semaphore: fix corner case sem_waitirq assert crash
[   11.041077] [25] [ EMERG] [ap] up_assert: Assertion failed at file:semaphore/sem_waitirq.c line: 84 task: thermal service
[   11.041407] [25] [ EMERG] [ap] backtrace:
[   11.041517] [25] [ EMERG] [ap] [25] [<0x2c687c9e>] up_backtrace+0xa/0x164
[   11.041627] [25] [ EMERG] [ap] [25] [<0x2c676e6c>] sched_dumpstack+0x1c/0x5c
[   11.041682] [25] [ EMERG] [ap] [25] [<0x2c68763a>] up_assert+0x42/0x24c
[   11.041792] [25] [ EMERG] [ap] [25] [<0x2c67355e>] _assert+0x2/0xc
[   11.041847] [25] [ EMERG] [ap] [25] [<0x2c65d536>] nxsem_wait_irq+0x3e/0x134
[   11.042288] [25] [ EMERG] [ap] [25] [<0x2c65d378>] nxsem_timeout+0x24/0x34
[   11.043169] [25] [ EMERG] [ap] [25] [<0x2c65f74c>] wd_timer+0xc0/0x104
[   11.043995] [25] [ EMERG] [ap] [25] [<0x2c65c930>] nxsched_alarm_expiration+0x4c/0xdc
[   11.044986] [25] [ EMERG] [ap] [25] [<0x2c670872>] oneshot_callback+0x16/0x24
[   11.045867] [25] [ EMERG] [ap] [25] [<0x2c6822b8>] bes_oneshot_irq_handler+0x18/0x28
[   11.046858] [25] [ EMERG] [ap] [25] [<0x57e5c>] up_irq_handler+0x4/0xc
[   11.047684] [25] [ EMERG] [ap] [25] [<0x2c65a20e>] irq_dispatch+0x5a/0xb8
[   11.048510] [25] [ EMERG] [ap] [25] [<0x2c6864d8>] arm_doirq+0x28/0x3c
[   11.049336] [25] [ EMERG] [ap] [25] [<0x2c681732>] exception_common+0x4a/0xac
[   11.050272] [25] [ EMERG] [ap] [25] [<0x2c65a324>] leave_critical_section+0x2c/0x54
[   11.051208] [25] [ EMERG] [ap] [25] [<0x2c65f472>] timer_settime+0x9e/0x10c

There are 2 ways can caused this:
1. sem_timedwait
   HW IRQ sem_post
   TIMER IRQ do wd_timer -> nxsem_timeout -> crash

   Note: The 2 IRQS happens amost at same time

2. sem_timedwait
   TIMER IRQ do wd_timer -> wd_func1 sem_post
                         -> wd_func2 nxsem_timeout -> crash

Resolve:
Stop the watchdog when sem_post

Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-02-18 23:00:28 +08:00
Petro Karashchenko
7933442b98 sched/semaphore/sem_clockwait: fix typo in comment
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-02-17 12:54:49 +01:00
Petro Karashchenko
41c95da594 register_driver: fix driver modes accross the code
State of problem:
 - Some drivers that do not support write operations (does not
   have write handler or ioctl do not perform any write actions)
   are registered with write permissions
 - Some drivers that do not support read operation (does not
   have read handler or ioctl do not perform any read actions)
   are registered with read permissions
 - Some drivers are registered with execute permissions

Solution:
 - Iterate code where register_driver() is used and change 'mode'
   parameter to reflect the actual read/write operations executed
   by a driver
 - Remove execute permissions from 'mode' parameter

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-02-16 16:15:29 +08:00
Zeng Zhaoxiu
fc4ab4fd94 semaphore: Improve the nxsem_release_holder function.
1. The task which called nxsem_release_holder may not be a holder of the semaphore,
   counts of the holder would not be decreamented.
   This commit try to resolve the problem if there is only one holder.
2. Avoid counts overflow.

Signed-off-by: Zeng Zhaoxiu <walker.zeng@transtekcorp.com>
2022-02-13 03:20:51 +08:00
Zeng Zhaoxiu
ea8f5f565e semaphore: Cleanup, merge public code.
Signed-off-by: Zeng Zhaoxiu <walker.zeng@transtekcorp.com>
2022-02-13 03:20:51 +08:00
Zeng Zhaoxiu
5bf7c185af semphore: release all semphores' holder that the task held when exit
Add a list in TCB to track all semphores the task held, so we
can release all holders when exit, so nxsched_verify_tcb
is unnecessary.

Signed-off-by: Zeng Zhaoxiu <walker.zeng@transtekcorp.com>
2022-02-13 03:20:51 +08:00
patacongo
cfee589a4a Update sched/wdog/wd_start.c
Co-authored-by: David Sidrane <David.Sidrane@Nscdg.com>
2022-02-10 22:33:47 +08:00
Gregory Nutt
8af4d65c9a Added comment to wdog_start
Add a comment briefly explaining why one timer tick is added to the watchdog delay.  This has confused a lot of people and has resulted in numerous awkward discussions and ill-informed attempts to modify the code to remove that addition.  Perhaps a rather lengthy comment will reduce that confusion and put an end to this thrashing.
2022-02-10 22:33:47 +08:00
chao.an
b3d45fd6c0 sched/mqueue: remove unused leave_cancellation_point
should be removed by:

commit fca07be1df
Author: Gregory Nutt <gnutt@nuttx.org>
Date:   Tue Oct 10 08:43:10 2017 -0600

    Squashed commit of the following:

        Change all calls to mq_send() and mq_timedsend() in the OS to calls to
        nxmq_send() and nxmq_timedsend(), making appropriate changes for differences
        in return values.

        sched/mqueue:  Add internal function nxmq_send() and nxmq_timedsend() that are
        equivalent to mq_send() and mq_timedsend() except that they do not create
        cancellation points and do to not modify the errno variable.

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 22:33:21 +08:00
chao.an
479d196208 sched/module: remove redundant unlock
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 22:31:51 +08:00
Xiang Xiao
d426875fcf tools/mkconfig: Remove the unnecessary config option correction
since Kconfig can handle the dependence correctly for us

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-09 14:34:38 -03:00
Huang Qi
8bf7f94d39 pthread: Call cleanup callback while asyncrhonous cancel
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-02-09 21:21:43 +08:00
Huang Qi
c0a0de97ce Revert "libc: Call pthread_exit in user-space by up_pthread_exit"
This reverts commit f4a0b7aedd.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-02-09 21:21:43 +08:00
Huang Qi
6814b1416f Revert "pthread: Avoid recursive pthread_exit call"
This reverts commit a2941532bd.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-02-09 21:21:43 +08:00
Xiang Xiao
0000e61da6 task: Always implement posix_spawnp as macro
Since there is no benefit to implement it as
function when CONFIG_LIBC_ENVPATH equals y

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-09 20:09:11 +08:00
Xiang Xiao
ab3b0d0162 sched: Implement sysinfo function
specify here:
https://man7.org/linux/man-pages/man2/sysinfo.2.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-08 10:27:38 +08:00
Xiang Xiao
0499979908 sched: Disable pthread by default when DEFAULT_SMALL is enabled
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-07 12:04:03 +08:00
Xiang Xiao
ef1abbbea0 Fix signal/sig_default.c:195:21: error: unused variable 'rtcb'
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-07 12:04:03 +08:00
Xiang Xiao
5c5f1dec08 sched: Don't duplicate caller file handler when creating kernel thread
kernel thread should have only the starndard file i/o just like idle thread

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-02-01 08:22:45 +09:00
Xiang Xiao
d48946063a Revert "sched: Don't duplicate caller file handler when creating kernel thread"
This reverts commit 512676cb06.
2022-02-01 08:22:45 +09:00
Xiang Xiao
a9d7a776c4 sched: Remove SDCLONE_DISABLE option and config
since the related code was removed by:
commit 4d5a964f29
Author: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Date:   Tue Feb 23 18:04:13 2021 +0800

    net: unify socket into file descriptor

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-31 19:03:20 +01:00
Xiang Xiao
512676cb06 sched: Don't duplicate caller file handler when creating kernel thread
kernel thread should have only the starndard file i/o just like idle thread

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-31 14:44:29 +01:00
ligd
d8c2610157 idle: remove heap & stack check in idle thread
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-01-29 00:53:47 +08:00
ligd
b316611ef0 Revert "sem: remove limitation of irq context when do sem_trywait"
This reverts commit 7c547b3ebd.
2022-01-29 00:53:47 +08:00
chao.an
e781787cb9 sched/critmonitor: remove the assertion if counter == 0
Perf timer interface generally uses the hardware cycle counter
provided by the arch chip directly(such as DWT_CYCCNT(cortex-m)),
CYCCNT is a free running counter and counting upwards.
It wraps around to 0 on overflow.

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-01-25 20:24:58 +08:00
Xiang Xiao
a24ae559c2 arch: Decouple up_critmon_[gettime|convert] from critmon
and rename to up_perf_[gettime|convert] since it's useful in other case

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-25 14:43:34 +08:00
Petro Karashchenko
c0881feca9 boards/arm/samv7/same70-qmtech: fix description in README.txt
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-23 20:08:10 -03:00
Xiang Xiao
77792a1598 sched: Define CONFIG_SMP_NCPUS to 1 in no SMP case
to simplify the SMP related code logic

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-20 23:21:21 +08:00
Petro Karashchenko
08043fb5bc net: unify FAR keyword usage for all net buffer memory mapped buffers
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-20 01:42:56 +08:00
ligd
dd08815991 idle: remove heap & stack check in idle thread
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-01-20 01:14:56 +08:00
ligd
cb502a869c clock: update clock_synchronize() to support with time
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-01-18 22:48:15 +08:00
ligd
0a51f13ca5 rpmsg_rtc: merge the rpmsg_rtc_init to same place
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-01-18 22:48:15 +08:00
Xiang Xiao
1b77ae88ef fs/procfs: Remove the unnecessary strcmp
since the procfs already make the same check for us

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-01-12 07:19:40 +01:00
Petro Karashchenko
a743fed63d file_operations: get back C89 compatible initializer
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-11 02:14:00 +08:00