Skip to content

Commit 815d091

Browse files
committed
nouveau/dispnv50: add cursor pitch check
The hardware needs a FB which is packed. Add checks to make sure this is the case. While at it, add debug logs for the existing checks. This allows user-space to more easily figure out why a configuration is rejected. v2: - Use drm_format_info instead of hardcoding bytes-per-pixel (Ilia) - Remove unnecessary size check (Ilia) v3: - Add missing newlines in debug messages (Lyude) - Use NV_ATOMIC (Lyude) - Add missing debug log for invalid format (Ilia) v4: add plane name in debug messages (Ilia) Signed-off-by: Simon Ser <[email protected]> Reviewed-by: Lyude Paul <[email protected]> Reviewed-by: Ilia Mirkin <[email protected]> Cc: Ben Skeggs <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 70d1ace commit 815d091

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

drivers/gpu/drm/nouveau/dispnv50/curs507a.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <nvhw/class/cl507a.h>
3030

3131
#include <drm/drm_atomic_helper.h>
32+
#include <drm/drm_fourcc.h>
3233

3334
bool
3435
curs507a_space(struct nv50_wndw *wndw)
@@ -99,6 +100,7 @@ curs507a_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
99100
{
100101
struct nouveau_drm *drm = nouveau_drm(wndw->plane.dev);
101102
struct nv50_head *head = nv50_head(asyw->state.crtc);
103+
struct drm_framebuffer *fb = asyw->state.fb;
102104
int ret;
103105

104106
ret = drm_atomic_helper_check_plane_state(&asyw->state, &asyh->state,
@@ -124,11 +126,30 @@ curs507a_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
124126
return -EINVAL;
125127
}
126128

129+
if (asyw->image.pitch[0] != asyw->image.w * fb->format->cpp[0]) {
130+
NV_ATOMIC(drm,
131+
"%s: invalid cursor image pitch: image must be packed (pitch = %d, width = %d)\n",
132+
wndw->plane.name, asyw->image.pitch[0], asyw->image.w);
133+
return -EINVAL;
134+
}
135+
127136
ret = head->func->curs_layout(head, asyw, asyh);
128-
if (ret)
137+
if (ret) {
138+
NV_ATOMIC(drm,
139+
"%s: invalid cursor image size: unsupported size %dx%d\n",
140+
wndw->plane.name, asyw->image.w, asyw->image.h);
141+
return ret;
142+
}
143+
144+
ret = head->func->curs_format(head, asyw, asyh);
145+
if (ret) {
146+
NV_ATOMIC(drm,
147+
"%s: invalid cursor image format 0x%X\n",
148+
wndw->plane.name, fb->format->format);
129149
return ret;
150+
}
130151

131-
return head->func->curs_format(head, asyw, asyh);
152+
return 0;
132153
}
133154

134155
static const u32

0 commit comments

Comments
 (0)