Skip to content

Commit 76824d2

Browse files
lumagRob Clark
authored andcommitted
drm/msm/snapshot: fix dumping of the unaligned regions
The snapshotting code internally aligns data segment to 16 bytes. This works fine for DPU code (where most of the regions are aligned), but fails for snapshotting of the DSI data (because DSI data region is shifted by 4 bytes). Fix the code by removing length alignment and by accurately printing last registers in the region. While reworking the code also fix the 16x memory overallocation in msm_disp_state_dump_regs(). Fixes: 9865948 ("drm/msm: add support to take dpu snapshot") Reported-by: Salendarsingh Gaud <sgaud@qti.qualcomm.com> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Patchwork: https://patchwork.freedesktop.org/patch/725449/ Message-ID: <20260516-msm-fix-dsi-dump-2-v2-1-9e49fb2d240e@oss.qualcomm.com> Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
1 parent 3392291 commit 76824d2

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "msm_disp_snapshot.h"
1111

12-
static void msm_disp_state_dump_regs(u32 **reg, u32 aligned_len, void __iomem *base_addr)
12+
static void msm_disp_state_dump_regs(u32 **reg, u32 len, void __iomem *base_addr)
1313
{
1414
u32 len_padded;
1515
u32 num_rows;
@@ -19,11 +19,11 @@ static void msm_disp_state_dump_regs(u32 **reg, u32 aligned_len, void __iomem *b
1919
void __iomem *end_addr;
2020
int i;
2121

22-
len_padded = aligned_len * REG_DUMP_ALIGN;
23-
num_rows = aligned_len / REG_DUMP_ALIGN;
22+
len_padded = round_up(len, REG_DUMP_ALIGN);
23+
num_rows = DIV_ROUND_UP(len, REG_DUMP_ALIGN);
2424

2525
addr = base_addr;
26-
end_addr = base_addr + aligned_len;
26+
end_addr = base_addr + len;
2727

2828
*reg = kvzalloc(len_padded, GFP_KERNEL);
2929
if (!*reg)
@@ -48,8 +48,8 @@ static void msm_disp_state_dump_regs(u32 **reg, u32 aligned_len, void __iomem *b
4848
static void msm_disp_state_print_regs(const u32 *dump_addr, u32 len,
4949
void __iomem *base_addr, struct drm_printer *p)
5050
{
51+
void __iomem *addr, *end_addr;
5152
int i;
52-
void __iomem *addr;
5353
u32 num_rows;
5454

5555
if (!dump_addr) {
@@ -58,6 +58,7 @@ static void msm_disp_state_print_regs(const u32 *dump_addr, u32 len,
5858
}
5959

6060
addr = base_addr;
61+
end_addr = base_addr + len;
6162
num_rows = len / REG_DUMP_ALIGN;
6263

6364
for (i = 0; i < num_rows; i++) {
@@ -67,6 +68,17 @@ static void msm_disp_state_print_regs(const u32 *dump_addr, u32 len,
6768
dump_addr[i * 4 + 2], dump_addr[i * 4 + 3]);
6869
addr += REG_DUMP_ALIGN;
6970
}
71+
72+
if (addr != end_addr) {
73+
drm_printf(p, "0x%lx : %08x",
74+
(unsigned long)(addr - base_addr),
75+
dump_addr[i * 4]);
76+
if (addr + 0x4 < end_addr)
77+
drm_printf(p, " %08x", dump_addr[i * 4 + 1]);
78+
if (addr + 0x8 < end_addr)
79+
drm_printf(p, " %08x", dump_addr[i * 4 + 2]);
80+
drm_printf(p, "\n");
81+
}
7082
}
7183

7284
void msm_disp_state_print(struct msm_disp_state *state, struct drm_printer *p)
@@ -185,7 +197,7 @@ void msm_disp_snapshot_add_block(struct msm_disp_state *disp_state, u32 len,
185197
va_end(va);
186198

187199
INIT_LIST_HEAD(&new_blk->node);
188-
new_blk->size = ALIGN(len, REG_DUMP_ALIGN);
200+
new_blk->size = len;
189201
new_blk->base_addr = base_addr;
190202

191203
msm_disp_state_dump_regs(&new_blk->state, new_blk->size, base_addr);

0 commit comments

Comments
 (0)