drm/xe: Count dwords before allocating
authorLucas De Marchi <lucas.demarchi@intel.com>
Thu, 10 Jul 2025 20:33:47 +0000 (13:33 -0700)
committerLucas De Marchi <lucas.demarchi@intel.com>
Mon, 14 Jul 2025 20:20:02 +0000 (13:20 -0700)
commite4cb5823ba3e2668ef5c164898e2aa2c0ad73742
tree36b169e92e9418ed76651f2aa60eedb518d83641
parent76650bcf2ae49106a9164406c90feba4c3135763
drm/xe: Count dwords before allocating

The bb allocation in emit_wa_job() is wrong in 2 ways: first it's
allocating enough space for the 3DSTATE or hardcoding 4k depending on
the engine. In the first case it doesn't account for the WAs and in the
former it may not be sufficient. Secondly it's using the size instead of
number of dwords, causing the buffer to be 4x bigger than needed:
xe_bb_new() receives number of dwords as parameter and its declaration
was also not following its implementation.

Lastly, reword the debug message since it's not only about the LRC WAs
anymore as it also include the 3DSTATE for render.

While it's unlikely this is causing any real issue, let's calculate the
needed space and allocate just enough.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Link: https://lore.kernel.org/r/20250710-lrc-refactors-v2-2-a5e2ca03f6bd@intel.com
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
drivers/gpu/drm/xe/xe_bb.h
drivers/gpu/drm/xe/xe_gt.c