[dm][ufs] fixup the ufs supported - #11646
Conversation
Signed-off-by: GuEe-GUI <2991707448@qq.com>
Signed-off-by: GuEe-GUI <2991707448@qq.com>
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-07-22 23:27 CST)
📝 Review Instructions
|
|
There was a problem hiding this comment.
🟡 Not ready to approve
It introduces a confirmed GPT size validation regression (potential out-of-bounds CRC read) and a confirmed ISR/thread race on irq_status that can drop interrupt bits.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR improves UFS bring-up robustness and extends EFI/GPT partition parsing to support disks with 4KB logical block sizes (common on UFS), aligning the driver stack with early-probe and non-512B sector environments.
本 PR 增强了 UFS 初始化/链路启动流程的健壮性,并扩展 EFI/GPT 分区解析以支持 4KB 逻辑块大小(UFS 常见),以适配早期 probe 阶段及非 512B 扇区的场景。
Changes:
- UFS: Add HCE enable wait, refactor link-startup flow, and switch UTP completion wait to polling for early-probe hosts.
UFS:增加 HCE 使能等待、调整链路启动流程,并将 UTP 完成等待改为轮询以适配早期 probe 主机。 - UFS PM: Add UIC DME_RESET / DME_ENABLE helper APIs.
UFS 电源管理:新增 UIC DME_RESET / DME_ENABLE 辅助接口。 - EFI/GPT: Make GPT reads work with logical block sizes > 512B (e.g., 4KB).
EFI/GPT:支持逻辑块大小大于 512B(如 4KB)的读取与解析。
File summaries
| File | Description |
|---|---|
| components/drivers/ufs/ufs.c | Adds early bring-up waits/polling and updates link/transfer flow for more robust UFS initialization. |
| components/drivers/ufs/ufs_pm.c | Introduces new DME reset/enable helpers wrapping UIC commands with result checking. |
| components/drivers/include/drivers/ufs.h | Extends rt_ufs_ops with hce_enable_notify and exports new DME helper APIs. |
| components/drivers/block/partitions/efi.c | Updates GPT/EFI reading logic to support 4KB logical blocks and improves error handling. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 3
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| /* Sanity check partition table size */ | ||
| pt_size = (rt_uint64_t)rt_le32_to_cpu((*gpt)->num_partition_entries) * | ||
| rt_le32_to_cpu((*gpt)->sizeof_partition_entry); | ||
|
|
||
| if (pt_size > (rt_uint64_t)RT_UINT32_MAX) | ||
| { | ||
| goto _fail; | ||
| } | ||
|
|
||
| if (!(*ptes = alloc_read_gpt_entries(disk, *gpt))) |
| LOG_E("%s: UFS UTP wait timeout: IS=%#08x irq_status=%#08x UTRLDBR=%#08x OCS=%#x", | ||
| rt_dm_dev_get_name(ufs->parent.dev), | ||
| HWREG32(regs + RT_UFS_REG_IS), ufs->irq_status); | ||
| HWREG32(regs + RT_UFS_REG_IS), ufs->irq_status, | ||
| HWREG32(regs + RT_UFS_REG_UTRLDBR), ufs_utrd_ocs(ufs)); |
| ufs->irq_status &= ~RT_UFS_REG_IS_UTRCS; | ||
| HWREG32(ufs->regs + RT_UFS_REG_IS) = RT_UFS_REG_IS_UTRCS; | ||
| return RT_EOK; |
拉取/合并请求描述:(PR description)
[
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up