summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/nouveau/dispnv50
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2021-02-06 01:41:40 +0300
committerSimon Ser <contact@emersion.fr>2023-07-10 10:45:47 +0300
commit815d091f90e170406bcef9aafc4ca434de206765 (patch)
tree7bb26b3e04e572bddf37b74ab56fdaca265b29c4 /drivers/gpu/drm/nouveau/dispnv50
parent70d1ace56db6c79d39dbe9c0d5244452b67e2fde (diff)
downloadlinux-815d091f90e170406bcef9aafc4ca434de206765.tar.xz
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 <contact@emersion.fr> Reviewed-by: Lyude Paul <lyude@redhat.com> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu> Cc: Ben Skeggs <bskeggs@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210205224140.28174-1-contact@emersion.fr
Diffstat (limited to 'drivers/gpu/drm/nouveau/dispnv50')
-rw-r--r--drivers/gpu/drm/nouveau/dispnv50/curs507a.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
index 78ee32da01c8..a95ee5dcc2e3 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
@@ -29,6 +29,7 @@
#include <nvhw/class/cl507a.h>
#include <drm/drm_atomic_helper.h>
+#include <drm/drm_fourcc.h>
bool
curs507a_space(struct nv50_wndw *wndw)
@@ -99,6 +100,7 @@ curs507a_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
{
struct nouveau_drm *drm = nouveau_drm(wndw->plane.dev);
struct nv50_head *head = nv50_head(asyw->state.crtc);
+ struct drm_framebuffer *fb = asyw->state.fb;
int ret;
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,
return -EINVAL;
}
+ if (asyw->image.pitch[0] != asyw->image.w * fb->format->cpp[0]) {
+ NV_ATOMIC(drm,
+ "%s: invalid cursor image pitch: image must be packed (pitch = %d, width = %d)\n",
+ wndw->plane.name, asyw->image.pitch[0], asyw->image.w);
+ return -EINVAL;
+ }
+
ret = head->func->curs_layout(head, asyw, asyh);
- if (ret)
+ if (ret) {
+ NV_ATOMIC(drm,
+ "%s: invalid cursor image size: unsupported size %dx%d\n",
+ wndw->plane.name, asyw->image.w, asyw->image.h);
+ return ret;
+ }
+
+ ret = head->func->curs_format(head, asyw, asyh);
+ if (ret) {
+ NV_ATOMIC(drm,
+ "%s: invalid cursor image format 0x%X\n",
+ wndw->plane.name, fb->format->format);
return ret;
+ }
- return head->func->curs_format(head, asyw, asyh);
+ return 0;
}
static const u32