Skip to content

doc: add Doxygen comments to PCI driver subsystem#11484

Open
GorrayLi wants to merge 3 commits into
RT-Thread:masterfrom
GorrayLi:driver_pci
Open

doc: add Doxygen comments to PCI driver subsystem#11484
GorrayLi wants to merge 3 commits into
RT-Thread:masterfrom
GorrayLi:driver_pci

Conversation

@GorrayLi

@GorrayLi GorrayLi commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

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

[

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

doc: add Doxygen comments to PCI driver subsystem

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

doc: add Doxygen comments to PCI driver subsystem

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

  • BSP:

  • .config:

  • action:

]

当前拉取/合并请求的状态 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:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 代码是高质量的 Code in this PR is of high quality
  • 已经使用formatting 等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification
  • 如果是新增bsp, 已经添加ci检查到.github/ALL_BSP_COMPILE.json 详细请参考链接BSP自查

GorrayLi added 2 commits June 13, 2026 16:29
Signed-off-by: ligr <liguorui1213@163.com>
Signed-off-by: ligr <liguorui1213@163.com>
@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:driver_pci
  • 设置PR number为 \ Set the PR number to:11484
  1. 等待工作流完成 | Wait for the workflow to complete
    格式化后的代码将自动推送至你的分支。
    The formatted code will be automatically pushed to your branch.

完成后,提交将自动更新至 driver_pci 分支,关联的 Pull Request 也会同步更新。
Once completed, commits will be pushed to the driver_pci 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

Copy link
Copy Markdown

📌 Code Review Assignment

🏷️ Tag: components

Reviewers: @Maihuanyi

Changed Files (Click to expand)
  • components/drivers/include/drivers/pci.h
  • components/drivers/include/drivers/pci_endpoint.h
  • components/drivers/include/drivers/pci_msi.h
  • components/drivers/pci/access.c
  • components/drivers/pci/ecam.c
  • components/drivers/pci/ecam.h
  • components/drivers/pci/endpoint/endpoint.c
  • components/drivers/pci/endpoint/mem.c
  • components/drivers/pci/host-bridge.c
  • components/drivers/pci/host/dw/pcie-dw.c
  • components/drivers/pci/host/dw/pcie-dw.h
  • components/drivers/pci/host/dw/pcie-dw_ep.c
  • components/drivers/pci/host/dw/pcie-dw_host.c
  • components/drivers/pci/host/dw/pcie-dw_platfrom.c
  • components/drivers/pci/host/pci-host-common.c
  • components/drivers/pci/host/pci-host-generic.c
  • components/drivers/pci/irq.c
  • components/drivers/pci/msi/device.c
  • components/drivers/pci/msi/irq.c
  • components/drivers/pci/msi/msi.c
  • components/drivers/pci/ofw.c
  • components/drivers/pci/pci.c
  • components/drivers/pci/pme.c
  • components/drivers/pci/probe.c
  • components/drivers/pci/procfs.c
  • components/drivers/pci/procfs.h

📊 Current Review Status (Last Updated: 2026-06-15 08:48 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to improve maintainability of RT-Thread’s PCI subsystem by adding Doxygen documentation blocks across the PCI core, host/ECAM/DW drivers, MSI/MSI-X, procfs, and endpoint framework.

Changes:

  • Add Doxygen @file/API comments across PCI core, host, MSI/MSI-X, procfs, and endpoint code.
  • Minor code formatting adjustments (indentation/brace style) mixed into multiple PCI files.
  • Includes at least one non-doc functional change (so the PR is not doc-only as titled/described).

Notes (review checklist related / 审查清单相关提示):

  • PR title format: repository guideline prefers lowercase prefix like [module][subsystem] ...; current title uses "doc: ..." rather than [doc]... / [components][drivers]....
  • PR description “BSP / .config / action” fields are left empty.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 19 comments.

Show a summary per file
File Description
components/drivers/pci/procfs.h Adds procfs interface Doxygen comments.
components/drivers/pci/procfs.c Adds procfs implementation Doxygen comments and some formatting changes.
components/drivers/pci/probe.c Adds detailed PCI enumeration/probing Doxygen comments.
components/drivers/pci/pme.c Adds PME capability Doxygen comments and replaces legacy block comment.
components/drivers/pci/pci.c Adds core PCI API Doxygen comments; includes some formatting/readability changes.
components/drivers/pci/ofw.c Adds device-tree integration Doxygen comments and adjusts log alignment.
components/drivers/pci/msi/msi.c Adds MSI/MSI-X core Doxygen comments and helper doc.
components/drivers/pci/msi/irq.c Adds file/function Doxygen comments; includes a logic change in a touched hunk.
components/drivers/pci/msi/device.c Adds MSI/MSI-X capability init Doxygen comments.
components/drivers/pci/irq.c Adds INTx routing/assignment Doxygen comments.
components/drivers/pci/host/pci-host-generic.c Adds generic host driver Doxygen comments; changes initializer formatting.
components/drivers/pci/host/pci-host-common.c Adds common probe/remove Doxygen comments.
components/drivers/pci/host/dw/pcie-dw.c Adds DesignWare core library Doxygen comments and reformats some control flow.
components/drivers/pci/host/dw/pcie-dw_platfrom.c Adds DesignWare platform driver Doxygen comments.
components/drivers/pci/host/dw/pcie-dw_host.c Adds RC-mode Doxygen comments and some formatting changes.
components/drivers/pci/host/dw/pcie-dw_ep.c Adds EP-mode Doxygen comments and reformats ops table.
components/drivers/pci/host-bridge.c Adds host-bridge driver Doxygen comments and restructures comments/initializers.
components/drivers/pci/endpoint/mem.c Adds endpoint memory allocator Doxygen comments; minor formatting.
components/drivers/pci/endpoint/endpoint.c Adds endpoint framework Doxygen comments across public APIs.
components/drivers/pci/ecam.h Adds ECAM definition Doxygen comments and restructures macro docs.
components/drivers/pci/ecam.c Adds ECAM implementation Doxygen comments; changes initializer brace style.
components/drivers/pci/access.c Adds config access layer Doxygen comments, including macro documentation blocks.
components/drivers/include/drivers/pci_msi.h Adds MSI/MSI-X structure and API Doxygen comments.
components/drivers/include/drivers/pci_endpoint.h Adds comprehensive endpoint public API Doxygen documentation.
Comments suppressed due to low confidence (2)

components/drivers/pci/procfs.c:290

  • [spelling/拼写]: pci_lseek() parameter name and Doxygen tag use wherece, which is a typo for whence.

English: Using the conventional whence name (and matching documentation) improves readability and avoids confusion with lseek(2) semantics.
中文:建议将参数名统一为常见的 whence(并同步更新注释),避免与 lseek 语义产生混淆。

 * @param[in] wherece SEEK_SET, SEEK_CUR, or SEEK_END (config space size)
 * @return New position, or negative error
 */
static off_t pci_lseek(struct dfs_file *file, off_t offset, int wherece)
{
    struct proc_dentry *dentry = file->vnode->data;
    struct rt_pci_device *pdev = dentry->data;

    switch (wherece)

components/drivers/pci/ecam.c:107

  • [codebase_conventions/代码库规范]: This initializer switches to K&R-style braces (= {) which conflicts with RT-Thread's documented Allman brace style.

English: documentation/7.contribution/coding_style_en.md recommends braces on their own lines and suggests formatting with astyle --style=allman. Please keep braces on separate lines for these initializers (including nested initializers).
中文:RT-Thread 编码规范建议使用 Allman 风格(大括号独占一行,并推荐 astyle --style=allman)。这里的初始化(包括嵌套初始化)建议保持大括号换行,以保持代码风格一致。

/** @brief Standard ECAM operations using direct MMIO read/write */
const struct pci_ecam_ops pci_generic_ecam_ops = {
    .pci_ops = {
        .map = pci_ecam_map,
        .read = rt_pci_bus_read_config_uxx,
        .write = rt_pci_bus_write_config_uxx,
    }
};

Comment on lines +15 to +16
* Provides /proc/pci/<BDF> per-device configuration space files
* and /proc/pci/devices enumeration for userspace access.
Comment on lines +29 to +40
/**
* @brief Create /proc/pci/<BDF> entry for a PCI device
*
* @param[in] pdev PCI device to attach
*/
void pci_procfs_attach(struct rt_pci_device *pdev);

/**
* @brief Remove /proc/pci/<BDF> entry for a PCI device
*
* @param[in] pdev PCI device to detach
*/
Comment on lines +43 to +56
/**
* @brief No-op: create /proc/pci/<BDF> entry (procfs disabled)
*
* @param[in] pdev PCI device
*/
rt_inline void pci_procfs_attach(struct rt_pci_device *pdev)
{
}

/**
* @brief No-op: remove /proc/pci/<BDF> entry (procfs disabled)
*
* @param[in] pdev PCI device
*/
Comment on lines +16 to +18
* - /proc/pci/devices: A list of all PCI devices with their BARs and drivers
* - /proc/pci/<BDF>: Per-device config space read/write (like Linux's sysfs config)
*
Comment on lines +98 to +102
* @brief Read PCI config space from userspace (/proc/pci/<BDF>)
*
* Handles arbitrary offsets and sizes with proper alignment.
* Data is converted to little-endian for userspace consumption.
*
Comment on lines 625 to +626
LOG_E("%s: MSI pic MUST implemented %s",
rt_ofw_node_full_name(msi_ic_np), "irq_free_msi");
rt_ofw_node_full_name(msi_ic_np), "irq_free_msi");
Comment on lines 864 to 865
LOG_E("Invail num-lanes = %d", pci->num_lanes);
return;
Comment on lines 81 to 86
if (last_irq >= 0 && last_irq + 1 != irq)
{
for (int idx = 0; idx < i; ++i, --last_irq)
for (int idx = 0; idx < i; ++idx, --last_irq)
{
rt_bitmap_set_bit(msi_irq_map, last_irq);
}
Comment on lines +32 to 40
/** @brief CAM-mode ECAM ops with 16-bit bus shift for legacy PCI */
static const struct pci_ecam_ops gen_pci_cfg_cam_bus_ops = {
.bus_shift = 16,
.pci_ops =
{
.pci_ops = {
.map = pci_ecam_map,
.read = rt_pci_bus_read_config_uxx,
.write = rt_pci_bus_write_config_uxx,
}
};
Comment on lines +1340 to 1347
/** @brief PCI bus type descriptor */
static struct rt_bus pci_bus = {
.name = "pci",
.match = pci_match,
.probe = pci_probe,
.remove = pci_remove,
.shutdown = pci_shutdown,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants