Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/xe: fix devcoredump chunk alignmnent calculation

The device core dumps are copied in 1.5GB chunks, which leads to a
link-time error on 32-bit builds because of the 64-bit division not
getting trivially turned into mask and shift operations:

ERROR: modpost: "__moddi3" [drivers/gpu/drm/xe/xe.ko] undefined!

On top of this, I noticed that the ALIGN_DOWN() usage here cannot
work because that is only defined for power-of-two alignments.
Change ALIGN_DOWN into an explicit div_u64_rem() that avoids the
link error and hopefully produces the right results.

Doing a 1.5GB kvmalloc() does seem a bit suspicious as well, e.g.
this will clearly fail on any 32-bit platform and is also likely
to run out of memory on 64-bit systems under memory pressure, so
using a much smaller power-of-two chunk size might be a good idea
instead.

v2:
- Always call div_u64_rem (Matt)

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202504251238.JsNgFeFc-lkp@intel.com/
Fixes: c4a2e5f865b7 ("drm/xe: Add devcoredump chunking")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://lore.kernel.org/r/20250501012545.1045247-1-matthew.brost@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

authored by

Arnd Bergmann and committed by
Rodrigo Vivi
9c088a5c dba7d17d

+9 -4
+9 -4
drivers/gpu/drm/xe/xe_devcoredump.c
··· 177 177 struct xe_devcoredump *coredump = data; 178 178 struct xe_devcoredump_snapshot *ss; 179 179 ssize_t byte_copied; 180 + u32 chunk_offset; 181 + ssize_t new_chunk_position; 180 182 181 183 if (!coredump) 182 184 return -ENODEV; ··· 203 201 return 0; 204 202 } 205 203 204 + new_chunk_position = div_u64_rem(offset, 205 + XE_DEVCOREDUMP_CHUNK_MAX, 206 + &chunk_offset); 207 + 206 208 if (offset >= ss->read.chunk_position + XE_DEVCOREDUMP_CHUNK_MAX || 207 209 offset < ss->read.chunk_position) { 208 - ss->read.chunk_position = 209 - ALIGN_DOWN(offset, XE_DEVCOREDUMP_CHUNK_MAX); 210 + ss->read.chunk_position = new_chunk_position * 211 + XE_DEVCOREDUMP_CHUNK_MAX; 210 212 211 213 __xe_devcoredump_read(ss->read.buffer, 212 214 XE_DEVCOREDUMP_CHUNK_MAX, ··· 219 213 220 214 byte_copied = count < ss->read.size - offset ? count : 221 215 ss->read.size - offset; 222 - memcpy(buffer, ss->read.buffer + 223 - (offset % XE_DEVCOREDUMP_CHUNK_MAX), byte_copied); 216 + memcpy(buffer, ss->read.buffer + chunk_offset, byte_copied); 224 217 225 218 mutex_unlock(&coredump->lock); 226 219