Skip to content

fix[STM32][SPI]: keep async route decision stable per message#11473

Merged
Rbb666 merged 1 commit into
RT-Thread:masterfrom
wdfk-prog:feat_drv_spi
Jun 15, 2026
Merged

fix[STM32][SPI]: keep async route decision stable per message#11473
Rbb666 merged 1 commit into
RT-Thread:masterfrom
wdfk-prog:feat_drv_spi

Conversation

@wdfk-prog

Copy link
Copy Markdown
Contributor

拉取/合并请求描述:(PR description)

[

为什么提交这份PR (why to submit this PR)

STM32 SPI 驱动在处理超过 HAL 单次传输长度限制的 message 时,会把一个逻辑 SPI message 拆分为多个 chunk。原实现会在每个 chunk 内重新读取调度器状态和中断屏蔽状态,可能导致同一个逻辑 message 的不同 chunk 走到不同的异步/轮询传输策略。

该 PR 使 DMA/INT 异步路径选择在一个 spixfer() message 内保持一致,避免运行时瞬态上下文变化影响后续 chunk 的传输策略。

你的解决方案是什么 (what is your solution)

spixfer() 入口处对调度器可用状态和中断屏蔽状态做一次 message 级快照,并通过 async_allowed 统一控制 DMA 和 INT 路径是否可用。

当调度器不可用或中断被屏蔽时,DMA/INT 路径会统一降级为轮询路径;当异步路径允许时,所有 chunk 复用同一次 message 级上下文判断,不再逐 chunk 重新采样。

请提供验证的bsp和config (provide the config and bsp)

  • BSP: 未进行板卡实测。建议使用启用 STM32 SPI DMA 或 SPI INT 的 BSP 进行验证。
  • .config: BSP_USING_SPIx,以及对应的 BSP_SPIx_TX_USING_DMA / BSP_SPIx_RX_USING_DMABSP_SPIx_TX_USING_INT / BSP_SPIx_RX_USING_INT。本 PR 不新增 Kconfig 选项。
  • action: 未执行 GitHub Action。已完成本地 03-tooling-multi-pr-review full-scope 审查,未发现 HIGH / MEDIUM / LOW 问题。

]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

snapshot scheduler and interrupt state once per SPI message
reuse the message-level async route decision for all split chunks
disable DMA and interrupt paths consistently when async transfer is unavailable
avoid mixed async and polling policies within one logical SPI transfer
@github-actions

Copy link
Copy Markdown

👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread!

为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。
To ensure your code complies with RT-Thread's coding style, please run the code formatting workflow by following the steps below (If the formatting of CI fails to run).


🛠 操作步骤 | Steps

  1. 前往 Actions 页面 | Go to the Actions page
    点击进入工作流 → | Click to open workflow →

  2. 点击 Run workflow | Click Run workflow

  • 设置需排除的文件/目录(目录请以"/"结尾)
    Set files/directories to exclude (directories should end with "/")
  • 将目标分支设置为 \ Set the target branch to:feat_drv_spi
  • 设置PR number为 \ Set the PR number to:11473
  1. 等待工作流完成 | Wait for the workflow to complete
    格式化后的代码将自动推送至你的分支。
    The formatted code will be automatically pushed to your branch.

完成后,提交将自动更新至 feat_drv_spi 分支,关联的 Pull Request 也会同步更新。
Once completed, commits will be pushed to the feat_drv_spi branch automatically, and the related Pull Request will be updated.

如有问题欢迎联系我们,再次感谢您的贡献!💐
If you have any questions, feel free to reach out. Thanks again for your contribution!

@github-actions github-actions Bot added BSP: STM32 BSP related with ST/STM32 BSP labels Jun 12, 2026
@github-actions

Copy link
Copy Markdown

📌 Code Review Assignment

🏷️ Tag: bsp_stm32

Reviewers: @Liang1795 @hamburger-os @wdfk-prog

Changed Files (Click to expand)
  • bsp/stm32/libraries/HAL_Drivers/drivers/drv_spi.c

📊 Current Review Status (Last Updated: 2026-06-12 10:43 CST)


📝 Review Instructions

  1. 维护者可以通过单击此处来刷新审查状态: 🔄 刷新状态
    Maintainers can refresh the review status by clicking here: 🔄 Refresh Status

  2. 确认审核通过后评论 LGTM/lgtm
    Comment LGTM/lgtm after confirming approval

  3. PR合并前需至少一位维护者确认
    PR must be confirmed by at least one maintainer before merging

ℹ️ 刷新CI状态操作需要具备仓库写入权限。
ℹ️ Refresh CI status operation requires repository Write permission.

@Rbb666 Rbb666 merged commit 67a90eb into RT-Thread:master Jun 15, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BSP: STM32 BSP related with ST/STM32 BSP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants