v3: Addressed Christian’s feedbacks from v2

Move BAR I/O mapping into TTM:

New helpers in amdgpu_ttm.c: amdgpu_ttm_mmio_remap_alloc_sgt() /
amdgpu_ttm_mmio_remap_free_sgt().  Export prototypes in amdgpu_ttm.h and
include it from amdgpu_dma_buf.c.

Stop doing offset calculations in dma-buf: Use amdgpu_res_cursor
(amdgpu_res_first/next) in the TTM helper to get start/size.  Compute
BAR phys as adev->rmmio_remap.bus_addr + start inside the helper.

Simplify dma-buf MMIO_REMAP path: amdgpu_dma_buf_map()/unmap() now just
call the TTM helpers.  Drop ad-hoc checks (e.g., resource->start,
size/page checks) from dma-buf per review; policy checks remain at
callers when needed.

Keep the mapping: Build a minimal 1-entry sg_table (sg_alloc_table(...,
1, ...)) with sg_set_page(NULL, ...) since this is BAR I/O (no struct
pages).  Map with dma_map_resource(..., DMA_ATTR_SKIP_CPU_SYNC); unmap
with dma_unmap_resource().

* Only compilation tested so far (x86_64, defconfig + amdgpu enabled).

Suggested-by: Christian König <[email protected]>
Suggested-by: Alex Deucher <[email protected]>
Cc: Christian König <[email protected]>
Cc: Alex Deucher <[email protected]>

Srinivasan Shanmugam (2):
  drm/amdgpu/ttm: Pin 4K MMIO_REMAP Singleton BO at Init
  drm/amdgpu: Map/Unmap MMIO_REMAP as BAR register window; add TTM sg
    helpers; wire dma-buf

 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c |  18 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c     | 106 ++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h     |   9 ++
 3 files changed, 133 insertions(+)


base-commit: 40f4510b661af74cd4b32b368747867c00ad7490
-- 
2.34.1

Reply via email to