From 2d24298af0188eafabc8e4553d100d330402ab10 Mon Sep 17 00:00:00 2001 From: Vedashree Vidwans Date: Mon, 1 Jun 2020 14:55:20 -0700 Subject: [PATCH] gpu: nvgpu: update nvgpu_pte_dbg_print function Currently, nvgpu_pte_dbg_print() overwrites ctag string "ctag=" and only prints ctag number. For example, nvgpu_pte_dbg_print:104 [DBG] vm=3 PTE: i=0 size=8 | GPU 0x1efc000000 phys 0x115a50000 pgsz: 4kb perm=RW kind=0x8 APT=SYSTEM C--V- 1 [0x08000010, 0x115a5007] Update nvgpu_pte_dbg_print function to include ctag string. nvgpu_pte_dbg_print:104 [DBG] vm=3 PTE: i=0 size=8 | GPU 0x1efc000000 phys 0x115a50000 pgsz: 4kb perm=RW kind=0x8 APT=SYSTEM C--V- ctag=1 [0x08000010, 0x115a5007] Jira NVGPU-5489 Change-Id: I2f84f89da685ad6a84534c0bb51e3ca1244b3497 Signed-off-by: Vedashree Vidwans Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2354182 Reviewed-by: Seema Khowala Reviewed-by: automaticguardword Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Deepak Nibade Reviewed-by: Alex Waterman Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: Seema Khowala Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/mm/gmmu/pte.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/nvgpu/common/mm/gmmu/pte.c b/drivers/gpu/nvgpu/common/mm/gmmu/pte.c index 9af8dc512..870e137ff 100644 --- a/drivers/gpu/nvgpu/common/mm/gmmu/pte.c +++ b/drivers/gpu/nvgpu/common/mm/gmmu/pte.c @@ -79,10 +79,24 @@ void nvgpu_pte_dbg_print(struct gk20a *g, const char *aperture_str = nvgpu_aperture_str(attrs->aperture); const char *perm_str = nvgpu_gmmu_perm_str(attrs->rw_flag); #ifdef CONFIG_NVGPU_COMPRESSION - u32 ctag = nvgpu_safe_cast_u64_to_u32(attrs->ctag / + u64 ctag_tmp = attrs->ctag; + u32 str_len = 0U; + u32 ctag_num = 0U; + + /* + * attrs->ctag is incremented to count current page size as well. + * Subtract to get this page's ctag line number. + */ + if (ctag_tmp != 0ULL) { + ctag_tmp = nvgpu_safe_sub_u64(ctag_tmp, page_size); + } + + ctag_num = nvgpu_safe_cast_u64_to_u32(ctag_tmp / g->ops.fb.compression_page_size(g)); - (void)strcpy(ctag_str, "ctag=0x"); - (void)nvgpu_strnadd_u32(ctag_str, ctag, (u32)strlen(ctag_str), 10U); + (void)strcpy(ctag_str, "ctag=0x\0"); + str_len = (u32)strlen(ctag_str); + (void)nvgpu_strnadd_u32(ctag_str + str_len, ctag_num, + nvgpu_safe_sub_u32(31U, str_len), 16U); #endif (void)map_attrs_to_str(attrs_str, attrs); pte_dbg(g, attrs,