Skip to content

Commit 8047d36

Browse files
kwachowsjlawryno
authored andcommitted
accel/ivpu: Add debug prints for MMU map/unmap operations
It is common need to be able to see IOVA/physical to VPU addresses mappings. Especially when debugging different kind of memory related issues. Lack of such logs forces user to modify and recompile KMD manually. This commit adds those logs under MMU debug mask which can be turned on dynamically with module param during KMD load. Signed-off-by: Wachowski, Karol <[email protected]> Signed-off-by: Jacek Lawrynowicz <[email protected]> Reviewed-by: Jacek Lawrynowicz <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 929acfb commit 8047d36

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

drivers/accel/ivpu/ivpu_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#define IVPU_DBG_JSM BIT(10)
5757
#define IVPU_DBG_KREF BIT(11)
5858
#define IVPU_DBG_RPM BIT(12)
59+
#define IVPU_DBG_MMU_MAP BIT(13)
5960

6061
#define ivpu_err(vdev, fmt, ...) \
6162
drm_err(&(vdev)->drm, "%s(): " fmt, __func__, ##__VA_ARGS__)

drivers/accel/ivpu/ivpu_mmu_context.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ ivpu_mmu_context_map_sgt(struct ivpu_device *vdev, struct ivpu_mmu_context *ctx,
355355
dma_addr_t dma_addr = sg_dma_address(sg) - sg->offset;
356356
size_t size = sg_dma_len(sg) + sg->offset;
357357

358+
ivpu_dbg(vdev, MMU_MAP, "Map ctx: %u dma_addr: 0x%llx vpu_addr: 0x%llx size: %lu\n",
359+
ctx->id, dma_addr, vpu_addr, size);
360+
358361
ret = ivpu_mmu_context_map_pages(vdev, ctx, vpu_addr, dma_addr, size, prot);
359362
if (ret) {
360363
ivpu_err(vdev, "Failed to map context pages\n");
@@ -366,6 +369,7 @@ ivpu_mmu_context_map_sgt(struct ivpu_device *vdev, struct ivpu_mmu_context *ctx,
366369

367370
/* Ensure page table modifications are flushed from wc buffers to memory */
368371
wmb();
372+
369373
mutex_unlock(&ctx->lock);
370374

371375
ret = ivpu_mmu_invalidate_tlb(vdev, ctx->id);
@@ -388,14 +392,19 @@ ivpu_mmu_context_unmap_sgt(struct ivpu_device *vdev, struct ivpu_mmu_context *ct
388392
mutex_lock(&ctx->lock);
389393

390394
for_each_sgtable_dma_sg(sgt, sg, i) {
395+
dma_addr_t dma_addr = sg_dma_address(sg) - sg->offset;
391396
size_t size = sg_dma_len(sg) + sg->offset;
392397

398+
ivpu_dbg(vdev, MMU_MAP, "Unmap ctx: %u dma_addr: 0x%llx vpu_addr: 0x%llx size: %lu\n",
399+
ctx->id, dma_addr, vpu_addr, size);
400+
393401
ivpu_mmu_context_unmap_pages(ctx, vpu_addr, size);
394402
vpu_addr += size;
395403
}
396404

397405
/* Ensure page table modifications are flushed from wc buffers to memory */
398406
wmb();
407+
399408
mutex_unlock(&ctx->lock);
400409

401410
ret = ivpu_mmu_invalidate_tlb(vdev, ctx->id);

0 commit comments

Comments
 (0)