The layout of bits within the individual tiles (referred to as sectors in the DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D() macro) changed for some formats starting in Blackwell 2 GPUs. New format modifiers are needed to denote the difference and prevent direct sharing of these incompatible buffers with older GPUs.
This patch series proposes first adding some helper macros and inline functions to drm_fourcc.h to make the NVIDIA block-linear format modifiers easier to work with given the proposed solution makes them harder to parse, then extending the existing sector type field in the parametric format modifier macro DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D() by another bit to accommodate the new layout type. There are a few ways the parameteric format modifier definition could have been altered to handle the new layouts: -The GOB Height and Page Kind field has a reserved value that could have been used. However, the GOB height and page kind enums did not change relative to prior chips, so this is sort of a lie. However, this is the least-invasive change. -An entirely new field could have been added. This seems inappropriate given the presence of an existing appropriate field. The advantage here is it avoids splitting the sector layout field across two bitfields. The proposed approach is the logically consistent one, but has the downside of being the most complex, and that it causes the DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D() macro to evaluate its 's' parameter twice. However, I believe the added helper functions and macros address the complexity, and I have audited the relevant code and do not believe the double evaluation should cause any problems in practice. James Jones (4): drm: macros defining fields of NVIDIA modifiers drm: add inline helper funcs for NVIDIA modifiers drm/nouveau: use format modifier helper funcs drm: define NVIDIA DRM format modifiers for GB20x drivers/gpu/drm/nouveau/nouveau_display.c | 12 ++- include/uapi/drm/drm_fourcc.h | 100 ++++++++++++++++++---- 2 files changed, 92 insertions(+), 20 deletions(-) -- 2.49.0