* [Nouveau] [PATCH v3] nouveau/dispnv50: add cursor pitch check
@ 2021-02-05 22:24 Simon Ser
2021-02-05 22:36 ` Ilia Mirkin
0 siblings, 1 reply; 4+ messages in thread
From: Simon Ser @ 2021-02-05 22:24 UTC (permalink / raw)
To: nouveau; +Cc: Ben Skeggs
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)
Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Ilia Mirkin <imirkin@alum.mit.edu>
---
drivers/gpu/drm/nouveau/dispnv50/curs507a.c | 31 +++++++++++++++++++--
1 file changed, 28 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
index 54fbd6fe751d..56459cfd037e 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
@@ -30,6 +30,7 @@
#include <drm/drm_atomic_helper.h>
#include <drm/drm_plane_helper.h>
+#include <drm/drm_fourcc.h>
bool
curs507a_space(struct nv50_wndw *wndw)
@@ -99,6 +100,8 @@ curs507a_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
struct nv50_head_atom *asyh)
{
struct nv50_head *head = nv50_head(asyw->state.crtc);
+ struct nouveau_drm *drm = nouveau_drm(head->base.base.dev);
+ struct drm_framebuffer *fb = asyw->state.fb;
int ret;
ret = drm_atomic_helper_check_plane_state(&asyw->state, &asyh->state,
@@ -109,14 +112,36 @@ curs507a_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
if (ret || !asyh->curs.visible)
return ret;
- if (asyw->image.w != asyw->image.h)
+ if (asyw->image.w != asyw->image.h) {
+ NV_ATOMIC(drm,
+ "Invalid cursor image size: width (%d) must match height (%d)\n",
+ asyw->image.w, asyw->image.h);
return -EINVAL;
+ }
+ if (asyw->image.pitch[0] != asyw->image.w * fb->format->cpp[0]) {
+ NV_ATOMIC(drm,
+ "Invalid cursor image pitch: image must be packed (pitch = %d, width = %d)\n",
+ asyw->image.pitch[0], asyw->image.w);
+ return -EINVAL;
+ }
ret = head->func->curs_layout(head, asyw, asyh);
- if (ret)
+ if (ret) {
+ NV_ATOMIC(drm,
+ "Invalid cursor image size: unsupported size %dx%d\n",
+ asyw->image.w, asyw->image.h);
+ return ret;
+ }
+
+ ret = head->func->curs_format(head, asyw, asyh);
+ if (ret) {
+ NV_ATOMIC(drm,
+ "Invalid cursor image format 0x%X\n",
+ fb->format->format);
return ret;
+ }
- return head->func->curs_format(head, asyw, asyh);
+ return 0;
}
static const u32
--
2.30.0
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Nouveau] [PATCH v3] nouveau/dispnv50: add cursor pitch check
2021-02-05 22:24 [Nouveau] [PATCH v3] nouveau/dispnv50: add cursor pitch check Simon Ser
@ 2021-02-05 22:36 ` Ilia Mirkin
2021-02-05 22:38 ` Lyude Paul
2021-02-05 22:38 ` Simon Ser
0 siblings, 2 replies; 4+ messages in thread
From: Ilia Mirkin @ 2021-02-05 22:36 UTC (permalink / raw)
To: Simon Ser; +Cc: nouveau, Ben Skeggs
On Fri, Feb 5, 2021 at 5:24 PM Simon Ser <contact@emersion.fr> wrote:
>
> 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)
>
> Signed-off-by: Simon Ser <contact@emersion.fr>
> Reviewed-by: Lyude Paul <lyude@redhat.com>
> Cc: Ben Skeggs <bskeggs@redhat.com>
> Cc: Ilia Mirkin <imirkin@alum.mit.edu>
> ---
> drivers/gpu/drm/nouveau/dispnv50/curs507a.c | 31 +++++++++++++++++++--
> 1 file changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
> index 54fbd6fe751d..56459cfd037e 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
> @@ -30,6 +30,7 @@
>
> #include <drm/drm_atomic_helper.h>
> #include <drm/drm_plane_helper.h>
> +#include <drm/drm_fourcc.h>
Why is this needed?
>
> bool
> curs507a_space(struct nv50_wndw *wndw)
> @@ -99,6 +100,8 @@ curs507a_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
> struct nv50_head_atom *asyh)
> {
> struct nv50_head *head = nv50_head(asyw->state.crtc);
> + struct nouveau_drm *drm = nouveau_drm(head->base.base.dev);
> + struct drm_framebuffer *fb = asyw->state.fb;
> int ret;
>
> ret = drm_atomic_helper_check_plane_state(&asyw->state, &asyh->state,
> @@ -109,14 +112,36 @@ curs507a_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
> if (ret || !asyh->curs.visible)
> return ret;
>
> - if (asyw->image.w != asyw->image.h)
> + if (asyw->image.w != asyw->image.h) {
> + NV_ATOMIC(drm,
> + "Invalid cursor image size: width (%d) must match height (%d)\n",
> + asyw->image.w, asyw->image.h);
Maybe keep with the style of the other NV_ATOMIC's, e.g. include %s:
at the beginning with wndw->plane.name as the value?
Either way,
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
> return -EINVAL;
> + }
> + if (asyw->image.pitch[0] != asyw->image.w * fb->format->cpp[0]) {
> + NV_ATOMIC(drm,
> + "Invalid cursor image pitch: image must be packed (pitch = %d, width = %d)\n",
> + asyw->image.pitch[0], asyw->image.w);
> + return -EINVAL;
> + }
>
> ret = head->func->curs_layout(head, asyw, asyh);
> - if (ret)
> + if (ret) {
> + NV_ATOMIC(drm,
> + "Invalid cursor image size: unsupported size %dx%d\n",
> + asyw->image.w, asyw->image.h);
> + return ret;
> + }
> +
> + ret = head->func->curs_format(head, asyw, asyh);
> + if (ret) {
> + NV_ATOMIC(drm,
> + "Invalid cursor image format 0x%X\n",
> + fb->format->format);
> return ret;
> + }
>
> - return head->func->curs_format(head, asyw, asyh);
> + return 0;
> }
>
> static const u32
> --
> 2.30.0
>
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Nouveau] [PATCH v3] nouveau/dispnv50: add cursor pitch check
2021-02-05 22:36 ` Ilia Mirkin
@ 2021-02-05 22:38 ` Lyude Paul
2021-02-05 22:38 ` Simon Ser
1 sibling, 0 replies; 4+ messages in thread
From: Lyude Paul @ 2021-02-05 22:38 UTC (permalink / raw)
To: Ilia Mirkin, Simon Ser; +Cc: nouveau, Ben Skeggs
On Fri, 2021-02-05 at 17:36 -0500, Ilia Mirkin wrote:
> On Fri, Feb 5, 2021 at 5:24 PM Simon Ser <contact@emersion.fr> wrote:
> >
> > 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)
> >
> > Signed-off-by: Simon Ser <contact@emersion.fr>
> > Reviewed-by: Lyude Paul <lyude@redhat.com>
> > Cc: Ben Skeggs <bskeggs@redhat.com>
> > Cc: Ilia Mirkin <imirkin@alum.mit.edu>
> > ---
> > drivers/gpu/drm/nouveau/dispnv50/curs507a.c | 31 +++++++++++++++++++--
> > 1 file changed, 28 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
> > b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
> > index 54fbd6fe751d..56459cfd037e 100644
> > --- a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
> > +++ b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
> > @@ -30,6 +30,7 @@
> >
> > #include <drm/drm_atomic_helper.h>
> > #include <drm/drm_plane_helper.h>
> > +#include <drm/drm_fourcc.h>
>
> Why is this needed?
>
> >
> > bool
> > curs507a_space(struct nv50_wndw *wndw)
> > @@ -99,6 +100,8 @@ curs507a_acquire(struct nv50_wndw *wndw, struct
> > nv50_wndw_atom *asyw,
> > struct nv50_head_atom *asyh)
> > {
> > struct nv50_head *head = nv50_head(asyw->state.crtc);
> > + struct nouveau_drm *drm = nouveau_drm(head->base.base.dev);
> > + struct drm_framebuffer *fb = asyw->state.fb;
> > int ret;
> >
> > ret = drm_atomic_helper_check_plane_state(&asyw->state, &asyh-
> > >state,
> > @@ -109,14 +112,36 @@ curs507a_acquire(struct nv50_wndw *wndw, struct
> > nv50_wndw_atom *asyw,
> > if (ret || !asyh->curs.visible)
> > return ret;
> >
> > - if (asyw->image.w != asyw->image.h)
> > + if (asyw->image.w != asyw->image.h) {
> > + NV_ATOMIC(drm,
> > + "Invalid cursor image size: width (%d) must match
> > height (%d)\n",
> > + asyw->image.w, asyw->image.h);
>
> Maybe keep with the style of the other NV_ATOMIC's, e.g. include %s:
> at the beginning with wndw->plane.name as the value?
Seconded on that - thanks for catching that!
>
> Either way,
>
> Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
>
> > return -EINVAL;
> > + }
> > + if (asyw->image.pitch[0] != asyw->image.w * fb->format->cpp[0]) {
> > + NV_ATOMIC(drm,
> > + "Invalid cursor image pitch: image must be packed
> > (pitch = %d, width = %d)\n",
> > + asyw->image.pitch[0], asyw->image.w);
> > + return -EINVAL;
> > + }
> >
> > ret = head->func->curs_layout(head, asyw, asyh);
> > - if (ret)
> > + if (ret) {
> > + NV_ATOMIC(drm,
> > + "Invalid cursor image size: unsupported size
> > %dx%d\n",
> > + asyw->image.w, asyw->image.h);
> > + return ret;
> > + }
> > +
> > + ret = head->func->curs_format(head, asyw, asyh);
> > + if (ret) {
> > + NV_ATOMIC(drm,
> > + "Invalid cursor image format 0x%X\n",
> > + fb->format->format);
> > return ret;
> > + }
> >
> > - return head->func->curs_format(head, asyw, asyh);
> > + return 0;
> > }
> >
> > static const u32
> > --
> > 2.30.0
> >
>
--
Sincerely,
Lyude Paul (she/her)
Software Engineer at Red Hat
Note: I deal with a lot of emails and have a lot of bugs on my plate. If you've
asked me a question, are waiting for a review/merge on a patch, etc. and I
haven't responded in a while, please feel free to send me another email to check
on my status. I don't bite!
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Nouveau] [PATCH v3] nouveau/dispnv50: add cursor pitch check
2021-02-05 22:36 ` Ilia Mirkin
2021-02-05 22:38 ` Lyude Paul
@ 2021-02-05 22:38 ` Simon Ser
1 sibling, 0 replies; 4+ messages in thread
From: Simon Ser @ 2021-02-05 22:38 UTC (permalink / raw)
To: Ilia Mirkin; +Cc: nouveau, Ben Skeggs
On Friday, February 5th, 2021 at 11:36 PM, Ilia Mirkin <imirkin@alum.mit.edu> wrote:
> > --- a/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
> > +++ b/drivers/gpu/drm/nouveau/dispnv50/curs507a.c
> > @@ -30,6 +30,7 @@
> >
> > #include <drm/drm_atomic_helper.h>
> > #include <drm/drm_plane_helper.h>
> > +#include <drm/drm_fourcc.h>
>
> Why is this needed?
This is needed for the definition of struct drm_format_info.
> > bool
> > curs507a_space(struct nv50_wndw *wndw)
> > @@ -99,6 +100,8 @@ curs507a_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
> > struct nv50_head_atom *asyh)
> > {
> > struct nv50_head *head = nv50_head(asyw->state.crtc);
> > + struct nouveau_drm *drm = nouveau_drm(head->base.base.dev);
> > + struct drm_framebuffer *fb = asyw->state.fb;
> > int ret;
> >
> > ret = drm_atomic_helper_check_plane_state(&asyw->state, &asyh->state,
> > @@ -109,14 +112,36 @@ curs507a_acquire(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw,
> > if (ret || !asyh->curs.visible)
> > return ret;
> >
> > - if (asyw->image.w != asyw->image.h)
> > + if (asyw->image.w != asyw->image.h) {
> > + NV_ATOMIC(drm,
> > + "Invalid cursor image size: width (%d) must match height (%d)\n",
> > + asyw->image.w, asyw->image.h);
>
> Maybe keep with the style of the other NV_ATOMIC's, e.g. include %s:
> at the beginning with wndw->plane.name as the value?
Good idea.
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-02-05 22:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-05 22:24 [Nouveau] [PATCH v3] nouveau/dispnv50: add cursor pitch check Simon Ser
2021-02-05 22:36 ` Ilia Mirkin
2021-02-05 22:38 ` Lyude Paul
2021-02-05 22:38 ` Simon Ser
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).