amdgpu: phytium: update phytium amdgpu controller driver support to 6.6.0.4#1666
amdgpu: phytium: update phytium amdgpu controller driver support to 6.6.0.4#1666zhangfuxiang123 wants to merge 2 commits intodeepin-community:linux-6.6.yfrom
Conversation
In Phyfusion DirectX 11 API remoting, bad address error occurs in qemu when running some d3d11 demos. The patch fixed this issue. Signed-off-by: Zhang Fuxiang <zhangfuxiang2144@phytium.com.cn> Signed-off-by: Liu Tao <liutao@phytium.com.cn> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
With phytium virtual gpu acceleration method in qemu windows guest OS, guest OS driver needs to share GPU device memory with host and requires the shared buffer mapping remains valid, but the ttm map implemenataion did not account for this usecase. So we add a ref count for every pages of the shared buffer. Signed-off-by: Zhang Fuxiang <zhangfuxiang2144@phytium.com.cn> Signed-off-by: Liu Tao <liutao@phytium.com.cn> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates the Phytium-specific AMDGPU GEM mmap behavior to allow uncached mappings on Phytium SoCs and adjusts TTM page handling by explicitly managing page reference counts when populating/unpopulating TTM translation tables, improving compatibility with kernel 6.6.0.4 and VM guest visibility. Sequence diagram for updated amdgpu_gem_object_mmap behavior on Phytium SoCssequenceDiagram
actor UserProcess
participant VFS
participant DRMCore
participant amdgpu_gem_object_mmap
participant is_phytium_soc
participant drm_gem_ttm_mmap
UserProcess->>VFS: mmap on amdgpu GEM file
VFS->>DRMCore: drm_gem_mmap
DRMCore->>amdgpu_gem_object_mmap: amdgpu_gem_object_mmap(obj, vma)
amdgpu_gem_object_mmap->>amdgpu_gem_object_mmap: check VM_SHARED and VM_ACCESS_FLAGS
alt CONFIG_ARCH_PHYTIUM enabled
amdgpu_gem_object_mmap->>is_phytium_soc: is_phytium_soc()
alt running_on_phytium_soc
is_phytium_soc-->>amdgpu_gem_object_mmap: true
amdgpu_gem_object_mmap->>amdgpu_gem_object_mmap: vm_flags_set(vma, VM_ALLOW_ANY_UNCACHED)
else not_phytium_soc
is_phytium_soc-->>amdgpu_gem_object_mmap: false
end
end
amdgpu_gem_object_mmap->>drm_gem_ttm_mmap: drm_gem_ttm_mmap(obj, vma)
drm_gem_ttm_mmap-->>DRMCore: mmap result
DRMCore-->>VFS: mmap result
VFS-->>UserProcess: mapping established
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Hi @zhangfuxiang123. Thanks for your PR. I'm waiting for a deepin-community member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The addition of VM_ALLOW_ANY_UNCACHED under CONFIG_ARCH_PHYTIUM is tightly coupled to is_phytium_soc(); consider adding a brief comment explaining why the generic flag is safe for all Phytium SoCs and not gated on more specific hardware capabilities to avoid future misuse.
- In amdgpu_ttm_tt_populate/unpopulate, the new page_ref_inc/dec() calls assume every entry in ttm->pages[] is non-NULL and valid; if there are code paths where sparse or partially populated arrays are possible, you may want to guard these calls with a NULL check or document the invariant.
- The explicit page_ref_inc/dec() in the TTM populate/unpopulate paths change the lifetime semantics of these pages; consider adding a short code comment summarizing the ownership model (who holds the extra ref and when it’s dropped) to avoid future double-free or leak regressions if this code is refactored.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The addition of VM_ALLOW_ANY_UNCACHED under CONFIG_ARCH_PHYTIUM is tightly coupled to is_phytium_soc(); consider adding a brief comment explaining why the generic flag is safe for all Phytium SoCs and not gated on more specific hardware capabilities to avoid future misuse.
- In amdgpu_ttm_tt_populate/unpopulate, the new page_ref_inc/dec() calls assume every entry in ttm->pages[] is non-NULL and valid; if there are code paths where sparse or partially populated arrays are possible, you may want to guard these calls with a NULL check or document the invariant.
- The explicit page_ref_inc/dec() in the TTM populate/unpopulate paths change the lifetime semantics of these pages; consider adding a short code comment summarizing the ownership model (who holds the extra ref and when it’s dropped) to avoid future double-free or leak regressions if this code is refactored.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
This PR updates AMDGPU’s Phytium-specific handling around GEM mmap flags and TTM page lifecycle management, aiming to improve VM guest memory visibility and avoid mmap “bad address” issues on Phytium SoCs.
Changes:
- Adds per-page refcount adjustments during TTM TT populate/unpopulate.
- Sets
VM_ALLOW_ANY_UNCACHEDon GEM mmap for Phytium platforms (guarded byCONFIG_ARCH_PHYTIUM).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | Adds page refcount inc/dec in TTM populate/unpopulate paths. |
| drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | Adds Phytium-specific mmap flag handling and a new arch header include. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for (i = 0; i < ttm->num_pages; ++i) { | ||
| ttm->pages[i]->mapping = bdev->dev_mapping; | ||
| page_ref_inc(ttm->pages[i]); | ||
| } |
| for (i = 0; i < ttm->num_pages; ++i) | ||
| for (i = 0; i < ttm->num_pages; ++i) { | ||
| ttm->pages[i]->mapping = NULL; | ||
| page_ref_dec(ttm->pages[i]); |
| #ifdef CONFIG_ARCH_PHYTIUM | ||
| #include <asm/phytium_cputype.h> | ||
| #endif | ||
|
|
|
|
||
| #ifdef CONFIG_ARCH_PHYTIUM | ||
| /*lt: workaround for bad address error with d3d11 api remoting*/ | ||
| if (is_phytium_soc()) |
| vm_flags_clear(vma, VM_MAYWRITE); | ||
|
|
||
| #ifdef CONFIG_ARCH_PHYTIUM | ||
| /*lt: workaround for bad address error with d3d11 api remoting*/ |
This patches updates the support for phytium amdgpu controller driver.
Summary by Sourcery
Update the Phytium-specific amdgpu driver handling for GEM mappings and TTM page management.
Bug Fixes:
Enhancements: