Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bsp/hpmicro/hpm5100evk/rtconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
STRIP = PREFIX + 'strip'

ARCH_ABI = ' -mcmodel=medlow '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
Expand Down
2 changes: 1 addition & 1 deletion bsp/hpmicro/hpm5300evk/rtconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
STRIP = PREFIX + 'strip'

ARCH_ABI = ' -mcmodel=medlow '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
Expand Down
2 changes: 1 addition & 1 deletion bsp/hpmicro/hpm5301evklite/rtconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
STRIP = PREFIX + 'strip'

ARCH_ABI = ' -mcmodel=medlow '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
Expand Down
2 changes: 1 addition & 1 deletion bsp/hpmicro/hpm5e00evk/rtconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
STRIP = PREFIX + 'strip'

ARCH_ABI = ' -mcmodel=medlow '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
Expand Down
2 changes: 1 addition & 1 deletion bsp/hpmicro/hpm6200evk/rtconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
STRIP = PREFIX + 'strip'

ARCH_ABI = ' -mcmodel=medlow '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
Expand Down
2 changes: 1 addition & 1 deletion bsp/hpmicro/hpm6300evk/rtconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
STRIP = PREFIX + 'strip'

ARCH_ABI = ' -mcmodel=medlow '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
Expand Down
2 changes: 1 addition & 1 deletion bsp/hpmicro/hpm6750evk/rtconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
STRIP = PREFIX + 'strip'

ARCH_ABI = ' -mcmodel=medlow '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
Expand Down
2 changes: 1 addition & 1 deletion bsp/hpmicro/hpm6750evk2/rtconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
STRIP = PREFIX + 'strip'

ARCH_ABI = ' -mcmodel=medlow '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
Expand Down
2 changes: 1 addition & 1 deletion bsp/hpmicro/hpm6750evkmini/rtconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
STRIP = PREFIX + 'strip'

ARCH_ABI = ' -mcmodel=medlow '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
Expand Down
2 changes: 1 addition & 1 deletion bsp/hpmicro/hpm6800evk/rtconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
STRIP = PREFIX + 'strip'

ARCH_ABI = ' -mcmodel=medlow '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
Expand Down
2 changes: 1 addition & 1 deletion bsp/hpmicro/hpm6e00evk/rtconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
STRIP = PREFIX + 'strip'

ARCH_ABI = ' -mcmodel=medlow '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
Expand Down
2 changes: 1 addition & 1 deletion bsp/hpmicro/hpm6p00evk/rtconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
STRIP = PREFIX + 'strip'

ARCH_ABI = ' -mcmodel=medlow '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 ' + ' -ffunction-sections -fdata-sections -fno-common '
DEVICE = ARCH_ABI + ' -DUSE_NONVECTOR_MODE=1 -DRT_CPU_CACHE_LINE_SZ=64 ' + ' -ffunction-sections -fdata-sections -fno-common '
CFLAGS = DEVICE
AFLAGS = CFLAGS
LFLAGS = ARCH_ABI + ' --specs=nano.specs --specs=nosys.specs -nostartfiles -Wl,--gc-sections '
Expand Down
11 changes: 9 additions & 2 deletions components/drivers/serial/dev_serial_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,10 @@ static rt_err_t rt_serial_rx_enable(struct rt_device *dev,
struct rt_serial_device *serial;
struct rt_serial_rx_fifo *rx_fifo = RT_NULL;
rt_size_t rx_fifo_size = 0;
#ifdef RT_SERIAL_USING_DMA
rt_size_t dma_ping_offset = 0;
rt_uint8_t *dma_ping = RT_NULL;
#endif

RT_ASSERT(dev != RT_NULL);
serial = (struct rt_serial_device *)dev;
Expand Down Expand Up @@ -1127,7 +1131,9 @@ static rt_err_t rt_serial_rx_enable(struct rt_device *dev,
#ifdef RT_SERIAL_USING_DMA
if (serial->config.dma_ping_bufsz < RT_SERIAL_RX_MINBUFSZ / 2)
serial->config.dma_ping_bufsz = RT_SERIAL_RX_MINBUFSZ / 2;
rx_fifo_size = sizeof(struct rt_serial_rx_fifo) + serial->config.rx_bufsz + serial->config.dma_ping_bufsz;

dma_ping_offset = sizeof(struct rt_serial_rx_fifo) + serial->config.rx_bufsz;
rx_fifo_size = dma_ping_offset + RT_ALIGN(serial->config.dma_ping_bufsz, RT_CPU_CACHE_LINE_SZ) + RT_CPU_CACHE_LINE_SZ;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里只看全局 RT_SERIAL_USING_DMA。例如 at32f455-start 的 UART1 默认走中断接收,打开时也会多申请 32 字节。上面两处 TX 分配也会增加纯中断模式的堆开销。请只在需要缓存维护的 DMA 路径预留对齐空间。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

取消了tx的修改,因为其实没有需要保护的实际场景

#else
rx_fifo_size = sizeof(struct rt_serial_rx_fifo) + serial->config.rx_bufsz;
#endif
Expand All @@ -1141,8 +1147,9 @@ static rt_err_t rt_serial_rx_enable(struct rt_device *dev,
serial->config.rx_bufsz);

#ifdef RT_SERIAL_USING_DMA
dma_ping = (rt_uint8_t *)RT_ALIGN((rt_ubase_t)rx_fifo + dma_ping_offset, RT_CPU_CACHE_LINE_SZ);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HPM6880 的 RX 重分配只检查主 ring。RT_ALIGN_SIZE=4 时,主 ring 的起址和取整后容量都可能满足 64 字节对齐,驱动便会沿用这里的 ping buffer。32 字节对齐可能把 ping 移到 64 字节行中间,后续整行 invalidate 会越过堆块末尾。请按 BSP 的实际缓存行对齐并预留尾部空间。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已为BSP添加-DRT_CPU_CACHE_LINE_SZ=64声明

rt_ringbuffer_init(&rx_fifo->dma_ping_rb,
(rt_uint8_t *)rx_fifo + sizeof(struct rt_serial_rx_fifo) + serial->config.rx_bufsz,
dma_ping,
serial->config.dma_ping_bufsz);
#endif

Expand Down
Loading