2021-01-19 05:42:05

by Lyude Paul

[permalink] [raw]
Subject: [PATCH 1/3] drivers/nouveau/kms/nv50-: Reject format modifiers for cursor planes

Nvidia hardware doesn't actually support using tiling formats with the
cursor plane, only linear is allowed. In the future, we should write a
testcase for this.

Fixes: c586f30bf74c ("drm/nouveau/kms: Add format mod prop to base/ovly/nvdisp")
Cc: James Jones <[email protected]>
Cc: Martin Peres <[email protected]>
Cc: Jeremy Cline <[email protected]>
Cc: Simon Ser <[email protected]>
Cc: <[email protected]> # v5.8+
Signed-off-by: Lyude Paul <[email protected]>
---
drivers/gpu/drm/nouveau/dispnv50/wndw.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
index ce451242f79e..271de3a63f21 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
@@ -702,6 +702,11 @@ nv50_wndw_init(struct nv50_wndw *wndw)
nvif_notify_get(&wndw->notify);
}

+static const u64 nv50_cursor_format_modifiers[] = {
+ DRM_FORMAT_MOD_LINEAR,
+ DRM_FORMAT_MOD_INVALID,
+};
+
int
nv50_wndw_new_(const struct nv50_wndw_func *func, struct drm_device *dev,
enum drm_plane_type type, const char *name, int index,
@@ -713,6 +718,7 @@ nv50_wndw_new_(const struct nv50_wndw_func *func, struct drm_device *dev,
struct nvif_mmu *mmu = &drm->client.mmu;
struct nv50_disp *disp = nv50_disp(dev);
struct nv50_wndw *wndw;
+ const u64 *format_modifiers;
int nformat;
int ret;

@@ -728,10 +734,13 @@ nv50_wndw_new_(const struct nv50_wndw_func *func, struct drm_device *dev,

for (nformat = 0; format[nformat]; nformat++);

- ret = drm_universal_plane_init(dev, &wndw->plane, heads, &nv50_wndw,
- format, nformat,
- nouveau_display(dev)->format_modifiers,
- type, "%s-%d", name, index);
+ if (type == DRM_PLANE_TYPE_CURSOR)
+ format_modifiers = nv50_cursor_format_modifiers;
+ else
+ format_modifiers = nouveau_display(dev)->format_modifiers;
+
+ ret = drm_universal_plane_init(dev, &wndw->plane, heads, &nv50_wndw, format, nformat,
+ format_modifiers, type, "%s-%d", name, index);
if (ret) {
kfree(*pwndw);
*pwndw = NULL;
--
2.29.2


2021-01-19 05:42:10

by Lyude Paul

[permalink] [raw]
Subject: [PATCH 3/3] drm/nouveau/kms/nve4-nv138: Fix > 64x64 cursors

While we do handle the additional cursor sizes introduced in NVE4, it looks
like we accidentally broke this when converting over to use Nvidia's
display headers. Since we now use NVVAL in dispnv50/head907d.c in order to
format the value for the cursor layout and NVD9 only had one byte reserved
vs. the 2 bytes reserved in later generations, we end up accidentally
stripping the second bit in the cursor layout format parameter - causing us
to set the wrong cursor size.

This fixes that by adding our own curs_set hook for 917d which uses the
NV917D headers.

Cc: Martin Peres <[email protected]>
Cc: Jeremy Cline <[email protected]>
Cc: Simon Ser <[email protected]>
Cc: <[email protected]> # v5.9+
Signed-off-by: Lyude Paul <[email protected]>
Fixes: ed0b86a90bf9 ("drm/nouveau/kms/nv50-: use NVIDIA's headers for core head_curs_set()")
---
drivers/gpu/drm/nouveau/dispnv50/head917d.c | 28 ++++++++++++++++++-
.../drm/nouveau/include/nvhw/class/cl917d.h | 4 +++
2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/head917d.c b/drivers/gpu/drm/nouveau/dispnv50/head917d.c
index a5d827403660..ea9f8667305e 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/head917d.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/head917d.c
@@ -22,6 +22,7 @@
#include "head.h"
#include "core.h"

+#include "nvif/push.h"
#include <nvif/push507c.h>

#include <nvhw/class/cl917d.h>
@@ -73,6 +74,31 @@ head917d_base(struct nv50_head *head, struct nv50_head_atom *asyh)
return 0;
}

+static int
+head917d_curs_set(struct nv50_head *head, struct nv50_head_atom *asyh)
+{
+ struct nvif_push *push = nv50_disp(head->base.base.dev)->core->chan.push;
+ const int i = head->base.index;
+ int ret;
+
+ ret = PUSH_WAIT(push, 5);
+ if (ret)
+ return ret;
+
+ PUSH_MTHD(push, NV917D, HEAD_SET_CONTROL_CURSOR(i),
+ NVDEF(NV917D, HEAD_SET_CONTROL_CURSOR, ENABLE, ENABLE) |
+ NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, FORMAT, asyh->curs.format) |
+ NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, SIZE, asyh->curs.layout) |
+ NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_X, 0) |
+ NVVAL(NV917D, HEAD_SET_CONTROL_CURSOR, HOT_SPOT_Y, 0) |
+ NVDEF(NV917D, HEAD_SET_CONTROL_CURSOR, COMPOSITION, ALPHA_BLEND),
+
+ HEAD_SET_OFFSET_CURSOR(i), asyh->curs.offset >> 8);
+
+ PUSH_MTHD(push, NV917D, HEAD_SET_CONTEXT_DMA_CURSOR(i), asyh->curs.handle);
+ return 0;
+}
+
int
head917d_curs_layout(struct nv50_head *head, struct nv50_wndw_atom *asyw,
struct nv50_head_atom *asyh)
@@ -101,7 +127,7 @@ head917d = {
.core_clr = head907d_core_clr,
.curs_layout = head917d_curs_layout,
.curs_format = head507d_curs_format,
- .curs_set = head907d_curs_set,
+ .curs_set = head917d_curs_set,
.curs_clr = head907d_curs_clr,
.base = head917d_base,
.ovly = head907d_ovly,
diff --git a/drivers/gpu/drm/nouveau/include/nvhw/class/cl917d.h b/drivers/gpu/drm/nouveau/include/nvhw/class/cl917d.h
index 2a2612d6e1e0..fb223723a38a 100644
--- a/drivers/gpu/drm/nouveau/include/nvhw/class/cl917d.h
+++ b/drivers/gpu/drm/nouveau/include/nvhw/class/cl917d.h
@@ -66,6 +66,10 @@
#define NV917D_HEAD_SET_CONTROL_CURSOR_COMPOSITION_ALPHA_BLEND (0x00000000)
#define NV917D_HEAD_SET_CONTROL_CURSOR_COMPOSITION_PREMULT_ALPHA_BLEND (0x00000001)
#define NV917D_HEAD_SET_CONTROL_CURSOR_COMPOSITION_XOR (0x00000002)
+#define NV917D_HEAD_SET_OFFSET_CURSOR(a) (0x00000484 + (a)*0x00000300)
+#define NV917D_HEAD_SET_OFFSET_CURSOR_ORIGIN 31:0
+#define NV917D_HEAD_SET_CONTEXT_DMA_CURSOR(a) (0x0000048C + (a)*0x00000300)
+#define NV917D_HEAD_SET_CONTEXT_DMA_CURSOR_HANDLE 31:0
#define NV917D_HEAD_SET_DITHER_CONTROL(a) (0x000004A0 + (a)*0x00000300)
#define NV917D_HEAD_SET_DITHER_CONTROL_ENABLE 0:0
#define NV917D_HEAD_SET_DITHER_CONTROL_ENABLE_DISABLE (0x00000000)
--
2.29.2

2021-01-19 05:44:01

by Lyude Paul

[permalink] [raw]
Subject: [PATCH 2/3] drm/nouveau/kms/nv50-: Report max cursor size to userspace

Cc: Martin Peres <[email protected]>
Cc: Jeremy Cline <[email protected]>
Cc: Simon Ser <[email protected]>
Signed-off-by: Lyude Paul <[email protected]>
---
drivers/gpu/drm/nouveau/dispnv50/disp.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index c6367035970e..5f4f09a601d4 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -2663,6 +2663,14 @@ nv50_display_create(struct drm_device *dev)
else
nouveau_display(dev)->format_modifiers = disp50xx_modifiers;

+ if (disp->disp->object.oclass >= GK104_DISP) {
+ dev->mode_config.cursor_width = 256;
+ dev->mode_config.cursor_height = 256;
+ } else {
+ dev->mode_config.cursor_width = 64;
+ dev->mode_config.cursor_height = 64;
+ }
+
/* create crtc objects to represent the hw heads */
if (disp->disp->object.oclass >= GV100_DISP)
crtcs = nvif_rd32(&device->object, 0x610060) & 0xff;
--
2.29.2

2021-01-19 11:20:11

by Simon Ser

[permalink] [raw]
Subject: Re: [PATCH 1/3] drivers/nouveau/kms/nv50-: Reject format modifiers for cursor planes

On Tuesday, January 19th, 2021 at 2:54 AM, Lyude Paul <[email protected]> wrote:

> Nvidia hardware doesn't actually support using tiling formats with the
> cursor plane, only linear is allowed. In the future, we should write a
> testcase for this.
>
> Fixes: c586f30bf74c ("drm/nouveau/kms: Add format mod prop to base/ovly/nvdisp")
> Cc: James Jones <[email protected]>
> Cc: Martin Peres <[email protected]>
> Cc: Jeremy Cline <[email protected]>
> Cc: Simon Ser <[email protected]>
> Cc: <[email protected]> # v5.8+
> Signed-off-by: Lyude Paul <[email protected]>

Together with [1], this patch allows me to run unpatched modifier-aware
user-space successfully, without a cursor visual glitch. drm_info
correctly reports the new modifier list, and wlroots logs confirm that
a flavor of NVIDIA_BLOCK_LINEAR_2D is used for the primary buffers and
LINEAR is used for cursor buffers.

Code looks good to me as well.

Reviewed-by: Simon Ser <[email protected]>

[1]: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3724

2021-01-19 11:31:24

by Simon Ser

[permalink] [raw]
Subject: Re: [PATCH 2/3] drm/nouveau/kms/nv50-: Report max cursor size to userspace

On Tuesday, January 19th, 2021 at 2:54 AM, Lyude Paul <[email protected]> wrote:

> Cc: Martin Peres <[email protected]>
> Cc: Jeremy Cline <[email protected]>
> Cc: Simon Ser <[email protected]>
> Signed-off-by: Lyude Paul <[email protected]>
> ---
> drivers/gpu/drm/nouveau/dispnv50/disp.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> index c6367035970e..5f4f09a601d4 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> @@ -2663,6 +2663,14 @@ nv50_display_create(struct drm_device *dev)
> else
> nouveau_display(dev)->format_modifiers = disp50xx_modifiers;
>
> + if (disp->disp->object.oclass >= GK104_DISP) {

I can confirm this works fine on GK208B. Tested with wlroots. I don't
have older cards to test, though.

Tested-by: Simon Ser <[email protected]>

> + dev->mode_config.cursor_width = 256;
> + dev->mode_config.cursor_height = 256;
> + } else {
> + dev->mode_config.cursor_width = 64;
> + dev->mode_config.cursor_height = 64;
> + }
> +
> /* create crtc objects to represent the hw heads */
> if (disp->disp->object.oclass >= GV100_DISP)
> crtcs = nvif_rd32(&device->object, 0x610060) & 0xff;
> --
> 2.29.2

2021-01-19 16:15:39

by James Jones

[permalink] [raw]
Subject: Re: [PATCH 1/3] drivers/nouveau/kms/nv50-: Reject format modifiers for cursor planes

Gah, yes, good catch.

Reviewed-by: James Jones <[email protected]>

On 1/18/21 5:54 PM, Lyude Paul wrote:
> Nvidia hardware doesn't actually support using tiling formats with the
> cursor plane, only linear is allowed. In the future, we should write a
> testcase for this.
>
> Fixes: c586f30bf74c ("drm/nouveau/kms: Add format mod prop to base/ovly/nvdisp")
> Cc: James Jones <[email protected]>
> Cc: Martin Peres <[email protected]>
> Cc: Jeremy Cline <[email protected]>
> Cc: Simon Ser <[email protected]>
> Cc: <[email protected]> # v5.8+
> Signed-off-by: Lyude Paul <[email protected]>
> ---
> drivers/gpu/drm/nouveau/dispnv50/wndw.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
> index ce451242f79e..271de3a63f21 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
> @@ -702,6 +702,11 @@ nv50_wndw_init(struct nv50_wndw *wndw)
> nvif_notify_get(&wndw->notify);
> }
>
> +static const u64 nv50_cursor_format_modifiers[] = {
> + DRM_FORMAT_MOD_LINEAR,
> + DRM_FORMAT_MOD_INVALID,
> +};
> +
> int
> nv50_wndw_new_(const struct nv50_wndw_func *func, struct drm_device *dev,
> enum drm_plane_type type, const char *name, int index,
> @@ -713,6 +718,7 @@ nv50_wndw_new_(const struct nv50_wndw_func *func, struct drm_device *dev,
> struct nvif_mmu *mmu = &drm->client.mmu;
> struct nv50_disp *disp = nv50_disp(dev);
> struct nv50_wndw *wndw;
> + const u64 *format_modifiers;
> int nformat;
> int ret;
>
> @@ -728,10 +734,13 @@ nv50_wndw_new_(const struct nv50_wndw_func *func, struct drm_device *dev,
>
> for (nformat = 0; format[nformat]; nformat++);
>
> - ret = drm_universal_plane_init(dev, &wndw->plane, heads, &nv50_wndw,
> - format, nformat,
> - nouveau_display(dev)->format_modifiers,
> - type, "%s-%d", name, index);
> + if (type == DRM_PLANE_TYPE_CURSOR)
> + format_modifiers = nv50_cursor_format_modifiers;
> + else
> + format_modifiers = nouveau_display(dev)->format_modifiers;
> +
> + ret = drm_universal_plane_init(dev, &wndw->plane, heads, &nv50_wndw, format, nformat,
> + format_modifiers, type, "%s-%d", name, index);
> if (ret) {
> kfree(*pwndw);
> *pwndw = NULL;
>

2021-01-19 17:36:55

by Ville Syrjälä

[permalink] [raw]
Subject: Re: [PATCH 1/3] drivers/nouveau/kms/nv50-: Reject format modifiers for cursor planes

On Mon, Jan 18, 2021 at 08:54:12PM -0500, Lyude Paul wrote:
> Nvidia hardware doesn't actually support using tiling formats with the
> cursor plane, only linear is allowed. In the future, we should write a
> testcase for this.

There are a couple of old modifier/format sanity tests here:
https://patchwork.freedesktop.org/series/46876/

Couple of things missing that now came to my mind:
- test setplane/etc. rejects unsupported formats/modifiers even if
addfb allowed them, exactly for the case where only a subset of
planes support something
- validate the IN_FORMATS blob harder, eg. make sure each modifier
listed there supports at least one format. IIRC this was busted on
a few drivers last year, dunno if they got fixed or not. Hmm,
actually since this is now using the pre-parsed stuff I guess we
should just stick an assert into igt_fill_plane_format_mod() where
the blob gets parsed

>
> Fixes: c586f30bf74c ("drm/nouveau/kms: Add format mod prop to base/ovly/nvdisp")
> Cc: James Jones <[email protected]>
> Cc: Martin Peres <[email protected]>
> Cc: Jeremy Cline <[email protected]>
> Cc: Simon Ser <[email protected]>
> Cc: <[email protected]> # v5.8+
> Signed-off-by: Lyude Paul <[email protected]>
> ---
> drivers/gpu/drm/nouveau/dispnv50/wndw.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
> index ce451242f79e..271de3a63f21 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
> @@ -702,6 +702,11 @@ nv50_wndw_init(struct nv50_wndw *wndw)
> nvif_notify_get(&wndw->notify);
> }
>
> +static const u64 nv50_cursor_format_modifiers[] = {
> + DRM_FORMAT_MOD_LINEAR,
> + DRM_FORMAT_MOD_INVALID,
> +};
> +
> int
> nv50_wndw_new_(const struct nv50_wndw_func *func, struct drm_device *dev,
> enum drm_plane_type type, const char *name, int index,
> @@ -713,6 +718,7 @@ nv50_wndw_new_(const struct nv50_wndw_func *func, struct drm_device *dev,
> struct nvif_mmu *mmu = &drm->client.mmu;
> struct nv50_disp *disp = nv50_disp(dev);
> struct nv50_wndw *wndw;
> + const u64 *format_modifiers;
> int nformat;
> int ret;
>
> @@ -728,10 +734,13 @@ nv50_wndw_new_(const struct nv50_wndw_func *func, struct drm_device *dev,
>
> for (nformat = 0; format[nformat]; nformat++);
>
> - ret = drm_universal_plane_init(dev, &wndw->plane, heads, &nv50_wndw,
> - format, nformat,
> - nouveau_display(dev)->format_modifiers,
> - type, "%s-%d", name, index);
> + if (type == DRM_PLANE_TYPE_CURSOR)
> + format_modifiers = nv50_cursor_format_modifiers;
> + else
> + format_modifiers = nouveau_display(dev)->format_modifiers;
> +
> + ret = drm_universal_plane_init(dev, &wndw->plane, heads, &nv50_wndw, format, nformat,
> + format_modifiers, type, "%s-%d", name, index);
> if (ret) {
> kfree(*pwndw);
> *pwndw = NULL;
> --
> 2.29.2
>
> _______________________________________________
> dri-devel mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Ville Syrj?l?
Intel

2021-02-23 14:44:15

by Alex Riesen

[permalink] [raw]
Subject: Re: [PATCH 2/3] drm/nouveau/kms/nv50-: Report max cursor size to userspace

Lyude Paul, Tue, Jan 19, 2021 02:54:13 +0100:
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> index c6367035970e..5f4f09a601d4 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> @@ -2663,6 +2663,14 @@ nv50_display_create(struct drm_device *dev)
> else
> nouveau_display(dev)->format_modifiers = disp50xx_modifiers;
>
> + if (disp->disp->object.oclass >= GK104_DISP) {
> + dev->mode_config.cursor_width = 256;
> + dev->mode_config.cursor_height = 256;
> + } else {
> + dev->mode_config.cursor_width = 64;
> + dev->mode_config.cursor_height = 64;
> + }
> +
> /* create crtc objects to represent the hw heads */
> if (disp->disp->object.oclass >= GV100_DISP)
> crtcs = nvif_rd32(&device->object, 0x610060) & 0xff;

This change broke X cursor in my setup, and reverting the commit restores it.

Dell Precision M4800, issue ~2014 with GK106GLM [Quadro K2100M] (rev a1).
libdrm 2.4.91-1 (Debian 10.8 stable).
There are no errors or warnings in Xorg logs nor in the kernel log.

Regards,
Alex

2021-02-23 15:00:02

by Ilia Mirkin

[permalink] [raw]
Subject: Re: [PATCH 2/3] drm/nouveau/kms/nv50-: Report max cursor size to userspace

On Tue, Feb 23, 2021 at 9:26 AM Alex Riesen
<[email protected]> wrote:
>
> Lyude Paul, Tue, Jan 19, 2021 02:54:13 +0100:
> > diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > index c6367035970e..5f4f09a601d4 100644
> > --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > @@ -2663,6 +2663,14 @@ nv50_display_create(struct drm_device *dev)
> > else
> > nouveau_display(dev)->format_modifiers = disp50xx_modifiers;
> >
> > + if (disp->disp->object.oclass >= GK104_DISP) {
> > + dev->mode_config.cursor_width = 256;
> > + dev->mode_config.cursor_height = 256;
> > + } else {
> > + dev->mode_config.cursor_width = 64;
> > + dev->mode_config.cursor_height = 64;
> > + }
> > +
> > /* create crtc objects to represent the hw heads */
> > if (disp->disp->object.oclass >= GV100_DISP)
> > crtcs = nvif_rd32(&device->object, 0x610060) & 0xff;
>
> This change broke X cursor in my setup, and reverting the commit restores it.
>
> Dell Precision M4800, issue ~2014 with GK106GLM [Quadro K2100M] (rev a1).
> libdrm 2.4.91-1 (Debian 10.8 stable).
> There are no errors or warnings in Xorg logs nor in the kernel log.

Hi Alex,

Could you confirm which ddx is driving the nvidia hw? You can find
this out by running "xrandr --listproviders", or also in the xorg log.

Thanks,

-ilia

2021-02-23 15:51:28

by Ilia Mirkin

[permalink] [raw]
Subject: Re: [PATCH 2/3] drm/nouveau/kms/nv50-: Report max cursor size to userspace

On Tue, Feb 23, 2021 at 10:36 AM Alex Riesen
<[email protected]> wrote:
>
> Ilia Mirkin, Tue, Feb 23, 2021 15:56:21 +0100:
> > On Tue, Feb 23, 2021 at 9:26 AM Alex Riesen <[email protected]> wrote:
> > > Lyude Paul, Tue, Jan 19, 2021 02:54:13 +0100:
> > > > diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > > > index c6367035970e..5f4f09a601d4 100644
> > > > --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > > > +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > > > @@ -2663,6 +2663,14 @@ nv50_display_create(struct drm_device *dev)
> > > > else
> > > > nouveau_display(dev)->format_modifiers = disp50xx_modifiers;
> > > >
> > > > + if (disp->disp->object.oclass >= GK104_DISP) {
> > > > + dev->mode_config.cursor_width = 256;
> > > > + dev->mode_config.cursor_height = 256;
> > > > + } else {
> > > > + dev->mode_config.cursor_width = 64;
> > > > + dev->mode_config.cursor_height = 64;
> > > > + }
> > > > +
> > > > /* create crtc objects to represent the hw heads */
> > > > if (disp->disp->object.oclass >= GV100_DISP)
> > > > crtcs = nvif_rd32(&device->object, 0x610060) & 0xff;
> > >
> > > This change broke X cursor in my setup, and reverting the commit restores it.
> > >
> > > Dell Precision M4800, issue ~2014 with GK106GLM [Quadro K2100M] (rev a1).
> > > libdrm 2.4.91-1 (Debian 10.8 stable).
> > > There are no errors or warnings in Xorg logs nor in the kernel log.
> >
> > Could you confirm which ddx is driving the nvidia hw? You can find
> > this out by running "xrandr --listproviders", or also in the xorg log.
>
> xrandr(1) does not seem to list much:
>
> $ xrandr --listproviders
> Providers: number : 1
> Provider 0: id: 0x48 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 4 outputs: 5 associated providers: 0 name:modesetting

Thanks - this is what I was looking for. name:modesetting, i.e. the
modesetting ddx driver.

I checked nouveau source, and it seems like it uses a 64x64 cursor no
matter what. Not sure what the modesetting ddx does.

I'd recommend using xf86-video-nouveau in any case, but some distros
have decided to explicitly force modesetting in preference of nouveau.
Oh well. (And regardless, the regression should be addressed somehow,
but it's also good to understand what the problem is.)

Can you confirm what the problem with the cursor is?

-ilia

2021-02-23 16:26:41

by Alex Riesen

[permalink] [raw]
Subject: Re: [PATCH 2/3] drm/nouveau/kms/nv50-: Report max cursor size to userspace

Alex Riesen, Tue, Feb 23, 2021 16:51:26 +0100:
> Ilia Mirkin, Tue, Feb 23, 2021 16:46:52 +0100:
> > I'd recommend using xf86-video-nouveau in any case, but some distros
>
> I would like try this out. Do you know how to force the xorg server to
> choose this driver instead of modesetting?

Found that myself (a Device section with Driver set to "nouveau"):

$ xrandr --listproviders
Providers: number : 1
Provider 0: id: 0x68 cap: 0x7, Source Output, Sink Output, Source Offload crtcs: 4 outputs: 5 associated providers: 0 name:nouveau

And yes, the cursor looks good in v5.11 even without reverting the commit.

2021-02-23 20:11:21

by Alex Riesen

[permalink] [raw]
Subject: Re: [PATCH 2/3] drm/nouveau/kms/nv50-: Report max cursor size to userspace

Ilia Mirkin, Tue, Feb 23, 2021 15:56:21 +0100:
> On Tue, Feb 23, 2021 at 9:26 AM Alex Riesen <[email protected]> wrote:
> > Lyude Paul, Tue, Jan 19, 2021 02:54:13 +0100:
> > > diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > > index c6367035970e..5f4f09a601d4 100644
> > > --- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > > +++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
> > > @@ -2663,6 +2663,14 @@ nv50_display_create(struct drm_device *dev)
> > > else
> > > nouveau_display(dev)->format_modifiers = disp50xx_modifiers;
> > >
> > > + if (disp->disp->object.oclass >= GK104_DISP) {
> > > + dev->mode_config.cursor_width = 256;
> > > + dev->mode_config.cursor_height = 256;
> > > + } else {
> > > + dev->mode_config.cursor_width = 64;
> > > + dev->mode_config.cursor_height = 64;
> > > + }
> > > +
> > > /* create crtc objects to represent the hw heads */
> > > if (disp->disp->object.oclass >= GV100_DISP)
> > > crtcs = nvif_rd32(&device->object, 0x610060) & 0xff;
> >
> > This change broke X cursor in my setup, and reverting the commit restores it.
> >
> > Dell Precision M4800, issue ~2014 with GK106GLM [Quadro K2100M] (rev a1).
> > libdrm 2.4.91-1 (Debian 10.8 stable).
> > There are no errors or warnings in Xorg logs nor in the kernel log.
>
> Could you confirm which ddx is driving the nvidia hw? You can find
> this out by running "xrandr --listproviders", or also in the xorg log.

xrandr(1) does not seem to list much:

$ xrandr --listproviders
Providers: number : 1
Provider 0: id: 0x48 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 4 outputs: 5 associated providers: 0 name:modesetting

I failed to find a DDX in Xorg.0.log. Both Xorg.0.log and dmesg can be seen here:

https://gist.github.com/ar-cetitec/68c27551d9a59b89dc73bffe0456bbef


2021-02-23 20:12:21

by Alex Riesen

[permalink] [raw]
Subject: Re: [PATCH 2/3] drm/nouveau/kms/nv50-: Report max cursor size to userspace

Ilia Mirkin, Tue, Feb 23, 2021 16:46:52 +0100:
> On Tue, Feb 23, 2021 at 10:36 AM Alex Riesen <[email protected]> wrote:
> > Ilia Mirkin, Tue, Feb 23, 2021 15:56:21 +0100:
> > > On Tue, Feb 23, 2021 at 9:26 AM Alex Riesen <[email protected]> wrote:
> > > >
> > > > This change broke X cursor in my setup, and reverting the commit restores it.
> > > >
> > > > Dell Precision M4800, issue ~2014 with GK106GLM [Quadro K2100M] (rev a1).
> > > > libdrm 2.4.91-1 (Debian 10.8 stable).
> > > > There are no errors or warnings in Xorg logs nor in the kernel log.
> > >
> > > Could you confirm which ddx is driving the nvidia hw? You can find
> > > this out by running "xrandr --listproviders", or also in the xorg log.
> >
> > xrandr(1) does not seem to list much:
> >
> > $ xrandr --listproviders
> > Providers: number : 1
> > Provider 0: id: 0x48 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 4 outputs: 5 associated providers: 0 name:modesetting
>
> Thanks - this is what I was looking for. name:modesetting, i.e. the
> modesetting ddx driver.
>
> I checked nouveau source, and it seems like it uses a 64x64 cursor no
> matter what. Not sure what the modesetting ddx does.
>
> I'd recommend using xf86-video-nouveau in any case, but some distros

I would like try this out. Do you know how to force the xorg server to
choose this driver instead of modesetting?

> have decided to explicitly force modesetting in preference of nouveau.
> Oh well. (And regardless, the regression should be addressed somehow,
> but it's also good to understand what the problem is.)
>
> Can you confirm what the problem with the cursor is?

The cursor looks stretched vertically over a bigger matrix, while missing some
lines and being wrapped over the bottom on top of that matrix.

2021-02-23 20:36:42

by Ilia Mirkin

[permalink] [raw]
Subject: Re: [PATCH 2/3] drm/nouveau/kms/nv50-: Report max cursor size to userspace

On Tue, Feb 23, 2021 at 11:23 AM Alex Riesen
<[email protected]> wrote:
>
> Alex Riesen, Tue, Feb 23, 2021 16:51:26 +0100:
> > Ilia Mirkin, Tue, Feb 23, 2021 16:46:52 +0100:
> > > I'd recommend using xf86-video-nouveau in any case, but some distros
> >
> > I would like try this out. Do you know how to force the xorg server to
> > choose this driver instead of modesetting?
>
> Found that myself (a Device section with Driver set to "nouveau"):
>
> $ xrandr --listproviders
> Providers: number : 1
> Provider 0: id: 0x68 cap: 0x7, Source Output, Sink Output, Source Offload crtcs: 4 outputs: 5 associated providers: 0 name:nouveau
>
> And yes, the cursor looks good in v5.11 even without reverting the commit.

FWIW it's not immediately apparent to me what grave error modesetting
is committing in setting the cursor. The logic looks perfectly
reasonable. It's not trying to be fancy with rendering the cursor/etc.

The one thing is that it's using drmModeSetCursor2 which sets the
hotspot at the same time. But internally inside nouveau I think it
should work out to the same thing. Perhaps setting the hotspot, or
something in that path, doesn't quite work for 256x256? [Again, no
clue what that might be.]

It might also be worthwhile just testing if the 256x256 cursor works
quite the way one would want. If you're interested, grab libdrm,
there's a test called 'modetest', which has an option to enable a
moving cursor (-c iirc). It's hard-coded to 64x64, so you'll have to
modify it there too (and probably change the pattern from plain gray
to any one of the other ones).

Cheers,

-ilia

2021-02-24 09:16:20

by Alex Riesen

[permalink] [raw]
Subject: Re: [PATCH 2/3] drm/nouveau/kms/nv50-: Report max cursor size to userspace

Ilia Mirkin, Tue, Feb 23, 2021 19:13:59 +0100:
> On Tue, Feb 23, 2021 at 11:23 AM Alex Riesen <[email protected]> wrote:
> >
> > $ xrandr --listproviders
> > Providers: number : 1
> > Provider 0: id: 0x68 cap: 0x7, Source Output, Sink Output, Source Offload crtcs: 4 outputs: 5 associated providers: 0 name:nouveau
> >
> > And yes, the cursor looks good in v5.11 even without reverting the commit.
>
> FWIW it's not immediately apparent to me what grave error modesetting
> is committing in setting the cursor. The logic looks perfectly
> reasonable. It's not trying to be fancy with rendering the cursor/etc.
>
> The one thing is that it's using drmModeSetCursor2 which sets the
> hotspot at the same time. But internally inside nouveau I think it
> should work out to the same thing. Perhaps setting the hotspot, or
> something in that path, doesn't quite work for 256x256? [Again, no
> clue what that might be.]
>
> It might also be worthwhile just testing if the 256x256 cursor works
> quite the way one would want. If you're interested, grab libdrm,
> there's a test called 'modetest', which has an option to enable a
> moving cursor (-c iirc). It's hard-coded to 64x64, so you'll have to
> modify it there too (and probably change the pattern from plain gray
> to any one of the other ones).

I am interested, so I did.

If I start the test without X running, the sprite of 256x256 cursor always
contained horizontal lines across it, both with commit reverted and vanilla
v5.11. Similarly, the 64x64 cursor has no lines across it in both kernels.

The test does not seem to work at all if there is an X server running (using
modesetting driver): modetest complained about permission denied to set the
mode, and just sits there, drawing nothing on the displays.
So I could not run the test in the environment of original problem.
Am I starting it correctly? Is the change in modetest.c correct?

$ ./modetest -c |grep '^[0-9]\|preferred'
85 86 connected LVDS-1 340x190 13 86
#0 1920x1080 60.01 1920 2010 2070 2226 1080 1086 1095 1142 152540 flags: phsync, nvsync; type: preferred, driver
87 89 connected DP-1 470x300 18 88, 89
#0 1680x1050 59.88 1680 1728 1760 1840 1050 1053 1059 1080 119000 flags: phsync, nvsync; type: preferred, driver
90 0 disconnected DP-2 0x0 0 91, 92
93 95 connected DP-3 520x320 10 94, 95
#0 1920x1200 59.95 1920 1968 2000 2080 1200 1203 1209 1235 154000 flags: phsync, nvsync; type: preferred, driver
96 0 disconnected VGA-1 0x0 0 97

$ ./modetest -s 85:1920x1080 -s 93:1920x1200 -s 87:1680x1050 -C
trying to open device 'i915'...failed
trying to open device 'amdgpu'...failed
trying to open device 'radeon'...failed
trying to open device 'nouveau'...done
setting mode 1920x1080-60.01Hz on connectors 85, crtc 50
starting cursor

cursor stopped

This is the change on top of 1225171b (master):

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index fc75383a..cdba7b4e 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -1730,14 +1730,14 @@ static void set_cursors(struct device *dev, struct pipe_arg *pipes, unsigned int
int ret;

/* maybe make cursor width/height configurable some day */
- uint32_t cw = 64;
- uint32_t ch = 64;
+ uint32_t cw = 256;
+ uint32_t ch = 256;

/* create cursor bo.. just using PATTERN_PLAIN as it has
* translucent alpha
*/
bo = bo_create(dev->fd, DRM_FORMAT_ARGB8888, cw, ch, handles, pitches,
- offsets, UTIL_PATTERN_PLAIN);
+ offsets, UTIL_PATTERN_SMPTE);
if (bo == NULL)
return;