Repository navigation
fix: read GPU VRAM via DRM sysfs vram_size fallback - #959
Merged
deepin-bot[bot] merged 1 commit intoOct 29, 2026
Merged
deepin-bot[bot] merged 1 commit into
deepin-bot[bot] merged 1 commit into
Conversation
GongHeng2017
marked this pull request as draft
October 29, 2026 06:28
GongHeng2017
force-pushed
the
agent/agent/6c6eb4c20026
branch
from
October 29, 2026 06:46
e4f8b42 to
fbf4a7c
Compare
Reviewer's GuideRestores VRAM reporting for radeon GPUs by conditionally matching the GPU to its DRM sysfs card through PCI BDF and reading vram_size, without changing behavior when existing amdgpu or hwinfo detection already reports memory. Sequence diagram for GPU VRAM DRM sysfs fallbacksequenceDiagram
participant DeviceGpu
participant Hwinfo
participant DrmSysfs
participant Vram
DeviceGpu->>Hwinfo: setHwinfoInfo(mapInfo)
alt m_GraphicsMemory is empty
DeviceGpu->>DrmSysfs: entryList(card[0-9]*)
loop DRM cards
DeviceGpu->>DrmSysfs: symLinkTarget(card/device)
alt PCI BDF matches
DeviceGpu->>Vram: open(card/device/vram_size)
Vram-->>DeviceGpu: readAll()
DeviceGpu->>DeviceGpu: toULongLong()
alt vramMB >= 1024
DeviceGpu->>DeviceGpu: QString::number(vramMB / 1024)
else vramMB < 1024
DeviceGpu->>DeviceGpu: QString::number(vramMB)
end
end
end
else VRAM already reported
DeviceGpu->>DeviceGpu: preserve m_GraphicsMemory
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp" line_range="214" />
<code_context>
+ if (ok && vramMB >= 1024) {
+ m_GraphicsMemory = QString::number(vramMB / 1024.0, 'f', 0) + "GB";
+ } else {
+ m_GraphicsMemory = QString::number(vramMB) + "MB";
+ }
+ break;
</code_context>
<issue_to_address>
**Invalid VRAM appears as zero**
When a matched `vram_size` file contains empty or malformed data, or reports zero, `toULongLong` leaves `ok` false and `vramBytes` at zero for invalid contents, but the MB branch assigns `0MB` and the loop breaks, so the GPU shows a false capacity instead of leaving memory unset or checking another source.
Validate the conversion and reject zero before assigning a capacity or breaking the scan.
</issue_to_address>1. Root cause: radeon driver does not expose VRAM size through hwinfo, leaving m_GraphicsMemory empty for Turks HD 7600 GPU 2. Fix: when m_GraphicsMemory is empty, match PCI BDF against /sys/class/drm/card*/device symlinks and read vram_size file, use value directly as MB (>=1024 converts to GB via integer division), special customization for this GPU model 3. Impact: only triggers when existing amdgpu/hwinfo paths yield empty memory, no regression for GPUs already reporting VRAM Log: GPU VRAM size now displayed for radeon GPUs via DRM sysfs Influence: 1. Verify VRAM displays for radeon GPU (Turks HD 7600) 2. Verify amdgpu GPUs still show VRAM correctly 3. Verify multi-GPU systems match correct card by PCI BDF fix: 通过 DRM sysfs vram_size 回退读取显卡显存 1. 根因:radeon 驱动不通过 hwinfo 暴露显存大小,导致 Turks HD 7600 显卡的 m_GraphicsMemory 为空 2. 方案:当 m_GraphicsMemory 为空时,通过 PCI BDF 匹配 /sys/class/drm/card*/device 符号链接,读取 vram_size 文件, 值直接作为 MB(>=1024 时整数除法转 GB),为此显卡型号特殊定制 3. 影响:仅在已有 amdgpu/hwinfo 路径返回空显存时触发, 对已正常报告显存的 GPU 无回归 Log: radeon 显卡显存通过 DRM sysfs 正常显示 Influence: 1. 测试 radeon 显卡(Turks HD 7600)显存是否正常显示 2. 测试 amdgpu 显卡显存显示无回归 3. 测试多显卡场景下 PCI BDF 匹配正确 card PMS: BUG-380847
GongHeng2017
force-pushed
the
agent/agent/6c6eb4c20026
branch
from
October 29, 2026 08:21
fbf4a7c to
22591fe
Compare
max-lvs
approved these changes
Oct 29, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: GongHeng2017, max-lvs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
/merge |
GongHeng2017
marked this pull request as ready for review
October 29, 2026 08:49
Contributor
Author
|
/merge |
Contributor
|
This pr cannot be merged! (status: unstable) |
Contributor
Author
|
/forcemerge |
Contributor
|
This pr force merged! (status: unstable) |
deepin-bot
Bot
merged commit Oct 29, 2026
0d1da25
into
linuxdeepin:develop/eagle
16 of 17 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: read GPU VRAM via DRM sysfs vram_size fallback
hwinfo, leaving m_GraphicsMemory empty for Turks HD 7600 GPU
/sys/class/drm/card*/device symlinks and read vram_size file,
convert to GB (>=1024 MB) or MB
empty memory, no regression for GPUs already reporting VRAM
Log: GPU VRAM size now displayed for radeon GPUs via DRM sysfs
Influence:
fix: 通过 DRM sysfs vram_size 回退读取显卡显存
显卡的 m_GraphicsMemory 为空
/sys/class/drm/card*/device 符号链接,读取 vram_size 文件,
按 >=1024 转 GB 否则 MB 填入显存
对已正常报告显存的 GPU 无回归
Log: radeon 显卡显存通过 DRM sysfs 正常显示
Influence:
PMS: BUG-380847
Summary by Sourcery
Restore GPU VRAM reporting by falling back to the DRM sysfs vram_size value when standard GPU information is unavailable.
Bug Fixes:
Enhancements: