modesetting: use single sized hw cursor buffer for older amdgpu gpus

Some amdgpu hardware (older ones, such as AMD Polaris 11 ) can only
render 64x64, 64x128 and 128x128 cursor. It doens't report any errors to
user space and only visual glitches on monitor visible.

This patch checks If drm driver reports any cursor side 64 or 128 - assume
hardware can only render 64x64 or 128x128 hw cursor planes

Fixes: https://gitlab.freedesktop.org/xorg/xserver/-/work_items/1922
Fixes: https://github.com/X11Libre/xserver/issues/1816

Signed-off-by: Tautvis <gtautvis@gmail.com>
This commit is contained in:
Tautvis 2026-09-26 23:22:04 +03:00 • committed by Enrico Weigelt
commit 46c411e49b
3 changed files with 57 additions and 0 deletions

View file

@ -1046,6 +1046,46 @@ ms_is_running_virtual_gpu(drmmode_ptr drmmode)
return false;
}
/**
* @brief ms_is_running_single_size_hwcursor_gpu
* reported https://gitlab.freedesktop.org/xorg/xserver/-/work_items/1922 hardware cursor on amdgpu is problematic too
* implying on report older amd hardware working correctly with only 128x128 and 64x128 cursor.
*
* until we collect which hardware is affected assume only single cursor size
* @param drmmode
*/
static inline void
probe_if_is_running_single_size_hwcursor_gpu(drmmode_ptr drmmode){
drmVersionPtr version = drmGetVersion(drmmode->fd);
bool borked_cursor = false;
if (strstr(version->name, "amdgpu")){
uint64_t cursor_width,cursor_height;
int ret1 = drmGetCap(drmmode->fd, DRM_CAP_CURSOR_WIDTH, &cursor_width);
int ret2 = drmGetCap(drmmode->fd, DRM_CAP_CURSOR_HEIGHT, &cursor_height);
if (ret1 || ret2){ /* lets fallback code deal with it */
drmmode->fixed_size_cursor = borked_cursor;
drmFreeVersion(version);
return;
}
/* assume only older gpu devices experience this problem */
if ( cursor_width == 64 || cursor_width == 128 ||
cursor_height == 64 || cursor_height == 128) {
borked_cursor = true;
}
}
drmFreeVersion(version);
drmmode->fixed_size_cursor = borked_cursor;
}
static void
FreeScreen(ScrnInfoPtr pScrn)
@ -1389,6 +1429,18 @@ PreInit(ScrnInfoPtr pScrn, int flags)
}
}
probe_if_is_running_single_size_hwcursor_gpu(&ms->drmmode);
if (ms->drmmode.fixed_size_cursor){
drmVersionPtr version = drmGetVersion(ms->drmmode.fd);
const char *name="N/A";
if (version){
name = version->name;
}
xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Forcing fixed hardware cursor on driver %s due to known issues\n", name);
drmFreeVersion(version);
}
try_enable_glamor(pScrn);
if (!ms->drmmode.glamor_gbm) {

View file

@ -4705,6 +4705,10 @@ static void drmmode_probe_cursor_size(xf86CrtcPtr crtc)
drmmode_crtc->cursor_probed = TRUE;
if (drmmode->fixed_size_cursor){
return;
}
xf86DrvMsg(crtc->scrn->scrnIndex, X_WARNING,
"Probing the cursor size using the old method\n");

View file

@ -96,6 +96,7 @@ typedef struct {
drmEventContext event_context;
struct gbm_bo *front_bo;
Bool sw_cursor;
Bool fixed_size_cursor;
Bool set_cursor_failed;
/* Broken-out options. */