Commit Graph

55334 Commits

Author SHA1 Message Date
ligd 7567e429b6 syslog_rpmsg: fix coding style
Follow the nxstyle

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-10-07 12:18:10 +08:00
yuanyongjian 8713638687 syslog/syslog_rpmsg.c: improve syslog_rpmsg performance
use copy buffer instead of single assignment

Signed-off-by: yuanyongjian <yuanyongjian@xiaomi.com>
2024-10-07 12:18:10 +08:00
Xiang Xiao 6e5c81e061 mm/heap: hold heap lock before access mm_nregions
to remove the race condition and rename IDX to idx

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: Neo Xu <neo.xu1990@gmail.com>
2024-10-07 04:19:27 +08:00
Yongrong Wang 365fed554e rpmsgblk.c: fix compile warning
misc/rpmsgblk.c:616:29: warning: implicit declaration of function ‘rpmsg_virtio_get_buffer_size’; did you mean ‘rpmsg_get_rx_buffer_size’? [-Wimplicit-function-declaration]
  616 |   if (MAX(msglen, rsplen) > rpmsg_virtio_get_buffer_size(priv->ept.rdev))
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                             rpmsg_get_rx_buffer_size

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
2024-10-07 04:18:18 +08:00
Kyle Wilson ac15155fc9 Enable LPUART functionality for the STM32G4 series.
1. Kconfig - Removed USART1 config option from STM32_STM32G47XX. Not necessary to adding LPUART functionality. 2. stm32_lowput.c - Added extra check from STM32G4 board because that is the only with LPUART functionality. 2. stm32_serial.c - Removed unneeded function (stm32_serial_get_lpuart). Fixed up_putc return bug. Added configuration for DMAMAP_LPUART RX and TX for STM32G4XXX only. The G4 is the only in this family with LPUART and uses a DMAMUX unlike the others.

1. Removed 1WIRE LPUART refereences in Kconfig and stm32_uart.h. There is no support for LPUART currently in stm32_1wire.c. 2. Removed references to LPUART under DMA_V2 ifdefs. STM32G4 uses DMA_V1, and I saw that none of the chips DMA_V2 (F20, F4) have LPUARTs. AFAIK the only chip in the stm32 folder that has LPUART peripherals is the STM32G4.

Removed unnecessary brackets and empty lines

Added lpuartnsh (LPUART NuttShell) config to the nucleo-g474re board configurations. nsh uses USART3 by default. lpuartnsh uses nsh as a template, changes the serial console to LPUART1, and adds the DMA configs to enable DMA for the LPUART.

Added support for using the lpuart prescaler register. Without prescaling the apbclock, 9600 baud is not supported on the G474RE. By utilizing the prescaler, when necessary, we can support nearly any baud rate (300 baud to 30M Mbaud). lowputc defaults to a prescaler of 16 for the lpuart so standard baud rates (9600 to 115200) are supported early in the boot process. Later in stm32_serial.c the ideal prescaler and BRR values are determined.

Added ifdef statements for LPUART code sections not compatible with other chips.

Changed LPUART BRR calcuation to use 64-bit integers.

Feedback from nuttx pull request. Added brackets around single line if/else statements. Reordered lpuartnsh defconfig file.

Fix lpuart brr calculation after attempting to break the calculation into 2 lines.

Removed TAB
2024-10-07 04:14:59 +08:00
cuiziwei 97359a7f76 nuttx/libxx: Simplify compilation warnings for passing CXXFLAGS.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-10-07 00:46:45 +08:00
Xiang Xiao 7c839d7a09 rptun: Remove include/nuttx/rptun/openamp.h
and use include/nuttx/rpmsg/rpmsg.h instead

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-07 00:44:28 +08:00
hujun5 eae57cb0e6 sched: replace sync pause with async pause for nxtask_terminate
reason:
In the kernel, we are planning to remove all occurrences of up_cpu_pause as one of the steps to
simplify the implementation of critical sections. The goal is to enable spin_lock_irqsave to encapsulate critical sections,
thereby facilitating the replacement of critical sections(big lock) with smaller spin_lock_irqsave(small lock)

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-06 09:26:56 +08:00
raiden00pl bcf309d80e arch/arm/nrf{52|53|91}: fix max timer timeout
fix prerpocessor value of max timer timeout
2024-10-06 08:39:12 +08:00
raiden00pl 500b985874 boards/arm/nrf52/nrf52840-dk: fix timer example
board logic expects TIMER2 to be enabled
2024-10-06 08:39:12 +08:00
Yongrong Wang 26ac220810 virtio devices: update virtqueue operate buffer add lock API
1. Use the virtqueue_xxx_lock() api;
2. Add spinlock for some virtio and vhost drivers that do not
   use spinlock to protect the virtqueues;

Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
2024-10-06 08:37:53 +08:00
Bowen Wang fd9efb600c virtio/virtio-net: add spinlock for the virtqueue
virtqueues are used in irq and thread, so add spinlock to protect
them.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-10-06 08:37:53 +08:00
Bowen Wang c0edb0f402 virtio/virtio-net: calculate the correct buffer number
Avoid exceed the virtqueue length limit when adding buffer to the
virtqueue.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-10-06 08:37:53 +08:00
Bowen Wang 280538adc6 virtio/virtio.h: add virtqueue lock api for better use
Later, we will change all virtio driver to use the new api

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-10-06 08:37:53 +08:00
wangyongrong 377f184019 virtio-rpmb.c: add spin lock for virtqueue add/get buffer
Virtqueeus are used in both user thread and interrupt, so add spinlock
to proetect them.

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-10-06 08:37:53 +08:00
wangyongrong e8a8052a8a virtio-serial.c: add spin lock for virtqueue add/get buffer
Virtqueeus are used in both user thread and interrupt, so add spinlock
to proetect them.

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-10-06 08:37:53 +08:00
wangyongrong 67ceba3cd6 virtio-blk.c: add spin lock to fix get/add virtqueue buffer at the same time err
Virtqueues are used in both user thread and interrupt, so add spinlock to protect
them.

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-10-06 08:37:53 +08:00
wangyongrong 58aca26b1b virtio-blk.c: change virtio blk req and resp to local variables
So we can remove the mutex lock to improve the virtio-block driver
performance

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-10-06 08:37:53 +08:00
wangyongrong 735dc6e2bf virtio-rng.c: add spin lock to fix get/add virtqueue buffer at the same time err
the virtqueue should be protected by the spinlock, because the virtqueues are used
both in worker and interrupt.

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-10-06 08:37:53 +08:00
wangyongrong f6f151a8e1 virtio-blk: add VIRTIO_BLK_F_BLK_SIZE feature
Support configure the virtio block device block size to other value
(default value is 512)

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-10-06 08:37:53 +08:00
wangyongrong ef58c71582 virtio-blk: add VIRTIO_BLK_F_RO feature
When feature VIRTIO_BLK_F_RO is set, virtio-blk only support read
operation.

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-10-06 08:37:53 +08:00
wangyongrong 7ec167392c virtio-blk: add VIRTIO_BLK_F_FLUSH features
Should support the flush command only when virtio device support
feature VIRTIO_BLK_F_FLUSH

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-10-06 08:37:53 +08:00
Bowen Wang 7eda1700c2 virtio/virtio-rng: make virtio-rng work for remoteproc transport layer
For remoteproc transport layer, the virtio drivers can not use the malloced
memory from the default system heap to communicate with the virtio devices,
the buffers placed in virtqueue should be in the share memory region
(mallcoed virtio_alloc_buf()).

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-10-06 08:37:53 +08:00
Bowen Wang 106040df6c virtio-serial: support custom the virtio serial device name
By setting config CONFIG_DRIVERS_VIRTIO_SERIAL_NAME to "ttyXX0;ttyXX1;..."
to customize the virtio serial name.

For example:
If CONFIG_DRIVERS_VIRTIO_SERIAL_NAME="ttyBT;ttyTest0;ttyTest1",
virtio-serial will register three uart devices with names:
"/dev/ttyBT", "/dev/ttyTest0", "/dev/ttyTest1" to the VFS.

nsh> ls dev
/dev:
 console
 null
 telnet
 ttyBT
 ttyS0
 ttyTest0
 ttyTest1
 zero

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-10-06 08:37:53 +08:00
Bowen Wang 84d2aae63b virtio-mmio: add secure virtio mmio device register api
In secure state, call virtio_register_mmio_device_secure() to
register the secure virtio mmio device;
In non-secure state, call virtio_register_mmio_device() to
register the non-secure virtio mmio device;
Board should ensure not mixed use the secure and non-seucre mmio
device.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-10-06 08:37:53 +08:00
shipei 551b9b1626 audio:add getlatency for virtio snd driver
add getlatency in virtio snd driver

Signed-off-by: shipei <shipei@xiaomi.com>
2024-10-06 08:37:53 +08:00
raiden00pl 50f21f93d4 boards/arm/stm32f0l0g0/stm32g071b-disco: fix djoy example
fix djoy example for stm32g071b-disco.
CONFIG_NSH_ARCHINIT=y must be set to register djoy.
2024-10-05 17:29:16 -03:00
raiden00pl 65a3b5f524 arch/arm/nrf{52|53|91}: fix read GPIO state for outputs
when GPIO is configured as output, we have to read output
state instead of input register
2024-10-05 23:40:34 +08:00
raiden00pl e3bbd0cfd8 drivers/serial/CMakeLists.txt: add missing files
add missing files: uart_bth5.c and uart_ram.c
2024-10-05 23:40:11 +08:00
Xiang Xiao 1195ec03f7 driver/vhost: Call metal_init in vhost_register_drivers
since libmetal come from OpenAMP need be initialized before working

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-05 12:05:13 -03:00
Xiang Xiao f914bc8ef2 driver/vhost: Check driver is NULL before calling probe
to avoid the same device bind to multiple drivers at the same time

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-05 12:05:13 -03:00
Xiang Xiao 1e823a077c driver/vhost: vhost_register_device should set priv before inovking probe
align the behavior with vhost_register_driver

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-05 12:05:13 -03:00
Xiang Xiao 347c2dae29 driver/virtio: Check driver isn't NULL before calling remove
since the device mayn't bind to the driver yet

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-05 12:05:13 -03:00
Xiang Xiao bad1627759 driver/vhost: Check driver isn't NULL before calling remove
since the device mayn't bind to the driver yet

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-05 12:05:13 -03:00
Xiang Xiao 0f918c8d4d pci/ivshmem: Check drv isn't NULL before calling remove
since the device mayn't bind to the driver yet

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-05 12:05:13 -03:00
Xiang Xiao 2aaaa7632f rpmsg/ivshmem: Skip unregistering ivshmem driver
since ivshmem device may insert again

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-05 12:05:13 -03:00
Xiang Xiao 6685fb5434 pci/ivshmem: Skip unregistering ivshmem driver
since ivshmem device may insert again

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2024-10-05 12:05:13 -03:00
chenrun1 8f9857bf8c fs_lock:Check the nwaiter when deleting a bucket
Summary:
  Fixed the problem of releasing the bucket prematurely in multi-threaded flock scenarios.

A thread setlk
B thread setlk_wait
A thread releases lock but fails to determine if nwaiter causes the bucket to be released prematurely
post B thread causes crash due to heap use after free

https://github.com/apache/nuttx/issues/13821

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-10-05 21:09:46 +08:00
Michal Lenc f778660aca smartfs: return -ENOTTY if ioctl command is not found
The upper layer expects -ENOTTY is returned if ioctl command is not
found in file system specific implementation.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2024-10-05 20:52:31 +08:00
raiden00pl fb7fe185d8 boards/sim: update foc test config
Update FOC configuration so that it doesnt fail during initialization.
2024-10-05 18:45:12 +08:00
anjiahao a613bcb7cb modlib:add new dump api to modlib
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-05 15:22:02 +08:00
anjiahao a9cb28cd23 modlib:Standardized module loading method
1. use '__attribute__((constructor))' mark initialize function
2. use '__attribute__((destructor))' mark uninitialize function
3. compile module with -fvisibility=hidden. use `__attribute__((visibility("default")))`
mark is need export symbol.so not need module_initialize to initialize export symbol.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2024-10-05 15:22:02 +08:00
hujun5 5df3625b62 sched: replace sync pause with async pause for nxtask_restart
reason:
In the kernel, we are planning to remove all occurrences of up_cpu_pause as one of the steps to
simplify the implementation of critical sections. The goal is to enable spin_lock_irqsave to encapsulate critical sections,
thereby facilitating the replacement of critical sections(big lock) with smaller spin_lock_irqsave(small lock)

Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic
-machine virt,virtualization=on,gic-version=3
-net none -chardev stdio,id=con,mux=on -serial chardev:con
-mon chardev=con,mode=readline -kernel ./nuttx

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-05 14:23:25 +08:00
hujun5 0b0f535c66 sched: replace sync pause with async pause for setpriority
reason:
In the kernel, we are planning to remove all occurrences of up_cpu_pause as one of the steps to
simplify the implementation of critical sections. The goal is to enable spin_lock_irqsave to encapsulate critical sections,
thereby facilitating the replacement of critical sections(big lock) with smaller spin_lock_irqsave(small lock)

Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic
-machine virt,virtualization=on,gic-version=3
-net none -chardev stdio,id=con,mux=on -serial chardev:con
-mon chardev=con,mode=readline -kernel ./nuttx

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-05 14:00:59 +08:00
hujun5 8e89984360 sched: replace sync pause with async pause for nxsched_suspend
reason:
In the kernel, we are planning to remove all occurrences of up_cpu_pause as one of the steps to
simplify the implementation of critical sections. The goal is to enable spin_lock_irqsave to encapsulate critical sections,
thereby facilitating the replacement of critical sections(big lock) with smaller spin_lock_irqsave(small lock)

Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic
-machine virt,virtualization=on,gic-version=3
-net none -chardev stdio,id=con,mux=on -serial chardev:con
-mon chardev=con,mode=readline -kernel ./nuttx

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-05 13:59:35 +08:00
hujun5 6a13e4a6f6 sched/sched: next pointer value is definitely not null
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-05 13:49:55 +08:00
hujun5 b4cc9fb11b sched: change nxsched_islocked_global to nxsched_islocked_tcb
reason:
1 To improve efficiency, we mimic Linux's behavior where preemption disabling is only applicable to the current CPU and does not affect other CPUs.
2 In the future, we will implement "spinlock+sched_lock", and use it extensively. Under such circumstances, if preemption is still globally disabled, it will seriously impact the scheduling efficiency.
3 We have removed g_cpu_lockset and used irqcount in order to eliminate the dependency of schedlock on critical sections in the future, simplify the logic, and further enhance the performance of sched_lock.
4 We set lockcount to 1 in order to lock scheduling on all CPUs during startup, without the need to provide additional functions to disable scheduling on other CPUs.
5 Cpu1~n must wait for cpu0 to enter the idle state before enabling scheduling because it prevents CPUs1~n from competing with cpu0 for the memory manager mutex, which could cause the cpu0 idle task to enter a wait state and trigger an assert.

size nuttx
before:
   text    data     bss     dec     hex filename
 265396   51057   63646  380099   5ccc3 nuttx
after:
   text    data     bss     dec     hex filename
 265184   51057   63642  379883   5cbeb nuttx

size -216

Configuring NuttX and compile:
$ ./tools/configure.sh -l qemu-armv8a:nsh_smp
$ make
Running with qemu
$ qemu-system-aarch64 -cpu cortex-a53 -smp 4 -nographic \
   -machine virt,virtualization=on,gic-version=3 \
   -net none -chardev stdio,id=con,mux=on -serial chardev:con \
   -mon chardev=con,mode=readline -kernel ./nuttx

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-10-05 13:49:55 +08:00
zhanghongyu bd83d2aca5 fs_lock: fix cmake build error
nuttx/fs/vfs/fs_lock.c:39:10: fatal error: sched/sched.h: No such file or directory
   39 | #include "sched/sched.h"
      |          ^~~~~~~~~~~~~~~

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2024-10-05 13:43:02 +08:00
wanggang26 e16c785e8c mmcsd: move block driver register to probe stage in order to read ext_csd reg
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-10-05 09:17:25 +08:00
cuiziwei 6373931cf1 nuttx/arch: Fix the issue where the compiler cannot recognize min-pagesize=0.
Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2024-10-05 08:45:08 +08:00