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

2021-01-19 Thread James Jones

Gah, yes, good catch.

Reviewed-by: James Jones 

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 
Cc: Martin Peres 
Cc: Jeremy Cline 
Cc: Simon Ser 
Cc:  # v5.8+
Signed-off-by: Lyude Paul 
---
  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(>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 = >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, >plane, heads, _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, >plane, heads, _wndw, 
format, nformat,
+  format_modifiers, type, "%s-%d", name, 
index);
if (ret) {
kfree(*pwndw);
*pwndw = NULL;



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

2021-01-19 Thread Ville Syrjälä
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 
> Cc: Martin Peres 
> Cc: Jeremy Cline 
> Cc: Simon Ser 
> Cc:  # v5.8+
> Signed-off-by: Lyude Paul 
> ---
>  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(>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 = >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, >plane, heads, _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, >plane, heads, _wndw, 
> format, nformat,
> +format_modifiers, type, "%s-%d", name, 
> index);
>   if (ret) {
>   kfree(*pwndw);
>   *pwndw = NULL;
> -- 
> 2.29.2
> 
> ___
> dri-devel mailing list
> dri-de...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel


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

2021-01-19 Thread Simon Ser
On Tuesday, January 19th, 2021 at 2:54 AM, 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 
> Cc: Martin Peres 
> Cc: Jeremy Cline 
> Cc: Simon Ser 
> Cc:  # v5.8+
> Signed-off-by: Lyude Paul 

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 

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