[git pull] vmwgfx-fixes-5.9

2020-09-29 Thread Roland Scheidegger (VMware)
Dave, Daniel

One important fix for recent breakage.

The following changes since commit a1b8638ba1320e6684aa98233c15255eb803fac7:

  Linux 5.9-rc7 (2020-09-27 14:38:10 -0700)

are available in the Git repository at:

  git://people.freedesktop.org/~sroland/linux vmwgfx-fixes-5.9

for you to fetch changes up to f54c4442893b8dfbd3aff8e903c54dfff1aef990:

  drm/vmwgfx: Fix error handling in get_node (2020-09-30 05:44:28 +0200)


Zack Rusin (1):
  drm/vmwgfx: Fix error handling in get_node

 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_thp.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/vmwgfx: Fix error handling in get_node

2020-09-29 Thread Roland Scheidegger (VMware)
From: Zack Rusin 

ttm_mem_type_manager_func.get_node was changed to return -ENOSPC
instead of setting the node pointer to NULL. Unfortunately
vmwgfx still had two places where it was explicitly converting
-ENOSPC to 0 causing regressions. This fixes those spots by
allowing -ENOSPC to be returned. That seems to fix recent
regressions with vmwgfx.

Signed-off-by: Zack Rusin 
Reviewed-by: Roland Scheidegger 
Reviewed-by: Martin Krastev 
Sigend-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_thp.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
index 4a76fc7114ad..f8bdd4ea294a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
@@ -55,7 +55,7 @@ static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager 
*man,
 
id = ida_alloc_max(>gmr_ida, gman->max_gmr_ids - 1, GFP_KERNEL);
if (id < 0)
-   return (id != -ENOMEM ? 0 : id);
+   return id;
 
spin_lock(>lock);
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
index b7c816ba7166..c8b9335bccd8 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_thp.c
@@ -95,7 +95,7 @@ static int vmw_thp_get_node(struct ttm_mem_type_manager *man,
mem->start = node->start;
}
 
-   return 0;
+   return ret;
 }
 
 
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[git pull] vmwgfx-next-5.9

2020-08-11 Thread Roland Scheidegger (VMware)
Dave, Daniel,

vmwgfx fixes pull for 5.9.
The drm_mode_config_reset patches are very important fixing a recently
introduced kernel crash, the others fix various older issues which are
a bit less serious in practice.
(Although still pending a solution for the other crash introduced by
2ddef17678bc2ea1d20517dd2b4ed4aa967ffa8b.)

The following changes since commit dc100bc8fae59aafd2ea2e1a1a43ef1f65f8a8bc:

  Merge tag 'drm-msm-next-2020-07-30' of https://gitlab.freedesktop.org/drm/msm 
into drm-next (2020-08-05 08:05:31 +1000)

are available in the Git repository at:

  git://people.freedesktop.org/~sroland/linux vmwgfx-next-5.9

for you to fetch changes up to e97644ebcdc83854e6e29e96285b25042445c28c:

  drm/vmwgfx: fix spelling mistake "Cant" -> "Can't" (2020-08-11 03:16:03 +0200)


Colin Ian King (2):
  drm/vmwgfx: fix spelling mistake "Cound" -> "Could"
  drm/vmwgfx: fix spelling mistake "Cant" -> "Can't"

Dan Carpenter (2):
  drm/vmwgfx: Use correct vmw_legacy_display_unit pointer
  drm/vmwgfx: Fix two list_for_each loop exit tests

Daniel Vetter (1):
  drm/vmwgfx/stdu: Use drm_mode_config_reset

Gustavo A. R. Silva (1):
  drm/vmwgfx: Use struct_size() helper

Roland Scheidegger (2):
  drm/vmwgfx/sou: Use drm_mode_config_reset
  drm/vmwgfx/ldu: Use drm_mode_config_reset

 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 10 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | 13 -
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c|  9 ++---
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c|  9 ++---
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c |  2 +-
 6 files changed, 15 insertions(+), 30 deletions(-)
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/2] drm/vmwgfx/ldu: Use drm_mode_config_reset

2020-08-10 Thread Roland Scheidegger (VMware)
From: Roland Scheidegger 

Same problem as in stdu, same fix.

Fixes: 51f644b40b4b ("drm/atomic-helper: reset vblank on crtc reset")
Acked-by: Charmaine Lee 
Reviewed-by: Zack Rusin 
Signed-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
index 009f1742bed5..c4017c7a24db 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
@@ -387,8 +387,6 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, 
unsigned unit)
ldu->base.is_implicit = true;
 
/* Initialize primary plane */
-   vmw_du_plane_reset(primary);
-
ret = drm_universal_plane_init(dev, >base.primary,
   0, _ldu_plane_funcs,
   vmw_primary_plane_formats,
@@ -402,8 +400,6 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, 
unsigned unit)
drm_plane_helper_add(primary, _ldu_primary_plane_helper_funcs);
 
/* Initialize cursor plane */
-   vmw_du_plane_reset(cursor);
-
ret = drm_universal_plane_init(dev, >base.cursor,
0, _ldu_cursor_funcs,
vmw_cursor_plane_formats,
@@ -417,7 +413,6 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, 
unsigned unit)
 
drm_plane_helper_add(cursor, _ldu_cursor_plane_helper_funcs);
 
-   vmw_du_connector_reset(connector);
ret = drm_connector_init(dev, connector, _legacy_connector_funcs,
 DRM_MODE_CONNECTOR_VIRTUAL);
if (ret) {
@@ -445,7 +440,6 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, 
unsigned unit)
goto err_free_encoder;
}
 
-   vmw_du_crtc_reset(crtc);
ret = drm_crtc_init_with_planes(dev, crtc, >base.primary,
>base.cursor,
_legacy_crtc_funcs, NULL);
@@ -520,6 +514,8 @@ int vmw_kms_ldu_init_display(struct vmw_private *dev_priv)
 
dev_priv->active_display_unit = vmw_du_legacy;
 
+   drm_mode_config_reset(dev);
+
DRM_INFO("Legacy Display Unit initialized\n");
 
return 0;
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/2] drm/vmwgfx/sou: Use drm_mode_config_reset

2020-08-10 Thread Roland Scheidegger (VMware)
From: Roland Scheidegger 

Same problem as in stdu, same fix.

Fixes: 51f644b40b4b ("drm/atomic-helper: reset vblank on crtc reset")
Acked-by: Charmaine Lee 
Reviewed-by: Zack Rusin 
Signed-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
index 32a22e4eddb1..4bf0f5ec4fc2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
@@ -859,8 +859,6 @@ static int vmw_sou_init(struct vmw_private *dev_priv, 
unsigned unit)
sou->base.is_implicit = false;
 
/* Initialize primary plane */
-   vmw_du_plane_reset(primary);
-
ret = drm_universal_plane_init(dev, >base.primary,
   0, _sou_plane_funcs,
   vmw_primary_plane_formats,
@@ -875,8 +873,6 @@ static int vmw_sou_init(struct vmw_private *dev_priv, 
unsigned unit)
drm_plane_enable_fb_damage_clips(primary);
 
/* Initialize cursor plane */
-   vmw_du_plane_reset(cursor);
-
ret = drm_universal_plane_init(dev, >base.cursor,
0, _sou_cursor_funcs,
vmw_cursor_plane_formats,
@@ -890,7 +886,6 @@ static int vmw_sou_init(struct vmw_private *dev_priv, 
unsigned unit)
 
drm_plane_helper_add(cursor, _sou_cursor_plane_helper_funcs);
 
-   vmw_du_connector_reset(connector);
ret = drm_connector_init(dev, connector, _sou_connector_funcs,
 DRM_MODE_CONNECTOR_VIRTUAL);
if (ret) {
@@ -918,8 +913,6 @@ static int vmw_sou_init(struct vmw_private *dev_priv, 
unsigned unit)
goto err_free_encoder;
}
 
-
-   vmw_du_crtc_reset(crtc);
ret = drm_crtc_init_with_planes(dev, crtc, >base.primary,
>base.cursor,
_screen_object_crtc_funcs, NULL);
@@ -973,6 +966,8 @@ int vmw_kms_sou_init_display(struct vmw_private *dev_priv)
 
dev_priv->active_display_unit = vmw_du_screen_object;
 
+   drm_mode_config_reset(dev);
+
DRM_INFO("Screen Objects Display Unit initialized\n");
 
return 0;
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[git pull] vmwgfx-fixes-5.8

2020-07-15 Thread Roland Scheidegger (VMware)
Dave, Daniel,

vmwgfx-fixes pull for 5.8.
Just one fix for now, but it's a really important one, causing black
screens in VMs (sometimes on boot), hence marking it for stable.

The following changes since commit 1f054fd26e29784d373c3d29c348ee48f1c41fb2:

  drm/vmwgfx: fix update of display surface when resolution changes (2020-07-14 
04:05:52 +0200)

are available in the Git repository at:

  git://people.freedesktop.org/~sroland/linux vmwgfx-fixes-5.8

for you to fetch changes up to 1f054fd26e29784d373c3d29c348ee48f1c41fb2:

  drm/vmwgfx: fix update of display surface when resolution changes (2020-07-14 
04:05:52 +0200)


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/vmwgfx: fix update of display surface when resolution changes

2020-07-13 Thread Roland Scheidegger (VMware)
From: Roland Scheidegger 

The assignment of metadata overwrote the new display resolution values,
hence we'd miss the size actually changed and wouldn't redefine the
surface. This would then lead to command buffer error when trying to
update the screen target (due to the size mismatch), and result in a
VM with black screen.

Fixes: 504901dbb0b5 ("drm/vmwgfx: Refactor surface_define to use 
vmw_surface_metadata")
Reviewed-by: Charmaine Lee 
Signed-off-by: Roland Scheidegger 
Cc: sta...@vger.kernel.org
---
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
index 9ffa9c75a5da..16b385629688 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
@@ -1069,10 +1069,6 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane 
*plane,
if (new_content_type != SAME_AS_DISPLAY) {
struct vmw_surface_metadata metadata = {0};
 
-   metadata.base_size.width = hdisplay;
-   metadata.base_size.height = vdisplay;
-   metadata.base_size.depth = 1;
-
/*
 * If content buffer is a buffer object, then we have to
 * construct surface info
@@ -1104,6 +1100,10 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane 
*plane,
metadata = new_vfbs->surface->metadata;
}
 
+   metadata.base_size.width = hdisplay;
+   metadata.base_size.height = vdisplay;
+   metadata.base_size.depth = 1;
+
if (vps->surf) {
struct drm_vmw_size cur_base_size =
vps->surf->metadata.base_size;
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[git pull] vmwgfx-fixes-5.7

2020-05-15 Thread Roland Scheidegger (VMware)
Dave, Daniel

Some minor fixes and a maintainer change.

The following changes since commit 24085f70a6e1b0cb647ec92623284641d8270637:

  Merge tag 'trace-v5.7-rc4' of 
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace (2020-05-12 
11:06:26 -0700)

are available in the Git repository at:

  git+ssh://srol...@people.freedesktop.org/~sroland/linux vmwgfx-fixes-5.7

for you to fetch changes up to 80542002ccd41f3703a9ae9e8e95cfbaad370db6:

  drm/vmwgfx: Return true in function vmw_fence_obj_signaled() (2020-05-16 
06:50:37 +0200)


Colin Ian King (1):
  drm/vmwgfx: remove redundant assignment to variable ret

Guixiong Wei (1):
  drm/vmwgfx: Fix parameter name in vmw_bo_init

Jason Yan (1):
  drm/vmwgfx: Return true in function vmw_fence_obj_signaled()

Roland Scheidegger (1):
  drm/vmwgfx: update MAINTAINERS entry

 MAINTAINERS | 4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.c   | 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[git pull] feature/staging_sm5

2020-03-23 Thread Roland Scheidegger (VMware)
Dave, Daniel,

vmwgfx pull for for 5.7. Needed for GL4 functionality.
Sync up device headers, add support for new commands, code
refactoring around surface definition.

Preliminary mesa userspace code using these new vmwgfx features
can be found at: https://gitlab.freedesktop.org/bhenden/mesa

v2: use more appropriate repo, rebased

The following changes since commit cb7adfd6ad12a11902ebe374bec7fd4efa2cec1c:

  Merge tag 'mediatek-drm-next-5.7' of 
https://github.com/ckhu-mediatek/linux.git-tags into drm-next (2020-03-20 
13:08:38 +1000)

are available in the Git repository at:

  git://people.freedesktop.org/~sroland/linux feature/staging_sm5

for you to fetch changes up to f59e61acececc5f25313252da178a5c5eba568bd:

  drm/vmwgfx: Use vmwgfx version 2.18 to signal SM5 compatibility (2020-03-23 
22:48:57 +0100)


Deepak Rawat (16):
  drm/vmwgfx: Also check for SVGA_CAP_DX before reading DX context support
  drm/vmwgfx: Sync legacy multisampling device capability
  drm/vmwgfx: Deprecate logic ops commands
  drm/vmwgfx: Use enum to represent graphics context capabilities
  drm/vmwgfx: Sync virtual device headers for new feature
  drm/vmwgfx: Add a new enum for SM5 graphics context capability
  drm/vmwgfx: Read new register for GB memory when available
  drm/vmwgfx: Support SM5 shader type in command buffer
  drm/vmwgfx: Add support for UA view commands
  drm/vmwgfx: Add support for indirect and dispatch commands
  drm/vmwgfx: Rename stream output target binding tracker struct
  drm/vmwgfx: Add support for streamoutput with mob commands
  drm/vmwgfx: Split surface metadata from struct vmw_surface
  drm/vmwgfx: Refactor surface_define to use vmw_surface_metadata
  drm/vmwgfx: Add surface define v4 command
  drm/vmwgfx: Add SM5 param for userspace

Thomas Hellström (VMware) (1):
  drm/vmwgfx: Use vmwgfx version 2.18 to signal SM5 compatibility

 drivers/gpu/drm/vmwgfx/Makefile|   2 +-
 drivers/gpu/drm/vmwgfx/device_include/svga3d_cmd.h | 161 -
 .../gpu/drm/vmwgfx/device_include/svga3d_devcaps.h | 787 +++--
 drivers/gpu/drm/vmwgfx/device_include/svga3d_dx.h  | 466 +++-
 .../gpu/drm/vmwgfx/device_include/svga3d_limits.h  |  36 +-
 .../drm/vmwgfx/device_include/svga3d_surfacedefs.h |  58 +-
 .../gpu/drm/vmwgfx/device_include/svga3d_types.h   | 347 +++--
 drivers/gpu/drm/vmwgfx/device_include/svga_reg.h   | 382 +++---
 drivers/gpu/drm/vmwgfx/device_include/svga_types.h |   1 +
 drivers/gpu/drm/vmwgfx/vmwgfx_binding.c| 213 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_binding.h|  33 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_context.c|  28 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c|   6 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c|  59 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h| 140 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c| 429 ++-
 drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c  |  18 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c|  43 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_mob.c|   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_so.c |  12 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_so.h |   7 +
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c   |  61 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c   | 387 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c| 608 
 include/uapi/drm/vmwgfx_drm.h  |  16 +-
 25 files changed, 3252 insertions(+), 1050 deletions(-)
 create mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 17/17] drm/vmwgfx: Use vmwgfx version 2.18 to signal SM5 compatibility

2020-03-23 Thread Roland Scheidegger (VMware)
From: Thomas Hellström (VMware) 

Signed-off-by: Thomas Hellström (VMware) 
Reviewed-by: Charmaine Lee 
Reviewed-by: Brian Paul 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
___
v2: Use 2.18 instead of 2.17
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 0447be87697e..5ddbcb9f6df4 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -58,7 +58,7 @@
 #define VMWGFX_DRIVER_NAME "vmwgfx"
 #define VMWGFX_DRIVER_DATE "20200114"
 #define VMWGFX_DRIVER_MAJOR 2
-#define VMWGFX_DRIVER_MINOR 17
+#define VMWGFX_DRIVER_MINOR 18
 #define VMWGFX_DRIVER_PATCHLEVEL 0
 #define VMWGFX_FIFO_STATIC_SIZE (1024*1024)
 #define VMWGFX_MAX_RELOCATIONS 2048
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 12/17] drm/vmwgfx: Add support for streamoutput with mob commands

2020-03-23 Thread Roland Scheidegger (VMware)
From: Deepak Rawat 

With SM5 capability a new version of streamoutput is supported by device
which need backing mob and a new field. With this change the new command
is supported in command buffer.

v2: Also track streamoutput context binding in binding manager.

v3: Track only one streamoutput as only one can be set to context.
v4: Fix comment typos

Signed-off-by: Deepak Rawat 
Signed-off-by: Neha Bhende 
Reviewed-by: Thomas Hellström (VMware) 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/Makefile  |   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_binding.c  |  39 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_binding.h  |  11 +
 drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c  |   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h  |  22 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c  | 173 -
 drivers/gpu/drm/vmwgfx/vmwgfx_so.h   |   1 +
 drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c | 387 +++
 8 files changed, 630 insertions(+), 7 deletions(-)
 create mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c

diff --git a/drivers/gpu/drm/vmwgfx/Makefile b/drivers/gpu/drm/vmwgfx/Makefile
index c877a21a0739..5c3515e8cce1 100644
--- a/drivers/gpu/drm/vmwgfx/Makefile
+++ b/drivers/gpu/drm/vmwgfx/Makefile
@@ -8,7 +8,7 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o 
vmwgfx_drv.o \
vmwgfx_cmdbuf_res.o vmwgfx_cmdbuf.o vmwgfx_stdu.o \
vmwgfx_cotable.o vmwgfx_so.o vmwgfx_binding.o vmwgfx_msg.o \
vmwgfx_simple_resource.o vmwgfx_va.o vmwgfx_blit.o \
-   vmwgfx_validation.o vmwgfx_page_dirty.o \
+   vmwgfx_validation.o vmwgfx_page_dirty.o vmwgfx_streamoutput.o \
ttm_object.o ttm_lock.o
 
 obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
index f923b3c7c152..f41550797970 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
@@ -78,6 +78,7 @@
  * @index_buffer: Index buffer binding.
  * @per_shader: Per shader-type bindings.
  * @ua_views: UAV bindings.
+ * @so_state: StreamOutput bindings.
  * @dirty: Bitmap tracking per binding-type changes that have not yet
  * been emitted to the device.
  * @dirty_vb: Bitmap tracking individual vertex buffer binding changes that
@@ -103,6 +104,7 @@ struct vmw_ctx_binding_state {
struct vmw_ctx_bindinfo_ib index_buffer;
struct vmw_dx_shader_bindings per_shader[SVGA3D_NUM_SHADERTYPE];
struct vmw_ctx_bindinfo_uav ua_views[VMW_MAX_UAV_BIND_TYPE];
+   struct vmw_ctx_bindinfo_so so_state;
 
unsigned long dirty;
DECLARE_BITMAP(dirty_vb, SVGA3D_DX_MAX_VERTEXBUFFERS);
@@ -127,6 +129,7 @@ static int vmw_binding_scrub_ib(struct vmw_ctx_bindinfo 
*bi, bool rebind);
 static int vmw_binding_scrub_vb(struct vmw_ctx_bindinfo *bi, bool rebind);
 static int vmw_binding_scrub_uav(struct vmw_ctx_bindinfo *bi, bool rebind);
 static int vmw_binding_scrub_cs_uav(struct vmw_ctx_bindinfo *bi, bool rebind);
+static int vmw_binding_scrub_so(struct vmw_ctx_bindinfo *bi, bool rebind);
 
 static void vmw_binding_build_asserts(void) __attribute__ ((unused));
 
@@ -202,6 +205,9 @@ static const size_t vmw_binding_uav_offsets[] = {
 static const size_t vmw_binding_cs_uav_offsets[] = {
offsetof(struct vmw_ctx_binding_state, ua_views[1].views),
 };
+static const size_t vmw_binding_so_offsets[] = {
+   offsetof(struct vmw_ctx_binding_state, so_state),
+};
 
 static const struct vmw_binding_info vmw_binding_infos[] = {
[vmw_ctx_binding_shader] = {
@@ -256,6 +262,10 @@ static const struct vmw_binding_info vmw_binding_infos[] = 
{
.size = sizeof(struct vmw_ctx_bindinfo_view),
.offsets = vmw_binding_cs_uav_offsets,
.scrub_func = vmw_binding_scrub_cs_uav},
+   [vmw_ctx_binding_so] = {
+   .size = sizeof(struct vmw_ctx_bindinfo_so),
+   .offsets = vmw_binding_so_offsets,
+   .scrub_func = vmw_binding_scrub_so},
 };
 
 /**
@@ -1290,6 +1300,33 @@ static int vmw_binding_scrub_cs_uav(struct 
vmw_ctx_bindinfo *bi, bool rebind)
return 0;
 }
 
+/**
+ * vmw_binding_scrub_so - Scrub a streamoutput binding from context.
+ * @bi: Single binding information.
+ * @rebind: Whether to issue a bind instead of scrub command.
+ */
+static int vmw_binding_scrub_so(struct vmw_ctx_bindinfo *bi, bool rebind)
+{
+   struct vmw_ctx_bindinfo_so *binding =
+   container_of(bi, typeof(*binding), bi);
+   struct vmw_private *dev_priv = bi->ctx->dev_priv;
+   struct {
+   SVGA3dCmdHeader header;
+   SVGA3dCmdDXSetStreamOutput body;
+   } *cmd;
+
+   cmd = VMW_FIFO_RESERVE_DX(dev_priv, sizeof(*cmd), bi->ctx->id);
+   if (!cmd)
+   return -ENOMEM;
+
+   cmd->header.id = SVGA_3D_CMD_DX_SET_STREAMOUTPUT;
+   cmd->header.size = 

[PATCH v2 04/17] drm/vmwgfx: Use enum to represent graphics context capabilities

2020-03-23 Thread Roland Scheidegger (VMware)
From: Deepak Rawat 

Instead of having different bool in device private to represent
incremental graphics context capabilities, add a new sm type enum.

v2: Use enum instead of bit flag.

v3: Incorporated review comments.

Signed-off-by: Deepak Rawat 
Reviewed-by: Thomas Hellström (VMware) 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_context.c |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 34 ++---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 40 +++--
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c |  6 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c   |  4 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_mob.c |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 10 +++
 8 files changed, 69 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
index a56c9d802382..0477d9a74fe8 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
@@ -731,7 +731,7 @@ static int vmw_context_define(struct drm_device *dev, void 
*data,
};
int ret;
 
-   if (!dev_priv->has_dx && dx) {
+   if (!has_sm4_context(dev_priv) && dx) {
VMW_DEBUG_USER("DX contexts not supported by device.\n");
return -EINVAL;
}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index f976dabe18de..5277b9832d58 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -449,7 +449,7 @@ static int vmw_request_device(struct vmw_private *dev_priv)
dev_priv->cman = vmw_cmdbuf_man_create(dev_priv);
if (IS_ERR(dev_priv->cman)) {
dev_priv->cman = NULL;
-   dev_priv->has_dx = false;
+   dev_priv->sm_type = VMW_SM_LEGACY;
}
 
ret = vmw_request_device_late(dev_priv);
@@ -886,11 +886,22 @@ static int vmw_driver_load(struct drm_device *dev, 
unsigned long chipset)
if (dev_priv->has_mob && (dev_priv->capabilities & SVGA_CAP_DX)) {
spin_lock(_priv->cap_lock);
vmw_write(dev_priv, SVGA_REG_DEV_CAP, SVGA3D_DEVCAP_DXCONTEXT);
-   dev_priv->has_dx = !!vmw_read(dev_priv, SVGA_REG_DEV_CAP);
+   if (vmw_read(dev_priv, SVGA_REG_DEV_CAP))
+   dev_priv->sm_type = VMW_SM_4;
spin_unlock(_priv->cap_lock);
}
 
vmw_validation_mem_init_ttm(dev_priv, VMWGFX_VALIDATION_MEM_GRAN);
+
+   /* SVGA_CAP2_DX2 (DefineGBSurface_v3) is needed for SM4_1 support */
+   if (has_sm4_context(dev_priv) &&
+   (dev_priv->capabilities2 & SVGA_CAP2_DX2)) {
+   vmw_write(dev_priv, SVGA_REG_DEV_CAP, SVGA3D_DEVCAP_SM41);
+
+   if (vmw_read(dev_priv, SVGA_REG_DEV_CAP))
+   dev_priv->sm_type = VMW_SM_4_1;
+   }
+
ret = vmw_kms_init(dev_priv);
if (unlikely(ret != 0))
goto out_no_kms;
@@ -900,23 +911,12 @@ static int vmw_driver_load(struct drm_device *dev, 
unsigned long chipset)
if (ret)
goto out_no_fifo;
 
-   if (dev_priv->has_dx) {
-   /*
-* SVGA_CAP2_DX2 (DefineGBSurface_v3) is needed for SM4_1
-* support
-*/
-   if ((dev_priv->capabilities2 & SVGA_CAP2_DX2) != 0) {
-   vmw_write(dev_priv, SVGA_REG_DEV_CAP,
-   SVGA3D_DEVCAP_SM41);
-   dev_priv->has_sm4_1 = vmw_read(dev_priv,
-   SVGA_REG_DEV_CAP);
-   }
-   }
-
-   DRM_INFO("DX: %s\n", dev_priv->has_dx ? "yes." : "no.");
DRM_INFO("Atomic: %s\n", (dev->driver->driver_features & DRIVER_ATOMIC)
 ? "yes." : "no.");
-   DRM_INFO("SM4_1: %s\n", dev_priv->has_sm4_1 ? "yes." : "no.");
+   if (dev_priv->sm_type == VMW_SM_4_1)
+   DRM_INFO("SM4_1 support available.\n");
+   if (dev_priv->sm_type == VMW_SM_4)
+   DRM_INFO("SM4 support available.\n");
 
snprintf(host_log, sizeof(host_log), "vmwgfx: %s-%s",
VMWGFX_REPO, VMWGFX_GIT_VERSION);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index b70d73225707..243731813887 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -441,6 +441,20 @@ enum {
VMW_IRQTHREAD_MAX
 };
 
+/**
+ * enum vmw_sm_type - Graphics context capability supported by device.
+ * @VMW_SM_LEGACY: Pre DX context.
+ * @VMW_SM_4: Context support upto SM4.
+ * @VMW_SM_4_1: Context support upto SM4_1.
+ * @VMW_SM_MAX: Should be the last.
+ */
+enum vmw_sm_type {
+   VMW_SM_LEGACY = 0,
+   VMW_SM_4,
+   VMW_SM_4_1,
+   VMW_SM_MAX
+};
+
 struct vmw_private {
struct 

[PATCH v2 08/17] drm/vmwgfx: Support SM5 shader type in command buffer

2020-03-23 Thread Roland Scheidegger (VMware)
From: Deepak Rawat 

Virtual device now supports new shader types, allow them as valid shader
type in command buffer. Also add per shader bind info in binding manager
state for new shader type.

Signed-off-by: Deepak Rawat 
Reviewed-by: Thomas Hellström (VMware) 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_binding.c | 11 ++-
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 14 +++---
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
index 66e14e38d5e8..5a7e8db3e826 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
@@ -98,7 +98,7 @@ struct vmw_ctx_binding_state {
struct vmw_ctx_bindinfo_so so_targets[SVGA3D_DX_MAX_SOTARGETS];
struct vmw_ctx_bindinfo_vb vertex_buffers[SVGA3D_DX_MAX_VERTEXBUFFERS];
struct vmw_ctx_bindinfo_ib index_buffer;
-   struct vmw_dx_shader_bindings per_shader[SVGA3D_NUM_SHADERTYPE_DX10];
+   struct vmw_dx_shader_bindings per_shader[SVGA3D_NUM_SHADERTYPE];
 
unsigned long dirty;
DECLARE_BITMAP(dirty_vb, SVGA3D_DX_MAX_VERTEXBUFFERS);
@@ -151,6 +151,9 @@ static const size_t vmw_binding_shader_offsets[] = {
offsetof(struct vmw_ctx_binding_state, per_shader[0].shader),
offsetof(struct vmw_ctx_binding_state, per_shader[1].shader),
offsetof(struct vmw_ctx_binding_state, per_shader[2].shader),
+   offsetof(struct vmw_ctx_binding_state, per_shader[3].shader),
+   offsetof(struct vmw_ctx_binding_state, per_shader[4].shader),
+   offsetof(struct vmw_ctx_binding_state, per_shader[5].shader),
 };
 static const size_t vmw_binding_rt_offsets[] = {
offsetof(struct vmw_ctx_binding_state, render_targets),
@@ -162,6 +165,9 @@ static const size_t vmw_binding_cb_offsets[] = {
offsetof(struct vmw_ctx_binding_state, per_shader[0].const_buffers),
offsetof(struct vmw_ctx_binding_state, per_shader[1].const_buffers),
offsetof(struct vmw_ctx_binding_state, per_shader[2].const_buffers),
+   offsetof(struct vmw_ctx_binding_state, per_shader[3].const_buffers),
+   offsetof(struct vmw_ctx_binding_state, per_shader[4].const_buffers),
+   offsetof(struct vmw_ctx_binding_state, per_shader[5].const_buffers),
 };
 static const size_t vmw_binding_dx_ds_offsets[] = {
offsetof(struct vmw_ctx_binding_state, ds_view),
@@ -170,6 +176,9 @@ static const size_t vmw_binding_sr_offsets[] = {
offsetof(struct vmw_ctx_binding_state, per_shader[0].shader_res),
offsetof(struct vmw_ctx_binding_state, per_shader[1].shader_res),
offsetof(struct vmw_ctx_binding_state, per_shader[2].shader_res),
+   offsetof(struct vmw_ctx_binding_state, per_shader[3].shader_res),
+   offsetof(struct vmw_ctx_binding_state, per_shader[4].shader_res),
+   offsetof(struct vmw_ctx_binding_state, per_shader[5].shader_res),
 };
 static const size_t vmw_binding_so_offsets[] = {
offsetof(struct vmw_ctx_binding_state, so_targets),
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index 73f19f0fec88..4abed135c013 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -2118,6 +2118,9 @@ vmw_cmd_dx_set_single_constant_buffer(struct vmw_private 
*dev_priv,
  SVGA3dCmdHeader *header)
 {
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXSetSingleConstantBuffer);
+   SVGA3dShaderType max_shader_num = has_sm5_context(dev_priv) ?
+   SVGA3D_NUM_SHADERTYPE : SVGA3D_NUM_SHADERTYPE_DX10;
+
struct vmw_resource *res = NULL;
struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context);
struct vmw_ctx_bindinfo_cb binding;
@@ -2141,7 +2144,7 @@ vmw_cmd_dx_set_single_constant_buffer(struct vmw_private 
*dev_priv,
binding.size = cmd->body.sizeInBytes;
binding.slot = cmd->body.slot;
 
-   if (binding.shader_slot >= SVGA3D_NUM_SHADERTYPE_DX10 ||
+   if (binding.shader_slot >= max_shader_num ||
binding.slot >= SVGA3D_DX_MAX_CONSTBUFFERS) {
VMW_DEBUG_USER("Illegal const buffer shader %u slot %u.\n",
   (unsigned int) cmd->body.type,
@@ -2169,12 +2172,15 @@ static int vmw_cmd_dx_set_shader_res(struct vmw_private 
*dev_priv,
 {
VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXSetShaderResources) =
container_of(header, typeof(*cmd), header);
+   SVGA3dShaderType max_allowed = has_sm5_context(dev_priv) ?
+   SVGA3D_SHADERTYPE_MAX : SVGA3D_SHADERTYPE_DX10_MAX;
+
u32 num_sr_view = (cmd->header.size - sizeof(cmd->body)) /
sizeof(SVGA3dShaderResourceViewId);
 
if ((u64) cmd->body.startView + (u64) num_sr_view >
(u64) SVGA3D_DX_MAX_SRVIEWS ||
-   cmd->body.type >= 

[PATCH v2 06/17] drm/vmwgfx: Add a new enum for SM5 graphics context capability

2020-03-23 Thread Roland Scheidegger (VMware)
From: Deepak Rawat 

A new enum to represent new SM5 graphics context capability in vmwgfx.

v2: use new correct cap bits (merged several later commits into it).

Signed-off-by: Deepak Rawat 
Signed-off-by: Thomas Hellström (VMware) 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 11 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 13 +
 2 files changed, 24 insertions(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 5277b9832d58..b55bd3b5f5cd 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -290,6 +290,8 @@ static void vmw_print_capabilities2(uint32_t capabilities2)
DRM_INFO("  Grow oTable.\n");
if (capabilities2 & SVGA_CAP2_INTRA_SURFACE_COPY)
DRM_INFO("  IntraSurface copy.\n");
+   if (capabilities2 & SVGA_CAP2_DX3)
+   DRM_INFO("  DX3.\n");
 }
 
 static void vmw_print_capabilities(uint32_t capabilities)
@@ -900,6 +902,13 @@ static int vmw_driver_load(struct drm_device *dev, 
unsigned long chipset)
 
if (vmw_read(dev_priv, SVGA_REG_DEV_CAP))
dev_priv->sm_type = VMW_SM_4_1;
+
+   if (has_sm4_1_context(dev_priv) &&
+   (dev_priv->capabilities2 & SVGA_CAP2_DX3)) {
+   vmw_write(dev_priv, SVGA_REG_DEV_CAP, 
SVGA3D_DEVCAP_SM5);
+   if (vmw_read(dev_priv, SVGA_REG_DEV_CAP))
+   dev_priv->sm_type = VMW_SM_5;
+   }
}
 
ret = vmw_kms_init(dev_priv);
@@ -913,6 +922,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned 
long chipset)
 
DRM_INFO("Atomic: %s\n", (dev->driver->driver_features & DRIVER_ATOMIC)
 ? "yes." : "no.");
+   if (dev_priv->sm_type == VMW_SM_5)
+   DRM_INFO("SM5 support available.\n");
if (dev_priv->sm_type == VMW_SM_4_1)
DRM_INFO("SM4_1 support available.\n");
if (dev_priv->sm_type == VMW_SM_4)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 243731813887..262e57623df4 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -446,12 +446,14 @@ enum {
  * @VMW_SM_LEGACY: Pre DX context.
  * @VMW_SM_4: Context support upto SM4.
  * @VMW_SM_4_1: Context support upto SM4_1.
+ * @VMW_SM_5: Context support up to SM5.
  * @VMW_SM_MAX: Should be the last.
  */
 enum vmw_sm_type {
VMW_SM_LEGACY = 0,
VMW_SM_4,
VMW_SM_4_1,
+   VMW_SM_5,
VMW_SM_MAX
 };
 
@@ -684,6 +686,17 @@ static inline bool has_sm4_1_context(const struct 
vmw_private *dev_priv)
return (dev_priv->sm_type >= VMW_SM_4_1);
 }
 
+/**
+ * has_sm5_context - Does the device support SM5 context.
+ * @dev_priv: Device private.
+ *
+ * Return: Bool value if device support SM5 context or not.
+ */
+static inline bool has_sm5_context(const struct vmw_private *dev_priv)
+{
+   return (dev_priv->sm_type >= VMW_SM_5);
+}
+
 extern void vmw_svga_enable(struct vmw_private *dev_priv);
 extern void vmw_svga_disable(struct vmw_private *dev_priv);
 
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 01/17] drm/vmwgfx: Also check for SVGA_CAP_DX before reading DX context support

2020-03-23 Thread Roland Scheidegger (VMware)
From: Deepak Rawat 

Virtual device consider SVGA_CAP_DX and SVGA3D_DEVCAP_DXCONTEXT
independent of each other. Some of the commands in cmd_buf depends on
SVGA_CAP_DX, so better to check for that as well.

Signed-off-by: Deepak Rawat 
Reviewed-by: Thomas Hellström (VMware) 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 4f58364421ce..f976dabe18de 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -883,7 +883,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned 
long chipset)
}
}
 
-   if (dev_priv->has_mob) {
+   if (dev_priv->has_mob && (dev_priv->capabilities & SVGA_CAP_DX)) {
spin_lock(_priv->cap_lock);
vmw_write(dev_priv, SVGA_REG_DEV_CAP, SVGA3D_DEVCAP_DXCONTEXT);
dev_priv->has_dx = !!vmw_read(dev_priv, SVGA_REG_DEV_CAP);
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 16/17] drm/vmwgfx: Add SM5 param for userspace

2020-03-23 Thread Roland Scheidegger (VMware)
From: Deepak Rawat 

Add a new param for user-space to determine if kernel module is SM5
capable.

Signed-off-by: Deepak Rawat 
Reviewed-by: Thomas Hellström (VMware) 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c | 3 +++
 include/uapi/drm/vmwgfx_drm.h | 4 
 2 files changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
index 0af42875ba4e..f681b7b4df1b 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
@@ -119,6 +119,9 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data,
case DRM_VMW_PARAM_SM4_1:
param->value = has_sm4_1_context(dev_priv);
break;
+   case DRM_VMW_PARAM_SM5:
+   param->value = has_sm5_context(dev_priv);
+   break;
default:
return -EINVAL;
}
diff --git a/include/uapi/drm/vmwgfx_drm.h b/include/uapi/drm/vmwgfx_drm.h
index 8cd4b321597c..02e917507479 100644
--- a/include/uapi/drm/vmwgfx_drm.h
+++ b/include/uapi/drm/vmwgfx_drm.h
@@ -86,6 +86,9 @@ extern "C" {
  *
  * DRM_VMW_PARAM_SM4_1
  * SM4_1 support is enabled.
+ *
+ * DRM_VMW_PARAM_SM5
+ * SM5 support is enabled.
  */
 
 #define DRM_VMW_PARAM_NUM_STREAMS  0
@@ -103,6 +106,7 @@ extern "C" {
 #define DRM_VMW_PARAM_DX   12
 #define DRM_VMW_PARAM_HW_CAPS2 13
 #define DRM_VMW_PARAM_SM4_114
+#define DRM_VMW_PARAM_SM5  15
 
 /**
  * enum drm_vmw_handle_type - handle type for ref ioctls
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 02/17] drm/vmwgfx: Sync legacy multisampling device capability

2020-03-23 Thread Roland Scheidegger (VMware)
From: Deepak Rawat 

In favor of SM4.1 multisampling capability, virtual device deprecated
old multisampling device capability. Mark legacy multisampling device
capability as dead. Rename the function that masks legacy multisample
capability to reflect that now it is masking a deprecated feature.

Signed-off-by: Deepak Rawat 
Reviewed-by: Thomas Hellström (VMware) 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
---
 .../gpu/drm/vmwgfx/device_include/svga3d_devcaps.h  | 13 +
 drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c   | 11 +++
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/device_include/svga3d_devcaps.h 
b/drivers/gpu/drm/vmwgfx/device_include/svga3d_devcaps.h
index f256560049bf..2de878b5ba16 100644
--- a/drivers/gpu/drm/vmwgfx/device_include/svga3d_devcaps.h
+++ b/drivers/gpu/drm/vmwgfx/device_include/svga3d_devcaps.h
@@ -163,10 +163,15 @@ typedef enum {
SVGA3D_DEVCAP_SURFACEFMT_A16B16G16R16   = 67,
SVGA3D_DEVCAP_SURFACEFMT_UYVY   = 68,
SVGA3D_DEVCAP_SURFACEFMT_YUY2   = 69,
-   SVGA3D_DEVCAP_MULTISAMPLE_NONMASKABLESAMPLES= 70,
-   SVGA3D_DEVCAP_MULTISAMPLE_MASKABLESAMPLES   = 71,
-   SVGA3D_DEVCAP_ALPHATOCOVERAGE   = 72,
-   SVGA3D_DEVCAP_SUPERSAMPLE   = 73,
+
+   /*
+* Deprecated.
+*/
+   SVGA3D_DEVCAP_DEAD4 = 70,
+   SVGA3D_DEVCAP_DEAD5 = 71,
+   SVGA3D_DEVCAP_DEAD7 = 72,
+   SVGA3D_DEVCAP_DEAD6 = 73,
+
SVGA3D_DEVCAP_AUTOGENMIPMAPS= 74,
SVGA3D_DEVCAP_SURFACEFMT_NV12   = 75,
SVGA3D_DEVCAP_SURFACEFMT_AYUV   = 76,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
index a15375eb476e..09b255465f99 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
@@ -126,14 +126,17 @@ int vmw_getparam_ioctl(struct drm_device *dev, void *data,
return 0;
 }
 
-static u32 vmw_mask_multisample(unsigned int cap, u32 fmt_value)
+static u32 vmw_mask_legacy_multisample(unsigned int cap, u32 fmt_value)
 {
/*
 * A version of user-space exists which use MULTISAMPLE_MASKABLESAMPLES
 * to check the sample count supported by virtual device. Since there
 * never was support for multisample count for backing MOB return 0.
+*
+* MULTISAMPLE_MASKABLESAMPLES devcap is marked as deprecated by virtual
+* device.
 */
-   if (cap == SVGA3D_DEVCAP_MULTISAMPLE_MASKABLESAMPLES)
+   if (cap == SVGA3D_DEVCAP_DEAD5)
return 0;
 
return fmt_value;
@@ -164,7 +167,7 @@ static int vmw_fill_compat_cap(struct vmw_private 
*dev_priv, void *bounce,
for (i = 0; i < max_size; ++i) {
vmw_write(dev_priv, SVGA_REG_DEV_CAP, i);
compat_cap->pairs[i][0] = i;
-   compat_cap->pairs[i][1] = vmw_mask_multisample
+   compat_cap->pairs[i][1] = vmw_mask_legacy_multisample
(i, vmw_read(dev_priv, SVGA_REG_DEV_CAP));
}
spin_unlock(_priv->cap_lock);
@@ -220,7 +223,7 @@ int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data,
spin_lock(_priv->cap_lock);
for (i = 0; i < num; ++i) {
vmw_write(dev_priv, SVGA_REG_DEV_CAP, i);
-   *bounce32++ = vmw_mask_multisample
+   *bounce32++ = vmw_mask_legacy_multisample
(i, vmw_read(dev_priv, SVGA_REG_DEV_CAP));
}
spin_unlock(_priv->cap_lock);
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 11/17] drm/vmwgfx: Rename stream output target binding tracker struct

2020-03-23 Thread Roland Scheidegger (VMware)
From: Deepak Rawat 

Previous name vmw_ctx_bindinfo_so is misleading because it actually
represent so target and stream output is a new resource type that needs
tracking for SM5 capable device. Also rename binding type enum and
internal functions to reflect these belongs to so targets.

Signed-off-by: Deepak Rawat 
Reviewed-by: Thomas Hellström (VMware) 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_binding.c | 36 -
 drivers/gpu/drm/vmwgfx/vmwgfx_binding.h |  6 ++---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c |  4 +--
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
index f0a576698266..f923b3c7c152 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
@@ -57,7 +57,7 @@
 
 #define VMW_BINDING_RT_BIT 0
 #define VMW_BINDING_PS_BIT 1
-#define VMW_BINDING_SO_BIT 2
+#define VMW_BINDING_SO_T_BIT   2
 #define VMW_BINDING_VB_BIT 3
 #define VMW_BINDING_UAV_BIT4
 #define VMW_BINDING_CS_UAV_BIT 5
@@ -98,7 +98,7 @@ struct vmw_ctx_binding_state {
struct vmw_ctx_bindinfo_view render_targets[SVGA3D_RT_MAX];
struct vmw_ctx_bindinfo_tex texture_units[SVGA3D_NUM_TEXTURE_UNITS];
struct vmw_ctx_bindinfo_view ds_view;
-   struct vmw_ctx_bindinfo_so so_targets[SVGA3D_DX_MAX_SOTARGETS];
+   struct vmw_ctx_bindinfo_so_target so_targets[SVGA3D_DX_MAX_SOTARGETS];
struct vmw_ctx_bindinfo_vb vertex_buffers[SVGA3D_DX_MAX_VERTEXBUFFERS];
struct vmw_ctx_bindinfo_ib index_buffer;
struct vmw_dx_shader_bindings per_shader[SVGA3D_NUM_SHADERTYPE];
@@ -119,7 +119,7 @@ static int vmw_binding_scrub_texture(struct 
vmw_ctx_bindinfo *bi, bool rebind);
 static int vmw_binding_scrub_cb(struct vmw_ctx_bindinfo *bi, bool rebind);
 static int vmw_binding_scrub_dx_rt(struct vmw_ctx_bindinfo *bi, bool rebind);
 static int vmw_binding_scrub_sr(struct vmw_ctx_bindinfo *bi, bool rebind);
-static int vmw_binding_scrub_so(struct vmw_ctx_bindinfo *bi, bool rebind);
+static int vmw_binding_scrub_so_target(struct vmw_ctx_bindinfo *bi, bool 
rebind);
 static int vmw_binding_emit_dirty(struct vmw_ctx_binding_state *cbs);
 static int vmw_binding_scrub_dx_shader(struct vmw_ctx_bindinfo *bi,
   bool rebind);
@@ -187,7 +187,7 @@ static const size_t vmw_binding_sr_offsets[] = {
offsetof(struct vmw_ctx_binding_state, per_shader[4].shader_res),
offsetof(struct vmw_ctx_binding_state, per_shader[5].shader_res),
 };
-static const size_t vmw_binding_so_offsets[] = {
+static const size_t vmw_binding_so_target_offsets[] = {
offsetof(struct vmw_ctx_binding_state, so_targets),
 };
 static const size_t vmw_binding_vb_offsets[] = {
@@ -236,10 +236,10 @@ static const struct vmw_binding_info vmw_binding_infos[] 
= {
.size = sizeof(struct vmw_ctx_bindinfo_view),
.offsets = vmw_binding_dx_ds_offsets,
.scrub_func = vmw_binding_scrub_dx_rt},
-   [vmw_ctx_binding_so] = {
-   .size = sizeof(struct vmw_ctx_bindinfo_so),
-   .offsets = vmw_binding_so_offsets,
-   .scrub_func = vmw_binding_scrub_so},
+   [vmw_ctx_binding_so_target] = {
+   .size = sizeof(struct vmw_ctx_bindinfo_so_target),
+   .offsets = vmw_binding_so_target_offsets,
+   .scrub_func = vmw_binding_scrub_so_target},
[vmw_ctx_binding_vb] = {
.size = sizeof(struct vmw_ctx_bindinfo_vb),
.offsets = vmw_binding_vb_offsets,
@@ -874,8 +874,8 @@ static void vmw_collect_so_targets(struct 
vmw_ctx_binding_state *cbs,
   const struct vmw_ctx_bindinfo *bi,
   u32 max_num)
 {
-   const struct vmw_ctx_bindinfo_so *biso =
-   container_of(bi, struct vmw_ctx_bindinfo_so, bi);
+   const struct vmw_ctx_bindinfo_so_target *biso =
+   container_of(bi, struct vmw_ctx_bindinfo_so_target, bi);
unsigned long i;
SVGA3dSoTarget *so_buffer = (SVGA3dSoTarget *) cbs->bind_cmd_buffer;
 
@@ -900,11 +900,11 @@ static void vmw_collect_so_targets(struct 
vmw_ctx_binding_state *cbs,
 }
 
 /**
- * vmw_binding_emit_set_so - Issue delayed streamout binding commands
+ * vmw_emit_set_so_target - Issue delayed streamout binding commands
  *
  * @cbs: Pointer to the context's struct vmw_ctx_binding_state
  */
-static int vmw_emit_set_so(struct vmw_ctx_binding_state *cbs)
+static int vmw_emit_set_so_target(struct vmw_ctx_binding_state *cbs)
 {
const struct vmw_ctx_bindinfo *loc = >so_targets[0].bi;
struct {
@@ -1136,8 +1136,8 @@ static int vmw_binding_emit_dirty(struct 
vmw_ctx_binding_state *cbs)
case VMW_BINDING_PS_BIT:
ret = vmw_binding_emit_dirty_ps(cbs);

[PATCH v2 13/17] drm/vmwgfx: Split surface metadata from struct vmw_surface

2020-03-23 Thread Roland Scheidegger (VMware)
From: Deepak Rawat 

Create a new structure vmw_surface_metadata representing the metadata
used for creating surface. With this can make the surface_define_priv
a bit cleaner.

Signed-off-by: Deepak Rawat 
Reviewed-by: Brian Paul 
Reviewed-by: Thomas Hellström (VMware) 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |  56 --
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  16 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c|  44 +++--
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 240 +---
 4 files changed, 202 insertions(+), 154 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index cfd8eaf7973e..c87bb854267b 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -225,24 +225,56 @@ struct vmw_cursor_snooper {
 struct vmw_framebuffer;
 struct vmw_surface_offset;
 
-struct vmw_surface {
-   struct vmw_resource res;
-   SVGA3dSurfaceAllFlags flags;
-   uint32_t format;
-   uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
+/**
+ * struct vmw_surface_metadata - Metadata describing a surface.
+ *
+ * @flags: Device flags.
+ * @format: Surface SVGA3D_x format.
+ * @mip_levels: Mip level for each face. For GB first index is used only.
+ * @multisample_count: Sample count.
+ * @multisample_pattern: Sample patterns.
+ * @quality_level: Quality level.
+ * @autogen_filter: Filter for automatically generated mipmaps.
+ * @array_size: Number of array elements for a 1D/2D texture. For cubemap
+texture number of faces * array_size. This should be 0 for pre
+   SM4 device.
+ * @num_sizes: Size of @sizes. For GB surface this should always be 1.
+ * @base_size: Surface dimension.
+ * @sizes: Array representing mip sizes. Legacy only.
+ * @scanout: Whether this surface will be used for scanout.
+ *
+ * This tracks metadata for both legacy and guest backed surface.
+ */
+struct vmw_surface_metadata {
+   u64 flags;
+   u32 format;
+   u32 mip_levels[DRM_VMW_MAX_SURFACE_FACES];
+   u32 multisample_count;
+   u32 multisample_pattern;
+   u32 quality_level;
+   u32 autogen_filter;
+   u32 array_size;
+   u32 num_sizes;
struct drm_vmw_size base_size;
struct drm_vmw_size *sizes;
-   uint32_t num_sizes;
bool scanout;
-   uint32_t array_size;
-   /* TODO so far just a extra pointer */
+};
+
+/**
+ * struct vmw_surface: Resource structure for a surface.
+ *
+ * @res: The base resource for this surface.
+ * @metadata: Metadata for this surface resource.
+ * @snooper: Cursor data. Legacy surface only.
+ * @offsets: Legacy surface only.
+ * @view_list: List of views bound to this surface.
+ */
+struct vmw_surface {
+   struct vmw_resource res;
+   struct vmw_surface_metadata metadata;
struct vmw_cursor_snooper snooper;
struct vmw_surface_offset *offsets;
-   SVGA3dTextureFilter autogen_filter;
-   uint32_t multisample_count;
struct list_head view_list;
-   SVGA3dMSPattern multisample_pattern;
-   SVGA3dMSQualityLevel quality_level;
 };
 
 struct vmw_marker_queue {
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 04b79e8975ce..4d2aaca15fd2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -905,14 +905,14 @@ static int vmw_kms_new_framebuffer_surface(struct 
vmw_private *dev_priv,
 */
 
/* Surface must be marked as a scanout. */
-   if (unlikely(!surface->scanout))
+   if (unlikely(!surface->metadata.scanout))
return -EINVAL;
 
-   if (unlikely(surface->mip_levels[0] != 1 ||
-surface->num_sizes != 1 ||
-surface->base_size.width < mode_cmd->width ||
-surface->base_size.height < mode_cmd->height ||
-surface->base_size.depth != 1)) {
+   if (unlikely(surface->metadata.mip_levels[0] != 1 ||
+surface->metadata.num_sizes != 1 ||
+surface->metadata.base_size.width < mode_cmd->width ||
+surface->metadata.base_size.height < mode_cmd->height ||
+surface->metadata.base_size.depth != 1)) {
DRM_ERROR("Incompatible surface dimensions "
  "for requested mode.\n");
return -EINVAL;
@@ -941,7 +941,7 @@ static int vmw_kms_new_framebuffer_surface(struct 
vmw_private *dev_priv,
 * For DX, surface format validation is done when surface->scanout
 * is set.
 */
-   if (!has_sm4_context(dev_priv) && format != surface->format) {
+   if (!has_sm4_context(dev_priv) && format != surface->metadata.format) {
DRM_ERROR("Invalid surface format for requested mode.\n");
return -EINVAL;
}
@@ -2516,7 +2516,7 @@ int 

[PATCH v2 14/17] drm/vmwgfx: Refactor surface_define to use vmw_surface_metadata

2020-03-23 Thread Roland Scheidegger (VMware)
From: Deepak Rawat 

Makes surface_define cleaner by sending vmw_surface_metadata instead of
all the arguments individually.

v2: fix uninitialized return value, error message

Signed-off-by: Deepak Rawat 
Reviewed-by: Brian Paul 
Reviewed-by: Thomas Hellström (VMware) 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |   5 +
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  27 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c|  51 +---
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 378 
 4 files changed, 215 insertions(+), 246 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index c87bb854267b..326d1dd58bc5 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -1309,6 +1309,11 @@ extern int vmw_gb_surface_reference_ext_ioctl(struct 
drm_device *dev,
  void *data,
  struct drm_file *file_priv);
 
+int vmw_gb_surface_define(struct vmw_private *dev_priv,
+ uint32_t user_accounting_size,
+ const struct vmw_surface_metadata *req,
+ struct vmw_surface **srf_out);
+
 /*
  * Shader management - vmwgfx_shader.c
  */
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 4d2aaca15fd2..04d66592f605 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -1144,8 +1144,8 @@ static int vmw_create_bo_proxy(struct drm_device *dev,
   struct vmw_buffer_object *bo_mob,
   struct vmw_surface **srf_out)
 {
+   struct vmw_surface_metadata metadata = {0};
uint32_t format;
-   struct drm_vmw_size content_base_size = {0};
struct vmw_resource *res;
unsigned int bytes_pp;
struct drm_format_name_buf format_name;
@@ -1175,22 +1175,15 @@ static int vmw_create_bo_proxy(struct drm_device *dev,
return -EINVAL;
}
 
-   content_base_size.width  = mode_cmd->pitches[0] / bytes_pp;
-   content_base_size.height = mode_cmd->height;
-   content_base_size.depth  = 1;
-
-   ret = vmw_surface_gb_priv_define(dev,
-0, /* kernel visible only */
-0, /* flags */
-format,
-true, /* can be a scanout buffer */
-1, /* num of mip levels */
-0,
-0,
-content_base_size,
-SVGA3D_MS_PATTERN_NONE,
-SVGA3D_MS_QUALITY_NONE,
-srf_out);
+   metadata.format = format;
+   metadata.mip_levels[0] = 1;
+   metadata.num_sizes = 1;
+   metadata.base_size.width = mode_cmd->pitches[0] / bytes_pp;
+   metadata.base_size.height =  mode_cmd->height;
+   metadata.base_size.depth = 1;
+   metadata.scanout = true;
+
+   ret = vmw_gb_surface_define(vmw_priv(dev), 0, , srf_out);
if (ret) {
DRM_ERROR("Failed to allocate proxy content buffer\n");
return ret;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
index 60275fe0db94..9ffa9c75a5da 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
@@ -1041,7 +1041,6 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane *plane,
struct vmw_plane_state *vps = vmw_plane_state_to_vps(new_state);
enum stdu_content_type new_content_type;
struct vmw_framebuffer_surface *new_vfbs;
-   struct drm_crtc *crtc = new_state->crtc;
uint32_t hdisplay = new_state->crtc_w, vdisplay = new_state->crtc_h;
int ret;
 
@@ -1068,12 +1067,11 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane 
*plane,
new_content_type = SEPARATE_SURFACE;
 
if (new_content_type != SAME_AS_DISPLAY) {
-   struct vmw_surface content_srf;
-   struct drm_vmw_size display_base_size = {0};
+   struct vmw_surface_metadata metadata = {0};
 
-   display_base_size.width  = hdisplay;
-   display_base_size.height = vdisplay;
-   display_base_size.depth  = 1;
+   metadata.base_size.width = hdisplay;
+   metadata.base_size.height = vdisplay;
+   metadata.base_size.depth = 1;
 
/*
 * If content buffer is a buffer object, then we have to
@@ -1083,15 +1081,15 @@ vmw_stdu_primary_plane_prepare_fb(struct drm_plane 
*plane,
 
switch (new_fb->format->cpp[0]*8) {
  

[PATCH v2 09/17] drm/vmwgfx: Add support for UA view commands

2020-03-23 Thread Roland Scheidegger (VMware)
From: Deepak Rawat 

Virtual device now support new commands to manage unordered access
views. Allow them as part of user-space command buffer. This involves
adding UA view cotable, binding tracker info, new view type and command
verifier functions.

v2: fix comment typo
v3: style fixes (don't use deprecated PTR_RET)

Signed-off-by: Deepak Rawat 
Signed-off-by: Neha Bhende 
Reviewed-by: Thomas Hellström (VMware) 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_binding.c | 129 -
 drivers/gpu/drm/vmwgfx/vmwgfx_binding.h |  16 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_context.c |  26 +++--
 drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c |   4 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 144 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_so.c  |  12 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_so.h  |   6 +
 7 files changed, 319 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
index 5a7e8db3e826..f0a576698266 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
@@ -59,7 +59,9 @@
 #define VMW_BINDING_PS_BIT 1
 #define VMW_BINDING_SO_BIT 2
 #define VMW_BINDING_VB_BIT 3
-#define VMW_BINDING_NUM_BITS   4
+#define VMW_BINDING_UAV_BIT4
+#define VMW_BINDING_CS_UAV_BIT 5
+#define VMW_BINDING_NUM_BITS   6
 
 #define VMW_BINDING_PS_SR_BIT  0
 
@@ -75,6 +77,7 @@
  * @vertex_buffers: Vertex buffer bindings.
  * @index_buffer: Index buffer binding.
  * @per_shader: Per shader-type bindings.
+ * @ua_views: UAV bindings.
  * @dirty: Bitmap tracking per binding-type changes that have not yet
  * been emitted to the device.
  * @dirty_vb: Bitmap tracking individual vertex buffer binding changes that
@@ -99,6 +102,7 @@ struct vmw_ctx_binding_state {
struct vmw_ctx_bindinfo_vb vertex_buffers[SVGA3D_DX_MAX_VERTEXBUFFERS];
struct vmw_ctx_bindinfo_ib index_buffer;
struct vmw_dx_shader_bindings per_shader[SVGA3D_NUM_SHADERTYPE];
+   struct vmw_ctx_bindinfo_uav ua_views[VMW_MAX_UAV_BIND_TYPE];
 
unsigned long dirty;
DECLARE_BITMAP(dirty_vb, SVGA3D_DX_MAX_VERTEXBUFFERS);
@@ -121,6 +125,9 @@ static int vmw_binding_scrub_dx_shader(struct 
vmw_ctx_bindinfo *bi,
   bool rebind);
 static int vmw_binding_scrub_ib(struct vmw_ctx_bindinfo *bi, bool rebind);
 static int vmw_binding_scrub_vb(struct vmw_ctx_bindinfo *bi, bool rebind);
+static int vmw_binding_scrub_uav(struct vmw_ctx_bindinfo *bi, bool rebind);
+static int vmw_binding_scrub_cs_uav(struct vmw_ctx_bindinfo *bi, bool rebind);
+
 static void vmw_binding_build_asserts(void) __attribute__ ((unused));
 
 typedef int (*vmw_scrub_func)(struct vmw_ctx_bindinfo *, bool);
@@ -189,6 +196,12 @@ static const size_t vmw_binding_vb_offsets[] = {
 static const size_t vmw_binding_ib_offsets[] = {
offsetof(struct vmw_ctx_binding_state, index_buffer),
 };
+static const size_t vmw_binding_uav_offsets[] = {
+   offsetof(struct vmw_ctx_binding_state, ua_views[0].views),
+};
+static const size_t vmw_binding_cs_uav_offsets[] = {
+   offsetof(struct vmw_ctx_binding_state, ua_views[1].views),
+};
 
 static const struct vmw_binding_info vmw_binding_infos[] = {
[vmw_ctx_binding_shader] = {
@@ -235,6 +248,14 @@ static const struct vmw_binding_info vmw_binding_infos[] = 
{
.size = sizeof(struct vmw_ctx_bindinfo_ib),
.offsets = vmw_binding_ib_offsets,
.scrub_func = vmw_binding_scrub_ib},
+   [vmw_ctx_binding_uav] = {
+   .size = sizeof(struct vmw_ctx_bindinfo_view),
+   .offsets = vmw_binding_uav_offsets,
+   .scrub_func = vmw_binding_scrub_uav},
+   [vmw_ctx_binding_cs_uav] = {
+   .size = sizeof(struct vmw_ctx_bindinfo_view),
+   .offsets = vmw_binding_cs_uav_offsets,
+   .scrub_func = vmw_binding_scrub_cs_uav},
 };
 
 /**
@@ -320,6 +341,18 @@ void vmw_binding_add(struct vmw_ctx_binding_state *cbs,
INIT_LIST_HEAD(>res_list);
 }
 
+/**
+ * vmw_binding_add_uav_index - Add UAV index for tracking.
+ * @cbs: Pointer to the context binding state tracker.
+ * @slot: UAV type to which bind this index.
+ * @index: The splice index to track.
+ */
+void vmw_binding_add_uav_index(struct vmw_ctx_binding_state *cbs, uint32 slot,
+  uint32 index)
+{
+   cbs->ua_views[slot].index = index;
+}
+
 /**
  * vmw_binding_transfer: Transfer a context binding tracking entry.
  *
@@ -459,6 +492,10 @@ void vmw_binding_state_commit(struct vmw_ctx_binding_state 
*to,
vmw_binding_transfer(to, from, entry);
vmw_binding_drop(entry);
}
+
+   /* Also transfer uav splice indices */
+   to->ua_views[0].index = from->ua_views[0].index;
+   to->ua_views[1].index = from->ua_views[1].index;
 }
 
 /**
@@ -1014,6 +1051,66 @@ 

[PATCH v2 03/17] drm/vmwgfx: Deprecate logic ops commands

2020-03-23 Thread Roland Scheidegger (VMware)
From: Deepak Rawat 

Logic ops commands are marked as deprecated by virtual device and were
never used by vmwgfx.

Signed-off-by: Deepak Rawat 
Reviewed-by: Thomas Hellström (VMware) 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
---
 .../gpu/drm/vmwgfx/device_include/svga3d_cmd.h | 12 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c| 18 ++
 2 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/device_include/svga3d_cmd.h 
b/drivers/gpu/drm/vmwgfx/device_include/svga3d_cmd.h
index 9cbba0e8ce6a..84ea8d385b0e 100644
--- a/drivers/gpu/drm/vmwgfx/device_include/svga3d_cmd.h
+++ b/drivers/gpu/drm/vmwgfx/device_include/svga3d_cmd.h
@@ -104,12 +104,12 @@ typedef enum {
SVGA_3D_CMD_DEAD1  = 1083,
SVGA_3D_CMD_DEAD2  = 1084,
 
-   SVGA_3D_CMD_LOGICOPS_BITBLT= 1085,
-   SVGA_3D_CMD_LOGICOPS_TRANSBLT  = 1086,
-   SVGA_3D_CMD_LOGICOPS_STRETCHBLT= 1087,
-   SVGA_3D_CMD_LOGICOPS_COLORFILL = 1088,
-   SVGA_3D_CMD_LOGICOPS_ALPHABLEND= 1089,
-   SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND= 1090,
+   SVGA_3D_CMD_DEAD12 = 1085,
+   SVGA_3D_CMD_DEAD13 = 1086,
+   SVGA_3D_CMD_DEAD14 = 1087,
+   SVGA_3D_CMD_DEAD15 = 1088,
+   SVGA_3D_CMD_DEAD16 = 1089,
+   SVGA_3D_CMD_DEAD17 = 1090,
 
SVGA_3D_CMD_SET_OTABLE_BASE= 1091,
SVGA_3D_CMD_READBACK_OTABLE= 1092,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index 73489a45decb..74a2c7ec9198 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -2922,18 +2922,12 @@ static const struct vmw_cmd_entry 
vmw_cmd_entries[SVGA_3D_CMD_MAX] = {
false, false, false),
VMW_CMD_DEF(SVGA_3D_CMD_DEAD2, _cmd_invalid,
false, false, false),
-   VMW_CMD_DEF(SVGA_3D_CMD_LOGICOPS_BITBLT, _cmd_invalid,
-   false, false, false),
-   VMW_CMD_DEF(SVGA_3D_CMD_LOGICOPS_TRANSBLT, _cmd_invalid,
-   false, false, false),
-   VMW_CMD_DEF(SVGA_3D_CMD_LOGICOPS_STRETCHBLT, _cmd_invalid,
-   false, false, false),
-   VMW_CMD_DEF(SVGA_3D_CMD_LOGICOPS_COLORFILL, _cmd_invalid,
-   false, false, false),
-   VMW_CMD_DEF(SVGA_3D_CMD_LOGICOPS_ALPHABLEND, _cmd_invalid,
-   false, false, false),
-   VMW_CMD_DEF(SVGA_3D_CMD_LOGICOPS_CLEARTYPEBLEND, _cmd_invalid,
-   false, false, false),
+   VMW_CMD_DEF(SVGA_3D_CMD_DEAD12, _cmd_invalid, false, false, false),
+   VMW_CMD_DEF(SVGA_3D_CMD_DEAD13, _cmd_invalid, false, false, false),
+   VMW_CMD_DEF(SVGA_3D_CMD_DEAD14, _cmd_invalid, false, false, false),
+   VMW_CMD_DEF(SVGA_3D_CMD_DEAD15, _cmd_invalid, false, false, false),
+   VMW_CMD_DEF(SVGA_3D_CMD_DEAD16, _cmd_invalid, false, false, false),
+   VMW_CMD_DEF(SVGA_3D_CMD_DEAD17, _cmd_invalid, false, false, false),
VMW_CMD_DEF(SVGA_3D_CMD_SET_OTABLE_BASE, _cmd_invalid,
false, false, true),
VMW_CMD_DEF(SVGA_3D_CMD_READBACK_OTABLE, _cmd_invalid,
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 00/17] drm/vmwgfx add support for GL4

2020-03-23 Thread Roland Scheidegger (VMware)

This series updates vmwgfx to support newer vmware svga device protocol
and expose new commands to userspace..
This is required for supporting newer GL4 features in the guest.

This syncs up the device headers, adds support for the new commands,
and also refactors some code (in particular around surface definition)
to more easily support the new commands.

Preliminary mesa userspace code using these new vmwgfx features can be
found at: https://gitlab.freedesktop.org/bhenden/mesa

v2: rebased on newer drm-next version, fixed up the email addresses
in some R-b and Signed-off-by to what they really should be, hopefully
fixed up sender email from header, no actual code changes

Deepak Rawat (16):
  drm/vmwgfx: Also check for SVGA_CAP_DX before reading DX context
support
  drm/vmwgfx: Sync legacy multisampling device capability
  drm/vmwgfx: Deprecate logic ops commands
  drm/vmwgfx: Use enum to represent graphics context capabilities
  drm/vmwgfx: Sync virtual device headers for new feature
  drm/vmwgfx: Add a new enum for SM5 graphics context capability
  drm/vmwgfx: Read new register for GB memory when available
  drm/vmwgfx: Support SM5 shader type in command buffer
  drm/vmwgfx: Add support for UA view commands
  drm/vmwgfx: Add support for indirect and dispatch commands
  drm/vmwgfx: Rename stream output target binding tracker struct
  drm/vmwgfx: Add support for streamoutput with mob commands
  drm/vmwgfx: Split surface metadata from struct vmw_surface
  drm/vmwgfx: Refactor surface_define to use vmw_surface_metadata
  drm/vmwgfx: Add surface define v4 command
  drm/vmwgfx: Add SM5 param for userspace

Thomas Hellström (VMware) (1):
  drm/vmwgfx: Use vmwgfx version 2.18 to signal SM5 compatibility

 drivers/gpu/drm/vmwgfx/Makefile   |   2 +-
 .../drm/vmwgfx/device_include/svga3d_cmd.h| 161 +++-
 .../vmwgfx/device_include/svga3d_devcaps.h| 787 +-
 .../gpu/drm/vmwgfx/device_include/svga3d_dx.h | 466 ++-
 .../drm/vmwgfx/device_include/svga3d_limits.h |  36 +-
 .../device_include/svga3d_surfacedefs.h   |  58 +-
 .../drm/vmwgfx/device_include/svga3d_types.h  | 347 +++-
 .../gpu/drm/vmwgfx/device_include/svga_reg.h  | 382 ++---
 .../drm/vmwgfx/device_include/svga_types.h|   1 +
 drivers/gpu/drm/vmwgfx/vmwgfx_binding.c   | 213 -
 drivers/gpu/drm/vmwgfx/vmwgfx_binding.h   |  33 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_context.c   |  28 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c   |   6 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   |  59 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h   | 140 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c   | 429 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c |  18 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c   |  43 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_mob.c   |   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_so.c|  12 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_so.h|   7 +
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c  |  61 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c  | 387 +
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c   | 608 +++---
 include/uapi/drm/vmwgfx_drm.h |  16 +-
 25 files changed, 3252 insertions(+), 1050 deletions(-)
 create mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c

-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 15/17] drm/vmwgfx: Add surface define v4 command

2020-03-23 Thread Roland Scheidegger (VMware)
From: Deepak Rawat 

Surface define v4 added new member buffer_byte_stride. With this patch
add buffer_byte_stride in surface metadata and create surface using new
command if support is available.

Also with this patch replace device specific data types with kernel
types.

Signed-off-by: Deepak Rawat 
Reviewed-by: Thomas Hellström (VMware) 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |  2 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 36 +++--
 include/uapi/drm/vmwgfx_drm.h   | 12 +
 3 files changed, 43 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 326d1dd58bc5..0447be87697e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -238,6 +238,7 @@ struct vmw_surface_offset;
  * @array_size: Number of array elements for a 1D/2D texture. For cubemap
 texture number of faces * array_size. This should be 0 for pre
SM4 device.
+ * @buffer_byte_stride: Buffer byte stride.
  * @num_sizes: Size of @sizes. For GB surface this should always be 1.
  * @base_size: Surface dimension.
  * @sizes: Array representing mip sizes. Legacy only.
@@ -255,6 +256,7 @@ struct vmw_surface_metadata {
u32 autogen_filter;
u32 array_size;
u32 num_sizes;
+   u32 buffer_byte_stride;
struct drm_vmw_size base_size;
struct drm_vmw_size *sizes;
bool scanout;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
index 6c907b147e97..7ef51fa84b01 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -1082,6 +1082,10 @@ static int vmw_gb_surface_create(struct vmw_resource 
*res)
SVGA3dCmdHeader header;
SVGA3dCmdDefineGBSurface_v3 body;
} *cmd3;
+   struct {
+   SVGA3dCmdHeader header;
+   SVGA3dCmdDefineGBSurface_v4 body;
+   } *cmd4;
 
if (likely(res->id != -1))
return 0;
@@ -1098,7 +1102,11 @@ static int vmw_gb_surface_create(struct vmw_resource 
*res)
goto out_no_fifo;
}
 
-   if (has_sm4_1_context(dev_priv) && metadata->array_size > 0) {
+   if (has_sm5_context(dev_priv) && metadata->array_size > 0) {
+   cmd_id = SVGA_3D_CMD_DEFINE_GB_SURFACE_V4;
+   cmd_len = sizeof(cmd4->body);
+   submit_len = sizeof(*cmd4);
+   } else if (has_sm4_1_context(dev_priv) && metadata->array_size > 0) {
cmd_id = SVGA_3D_CMD_DEFINE_GB_SURFACE_V3;
cmd_len = sizeof(cmd3->body);
submit_len = sizeof(*cmd3);
@@ -1116,12 +1124,29 @@ static int vmw_gb_surface_create(struct vmw_resource 
*res)
cmd = VMW_FIFO_RESERVE(dev_priv, submit_len);
cmd2 = (typeof(cmd2))cmd;
cmd3 = (typeof(cmd3))cmd;
+   cmd4 = (typeof(cmd4))cmd;
if (unlikely(!cmd)) {
ret = -ENOMEM;
goto out_no_fifo;
}
 
-   if (has_sm4_1_context(dev_priv) && metadata->array_size > 0) {
+   if (has_sm5_context(dev_priv) && metadata->array_size > 0) {
+   cmd4->header.id = cmd_id;
+   cmd4->header.size = cmd_len;
+   cmd4->body.sid = srf->res.id;
+   cmd4->body.surfaceFlags = metadata->flags;
+   cmd4->body.format = metadata->format;
+   cmd4->body.numMipLevels = metadata->mip_levels[0];
+   cmd4->body.multisampleCount = metadata->multisample_count;
+   cmd4->body.multisamplePattern = metadata->multisample_pattern;
+   cmd4->body.qualityLevel = metadata->quality_level;
+   cmd4->body.autogenFilter = metadata->autogen_filter;
+   cmd4->body.size.width = metadata->base_size.width;
+   cmd4->body.size.height = metadata->base_size.height;
+   cmd4->body.size.depth = metadata->base_size.depth;
+   cmd4->body.arraySize = metadata->array_size;
+   cmd4->body.bufferByteStride = metadata->buffer_byte_stride;
+   } else if (has_sm4_1_context(dev_priv) && metadata->array_size > 0) {
cmd3->header.id = cmd_id;
cmd3->header.size = cmd_len;
cmd3->body.sid = srf->res.id;
@@ -1341,6 +1366,7 @@ int vmw_gb_surface_define_ioctl(struct drm_device *dev, 
void *data,
req_ext.svga3d_flags_upper_32_bits = 0;
req_ext.multisample_pattern = SVGA3D_MS_PATTERN_NONE;
req_ext.quality_level = SVGA3D_MS_QUALITY_NONE;
+   req_ext.buffer_byte_stride = 0;
req_ext.must_be_zero = 0;
 
return vmw_gb_surface_define_internal(dev, _ext, rep, file_priv);
@@ -1467,6 +1493,11 @@ vmw_gb_surface_define_internal(struct drm_device *dev,
}
}
 
+   if (req->buffer_byte_stride > 0 && 

[PATCH v2 10/17] drm/vmwgfx: Add support for indirect and dispatch commands

2020-03-23 Thread Roland Scheidegger (VMware)
From: Deepak Rawat 

Validate indirect and dispatch commands in command buffer.

Signed-off-by: Deepak Rawat 
Reviewed-by: Thomas Hellström (VMware) 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 70 +
 1 file changed, 70 insertions(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index ed56d9918c6a..ecab6cbbc8d3 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -2816,6 +2816,16 @@ static int vmw_cmd_intra_surface_copy(struct vmw_private 
*dev_priv,
 >body.surface.sid, NULL);
 }
 
+static int vmw_cmd_sm5(struct vmw_private *dev_priv,
+  struct vmw_sw_context *sw_context,
+  SVGA3dCmdHeader *header)
+{
+   if (!has_sm5_context(dev_priv))
+   return -EINVAL;
+
+   return 0;
+}
+
 static int vmw_cmd_sm5_view_define(struct vmw_private *dev_priv,
   struct vmw_sw_context *sw_context,
   SVGA3dCmdHeader *header)
@@ -2938,6 +2948,57 @@ static int vmw_cmd_set_cs_uav(struct vmw_private 
*dev_priv,
return ret;
 }
 
+static int vmw_cmd_indexed_instanced_indirect(struct vmw_private *dev_priv,
+ struct vmw_sw_context *sw_context,
+ SVGA3dCmdHeader *header)
+{
+   struct vmw_draw_indexed_instanced_indirect_cmd {
+   SVGA3dCmdHeader header;
+   SVGA3dCmdDXDrawIndexedInstancedIndirect body;
+   } *cmd = container_of(header, typeof(*cmd), header);
+
+   if (!has_sm5_context(dev_priv))
+   return -EINVAL;
+
+   return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
+VMW_RES_DIRTY_NONE, user_surface_converter,
+>body.argsBufferSid, NULL);
+}
+
+static int vmw_cmd_instanced_indirect(struct vmw_private *dev_priv,
+ struct vmw_sw_context *sw_context,
+ SVGA3dCmdHeader *header)
+{
+   struct vmw_draw_instanced_indirect_cmd {
+   SVGA3dCmdHeader header;
+   SVGA3dCmdDXDrawInstancedIndirect body;
+   } *cmd = container_of(header, typeof(*cmd), header);
+
+   if (!has_sm5_context(dev_priv))
+   return -EINVAL;
+
+   return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
+VMW_RES_DIRTY_NONE, user_surface_converter,
+>body.argsBufferSid, NULL);
+}
+
+static int vmw_cmd_dispatch_indirect(struct vmw_private *dev_priv,
+struct vmw_sw_context *sw_context,
+SVGA3dCmdHeader *header)
+{
+   struct vmw_dispatch_indirect_cmd {
+   SVGA3dCmdHeader header;
+   SVGA3dCmdDXDispatchIndirect body;
+   } *cmd = container_of(header, typeof(*cmd), header);
+
+   if (!has_sm5_context(dev_priv))
+   return -EINVAL;
+
+   return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface,
+VMW_RES_DIRTY_NONE, user_surface_converter,
+>body.argsBufferSid, NULL);
+}
+
 static int vmw_cmd_check_not_3d(struct vmw_private *dev_priv,
struct vmw_sw_context *sw_context,
void *buf, uint32_t *size)
@@ -3303,8 +3364,17 @@ static const struct vmw_cmd_entry 
vmw_cmd_entries[SVGA_3D_CMD_MAX] = {
false, true),
VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_UA_VIEWS, _cmd_set_uav, true, false,
true),
+   VMW_CMD_DEF(SVGA_3D_CMD_DX_DRAW_INDEXED_INSTANCED_INDIRECT,
+   _cmd_indexed_instanced_indirect, true, false, true),
+   VMW_CMD_DEF(SVGA_3D_CMD_DX_DRAW_INSTANCED_INDIRECT,
+   _cmd_instanced_indirect, true, false, true),
+   VMW_CMD_DEF(SVGA_3D_CMD_DX_DISPATCH, _cmd_sm5, true, false, true),
+   VMW_CMD_DEF(SVGA_3D_CMD_DX_DISPATCH_INDIRECT,
+   _cmd_dispatch_indirect, true, false, true),
VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_CS_UA_VIEWS, _cmd_set_cs_uav, true,
false, true),
+   VMW_CMD_DEF(SVGA_3D_CMD_DX_DEFINE_DEPTHSTENCIL_VIEW_V2,
+   _cmd_sm5_view_define, true, false, true),
 };
 
 bool vmw_cmd_describe(const void *buf, u32 *size, char const **cmd)
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 07/17] drm/vmwgfx: Read new register for GB memory when available

2020-03-23 Thread Roland Scheidegger (VMware)
From: Deepak Rawat 

Virtual device added new register for suggested GB memory, read the new
register when available.

Signed-off-by: Deepak Rawat 
Reviewed-by: Thomas Hellström (VMware) 
Reviewed-by: Roland Scheidegger 
Signed-off-by: Roland Scheidegger 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index b55bd3b5f5cd..71e45b568511 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -720,9 +720,15 @@ static int vmw_driver_load(struct drm_device *dev, 
unsigned long chipset)
dev_priv->max_mob_pages = 0;
dev_priv->max_mob_size = 0;
if (dev_priv->capabilities & SVGA_CAP_GBOBJECTS) {
-   uint64_t mem_size =
-   vmw_read(dev_priv,
-SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB);
+   uint64_t mem_size;
+
+   if (dev_priv->capabilities2 & SVGA_CAP2_GB_MEMSIZE_2)
+   mem_size = vmw_read(dev_priv,
+   SVGA_REG_GBOBJECT_MEM_SIZE_KB);
+   else
+   mem_size =
+   vmw_read(dev_priv,
+
SVGA_REG_SUGGESTED_GBOBJECT_MEM_SIZE_KB);
 
/*
 * Workaround for low memory 2D VMs to compensate for the
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[git pull] feature/staging_sm5

2020-03-20 Thread Roland Scheidegger (VMware)
Dave, Daniel,

vmwgfx pull for for 5.7. Needed for GL4 functionality.
Sync up device headers, add support for new commands, code
refactoring around surface definition.

Preliminary mesa userspace code using these new vmwgfx features
can be found at: https://gitlab.freedesktop.org/bhenden/mesa

The following changes since commit dad569af718c4e603c35f59ed03bf0555633dd95:

  drm/vmwgfx: Refuse DMA operation when SEV encryption is active (2020-01-28 
09:27:45 +0100)

are available in the Git repository at:

  g...@gitlab.freedesktop.org:sroland/vmwgfx_drm.git feature/staging_sm5

for you to fetch changes up to 4526035058cc6cc09afbca3a5d86862438ae1edf:

  drm/vmwgfx: Use vmwgfx version 2.18 to signal SM5 compatibility (2020-03-20 
23:35:53 +0100)


Deepak Rawat (16):
  drm/vmwgfx: Also check for SVGA_CAP_DX before reading DX context support
  drm/vmwgfx: Sync legacy multisampling device capability
  drm/vmwgfx: Deprecate logic ops commands
  drm/vmwgfx: Use enum to represent graphics context capabilities
  drm/vmwgfx: Sync virtual device headers for new feature
  drm/vmwgfx: Add a new enum for SM5 graphics context capability
  drm/vmwgfx: Read new register for GB memory when available
  drm/vmwgfx: Support SM5 shader type in command buffer
  drm/vmwgfx: Add support for UA view commands
  drm/vmwgfx: Add support for indirect and dispatch commands
  drm/vmwgfx: Rename stream output target binding tracker struct
  drm/vmwgfx: Add support for streamoutput with mob commands
  drm/vmwgfx: Split surface metadata from struct vmw_surface
  drm/vmwgfx: Refactor surface_define to use vmw_surface_metadata
  drm/vmwgfx: Add surface define v4 command
  drm/vmwgfx: Add SM5 param for userspace

Thomas Hellström (VMware) (1):
  drm/vmwgfx: Use vmwgfx version 2.18 to signal SM5 compatibility

 drivers/gpu/drm/vmwgfx/Makefile|   2 +-
 drivers/gpu/drm/vmwgfx/device_include/svga3d_cmd.h | 161 -
 .../gpu/drm/vmwgfx/device_include/svga3d_devcaps.h | 787 +++--
 drivers/gpu/drm/vmwgfx/device_include/svga3d_dx.h  | 466 +++-
 .../gpu/drm/vmwgfx/device_include/svga3d_limits.h  |  36 +-
 .../drm/vmwgfx/device_include/svga3d_surfacedefs.h |  58 +-
 .../gpu/drm/vmwgfx/device_include/svga3d_types.h   | 347 +++--
 drivers/gpu/drm/vmwgfx/device_include/svga_reg.h   | 382 +++---
 drivers/gpu/drm/vmwgfx/device_include/svga_types.h |   1 +
 drivers/gpu/drm/vmwgfx/vmwgfx_binding.c| 213 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_binding.h|  33 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_context.c|  28 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c|   6 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c|  59 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h| 152 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c| 429 ++-
 drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c  |  18 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c|  43 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_mob.c|   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_so.c |  12 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_so.h |   7 +
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c   |  61 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c   | 387 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c| 608 
 include/uapi/drm/vmwgfx_drm.h  |  16 +-
 25 files changed, 3252 insertions(+), 1062 deletions(-)
 create mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_streamoutput.c
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel