Repository navigation
Conversation
The KCL fallback for drm_prime_sg_to_dma_addr_array() calls drm_prime_sg_to_page_addr_arrays() to extract DMA addresses. Older implementations of drm_prime_sg_to_page_addr_arrays() walk each DMA address range using sg->length. This assumes that the physical and DMA views of a scatterlist have identical layouts. That assumption does not hold when DMA mapping merges entries or when ONLY the DMA view is valid. In such cases the fallback can leave DMA address entries unpopulated while still returning success. Use for_each_sg_dma_page() to walk the mapped entries directly. This uses sgt->nents and the DMA length of each entry, matching the semantics of the upstream drm_prime_sg_to_dma_addr_array() implementation. Tested on Linux 5.4.18 with an imported DMA-BUF whose mapped scatterlist provides the DMA view required by the importer. Fixes: faab963 ("drm/amdkcl: fake the drm_prime_sg_to_dma_addr_array") Signed-off-by: Jiaming Fan <fan.jiaming@hotmail.com>
|
@kentrussell This fixes the KCL fallback of |
|
Some context: we hit this while building on the amdgpu DKMS stack on a customer's 5.4.18 kernel. DMA-BUF sharing with an out-of-tree PowerVR driver failed on import, which we traced to this fallback. On compatibility: the fallback is only built on kernels < 5.12 without |
0db4a01 to
4319cc0
Compare
|
@kentrussell Sorry for the noise earlier: the branch had been based on a fork master that still carried 6 unrelated commits (SVM eviction and DCN vblank changes), which made this PR look like a 16-file change with conflicts. I have rebased it onto the current master. It is now a single commit touching only Since this is KCL-only and not applicable to amd-gfx, could you pull it into the internal dkms branch review, like #194? If you do see this, I'd really appreciate a reply either way, whether it's accepted or declined, so I know where it stands. Thanks. |
|
@kentrussell Could you help route this to the KCL team, or point me to the appropriate contact or submission channel for KCL-only fixes? I understand this repository is a mirror. Thanks. |
Motivation
The KCL fallback for
drm_prime_sg_to_dma_addr_array()callsdrm_prime_sg_to_page_addr_arrays()to extract DMA addresses.Older implementations of
drm_prime_sg_to_page_addr_arrays()walk each DMA address range usingsg->length. This assumes that the physical and DMA views of a scatterlist have identical layouts. That assumption does not hold when DMA mapping merges entries or when ONLY the DMA view is valid. In such cases the fallback can leave DMA address entries unpopulated while still returning success.Fixes: faab963 ("drm/amdkcl: fake the drm_prime_sg_to_dma_addr_array")
Technical Details
Use
for_each_sg_dma_page()to walk the mapped entries directly. This usessgt->nentsand the DMA length of each entry, matching the semantics of the upstreamdrm_prime_sg_to_dma_addr_array()implementation.Test Plan
Import a DMA-BUF whose mapped scatterlist provides the DMA view required by the importer on Linux 5.4.18.
Test Result
Before this change, the DMA address array was incomplete and the import failed. After this change, the expected DMA addresses were populated and the import succeeded
Submission Checklist