[PATCH 12/14] MAINTAINERS: Add maintainer entry for the VMWGFX DRM driver

2016-04-25 Thread Sinclair Yeh
On Sun, Apr 24, 2016 at 11:12:28AM +0100, Emil Velikov wrote:
> On 22 April 2016 at 15:22, Sinclair Yeh  wrote:
> > Hi,
> >
> > On Fri, Apr 22, 2016 at 12:04:00AM +0100, Emil Velikov wrote:
> >> Thomas is one of the original authors of the driver, with recent
> >> contributions from Sinclair and Brian.
> >>
> >> Cc: Sinclair Yeh 
> >> Cc: Thomas Hellstrom 
> >> Cc: Brian Paul 
> >> Cc: "VMware Graphics" 
> >> Signed-off-by: Emil Velikov 
> >> ---
> >> Gents can anyone confirm if the data is correct ?
> >
> > You can also add me as a maintainer for vmwgfx if you like.
> >
> Nice one, thanks.
> 
> Just realised that it's missing a tree tag, so based on the last few
> pull req. it should be:
> 
> T:git git://people.freedesktop.org/~thomash/linux

This is fine.

> 
> >>
> >> I'm thinking that the status should be Supported, although the driver
> >> hasn't see much action recently.
> >>
> Can I bother you for a confirmation on the Maintained vs Supported question ?

Yes, it's "Supported."

> 
> >> NOTE: The following email linux-graphics-maintainer at vmware.com is also
> >> listed for the VMMOUSE driver. Is that correct ?
> >
> > Yes, correct since it's the same team that maintains the vmmouse driver.
> >
> Ack.
> 
> Thanks
> Emil


[PATCH 1/3] drm/vmwgfx: Enable SVGA_3D_CMD_DX_SET_PREDICATION

2016-04-27 Thread Sinclair Yeh
From: Charmaine Lee 

Fixes piglit tests nv_conditional_render-* crashes.

Signed-off-by: Charmaine Lee 
Reviewed-by: Brian Paul 
Reviewed-by: Sinclair Yeh 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index 723ba16..541b340 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -3305,7 +3305,7 @@ static const struct vmw_cmd_entry 
vmw_cmd_entries[SVGA_3D_CMD_MAX] = {
true, false, true),
VMW_CMD_DEF(SVGA_3D_CMD_DX_READBACK_QUERY, &vmw_cmd_invalid,
true, false, true),
-   VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_PREDICATION, &vmw_cmd_invalid,
+   VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_PREDICATION, &vmw_cmd_dx_cid_check,
true, false, true),
VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_VIEWPORTS, &vmw_cmd_dx_cid_check,
true, false, true),
-- 
1.9.1



[PATCH 2/3] drm/vmwgfx: use vmw_cmd_dx_cid_check for query commands.

2016-04-27 Thread Sinclair Yeh
From: Charmaine Lee 

Instead of calling vmw_cmd_ok, call vmw_cmd_dx_cid_check to
validate the context id for query commands.

Signed-off-by: Charmaine Lee 
Reviewed-by: Sinclair Yeh 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index 541b340..1a1a87c 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -3293,15 +3293,15 @@ static const struct vmw_cmd_entry 
vmw_cmd_entries[SVGA_3D_CMD_MAX] = {
&vmw_cmd_dx_cid_check, true, false, true),
VMW_CMD_DEF(SVGA_3D_CMD_DX_DEFINE_QUERY, &vmw_cmd_dx_define_query,
true, false, true),
-   VMW_CMD_DEF(SVGA_3D_CMD_DX_DESTROY_QUERY, &vmw_cmd_ok,
+   VMW_CMD_DEF(SVGA_3D_CMD_DX_DESTROY_QUERY, &vmw_cmd_dx_cid_check,
true, false, true),
VMW_CMD_DEF(SVGA_3D_CMD_DX_BIND_QUERY, &vmw_cmd_dx_bind_query,
true, false, true),
VMW_CMD_DEF(SVGA_3D_CMD_DX_SET_QUERY_OFFSET,
-   &vmw_cmd_ok, true, false, true),
-   VMW_CMD_DEF(SVGA_3D_CMD_DX_BEGIN_QUERY, &vmw_cmd_ok,
+   &vmw_cmd_dx_cid_check, true, false, true),
+   VMW_CMD_DEF(SVGA_3D_CMD_DX_BEGIN_QUERY, &vmw_cmd_dx_cid_check,
true, false, true),
-   VMW_CMD_DEF(SVGA_3D_CMD_DX_END_QUERY, &vmw_cmd_ok,
+   VMW_CMD_DEF(SVGA_3D_CMD_DX_END_QUERY, &vmw_cmd_dx_cid_check,
true, false, true),
VMW_CMD_DEF(SVGA_3D_CMD_DX_READBACK_QUERY, &vmw_cmd_invalid,
true, false, true),
-- 
1.9.1



[PATCH 3/3] drm/vmwgfx: Fix order of operation

2016-04-27 Thread Sinclair Yeh
mode->hdisplay * (var->bits_per_pixel + 7) gets evaluated before
the division, potentially making the pitch larger than it should
be.

Since the original intention is to do a div-round-up, just use
the macro instead.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
index 3b1faf7..679a4cb 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
@@ -573,9 +573,9 @@ static int vmw_fb_set_par(struct fb_info *info)
mode = old_mode;
old_mode = NULL;
} else if (!vmw_kms_validate_mode_vram(vmw_priv,
-  mode->hdisplay *
-  (var->bits_per_pixel + 7) / 8,
-  mode->vdisplay)) {
+   mode->hdisplay *
+   DIV_ROUND_UP(var->bits_per_pixel, 8),
+   mode->vdisplay)) {
drm_mode_destroy(vmw_priv->dev, mode);
return -EINVAL;
}
-- 
1.9.1



[PATCH 3/3] drm/vmwgfx: Fix order of operation

2016-04-27 Thread Sinclair Yeh
mode->hdisplay * (var->bits_per_pixel + 7) gets evaluated before
the division, potentially making the pitch larger than it should
be.

Since the original intention is to do a div-round-up, just use
the macro instead.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
index 3b1faf7..679a4cb 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
@@ -573,9 +573,9 @@ static int vmw_fb_set_par(struct fb_info *info)
mode = old_mode;
old_mode = NULL;
} else if (!vmw_kms_validate_mode_vram(vmw_priv,
-  mode->hdisplay *
-  (var->bits_per_pixel + 7) / 8,
-  mode->vdisplay)) {
+   mode->hdisplay *
+   DIV_ROUND_UP(var->bits_per_pixel, 8),
+   mode->vdisplay)) {
drm_mode_destroy(vmw_priv->dev, mode);
return -EINVAL;
}
-- 
1.9.1



[PATCH 1/2] drm/vmwgfx: Add VMWare host messaging capability

2016-04-27 Thread Sinclair Yeh
This patch adds capabilities for a VMWare guest to send and
receive messages from the host, and adds functions to sending log
messages to vmware.log and to request device settings that aren't
available through the virtual hardware, e.g. certain settings in
the VMX file.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 418 
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.h | 192 +
 2 files changed, 610 insertions(+)
 create mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
 create mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_msg.h

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
new file mode 100644
index 000..9c2bb21
--- /dev/null
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
@@ -0,0 +1,418 @@
+/*
+ * Copyright © 2016 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+
+#include 
+#include 
+#include 
+#include 
+#include "drmP.h"
+#include "vmwgfx_msg.h"
+
+
+#define MESSAGE_STATUS_SUCCESS  0x0001
+#define MESSAGE_STATUS_DORECV   0x0002
+#define MESSAGE_STATUS_CPT  0x0010
+#define MESSAGE_STATUS_HB   0x0080
+
+#define RPCI_PROTOCOL_NUM   0x49435052
+#define GUESTMSG_FLAG_COOKIE0x8000
+
+#define RETRIES 3
+
+#define VMW_HYPERVISOR_MAGIC0x564D5868
+#define VMW_HYPERVISOR_PORT 0x5658
+#define VMW_HYPERVISOR_HB_PORT  0x5659
+
+#define VMW_PORT_CMD_MSG30
+#define VMW_PORT_CMD_HB_MSG 0
+#define VMW_PORT_CMD_OPEN_CHANNEL  (MSG_TYPE_OPEN << 16 | VMW_PORT_CMD_MSG)
+#define VMW_PORT_CMD_CLOSE_CHANNEL (MSG_TYPE_CLOSE << 16 | VMW_PORT_CMD_MSG)
+#define VMW_PORT_CMD_SENDSIZE   (MSG_TYPE_SENDSIZE << 16 | VMW_PORT_CMD_MSG)
+#define VMW_PORT_CMD_RECVSIZE   (MSG_TYPE_RECVSIZE << 16 | VMW_PORT_CMD_MSG)
+#define VMW_PORT_CMD_RECVSTATUS (MSG_TYPE_RECVSTATUS << 16 | VMW_PORT_CMD_MSG)
+
+#define HIGH_WORD(X) ((X & 0x) >> 16)
+
+static u32 vmw_msg_enabled = 1;
+
+enum rpc_msg_type {
+   MSG_TYPE_OPEN,
+   MSG_TYPE_SENDSIZE,
+   MSG_TYPE_SENDPAYLOAD,
+   MSG_TYPE_RECVSIZE,
+   MSG_TYPE_RECVPAYLOAD,
+   MSG_TYPE_RECVSTATUS,
+   MSG_TYPE_CLOSE,
+};
+
+struct rpc_channel {
+   u16 channel_id;
+   u32 cookie_high;
+   u32 cookie_low;
+};
+
+
+
+/**
+ * vmw_open_channel
+ *
+ * @channel: RPC channel
+ * @protocol:
+ *
+ * Returns: 0 on success
+ */
+static int vmw_open_channel(struct rpc_channel *channel, unsigned protocol)
+{
+   unsigned long eax, ebx, ecx, edx, si = 0, di = 0;
+
+   VMW_PORT(VMW_PORT_CMD_OPEN_CHANNEL,
+   (protocol | GUESTMSG_FLAG_COOKIE), si, di,
+   VMW_HYPERVISOR_PORT,
+   VMW_HYPERVISOR_MAGIC,
+   eax, ebx, ecx, edx, si, di);
+
+   if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0)
+   return -EINVAL;
+
+   channel->channel_id  = HIGH_WORD(edx);
+   channel->cookie_high = si;
+   channel->cookie_low  = di;
+
+   return 0;
+}
+
+
+
+/**
+ * vmw_close_channel
+ *
+ * @channel: RPC channel
+ *
+ * Returns: 0 on success
+ */
+static int vmw_close_channel(struct rpc_channel *channel)
+{
+   unsigned long eax, ebx, ecx, edx, si, di;
+
+   /* Set up additional parameters */
+   si  = channel->cookie_high;
+   di  = channel->cookie_low;
+
+   VMW_PORT(VMW_PORT_CMD_CLOSE_CHANNEL,
+   0, si, di,
+   (VMW_HYPERVISOR_PORT | (channel->channel_id << 16)),
+   VMW_HYPERVISOR_MAGIC,
+   eax, ebx, ecx, edx, si, di);
+
+   if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0)
+   return -EINVAL;
+
+   return 0;
+}
+
+
+
+/**
+ * vmw_send_msg: Sends 

[PATCH 2/2] drm/vmwgfx: Report vmwgfx version to vmware.log

2016-04-27 Thread Sinclair Yeh
When tracking down a customer issue, it is useful to know exactly
which version of the vmwgfx they are using.  Since vmware.log is
often the only available debug log, report vmwgfx version in there.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/.gitignore   |  2 ++
 drivers/gpu/drm/vmwgfx/Makefile |  7 ++-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 20 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |  6 ++
 4 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/vmwgfx/.gitignore

diff --git a/drivers/gpu/drm/vmwgfx/.gitignore 
b/drivers/gpu/drm/vmwgfx/.gitignore
new file mode 100644
index 000..7193109
--- /dev/null
+++ b/drivers/gpu/drm/vmwgfx/.gitignore
@@ -0,0 +1,2 @@
+vmwgfx_version.h
+
diff --git a/drivers/gpu/drm/vmwgfx/Makefile b/drivers/gpu/drm/vmwgfx/Makefile
index d281575..fd6f47f 100644
--- a/drivers/gpu/drm/vmwgfx/Makefile
+++ b/drivers/gpu/drm/vmwgfx/Makefile
@@ -8,6 +8,11 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o 
vmwgfx_drv.o \
vmwgfx_fence.o vmwgfx_dmabuf.o vmwgfx_scrn.o vmwgfx_context.o \
vmwgfx_surface.o vmwgfx_prime.o vmwgfx_mob.o vmwgfx_shader.o \
vmwgfx_cmdbuf_res.o vmwgfx_cmdbuf.o vmwgfx_stdu.o \
-   vmwgfx_cotable.o vmwgfx_so.o vmwgfx_binding.o
+   vmwgfx_cotable.o vmwgfx_so.o vmwgfx_binding.o vmwgfx_msg.o
+
+$(obj)/vmwgfx_drv.o: $(src)/vmwgfx_version.h
+
+$(src)/vmwgfx_version.h:
+   @echo "#define VMWGFX_GIT_VERSION \""`git rev-parse --short HEAD`"\"" > 
$(src)/vmwgfx_version.h

 obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index e7335a48..b37f388 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1,6 +1,6 @@
 /**
  *
- * Copyright © 2009-2015 VMware, Inc., Palo Alto, CA., USA
+ * Copyright © 2009-2016 VMware, Inc., Palo Alto, CA., USA
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include "vmwgfx_version.h"

 #define VMWGFX_DRIVER_NAME "vmwgfx"
 #define VMWGFX_DRIVER_DESC "Linux drm driver for VMware graphics devices"
@@ -44,6 +45,12 @@
 #define VMW_MIN_INITIAL_WIDTH 800
 #define VMW_MIN_INITIAL_HEIGHT 600

+#ifndef VMWGFX_GIT_VERSION
+#define VMWGFX_GIT_VERSION "Unknown"
+#endif
+
+#define VMWGFX_REPO "In Tree"
+

 /**
  * Fully encoded drm commands. Might move to vmw_drm.h
@@ -613,6 +620,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned 
long chipset)
uint32_t svga_id;
enum vmw_res_type i;
bool refuse_dma = false;
+   char host_log[100] = {0};

dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
if (unlikely(dev_priv == NULL)) {
@@ -873,6 +881,16 @@ static int vmw_driver_load(struct drm_device *dev, 
unsigned long chipset)

DRM_INFO("DX: %s\n", dev_priv->has_dx ? "yes." : "no.");

+   snprintf(host_log, sizeof(host_log), "vmwgfx: %s-%s",
+   VMWGFX_REPO, VMWGFX_GIT_VERSION);
+   vmw_host_log(host_log);
+
+   memset(host_log, 0, sizeof(host_log));
+   snprintf(host_log, sizeof(host_log), "vmwgfx: Module Version: %d.%d.%d",
+   VMWGFX_DRIVER_MAJOR, VMWGFX_DRIVER_MINOR,
+   VMWGFX_DRIVER_PATCHLEVEL);
+   vmw_host_log(host_log);
+
if (dev_priv->enable_fb) {
vmw_fifo_resource_inc(dev_priv);
vmw_svga_enable(dev_priv);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 019a6ca..6715d4a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -1234,4 +1234,10 @@ static inline void vmw_mmio_write(u32 value, u32 *addr)
 {
WRITE_ONCE(*addr, value);
 }
+
+/**
+ * Add vmw_msg module function
+ */
+extern int vmw_host_log(const char *log);
+
 #endif
-- 
1.9.1



[git pull] vmwgfx-fixes

2016-04-28 Thread Sinclair Yeh
Hi Dave,

The following changes since commit 928815245cbdaa611873424759d5e7a7293dd18b:

  Merge tag 'drm-intel-fixes-2016-04-07' of 
git://anongit.freedesktop.org/drm-intel into drm-fixes (2016-04-11 13:30:05 
+1000)

are available in the git repository at:


  git://people.freedesktop.org/~syeh/repos_linux drm-vmwgfx-fixes

for you to fetch changes up to 7851496a32319237456919575e5f4ba62f74cc7d:

  drm/vmwgfx: Fix order of operation (2016-04-28 11:07:30 -0700)


Charmaine Lee (2):
  drm/vmwgfx: Enable SVGA_3D_CMD_DX_SET_PREDICATION
  drm/vmwgfx: use vmw_cmd_dx_cid_check for query commands.

Sinclair Yeh (1):
  drm/vmwgfx: Fix order of operation

 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 10 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c  |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)



[PATCH 0215/1285] Replace numeric parameter like 0444 with macro

2016-08-04 Thread Sinclair Yeh
Reviewed-by: Sinclair Yeh 

On Tue, Aug 02, 2016 at 06:50:25PM +0800, Baole Ni wrote:
> I find that the developers often just specified the numeric value
> when calling a macro which is defined with a parameter for access permission.
> As we know, these numeric value for access permission have had the 
> corresponding macro,
> and that using macro can improve the robustness and readability of the code,
> thus, I suggest replacing the numeric parameter with the macro.
> 
> Signed-off-by: Chuansheng Liu 
> Signed-off-by: Baole Ni 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 9fcd820..b8e5d3d 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -240,15 +240,15 @@ static int vmwgfx_pm_notifier(struct notifier_block 
> *nb, unsigned long val,
> void *ptr);
>  
>  MODULE_PARM_DESC(enable_fbdev, "Enable vmwgfx fbdev");
> -module_param_named(enable_fbdev, enable_fbdev, int, 0600);
> +module_param_named(enable_fbdev, enable_fbdev, int, S_IRUSR | S_IWUSR);
>  MODULE_PARM_DESC(force_dma_api, "Force using the DMA API for TTM pages");
> -module_param_named(force_dma_api, vmw_force_iommu, int, 0600);
> +module_param_named(force_dma_api, vmw_force_iommu, int, S_IRUSR | S_IWUSR);
>  MODULE_PARM_DESC(restrict_iommu, "Try to limit IOMMU usage for TTM pages");
> -module_param_named(restrict_iommu, vmw_restrict_iommu, int, 0600);
> +module_param_named(restrict_iommu, vmw_restrict_iommu, int, S_IRUSR | 
> S_IWUSR);
>  MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages");
> -module_param_named(force_coherent, vmw_force_coherent, int, 0600);
> +module_param_named(force_coherent, vmw_force_coherent, int, S_IRUSR | 
> S_IWUSR);
>  MODULE_PARM_DESC(restrict_dma_mask, "Restrict DMA mask to 44 bits with 
> IOMMU");
> -module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, 0600);
> +module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, S_IRUSR | 
> S_IWUSR);
>  
>  
>  static void vmw_print_capabilities(uint32_t capabilities)
> -- 
> 2.9.2
> 


[Intel-gfx] [PATCH 05/11] drm/vmwgfx: Remove call to reservation_object_test_signaled_rcu before wait

2016-10-05 Thread Sinclair Yeh
Hi,

I'm preparing a fixes pull request, and I'll include this one if it
hasn't been applied by others already.

Sinclair


On Wed, Oct 05, 2016 at 09:41:22PM +0530, Sumit Semwal wrote:
> Hi Thomas, Sinclair,
> 
> On 23 September 2016 at 18:26, Daniel Vetter  wrote:
> > On Mon, Aug 29, 2016 at 08:08:28AM +0100, Chris Wilson wrote:
> >> Since fence_wait_timeout_reservation_object_wait_timeout_rcu() with a
> >> timeout of 0 becomes reservation_object_test_signaled_rcu(), we do not
> >> need to handle such conversion in the caller. The only challenge are
> >> those callers that wish to differentiate the error code between the
> >> nonblocking busy check and potentially blocking wait.
> >>
> >> Signed-off-by: Chris Wilson 
> >> Cc: Sinclair Yeh 
> >> Cc: Thomas Hellstrom 
> >> Reviewed-by: Sinclair Yeh 
> >
> > Reviewed-by: Daniel Vetter 
> >
> Could you please let me know if this patch is already queued up at
> your end, or should I just take it via drm-misc with Sinclair's r-b?
> 
> Thanks and Best,
> Sumit.


[git pull] vmwgfx-fixes

2016-10-17 Thread Sinclair Yeh
Hi Dave,

The following changes since commit 90fd68dcf9a763f7e575c8467415bd8a66d073f4:

  drm/udl: fix line iterator in damage handling (2016-09-28 13:29:18 +1000)

are available in the git repository at:

  ssh://people.freedesktop.org/~syeh/repos_linux drm-vmwgfx-fixes

for you to fetch changes up to 862f6157d176c9db5a7ed423245108d9bb3d7038:

  drm/vmwgfx: Adjust checks for null pointers in 13 functions (2016-10-10 
13:23:16 -0700)


Baole Ni (1):
  drm/vmwgfx: Replace numeric parameter like 0444 with macro

Charmaine Lee (1):
  drm/vmwgfx: Enable SVGA_3D_CMD_DX_TRANSFER_FROM_BUFFER command

Chris Wilson (1):
  drm/vmwgfx: Remove call to reservation_object_test_signaled_rcu before 
wait

Markus Elfring (3):
  drm/vmwgfx: Use kmalloc_array() in vmw_surface_define_ioctl()
  drm/vmwgfx: Use memdup_user() rather than duplicating its implementation
  drm/vmwgfx: Adjust checks for null pointers in 13 functions

Thomas Hellstrom (4):
  drm/vmwgfx: Allow resource relocations on byte boundaries
  drm/vmwgfx: Remove a leftover debug printout
  drm/vmwgfx: Limit the user-space command buffer size
  drm/vmwgfx: Avoid validating views on view destruction

 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c  |  10 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h  |   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c  | 145 
+
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c |   6 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c  |  56 
--
 5 files changed, 146 insertions(+), 73 deletions(-)



Re: [PATCH 10/11] drm/vmwgfx: Switch over to internal atomic API for STDU

2017-03-29 Thread Sinclair Yeh
Hi Daniel,

On Tue, Mar 28, 2017 at 09:49:38AM +0200, Daniel Vetter wrote:
> On Mon, Mar 27, 2017 at 03:01:03PM -0700, Sinclair Yeh wrote:
> > Switch over to using internal atomic API for mode set.
> > 
> > This removes the legacy set_config API, replacing it with
> > drm_atomic_helper_set_config().  The DRM helper will use various
> > vmwgfx-specific atomic functions to set a mode.
> > 
> > DRIVER_ATOMIC capability flag is not yet set, so the user mode
> > will still use the legacy mode set IOCTL.
> > 
> > v2:
> > * Avoid a clash between page-flip pinning and setcrtc pinning, modify
> > the page-flip code to use the page-flip helper and the atomic callbacks.
> > To enable this, we will need to add a wrapper around atomic_commit.
> > 
> > * Add vmw_kms_set_config() to work around vmwgfx xorg driver bug
> > 
> > Signed-off-by: Sinclair Yeh 
> > Signed-off-by: Thomas Hellstrom 
> > Reviewed-by: Thomas Hellstrom 
> > ---
> >  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  |  20 +++
> >  drivers/gpu/drm/vmwgfx/vmwgfx_kms.h  |   1 +
> >  drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 325 
> > ---
> >  3 files changed, 51 insertions(+), 295 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
> > b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > index 6b593aaf..7104796 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > @@ -2923,3 +2923,23 @@ vmw_kms_create_implicit_placement_property(struct 
> > vmw_private *dev_priv,
> >   "implicit_placement", 0, 1);
> >  
> >  }
> > +
> > +
> > +/**
> > + * vmw_kms_set_config - Wrapper around drm_atomic_helper_set_config
> > + *
> > + * @set: The configuration to set.
> > + *
> > + * The vmwgfx Xorg driver doesn't assign the mode::type member, which
> > + * when drm_mode_set_crtcinfo is called as part of the configuration 
> > setting
> > + * causes it to return incorrect crtc dimensions causing severe problems in
> > + * the vmwgfx modesetting. So explicitly clear that member before calling
> > + * into drm_atomic_helper_set_config.
> > + */
> > +int vmw_kms_set_config(struct drm_mode_set *set)
> > +{
> > +   if (set && set->mode)
> > +   set->mode->type = 0;
> 
> ugh :( Looking at set_crtcinfo the only thing I can see it look at ->type
> is to check for built-in modes. Not a single driver is using that afaics,
> we might as well remove this and and void the vmw special case here too.

Do you mean remove drm_display_mode->type field altogether or just
the check in drm_mode_set_crtcinfo?

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


Re: [PATCH] kernel: drm/vmwgfx: limit the number of mip levels in vmw_gb_surface_define_ioctl()

2017-03-31 Thread Sinclair Yeh
Hi Vladis,


On Thu, Mar 30, 2017 at 12:27:12PM +0200, Vladis Dronov wrote:
> The 'req->mip_levels' parameter in vmw_gb_surface_define_ioctl() is
> a user-controlled 'uint32_t' value which is used as a loop count limit.
> This can lead to a kernel lockup and DoS. Add check for 'req->mip_levels'.
> 
> References:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.redhat.com_show-5Fbug.cgi-3Fid-3D1437431&d=DwIBAg&c=uilaK90D4TOVoH58JNXRgQ&r=HaJ2a6NYExoV0cntAYcoqA&m=5yR87BuuU86aoAjCveInxh6jvgOyumqIHQhTs0xLo38&s=tWQs7vwNLgD_b2RWMddVtusEKh9FQTIF5rKFOWudslE&e=
>  
> Signed-off-by: Vladis Dronov 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> index b445ce9..b30824b 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> @@ -1281,6 +1281,10 @@ int vmw_gb_surface_define_ioctl(struct drm_device 
> *dev, void *data,
>   if (req->multisample_count != 0)
>   return -EINVAL;
>  
> + if (req->mip_levels > DRM_VMW_MAX_SURFACE_FACES *
> + DRM_VMW_MAX_MIP_LEVELS)
> + return -EINVAL;
> +

Here, the check should be "> DRM_VMW_MAX_MIP_LEVELS" because req->mip_levels
is only for one layer.

Also, as long as we can doing a check, I would suggest we check for 0 as
well.

Sinclair

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


[git pull] vmwgfx-next

2017-03-31 Thread Sinclair Yeh
Hi Dave,

This series enables atomic mode set for vmwgfx.  A number of features and
larger fixes are also included.

The following changes since commit 8cd3ac52963f2e99f4c21d1c9ce89531ce66c2d6:

  Merge branch 'drm-next-4.12' of git://people.freedesktop.org/~agd5f/linux 
into drm-next (2017-03-31 11:47:18 +1000)

are available in the git repository at:

  git://people.freedesktop.org/~syeh/repos_linux drm-vmwgfx-next

for you to fetch changes up to 28c954299cd2b5cb5411816c9eeaf3f51ed4638e:

  drm/vmwgfx: Properly check display/scanout surface size (2017-03-31 15:21:20 
-0700)

----
Sinclair Yeh (18):
  drm/vmwgfx: Removed unused snooper.crtc field
  drm/vmwgfx: Add universal plane support
  drm/vmwgfx: CRTC atomic state
  drm/vmwgfx: Plane atomic state
  drm/vmwgfx: Connector atomic state
  drm/vmwgfx: Add and connect CRTC helper functions
  drm/vmwgfx: Add and connect plane helper functions
  drm/vmwgfx: Add and connect connector helper function
  drm/vmwgfx: Add and connect atomic state object check/commit
  drm/vmwgfx: Fixes to vmwgfx_fb
  drm/vmwgfx: Switch over to internal atomic API for STDU
  drm/vmwgfx: Switch over to internal atomic API for SOU and LDU
  drm/vmwgfx: Turn on DRIVER_ATOMIC flag
  drm/vmwgfx: Explicityly track screen target width and height
  drm/vmwgfx: Skipping fbdev fb pinning for ldu
  drm/vmwgfx: Fix LDU X blank screen until mode change issue
  drm/vmwgfx: Support topology greater than texture size
  drm/vmwgfx: Properly check display/scanout surface size

Thomas Hellstrom (3):
  drm/vmwgfx: Introduce a simple resource type
  drm/vmwgfx: Re-implement the stream resource as a simple resource.
  drm/vmwgfx: Define an overlaid handle_close ioctl.

Øyvind A. Holm (1):
  drm/vmwgfx: Revert "drm/vmwgfx: Replace numeric parameter like 0444 with 
macro"

 drivers/gpu/drm/vmwgfx/Makefile |3 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c |   13 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c  |   27 ++-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  
+++--
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h |  143 --
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c |  373 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c|  254 
 drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h   |   40 
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c|  510 
+++-
 drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c |  256 
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c|  937 

 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c |   15 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_va.c  |  168 
 include/uapi/drm/vmwgfx_drm.h   |   24 +++
 15 files changed, 2856 insertions(+), 1020 deletions(-)
 create mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c
 create mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_va.c

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


Re: [PATCH 4/9] drm/vmwgfx: Revert "drm/vmwgfx: Replace numeric parameter like 0444 with macro"

2017-04-03 Thread Sinclair Yeh
On Sun, Apr 02, 2017 at 08:54:14AM +0200, Øyvind A. Holm wrote:
> On 2017-03-27 15:17:54, Sinclair Yeh wrote:
> > From: Øyvind A. Holm 
> >
> > This reverts commit 2d8e60e8b074 ("drm/vmwgfx: Replace numeric
> > parameter like 0444 with macro")
> > [...]
> > index 45d711e..d31dc34 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > @@ -241,13 +241,13 @@ static int vmwgfx_pm_notifier(struct notifier_block 
> > *nb, unsigned long val,
> >   void *ptr);
> >
> >  MODULE_PARM_DESC(enable_fbdev, "Enable vmwgfx fbdev");
> > -module_param_named(enable_fbdev, enable_fbdev, int, S_IRUSR | S_IWUSR);
> > +module_param_named(enable_fbdev, enable_fbdev, int, 0600);
> >  MODULE_PARM_DESC(force_dma_api, "Force using the DMA API for TTM pages");
> > -module_param_named(force_dma_api, vmw_force_iommu, int, S_IRUSR | S_IWUSR);
> > +module_param_named(force_dma_api, vmw_force_iommu, int, 0600);
> >  MODULE_PARM_DESC(restrict_iommu, "Try to limit IOMMU usage for TTM pages");
> > -module_param_named(restrict_iommu, vmw_restrict_iommu, int, S_IRUSR | 
> > S_IWUSR);
> > +module_param_named(restrict_iommu, vmw_restrict_iommu, int, 0600);
> >  MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages");
> > -module_param_named(force_coherent, vmw_force_coherent, int, S_IRUSR | 
> > S_IWUSR);
> > +module_param_named(force_coherent, vmw_force_coherent, int, 0600);
> >  MODULE_PARM_DESC(restrict_dma_mask, "Restrict DMA mask to 44 bits with 
> > IOMMU");
> >  module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, S_IRUSR 
> > | S_IWUSR);
> >  MODULE_PARM_DESC(assume_16bpp, "Assume 16-bpp when filtering modes");
> > --
> > 2.7.4
> 
> It seems as something has happened to the patch when applied, the last 
> change is gone, it was in my original patch sent to the list. This 
> change is missing:
> 
>   -module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, S_IRUSR 
> | S_IWUSR);
>   +module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, 0600);

Hmm... I'll put this as a new patch then.

thanks for letting me know!

Sinclair

> 
> I suppose it's to late to fix this exact commit (50f837371dd9) now 
> because it's part of the request-pull mail sent 2017-03-31 16:32:55 
> -0700. I can send a new patch created on top of commit 28c954299cd2 
> ("drm/vmwgfx: Properly check display/scanout surface size") that 
> completes this patch, if it's ok.
> 
> Regards,
> Øyvind
> 
> +-| Øyvind A. Holm  - N 60.37604° E 5.9° |-+
> | OpenPGP: 0xFB0CBEE894A506E5 - http://www.sunbase.org/pubkey.asc |
> | Fingerprint: A006 05D6 E676 B319 55E2  E77E FB0C BEE8 94A5 06E5 |
> +| 32db7b80-176e-11e7-8de9-db5caa6d21d3 |-+


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


Re: linux-next: build failure after merge of the drm-misc tree

2017-04-03 Thread Sinclair Yeh
Thanks for this.   This and "drm/vmwgfx: merge fixup for set_config API change":

Reviewed-by: Sinclair Yeh 

On Mon, Apr 03, 2017 at 01:31:29PM +1000, Stephen Rothwell wrote:
> Hi all,
> 
> After merging the drm-misc tree, today's linux-next build (x86_64
> allmodconfig) failed like this:
> 
> drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c: In function 'vmw_sou_crtc_page_flip':
> drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c:327:8: error: too few arguments to 
> function 'drm_atomic_helper_page_flip'
>   ret = drm_atomic_helper_page_flip(crtc, new_fb, NULL, flags);
> ^
> In file included from drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c:31:0:
> include/drm/drm_atomic_helper.h:126:5: note: declared here
>  int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
>  ^
> drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c: In function 'vmw_stdu_crtc_page_flip':
> drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c:508:8: error: too few arguments to 
> function 'drm_atomic_helper_page_flip'
>   ret = drm_atomic_helper_page_flip(crtc, new_fb, NULL, flags);
> ^
> In file included from drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c:32:0:
> include/drm/drm_atomic_helper.h:126:5: note: declared here
>  int drm_atomic_helper_page_flip(struct drm_crtc *crtc,
>  ^
> 
> Caused by commit
> 
>   41292b1fa13a ("drm: Add acquire ctx parameter to ->page_flip(_target)")
> 
> interacting with commits
> 
>   904bb5e5817f ("drm/vmwgfx: Switch over to internal atomic API for STDU")
>   b0119cb9229d ("drm/vmwgfx: Switch over to internal atomic API for SOU and 
> LDU")
> 
> from the drm tree.
> 
> I added this merge fix patch for today:
> 
> From: Stephen Rothwell 
> Date: Mon, 3 Apr 2017 13:25:55 +1000
> Subject: [PATCH] drm/vmwgfx: merge fixup for page_flip API change
> 
> Signed-off-by: Stephen Rothwell 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 2 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
> index 02b8f2541dca..8d7dc9def7c2 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
> @@ -324,7 +324,7 @@ static int vmw_sou_crtc_page_flip(struct drm_crtc *crtc,
>   return -EINVAL;
>  
>   flags &= ~DRM_MODE_PAGE_FLIP_ASYNC;
> - ret = drm_atomic_helper_page_flip(crtc, new_fb, NULL, flags);
> + ret = drm_atomic_helper_page_flip(crtc, new_fb, NULL, flags, ctx);
>   if (ret) {
>   DRM_ERROR("Page flip error %d.\n", ret);
>   return ret;
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
> index e59bbcd8b226..bad31bdf09b6 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
> @@ -505,7 +505,7 @@ static int vmw_stdu_crtc_page_flip(struct drm_crtc *crtc,
>* don't hand it to the helper.
>*/
>   flags &= ~DRM_MODE_PAGE_FLIP_ASYNC;
> - ret = drm_atomic_helper_page_flip(crtc, new_fb, NULL, flags);
> + ret = drm_atomic_helper_page_flip(crtc, new_fb, NULL, flags, ctx);
>   if (ret) {
>   DRM_ERROR("Page flip error %d.\n", ret);
>   return ret;
> -- 
> 2.11.0
> 
> -- 
> Cheers,
> Stephen Rothwell
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 12/15] drm: Add acquire ctx to ->gamma_set hook

2017-04-03 Thread Sinclair Yeh
vmwgfx part:  Reviewed-by: Sinclair Yeh 

On Mon, Apr 03, 2017 at 10:33:01AM +0200, Daniel Vetter wrote:
> Atomic helpers really want this instead of the hacked-up legacy
> backoff trick, which unfortunately prevents drivers from using their
> own private drm_modeset_locks.
> 
> Aside: There's a few atomic drivers (nv50, vc4, soon vmwgfx) which
> don't yet use the new atomic color mgmt/gamma table stuff. Would be
> nice if they could switch over and just hook up
> drm_atomic_helper_legacy_gamma_set() instead.
> 
> Cc: Dave Airlie 
> Cc: Alex Deucher 
> Cc: Christian König 
> Cc: Gerd Hoffmann 
> Cc: Ben Skeggs 
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> Cc: Eric Anholt 
> Signed-off-by: Daniel Vetter 
> ---
>  drivers/gpu/drm/amd/amdgpu/dce_v10_0.c   | 3 ++-
>  drivers/gpu/drm/amd/amdgpu/dce_v11_0.c   | 3 ++-
>  drivers/gpu/drm/amd/amdgpu/dce_v6_0.c| 3 ++-
>  drivers/gpu/drm/amd/amdgpu/dce_v8_0.c| 3 ++-
>  drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 3 ++-
>  drivers/gpu/drm/ast/ast_mode.c   | 3 ++-
>  drivers/gpu/drm/cirrus/cirrus_mode.c | 3 ++-
>  drivers/gpu/drm/drm_atomic_helper.c  | 4 +++-
>  drivers/gpu/drm/drm_color_mgmt.c | 3 ++-
>  drivers/gpu/drm/drm_fb_helper.c  | 3 ++-
>  drivers/gpu/drm/gma500/gma_display.c | 3 ++-
>  drivers/gpu/drm/gma500/gma_display.h | 3 ++-
>  drivers/gpu/drm/mgag200/mgag200_mode.c   | 3 ++-
>  drivers/gpu/drm/nouveau/dispnv04/crtc.c  | 3 ++-
>  drivers/gpu/drm/nouveau/nv50_display.c   | 3 ++-
>  drivers/gpu/drm/radeon/radeon_display.c  | 3 ++-
>  drivers/gpu/drm/vc4/vc4_crtc.c   | 3 ++-
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  | 3 ++-
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.h  | 3 ++-
>  include/drm/drm_atomic_helper.h  | 3 ++-
>  include/drm/drm_crtc.h   | 3 ++-
>  21 files changed, 43 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
> index f525ae4e0576..daf003dd2351 100644
> --- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
> @@ -2631,7 +2631,8 @@ static void dce_v10_0_cursor_reset(struct drm_crtc 
> *crtc)
>  }
>  
>  static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> - u16 *blue, uint32_t size)
> + u16 *blue, uint32_t size,
> + struct drm_modeset_acquire_ctx *ctx)
>  {
>   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
>   int i;
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
> index 3eac27f24d94..3a7296724457 100644
> --- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
> @@ -2651,7 +2651,8 @@ static void dce_v11_0_cursor_reset(struct drm_crtc 
> *crtc)
>  }
>  
>  static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> - u16 *blue, uint32_t size)
> + u16 *blue, uint32_t size,
> + struct drm_modeset_acquire_ctx *ctx)
>  {
>   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
>   int i;
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
> index 838cf1a778f2..8ccada5d6f39 100644
> --- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c
> @@ -1998,7 +1998,8 @@ static void dce_v6_0_cursor_reset(struct drm_crtc *crtc)
>  }
>  
>  static int dce_v6_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> -u16 *blue, uint32_t size)
> +u16 *blue, uint32_t size,
> +struct drm_modeset_acquire_ctx *ctx)
>  {
>   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
>   int i;
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
> index 1b0717b11efe..6943f2641c90 100644
> --- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
> @@ -2482,7 +2482,8 @@ static void dce_v8_0_cursor_reset(struct drm_crtc *crtc)
>  }
>  
>  static int dce_v8_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> -u16 *blue, uint32_t size)
> +u16 *blue, uint32_t size,
> +struct drm_modeset_acquire_ctx *ctx)
>  {
>   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
>   int i;
> diff --git a/driver

Re: [git pull] vmwgfx-next

2017-04-03 Thread Sinclair Yeh
On Sun, Apr 02, 2017 at 08:11:12PM +0200, Daniel Vetter wrote:
> On Fri, Mar 31, 2017 at 04:32:55PM -0700, Sinclair Yeh wrote:
> > Hi Dave,
> > 
> > This series enables atomic mode set for vmwgfx.  A number of features and
> > larger fixes are also included.
> > 
> > The following changes since commit 8cd3ac52963f2e99f4c21d1c9ce89531ce66c2d6:
> > 
> >   Merge branch 'drm-next-4.12' of git://people.freedesktop.org/~agd5f/linux 
> > into drm-next (2017-03-31 11:47:18 +1000)
> > 
> > are available in the git repository at:
> > 
> >   git://people.freedesktop.org/~syeh/repos_linux drm-vmwgfx-next
> > 
> > for you to fetch changes up to 28c954299cd2b5cb5411816c9eeaf3f51ed4638e:
> > 
> >   drm/vmwgfx: Properly check display/scanout surface size (2017-03-31 
> > 15:21:20 -0700)
> > 
> > 
> > Sinclair Yeh (18):
> >   drm/vmwgfx: Removed unused snooper.crtc field
> >   drm/vmwgfx: Add universal plane support
> >   drm/vmwgfx: CRTC atomic state
> >   drm/vmwgfx: Plane atomic state
> >   drm/vmwgfx: Connector atomic state
> >   drm/vmwgfx: Add and connect CRTC helper functions
> >   drm/vmwgfx: Add and connect plane helper functions
> >   drm/vmwgfx: Add and connect connector helper function
> >   drm/vmwgfx: Add and connect atomic state object check/commit
> >   drm/vmwgfx: Fixes to vmwgfx_fb
> >   drm/vmwgfx: Switch over to internal atomic API for STDU
> >   drm/vmwgfx: Switch over to internal atomic API for SOU and LDU
> >   drm/vmwgfx: Turn on DRIVER_ATOMIC flag
> >   drm/vmwgfx: Explicityly track screen target width and height
> >   drm/vmwgfx: Skipping fbdev fb pinning for ldu
> >   drm/vmwgfx: Fix LDU X blank screen until mode change issue
> >   drm/vmwgfx: Support topology greater than texture size
> >   drm/vmwgfx: Properly check display/scanout surface size
> > 
> > Thomas Hellstrom (3):
> >   drm/vmwgfx: Introduce a simple resource type
> >   drm/vmwgfx: Re-implement the stream resource as a simple resource.
> >   drm/vmwgfx: Define an overlaid handle_close ioctl.
> > 
> > Øyvind A. Holm (1):
> >   drm/vmwgfx: Revert "drm/vmwgfx: Replace numeric parameter like 0444 
> > with macro"
> 
> Quite a pile of conflicts of this against the drm-misc-next pull. Nothing
> too hairy, but just more reasons to remove all the vmwgfx special cases
> again :-)
> Also noticed that you've forgotten to garabge collect the legacy cursor
> functions. Probably a good reason for having vfunc implementations in the
> same file as the vtable so that they can all be static and the compiler
> will tell you when you forget to remove stuff. vmwgfx and radeon/amdgpu
> are anti-pattern drivers in this regard imo. On top it's annoying when you
> always have to change a prototype in 2 places when doing a subsystem-wide
> change :-)

Thanks, I'll clean this up.
 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 18/19] drm: Add acquire ctx parameter to ->set_config

2017-04-03 Thread Sinclair Yeh

I missed this one, and looks like it's already in.  So a belated:
Reviewed-by: Sinclair Yeh 

for the vmwgfx part

On Wed, Mar 22, 2017 at 10:50:57PM +0100, Daniel Vetter wrote:
> Surprisingly a lot of legacy drivers roll their own, for
> runtime pm and because vmwgfx.
> 
> Also make nouveau's set_config static while at it.
> 
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> Cc: Ben Skeggs 
> Cc: Patrik Jakobsson 
> Cc: Alex Deucher 
> Cc: Christian König 
> 
> Signed-off-by: Daniel Vetter 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 5 +++--
>  drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h| 3 ++-
>  drivers/gpu/drm/drm_atomic_helper.c | 4 +++-
>  drivers/gpu/drm/drm_crtc.c  | 2 +-
>  drivers/gpu/drm/drm_crtc_helper.c   | 4 +++-
>  drivers/gpu/drm/drm_plane_helper.c  | 2 +-
>  drivers/gpu/drm/gma500/gma_display.c| 7 ---
>  drivers/gpu/drm/gma500/gma_display.h| 3 ++-
>  drivers/gpu/drm/nouveau/dispnv04/crtc.c | 7 ---
>  drivers/gpu/drm/nouveau/nouveau_display.h   | 1 -
>  drivers/gpu/drm/radeon/radeon_display.c | 5 +++--
>  drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | 3 ++-
>  drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c| 3 ++-
>  drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c| 3 ++-
>  include/drm/drm_atomic_helper.h | 3 ++-
>  include/drm/drm_crtc.h  | 3 ++-
>  include/drm/drm_crtc_helper.h   | 3 ++-
>  17 files changed, 38 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index 7b4fe91d3aec..ce15721cadda 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -333,7 +333,8 @@ int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
>   return 0;
>  }
>  
> -int amdgpu_crtc_set_config(struct drm_mode_set *set)
> +int amdgpu_crtc_set_config(struct drm_mode_set *set,
> +struct drm_modeset_acquire_ctx *ctx)
>  {
>   struct drm_device *dev;
>   struct amdgpu_device *adev;
> @@ -350,7 +351,7 @@ int amdgpu_crtc_set_config(struct drm_mode_set *set)
>   if (ret < 0)
>   return ret;
>  
> - ret = drm_crtc_helper_set_config(set);
> + ret = drm_crtc_helper_set_config(set, ctx);
>  
>   list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
>   if (crtc->enabled)
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> index d19b803ba509..20d6522fd7b4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> @@ -593,7 +593,8 @@ int amdgpu_align_pitch(struct amdgpu_device *adev, int 
> width, int bpp, bool tile
>  /* amdgpu_display.c */
>  void amdgpu_print_display_setup(struct drm_device *dev);
>  int amdgpu_modeset_create_props(struct amdgpu_device *adev);
> -int amdgpu_crtc_set_config(struct drm_mode_set *set);
> +int amdgpu_crtc_set_config(struct drm_mode_set *set,
> +struct drm_modeset_acquire_ctx *ctx);
>  int amdgpu_crtc_page_flip_target(struct drm_crtc *crtc,
>struct drm_framebuffer *fb,
>struct drm_pending_vblank_event *event,
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> b/drivers/gpu/drm/drm_atomic_helper.c
> index 08d10abcece0..b502e2809ebd 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -2266,6 +2266,7 @@ static int update_output_state(struct drm_atomic_state 
> *state,
>  /**
>   * drm_atomic_helper_set_config - set a new config from userspace
>   * @set: mode set configuration
> + * @ctx: lock acquisition context
>   *
>   * Provides a default crtc set_config handler using the atomic driver 
> interface.
>   *
> @@ -2278,7 +2279,8 @@ static int update_output_state(struct drm_atomic_state 
> *state,
>   * Returns:
>   * Returns 0 on success, negative errno numbers on failure.
>   */
> -int drm_atomic_helper_set_config(struct drm_mode_set *set)
> +int drm_atomic_helper_set_config(struct drm_mode_set *set,
> +  struct drm_modeset_acquire_ctx *ctx)
>  {
>   struct drm_atomic_state *state;
>   struct drm_crtc *crtc = set->crtc;
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index bfaa0e769ea6..3fe1ec23c87e 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -462,7 +462,7 @@ static int __drm_mode_set_config_internal(struct 
> drm_mode_set *set,
>  
>   fb = set->fb;
>  
&

Re: [PATCH] dma-buf: Rename dma-ops to prevent conflict with kunmap_atomic macro

2017-04-19 Thread Sinclair Yeh
Minor nits, otherwise the vmwgfx part,
  Reviewed-by: Sinclair Yeh 

On Tue, Apr 18, 2017 at 06:17:00PM -0600, Logan Gunthorpe wrote:
> Seeing the kunmap_atomic dma_buf_op shares the same name with a macro
s^

> in higmem.h, the former can be aliased if any dma-buf user includes
   h^
> that header.
> 
> I'm personally trying to include highmem.h inside scatterlist.h and this
> breaks the dma-buf code proper.
> 
> Christoph Hellwig suggested [1] renaming it and pushing this patch ASAP.
> 
> To maintain consistency I've renamed all four of kmap* and kunmap* to be
> map* and unmap*. (Even though only kmap_atomic presently conflicts.)
> 
> [1] 
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.spinics.net_lists_target-2Ddevel_msg15070.html&d=DwIBAg&c=uilaK90D4TOVoH58JNXRgQ&r=HaJ2a6NYExoV0cntAYcoqA&m=QP_jolGTC4ofBnHRnAs0tFIXHnVWaTT0AdMyCL9SM64&s=un2hxBL1283iOTtJeJnvyyvtAu1d5Imyh5Q7AzljrfQ&e=
>  
> 
> Signed-off-by: Logan Gunthorpe 
> ---
>  drivers/dma-buf/dma-buf.c  | 16 
>  drivers/gpu/drm/armada/armada_gem.c|  8 
>  drivers/gpu/drm/drm_prime.c|  8 
>  drivers/gpu/drm/i915/i915_gem_dmabuf.c |  8 
>  drivers/gpu/drm/omapdrm/omap_gem_dmabuf.c  |  8 
>  drivers/gpu/drm/tegra/gem.c|  4 ++--
>  drivers/gpu/drm/udl/udl_dmabuf.c   |  8 
>  drivers/gpu/drm/vmwgfx/vmwgfx_prime.c  |  8 
>  drivers/media/v4l2-core/videobuf2-dma-contig.c |  4 ++--
>  drivers/media/v4l2-core/videobuf2-dma-sg.c |  4 ++--
>  drivers/media/v4l2-core/videobuf2-vmalloc.c|  4 ++--
>  drivers/staging/android/ion/ion.c  |  8 
>  include/linux/dma-buf.h| 22 +++---
>  13 files changed, 55 insertions(+), 55 deletions(-)
> 
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 0007b79..7cc2bfe 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -405,8 +405,8 @@ struct dma_buf *dma_buf_export(const struct 
> dma_buf_export_info *exp_info)
> || !exp_info->ops->map_dma_buf
> || !exp_info->ops->unmap_dma_buf
> || !exp_info->ops->release
> -   || !exp_info->ops->kmap_atomic
> -   || !exp_info->ops->kmap
> +   || !exp_info->ops->map_atomic
> +   || !exp_info->ops->map
> || !exp_info->ops->mmap)) {
>   return ERR_PTR(-EINVAL);
>   }
> @@ -872,7 +872,7 @@ void *dma_buf_kmap_atomic(struct dma_buf *dmabuf, 
> unsigned long page_num)
>  {
>   WARN_ON(!dmabuf);
>  
> - return dmabuf->ops->kmap_atomic(dmabuf, page_num);
> + return dmabuf->ops->map_atomic(dmabuf, page_num);
>  }
>  EXPORT_SYMBOL_GPL(dma_buf_kmap_atomic);
>  
> @@ -889,8 +889,8 @@ void dma_buf_kunmap_atomic(struct dma_buf *dmabuf, 
> unsigned long page_num,
>  {
>   WARN_ON(!dmabuf);
>  
> - if (dmabuf->ops->kunmap_atomic)
> - dmabuf->ops->kunmap_atomic(dmabuf, page_num, vaddr);
> + if (dmabuf->ops->unmap_atomic)
> + dmabuf->ops->unmap_atomic(dmabuf, page_num, vaddr);
>  }
>  EXPORT_SYMBOL_GPL(dma_buf_kunmap_atomic);
>  
> @@ -907,7 +907,7 @@ void *dma_buf_kmap(struct dma_buf *dmabuf, unsigned long 
> page_num)
>  {
>   WARN_ON(!dmabuf);
>  
> - return dmabuf->ops->kmap(dmabuf, page_num);
> + return dmabuf->ops->map(dmabuf, page_num);
>  }
>  EXPORT_SYMBOL_GPL(dma_buf_kmap);
>  
> @@ -924,8 +924,8 @@ void dma_buf_kunmap(struct dma_buf *dmabuf, unsigned long 
> page_num,
>  {
>   WARN_ON(!dmabuf);
>  
> - if (dmabuf->ops->kunmap)
> - dmabuf->ops->kunmap(dmabuf, page_num, vaddr);
> + if (dmabuf->ops->unmap)
> + dmabuf->ops->unmap(dmabuf, page_num, vaddr);
>  }
>  EXPORT_SYMBOL_GPL(dma_buf_kunmap);
>  
> diff --git a/drivers/gpu/drm/armada/armada_gem.c 
> b/drivers/gpu/drm/armada/armada_gem.c
> index 1597458..d6c2a5d 100644
> --- a/drivers/gpu/drm/armada/armada_gem.c
> +++ b/drivers/gpu/drm/armada/armada_gem.c
> @@ -529,10 +529,10 @@ static const struct dma_buf_ops 
> armada_gem_prime_dmabuf_ops = {
>   .map_dma_buf= armada_gem_prime_map_dma_buf,
>   .unmap_dma_buf  = armada_gem_prime_unmap_dma_buf,
>   .release= drm_gem_dmabuf_release,
> - .kmap_atomic= armada_gem_dmabuf_no_kmap,
> - .kunma

Re: [PATCH v2] kernel: drm/vmwgfx: limit the number of mip levels in vmw_gb_surface_define_ioctl()

2017-04-19 Thread Sinclair Yeh
Thanks Vladis!

Reviewed-by: Sinclair Yeh 

On Thu, Apr 06, 2017 at 02:33:40PM +0200, Vladis Dronov wrote:
> The 'req->mip_levels' parameter in vmw_gb_surface_define_ioctl() is
> a user-controlled 'uint32_t' value which is used as a loop count limit.
> This can lead to a kernel lockup and DoS. Add check for 'req->mip_levels'.
> 
> References:
> https://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.redhat.com_show-5Fbug.cgi-3Fid-3D1437431&d=DwIBAg&c=uilaK90D4TOVoH58JNXRgQ&r=HaJ2a6NYExoV0cntAYcoqA&m=D9ZabTkAbhTqB-puuJ1a4SnWKUIGw0oXestkhJG6dCQ&s=6PZxBQ8MQjy-uc5pd6vyZg3D5yrG0jlSPi5pPE0oFK4&e=
>  
> Signed-off-by: Vladis Dronov 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> index b445ce9..e0d7ff9 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> @@ -1281,6 +1281,9 @@ int vmw_gb_surface_define_ioctl(struct drm_device *dev, 
> void *data,
>   if (req->multisample_count != 0)
>   return -EINVAL;
>  
> + if (req->mip_levels > DRM_VMW_MAX_MIP_LEVELS)
> + return -EINVAL;
> +
>   if (unlikely(vmw_user_surface_size == 0))
>   vmw_user_surface_size = ttm_round_pot(sizeof(*user_srf)) +
>   128;
> -- 
> 2.9.3
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[git pull] vmwgfx-next

2017-04-21 Thread Sinclair Yeh
Hi Dave,

The following changes since commit 6b1462700b4a6a1244c018cdd2fa97ded43090a0:

  Merge tag 'drm-misc-next-fixes-2017-04-20' of 
git://anongit.freedesktop.org/git/drm-misc into drm-next (2017-04-21 13:51:59 
+1000)

are available in the git repository at:

  git://people.freedesktop.org/~syeh/repos_linux drm-vmwgfx-next

for you to fetch changes up to 7a9d2001a16f11d30a1e128a067cf1aef2a99a70:

  drm/vmwgfx: Convert macro to octal representation (2017-04-21 09:25:47 -0700)


Øyvind A. Holm (1):
  drm/vmwgfx: Convert macro to octal representation

 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


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


Re: [PATCH] drm/vmwgfx: Handle vmalloc() failure in vmw_local_fifo_reserve()

2017-05-01 Thread Sinclair Yeh
Thanks Dan!

Reviewed-by: Sinclair Yeh 

On Thu, Apr 27, 2017 at 12:12:08PM +0300, Dan Carpenter wrote:
> If vmalloc() fails then we need to a bit of cleanup before returning.
> 
> Fixes: fb1d9738ca05 ("drm/vmwgfx: Add DRM driver for VMware Virtual GPU")
> Signed-off-by: Dan Carpenter 
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
> index b6a0806b06bf..a1c68e6a689e 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
> @@ -368,6 +368,8 @@ static void *vmw_local_fifo_reserve(struct vmw_private 
> *dev_priv,
>   return fifo_state->static_buffer;
>   else {
>   fifo_state->dynamic_buffer = vmalloc(bytes);
> + if (!fifo_state->dynamic_buffer)
> + goto out_err;
>   return fifo_state->dynamic_buffer;
>   }
>   }
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 5/6] drm/ttm: revert "implement LRU add callbacks v2"

2017-01-24 Thread Sinclair Yeh
Minor typo

On Fri, Jan 13, 2017 at 10:51:10AM +0100, Christian König wrote:
> From: Christian König 
> 
> The additional housekeeping had to much CPU overhead,
   ^


> let's use the BO priorities instead.
> 
> Signed-off-by: Christian König 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c |  2 --
>  drivers/gpu/drm/ast/ast_ttm.c   |  2 --
>  drivers/gpu/drm/bochs/bochs_mm.c|  2 --
>  drivers/gpu/drm/cirrus/cirrus_ttm.c |  2 --
>  drivers/gpu/drm/mgag200/mgag200_ttm.c   |  2 --
>  drivers/gpu/drm/nouveau/nouveau_bo.c|  2 --
>  drivers/gpu/drm/qxl/qxl_ttm.c   |  2 --
>  drivers/gpu/drm/radeon/radeon_ttm.c |  2 --
>  drivers/gpu/drm/ttm/ttm_bo.c| 19 +--
>  drivers/gpu/drm/virtio/virtgpu_ttm.c|  2 --
>  drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c  |  2 --
>  include/drm/ttm/ttm_bo_driver.h |  9 -
>  12 files changed, 5 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index dd086d8..0402a11 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -1086,8 +1086,6 @@ static struct ttm_bo_driver amdgpu_bo_driver = {
>   .fault_reserve_notify = &amdgpu_bo_fault_reserve_notify,
>   .io_mem_reserve = &amdgpu_ttm_io_mem_reserve,
>   .io_mem_free = &amdgpu_ttm_io_mem_free,
> - .lru_tail = &ttm_bo_default_lru_tail,
> - .swap_lru_tail = &ttm_bo_default_swap_lru_tail,
>  };
>  
>  int amdgpu_ttm_init(struct amdgpu_device *adev)
> diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
> index 2a1368f..50c910e 100644
> --- a/drivers/gpu/drm/ast/ast_ttm.c
> +++ b/drivers/gpu/drm/ast/ast_ttm.c
> @@ -236,8 +236,6 @@ struct ttm_bo_driver ast_bo_driver = {
>   .verify_access = ast_bo_verify_access,
>   .io_mem_reserve = &ast_ttm_io_mem_reserve,
>   .io_mem_free = &ast_ttm_io_mem_free,
> - .lru_tail = &ttm_bo_default_lru_tail,
> - .swap_lru_tail = &ttm_bo_default_swap_lru_tail,
>  };
>  
>  int ast_mm_init(struct ast_private *ast)
> diff --git a/drivers/gpu/drm/bochs/bochs_mm.c 
> b/drivers/gpu/drm/bochs/bochs_mm.c
> index 099a3c6..e4c1125 100644
> --- a/drivers/gpu/drm/bochs/bochs_mm.c
> +++ b/drivers/gpu/drm/bochs/bochs_mm.c
> @@ -205,8 +205,6 @@ struct ttm_bo_driver bochs_bo_driver = {
>   .verify_access = bochs_bo_verify_access,
>   .io_mem_reserve = &bochs_ttm_io_mem_reserve,
>   .io_mem_free = &bochs_ttm_io_mem_free,
> - .lru_tail = &ttm_bo_default_lru_tail,
> - .swap_lru_tail = &ttm_bo_default_swap_lru_tail,
>  };
>  
>  int bochs_mm_init(struct bochs_device *bochs)
> diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c 
> b/drivers/gpu/drm/cirrus/cirrus_ttm.c
> index d6da848..f53aa8f 100644
> --- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
> +++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
> @@ -236,8 +236,6 @@ struct ttm_bo_driver cirrus_bo_driver = {
>   .verify_access = cirrus_bo_verify_access,
>   .io_mem_reserve = &cirrus_ttm_io_mem_reserve,
>   .io_mem_free = &cirrus_ttm_io_mem_free,
> - .lru_tail = &ttm_bo_default_lru_tail,
> - .swap_lru_tail = &ttm_bo_default_swap_lru_tail,
>  };
>  
>  int cirrus_mm_init(struct cirrus_device *cirrus)
> diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c 
> b/drivers/gpu/drm/mgag200/mgag200_ttm.c
> index 5e20220..657598b 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
> @@ -236,8 +236,6 @@ struct ttm_bo_driver mgag200_bo_driver = {
>   .verify_access = mgag200_bo_verify_access,
>   .io_mem_reserve = &mgag200_ttm_io_mem_reserve,
>   .io_mem_free = &mgag200_ttm_io_mem_free,
> - .lru_tail = &ttm_bo_default_lru_tail,
> - .swap_lru_tail = &ttm_bo_default_swap_lru_tail,
>  };
>  
>  int mgag200_mm_init(struct mga_device *mdev)
> diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
> b/drivers/gpu/drm/nouveau/nouveau_bo.c
> index 5b0a28b..3949a74 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_bo.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
> @@ -1570,8 +1570,6 @@ struct ttm_bo_driver nouveau_bo_driver = {
>   .fault_reserve_notify = &nouveau_ttm_fault_reserve_notify,
>   .io_mem_reserve = &nouveau_ttm_io_mem_reserve,
>   .io_mem_free = &nouveau_ttm_io_mem_free,
> - .lru_tail = &ttm_bo_default_lru_tail,
> - .swap_lru_tail = &ttm_bo_default_swap_lru_tail,
>  };
>  
>  struct nvkm_vma *
> diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
> index f3939a9..2955f91 100644
> --- a/drivers/gpu/drm/qxl/qxl_ttm.c
> +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
> @@ -395,8 +395,6 @@ static struct ttm_bo_driver qxl_bo_driver = {
>   .io_mem_reserve = &qxl_ttm_io_mem_reserve,
>   .io_mem_free = &qxl_ttm_io_mem_free,
>   .move_notify = &qxl_bo_move_notify,
> - .lru_tail = &ttm_bo_default_lru_tail,
> - .swap_lru_tail = &ttm_bo_default_swap_lru_tail,
>

Re: [PATCH 6/6] drm/ttm: revert "add optional LRU removal callback v2"

2017-01-24 Thread Sinclair Yeh
Pathces 1, 2, 5, 6:
Reviewed-by: Sinclair Yeh 

On Fri, Jan 13, 2017 at 10:51:11AM +0100, Christian König wrote:
> From: Christian König 
> 
> Without the custom LRU management the callback is not used any more.
> 
> Signed-off-by: Christian König 
> ---
>  drivers/gpu/drm/ttm/ttm_bo.c| 12 +---
>  include/drm/ttm/ttm_bo_driver.h |  6 --
>  2 files changed, 5 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 59fac2f..dfaeac4 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -186,12 +186,8 @@ EXPORT_SYMBOL(ttm_bo_add_to_lru);
>  
>  int ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
>  {
> - struct ttm_bo_device *bdev = bo->bdev;
>   int put_count = 0;
>  
> - if (bdev->driver->lru_removal)
> - bdev->driver->lru_removal(bo);
> -
>   if (!list_empty(&bo->swap)) {
>   list_del_init(&bo->swap);
>   ++put_count;
> @@ -201,6 +197,11 @@ int ttm_bo_del_from_lru(struct ttm_buffer_object *bo)
>   ++put_count;
>   }
>  
> + /*
> +  * TODO: Add a driver hook to delete from
> +  * driver-specific LRU's here.
> +  */
> +
>   return put_count;
>  }
>  
> @@ -234,9 +235,6 @@ void ttm_bo_move_to_lru_tail(struct ttm_buffer_object *bo)
>  
>   lockdep_assert_held(&bo->resv->lock.base);
>  
> - if (bdev->driver->lru_removal)
> - bdev->driver->lru_removal(bo);
> -
>   put_count = ttm_bo_del_from_lru(bo);
>   ttm_bo_list_ref_sub(bo, put_count, true);
>   ttm_bo_add_to_lru(bo);
> diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
> index a1235fa..4395db1 100644
> --- a/include/drm/ttm/ttm_bo_driver.h
> +++ b/include/drm/ttm/ttm_bo_driver.h
> @@ -462,12 +462,6 @@ struct ttm_bo_driver {
> struct ttm_mem_reg *mem);
>   void (*io_mem_free)(struct ttm_bo_device *bdev,
>   struct ttm_mem_reg *mem);
> -
> - /**
> -  * Optional driver callback for when BO is removed from the LRU.
> -  * Called with LRU lock held immediately before the removal.
> -  */
> - void (*lru_removal)(struct ttm_buffer_object *bo);
>  };
>  
>  /**
> -- 
> 2.7.4
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 4/4] drm: Resurrect atomic rmfb code, v2

2017-01-25 Thread Sinclair Yeh
On Wed, Jan 25, 2017 at 09:36:36AM +0100, Maarten Lankhorst wrote:
> Op 25-01-17 om 09:09 schreef Thomas Hellstrom:
> > On 01/25/2017 05:54 AM, Daniel Vetter wrote:
> >> On Tue, Jan 24, 2017 at 01:44:54PM -0800, Matt Roper wrote:
> >>> On Wed, Jan 11, 2017 at 05:15:47PM +0100, Daniel Vetter wrote:
>  On Thu, Dec 15, 2016 at 03:29:45PM +0100, Maarten Lankhorst wrote:
> > From: Daniel Vetter 
> >
> > This was somehow lost between v3 and the merged version in Maarten's
> > patch merged as:
> >
> > commit f2d580b9a8149735cbc4b59c4a8df60173658140
> > Author: Maarten Lankhorst 
> > Date:   Wed May 4 14:38:26 2016 +0200
> >
> > drm/core: Do not preserve framebuffer on rmfb, v4.
> >
> > Actual code copied from Maarten's patch, but with the slight change to
> > just use dev->mode_config.funcs->atomic_commit to decide whether to
> > use the atomic path or not.
> >
> > v2:
> > - Remove plane->fb assignment, done by drm_atomic_clean_old_fb.
> > - Add WARN_ON when atomic_remove_fb fails.
> > - Always call drm_atomic_state_put.
> >
> > Signed-off-by: Daniel Vetter 
> > Signed-off-by: Daniel Vetter 
> > Signed-off-by: Maarten Lankhorst 
>  Would be great if someone else could r-b this, I've proven pretty well
>  that I don't understand the complexity here :(
>  -Daniel
> >>> It looks like this will change the behavior slightly in that rmfb will
> >>> cause primary planes to be disabled, but no longer cause the entire CRTC
> >>> to be turned off.  You'll probably want to note that in the commit
> >>> message, along with the justification on why this is okay ABI-wise.
> >>>
> >>> I know that 13803132818c ("drm/core: Preserve the framebuffer after
> >>> removing it.") was initially trying to not only leave the CRTC on, but
> >>> also preserve the framebuffer and leave the planes on; that wound up
> >>> causing some kind of regression for vmwgfx, but I'm unclear on the
> >>> details there.  I'd suggest getting an Ack from one of the vmware guys
> >>> to ensure that the less drastic change in behavior here won't cause them
> >>> any problems.
> > The vmware Xorg driver is currently relying on rmfb to turn all attached
> > crtcs off. Even if we were to fix that in the Xorg driver now, older
> > Xorgs with newer kernels still would break.
> Is it allowed for vmwgfx to keep the crtc enabled, but the primary plane 
> disabled?
> 
> If so, when vmwgfx is eventually converted to atomic then we need to 
> special-case rmfb for them somehow.

FYI, we are in the process of converting things to atomic.  This may happen
around 4.12

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


Re: [PATCH] drm/ttm: Make sure BOs being swapped out are cacheable

2017-01-25 Thread Sinclair Yeh
On Wed, Jan 25, 2017 at 10:49:33AM +0100, Christian König wrote:
> Am 25.01.2017 um 10:25 schrieb Thomas Hellstrom:
> >On 01/25/2017 09:21 AM, Michel Dänzer wrote:
> >>From: Michel Dänzer 
> >>
> >>The current caching state may not be tt_cached, even though the
> >>placement contains TTM_PL_FLAG_CACHED, because placement can contain
> >>multiple caching flags. Trying to swap out such a BO would trip up the
> >>
> >>BUG_ON(ttm->caching_state != tt_cached);
> >>
> >>in ttm_tt_swapout.
> >>
> >>Cc: sta...@vger.kernel.org
> >>Signed-off-by: Michel Dänzer 
> >Reviewed-by: Thomas Hellstrom 
> 
> Reviewed-by: Christian König .

Reviewed-by: Sinclair Yeh 

> 
> >
> >>---
> >>  drivers/gpu/drm/ttm/ttm_bo.c | 4 ++--
> >>  1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >>diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> >>index d5063618efa7..86e3b233b722 100644
> >>--- a/drivers/gpu/drm/ttm/ttm_bo.c
> >>+++ b/drivers/gpu/drm/ttm/ttm_bo.c
> >>@@ -1670,7 +1670,6 @@ static int ttm_bo_swapout(struct ttm_mem_shrink 
> >>*shrink)
> >>struct ttm_buffer_object *bo;
> >>int ret = -EBUSY;
> >>int put_count;
> >>-   uint32_t swap_placement = (TTM_PL_FLAG_CACHED | TTM_PL_FLAG_SYSTEM);
> >>spin_lock(&glob->lru_lock);
> >>list_for_each_entry(bo, &glob->swap_lru, swap) {
> >>@@ -1701,7 +1700,8 @@ static int ttm_bo_swapout(struct ttm_mem_shrink 
> >>*shrink)
> >> * Move to system cached
> >> */
> >>-   if ((bo->mem.placement & swap_placement) != swap_placement) {
> >>+   if (bo->mem.mem_type != TTM_PL_SYSTEM ||
> >>+   bo->ttm->caching_state != tt_cached) {
> >>struct ttm_mem_reg evict_mem;
> >>evict_mem = bo->mem;
> >
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 4/4] drm: Resurrect atomic rmfb code, v2

2017-01-26 Thread Sinclair Yeh
On Thu, Jan 26, 2017 at 10:55:51AM +0100, Maarten Lankhorst wrote:
> Op 25-01-17 om 19:05 schreef Sinclair Yeh:
> > On Wed, Jan 25, 2017 at 09:36:36AM +0100, Maarten Lankhorst wrote:
> >> Op 25-01-17 om 09:09 schreef Thomas Hellstrom:
> >>> On 01/25/2017 05:54 AM, Daniel Vetter wrote:
> >>>> On Tue, Jan 24, 2017 at 01:44:54PM -0800, Matt Roper wrote:
> >>>>> On Wed, Jan 11, 2017 at 05:15:47PM +0100, Daniel Vetter wrote:
> >>>>>> On Thu, Dec 15, 2016 at 03:29:45PM +0100, Maarten Lankhorst wrote:
> >>>>>>> From: Daniel Vetter 
> >>>>>>>
> >>>>>>> This was somehow lost between v3 and the merged version in Maarten's
> >>>>>>> patch merged as:
> >>>>>>>
> >>>>>>> commit f2d580b9a8149735cbc4b59c4a8df60173658140
> >>>>>>> Author: Maarten Lankhorst 
> >>>>>>> Date:   Wed May 4 14:38:26 2016 +0200
> >>>>>>>
> >>>>>>> drm/core: Do not preserve framebuffer on rmfb, v4.
> >>>>>>>
> >>>>>>> Actual code copied from Maarten's patch, but with the slight change to
> >>>>>>> just use dev->mode_config.funcs->atomic_commit to decide whether to
> >>>>>>> use the atomic path or not.
> >>>>>>>
> >>>>>>> v2:
> >>>>>>> - Remove plane->fb assignment, done by drm_atomic_clean_old_fb.
> >>>>>>> - Add WARN_ON when atomic_remove_fb fails.
> >>>>>>> - Always call drm_atomic_state_put.
> >>>>>>>
> >>>>>>> Signed-off-by: Daniel Vetter 
> >>>>>>> Signed-off-by: Daniel Vetter 
> >>>>>>> Signed-off-by: Maarten Lankhorst 
> >>>>>> Would be great if someone else could r-b this, I've proven pretty well
> >>>>>> that I don't understand the complexity here :(
> >>>>>> -Daniel
> >>>>> It looks like this will change the behavior slightly in that rmfb will
> >>>>> cause primary planes to be disabled, but no longer cause the entire CRTC
> >>>>> to be turned off.  You'll probably want to note that in the commit
> >>>>> message, along with the justification on why this is okay ABI-wise.
> >>>>>
> >>>>> I know that 13803132818c ("drm/core: Preserve the framebuffer after
> >>>>> removing it.") was initially trying to not only leave the CRTC on, but
> >>>>> also preserve the framebuffer and leave the planes on; that wound up
> >>>>> causing some kind of regression for vmwgfx, but I'm unclear on the
> >>>>> details there.  I'd suggest getting an Ack from one of the vmware guys
> >>>>> to ensure that the less drastic change in behavior here won't cause them
> >>>>> any problems.
> >>> The vmware Xorg driver is currently relying on rmfb to turn all attached
> >>> crtcs off. Even if we were to fix that in the Xorg driver now, older
> >>> Xorgs with newer kernels still would break.
> >> Is it allowed for vmwgfx to keep the crtc enabled, but the primary plane 
> >> disabled?
> >>
> >> If so, when vmwgfx is eventually converted to atomic then we need to 
> >> special-case rmfb for them somehow.
> > FYI, we are in the process of converting things to atomic.  This may happen
> > around 4.12
> >
> Will the driver allow the crtc to be enabled without primary plane?

Give me a few days to get back to you.  I'm reworking some patches right now.


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


[git pull] vmwgfx-next

2017-01-30 Thread Sinclair Yeh
Hi Dave,

This is to address what we've discussed, moving some of the minor changes
into a drm-next request.

-

The following changes since commit f0493e653f9679114d1dfd54ab88b54ce95576e1:

  drm/mgag200: Added support for the new device G200eH3 (2017-01-23 11:57:08 
+1000)

are available in the git repository at:

  git://people.freedesktop.org/~syeh/repos_linux drm-vmwgfx-next

for you to fetch changes up to 5d25fde23b3176c7f94d2a992cb9762707d7c2a0:

  drm/vmwgfx: Use kmemdup instead of kmalloc and memcpy (2017-01-26 21:26:17 
-0800)


Shyam Saini (1):
  drm/vmwgfx: Use kmemdup instead of kmalloc and memcpy

Sinclair Yeh (1):
  drm/vmwgfx: Fix depth input into drm_mode_legacy_fb_format

Thomas Hellstrom (4):
  drm/vmwgfx: Clear uninitialized fields of a parameter
  drm/vmwgfx: Annotate ignored return values
  drm/vmwgfx: Clear an uninitialized struct member
  drm/vmwgfx: Fix a potential integer overflow

 drivers/gpu/drm/vmwgfx/device_include/svga3d_surfacedefs.h | 2 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c| 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 3 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c| 4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_mob.c| 7 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c   | 4 ++--
 7 files changed, 12 insertions(+), 12 deletions(-)


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


Re: [PATCH v4 1/2] drm: Improve drm_mm search (and fix topdown allocation) with rbtrees

2017-02-02 Thread Sinclair Yeh
vmwgfx part:  Reviewed-by: Sinclair Yeh 

On Thu, Feb 02, 2017 at 11:44:33AM +, Chris Wilson wrote:
> The drm_mm range manager claimed to support top-down insertion, but it
> was neither searching for the top-most hole that could fit the
> allocation request nor fitting the request to the hole correctly.
> 
> In order to search the range efficiently, we create a secondary index
> for the holes using either their size or their address. This index
> allows us to find the smallest hole or the hole at the bottom or top of
> the range efficiently, whilst keeping the hole stack to rapidly service
> evictions.
> 
> v2: Search for holes both high and low. Rename flags to mode.
> v3: Discover rb_entry_safe() and use it!
> v4: Kerneldoc for enum drm_mm_insert_mode.
> 
> Signed-off-by: Chris Wilson 
> Reviewed-by: Joonas Lahtinen 
> Cc: Alex Deucher 
> Cc: "Christian König" 
> Cc: David Airlie 
> Cc: Russell King 
> Cc: Daniel Vetter 
> Cc: Jani Nikula 
> Cc: Sean Paul 
> Cc: Lucas Stach 
> Cc: Christian Gmeiner 
> Cc: Rob Clark 
> Cc: Thierry Reding 
> Cc: Stephen Warren 
> Cc: Alexandre Courbot 
> Cc: Eric Anholt 
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c  |  16 +-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c |  20 +-
>  drivers/gpu/drm/armada/armada_gem.c  |   4 +-
>  drivers/gpu/drm/drm_mm.c | 488 
> +++
>  drivers/gpu/drm/drm_vma_manager.c|   3 +-
>  drivers/gpu/drm/etnaviv/etnaviv_mmu.c|  16 +-
>  drivers/gpu/drm/i915/i915_gem.c  |  10 +-
>  drivers/gpu/drm/i915/i915_gem_evict.c|   9 +-
>  drivers/gpu/drm/i915/i915_gem_execbuffer.c   |   5 +-
>  drivers/gpu/drm/i915/i915_gem_gtt.c  |  39 +--
>  drivers/gpu/drm/i915/i915_gem_stolen.c   |   6 +-
>  drivers/gpu/drm/msm/msm_gem.c|   3 +-
>  drivers/gpu/drm/msm/msm_gem_vma.c|   3 +-
>  drivers/gpu/drm/selftests/test-drm_mm.c  |  58 ++--
>  drivers/gpu/drm/sis/sis_mm.c |   6 +-
>  drivers/gpu/drm/tegra/gem.c  |   4 +-
>  drivers/gpu/drm/ttm/ttm_bo_manager.c |  18 +-
>  drivers/gpu/drm/vc4/vc4_crtc.c   |   2 +-
>  drivers/gpu/drm/vc4/vc4_hvs.c|   3 +-
>  drivers/gpu/drm/vc4/vc4_plane.c  |   6 +-
>  drivers/gpu/drm/via/via_mm.c |   4 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c   |  10 +-
>  include/drm/drm_mm.h | 184 +-
>  23 files changed, 470 insertions(+), 447 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> index e4eb6dd3798a..0335c2f331e9 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> @@ -97,8 +97,7 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager *man,
>  {
>   struct amdgpu_gtt_mgr *mgr = man->priv;
>   struct drm_mm_node *node = mem->mm_node;
> - enum drm_mm_search_flags sflags = DRM_MM_SEARCH_BEST;
> - enum drm_mm_allocator_flags aflags = DRM_MM_CREATE_DEFAULT;
> + enum drm_mm_insert_mode mode;
>   unsigned long fpfn, lpfn;
>   int r;
>  
> @@ -115,15 +114,14 @@ int amdgpu_gtt_mgr_alloc(struct ttm_mem_type_manager 
> *man,
>   else
>   lpfn = man->size;
>  
> - if (place && place->flags & TTM_PL_FLAG_TOPDOWN) {
> - sflags = DRM_MM_SEARCH_BELOW;
> - aflags = DRM_MM_CREATE_TOP;
> - }
> + mode = DRM_MM_INSERT_BEST;
> + if (place && place->flags & TTM_PL_FLAG_TOPDOWN)
> + mode = DRM_MM_INSERT_HIGH;
>  
>   spin_lock(&mgr->lock);
> - r = drm_mm_insert_node_in_range_generic(&mgr->mm, node, mem->num_pages,
> - mem->page_alignment, 0,
> - fpfn, lpfn, sflags, aflags);
> + r = drm_mm_insert_node_in_range(&mgr->mm, node,
> + mem->num_pages, mem->page_alignment, 0,
> + fpfn, lpfn, mode);
>   spin_unlock(&mgr->lock);
>  
>   if (!r) {
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> index ac9007986c11..9e577e3d3147 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
> @@ -97,8 +97,7 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager 
> *man,
>   struct amdgpu_vram_mgr *mgr = man->priv;

Re: [PATCH 4/4] drm: Resurrect atomic rmfb code, v2

2017-02-09 Thread Sinclair Yeh
I've verified that it doesn't break our existing code, but I'm in the process 
of rebasing my atomic enabling patch series onto drm-next along with this.  I 
should be able to get this done by tomorrow morning.

From: Maarten Lankhorst 
Sent: Thursday, February 9, 2017 4:29:49 AM
To: Sinclair Yeh
Cc: Thomas Hellstrom; Daniel Vetter; Matt Roper; Daniel Vetter; 
intel-...@lists.freedesktop.org; dri-devel@lists.freedesktop.org; Daniel Vetter
Subject: Re: [PATCH 4/4] drm: Resurrect atomic rmfb code, v2

Op 26-01-17 om 19:39 schreef Sinclair Yeh:
> On Thu, Jan 26, 2017 at 10:55:51AM +0100, Maarten Lankhorst wrote:
>> Op 25-01-17 om 19:05 schreef Sinclair Yeh:
>>> On Wed, Jan 25, 2017 at 09:36:36AM +0100, Maarten Lankhorst wrote:
>>>> Op 25-01-17 om 09:09 schreef Thomas Hellstrom:
>>>>> On 01/25/2017 05:54 AM, Daniel Vetter wrote:
>>>>>> On Tue, Jan 24, 2017 at 01:44:54PM -0800, Matt Roper wrote:
>>>>>>> On Wed, Jan 11, 2017 at 05:15:47PM +0100, Daniel Vetter wrote:
>>>>>>>> On Thu, Dec 15, 2016 at 03:29:45PM +0100, Maarten Lankhorst wrote:
>>>>>>>>> From: Daniel Vetter 
>>>>>>>>>
>>>>>>>>> This was somehow lost between v3 and the merged version in Maarten's
>>>>>>>>> patch merged as:
>>>>>>>>>
>>>>>>>>> commit f2d580b9a8149735cbc4b59c4a8df60173658140
>>>>>>>>> Author: Maarten Lankhorst 
>>>>>>>>> Date:   Wed May 4 14:38:26 2016 +0200
>>>>>>>>>
>>>>>>>>> drm/core: Do not preserve framebuffer on rmfb, v4.
>>>>>>>>>
>>>>>>>>> Actual code copied from Maarten's patch, but with the slight change to
>>>>>>>>> just use dev->mode_config.funcs->atomic_commit to decide whether to
>>>>>>>>> use the atomic path or not.
>>>>>>>>>
>>>>>>>>> v2:
>>>>>>>>> - Remove plane->fb assignment, done by drm_atomic_clean_old_fb.
>>>>>>>>> - Add WARN_ON when atomic_remove_fb fails.
>>>>>>>>> - Always call drm_atomic_state_put.
>>>>>>>>>
>>>>>>>>> Signed-off-by: Daniel Vetter 
>>>>>>>>> Signed-off-by: Daniel Vetter 
>>>>>>>>> Signed-off-by: Maarten Lankhorst 
>>>>>>>> Would be great if someone else could r-b this, I've proven pretty well
>>>>>>>> that I don't understand the complexity here :(
>>>>>>>> -Daniel
>>>>>>> It looks like this will change the behavior slightly in that rmfb will
>>>>>>> cause primary planes to be disabled, but no longer cause the entire CRTC
>>>>>>> to be turned off.  You'll probably want to note that in the commit
>>>>>>> message, along with the justification on why this is okay ABI-wise.
>>>>>>>
>>>>>>> I know that 13803132818c ("drm/core: Preserve the framebuffer after
>>>>>>> removing it.") was initially trying to not only leave the CRTC on, but
>>>>>>> also preserve the framebuffer and leave the planes on; that wound up
>>>>>>> causing some kind of regression for vmwgfx, but I'm unclear on the
>>>>>>> details there.  I'd suggest getting an Ack from one of the vmware guys
>>>>>>> to ensure that the less drastic change in behavior here won't cause them
>>>>>>> any problems.
>>>>> The vmware Xorg driver is currently relying on rmfb to turn all attached
>>>>> crtcs off. Even if we were to fix that in the Xorg driver now, older
>>>>> Xorgs with newer kernels still would break.
>>>> Is it allowed for vmwgfx to keep the crtc enabled, but the primary plane 
>>>> disabled?
>>>>
>>>> If so, when vmwgfx is eventually converted to atomic then we need to 
>>>> special-case rmfb for them somehow.
>>> FYI, we are in the process of converting things to atomic.  This may happen
>>> around 4.12
>>>
>> Will the driver allow the crtc to be enabled without primary plane?
> Give me a few days to get back to you.  I'm reworking some patches right now.
>
>
Any update on this?

~Maarten

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


Re: [Intel-gfx] [PATCH v3 4/4] drm: Resurrect atomic rmfb code, v3

2017-02-15 Thread Sinclair Yeh
On Wed, Feb 15, 2017 at 03:56:09PM +0200, Jani Nikula wrote:
> On Wed, 25 Jan 2017, Maarten Lankhorst  
> wrote:
> > This was somehow lost between v3 and the merged version in Maarten's
> > patch merged as:
> >
> > commit f2d580b9a8149735cbc4b59c4a8df60173658140
> > Author: Maarten Lankhorst 
> > Date:   Wed May 4 14:38:26 2016 +0200
> >
> > drm/core: Do not preserve framebuffer on rmfb, v4.
> >
> > This introduces a slight behavioral change to rmfb. Instead of
> > disabling a crtc when the primary plane is disabled, we try to
> > preserve it.
> >
> > Apart from old versions of the vmwgfx xorg driver, there is
> > nothing depending on rmfb disabling a crtc. Since vmwgfx is
> > a legacy driver we can safely only disable the plane with atomic.
> >
> > If this commit is rejected by the driver then we will still fall
> > back to the old behavior and turn off the crtc.
> >
> > v2:
> > - Remove plane->fb assignment, done by drm_atomic_clean_old_fb.
> > - Add WARN_ON when atomic_remove_fb fails.
> > - Always call drm_atomic_state_put.
> > v3:
> > - Use drm_drv_uses_atomic_modeset
> > - Handle the case where the first plane-disable-only commit fails
> >   with -EINVAL. Some drivers do not support this, fall back to
> >   disabling all crtc's in this case.
> >
> > Signed-off-by: Daniel Vetter 
> > Signed-off-by: Daniel Vetter 
> > Signed-off-by: Maarten Lankhorst 
> 
> Pushed to drm-misc-next-fixes, and sent the pull request to Dave. Thanks
> for the patch.

I verified yesterday that this patch will cause a regression for vmwgfx
multi-mon.  Can we hold off on this?



> 
> BR,
> Jani.
> 
> 
> > ---
> >  drivers/gpu/drm/drm_atomic.c| 106 
> > 
> >  drivers/gpu/drm/drm_crtc_internal.h |   1 +
> >  drivers/gpu/drm/drm_framebuffer.c   |   7 +++
> >  3 files changed, 114 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> > index 723392fc98c8..c79ab8048435 100644
> > --- a/drivers/gpu/drm/drm_atomic.c
> > +++ b/drivers/gpu/drm/drm_atomic.c
> > @@ -2058,6 +2058,112 @@ static void complete_crtc_signaling(struct 
> > drm_device *dev,
> > kfree(fence_state);
> >  }
> >  
> > +int drm_atomic_remove_fb(struct drm_framebuffer *fb)
> > +{
> > +   struct drm_modeset_acquire_ctx ctx;
> > +   struct drm_device *dev = fb->dev;
> > +   struct drm_atomic_state *state;
> > +   struct drm_plane *plane;
> > +   struct drm_connector *conn;
> > +   struct drm_connector_state *conn_state;
> > +   int i, ret = 0;
> > +   unsigned plane_mask, disable_crtcs = false;
> > +
> > +   state = drm_atomic_state_alloc(dev);
> > +   if (!state)
> > +   return -ENOMEM;
> > +
> > +   drm_modeset_acquire_init(&ctx, 0);
> > +   state->acquire_ctx = &ctx;
> > +
> > +retry:
> > +   plane_mask = 0;
> > +   ret = drm_modeset_lock_all_ctx(dev, &ctx);
> > +   if (ret)
> > +   goto unlock;
> > +
> > +   drm_for_each_plane(plane, dev) {
> > +   struct drm_plane_state *plane_state;
> > +
> > +   if (plane->state->fb != fb)
> > +   continue;
> > +
> > +   plane_state = drm_atomic_get_plane_state(state, plane);
> > +   if (IS_ERR(plane_state)) {
> > +   ret = PTR_ERR(plane_state);
> > +   goto unlock;
> > +   }
> > +
> > +   /*
> > +* Some drivers do not support keeping crtc active with the
> > +* primary plane disabled. If we fail to commit with -EINVAL
> > +* then we will try to perform the same commit but with all
> > +* crtc's disabled for primary planes as well.
> > +*/
> > +   if (disable_crtcs && plane_state->crtc->primary == plane) {
> > +   struct drm_crtc_state *crtc_state;
> > +
> > +   crtc_state = drm_atomic_get_existing_crtc_state(state, 
> > plane_state->crtc);
> > +
> > +   ret = drm_atomic_add_affected_connectors(state, 
> > plane_state->crtc);
> > +   if (ret)
> > +   goto unlock;
> > +
> > +   crtc_state->active = false;
> > +   ret = drm_atomic_set_mode_for_crtc(crtc_state, NULL);
> > +   if (ret)
> > +   goto unlock;
> > +   }
> > +
> > +   drm_atomic_set_fb_for_plane(plane_state, NULL);
> > +   ret = drm_atomic_set_crtc_for_plane(plane_state, NULL);
> > +   if (ret)
> > +   goto unlock;
> > +
> > +   plane_mask |= BIT(drm_plane_index(plane));
> > +
> > +   plane->old_fb = plane->fb;
> > +   }
> > +
> > +   /* This list is only not empty when disable_crtcs is set. */
> > +   for_each_connector_in_state(state, conn, conn_state, i) {
> > +   ret = drm_atomic_set_crtc_for_connector(conn_state, NULL);
> > +
> > +   if (ret)
> > +   goto unlock;
> > +   }
> > +
> > +   if (plane_mask)
> > +   ret = drm_atomic_commit(sta

Re: [PATCH] drm/vmwgfx: Work around drm removal of control nodes

2017-02-21 Thread Sinclair Yeh
Reviewed-by: Sinclair Yeh 


On Tue, Feb 21, 2017 at 05:42:27PM +0700, Thomas Hellstrom wrote:
> vmware tools has a daemon that gets layout information from the GUI and
> forwards it to DRM so that the modesetting code can set preferred connector
> locations and modes. This daemon was using control nodes but since control
> nodes were just removed, make it possible for the daemon to use render- or
> primary nodes instead. This is a bit ugly but will allow drm to proceed with
> removal of the mostly unused control-node code and allow vmware to proceed
> with fixing up automatic layout settings for gnome-shell/wayland.
> 
> We bump minor to inform user-space about the api change.
> 
> Cc: 
> Signed-off-by: Thomas Hellstrom 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 11 ++-
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |  4 ++--
>  2 files changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 541a588..d08f269 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -199,9 +199,14 @@ static const struct drm_ioctl_desc vmw_ioctls[] = {
>   VMW_IOCTL_DEF(VMW_PRESENT_READBACK,
> vmw_present_readback_ioctl,
> DRM_MASTER | DRM_AUTH),
> + /*
> +  * The permissions of the below ioctl are overridden in
> +  * vmw_generic_ioctl(). We require either
> +  * DRM_MASTER or capable(CAP_SYS_ADMIN).
> +  */
>   VMW_IOCTL_DEF(VMW_UPDATE_LAYOUT,
> vmw_kms_update_layout_ioctl,
> -   DRM_MASTER | DRM_CONTROL_ALLOW),
> +   DRM_RENDER_ALLOW),
>   VMW_IOCTL_DEF(VMW_CREATE_SHADER,
> vmw_shader_define_ioctl,
> DRM_AUTH | DRM_RENDER_ALLOW),
> @@ -1123,6 +1128,10 @@ static long vmw_generic_ioctl(struct file *filp, 
> unsigned int cmd,
>  
>   return (long) vmw_execbuf_ioctl(dev, arg, file_priv,
>   _IOC_SIZE(cmd));
> + } else if (nr == DRM_COMMAND_BASE + DRM_VMW_UPDATE_LAYOUT) {
> + if (!drm_is_current_master(file_priv) &&
> + !capable(CAP_SYS_ADMIN))
> + return -EACCES;
>   }
>  
>   if (unlikely(ioctl->cmd != cmd))
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> index 1e59a48..59ff419 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
> @@ -41,9 +41,9 @@
>  #include 
>  #include "vmwgfx_fence.h"
>  
> -#define VMWGFX_DRIVER_DATE "20160210"
> +#define VMWGFX_DRIVER_DATE "20170221"
>  #define VMWGFX_DRIVER_MAJOR 2
> -#define VMWGFX_DRIVER_MINOR 11
> +#define VMWGFX_DRIVER_MINOR 12
>  #define VMWGFX_DRIVER_PATCHLEVEL 0
>  #define VMWGFX_FILE_PAGE_OFFSET 0x0010
>  #define VMWGFX_FIFO_STATIC_SIZE (1024*1024)
> -- 
> 2.9.3
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2] Revert "drm/vmwgfx: Replace numeric parameter like 0444 with macro"

2017-02-24 Thread Sinclair Yeh
Hi Oyvind,

Thanks for looking at this.

At this moment, I don't really see a benefit one way or anther, so
I am going to stick with the macro version for now, changing the one
remaining module_param_named() you mentioned to using the macros to
keep things consistent.

If one day we have a paramter with a long ORing of the macros, then
we can revisit this decision.

Sinclair

On Sat, Feb 04, 2017 at 07:17:27PM +0100, Øyvind A. Holm wrote:
> This reverts commit 2d8e60e8b0742b7a5cddc806fe38bb81ee876c33.
> 
> The commit belongs to the series of 1285 patches sent to LKML on
> 2016-08-02, it changes the representation of file permissions from the
> octal value "0600" to "S_IRUSR | S_IWUSR".
> 
> The general consensus was that the changes does not increase
> readability, quite the opposite; 0600 is easier to parse mentally than
> S_IRUSR | S_IWUSR.
> 
> It also causes argument inconsistency, due to commit 04319d89fbec
> ("drm/vmwgfx: Add an option to change assumed FB bpp") that added
> another call to module_param_named() where the permissions are written
> as 0600.
> 
> Signed-off-by: Øyvind A. Holm 
> ---
> This is a resend of the patch originally sent on 2017-01-16. The only
> difference from v1 is an improved commit message with some more details.
> 
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 18061a4bc2f2..e8ae3dc476d1 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -241,15 +241,15 @@ static int vmwgfx_pm_notifier(struct notifier_block 
> *nb, unsigned long val,
> void *ptr);
>  
>  MODULE_PARM_DESC(enable_fbdev, "Enable vmwgfx fbdev");
> -module_param_named(enable_fbdev, enable_fbdev, int, S_IRUSR | S_IWUSR);
> +module_param_named(enable_fbdev, enable_fbdev, int, 0600);
>  MODULE_PARM_DESC(force_dma_api, "Force using the DMA API for TTM pages");
> -module_param_named(force_dma_api, vmw_force_iommu, int, S_IRUSR | S_IWUSR);
> +module_param_named(force_dma_api, vmw_force_iommu, int, 0600);
>  MODULE_PARM_DESC(restrict_iommu, "Try to limit IOMMU usage for TTM pages");
> -module_param_named(restrict_iommu, vmw_restrict_iommu, int, S_IRUSR | 
> S_IWUSR);
> +module_param_named(restrict_iommu, vmw_restrict_iommu, int, 0600);
>  MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages");
> -module_param_named(force_coherent, vmw_force_coherent, int, S_IRUSR | 
> S_IWUSR);
> +module_param_named(force_coherent, vmw_force_coherent, int, 0600);
>  MODULE_PARM_DESC(restrict_dma_mask, "Restrict DMA mask to 44 bits with 
> IOMMU");
> -module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, S_IRUSR | 
> S_IWUSR);
> +module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, 0600);
>  MODULE_PARM_DESC(assume_16bpp, "Assume 16-bpp when filtering modes");
>  module_param_named(assume_16bpp, vmw_assume_16bpp, int, 0600);
>  
> -- 
> 2.12.0.rc0
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2] Revert "drm/vmwgfx: Replace numeric parameter like 0444 with macro"

2017-02-24 Thread Sinclair Yeh
On Fri, Feb 24, 2017 at 11:06:03AM -0800, Sinclair Yeh wrote:
> Hi Oyvind,
> 
> Thanks for looking at this.
> 
> At this moment, I don't really see a benefit one way or anther, so
> I am going to stick with the macro version for now, changing the one
> remaining module_param_named() you mentioned to using the macros to
> keep things consistent.
> 
> If one day we have a paramter with a long ORing of the macros, then
> we can revisit this decision.

Actually, now that I see checkpatch.pl has been modified to prefer
octal permissions, I think your suggestion is better.  So I'll
just take your patch instead.

thanks!

Sinclair



> 
> Sinclair
> 
> On Sat, Feb 04, 2017 at 07:17:27PM +0100, Øyvind A. Holm wrote:
> > This reverts commit 2d8e60e8b0742b7a5cddc806fe38bb81ee876c33.
> > 
> > The commit belongs to the series of 1285 patches sent to LKML on
> > 2016-08-02, it changes the representation of file permissions from the
> > octal value "0600" to "S_IRUSR | S_IWUSR".
> > 
> > The general consensus was that the changes does not increase
> > readability, quite the opposite; 0600 is easier to parse mentally than
> > S_IRUSR | S_IWUSR.
> > 
> > It also causes argument inconsistency, due to commit 04319d89fbec
> > ("drm/vmwgfx: Add an option to change assumed FB bpp") that added
> > another call to module_param_named() where the permissions are written
> > as 0600.
> > 
> > Signed-off-by: Øyvind A. Holm 
> > ---
> > This is a resend of the patch originally sent on 2017-01-16. The only
> > difference from v1 is an improved commit message with some more details.
> > 
> >  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 10 +-
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
> > b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > index 18061a4bc2f2..e8ae3dc476d1 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> > @@ -241,15 +241,15 @@ static int vmwgfx_pm_notifier(struct notifier_block 
> > *nb, unsigned long val,
> >   void *ptr);
> >  
> >  MODULE_PARM_DESC(enable_fbdev, "Enable vmwgfx fbdev");
> > -module_param_named(enable_fbdev, enable_fbdev, int, S_IRUSR | S_IWUSR);
> > +module_param_named(enable_fbdev, enable_fbdev, int, 0600);
> >  MODULE_PARM_DESC(force_dma_api, "Force using the DMA API for TTM pages");
> > -module_param_named(force_dma_api, vmw_force_iommu, int, S_IRUSR | S_IWUSR);
> > +module_param_named(force_dma_api, vmw_force_iommu, int, 0600);
> >  MODULE_PARM_DESC(restrict_iommu, "Try to limit IOMMU usage for TTM pages");
> > -module_param_named(restrict_iommu, vmw_restrict_iommu, int, S_IRUSR | 
> > S_IWUSR);
> > +module_param_named(restrict_iommu, vmw_restrict_iommu, int, 0600);
> >  MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages");
> > -module_param_named(force_coherent, vmw_force_coherent, int, S_IRUSR | 
> > S_IWUSR);
> > +module_param_named(force_coherent, vmw_force_coherent, int, 0600);
> >  MODULE_PARM_DESC(restrict_dma_mask, "Restrict DMA mask to 44 bits with 
> > IOMMU");
> > -module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, S_IRUSR 
> > | S_IWUSR);
> > +module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, 0600);
> >  MODULE_PARM_DESC(assume_16bpp, "Assume 16-bpp when filtering modes");
> >  module_param_named(assume_16bpp, vmw_assume_16bpp, int, 0600);
> >  
> > -- 
> > 2.12.0.rc0
> > 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2] drm: move allocation out of drm_get_format_name()

2016-11-07 Thread Sinclair Yeh
Thomas has already acked the earlier version, but in case you need
it for this one, too.

vmwgfx portion:  Acked-by: Sinclair Yeh 

On Mon, Nov 07, 2016 at 12:48:09AM +, Eric Engestrom wrote:
> Fixes: 90844f00049e9f42573fd31d7c32e8fd31d3fd07
> 
> drm: make drm_get_format_name thread-safe
> 
> Signed-off-by: Eric Engestrom 
> [danvet: Clarify that the returned pointer must be freed with
> kfree().]
> Signed-off-by: Daniel Vetter 
> 
> Cc: Rob Clark 
> Cc: Christian König 
> Suggested-by: Ville Syrjälä 
> Signed-off-by: Eric Engestrom 
> ---
> 
> v2: use single-field struct instead of typedef to let the compiler
> enforce the type (Christian König)
> 
> ---
>  include/drm/drm_fourcc.h| 10 +-
>  drivers/gpu/drm/drm_fourcc.c| 14 +++--
>  drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  |  7 ++---
>  drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  |  7 ++---
>  drivers/gpu/drm/amd/amdgpu/dce_v6_0.c   |  3 +-
>  drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   |  7 ++---
>  drivers/gpu/drm/drm_atomic.c|  7 +++--
>  drivers/gpu/drm/drm_crtc.c  |  7 +++--
>  drivers/gpu/drm/drm_framebuffer.c   |  7 +++--
>  drivers/gpu/drm/drm_modeset_helper.c|  7 +++--
>  drivers/gpu/drm/drm_plane.c |  7 +++--
>  drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c |  7 ++---
>  drivers/gpu/drm/i915/i915_debugfs.c | 10 +++---
>  drivers/gpu/drm/i915/intel_atomic_plane.c   |  8 ++---
>  drivers/gpu/drm/i915/intel_display.c| 41 
> ++---
>  drivers/gpu/drm/radeon/atombios_crtc.c  | 14 -
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  3 +-
>  17 files changed, 80 insertions(+), 86 deletions(-)
> 
> diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
> index dc0aafa..4b03ca0 100644
> --- a/include/drm/drm_fourcc.h
> +++ b/include/drm/drm_fourcc.h
> @@ -45,6 +45,14 @@ struct drm_format_info {
>   u8 vsub;
>  };
>  
> +/**
> + * struct drm_format_name_buf - name of a DRM format
> + * @str: string buffer containing the format name
> + */
> +struct drm_format_name_buf {
> + char str[32];
> +};
> +
>  const struct drm_format_info *__drm_format_info(u32 format);
>  const struct drm_format_info *drm_format_info(u32 format);
>  uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth);
> @@ -54,6 +62,6 @@ int drm_format_horz_chroma_subsampling(uint32_t format);
>  int drm_format_vert_chroma_subsampling(uint32_t format);
>  int drm_format_plane_width(int width, uint32_t format, int plane);
>  int drm_format_plane_height(int height, uint32_t format, int plane);
> -char *drm_get_format_name(uint32_t format) __malloc;
> +char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf);
>  
>  #endif /* __DRM_FOURCC_H__ */
> diff --git a/drivers/gpu/drm/drm_fourcc.c b/drivers/gpu/drm/drm_fourcc.c
> index cbb8b77..99b0b60 100644
> --- a/drivers/gpu/drm/drm_fourcc.c
> +++ b/drivers/gpu/drm/drm_fourcc.c
> @@ -79,17 +79,13 @@ uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t 
> depth)
>  EXPORT_SYMBOL(drm_mode_legacy_fb_format);
>  
>  /**
> - * drm_get_format_name - return a string for drm fourcc format
> + * drm_get_format_name - fill a string with a drm fourcc format's name
>   * @format: format to compute name of
> + * @buf: caller-supplied buffer
> - *
> - * Note that the buffer returned by this function is owned by the caller
> - * and will need to be freed using kfree().
>   */
> -char *drm_get_format_name(uint32_t format)
> +char *drm_get_format_name(uint32_t format, struct drm_format_name_buf *buf)
>  {
> - char *buf = kmalloc(32, GFP_KERNEL);
> -
> - snprintf(buf, 32,
> + snprintf(buf->str, sizeof(buf->str),
>"%c%c%c%c %s-endian (0x%08x)",
>printable_char(format & 0xff),
>printable_char((format >> 8) & 0xff),
> @@ -98,7 +94,7 @@ char *drm_get_format_name(uint32_t format)
>format & DRM_FORMAT_BIG_ENDIAN ? "big" : "little",
>format);
>  
> - return buf;
> + return buf->str;
>  }
>  EXPORT_SYMBOL(drm_get_format_name);
>  
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
> index 199d3f7..2924cdd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
> @@ -2032,7 +2032,7 @@ static int dce_v10_0_crtc_do_set_base(struct drm_crtc 
> *crtc,
>   u32 tmp, viewport_w, viewport

[PATCH] drm/vmwgfx : Fix NULL pointer comparison

2016-11-08 Thread Sinclair Yeh
Thanks!

Reviewed-by: Sinclair Yeh 

On Tue, Nov 08, 2016 at 05:30:31PM +0530, Ravikant Bijendra Sharma wrote:
> From: Ravikant B Sharma 
> 
> Replace direct comparisons to NULL i.e.
> 'x == NULL' with '!x'. As per coding standard.
> 
> Signed-off-by: Ravikant B Sharma 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c|4 ++--
>  drivers/gpu/drm/vmwgfx/vmwgfx_context.c   |2 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c   |2 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   |6 +++---
>  drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c   |4 ++--
>  drivers/gpu/drm/vmwgfx/vmwgfx_fence.c |   10 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c |2 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_mob.c   |6 +++---
>  drivers/gpu/drm/vmwgfx/vmwgfx_msg.c   |6 +++---
>  drivers/gpu/drm/vmwgfx/vmwgfx_resource.c  |6 +++---
>  drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c  |2 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_shader.c|6 +++---
>  12 files changed, 28 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
> index 13db8a2..133c8bd 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
> @@ -205,7 +205,7 @@ int vmw_cmdbuf_res_add(struct vmw_cmdbuf_res_manager *man,
>   int ret;
>  
>   cres = kzalloc(sizeof(*cres), GFP_KERNEL);
> - if (unlikely(cres == NULL))
> + if (unlikely(!cres))
>   return -ENOMEM;
>  
>   cres->hash.key = user_key | (res_type << 24);
> @@ -291,7 +291,7 @@ struct vmw_cmdbuf_res_manager *
>   int ret;
>  
>   man = kzalloc(sizeof(*man), GFP_KERNEL);
> - if (man == NULL)
> + if (!man)
>   return ERR_PTR(-ENOMEM);
>  
>   man->dev_priv = dev_priv;
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
> index 443d1ed..1a46b18 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
> @@ -776,7 +776,7 @@ static int vmw_context_define(struct drm_device *dev, 
> void *data,
>   }
>  
>   ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
> - if (unlikely(ctx == NULL)) {
> + if (unlikely(!ctx)) {
>   ttm_mem_global_free(vmw_mem_glob(dev_priv),
>   vmw_user_context_size);
>   ret = -ENOMEM;
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c
> index 265c81e..8751805 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c
> @@ -583,7 +583,7 @@ struct vmw_resource *vmw_cotable_alloc(struct vmw_private 
> *dev_priv,
>   return ERR_PTR(ret);
>  
>   vcotbl = kzalloc(sizeof(*vcotbl), GFP_KERNEL);
> - if (unlikely(vcotbl == NULL)) {
> + if (unlikely(!vcotbl)) {
>   ret = -ENOMEM;
>   goto out_no_alloc;
>   }
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 18061a4..8a269db 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -625,7 +625,7 @@ static int vmw_driver_load(struct drm_device *dev, 
> unsigned long chipset)
>   char host_log[100] = {0};
>  
>   dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL);
> - if (unlikely(dev_priv == NULL)) {
> + if (unlikely(!dev_priv)) {
>   DRM_ERROR("Failed allocating a device private struct.\n");
>   return -ENOMEM;
>   }
> @@ -1029,7 +1029,7 @@ static int vmw_driver_open(struct drm_device *dev, 
> struct drm_file *file_priv)
>   int ret = -ENOMEM;
>  
>   vmw_fp = kzalloc(sizeof(*vmw_fp), GFP_KERNEL);
> - if (unlikely(vmw_fp == NULL))
> + if (unlikely(!vmw_fp))
>   return ret;
>  
>   vmw_fp->tfile = ttm_object_file_init(dev_priv->tdev, 10);
> @@ -1186,7 +1186,7 @@ static int vmw_master_create(struct drm_device *dev,
>   struct vmw_master *vmaster;
>  
>   vmaster = kzalloc(sizeof(*vmaster), GFP_KERNEL);
> - if (unlikely(vmaster == NULL))
> + if (unlikely(!vmaster))
>   return -ENOMEM;
>  
>   vmw_master_init(vmaster);
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> index c7b53d9..2154257 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> @@ -264,7 +264,7 @@ static int vmw_resource_val_add(struct vm

[PATCH] drm/vmwgfx: avoid gcc-7 parentheses warning

2016-11-16 Thread Sinclair Yeh
Looks good to me, thanks!
I'll incorporate this into the next pull request.

Reviewed-by: Sinclair Yeh 

On Wed, Nov 16, 2016 at 03:19:31PM +0100, Arnd Bergmann wrote:
> gcc-7 warns about slightly suspicious code in vmw_cmd_invalid:
> 
> drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c: In function 'vmw_cmd_invalid':
> drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c:522:23: error: the omitted middle 
> operand in ?: will always be 'true', suggest explicit middle operand 
> [-Werror=parentheses]
> 
> The problem is that it is mixing boolean and integer values here.
> I assume that the code actually works correctly, so making it use
> a literal '1' instead of the implied 'true' makes it more readable
> and avoids the warning.
> 
> The code has been in this file since the start, but it could
> make sense to backport this patch to stable to make it build cleanly
> with gcc-7.
> 
> Fixes: fb1d9738ca05 ("drm/vmwgfx: Add DRM driver for VMware Virtual GPU")
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> index c7b53d987f06..3f343e55972a 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> @@ -519,7 +519,7 @@ static int vmw_cmd_invalid(struct vmw_private *dev_priv,
>  struct vmw_sw_context *sw_context,
>  SVGA3dCmdHeader *header)
>  {
> - return capable(CAP_SYS_ADMIN) ? : -EINVAL;
> + return capable(CAP_SYS_ADMIN) ? 1 : -EINVAL;
>  }
>  
>  static int vmw_cmd_ok(struct vmw_private *dev_priv,
> -- 
> 2.9.0
> 


[PATCH 14/37] drm/vmwgfx: Populate fb->pixel_format

2016-11-21 Thread Sinclair Yeh
Reviewed-by: Sinclair Yeh 

On Fri, Nov 18, 2016 at 09:52:50PM +0200, ville.syrjala at linux.intel.com 
wrote:
> From: Ville Syrjälä 
> 
> Stuff something semi-reasonable into fb->pixel_format. I had to guess
> as to which formats we should pick. Did I guess correctly?
> 
> We can't quite use drm_mode_legacy_fb_format() due to the ARGB1555
> vs. XRGB155 mess. However use of 'A' formats should imply per-pixel
> alpha blending as far as KMS is concerned so I'm not at all sure we
> want to have any 'A' formats exposed as opposed to just 'X' formats.
> OTOH vmvgfx doesn't do planes, and so the core won't enforce that
> these formats match any list of supported formats, so the choice
> shouldn't be super important at this point.
> 
> Cc: linux-graphics-maintainer at vmware.com
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> Signed-off-by: Ville Syrjälä 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 23 ++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index 7d92ab56961b..5788913ca8f9 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -524,6 +524,7 @@ static int vmw_kms_new_framebuffer_surface(struct 
> vmw_private *dev_priv,
>   struct drm_device *dev = dev_priv->dev;
>   struct vmw_framebuffer_surface *vfbs;
>   enum SVGA3dSurfaceFormat format;
> + u32 pixel_format;
>   int ret;
>  
>   /* 3D is only supported on HWv8 and newer hosts */
> @@ -548,17 +549,22 @@ static int vmw_kms_new_framebuffer_surface(struct 
> vmw_private *dev_priv,
>   return -EINVAL;
>   }
>  
> + /* FIXME 'A' format implies per-pixel alpha blending for KMS */
>   switch (mode_cmd->depth) {
>   case 32:
> + pixel_format = DRM_FORMAT_ARGB;
>   format = SVGA3D_A8R8G8B8;
>   break;
>   case 24:
> + pixel_format = DRM_FORMAT_XRGB;
>   format = SVGA3D_X8R8G8B8;
>   break;
>   case 16:
> + pixel_format = DRM_FORMAT_RGB565;
>   format = SVGA3D_R5G6B5;
>   break;
>   case 15:
> + pixel_format = DRM_FORMAT_ARGB1555;
>   format = SVGA3D_A1R5G5B5;
>   break;
>   default:
> @@ -582,7 +588,8 @@ static int vmw_kms_new_framebuffer_surface(struct 
> vmw_private *dev_priv,
>   }
>  
>   vfbs->base.base.dev = dev;
> - /* XXX get the first 3 from the surface info */
> + /* XXX get the first 4 from the surface info */
> + vfbs->base.base.pixel_format = pixel_format;
>   vfbs->base.base.bits_per_pixel = mode_cmd->bpp;
>   vfbs->base.base.pitches[0] = mode_cmd->pitch;
>   vfbs->base.base.depth = mode_cmd->depth;
> @@ -834,6 +841,7 @@ static int vmw_kms_new_framebuffer_dmabuf(struct 
> vmw_private *dev_priv,
>   struct drm_device *dev = dev_priv->dev;
>   struct vmw_framebuffer_dmabuf *vfbd;
>   unsigned int requested_size;
> + u32 pixel_format;
>   int ret;
>  
>   requested_size = mode_cmd->height * mode_cmd->pitch;
> @@ -852,6 +860,12 @@ static int vmw_kms_new_framebuffer_dmabuf(struct 
> vmw_private *dev_priv,
>   if (mode_cmd->bpp == 32)
>   break;
>  
> + /* FIXME 'A' format implies per-pixel alpha blending 
> for KMS */
> + if (mode_cmd->depth == 32)
> + pixel_format = DRM_FORMAT_ARGB;
> + else
> + pixel_format = DRM_FORMAT_XRGB;
> +
>   DRM_ERROR("Invalid color depth/bbp: %d %d\n",
> mode_cmd->depth, mode_cmd->bpp);
>   return -EINVAL;
> @@ -861,6 +875,12 @@ static int vmw_kms_new_framebuffer_dmabuf(struct 
> vmw_private *dev_priv,
>   if (mode_cmd->bpp == 16)
>   break;
>  
> + /* FIXME 'A' format implies per-pixel alpha blending 
> for KMS */
> + if (mode_cmd->depth == 16)
> + pixel_format = DRM_FORMAT_RGB565;
> + else
> + pixel_format = DRM_FORMAT_ARGB1555;
> +
>   DRM_ERROR("Invalid color depth/bbp: %d %d\n",
> mode_cmd->depth, mode_cmd->bpp);
>   return -EINVAL;
> @@ -877,6 +897,7 @@ static int vmw_kms_new_framebuffer_dmabuf(struct 
> vmw_private *dev_priv,
>   }
>  
>   vfbd->base.base.dev = dev;
> + vfbd->base.base.pixel_format = pixel_format;
>   vfbd->base.base.bits_per_pixel = mode_cmd->bpp;
>   vfbd->base.base.pitches[0] = mode_cmd->pitch;
>   vfbd->base.base.depth = mode_cmd->depth;
> -- 
> 2.7.4
> 


[PATCH 12/37] drm/vmwgfx: Populate fb->dev before drm_framebuffer_init()

2016-11-21 Thread Sinclair Yeh
Minor typo below.

Reviewed-by: Sinclair Yeh 

On Fri, Nov 18, 2016 at 09:52:48PM +0200, ville.syrjala at linux.intel.com 
wrote:
> From: Ville Syrjälä 
> 
> drm_framebuffer_init() will start to check that fb->dev is already
> populated, so let's to that manually since vmwgfx isn't using
  ^
do

> drm_helper_mode_fill_fb_struct().
> 
> Cc: linux-graphics-maintainer at vmware.com
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> Signed-off-by: Ville Syrjälä 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index e3f68cc9bb4b..7d92ab56961b 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -581,6 +581,7 @@ static int vmw_kms_new_framebuffer_surface(struct 
> vmw_private *dev_priv,
>   goto out_err1;
>   }
>  
> + vfbs->base.base.dev = dev;
>   /* XXX get the first 3 from the surface info */
>   vfbs->base.base.bits_per_pixel = mode_cmd->bpp;
>   vfbs->base.base.pitches[0] = mode_cmd->pitch;
> @@ -875,6 +876,7 @@ static int vmw_kms_new_framebuffer_dmabuf(struct 
> vmw_private *dev_priv,
>   goto out_err1;
>   }
>  
> + vfbd->base.base.dev = dev;
>   vfbd->base.base.bits_per_pixel = mode_cmd->bpp;
>   vfbd->base.base.pitches[0] = mode_cmd->pitch;
>   vfbd->base.base.depth = mode_cmd->depth;
> -- 
> 2.7.4
> 


[PATCH] drm/vmwgfx: Fix handling of errors returned by 'vmw_cotable_alloc()'

2016-11-29 Thread Sinclair Yeh
Good catch.

Reviewed-by: Sinclair Yeh 

On Tue, Nov 29, 2016 at 07:49:19AM +0100, Christophe JAILLET wrote:
> 'vmw_cotable_alloc()' returns an error pointer on error, not NULL.
> Propagate the error code, instead of returning -ENOMEM unconditionally
> 
> Signed-off-by: Christophe JAILLET 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
> index 443d1ed00de7..d1aee9860033 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
> @@ -209,8 +209,8 @@ static int vmw_gb_context_init(struct vmw_private 
> *dev_priv,
>   for (i = 0; i < SVGA_COTABLE_DX10_MAX; ++i) {
>   uctx->cotables[i] = vmw_cotable_alloc(dev_priv,
> &uctx->res, i);
> - if (unlikely(uctx->cotables[i] == NULL)) {
> - ret = -ENOMEM;
> + if (unlikely(IS_ERR(uctx->cotables[i]))) {
> + ret = PTR_ERR(uctx->cotables[i]);
>   goto out_cotables;
>   }
>   }
> -- 
> 2.9.3
> 


Re: [PATCH 1/2] drm/vmwgfx: Drop drm_vblank_cleanup

2017-07-03 Thread Sinclair Yeh
Thanks!

Minor typo "dsiplay", otherwise:  Reviewed-by: Sinclair Yeh 

On Mon, Jun 26, 2017 at 06:19:48PM +0200, Daniel Vetter wrote:
> Again stopping the vblank before uninstalling the irq handler is kinda
> the wrong way round, but the fb_off stuff should take care of
> disabling the dsiplay at least in most cases. So drop the
> drm_vblank_cleanup code since it's not really doing anything, it looks
> all cargo-culted.
> 
> v2: Appease gcc better.
> 
> v3: Simplify code (Sean Paul)
> 
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> Reviewed-by: Sean Paul 
> Reviewed-by: Thomas Hellstrom 
> Signed-off-by: Daniel Vetter 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  |  8 ++--
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.h  |  2 --
>  drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c  |  4 
>  drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c |  9 -
>  drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 27 +--
>  5 files changed, 3 insertions(+), 47 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index 3d94ea67a825..1cd67b10a0d9 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -1658,7 +1658,7 @@ int vmw_kms_init(struct vmw_private *dev_priv)
>  
>  int vmw_kms_close(struct vmw_private *dev_priv)
>  {
> - int ret;
> + int ret = 0;
>  
>   /*
>* Docs says we should take the lock before calling this function
> @@ -1666,11 +1666,7 @@ int vmw_kms_close(struct vmw_private *dev_priv)
>* drm_encoder_cleanup which takes the lock we deadlock.
>*/
>   drm_mode_config_cleanup(dev_priv->dev);
> - if (dev_priv->active_display_unit == vmw_du_screen_object)
> - ret = vmw_kms_sou_close_display(dev_priv);
> - else if (dev_priv->active_display_unit == vmw_du_screen_target)
> - ret = vmw_kms_stdu_close_display(dev_priv);
> - else
> + if (dev_priv->active_display_unit == vmw_du_legacy)
>   ret = vmw_kms_ldu_close_display(dev_priv);
>  
>   return ret;
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
> index 5f8d678ae675..ff9c8389ff21 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
> @@ -390,7 +390,6 @@ int vmw_kms_update_proxy(struct vmw_resource *res,
>   * Screen Objects display functions - vmwgfx_scrn.c
>   */
>  int vmw_kms_sou_init_display(struct vmw_private *dev_priv);
> -int vmw_kms_sou_close_display(struct vmw_private *dev_priv);
>  int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv,
>struct vmw_framebuffer *framebuffer,
>struct drm_clip_rect *clips,
> @@ -418,7 +417,6 @@ int vmw_kms_sou_readback(struct vmw_private *dev_priv,
>   * Screen Target Display Unit functions - vmwgfx_stdu.c
>   */
>  int vmw_kms_stdu_init_display(struct vmw_private *dev_priv);
> -int vmw_kms_stdu_close_display(struct vmw_private *dev_priv);
>  int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv,
>  struct vmw_framebuffer *framebuffer,
>  struct drm_clip_rect *clips,
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
> index d3987bcf53f8..449ed4fba0f2 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
> @@ -582,13 +582,9 @@ int vmw_kms_ldu_init_display(struct vmw_private 
> *dev_priv)
>  
>  int vmw_kms_ldu_close_display(struct vmw_private *dev_priv)
>  {
> - struct drm_device *dev = dev_priv->dev;
> -
>   if (!dev_priv->ldu_priv)
>   return -ENOSYS;
>  
> - drm_vblank_cleanup(dev);
> -
>   BUG_ON(!list_empty(&dev_priv->ldu_priv->active));
>  
>   kfree(dev_priv->ldu_priv);
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
> index 8d7dc9def7c2..3b917c9b0c21 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
> @@ -746,15 +746,6 @@ int vmw_kms_sou_init_display(struct vmw_private 
> *dev_priv)
>   return 0;
>  }
>  
> -int vmw_kms_sou_close_display(struct vmw_private *dev_priv)
> -{
> - struct drm_device *dev = dev_priv->dev;
> -
> - drm_vblank_cleanup(dev);
> -
> - return 0;
> -}
> -
>  static int do_dmabuf_define_gmrfb(struct vmw_private *dev_priv,
> struct vmw_framebuffer *framebuffer)
>  {
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c 
> b/drivers/gpu/drm/vmwgfx/vmwg

Re: [PATCH] drm: ttm: vmwgfx: dma-buf: Constify ttm_place structures.

2017-07-04 Thread Sinclair Yeh
Looks good.  Thanks.

I've queued this for my next pull request.

On Sun, Jul 02, 2017 at 01:26:55PM +0530, Arvind Yadav wrote:
> ttm_place are not supposed to change at runtime. All functions
> working with ttm_place provided by  work
> with const ttm_place. So mark the non-const structs as const.
> 
> File size before:
>text  data bss dec hex filename
>3172   796  163984 f90 
> drivers/gpu/drm/vmwgfx/vmwgfx_buffer.o
> 
> File size After adding 'const':
>text  data bss dec hex filename
>3456   512  163984 f90 
> drivers/gpu/drm/vmwgfx/vmwgfx_buffer.o
> 
> Signed-off-by: Arvind Yadav 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 24 
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
> index 35bf781..c705632 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
> @@ -30,49 +30,49 @@
>  #include 
>  #include 
>  
> -static struct ttm_place vram_placement_flags = {
> +static const struct ttm_place vram_placement_flags = {
>   .fpfn = 0,
>   .lpfn = 0,
>   .flags = TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED
>  };
>  
> -static struct ttm_place vram_ne_placement_flags = {
> +static const struct ttm_place vram_ne_placement_flags = {
>   .fpfn = 0,
>   .lpfn = 0,
>   .flags = TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED | TTM_PL_FLAG_NO_EVICT
>  };
>  
> -static struct ttm_place sys_placement_flags = {
> +static const struct ttm_place sys_placement_flags = {
>   .fpfn = 0,
>   .lpfn = 0,
>   .flags = TTM_PL_FLAG_SYSTEM | TTM_PL_FLAG_CACHED
>  };
>  
> -static struct ttm_place sys_ne_placement_flags = {
> +static const struct ttm_place sys_ne_placement_flags = {
>   .fpfn = 0,
>   .lpfn = 0,
>   .flags = TTM_PL_FLAG_SYSTEM | TTM_PL_FLAG_CACHED | TTM_PL_FLAG_NO_EVICT
>  };
>  
> -static struct ttm_place gmr_placement_flags = {
> +static const struct ttm_place gmr_placement_flags = {
>   .fpfn = 0,
>   .lpfn = 0,
>   .flags = VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED
>  };
>  
> -static struct ttm_place gmr_ne_placement_flags = {
> +static const struct ttm_place gmr_ne_placement_flags = {
>   .fpfn = 0,
>   .lpfn = 0,
>   .flags = VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED | TTM_PL_FLAG_NO_EVICT
>  };
>  
> -static struct ttm_place mob_placement_flags = {
> +static const struct ttm_place mob_placement_flags = {
>   .fpfn = 0,
>   .lpfn = 0,
>   .flags = VMW_PL_FLAG_MOB | TTM_PL_FLAG_CACHED
>  };
>  
> -static struct ttm_place mob_ne_placement_flags = {
> +static const struct ttm_place mob_ne_placement_flags = {
>   .fpfn = 0,
>   .lpfn = 0,
>   .flags = VMW_PL_FLAG_MOB | TTM_PL_FLAG_CACHED | TTM_PL_FLAG_NO_EVICT
> @@ -85,7 +85,7 @@ struct ttm_placement vmw_vram_placement = {
>   .busy_placement = &vram_placement_flags
>  };
>  
> -static struct ttm_place vram_gmr_placement_flags[] = {
> +static const struct ttm_place vram_gmr_placement_flags[] = {
>   {
>   .fpfn = 0,
>   .lpfn = 0,
> @@ -97,7 +97,7 @@ static struct ttm_place vram_gmr_placement_flags[] = {
>   }
>  };
>  
> -static struct ttm_place gmr_vram_placement_flags[] = {
> +static const struct ttm_place gmr_vram_placement_flags[] = {
>   {
>   .fpfn = 0,
>   .lpfn = 0,
> @@ -116,7 +116,7 @@ struct ttm_placement vmw_vram_gmr_placement = {
>   .busy_placement = &gmr_placement_flags
>  };
>  
> -static struct ttm_place vram_gmr_ne_placement_flags[] = {
> +static const struct ttm_place vram_gmr_ne_placement_flags[] = {
>   {
>   .fpfn = 0,
>   .lpfn = 0,
> @@ -165,7 +165,7 @@ struct ttm_placement vmw_sys_ne_placement = {
>   .busy_placement = &sys_ne_placement_flags
>  };
>  
> -static struct ttm_place evictable_placement_flags[] = {
> +static const struct ttm_place evictable_placement_flags[] = {
>   {
>   .fpfn = 0,
>   .lpfn = 0,
> -- 
> 2.7.4
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 05/16] drm/vmwgfx: Make check_modeset() use the new atomic iterator macros.

2017-07-12 Thread Sinclair Yeh
Reviewed-by: Sinclair Yeh 

On Wed, Jul 12, 2017 at 10:13:33AM +0200, Maarten Lankhorst wrote:
> I don't think the checking of resources in this function is very
> atomic-like, but it should definitely not use a macro that's about
> to be removed.
> 
> Signed-off-by: Maarten Lankhorst 
> Cc: VMware Graphics 
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index 1cd67b10a0d9..64f66ff97fab 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -1536,8 +1536,7 @@ vmw_kms_atomic_check_modeset(struct drm_device *dev,
>   struct vmw_private *dev_priv = vmw_priv(dev);
>   int i;
>  
> -
> - for_each_crtc_in_state(state, crtc, crtc_state, i) {
> + for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
>   unsigned long requested_bb_mem = 0;
>  
>   if (dev_priv->active_display_unit == vmw_du_screen_target) {
> -- 
> 2.11.0
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Intel-gfx] [PATCH 05/16] drm/vmwgfx: Make check_modeset() use the new atomic iterator macros.

2017-07-12 Thread Sinclair Yeh
On Wed, Jul 12, 2017 at 11:09:16AM +0200, Daniel Vetter wrote:
> On Wed, Jul 12, 2017 at 10:13:33AM +0200, Maarten Lankhorst wrote:
> > I don't think the checking of resources in this function is very
> > atomic-like, but it should definitely not use a macro that's about
> > to be removed.
> > 
> > Signed-off-by: Maarten Lankhorst 
> > Cc: VMware Graphics 
> > Cc: Sinclair Yeh 
> > Cc: Thomas Hellstrom 
> > ---
> >  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
> > b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > index 1cd67b10a0d9..64f66ff97fab 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > @@ -1536,8 +1536,7 @@ vmw_kms_atomic_check_modeset(struct drm_device *dev,
> 
> Afaics vmw_kms_atomic_check_modeset should be static. Feel free to include
> or not include that bikeshed.
> 
> Reviewed-by: Daniel Vetter 

Yeah, good point.

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


Re: [PATCH 3/3] gpu: drm: drivers: Convert printk(KERN_ to pr_

2017-02-28 Thread Sinclair Yeh
For drm/vmwgfx:  Acked-by: Sinclair Yeh 

On Tue, Feb 28, 2017 at 04:55:54AM -0800, Joe Perches wrote:
> Use a more common logging style.
> 
> Miscellanea:
> 
> o Coalesce formats and realign arguments
> o Neaten a few macros now using pr_
> 
> Signed-off-by: Joe Perches 
> ---
>  drivers/gpu/drm/gma500/cdv_intel_lvds.c   |  9 -
>  drivers/gpu/drm/gma500/oaktrail_lvds.c| 18 +-
>  drivers/gpu/drm/gma500/psb_drv.h  |  5 ++---
>  drivers/gpu/drm/gma500/psb_intel_lvds.c   |  7 +++
>  drivers/gpu/drm/i915/i915_sw_fence.c  |  8 
>  drivers/gpu/drm/mgag200/mgag200_mode.c|  2 +-
>  drivers/gpu/drm/msm/msm_drv.c |  2 +-
>  drivers/gpu/drm/nouveau/nouveau_acpi.c|  7 ---
>  drivers/gpu/drm/nouveau/nouveau_vga.c |  4 ++--
>  drivers/gpu/drm/nouveau/nv50_display.c| 22 +++---
>  drivers/gpu/drm/nouveau/nvkm/core/mm.c| 10 +-
>  drivers/gpu/drm/omapdrm/dss/dsi.c | 17 -
>  drivers/gpu/drm/omapdrm/dss/dss.c |  3 +--
>  drivers/gpu/drm/omapdrm/dss/dss.h | 15 ++-
>  drivers/gpu/drm/omapdrm/omap_gem.c|  5 ++---
>  drivers/gpu/drm/r128/r128_cce.c   |  7 +++
>  drivers/gpu/drm/ttm/ttm_bo.c  |  2 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_fence.c |  6 ++
>  drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c |  3 +--
>  drivers/gpu/drm/vmwgfx/vmwgfx_resource.c  |  4 ++--
>  20 files changed, 72 insertions(+), 84 deletions(-)
> 
> diff --git a/drivers/gpu/drm/gma500/cdv_intel_lvds.c 
> b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
> index 5efdb7fbb7ee..e64960db3224 100644
> --- a/drivers/gpu/drm/gma500/cdv_intel_lvds.c
> +++ b/drivers/gpu/drm/gma500/cdv_intel_lvds.c
> @@ -284,8 +284,7 @@ static bool cdv_intel_lvds_mode_fixup(struct drm_encoder 
> *encoder,
>   head) {
>   if (tmp_encoder != encoder
>   && tmp_encoder->crtc == encoder->crtc) {
> - printk(KERN_ERR "Can't enable LVDS and another "
> -"encoder on the same pipe\n");
> + pr_err("Can't enable LVDS and another encoder on the 
> same pipe\n");
>   return false;
>   }
>   }
> @@ -756,13 +755,13 @@ void cdv_intel_lvds_init(struct drm_device *dev,
>  
>  failed_find:
>   mutex_unlock(&dev->mode_config.mutex);
> - printk(KERN_ERR "Failed find\n");
> + pr_err("Failed find\n");
>   psb_intel_i2c_destroy(gma_encoder->ddc_bus);
>  failed_ddc:
> - printk(KERN_ERR "Failed DDC\n");
> + pr_err("Failed DDC\n");
>   psb_intel_i2c_destroy(gma_encoder->i2c_bus);
>  failed_blc_i2c:
> - printk(KERN_ERR "Failed BLC\n");
> + pr_err("Failed BLC\n");
>   drm_encoder_cleanup(encoder);
>   drm_connector_cleanup(connector);
>   kfree(lvds_priv);
> diff --git a/drivers/gpu/drm/gma500/oaktrail_lvds.c 
> b/drivers/gpu/drm/gma500/oaktrail_lvds.c
> index f7038f12ac76..e6943fef0611 100644
> --- a/drivers/gpu/drm/gma500/oaktrail_lvds.c
> +++ b/drivers/gpu/drm/gma500/oaktrail_lvds.c
> @@ -255,15 +255,15 @@ static void oaktrail_lvds_get_configuration_mode(struct 
> drm_device *dev,
>   ((ti->vblank_hi << 8) | ti->vblank_lo);
>   mode->clock = ti->pixel_clock * 10;
>  #if 0
> - printk(KERN_INFO "hdisplay is %d\n", mode->hdisplay);
> - printk(KERN_INFO "vdisplay is %d\n", mode->vdisplay);
> - printk(KERN_INFO "HSS is %d\n", mode->hsync_start);
> - printk(KERN_INFO "HSE is %d\n", mode->hsync_end);
> - printk(KERN_INFO "htotal is %d\n", mode->htotal);
> - printk(KERN_INFO "VSS is %d\n", mode->vsync_start);
> - printk(KERN_INFO "VSE is %d\n", mode->vsync_end);
> - printk(KERN_INFO "vtotal is %d\n", mode->vtotal);
> - printk(KERN_INFO "clock is %d\n", mode->clock);
> + pr_info("hdisplay is %d\n", mode->hdisplay);
> + pr_info("vdisplay is %d\n", mode->vdisplay);
> + pr_info("HSS is %d\n", mode->hsync_start);
> + pr_info("HSE is %d\n", mode->hsync_end);
> + pr_info("htotal is %d\n", mode->htotal);
> + pr_i

Re: [PATCH] drm/vmwgfx: Check check that number of mip levels is above zero in vmw_surface_define_ioctl()

2017-03-24 Thread Sinclair Yeh
Hi,

thank you for this patch.  Murray McAllister reported this one a couple
of months ago, and this is already in our queue.

Sinclair

On Fri, Mar 24, 2017 at 04:37:10PM +0100, Vladis Dronov wrote:
> In vmw_surface_define_ioctl(), a num_sizes parameter is assigned a
> user-controlled value which is not checked for zero. It is used in
> a call to kmalloc() which returns ZERO_SIZE_PTR. Later ZERO_SIZE_PTR
> is dereferenced which leads to a GPF and possibly to a kernel panic.
> Add the check for zero to avoid this.
> 
> Reference: 
> https://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.redhat.com_show-5Fbug.cgi-3Fid-3D1435719&d=DwIBAg&c=uilaK90D4TOVoH58JNXRgQ&r=HaJ2a6NYExoV0cntAYcoqA&m=OW9cIAAez9eRIxEYMaToDu2szuR_YrfQcOzAH6L8dXo&s=-3P2pG3n1YW6-8NG6mLC7kyxmx7mMxJmXgY79ZgQeo4&e=
>  
> Signed-off-by: Vladis Dronov 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> index b445ce9..42840cc 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> @@ -716,8 +716,8 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void 
> *data,
>   for (i = 0; i < DRM_VMW_MAX_SURFACE_FACES; ++i)
>   num_sizes += req->mip_levels[i];
>  
> - if (num_sizes > DRM_VMW_MAX_SURFACE_FACES *
> - DRM_VMW_MAX_MIP_LEVELS)
> + if (num_sizes <= 0 ||
> + num_sizes > DRM_VMW_MAX_SURFACE_FACES * DRM_VMW_MAX_MIP_LEVELS)
>   return -EINVAL;
>  
>   size = vmw_user_surface_size + 128 +
> -- 
> 2.9.3
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 00/11] Enable Atomic Mode Set on vmwgfx

2017-03-27 Thread Sinclair Yeh
This series enables atomic mode set on vmwgfx.  Developed in
collaboration with Thomas Hellstrom and the VMWare Graphics
Team.

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


[PATCH 02/11] drm/vmwgfx: CRTC atomic state

2017-03-27 Thread Sinclair Yeh
Create and Add CRTC state.  We currently do not track any properties
or custom states so we can technically use the DRM helpers.  Creating
this code just to make potential future additions easier.

Most of the new code will be compiled but not enabled until
plane/connector state handling code is also in place.

This is the first of a series to enable atomic mode set for vmwgfx.

The atomic enabling effort was done in collaboration with Thomas
Hellstrom and the VMware Graphics Team.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  | 81 
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h  | 23 --
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c  | 10 +
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 10 +
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 10 +
 5 files changed, 131 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index c9f5dda..18bd8dc 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -26,6 +26,8 @@
  **/
 
 #include "vmwgfx_kms.h"
+#include 
+#include 
 
 
 /* Might need a hrtimer here? */
@@ -388,6 +390,84 @@ void vmw_du_primary_plane_destroy(struct drm_plane *plane)
 }
 
 
+/**
+ * vmw_du_crtc_duplicate_state - duplicate crtc state
+ * @crtc: DRM crtc
+ *
+ * Allocates and returns a copy of the crtc state (both common and
+ * vmw-specific) for the specified crtc.
+ *
+ * Returns: The newly allocated crtc state, or NULL on failure.
+ */
+struct drm_crtc_state *
+vmw_du_crtc_duplicate_state(struct drm_crtc *crtc)
+{
+   struct drm_crtc_state *state;
+   struct vmw_crtc_state *vcs;
+
+   if (WARN_ON(!crtc->state))
+   return NULL;
+
+   vcs = kmemdup(crtc->state, sizeof(*vcs), GFP_KERNEL);
+
+   if (!vcs)
+   return NULL;
+
+   state = &vcs->base;
+
+   __drm_atomic_helper_crtc_duplicate_state(crtc, state);
+
+   return state;
+}
+
+
+/**
+ * vmw_du_crtc_reset - creates a blank vmw crtc state
+ * @crtc: DRM crtc
+ *
+ * Resets the atomic state for @crtc by freeing the state pointer (which
+ * might be NULL, e.g. at driver load time) and allocating a new empty state
+ * object.
+ */
+void vmw_du_crtc_reset(struct drm_crtc *crtc)
+{
+   struct vmw_crtc_state *vcs;
+
+
+   if (crtc->state) {
+   __drm_atomic_helper_crtc_destroy_state(crtc->state);
+
+   kfree(vmw_crtc_state_to_vcs(crtc->state));
+   }
+
+   vcs = kzalloc(sizeof(*vcs), GFP_KERNEL);
+
+   if (!vcs) {
+   DRM_ERROR("Cannot allocate vmw_crtc_state\n");
+   return;
+   }
+
+   crtc->state = &vcs->base;
+   crtc->state->crtc = crtc;
+}
+
+
+/**
+ * vmw_du_crtc_destroy_state - destroy crtc state
+ * @crtc: DRM crtc
+ * @state: state object to destroy
+ *
+ * Destroys the crtc state (both common and vmw-specific) for the
+ * specified plane.
+ */
+void
+vmw_du_crtc_destroy_state(struct drm_crtc *crtc,
+ struct drm_crtc_state *state)
+{
+   drm_atomic_helper_crtc_destroy_state(crtc, state);
+}
+
+
 /*
  * Generic framebuffer code
  */
@@ -1600,6 +1680,7 @@ int vmw_du_connector_set_property(struct drm_connector 
*connector,
 }
 
 
+
 int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
 {
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
index e400bfb..370f75c 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
@@ -139,6 +139,19 @@ static const uint32_t vmw_cursor_plane_formats[] = {
DRM_FORMAT_ARGB,
 };
 
+
+#define vmw_crtc_state_to_vcs(x) container_of(x, struct vmw_crtc_state, base)
+
+
+/**
+ * Derived class for crtc state object
+ *
+ * @base DRM crtc object
+ */
+struct vmw_crtc_state {
+   struct drm_crtc_state base;
+};
+
 /**
  * Base class display unit.
  *
@@ -205,6 +218,9 @@ int vmw_du_crtc_cursor_set2(struct drm_crtc *crtc, struct 
drm_file *file_priv,
uint32_t handle, uint32_t width, uint32_t height,
int32_t hot_x, int32_t hot_y);
 int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
+int vmw_du_connector_set_property(struct drm_connector *connector,
+ struct drm_property *property,
+ uint64_t val);
 int vmw_du_connector_dpms(struct drm_connector *connector, int mode);
 void vmw_du_connector_save(struct drm_connector *connector);
 void vmw_du_connector_restore(struct drm_connector *connector);
@@ -212,9 +228,6 @@ enum drm_connector_status
 vmw_du_connector_detect(struct drm_connector *connector, bool force);
 int vmw_du_connector_fill_modes(struct drm_conn

[PATCH 01/11] drm/vmwgfx: Add universal plane support

2017-03-27 Thread Sinclair Yeh
Universal support is prerequisite for atomic mode set.

Explicitly create planes for the cursor and the primary FB.  With
a functional cursor plane, the DRM will no longer use the legacy
cursor_set2 and cursor_move entry points.

Signed-off-by: Sinclair Yeh 
Signed-off-by: Thomas Hellstrom 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c  |   1 +
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h  |   1 +
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  | 271 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h  |  39 +++--
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c  | 108 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c |  87 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c |  89 ++--
 7 files changed, 398 insertions(+), 198 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 541a588..45d711e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -645,6 +645,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned 
long chipset)
spin_lock_init(&dev_priv->waiter_lock);
spin_lock_init(&dev_priv->cap_lock);
spin_lock_init(&dev_priv->svga_lock);
+   spin_lock_init(&dev_priv->cursor_lock);
 
for (i = vmw_res_context; i < vmw_res_max; ++i) {
idr_init(&dev_priv->res_idr[i]);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 9ae4477..ef0181c 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -414,6 +414,7 @@ struct vmw_private {
unsigned num_implicit;
struct vmw_framebuffer *implicit_fb;
struct mutex global_kms_state_mutex;
+   spinlock_t cursor_lock;
 
/*
 * Context and surface management.
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 6bcba56..c9f5dda 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -33,10 +33,9 @@
 
 void vmw_du_cleanup(struct vmw_display_unit *du)
 {
-   if (du->cursor_surface)
-   vmw_surface_unreference(&du->cursor_surface);
-   if (du->cursor_dmabuf)
-   vmw_dmabuf_unreference(&du->cursor_dmabuf);
+   drm_plane_cleanup(&du->primary);
+   drm_plane_cleanup(&du->cursor);
+
drm_connector_unregister(&du->connector);
drm_crtc_cleanup(&du->crtc);
drm_encoder_cleanup(&du->encoder);
@@ -47,9 +46,9 @@ void vmw_du_cleanup(struct vmw_display_unit *du)
  * Display Unit Cursor functions
  */
 
-int vmw_cursor_update_image(struct vmw_private *dev_priv,
-   u32 *image, u32 width, u32 height,
-   u32 hotspotX, u32 hotspotY)
+static int vmw_cursor_update_image(struct vmw_private *dev_priv,
+  u32 *image, u32 width, u32 height,
+  u32 hotspotX, u32 hotspotY)
 {
struct {
u32 cmd;
@@ -83,10 +82,10 @@ int vmw_cursor_update_image(struct vmw_private *dev_priv,
return 0;
 }
 
-int vmw_cursor_update_dmabuf(struct vmw_private *dev_priv,
-struct vmw_dma_buffer *dmabuf,
-u32 width, u32 height,
-u32 hotspotX, u32 hotspotY)
+static int vmw_cursor_update_dmabuf(struct vmw_private *dev_priv,
+   struct vmw_dma_buffer *dmabuf,
+   u32 width, u32 height,
+   u32 hotspotX, u32 hotspotY)
 {
struct ttm_bo_kmap_obj map;
unsigned long kmap_offset;
@@ -120,145 +119,22 @@ int vmw_cursor_update_dmabuf(struct vmw_private 
*dev_priv,
 }
 
 
-void vmw_cursor_update_position(struct vmw_private *dev_priv,
-   bool show, int x, int y)
+static void vmw_cursor_update_position(struct vmw_private *dev_priv,
+  bool show, int x, int y)
 {
u32 *fifo_mem = dev_priv->mmio_virt;
uint32_t count;
 
+   spin_lock(&dev_priv->cursor_lock);
vmw_mmio_write(show ? 1 : 0, fifo_mem + SVGA_FIFO_CURSOR_ON);
vmw_mmio_write(x, fifo_mem + SVGA_FIFO_CURSOR_X);
vmw_mmio_write(y, fifo_mem + SVGA_FIFO_CURSOR_Y);
count = vmw_mmio_read(fifo_mem + SVGA_FIFO_CURSOR_COUNT);
vmw_mmio_write(++count, fifo_mem + SVGA_FIFO_CURSOR_COUNT);
+   spin_unlock(&dev_priv->cursor_lock);
 }
 
 
-/*
- * vmw_du_crtc_cursor_set2 - Driver cursor_set2 callback.
- */
-int vmw_du_crtc_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
-   uint32_t handle, uint32_t width, uint32_t height,
-   int32_t hot_x, int32_t hot_y)
-{
-   struct vmw_private *dev_priv = vmw_priv(crtc->dev);
-

[PATCH 04/11] drm/vmwgfx: Connector atomic state

2017-03-27 Thread Sinclair Yeh
Add connector handling functions. Start tracking is_implicity in
the connector state.  Eventually, this field should be tracked
exclusively in a connector state.

Now that plane and connector states have been created, we can also
activate the code that use CRTC state.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  | 139 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h  |  32 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c  |  13 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c |  13 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c |  14 +++-
 5 files changed, 204 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index d2171d9..a8e0909 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -567,6 +567,81 @@ vmw_du_plane_destroy_state(struct drm_plane *plane,
 }
 
 
+/**
+ * vmw_du_connector_duplicate_state - duplicate connector state
+ * @connector: DRM connector
+ *
+ * Allocates and returns a copy of the connector state (both common and
+ * vmw-specific) for the specified connector.
+ *
+ * Returns: The newly allocated connector state, or NULL on failure.
+ */
+struct drm_connector_state *
+vmw_du_connector_duplicate_state(struct drm_connector *connector)
+{
+   struct drm_connector_state *state;
+   struct vmw_connector_state *vcs;
+
+   if (WARN_ON(!connector->state))
+   return NULL;
+
+   vcs = kmemdup(connector->state, sizeof(*vcs), GFP_KERNEL);
+
+   if (!vcs)
+   return NULL;
+
+   state = &vcs->base;
+
+   __drm_atomic_helper_connector_duplicate_state(connector, state);
+
+   return state;
+}
+
+
+/**
+ * vmw_du_connector_reset - creates a blank vmw connector state
+ * @connector: DRM connector
+ *
+ * Resets the atomic state for @connector by freeing the state pointer (which
+ * might be NULL, e.g. at driver load time) and allocating a new empty state
+ * object.
+ */
+void vmw_du_connector_reset(struct drm_connector *connector)
+{
+   struct vmw_connector_state *vcs;
+
+
+   if (connector->state) {
+   __drm_atomic_helper_connector_destroy_state(connector->state);
+
+   kfree(vmw_connector_state_to_vcs(connector->state));
+   }
+
+   vcs = kzalloc(sizeof(*vcs), GFP_KERNEL);
+
+   if (!vcs) {
+   DRM_ERROR("Cannot allocate vmw_connector_state\n");
+   return;
+   }
+
+   __drm_atomic_helper_connector_reset(connector, &vcs->base);
+}
+
+
+/**
+ * vmw_du_connector_destroy_state - destroy connector state
+ * @connector: DRM connector
+ * @state: state object to destroy
+ *
+ * Destroys the connector state (both common and vmw-specific) for the
+ * specified plane.
+ */
+void
+vmw_du_connector_destroy_state(struct drm_connector *connector,
+ struct drm_connector_state *state)
+{
+   drm_atomic_helper_connector_destroy_state(connector, state);
+}
 /*
  * Generic framebuffer code
  */
@@ -1780,6 +1855,70 @@ int vmw_du_connector_set_property(struct drm_connector 
*connector,
 
 
 
+/**
+ * vmw_du_connector_atomic_set_property - Atomic version of get property
+ *
+ * @crtc - crtc the property is associated with
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
+ */
+int
+vmw_du_connector_atomic_set_property(struct drm_connector *connector,
+struct drm_connector_state *state,
+struct drm_property *property,
+uint64_t val)
+{
+   struct vmw_private *dev_priv = vmw_priv(connector->dev);
+   struct vmw_connector_state *vcs = vmw_connector_state_to_vcs(state);
+   struct vmw_display_unit *du = vmw_connector_to_du(connector);
+
+
+   if (property == dev_priv->implicit_placement_property) {
+   vcs->is_implicit = val;
+
+   /*
+* We should really be doing a drm_atomic_commit() to
+* commit the new state, but since this doesn't cause
+* an immedate state change, this is probably ok
+*/
+   du->is_implicit = vcs->is_implicit;
+   } else {
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+
+/**
+ * vmw_du_connector_atomic_get_property - Atomic version of get property
+ *
+ * @connector - connector the property is associated with
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
+ */
+int
+vmw_du_connector_atomic_get_property(struct drm_connector *connector,
+const struct drm_connector_state *state,
+struct drm_property *property,
+uint64_t *val)
+{
+   struct vmw_private *dev_priv = vmw_priv(connector->dev);
+   struct vmw_connecto

[PATCH 03/11] drm/vmwgfx: Plane atomic state

2017-03-27 Thread Sinclair Yeh
Add plane state handling functions.

We have to keep track of a few plane states so we cannot use the
DRM helper for this.

Created vmw_plane_state along with functions to reset, duplicate,
and destroty it.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  | 99 
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h  | 24 +
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c  | 13 +
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 13 +
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 10 
 5 files changed, 159 insertions(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 18bd8dc..d2171d9 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -35,6 +35,15 @@
 
 void vmw_du_cleanup(struct vmw_display_unit *du)
 {
+   if (du->cursor.state && du->cursor.state->fb) {
+   /*
+* On a layout change, the user mode doesn't call
+* drm_mode_cursor_ioctl() to release the cursor, so
+* we need to manualy release a reference of it.
+*/
+   drm_framebuffer_unreference(du->cursor.state->fb);
+   }
+
drm_plane_cleanup(&du->primary);
drm_plane_cleanup(&du->cursor);
 
@@ -468,6 +477,96 @@ vmw_du_crtc_destroy_state(struct drm_crtc *crtc,
 }
 
 
+/**
+ * vmw_du_plane_duplicate_state - duplicate plane state
+ * @plane: drm plane
+ *
+ * Allocates and returns a copy of the plane state (both common and
+ * vmw-specific) for the specified plane.
+ *
+ * Returns: The newly allocated plane state, or NULL on failure.
+ */
+struct drm_plane_state *
+vmw_du_plane_duplicate_state(struct drm_plane *plane)
+{
+   struct drm_plane_state *state;
+   struct vmw_plane_state *vps;
+
+   vps = kmemdup(plane->state, sizeof(*vps), GFP_KERNEL);
+
+   if (!vps)
+   return NULL;
+
+   vps->pinned = 0;
+
+   /* Each ref counted resource needs to be acquired again */
+   if (vps->surf)
+   (void) vmw_surface_reference(vps->surf);
+
+   if (vps->dmabuf)
+   (void) vmw_dmabuf_reference(vps->dmabuf);
+
+   state = &vps->base;
+
+   __drm_atomic_helper_plane_duplicate_state(plane, state);
+
+   return state;
+}
+
+
+/**
+ * vmw_du_plane_reset - creates a blank vmw plane state
+ * @plane: drm plane
+ *
+ * Resets the atomic state for @plane by freeing the state pointer (which might
+ * be NULL, e.g. at driver load time) and allocating a new empty state object.
+ */
+void vmw_du_plane_reset(struct drm_plane *plane)
+{
+   struct vmw_plane_state *vps;
+
+
+   if (plane->state)
+   vmw_du_plane_destroy_state(plane, plane->state);
+
+   vps = kzalloc(sizeof(*vps), GFP_KERNEL);
+
+   if (!vps) {
+   DRM_ERROR("Cannot allocate vmw_plane_state\n");
+   return;
+   }
+
+   plane->state = &vps->base;
+   plane->state->plane = plane;
+   plane->state->rotation = DRM_ROTATE_0;
+}
+
+
+/**
+ * vmw_du_plane_destroy_state - destroy plane state
+ * @plane: DRM plane
+ * @state: state object to destroy
+ *
+ * Destroys the plane state (both common and vmw-specific) for the
+ * specified plane.
+ */
+void
+vmw_du_plane_destroy_state(struct drm_plane *plane,
+  struct drm_plane_state *state)
+{
+   struct vmw_plane_state *vps = vmw_plane_state_to_vps(state);
+
+
+   if (vps->surf)
+   vmw_surface_unreference(&vps->surf);
+
+   if (vps->dmabuf)
+   vmw_dmabuf_unreference(&vps->dmabuf);
+
+   drm_atomic_helper_plane_destroy_state(plane, state);
+}
+
+
 /*
  * Generic framebuffer code
  */
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
index 370f75c..5602c24 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
@@ -141,6 +141,7 @@ static const uint32_t vmw_cursor_plane_formats[] = {
 
 
 #define vmw_crtc_state_to_vcs(x) container_of(x, struct vmw_crtc_state, base)
+#define vmw_plane_state_to_vps(x) container_of(x, struct vmw_plane_state, base)
 
 
 /**
@@ -153,6 +154,25 @@ struct vmw_crtc_state {
 };
 
 /**
+ * Derived class for plane state object
+ *
+ * @base DRM plane object
+ * @surf Display surface for STDU
+ * @dmabuf display dmabuf for SOU
+ * @content_fb_type Used by STDU.
+ * @pinned pin count for STDU display surface
+ */
+struct vmw_plane_state {
+   struct drm_plane_state base;
+   struct vmw_surface *surf;
+   struct vmw_dma_buffer *dmabuf;
+
+   int content_fb_type;
+
+   int pinned;
+};
+
+/**
  * Base class display unit.
  *
  * Since the SVGA hw doesn't have a concept of a crtc, encoder or connector
@@ -298,6 +318,10 @@ int vmw_du_cursor_plane_update(struct drm_plane *p

[PATCH 05/11] drm/vmwgfx: Add and connect CRTC helper functions

2017-03-27 Thread Sinclair Yeh
Atomic mode set requires us to refactor existing vmw_stdu_crtc_set_config
code into sections that check the validity of the new mode, and sections
that actually program the hardware state.

vmw_du_crtc_atomic_check() takes CRTC-related checking code.  In a later
patch, vmw_du_primary_plane_atomic_check() will take framebuffer-related
checking code.

These helpers won't be called until we flip on the atomic support
flag or set drm_crtc_funcs->set_config to using the atomic
helper.

v2:
* The state->num_connector is actually the total number of potential
  connectors, not just the one associated with the display unit.
  The proper one to check is ->connector_mask.

* Add the check to only allow plane state to be the same as crtc state
  (Thanks to mlankhorst)

* Make sure to turn on SVGA mode before using VRAM.  SVGA mode is
  disabled in master_drop if dbdev is not running.

Signed-off-by: Sinclair Yeh 
Signed-off-by: Thomas Hellstrom 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  |  48 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h  |   9 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c  |  79 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 119 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 117 ++
 5 files changed, 372 insertions(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index a8e0909..6f0f160 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -399,6 +399,54 @@ void vmw_du_primary_plane_destroy(struct drm_plane *plane)
 }
 
 
+int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
+struct drm_crtc_state *new_state)
+{
+   struct vmw_display_unit *du = vmw_crtc_to_du(new_state->crtc);
+   int connector_mask = 1 << drm_connector_index(&du->connector);
+   bool has_primary = new_state->plane_mask &
+  BIT(drm_plane_index(crtc->primary));
+
+   /* We always want to have an active plane with an active CRTC */
+   if (has_primary != new_state->enable)
+   return -EINVAL;
+
+
+   if (new_state->connector_mask != connector_mask &&
+   new_state->connector_mask != 0) {
+   DRM_ERROR("Invalid connectors configuration\n");
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+
+void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
+ struct drm_crtc_state *old_crtc_state)
+{
+}
+
+
+void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
+ struct drm_crtc_state *old_crtc_state)
+{
+   struct drm_pending_vblank_event *event = crtc->state->event;
+
+   if (event) {
+   crtc->state->event = NULL;
+
+   spin_lock_irq(&crtc->dev->event_lock);
+   if (drm_crtc_vblank_get(crtc) == 0)
+   drm_crtc_arm_vblank_event(crtc, event);
+   else
+   drm_crtc_send_vblank_event(crtc, event);
+   spin_unlock_irq(&crtc->dev->event_lock);
+   }
+
+}
+
+
 /**
  * vmw_du_crtc_duplicate_state - duplicate crtc state
  * @crtc: DRM crtc
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
index cc50bf3..f711b5d 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
@@ -161,6 +161,7 @@ struct vmw_crtc_state {
  * @surf Display surface for STDU
  * @dmabuf display dmabuf for SOU
  * @content_fb_type Used by STDU.
+ * @dmabuf_size Size of the dmabuf, used by Screen Object Display Unit
  * @pinned pin count for STDU display surface
  */
 struct vmw_plane_state {
@@ -169,6 +170,7 @@ struct vmw_plane_state {
struct vmw_dma_buffer *dmabuf;
 
int content_fb_type;
+   unsigned long dmabuf_size;
 
int pinned;
 };
@@ -342,10 +344,17 @@ int vmw_du_cursor_plane_update(struct drm_plane *plane,
   uint32_t src_x, uint32_t src_y,
   uint32_t src_w, uint32_t src_h);
 
+/* Atomic Helpers */
 void vmw_du_plane_reset(struct drm_plane *plane);
 struct drm_plane_state *vmw_du_plane_duplicate_state(struct drm_plane *plane);
 void vmw_du_plane_destroy_state(struct drm_plane *plane,
struct drm_plane_state *state);
+int vmw_du_crtc_atomic_check(struct drm_crtc *crtc,
+struct drm_crtc_state *state);
+void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
+ struct drm_crtc_state *old_crtc_state);
+void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
+ struct drm_crtc_state *old_crtc_state);
 void vmw_du_crtc_reset(struct drm_crtc *crtc);
 struct drm_crtc_state *vmw_du_crtc_duplicate_state(struct drm_crtc *crtc);
 void vmw_du_crtc_destroy_stat

[PATCH 06/11] drm/vmwgfx: Add and connect plane helper functions

2017-03-27 Thread Sinclair Yeh
Refactor previous FB and cursor plane update code into their
atomic counterparts: check, update, prepare, cleanup, and disable.

These helpers won't be called until we flip on the atomic support
flag or set drm_crtc_funcs->set_config to using the atomic
helper.

v2:
* Removed unnecessary pinning of cursor surface
* Added a few function headers

v3:
* Set clip region equal to the destination region
* Fixed surface pinning policy
* Enable SVGA mode in vmw_sou_primary_plane_prepare_fb

Signed-off-by: Sinclair Yeh 
Signed-off-by: Thomas Hellstrom 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  | 256 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h  |  15 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c  |  66 -
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 115 
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 244 +
 5 files changed, 695 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 6f0f160..d00ff21 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -26,8 +26,10 @@
  **/
 
 #include "vmwgfx_kms.h"
+#include 
 #include 
 #include 
+#include 
 
 
 /* Might need a hrtimer here? */
@@ -399,6 +401,260 @@ void vmw_du_primary_plane_destroy(struct drm_plane *plane)
 }
 
 
+/**
+ * vmw_du_vps_unpin_surf - unpins resource associated with a framebuffer 
surface
+ *
+ * @vps: plane state associated with the display surface
+ * @unreference: true if we also want to unreference the display.
+ */
+void vmw_du_plane_unpin_surf(struct vmw_plane_state *vps,
+bool unreference)
+{
+   if (vps->surf) {
+   if (vps->pinned) {
+   vmw_resource_unpin(&vps->surf->res);
+   vps->pinned--;
+   }
+
+   if (unreference) {
+   if (vps->pinned)
+   DRM_ERROR("Surface still pinned\n");
+   vmw_surface_unreference(&vps->surf);
+   }
+   }
+}
+
+
+/**
+ * vmw_du_plane_cleanup_fb - Unpins the cursor
+ *
+ * @plane:  display plane
+ * @old_state: Contains the FB to clean up
+ *
+ * Unpins the framebuffer surface
+ *
+ * Returns 0 on success
+ */
+void
+vmw_du_plane_cleanup_fb(struct drm_plane *plane,
+   struct drm_plane_state *old_state)
+{
+   struct vmw_plane_state *vps = vmw_plane_state_to_vps(old_state);
+
+   vmw_du_plane_unpin_surf(vps, false);
+}
+
+
+/**
+ * vmw_du_cursor_plane_prepare_fb - Readies the cursor by referencing it
+ *
+ * @plane:  display plane
+ * @new_state: info on the new plane state, including the FB
+ *
+ * Returns 0 on success
+ */
+int
+vmw_du_cursor_plane_prepare_fb(struct drm_plane *plane,
+  struct drm_plane_state *new_state)
+{
+   struct drm_framebuffer *fb = new_state->fb;
+   struct vmw_plane_state *vps = vmw_plane_state_to_vps(new_state);
+
+
+   if (vps->surf)
+   vmw_surface_unreference(&vps->surf);
+
+   if (vps->dmabuf)
+   vmw_dmabuf_unreference(&vps->dmabuf);
+
+   if (fb) {
+   if (vmw_framebuffer_to_vfb(fb)->dmabuf) {
+   vps->dmabuf = vmw_framebuffer_to_vfbd(fb)->buffer;
+   vmw_dmabuf_reference(vps->dmabuf);
+   } else {
+   vps->surf = vmw_framebuffer_to_vfbs(fb)->surface;
+   vmw_surface_reference(vps->surf);
+   }
+   }
+
+   return 0;
+}
+
+
+void
+vmw_du_cursor_plane_atomic_disable(struct drm_plane *plane,
+  struct drm_plane_state *old_state)
+{
+   struct drm_crtc *crtc = plane->state->crtc ?: old_state->crtc;
+   struct vmw_private *dev_priv = vmw_priv(crtc->dev);
+
+   drm_atomic_set_fb_for_plane(plane->state, NULL);
+   vmw_cursor_update_position(dev_priv, false, 0, 0);
+}
+
+
+void
+vmw_du_cursor_plane_atomic_update(struct drm_plane *plane,
+ struct drm_plane_state *old_state)
+{
+   struct drm_crtc *crtc = plane->state->crtc ?: old_state->crtc;
+   struct vmw_private *dev_priv = vmw_priv(crtc->dev);
+   struct vmw_display_unit *du = vmw_crtc_to_du(crtc);
+   struct vmw_plane_state *vps = vmw_plane_state_to_vps(plane->state);
+   s32 hotspot_x, hotspot_y;
+   int ret = 0;
+
+
+   hotspot_x = du->hotspot_x;
+   hotspot_y = du->hotspot_y;
+   du->cursor_surface = vps->surf;
+   du->cursor_dmabuf = vps->dmabuf;
+
+   /* setup new image */
+   if (vps->surf) {
+   du->cursor_age = du->

[PATCH 09/11] drm/vmwgfx: Fixes to vmwgfx_fb

2017-03-27 Thread Sinclair Yeh
1.  When unsetting a mode, num_connector should be set to zero
2.  The pixel_format field needs to be initialized as newer DRM internal
functions checks this field
3.  Take the drm_modeset_lock_all() because vmw_fb_kms_detach() can
change current mode

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
index e9005b9..7d3d5e3 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
@@ -434,7 +434,7 @@ static int vmw_fb_kms_detach(struct vmw_fb_par *par,
set.y = 0;
set.mode = NULL;
set.fb = NULL;
-   set.num_connectors = 1;
+   set.num_connectors = 0;
set.connectors = &par->con;
ret = drm_mode_set_config_internal(&set);
if (ret) {
@@ -822,7 +822,9 @@ int vmw_fb_off(struct vmw_private *vmw_priv)
flush_delayed_work(&par->local_work);
 
mutex_lock(&par->bo_mutex);
+   drm_modeset_lock_all(vmw_priv->dev);
(void) vmw_fb_kms_detach(par, true, false);
+   drm_modeset_unlock_all(vmw_priv->dev);
mutex_unlock(&par->bo_mutex);
 
return 0;
-- 
2.7.4

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


[PATCH 08/11] drm/vmwgfx: Add and connect atomic state object check/commit

2017-03-27 Thread Sinclair Yeh
This connects the main state object check and commit function.

Signed-off-by: Sinclair Yeh 
Signed-off-by: Thomas Hellstrom 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 66 +
 1 file changed, 66 insertions(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 2250a34a..6b593aaf 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -1581,8 +1581,74 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct 
drm_device *dev,
return &vfb->base;
 }
 
+
+
+/**
+ * vmw_kms_atomic_check_modeset- validate state object for modeset changes
+ *
+ * @dev: DRM device
+ * @state: the driver state object
+ *
+ * This is a simple wrapper around drm_atomic_helper_check_modeset() for
+ * us to assign a value to mode->crtc_clock so that
+ * drm_calc_timestamping_constants() won't throw an error message
+ *
+ * RETURNS
+ * Zero for success or -errno
+ */
+int
+vmw_kms_atomic_check_modeset(struct drm_device *dev,
+struct drm_atomic_state *state)
+{
+   struct drm_crtc_state *crtc_state;
+   struct drm_crtc *crtc;
+   int i, ret;
+
+
+   for_each_crtc_in_state(state, crtc, crtc_state, i) {
+   if (crtc_state->mode.crtc_clock == 0) {
+   /*
+* Our virtual device does not have a dot clock,
+* so use the logical clock value as the dot clock.
+*/
+   crtc_state->mode.crtc_clock = crtc_state->mode.clock;
+   }
+   }
+
+   ret = drm_atomic_helper_check_modeset(dev, state);
+   if (ret)
+   return ret;
+
+   return drm_atomic_helper_check_planes(dev, state);
+}
+
+
+/**
+ * vmw_kms_atomic_commit - Perform an atomic state commit
+ *
+ * @dev: DRM device
+ * @state: the driver state object
+ * @nonblock: Whether nonblocking behaviour is requested
+ *
+ * This is a simple wrapper around drm_atomic_helper_commit() for
+ * us to clear the nonblocking value.
+ * Nonblocking commits should avoid waiting on GPU completion to return.
+ * That is always the case for us.
+ *
+ * RETURNS
+ * Zero for success or negative error code on failure.
+ */
+int vmw_kms_atomic_commit(struct drm_device *dev,
+ struct drm_atomic_state *state,
+ bool nonblock)
+{
+   return drm_atomic_helper_commit(dev, state, false);
+}
+
 static const struct drm_mode_config_funcs vmw_kms_funcs = {
.fb_create = vmw_kms_fb_create,
+   .atomic_check = vmw_kms_atomic_check_modeset,
+   .atomic_commit = vmw_kms_atomic_commit,
 };
 
 static int vmw_kms_generic_present(struct vmw_private *dev_priv,
-- 
2.7.4

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


[PATCH 07/11] drm/vmwgfx: Add and connect connector helper function

2017-03-27 Thread Sinclair Yeh
Since the link between connector and encoder is always fixed in our case,
just return the one encoder.

These helpers won't be called until we flip on the atomic support
flag or set drm_crtc_funcs->set_config to using the atomic
helper.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  | 18 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h  |  2 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c  |  7 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c |  9 +
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c |  8 
 5 files changed, 44 insertions(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index d00ff21..2250a34a 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -2223,6 +2223,24 @@ vmw_du_connector_atomic_get_property(struct 
drm_connector *connector,
 }
 
 
+/**
+ * vmw_du_connector_best_encoder - there's only one
+ *
+ * @connector - connector the property is associated with
+ *
+ * In our case, there is only one encoder per connector
+ */
+struct drm_encoder *
+vmw_du_connector_best_encoder(struct drm_connector *connector)
+{
+   struct vmw_display_unit *du;
+
+   du = vmw_connector_to_du(connector);
+
+   return &du->encoder;
+}
+
+
 int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
 {
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
index de6a0b6..3251562 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
@@ -267,6 +267,8 @@ vmw_du_connector_atomic_get_property(struct drm_connector 
*connector,
 const struct drm_connector_state *state,
 struct drm_property *property,
 uint64_t *val);
+struct drm_encoder *
+vmw_du_connector_best_encoder(struct drm_connector *connector);
 int vmw_du_connector_dpms(struct drm_connector *connector, int mode);
 void vmw_du_connector_save(struct drm_connector *connector);
 void vmw_du_connector_restore(struct drm_connector *connector);
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
index 1d734de..282a0ef 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
@@ -389,6 +389,11 @@ static const struct drm_connector_funcs 
vmw_legacy_connector_funcs = {
.atomic_get_property = vmw_du_connector_atomic_get_property,
 };
 
+static const struct
+drm_connector_helper_funcs vmw_ldu_connector_helper_funcs = {
+   .best_encoder = vmw_du_connector_best_encoder,
+};
+
 /*
  * Legacy Display Plane Functions
  */
@@ -555,6 +560,8 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, 
unsigned unit)
DRM_ERROR("Failed to initialize connector\n");
goto err_free;
}
+
+   drm_connector_helper_add(connector, &vmw_ldu_connector_helper_funcs);
connector->status = vmw_du_connector_detect(connector, true);
vmw_connector_state_to_vcs(connector->state)->is_implicit = true;
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
index eca055e..e4154f1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
@@ -608,6 +608,14 @@ static const struct drm_connector_funcs 
vmw_sou_connector_funcs = {
.atomic_get_property = vmw_du_connector_atomic_get_property,
 };
 
+
+static const struct
+drm_connector_helper_funcs vmw_sou_connector_helper_funcs = {
+   .best_encoder = vmw_du_connector_best_encoder,
+};
+
+
+
 /*
  * Screen Object Display Plane Functions
  */
@@ -827,6 +835,7 @@ static int vmw_sou_init(struct vmw_private *dev_priv, 
unsigned unit)
goto err_free;
}
 
+   drm_connector_helper_add(connector, &vmw_sou_connector_helper_funcs);
connector->status = vmw_du_connector_detect(connector, true);
vmw_connector_state_to_vcs(connector->state)->is_implicit = false;
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
index cce5e5b..708d063 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
@@ -1189,6 +1189,12 @@ static const struct drm_connector_funcs 
vmw_stdu_connector_funcs = {
 };
 
 
+static const struct
+drm_connector_helper_funcs vmw_stdu_connector_helper_funcs = {
+   .best_encoder = vmw_du_connector_best_encoder,
+};
+
+
 
 /**
  * Screen Target Display Plane Functions
@@ -1549,6 +1555,8 @@ static int vmw_stdu_init(struct vmw_private *dev_priv, 
unsigned unit)
DRM_ERROR("Failed to initialize connector\n");
goto err_free;
}
+
+   drm_connector_helper_a

[PATCH 10/11] drm/vmwgfx: Switch over to internal atomic API for STDU

2017-03-27 Thread Sinclair Yeh
Switch over to using internal atomic API for mode set.

This removes the legacy set_config API, replacing it with
drm_atomic_helper_set_config().  The DRM helper will use various
vmwgfx-specific atomic functions to set a mode.

DRIVER_ATOMIC capability flag is not yet set, so the user mode
will still use the legacy mode set IOCTL.

v2:
* Avoid a clash between page-flip pinning and setcrtc pinning, modify
the page-flip code to use the page-flip helper and the atomic callbacks.
To enable this, we will need to add a wrapper around atomic_commit.

* Add vmw_kms_set_config() to work around vmwgfx xorg driver bug

Signed-off-by: Sinclair Yeh 
Signed-off-by: Thomas Hellstrom 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  |  20 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h  |   1 +
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 325 ---
 3 files changed, 51 insertions(+), 295 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 6b593aaf..7104796 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -2923,3 +2923,23 @@ vmw_kms_create_implicit_placement_property(struct 
vmw_private *dev_priv,
  "implicit_placement", 0, 1);
 
 }
+
+
+/**
+ * vmw_kms_set_config - Wrapper around drm_atomic_helper_set_config
+ *
+ * @set: The configuration to set.
+ *
+ * The vmwgfx Xorg driver doesn't assign the mode::type member, which
+ * when drm_mode_set_crtcinfo is called as part of the configuration setting
+ * causes it to return incorrect crtc dimensions causing severe problems in
+ * the vmwgfx modesetting. So explicitly clear that member before calling
+ * into drm_atomic_helper_set_config.
+ */
+int vmw_kms_set_config(struct drm_mode_set *set)
+{
+   if (set && set->mode)
+   set->mode->type = 0;
+
+   return drm_atomic_helper_set_config(set);
+}
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
index 3251562..0016f07 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
@@ -451,5 +451,6 @@ int vmw_kms_stdu_dma(struct vmw_private *dev_priv,
 bool to_surface,
 bool interruptible);
 
+int vmw_kms_set_config(struct drm_mode_set *set);
 
 #endif
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
index 708d063..ff00817 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
@@ -104,8 +104,7 @@ struct vmw_stdu_surface_copy {
  */
 struct vmw_screen_target_display_unit {
struct vmw_display_unit base;
-
-   struct vmw_surface *display_srf;
+   const struct vmw_surface *display_srf;
enum stdu_content_type content_fb_type;
 
bool defined;
@@ -118,32 +117,6 @@ static void vmw_stdu_destroy(struct 
vmw_screen_target_display_unit *stdu);
 
 
 /**
- * Screen Target Display Unit helper Functions
- */
-
-/**
- * vmw_stdu_unpin_display - unpins the resource associated with display surface
- *
- * @stdu: contains the display surface
- *
- * If the display surface was privatedly allocated by
- * vmw_surface_gb_priv_define() and not registered as a framebuffer, then it
- * won't be automatically cleaned up when all the framebuffers are freed.  As
- * such, we have to explicitly call vmw_resource_unreference() to get it freed.
- */
-static void vmw_stdu_unpin_display(struct vmw_screen_target_display_unit *stdu)
-{
-   if (stdu->display_srf) {
-   struct vmw_resource *res = &stdu->display_srf->res;
-
-   vmw_resource_unpin(res);
-   vmw_surface_unreference(&stdu->display_srf);
-   }
-}
-
-
-
-/**
  * Screen Target Display Unit CRTC Functions
  */
 
@@ -228,7 +201,7 @@ static int vmw_stdu_define_st(struct vmw_private *dev_priv,
  */
 static int vmw_stdu_bind_st(struct vmw_private *dev_priv,
struct vmw_screen_target_display_unit *stdu,
-   struct vmw_resource *res)
+   const struct vmw_resource *res)
 {
SVGA3dSurfaceImageId image;
 
@@ -377,129 +350,6 @@ static int vmw_stdu_destroy_st(struct vmw_private 
*dev_priv,
return ret;
 }
 
-/**
- * vmw_stdu_bind_fb - Bind an fb to a defined screen target
- *
- * @dev_priv: Pointer to a device private struct.
- * @crtc: The crtc holding the screen target.
- * @mode: The mode currently used by the screen target. Must be non-NULL.
- * @new_fb: The new framebuffer to bind. Must be non-NULL.

[PATCH 11/11] drm/vmwgfx: Switch over to internal atomic API for SOU and LDU

2017-03-27 Thread Sinclair Yeh
Switch over to internal atomic API.  This completes the atomic
internal atomic switch for all the Display Units.

Signed-off-by: Sinclair Yeh 
Signed-off-by: Thomas Hellstrom 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c  | 103 ++---
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 217 +++
 2 files changed, 25 insertions(+), 295 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
index 282a0ef..4954f26 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
@@ -95,7 +95,7 @@ static int vmw_ldu_commit_list(struct vmw_private *dev_priv)
 
if (crtc == NULL)
return 0;
-   fb = entry->base.crtc.primary->fb;
+   fb = entry->base.crtc.primary->state->fb;
 
return vmw_kms_write_svga(dev_priv, w, h, fb->pitches[0],
  fb->format->cpp[0] * 8,
@@ -104,7 +104,7 @@ static int vmw_ldu_commit_list(struct vmw_private *dev_priv)
 
if (!list_empty(&lds->active)) {
entry = list_entry(lds->active.next, typeof(*entry), active);
-   fb = entry->base.crtc.primary->fb;
+   fb = entry->base.crtc.primary->state->fb;
 
vmw_kms_write_svga(dev_priv, fb->width, fb->height, 
fb->pitches[0],
   fb->format->cpp[0] * 8, fb->format->depth);
@@ -255,102 +255,13 @@ static void vmw_ldu_crtc_helper_disable(struct drm_crtc 
*crtc)
 {
 }
 
-static int vmw_ldu_crtc_set_config(struct drm_mode_set *set)
-{
-   struct vmw_private *dev_priv;
-   struct vmw_legacy_display_unit *ldu;
-   struct drm_connector *connector;
-   struct drm_display_mode *mode;
-   struct drm_encoder *encoder;
-   struct vmw_framebuffer *vfb;
-   struct drm_framebuffer *fb;
-   struct drm_crtc *crtc;
-
-   if (!set)
-   return -EINVAL;
-
-   if (!set->crtc)
-   return -EINVAL;
-
-   /* get the ldu */
-   crtc = set->crtc;
-   ldu = vmw_crtc_to_ldu(crtc);
-   vfb = set->fb ? vmw_framebuffer_to_vfb(set->fb) : NULL;
-   dev_priv = vmw_priv(crtc->dev);
-
-   if (set->num_connectors > 1) {
-   DRM_ERROR("to many connectors\n");
-   return -EINVAL;
-   }
-
-   if (set->num_connectors == 1 &&
-   set->connectors[0] != &ldu->base.connector) {
-   DRM_ERROR("connector doesn't match %p %p\n",
-   set->connectors[0], &ldu->base.connector);
-   return -EINVAL;
-   }
-
-   /* ldu only supports one fb active at the time */
-   if (dev_priv->ldu_priv->fb && vfb &&
-   !(dev_priv->ldu_priv->num_active == 1 &&
- !list_empty(&ldu->active)) &&
-   dev_priv->ldu_priv->fb != vfb) {
-   DRM_ERROR("Multiple framebuffers not supported\n");
-   return -EINVAL;
-   }
-
-   /* since they always map one to one these are safe */
-   connector = &ldu->base.connector;
-   encoder = &ldu->base.encoder;
-
-   /* should we turn the crtc off? */
-   if (set->num_connectors == 0 || !set->mode || !set->fb) {
-
-   connector->encoder = NULL;
-   encoder->crtc = NULL;
-   crtc->primary->fb = NULL;
-   crtc->enabled = false;
-
-   vmw_ldu_del_active(dev_priv, ldu);
-
-   return vmw_ldu_commit_list(dev_priv);
-   }
-
-
-   /* we now know we want to set a mode */
-   mode = set->mode;
-   fb = set->fb;
-
-   if (set->x + mode->hdisplay > fb->width ||
-   set->y + mode->vdisplay > fb->height) {
-   DRM_ERROR("set outside of framebuffer\n");
-   return -EINVAL;
-   }
-
-   vmw_svga_enable(dev_priv);
-
-   crtc->primary->fb = fb;
-   encoder->crtc = crtc;
-   connector->encoder = encoder;
-   crtc->x = set->x;
-   crtc->y = set->y;
-   crtc->mode = *mode;
-   crtc->enabled = true;
-   ldu->base.set_gui_x = set->x;
-   ldu->base.set_gui_y = set->y;
-
-   vmw_ldu_add_active(dev_priv, ldu, vfb);
-
-   return vmw_ldu_commit_list(dev_priv);
-}
-
 static const struct drm_crtc_funcs vmw_legacy_crtc_funcs = {
.gamma_set = vmw_du_crtc_gamma_set,
.destroy = vmw_ldu_crtc_destroy,
.reset = vmw_du_crtc_reset,
.atomic_duplicate_state = vmw_du_crtc_duplicate_state,
.atomic_destroy_state = vmw_du_crtc_destroy_state,
-   .set_config = vmw_ldu_crtc_set_config,
+   .set_config 

[PATCH 1/9] drm/vmwgfx: Explicityly track screen target width and height

2017-03-27 Thread Sinclair Yeh
We can no longer make the assumption that vmw_stdu_update_st() will
be called when there's a valid display surface attached.  So
instead of using display_srf for width and height, make a record of
these paremeters when the screen target is first defined.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
index ff00817..9e40138 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
@@ -106,6 +106,7 @@ struct vmw_screen_target_display_unit {
struct vmw_display_unit base;
const struct vmw_surface *display_srf;
enum stdu_content_type content_fb_type;
+   s32 display_width, display_height;
 
bool defined;
 };
@@ -184,6 +185,8 @@ static int vmw_stdu_define_st(struct vmw_private *dev_priv,
vmw_fifo_commit(dev_priv, sizeof(*cmd));
 
stdu->defined = true;
+   stdu->display_width  = mode->hdisplay;
+   stdu->display_height = mode->vdisplay;
 
return 0;
 }
@@ -281,7 +284,6 @@ static int vmw_stdu_update_st(struct vmw_private *dev_priv,
  struct vmw_screen_target_display_unit *stdu)
 {
struct vmw_stdu_update *cmd;
-   struct drm_crtc *crtc = &stdu->base.crtc;
 
if (!stdu->defined) {
DRM_ERROR("No screen target defined");
@@ -295,8 +297,9 @@ static int vmw_stdu_update_st(struct vmw_private *dev_priv,
return -ENOMEM;
}
 
-   vmw_stdu_populate_update(cmd, stdu->base.unit, 0, crtc->mode.hdisplay,
-0, crtc->mode.vdisplay);
+   vmw_stdu_populate_update(cmd, stdu->base.unit,
+0, stdu->display_width,
+0, stdu->display_height);
 
vmw_fifo_commit(dev_priv, sizeof(*cmd));
 
@@ -346,6 +349,8 @@ static int vmw_stdu_destroy_st(struct vmw_private *dev_priv,
DRM_ERROR("Failed to sync with HW");
 
stdu->defined = false;
+   stdu->display_width  = 0;
+   stdu->display_height = 0;
 
return ret;
 }
-- 
2.7.4

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


[0/9] Collection of patches queued up for vmwgfx-next

2017-03-27 Thread Sinclair Yeh
These are a collection of patches currently queued for vmwgfx-next

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


[PATCH 2/9] drm/vmwgfx: Skipping fbdev fb pinning for ldu

2017-03-27 Thread Sinclair Yeh
Pinning fbdev's FB at the start of VRAM prevents X from pinning
its FB.  Since for ldu, the fb would be pinned anyway during a
mode set, just skip pinning it in fbdev.

This is not the best solution, but since ldu is not used much
anymore, it seems like a reasonable workaround.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 23 ---
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
index 7d3d5e3..09e120d 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
@@ -451,13 +451,15 @@ static int vmw_fb_kms_detach(struct vmw_fb_par *par,
}
 
if (par->vmw_bo && detach_bo) {
+   struct vmw_private *vmw_priv = par->vmw_priv;
+
if (par->bo_ptr) {
ttm_bo_kunmap(&par->map);
par->bo_ptr = NULL;
}
if (unref_bo)
vmw_dmabuf_unreference(&par->vmw_bo);
-   else
+   else if (vmw_priv->active_display_unit != vmw_du_legacy)
vmw_dmabuf_unpin(par->vmw_priv, par->vmw_bo, false);
}
 
@@ -585,18 +587,25 @@ static int vmw_fb_set_par(struct fb_info *info)
 
/*
 * Pin before mapping. Since we don't know in what placement
-* to pin, call into KMS to do it for us.
+* to pin, call into KMS to do it for us.  LDU doesn't require
+* additional pinning because set_config() would've pinned
+* it already
 */
-   ret = vfb->pin(vfb);
-   if (ret) {
-   DRM_ERROR("Could not pin the fbdev framebuffer.\n");
-   goto out_unlock;
+   if (vmw_priv->active_display_unit != vmw_du_legacy) {
+   ret = vfb->pin(vfb);
+   if (ret) {
+   DRM_ERROR("Could not pin the fbdev "
+ "framebuffer.\n");
+   goto out_unlock;
+   }
}
 
ret = ttm_bo_kmap(&par->vmw_bo->base, 0,
  par->vmw_bo->base.num_pages, &par->map);
if (ret) {
-   vfb->unpin(vfb);
+   if (vmw_priv->active_display_unit != vmw_du_legacy)
+   vfb->unpin(vfb);
+
DRM_ERROR("Could not map the fbdev framebuffer.\n");
goto out_unlock;
}
-- 
2.7.4

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


[PATCH 3/9] drm/vmwgfx: Fix LDU X blank screen until mode change issue

2017-03-27 Thread Sinclair Yeh
vmw_ldu_crtc_helper_commit() is not called if
drm_atomic_crtc_needs_modeset() decides nothing related to CRTC timing has
changed.

So a better place for this code is in vmw_ldu_primary_plane_atomic_update()
since we will need to update ld->fb every time the FB is updated.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | 41 +++--
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
index 4954f26..fddb0a3 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
@@ -226,24 +226,6 @@ static void vmw_ldu_crtc_helper_prepare(struct drm_crtc 
*crtc)
  */
 static void vmw_ldu_crtc_helper_commit(struct drm_crtc *crtc)
 {
-   struct vmw_private *dev_priv;
-   struct vmw_legacy_display_unit *ldu;
-   struct vmw_framebuffer *vfb;
-   struct drm_framebuffer *fb;
-
-
-   ldu = vmw_crtc_to_ldu(crtc);
-   dev_priv = vmw_priv(crtc->dev);
-   fb   = crtc->primary->state->fb;
-
-   vfb = (fb) ? vmw_framebuffer_to_vfb(fb) : NULL;
-
-   if (vfb)
-   vmw_ldu_add_active(dev_priv, ldu, vfb);
-   else
-   vmw_ldu_del_active(dev_priv, ldu);
-
-   vmw_ldu_commit_list(dev_priv);
 }
 
 /**
@@ -310,7 +292,7 @@ drm_connector_helper_funcs vmw_ldu_connector_helper_funcs = 
{
  */
 
 /**
- * vmw_ldu_primary_plane_cleanup_fb - Unpin fb
+ * vmw_ldu_primary_plane_cleanup_fb - Noop
  *
  * @plane:  display plane
  * @old_state: Contains the FB to clean up
@@ -327,7 +309,7 @@ vmw_ldu_primary_plane_cleanup_fb(struct drm_plane *plane,
 
 
 /**
- * vmw_ldu_primary_plane_prepare_fb -
+ * vmw_ldu_primary_plane_prepare_fb - Noop
  *
  * @plane:  display plane
  * @new_state: info on the new plane state, including the FB
@@ -346,6 +328,25 @@ static void
 vmw_ldu_primary_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
 {
+   struct vmw_private *dev_priv;
+   struct vmw_legacy_display_unit *ldu;
+   struct vmw_framebuffer *vfb;
+   struct drm_framebuffer *fb;
+   struct drm_crtc *crtc = plane->state->crtc ?: old_state->crtc;
+
+
+   ldu = vmw_crtc_to_ldu(crtc);
+   dev_priv = vmw_priv(plane->dev);
+   fb   = plane->state->fb;
+
+   vfb = (fb) ? vmw_framebuffer_to_vfb(fb) : NULL;
+
+   if (vfb)
+   vmw_ldu_add_active(dev_priv, ldu, vfb);
+   else
+   vmw_ldu_del_active(dev_priv, ldu);
+
+   vmw_ldu_commit_list(dev_priv);
 }
 
 
-- 
2.7.4

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


[PATCH 5/9] drm/vmwgfx: Introduce a simple resource type

2017-03-27 Thread Sinclair Yeh
From: Thomas Hellstrom 

The callbacks we need to provide to many resources are very similar, so
provide a simple resource type with a number of helpers for these
callbacks.

Signed-off-by: Thomas Hellstrom 
Reviewed-by: Sinclair Yeh 
---
 drivers/gpu/drm/vmwgfx/Makefile |   3 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h   |  40 
 drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c | 256 
 3 files changed, 298 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c

diff --git a/drivers/gpu/drm/vmwgfx/Makefile b/drivers/gpu/drm/vmwgfx/Makefile
index 473d004..2258908 100644
--- a/drivers/gpu/drm/vmwgfx/Makefile
+++ b/drivers/gpu/drm/vmwgfx/Makefile
@@ -8,6 +8,7 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o 
vmwgfx_drv.o \
vmwgfx_fence.o vmwgfx_dmabuf.o vmwgfx_scrn.o vmwgfx_context.o \
vmwgfx_surface.o vmwgfx_prime.o vmwgfx_mob.o vmwgfx_shader.o \
vmwgfx_cmdbuf_res.o vmwgfx_cmdbuf.o vmwgfx_stdu.o \
-   vmwgfx_cotable.o vmwgfx_so.o vmwgfx_binding.o vmwgfx_msg.o
+   vmwgfx_cotable.o vmwgfx_so.o vmwgfx_binding.o vmwgfx_msg.o \
+   vmwgfx_simple_resource.o
 
 obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h
index 5994ef6..ac05968 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource_priv.h
@@ -30,6 +30,8 @@
 
 #include "vmwgfx_drv.h"
 
+#define VMW_IDA_ACC_SIZE 128
+
 enum vmw_cmdbuf_res_state {
VMW_CMDBUF_RES_COMMITTED,
VMW_CMDBUF_RES_ADD,
@@ -83,6 +85,35 @@ struct vmw_res_func {
  enum vmw_cmdbuf_res_state state);
 };
 
+/**
+ * struct vmw_simple_resource_func - members and functions common for the
+ * simple resource helpers.
+ * @res_func:  struct vmw_res_func as described above.
+ * @ttm_res_type:  TTM resource type used for handle recognition.
+ * @size:  Size of the simple resource information struct.
+ * @init:  Initialize the simple resource information.
+ * @hw_destroy:  A resource hw_destroy function.
+ * @set_arg_handle:  Set the handle output argument of the ioctl create struct.
+ */
+struct vmw_simple_resource_func {
+   const struct vmw_res_func res_func;
+   int ttm_res_type;
+   size_t size;
+   int (*init)(struct vmw_resource *res, void *data);
+   void (*hw_destroy)(struct vmw_resource *res);
+   void (*set_arg_handle)(void *data, u32 handle);
+};
+
+/**
+ * struct vmw_simple_resource - Kernel only side simple resource
+ * @res: The resource we derive from.
+ * @func: The method and member virtual table.
+ */
+struct vmw_simple_resource {
+   struct vmw_resource res;
+   const struct vmw_simple_resource_func *func;
+};
+
 int vmw_resource_alloc_id(struct vmw_resource *res);
 void vmw_resource_release_id(struct vmw_resource *res);
 int vmw_resource_init(struct vmw_private *dev_priv, struct vmw_resource *res,
@@ -91,4 +122,13 @@ int vmw_resource_init(struct vmw_private *dev_priv, struct 
vmw_resource *res,
  const struct vmw_res_func *func);
 void vmw_resource_activate(struct vmw_resource *res,
   void (*hw_destroy) (struct vmw_resource *));
+int
+vmw_simple_resource_create_ioctl(struct drm_device *dev,
+void *data,
+struct drm_file *file_priv,
+const struct vmw_simple_resource_func *func);
+struct vmw_resource *
+vmw_simple_resource_lookup(struct ttm_object_file *tfile,
+  uint32_t handle,
+  const struct vmw_simple_resource_func *func);
 #endif
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c
new file mode 100644
index 000..051d3b3
--- /dev/null
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c
@@ -0,0 +1,256 @@
+/**
+ *
+ * Copyright © 2016 VMware, Inc., Palo Alto, CA., USA
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES O

[PATCH 7/9] drm/vmwgfx: Define an overlaid handle_close ioctl.

2017-03-27 Thread Sinclair Yeh
From: Thomas Hellstrom 

Instead of providing an ioctl for each handle type, provide a single
handle_close ioctl, and reuse the UNREF_DMABUF ioctl.

Signed-off-by: Thomas Hellstrom 
Reviewed-by: Sinclair Yeh 
---
 include/uapi/drm/vmwgfx_drm.h | 24 
 1 file changed, 24 insertions(+)

diff --git a/include/uapi/drm/vmwgfx_drm.h b/include/uapi/drm/vmwgfx_drm.h
index d325a41..d9dfde9 100644
--- a/include/uapi/drm/vmwgfx_drm.h
+++ b/include/uapi/drm/vmwgfx_drm.h
@@ -41,6 +41,7 @@ extern "C" {
 #define DRM_VMW_GET_PARAM0
 #define DRM_VMW_ALLOC_DMABUF 1
 #define DRM_VMW_UNREF_DMABUF 2
+#define DRM_VMW_HANDLE_CLOSE 2
 #define DRM_VMW_CURSOR_BYPASS3
 /* guarded by DRM_VMW_PARAM_NUM_STREAMS != 0*/
 #define DRM_VMW_CONTROL_STREAM   4
@@ -1092,6 +1093,29 @@ union drm_vmw_extended_context_arg {
struct drm_vmw_context_arg rep;
 };
 
+/*/
+/*
+ * DRM_VMW_HANDLE_CLOSE - Close a user-space handle and release its
+ * underlying resource.
+ *
+ * Note that this ioctl is overlaid on the DRM_VMW_UNREF_DMABUF Ioctl.
+ * The ioctl arguments therefore need to be identical in layout.
+ *
+ */
+
+/**
+ * struct drm_vmw_handle_close_arg
+ *
+ * @handle: Handle to close.
+ *
+ * Argument to the DRM_VMW_HANDLE_CLOSE Ioctl.
+ */
+struct drm_vmw_handle_close_arg {
+   __u32 handle;
+   __u32 pad64;
+};
+
+
 #if defined(__cplusplus)
 }
 #endif
-- 
2.7.4

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


[PATCH 6/9] drm/vmwgfx: Re-implement the stream resource as a simple resource.

2017-03-27 Thread Sinclair Yeh
From: Thomas Hellstrom 

Provide and document a reference implementation.

Signed-off-by: Thomas Hellstrom 
Reviewed-by: Sinclair Yeh 
---
 drivers/gpu/drm/vmwgfx/Makefile  |   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 254 ---
 drivers/gpu/drm/vmwgfx/vmwgfx_va.c   | 168 
 3 files changed, 169 insertions(+), 255 deletions(-)
 create mode 100644 drivers/gpu/drm/vmwgfx/vmwgfx_va.c

diff --git a/drivers/gpu/drm/vmwgfx/Makefile b/drivers/gpu/drm/vmwgfx/Makefile
index 2258908..aac17a6 100644
--- a/drivers/gpu/drm/vmwgfx/Makefile
+++ b/drivers/gpu/drm/vmwgfx/Makefile
@@ -9,6 +9,6 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o 
vmwgfx_drv.o \
vmwgfx_surface.o vmwgfx_prime.o vmwgfx_mob.o vmwgfx_shader.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_simple_resource.o vmwgfx_va.o
 
 obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
index 65b3f03..ce652c1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
@@ -45,31 +45,6 @@ struct vmw_bo_user_rep {
uint64_t map_handle;
 };
 
-struct vmw_stream {
-   struct vmw_resource res;
-   uint32_t stream_id;
-};
-
-struct vmw_user_stream {
-   struct ttm_base_object base;
-   struct vmw_stream stream;
-};
-
-
-static uint64_t vmw_user_stream_size;
-
-static const struct vmw_res_func vmw_stream_func = {
-   .res_type = vmw_res_stream,
-   .needs_backup = false,
-   .may_evict = false,
-   .type_name = "video streams",
-   .backup_placement = NULL,
-   .create = NULL,
-   .destroy = NULL,
-   .bind = NULL,
-   .unbind = NULL
-};
-
 static inline struct vmw_dma_buffer *
 vmw_dma_buffer(struct ttm_buffer_object *bo)
 {
@@ -259,24 +234,6 @@ void vmw_resource_activate(struct vmw_resource *res,
write_unlock(&dev_priv->resource_lock);
 }
 
-static struct vmw_resource *vmw_resource_lookup(struct vmw_private *dev_priv,
-   struct idr *idr, int id)
-{
-   struct vmw_resource *res;
-
-   read_lock(&dev_priv->resource_lock);
-   res = idr_find(idr, id);
-   if (!res || !res->avail || !kref_get_unless_zero(&res->kref))
-   res = NULL;
-
-   read_unlock(&dev_priv->resource_lock);
-
-   if (unlikely(res == NULL))
-   return NULL;
-
-   return res;
-}
-
 /**
  * vmw_user_resource_lookup_handle - lookup a struct resource from a
  * TTM user-space handle and perform basic type checks
@@ -776,217 +733,6 @@ int vmw_user_dmabuf_reference(struct ttm_object_file 
*tfile,
  TTM_REF_USAGE, NULL);
 }
 
-/*
- * Stream management
- */
-
-static void vmw_stream_destroy(struct vmw_resource *res)
-{
-   struct vmw_private *dev_priv = res->dev_priv;
-   struct vmw_stream *stream;
-   int ret;
-
-   DRM_INFO("%s: unref\n", __func__);
-   stream = container_of(res, struct vmw_stream, res);
-
-   ret = vmw_overlay_unref(dev_priv, stream->stream_id);
-   WARN_ON(ret != 0);
-}
-
-static int vmw_stream_init(struct vmw_private *dev_priv,
-  struct vmw_stream *stream,
-  void (*res_free) (struct vmw_resource *res))
-{
-   struct vmw_resource *res = &stream->res;
-   int ret;
-
-   ret = vmw_resource_init(dev_priv, res, false, res_free,
-   &vmw_stream_func);
-
-   if (unlikely(ret != 0)) {
-   if (res_free == NULL)
-   kfree(stream);
-   else
-   res_free(&stream->res);
-   return ret;
-   }
-
-   ret = vmw_overlay_claim(dev_priv, &stream->stream_id);
-   if (ret) {
-   vmw_resource_unreference(&res);
-   return ret;
-   }
-
-   DRM_INFO("%s: claimed\n", __func__);
-
-   vmw_resource_activate(&stream->res, vmw_stream_destroy);
-   return 0;
-}
-
-static void vmw_user_stream_free(struct vmw_resource *res)
-{
-   struct vmw_user_stream *stream =
-   container_of(res, struct vmw_user_stream, stream.res);
-   struct vmw_private *dev_priv = res->dev_priv;
-
-   ttm_base_object_kfree(stream, base);
-   ttm_mem_global_free(vmw_mem_glob(dev_priv),
-   vmw_user_stream_size);
-}
-
-/**
- * This function is called when user space has no more references on the
- * base object. It releases the base-object's reference on the resource object.
- */
-
-static void vmw_user_stream_base_release(struct ttm_base_object **p_base)
-{
-   struct ttm_base_object *base 

[PATCH 4/9] drm/vmwgfx: Revert "drm/vmwgfx: Replace numeric parameter like 0444 with macro"

2017-03-27 Thread Sinclair Yeh
From: Øyvind A. Holm 

This reverts commit 2d8e60e8b074 ("drm/vmwgfx: Replace numeric
parameter like 0444 with macro")

The commit belongs to the series of 1285 patches sent to LKML on
2016-08-02, it changes the representation of file permissions from the
octal value "0600" to "S_IRUSR | S_IWUSR".

The general consensus was that the changes does not increase
readability, quite the opposite; 0600 is easier to parse mentally than
S_IRUSR | S_IWUSR.

It also causes argument inconsistency, due to commit 04319d89fbec
("drm/vmwgfx: Add an option to change assumed FB bpp") that added
another call to module_param_named() where the permissions are written
as 0600.

Signed-off-by: Øyvind A. Holm 
Reviewed-by: Sinclair Yeh 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 45d711e..d31dc34 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -241,13 +241,13 @@ static int vmwgfx_pm_notifier(struct notifier_block *nb, 
unsigned long val,
  void *ptr);
 
 MODULE_PARM_DESC(enable_fbdev, "Enable vmwgfx fbdev");
-module_param_named(enable_fbdev, enable_fbdev, int, S_IRUSR | S_IWUSR);
+module_param_named(enable_fbdev, enable_fbdev, int, 0600);
 MODULE_PARM_DESC(force_dma_api, "Force using the DMA API for TTM pages");
-module_param_named(force_dma_api, vmw_force_iommu, int, S_IRUSR | S_IWUSR);
+module_param_named(force_dma_api, vmw_force_iommu, int, 0600);
 MODULE_PARM_DESC(restrict_iommu, "Try to limit IOMMU usage for TTM pages");
-module_param_named(restrict_iommu, vmw_restrict_iommu, int, S_IRUSR | S_IWUSR);
+module_param_named(restrict_iommu, vmw_restrict_iommu, int, 0600);
 MODULE_PARM_DESC(force_coherent, "Force coherent TTM pages");
-module_param_named(force_coherent, vmw_force_coherent, int, S_IRUSR | S_IWUSR);
+module_param_named(force_coherent, vmw_force_coherent, int, 0600);
 MODULE_PARM_DESC(restrict_dma_mask, "Restrict DMA mask to 44 bits with IOMMU");
 module_param_named(restrict_dma_mask, vmw_restrict_dma_mask, int, S_IRUSR | 
S_IWUSR);
 MODULE_PARM_DESC(assume_16bpp, "Assume 16-bpp when filtering modes");
-- 
2.7.4

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


[PATCH 8/9] drm/vmwgfx: Support topology greater than texture size

2017-03-27 Thread Sinclair Yeh
Most of the display servers today use a single surface to represent the
entire desktop even if it's stretched across multiple screens.

For vmwgfx with STDU, the maximum surface size is limited to the
maximum texture size on the host.  On a 2D VM, this limits our
ability to support configurations with more than one 4K monitor.

To get past this limitation, we will now allow using a large DMA buf
as the framebuffer, and take care of blitting contents from this DMA buf
to the display buffer.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  |  64 ++-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.h  |   4 +
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 202 +++
 3 files changed, 269 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 7104796..881ffd4 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -803,6 +803,11 @@ vmw_du_plane_duplicate_state(struct drm_plane *plane)
 
vps->pinned = 0;
 
+   /* Mapping is managed by prepare_fb/cleanup_fb */
+   memset(&vps->guest_map, 0, sizeof(vps->guest_map));
+   memset(&vps->host_map, 0, sizeof(vps->host_map));
+   vps->cpp = 0;
+
/* Each ref counted resource needs to be acquired again */
if (vps->surf)
(void) vmw_surface_reference(vps->surf);
@@ -861,6 +866,17 @@ vmw_du_plane_destroy_state(struct drm_plane *plane,
struct vmw_plane_state *vps = vmw_plane_state_to_vps(state);
 
 
+   /* Should have been freed by cleanup_fb */
+   if (vps->guest_map.virtual) {
+   DRM_ERROR("Guest mapping not freed\n");
+   ttm_bo_kunmap(&vps->guest_map);
+   }
+
+   if (vps->host_map.virtual) {
+   DRM_ERROR("Host mapping not freed\n");
+   ttm_bo_kunmap(&vps->host_map);
+   }
+
if (vps->surf)
vmw_surface_unreference(&vps->surf);
 
@@ -1435,6 +1451,25 @@ static int vmw_kms_new_framebuffer_dmabuf(struct 
vmw_private *dev_priv,
return ret;
 }
 
+
+/**
+ * vmw_kms_srf_ok - check if a surface can be created
+ *
+ * @width: requested width
+ * @height: requested height
+ *
+ * Surfaces need to be less than texture size
+ */
+static bool
+vmw_kms_srf_ok(struct vmw_private *dev_priv, uint32_t width, uint32_t height)
+{
+   if (width  > dev_priv->texture_max_width ||
+   height > dev_priv->texture_max_height)
+   return false;
+
+   return true;
+}
+
 /**
  * vmw_kms_new_framebuffer - Create a new framebuffer.
  *
@@ -1463,7 +1498,8 @@ vmw_kms_new_framebuffer(struct vmw_private *dev_priv,
 * therefore, wrap the DMA buf in a surface so we can use the
 * SurfaceCopy command.
 */
-   if (dmabuf && only_2d &&
+   if (vmw_kms_srf_ok(dev_priv, mode_cmd->width, mode_cmd->height)  &&
+   dmabuf && only_2d &&
dev_priv->active_display_unit == vmw_du_screen_target) {
ret = vmw_create_dmabuf_proxy(dev_priv->dev, mode_cmd,
  dmabuf, &surface);
@@ -1556,6 +1592,16 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct 
drm_device *dev,
if (ret)
goto err_out;
 
+
+   if (!bo &&
+   !vmw_kms_srf_ok(dev_priv, mode_cmd->width, mode_cmd->height)) {
+   DRM_ERROR("Surface size cannot exceed %dx%d",
+   dev_priv->texture_max_width,
+   dev_priv->texture_max_height);
+   goto err_out;
+   }
+
+
vfb = vmw_kms_new_framebuffer(dev_priv, bo, surface,
  !(dev_priv->capabilities & SVGA_CAP_3D),
  mode_cmd);
@@ -1602,10 +1648,13 @@ vmw_kms_atomic_check_modeset(struct drm_device *dev,
 {
struct drm_crtc_state *crtc_state;
struct drm_crtc *crtc;
+   struct vmw_private *dev_priv = vmw_priv(dev);
int i, ret;
 
 
for_each_crtc_in_state(state, crtc, crtc_state, i) {
+   unsigned long requested_bb_mem = 0;
+
if (crtc_state->mode.crtc_clock == 0) {
/*
 * Our virtual device does not have a dot clock,
@@ -1613,6 +1662,19 @@ vmw_kms_atomic_check_modeset(struct drm_device *dev,
 */
crtc_state->mode.crtc_clock = crtc_state->mode.clock;
}
+
+   if (dev_priv->active_display_unit == vmw_du_screen_target) {
+   if (crtc->primary->fb) {
+   int cpp = crtc->primary->fb->pitches[0] /
+ 

[PATCH 9/9] drm/vmwgfx: Properly check display/scanout surface size

2017-03-27 Thread Sinclair Yeh
The scanout surface size is the smaller of max texture size and
max STDU size.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Thomas Hellstrom 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  3 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c| 16 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 14 ++
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 881ffd4..9b0bf2c 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -2218,7 +2218,10 @@ int vmw_du_connector_fill_modes(struct drm_connector 
*connector,
 
if (dev_priv->active_display_unit == vmw_du_screen_target) {
max_width  = min(max_width,  dev_priv->stdu_max_width);
+   max_width  = min(max_width,  dev_priv->texture_max_width);
+
max_height = min(max_height, dev_priv->stdu_max_height);
+   max_height = min(max_height, dev_priv->texture_max_height);
}
 
/* Add preferred mode */
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
index ce1191a..6ae2042 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
@@ -1602,7 +1602,21 @@ int vmw_kms_stdu_init_display(struct vmw_private 
*dev_priv)
 
dev_priv->active_display_unit = vmw_du_screen_target;
 
-   if (!(dev_priv->capabilities & SVGA_CAP_3D)) {
+   if (dev_priv->capabilities & SVGA_CAP_3D) {
+   /*
+* For 3D VMs, display (scanout) buffer size is the smaller of
+* max texture and max STDU
+*/
+   uint32_t max_width, max_height;
+
+   max_width = min(dev_priv->texture_max_width,
+   dev_priv->stdu_max_width);
+   max_height = min(dev_priv->texture_max_height,
+dev_priv->stdu_max_height);
+
+   dev->mode_config.max_width = max_width;
+   dev->mode_config.max_height = max_height;
+   } else {
/*
 * Given various display aspect ratios, there's no way to
 * estimate these using prim_bb_mem.  So just set these to
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
index 6abcf82..41b9d20 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -1479,10 +1479,24 @@ int vmw_surface_gb_priv_define(struct drm_device *dev,
*srf_out = NULL;
 
if (for_scanout) {
+   uint32_t max_width, max_height;
+
if (!svga3dsurface_is_screen_target_format(format)) {
DRM_ERROR("Invalid Screen Target surface format.");
return -EINVAL;
}
+
+   max_width = min(dev_priv->texture_max_width,
+   dev_priv->stdu_max_width);
+   max_height = min(dev_priv->texture_max_height,
+dev_priv->stdu_max_height);
+
+   if (size.width > max_width || size.height > max_height) {
+   DRM_ERROR("%ux%u\n, exeeds max surface size %ux%u",
+ size.width, size.height,
+ max_width, max_height);
+   return -EINVAL;
+   }
} else {
const struct svga3d_surface_desc *desc;
 
-- 
2.7.4

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


Re: [Linux-graphics-maintainer] No mouse cursor since 36cc79bc9077319c04bd3b132edcacaa9a0d9f2b

2017-05-10 Thread Sinclair Yeh
Hi,

On Wed, May 10, 2017 at 12:31:39PM +0200, m...@ox.io wrote:
> 
> > Thomas Hellstrom hat am 10. Mai 2017 um 10:35 geschrieben:
> > 
> > Hi,
> > 
> > Thanks for reporting.
> 
> I would have reported earlier if it had not taken 3 days on the vm to bisect.
> 
> > I think there is a fix for this either in preparation or queued for
> > submission. Sinclair (CC'd) should know more.
> 
> If you point me to a patch I can test it.

please give this patch a try:

https://cgit.freedesktop.org/mesa/vmwgfx/commit/?id=324722b1e1582d45e865dcd2233a17edcfbd1638

If it doesn't work, then please send me the following:
1. dmesg from the guest
2. vmware.log from the host
3. .vmx file for your VM

thanks,

Sinclair

> 
> > Thanks,
> > Thomas
> 
> Mark
> 
> > 
> > On 05/10/2017 09:17 AM, m.t wrote:
> > > Hi,
> > > I don't have a mouse cursor in my virtual machine (vmware workstation 
> > > 12.5.5 
> > > build-5234757) with latest master from 
> > > https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_&d=DwICAg&c=uilaK90D4TOVoH58JNXRgQ&r=j2ey7nuAQ5d6NbMmCOnRsTIJfmv7blo3UCKagbsM9o2-No8JdlhkKK3ty481ErVu&m=DWnNRbcrxMhc78PIvembLdV3OsJi3vPwcdG03kqVpJo&s=mc7-KF2t4BktXs11MShGZBf9bzgxumqhmVQ0ocAIS0k&e=
> > >  
> > > kernel/git/torvalds/linux.git
> > >
> > > git bisect led me to 36cc79bc9077319c04bd3b132edcacaa9a0d9f2b as culprit.
> > >
> > > Regards 
> > > Mark
> > > ___
> > > Sent to linux-graphics-maintai...@vmware.com
> > 
> >
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3] drm: Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ to UAPI

2017-05-18 Thread Sinclair Yeh
vmwgfx part: Reviewed-by: Sinclair Yeh 

On Wed, May 17, 2017 at 09:39:11PM -0400, Robert Foss wrote:
> Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ defines to the UAPI
> as a convenience.
> 
> Ideally the DRM_ROTATE_ and DRM_REFLECT_ property ids are looked up
> through the atomic API, but realizing that userspace is likely to take
> shortcuts and assume that the enum values are what is sent over the
> wire.
> 
> As a result these defines are provided purely as a convenience to
> userspace applications.
> 
> Signed-off-by: Robert Foss 
> ---
> Changes since v2:
>  - Changed define prefix from DRM_MODE_PROP_ to DRM_MODE_
>  - Fix compilation errors
>  - Changed comment formatting
>  - Deduplicated comment lines
>  - Clarified DRM_MODE_PROP_REFLECT_ comment
> 
> Changes since v1:
>  - Moved defines from drm.h to drm_mode.h
>  - Changed define prefix from DRM_ to DRM_MODE_PROP_ 
>  - Updated uses of the defines to the new prefix
>  - Removed include from drm_rect.c
>  - Stopped using the BIT() macro 
> 
>  drivers/gpu/drm/arm/malidp_drv.h|  2 +-
>  drivers/gpu/drm/arm/malidp_planes.c | 18 -
>  drivers/gpu/drm/armada/armada_overlay.c |  2 +-
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c | 20 +-
>  drivers/gpu/drm/drm_atomic.c|  2 +-
>  drivers/gpu/drm/drm_atomic_helper.c |  2 +-
>  drivers/gpu/drm/drm_blend.c | 43 ++---
>  drivers/gpu/drm/drm_fb_helper.c |  4 +-
>  drivers/gpu/drm/drm_plane_helper.c  |  2 +-
>  drivers/gpu/drm/drm_rect.c  | 36 +-
>  drivers/gpu/drm/i915/i915_debugfs.c | 14 +++
>  drivers/gpu/drm/i915/intel_atomic_plane.c   |  6 +--
>  drivers/gpu/drm/i915/intel_display.c| 50 
> -
>  drivers/gpu/drm/i915/intel_fbc.c|  2 +-
>  drivers/gpu/drm/i915/intel_fbdev.c  |  2 +-
>  drivers/gpu/drm/i915/intel_sprite.c | 20 +-
>  drivers/gpu/drm/imx/ipuv3-plane.c   |  2 +-
>  drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c   | 30 +++
>  drivers/gpu/drm/nouveau/nv50_display.c  |  2 +-
>  drivers/gpu/drm/omapdrm/omap_drv.c  |  4 +-
>  drivers/gpu/drm/omapdrm/omap_fb.c   | 18 -
>  drivers/gpu/drm/omapdrm/omap_plane.c| 16 
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  4 +-
>  include/drm/drm_blend.h | 21 +--
>  include/uapi/drm/drm_mode.h | 49 +++-
>  25 files changed, 201 insertions(+), 170 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/malidp_drv.h 
> b/drivers/gpu/drm/arm/malidp_drv.h
> index 040311ffcaec..2e2033140efc 100644
> --- a/drivers/gpu/drm/arm/malidp_drv.h
> +++ b/drivers/gpu/drm/arm/malidp_drv.h
> @@ -65,6 +65,6 @@ void malidp_de_planes_destroy(struct drm_device *drm);
>  int malidp_crtc_init(struct drm_device *drm);
>  
>  /* often used combination of rotational bits */
> -#define MALIDP_ROTATED_MASK  (DRM_ROTATE_90 | DRM_ROTATE_270)
> +#define MALIDP_ROTATED_MASK  (DRM_MODE_ROTATE_90 | DRM_MODE_ROTATE_270)
>  
>  #endif  /* __MALIDP_DRV_H__ */
> diff --git a/drivers/gpu/drm/arm/malidp_planes.c 
> b/drivers/gpu/drm/arm/malidp_planes.c
> index 814fda23cead..063a8d2b0be3 100644
> --- a/drivers/gpu/drm/arm/malidp_planes.c
> +++ b/drivers/gpu/drm/arm/malidp_planes.c
> @@ -80,7 +80,7 @@ static void malidp_plane_reset(struct drm_plane *plane)
>   state = kzalloc(sizeof(*state), GFP_KERNEL);
>   if (state) {
>   state->base.plane = plane;
> - state->base.rotation = DRM_ROTATE_0;
> + state->base.rotation = DRM_MODE_ROTATE_0;
>   plane->state = &state->base;
>   }
>  }
> @@ -221,7 +221,7 @@ static int malidp_de_plane_check(struct drm_plane *plane,
>   return ret;
>  
>   /* packed RGB888 / BGR888 can't be rotated or flipped */
> - if (state->rotation != DRM_ROTATE_0 &&
> + if (state->rotation != DRM_MODE_ROTATE_0 &&
>   (fb->format->format == DRM_FORMAT_RGB888 ||
>fb->format->format == DRM_FORMAT_BGR888))
>   return -EINVAL;
> @@ -315,12 +315,12 @@ static void malidp_de_plane_update(struct drm_plane 
> *plane,
>   val &= ~LAYER_ROT_MASK;
>  
>   /* setup the rotation and axis flip bits */
> - if (plane->state->rotation & DRM_ROTATE_MASK)
> - val |= ilog2(plane->state->rotation & DRM_ROTATE_MASK) <<
> + if (plane->stat

Re: [PATCH] drm/vmwgfx: fix spelling mistake "exeeds" -> "exceeds"

2017-05-30 Thread Sinclair Yeh
Thanks.  Reviewed and queued.

On Sat, May 27, 2017 at 07:52:30PM +0100, Colin King wrote:
> From: Colin Ian King 
> 
> Trivial fix to spelling mistake in DRM_ERROR error message.
> 
> Signed-off-by: Colin Ian King 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> index 5900cff5bbc3..cee803c7d077 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> @@ -1492,7 +1492,7 @@ int vmw_surface_gb_priv_define(struct drm_device *dev,
>dev_priv->stdu_max_height);
>  
>   if (size.width > max_width || size.height > max_height) {
> - DRM_ERROR("%ux%u\n, exeeds max surface size %ux%u",
> + DRM_ERROR("%ux%u\n, exceeds max surface size %ux%u",
> size.width, size.height,
> max_width, max_height);
>   return -EINVAL;
> -- 
> 2.11.0
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 35/37] drm/vmwgfx: Drop drm_vblank_cleanup

2017-06-02 Thread Sinclair Yeh
Looks ok.  I won't get around to testing this until maybe mid next week though.

On Wed, May 24, 2017 at 04:52:10PM +0200, Daniel Vetter wrote:
> Again stopping the vblank before uninstalling the irq handler is kinda
> the wrong way round, but the fb_off stuff should take care of
> disabling the dsiplay at least in most cases. So drop the
typo ^

> drm_vblank_cleanup code since it's not really doing anything, it looks
> all cargo-culted.
> 
> v2: Appease gcc better.
> 
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> Signed-off-by: Daniel Vetter 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c  |  9 +++--
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.h  |  2 --
>  drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c  |  4 
>  drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c |  9 -
>  drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 27 +--
>  5 files changed, 4 insertions(+), 47 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index a8876b070168..d1f742478b03 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -1771,7 +1771,7 @@ int vmw_kms_init(struct vmw_private *dev_priv)
>  
>  int vmw_kms_close(struct vmw_private *dev_priv)
>  {
> - int ret;
> + int ret = 0;
>  
>   /*
>* Docs says we should take the lock before calling this function
> @@ -1779,11 +1779,8 @@ int vmw_kms_close(struct vmw_private *dev_priv)
>* drm_encoder_cleanup which takes the lock we deadlock.
>*/
>   drm_mode_config_cleanup(dev_priv->dev);
> - if (dev_priv->active_display_unit == vmw_du_screen_object)
> - ret = vmw_kms_sou_close_display(dev_priv);
> - else if (dev_priv->active_display_unit == vmw_du_screen_target)
> - ret = vmw_kms_stdu_close_display(dev_priv);
> - else
> + if (dev_priv->active_display_unit != vmw_du_screen_object &&
> + dev_priv->active_display_unit != vmw_du_screen_target)
>   ret = vmw_kms_ldu_close_display(dev_priv);
>  
>   return ret;
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
> index 13f2f1d2818a..f94b4ca38ab2 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h
> @@ -405,7 +405,6 @@ int vmw_kms_update_proxy(struct vmw_resource *res,
>   * Screen Objects display functions - vmwgfx_scrn.c
>   */
>  int vmw_kms_sou_init_display(struct vmw_private *dev_priv);
> -int vmw_kms_sou_close_display(struct vmw_private *dev_priv);
>  int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv,
>struct vmw_framebuffer *framebuffer,
>struct drm_clip_rect *clips,
> @@ -433,7 +432,6 @@ int vmw_kms_sou_readback(struct vmw_private *dev_priv,
>   * Screen Target Display Unit functions - vmwgfx_stdu.c
>   */
>  int vmw_kms_stdu_init_display(struct vmw_private *dev_priv);
> -int vmw_kms_stdu_close_display(struct vmw_private *dev_priv);
>  int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv,
>  struct vmw_framebuffer *framebuffer,
>  struct drm_clip_rect *clips,
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
> index d3987bcf53f8..449ed4fba0f2 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
> @@ -582,13 +582,9 @@ int vmw_kms_ldu_init_display(struct vmw_private 
> *dev_priv)
>  
>  int vmw_kms_ldu_close_display(struct vmw_private *dev_priv)
>  {
> - struct drm_device *dev = dev_priv->dev;
> -
>   if (!dev_priv->ldu_priv)
>   return -ENOSYS;
>  
> - drm_vblank_cleanup(dev);
> -
>   BUG_ON(!list_empty(&dev_priv->ldu_priv->active));
>  
>   kfree(dev_priv->ldu_priv);
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
> index 8d7dc9def7c2..3b917c9b0c21 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
> @@ -746,15 +746,6 @@ int vmw_kms_sou_init_display(struct vmw_private 
> *dev_priv)
>   return 0;
>  }
>  
> -int vmw_kms_sou_close_display(struct vmw_private *dev_priv)
> -{
> - struct drm_device *dev = dev_priv->dev;
> -
> - drm_vblank_cleanup(dev);
> -
> - return 0;
> -}
> -
>  static int do_dmabuf_define_gmrfb(struct vmw_private *dev_priv,
> struct vmw_framebuffer *framebuffer)
>  {
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_

[PATCH 3/3] drm/vmwgfx: Adjust checks for null pointers in 13 functions

2016-09-26 Thread Sinclair Yeh

This series looks good to me:  Reviewed-by: Sinclair Yeh 

Thanks!

On Fri, Sep 23, 2016 at 06:39:04PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring 
> Date: Fri, 23 Sep 2016 17:53:49 +0200
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> The script "checkpatch.pl" can point information out like the following.
> 
> Comparison to NULL could be written !…
> 
> Thus fix the affected source code places.
> 
> Signed-off-by: Markus Elfring 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 31 +++
>  1 file changed, 15 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> index 15504c6..b445ce9 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> @@ -324,7 +324,7 @@ static void vmw_hw_surface_destroy(struct vmw_resource 
> *res)
>   if (res->id != -1) {
>  
>   cmd = vmw_fifo_reserve(dev_priv, vmw_surface_destroy_size());
> - if (unlikely(cmd == NULL)) {
> + if (unlikely(!cmd)) {
>   DRM_ERROR("Failed reserving FIFO space for surface "
> "destruction.\n");
>   return;
> @@ -397,7 +397,7 @@ static int vmw_legacy_srf_create(struct vmw_resource *res)
>  
>   submit_size = vmw_surface_define_size(srf);
>   cmd = vmw_fifo_reserve(dev_priv, submit_size);
> - if (unlikely(cmd == NULL)) {
> + if (unlikely(!cmd)) {
>   DRM_ERROR("Failed reserving FIFO space for surface "
> "creation.\n");
>   ret = -ENOMEM;
> @@ -446,11 +446,10 @@ static int vmw_legacy_srf_dma(struct vmw_resource *res,
>   uint8_t *cmd;
>   struct vmw_private *dev_priv = res->dev_priv;
>  
> - BUG_ON(val_buf->bo == NULL);
> -
> + BUG_ON(!val_buf->bo);
>   submit_size = vmw_surface_dma_size(srf);
>   cmd = vmw_fifo_reserve(dev_priv, submit_size);
> - if (unlikely(cmd == NULL)) {
> + if (unlikely(!cmd)) {
>   DRM_ERROR("Failed reserving FIFO space for surface "
> "DMA.\n");
>   return -ENOMEM;
> @@ -538,7 +537,7 @@ static int vmw_legacy_srf_destroy(struct vmw_resource 
> *res)
>  
>   submit_size = vmw_surface_destroy_size();
>   cmd = vmw_fifo_reserve(dev_priv, submit_size);
> - if (unlikely(cmd == NULL)) {
> + if (unlikely(!cmd)) {
>   DRM_ERROR("Failed reserving FIFO space for surface "
> "eviction.\n");
>   return -ENOMEM;
> @@ -578,7 +577,7 @@ static int vmw_surface_init(struct vmw_private *dev_priv,
>   int ret;
>   struct vmw_resource *res = &srf->res;
>  
> - BUG_ON(res_free == NULL);
> + BUG_ON(!res_free);
>   if (!dev_priv->has_mob)
>   vmw_fifo_resource_inc(dev_priv);
>   ret = vmw_resource_init(dev_priv, res, true, res_free,
> @@ -747,7 +746,7 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void 
> *data,
>   }
>  
>   user_srf = kzalloc(sizeof(*user_srf), GFP_KERNEL);
> - if (unlikely(user_srf == NULL)) {
> + if (unlikely(!user_srf)) {
>   ret = -ENOMEM;
>   goto out_no_user_srf;
>   }
> @@ -772,7 +771,7 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void 
> *data,
>   srf->offsets = kmalloc_array(srf->num_sizes,
>sizeof(*srf->offsets),
>GFP_KERNEL);
> - if (unlikely(srf->offsets == NULL)) {
> + if (unlikely(!srf->offsets)) {
>   ret = -ENOMEM;
>   goto out_no_offsets;
>   }
> @@ -914,7 +913,7 @@ vmw_surface_handle_reference(struct vmw_private *dev_priv,
>  
>   ret = -EINVAL;
>   base = ttm_base_object_lookup_for_ref(dev_priv->tdev, handle);
> - if (unlikely(base == NULL)) {
> + if (unlikely(!base)) {
>   DRM_ERROR("Could not find surface to reference.\n");
>   goto out_no_lookup;
>   }
> @@ -1060,7 +1059,7 @@ static int vmw_gb_surface_create(struct vmw_resource 
> *res)
>  
>   cmd = vmw_fifo_reserve(dev_priv, submit_len);
>   cmd2 = (typeof(cmd2))cmd;
> - if (unlikely(cmd == NULL)) {
> + if (unlikely(!cmd)) {
>   DRM_ERROR("Failed reserving FIFO space for surface "
> "creation.\n");
>   ret = -ENO

[git pull] vmwgfx-fixes

2017-01-23 Thread Sinclair Yeh
Hi Dave,

The following changes since commit 25a7087fef1bfe7e0b9f4db4d75e08e9d9b11153:

  Merge remote-tracking branch 'vmwgfx_drm_stage/drm-fixes' into 
fdo_drm-vmwgfx-fixes (2017-01-19 08:42:10 -0800)

are available in the git repository at:

  git://people.freedesktop.org/~syeh/repos_linux drm-vmwgfx-fixes

for you to fetch changes up to 41007d4514845efbddaab60c7ead99fc44eb33bf:

  drm/vmwgfx: Use kmemdup instead of kmalloc and memcpy (2017-01-19 13:47:17 
-0800)


Kees Cook (1):
  drm/vmwgfx: use designated initializers

Shyam Saini (1):
  drm/vmwgfx: Use kmemdup instead of kmalloc and memcpy

Sinclair Yeh (1):
  drm/vmwgfx: Fix depth input into drm_mode_legacy_fb_format

Thomas Hellstrom (4):
  drm/vmwgfx: Clear uninitialized fields of a parameter
  drm/vmwgfx: Annotate ignored return values
  drm/vmwgfx: Clear an uninitialized struct member
  drm/vmwgfx: Fix a potential integer overflow

 drivers/gpu/drm/vmwgfx/device_include/svga3d_surfacedefs.h |  2 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c|  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c |  3 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c  | 10 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c|  4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_mob.c|  7 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c   |  4 ++--
 8 files changed, 17 insertions(+), 17 deletions(-)

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


[PATCH v2 12/14] MAINTAINERS: Add maintainer entry for the VMWGFX DRM driver

2016-05-03 Thread Sinclair Yeh
Reviewed-by: Sinclair Yeh 

On Tue, May 03, 2016 at 12:15:39AM +0100, Emil Velikov wrote:
> Thomas is one of the original authors of the driver, with recent
> contributions from Sinclair and Brian.
> 
> v2: Add Sinclair as maintainer. Add Sinclair+Thomas's tree, use
> Supported as status.
> 
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> Cc: Brian Paul 
> Cc: "VMware Graphics" 
> Signed-off-by: Emil Velikov 
> ---
>  MAINTAINERS | 11 +++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index a7c6a80..cf9b6d2 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -3909,6 +3909,17 @@ F: drivers/gpu/drm/etnaviv/
>  F:   include/uapi/drm/etnaviv_drm.h
>  F:   Documentation/devicetree/bindings/display/etnaviv/
>  
> +DRM DRIVER FOR VMWARE VIRTUAL GPU
> +M:   "VMware Graphics" 
> +M:   Sinclair Yeh 
> +M:   Thomas Hellstrom 
> +L:   dri-devel at lists.freedesktop.org
> +T:   git git://people.freedesktop.org/~syeh/repos_linux
> +T:   git git://people.freedesktop.org/~thomash/linux
> +S:   Supported
> +F:   drivers/gpu/drm/vmwgfx/
> +F:   include/uapi/drm/vmwgfx_drm.h
> +
>  DSBR100 USB FM RADIO DRIVER
>  M:   Alexey Klimov 
>  L:   linux-media at vger.kernel.org
> -- 
> 2.6.2
> 


[PATCH] drm/vmwgfx: Avoid compiler warning

2016-06-03 Thread Sinclair Yeh
Looks good to me.  Thanks!

Reviewed-by: Sinclair Yeh 

On Fri, Jun 03, 2016 at 05:47:13PM +0200, Thierry Reding wrote:
> From: Thierry Reding 
> 
> While the current code is correct and the compiler's DCE pass should
> remove either of the branches depending on the width of DMA addresses,
> the compiler still has to compile the code first.
> 
> On configurations with 32-bit DMA addresses, right-shifting the address
> by 32 causes GCC to output a build warning. Work around this by using a
> preprocessor conditional instead.
> 
> Signed-off-by: Thierry Reding 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
> index 67cebb23c940..577faca0fe9d 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
> @@ -291,12 +291,12 @@ void vmw_cmdbuf_header_free(struct vmw_cmdbuf_header 
> *header)
>  static int vmw_cmdbuf_header_submit(struct vmw_cmdbuf_header *header)
>  {
>   struct vmw_cmdbuf_man *man = header->man;
> - u32 val;
> +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
> + u32 val = header->handle >> 32;
> +#else
> + u32 val = 0;
> +#endif
>  
> - if (sizeof(header->handle) > 4)
> - val = (header->handle >> 32);
> - else
> - val = 0;
>   vmw_write(man->dev_priv, SVGA_REG_COMMAND_HIGH, val);
>  
>   val = (header->handle & 0xULL);
> -- 
> 2.8.3
> 


[PATCH v2] drm/core: Change declaration for gamma_set.

2016-06-07 Thread Sinclair Yeh
Acked-by: Sinclair Yeh 

On Tue, Jun 07, 2016 at 12:49:30PM +0200, Maarten Lankhorst wrote:
> Change return value to int to propagate errors from gamma_set,
> and remove start parameter. Updates always use the full size,
> and some drivers even ignore the start parameter altogether.
> 
> This is needed for atomic drivers, where an atomic commit can
> fail with -EINTR or -ENOMEM and should be restarted.
> 
> Changes since v1:
> - Fix compiler warning. (Emil)
> - Fix commit message (Daniel)
> 
> Cc: Alex Deucher 
> Acked-by: Alex Deucher 
> Cc: Christian König 
> Cc: David Airlie 
> Cc: Patrik Jakobsson 
> Cc: Ben Skeggs 
> Cc: Eric Anholt 
> Cc: VMware Graphics 
> Cc: Mathieu Larouche 
> Cc: Thierry Reding 
> Signed-off-by: Maarten Lankhorst 
> ---
>  drivers/gpu/drm/amd/amdgpu/dce_v10_0.c  | 10 ++
>  drivers/gpu/drm/amd/amdgpu/dce_v11_0.c  | 10 ++
>  drivers/gpu/drm/amd/amdgpu/dce_v8_0.c   | 10 ++
>  drivers/gpu/drm/ast/ast_mode.c  | 10 ++
>  drivers/gpu/drm/cirrus/cirrus_mode.c|  8 +---
>  drivers/gpu/drm/drm_atomic_helper.c | 13 ++---
>  drivers/gpu/drm/drm_crtc.c  |  2 +-
>  drivers/gpu/drm/drm_fb_helper.c |  2 +-
>  drivers/gpu/drm/gma500/gma_display.c|  9 +
>  drivers/gpu/drm/gma500/gma_display.h|  4 ++--
>  drivers/gpu/drm/mgag200/mgag200_mode.c  |  9 +
>  drivers/gpu/drm/nouveau/dispnv04/crtc.c | 12 +++-
>  drivers/gpu/drm/nouveau/nv50_display.c  |  9 +
>  drivers/gpu/drm/radeon/radeon_display.c | 11 +++
>  drivers/gpu/drm/vc4/vc4_crtc.c  |  8 +---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  8 +---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.h |  4 ++--
>  include/drm/drm_atomic_helper.h |  6 +++---
>  include/drm/drm_crtc.h  |  4 ++--
>  19 files changed, 85 insertions(+), 64 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
> index 7e57447bf5f4..112e358f0f9b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c
> @@ -2667,19 +2667,21 @@ static void dce_v10_0_cursor_reset(struct drm_crtc 
> *crtc)
>   }
>  }
>  
> -static void dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> - u16 *blue, uint32_t start, uint32_t size)
> +static int dce_v10_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> + u16 *blue, uint32_t size)
>  {
>   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
> - int end = (start + size > 256) ? 256 : start + size, i;
> + int i;
>  
>   /* userspace palettes are always correct as is */
> - for (i = start; i < end; i++) {
> + for (i = 0; i < size; i++) {
>   amdgpu_crtc->lut_r[i] = red[i] >> 6;
>   amdgpu_crtc->lut_g[i] = green[i] >> 6;
>   amdgpu_crtc->lut_b[i] = blue[i] >> 6;
>   }
>   dce_v10_0_crtc_load_lut(crtc);
> +
> + return 0;
>  }
>  
>  static void dce_v10_0_crtc_destroy(struct drm_crtc *crtc)
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
> index da101551960b..b522fa2435a8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c
> @@ -2678,19 +2678,21 @@ static void dce_v11_0_cursor_reset(struct drm_crtc 
> *crtc)
>   }
>  }
>  
> -static void dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> - u16 *blue, uint32_t start, uint32_t size)
> +static int dce_v11_0_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 
> *green,
> + u16 *blue, uint32_t size)
>  {
>   struct amdgpu_crtc *amdgpu_crtc = to_amdgpu_crtc(crtc);
> - int end = (start + size > 256) ? 256 : start + size, i;
> + int i;
>  
>   /* userspace palettes are always correct as is */
> - for (i = start; i < end; i++) {
> + for (i = 0; i < size; i++) {
>   amdgpu_crtc->lut_r[i] = red[i] >> 6;
>   amdgpu_crtc->lut_g[i] = green[i] >> 6;
>   amdgpu_crtc->lut_b[i] = blue[i] >> 6;
>   }
>   dce_v11_0_crtc_load_lut(crtc);
> +
> + return 0;
>  }
>  
>  static void dce_v11_0_crtc_destroy(struct drm_crtc *crtc)
> diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c 
> b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c
> index 41d9bc5f9c0e..b50ed72feedb 100644
> --- a/drivers/gpu/drm/am

[PATCH 1/6] drm/vmwgfx: Stop checking minor type directly

2016-06-24 Thread Sinclair Yeh
Thanks!

Reviewed-by: Sinclair Yeh 


On Fri, Jun 24, 2016 at 06:15:15PM +0100, Frank Binns wrote:
> Use the appropriate drm minor type helper instead.
> 
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> Signed-off-by: Frank Binns 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 6064664..5d5c951 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -1041,8 +1041,7 @@ static struct vmw_master *vmw_master_check(struct 
> drm_device *dev,
>   struct vmw_fpriv *vmw_fp = vmw_fpriv(file_priv);
>   struct vmw_master *vmaster;
>  
> - if (file_priv->minor->type != DRM_MINOR_LEGACY ||
> - !(flags & DRM_AUTH))
> + if (!drm_is_primary_client(file_priv) || !(flags & DRM_AUTH))
>   return NULL;
>  
>   ret = mutex_lock_interruptible(&dev->master_mutex);
> -- 
> 2.7.4
> 


[PATCH v3 14/15] drm: vmwgfx: Replace drm_fb_get_bpp_depth() with drm_format_info()

2016-06-27 Thread Sinclair Yeh
This patch looks good to me:

Reviewed-by: Sinclair Yeh 

On Thu, Jun 09, 2016 at 02:32:18AM +0300, Laurent Pinchart wrote:
> The driver is the last users of the drm_fb_get_bpp_depth() function. It
> should ideally be converted to use struct drm_mode_fb_cmd2 instead of
> the legacy struct drm_mode_fb_cmd internally, but that will require
> broad changes across the code base. As a first step, replace
> drm_fb_get_bpp_depth() with drm_format_info() in order to stop exporting
> the function to drivers.
> 
> The new DRM_ERROR() message comes from the vmw_create_dmabuf_proxy(),
> vmw_kms_new_framebuffer_surface() and vmw_kms_new_framebuffer_dmabuf()
> functions that currently print an error if the pixel format is
> unsupported.
> 
> Signed-off-by: Laurent Pinchart 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 12 ++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> Cc: VMware Graphics 
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index 55231cce73a0..1a7187f472de 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -980,14 +980,22 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct 
> drm_device *dev,
>   struct vmw_dma_buffer *bo = NULL;
>   struct ttm_base_object *user_obj;
>   struct drm_mode_fb_cmd mode_cmd;
> + const struct drm_format_info *info;
>   int ret;
>  
> + info = drm_format_info(mode_cmd2->pixel_format);
> + if (!info || !info->depth) {
> + DRM_ERROR("Unsupported framebuffer format %s\n",
> +   drm_get_format_name(mode_cmd2->pixel_format));
> + return ERR_PTR(-EINVAL);
> + }
> +
>   mode_cmd.width = mode_cmd2->width;
>   mode_cmd.height = mode_cmd2->height;
>   mode_cmd.pitch = mode_cmd2->pitches[0];
>   mode_cmd.handle = mode_cmd2->handles[0];
> - drm_fb_get_bpp_depth(mode_cmd2->pixel_format, &mode_cmd.depth,
> - &mode_cmd.bpp);
> + mode_cmd.depth = info->depth;
> + mode_cmd.bpp = info->cpp[0] * 8;
>  
>   /**
>* This code should be conditioned on Screen Objects not being used.
> -- 
> Regards,
> 
> Laurent Pinchart
> 


[git pull] vmwgfx-fixes

2016-07-04 Thread Sinclair Yeh
Hi Dave,

The following changes since commit 81e257e964268d050f8e9188becd44d50f241d72:

  drm/atomic: Make drm_atomic_legacy_backoff reset crtc->acquire_ctx 
(2016-06-24 11:10:36 +1000)

are available in the git repository at:

  git://people.freedesktop.org/~syeh/repos_linux drm-vmwgfx-fixes

for you to fetch changes up to beca4cf55323147ca9c8a98de1871be6e4fe8f34:

  drm/vmwgfx: Fix corner case screen target management (2016-07-01 10:47:51 
-0700)

----
Sinclair Yeh (6):
  drm/vmwgfx: Add a check to handle host message failure
  drm/vmwgfx: Work around mode set failure in 2D VMs
  drm/vmwgfx: Add an option to change assumed FB bpp
  drm/ttm: Make ttm_bo_mem_compat available
  drm/vmwgfx: Check pin count before attempting to move a buffer
  drm/vmwgfx: Delay pinning fbdev framebuffer until after mode set

Thomas Hellstrom (1):
  drm/vmwgfx: Fix corner case screen target management

 drivers/gpu/drm/ttm/ttm_bo.c   |  7 ---
 drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c | 25 ++---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c| 12 
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h|  1 +
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 47 
+--
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c| 10 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c|  3 +++
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c   |  8 
 include/drm/ttm/ttm_bo_api.h   | 14 ++
 9 files changed, 88 insertions(+), 39 deletions(-)



[PATCH 3/3] drm/vmwgfx: Delay pinning fbdev framebuffer until after mode set

2016-07-05 Thread Sinclair Yeh
Argh, you're right.  I'll send out a patch.  Thanks for catching this!

Sinclair

On Mon, Jul 04, 2016 at 04:51:52PM +0100, Emil Velikov wrote:
> Hi Sinclair,
> 
> On 1 July 2016 at 19:24,   wrote:
> > From: Sinclair Yeh 
> >
> > For the Screen Object display unit, we need to reserve a
> > guest-invisible region equal to the size of the framebuffer for
> > the host.  This region can only be reserved in VRAM, whereas
> > the guest-visible framebuffer can be reserved in either VRAM or
> > GMR.
> >
> > As such priority should be given to the guest-invisible
> > region otherwise in a limited VRAM situation, we can fail to
> > allocate this region.
> >
> > This patch makes it so that vmw_sou_backing_alloc() is called
> > before the framebuffer is pinned.
> >
> > Signed-off-by: Sinclair Yeh 
> > Reviewed-by: Thomas Hellstrom 
> > Cc: 
> > ---
> > This is the last patch of a 3-patch series to fix console black
> > screen issue on Ubuntu 16.04 server
> > ---
> >  drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 47 
> > --
> >  1 file changed, 25 insertions(+), 22 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c 
> > b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
> > index 679a4cb..66eaa30 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
> > @@ -517,28 +517,6 @@ static int vmw_fb_kms_framebuffer(struct fb_info *info)
> >
> > par->set_fb = &vfb->base;
> >
> > -   if (!par->bo_ptr) {
> > -   /*
> > -* Pin before mapping. Since we don't know in what placement
> > -* to pin, call into KMS to do it for us.
> > -*/
> > -   ret = vfb->pin(vfb);
> > -   if (ret) {
> > -   DRM_ERROR("Could not pin the fbdev framebuffer.\n");
> > -   return ret;
> > -   }
> > -
> > -   ret = ttm_bo_kmap(&par->vmw_bo->base, 0,
> > - par->vmw_bo->base.num_pages, &par->map);
> > -   if (ret) {
> > -   vfb->unpin(vfb);
> > -   DRM_ERROR("Could not map the fbdev framebuffer.\n");
> > -   return ret;
> > -   }
> > -
> > -   par->bo_ptr = ttm_kmap_obj_virtual(&par->map, 
> > &par->bo_iowrite);
> > -   }
> > -
> > return 0;
> >  }
> >
> > @@ -601,6 +579,31 @@ static int vmw_fb_set_par(struct fb_info *info)
> > if (ret)
> > goto out_unlock;
> >
> > +   if (!par->bo_ptr) {
> > +   struct vmw_framebuffer *vfb = 
> > vmw_framebuffer_to_vfb(set.fb);
> > +
> > +   /*
> > +* Pin before mapping. Since we don't know in what placement
> > +* to pin, call into KMS to do it for us.
> > +*/
> > +   ret = vfb->pin(vfb);
> > +   if (ret) {
> > +   DRM_ERROR("Could not pin the fbdev framebuffer.\n");
> > +   return ret;
> > +   }
> > +
> > +   ret = ttm_bo_kmap(&par->vmw_bo->base, 0,
> > + par->vmw_bo->base.num_pages, &par->map);
> > +   if (ret) {
> > +   vfb->unpin(vfb);
> > +   DRM_ERROR("Could not map the fbdev framebuffer.\n");
> > +   return ret;
> > +   }
> > +
> > +   par->bo_ptr = ttm_kmap_obj_virtual(&par->map, 
> > &par->bo_iowrite);
> > +   }
> > +
> > +
> Seems like you forgot to update the error paths. Thankfully we
> shouldn't be reaching those too often, if at all.
> 
> -Emil


[PATCH] drm/vmwgfx: Fix error paths when mapping framebuffer

2016-07-07 Thread Sinclair Yeh
Rather than returning immediately, make sure to unlock the
mutexes first.

Signed-off-by: Sinclair Yeh 
Reviewed-by: Charmaine Lee 
Reported-by: Emil Velikov 
Cc: 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
index 66eaa30..d2d9395 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
@@ -589,7 +589,7 @@ static int vmw_fb_set_par(struct fb_info *info)
ret = vfb->pin(vfb);
if (ret) {
DRM_ERROR("Could not pin the fbdev framebuffer.\n");
-   return ret;
+   goto out_unlock;
}

ret = ttm_bo_kmap(&par->vmw_bo->base, 0,
@@ -597,7 +597,7 @@ static int vmw_fb_set_par(struct fb_info *info)
if (ret) {
vfb->unpin(vfb);
DRM_ERROR("Could not map the fbdev framebuffer.\n");
-   return ret;
+   goto out_unlock;
}

par->bo_ptr = ttm_kmap_obj_virtual(&par->map, &par->bo_iowrite);
-- 
2.7.4



[git pull] vmwgfx-fixes

2016-07-08 Thread Sinclair Yeh
Hi Dave,

This contains one small patch to make sure we release a mutex when
hitting a framebuffer pinning and mapping failure.

It is not very often that we'll run into this case, and given that
it's late in the current release, I'm okay with batching this up with
the next one if this cannot go in now.



The following changes since commit beca4cf55323147ca9c8a98de1871be6e4fe8f34:

  drm/vmwgfx: Fix corner case screen target management (2016-07-01 10:47:51 
-0700)

are available in the git repository at:

  git://people.freedesktop.org/~syeh/repos_linux drm-vmwgfx-fixes

for you to fetch changes up to 58541f7a6458e17ab417321b284f0090f530aa91:

  drm/vmwgfx: Fix error paths when mapping framebuffer (2016-07-08 08:30:35 
-0700)

--------
Sinclair Yeh (1):
  drm/vmwgfx: Fix error paths when mapping framebuffer

 drivers/gpu/drm/vmwgfx/vmwgfx_fb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)




[PATCH] drm/vmwgfx: Delete an unnecessary check before the function call "vfree"

2016-07-22 Thread Sinclair Yeh
Looks good.  Thanks!

Reviewed-by: Sinclair Yeh 

On Fri, Jul 22, 2016 at 01:45:40PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring 
> Date: Fri, 22 Jul 2016 13:31:00 +0200
> 
> The vfree() function performs also input parameter validation.
> Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> index 1a1a87c..dc5beff 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> @@ -3625,9 +3625,7 @@ static int vmw_resize_cmd_bounce(struct vmw_sw_context 
> *sw_context,
>  (sw_context->cmd_bounce_size >> 1));
>   }
>  
> - if (sw_context->cmd_bounce != NULL)
> - vfree(sw_context->cmd_bounce);
> -
> + vfree(sw_context->cmd_bounce);
>   sw_context->cmd_bounce = vmalloc(sw_context->cmd_bounce_size);
>  
>   if (sw_context->cmd_bounce == NULL) {
> -- 
> 2.9.2
> 


[PATCH] drm/doc: Document uapi requirements in DRM

2016-08-26 Thread Sinclair Yeh
Reviewed-by: Sinclair Yeh 

On Fri, Aug 19, 2016 at 10:50:38PM +0200, Daniel Vetter wrote:
> Everyone knows them, except all the new folks joining from the ARM
> side haven't lived through all the pain of the past years and are
> entirely surprised when I raise this. Definitely time to document
> this.
> 
> Last time this was a big discussion was about 6 years ago, when qcom
> tried to land a kernel driver without userspace. Dave Airlie made the
> rules really clear:
> 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__airlied.livejournal.com_73115.html&d=CwIDaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=w9Iu3o4zAy-3-s8MFvrNSQ&m=YlKw0M9a4htB0LJuAWmS2fxNN9GUjDewsVWvDM3bkI8&s=sbslwGx1LSh92YTxx8DnoKFau_MPXjwM_uK6S4l4y8o&e=
>  
> 
> This write-up here is essentially what I've put into a presentation a
> while ago, which was also reviewed by Dave:
> 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__blog.ffwll.ch_2015_05_gfx-2Dkernel-2Dupstreaming-2Drequirements.html&d=CwIDaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=w9Iu3o4zAy-3-s8MFvrNSQ&m=YlKw0M9a4htB0LJuAWmS2fxNN9GUjDewsVWvDM3bkI8&s=EZbXCRJDTIcS1Rp5LG_A2GxBXRvTwl5jFYy6tLkfg-g&e=
>  
> 
> Cc: Dave Airlie 
> Cc: Oded Gabbay 
> Cc: Russell King 
> Cc: Tomi Valkeinen 
> Cc: Eric Anholt 
> Cc: Thomas Hellstrom 
> Cc: Sinclair Yeh 
> Cc: Lucas Stach 
> Cc: Benjamin Gaignard 
> Cc: Mark Yao 
> Cc: Laurent Pinchart 
> Cc: Ben Skeggs 
> Cc: Rob Clark 
> Cc: CK Hu 
> Cc: Xinliang Liu 
> Cc: Philipp Zabel 
> Cc: Stefan Agner 
> Cc: Inki Dae 
> Cc: Maxime Ripard  
> Cc: Boris Brezillon 
> Cc: Jani Nikula 
> Cc: Daniel Vetter 
> Cc: Thierry Reding 
> Cc: Christian König 
> Cc: Alex Deucher 
> Cc: Gerd Hoffmann 
> Cc: Brian Starkey 
> Cc: Liviu Dudau 
> Cc: Alexey Brodkin 
> Acked-by: Dave Airlie 
> Signed-off-by: Daniel Vetter 
> ---
>  Documentation/gpu/drm-uapi.rst | 67 
> ++
>  1 file changed, 67 insertions(+)
> 
> diff --git a/Documentation/gpu/drm-uapi.rst b/Documentation/gpu/drm-uapi.rst
> index 94876938aef3..a7e3aa27167d 100644
> --- a/Documentation/gpu/drm-uapi.rst
> +++ b/Documentation/gpu/drm-uapi.rst
> @@ -36,6 +36,73 @@ Primary Nodes, DRM Master and Authentication
>  Open-Source Userspace Requirements
>  ==
>  
> +The DRM subsystem has stricter requirements on what the userspace side for 
> new
> +uAPI needs to look like. This section here explains what exactly those
> +requirements are, and why they exist.
> +
> +The short summary is that any addition of DRM uAPI requires corresponding
> +open-sourced userspace patches, and those patches must be reviewed and ready 
> for
> +merging into a suitable and canonical upstream project.
> +
> +GFX devices (both display and render/GPU side) are really complex bits of 
> hardware,
> +with userspace and kernel by necessity having to work together really 
> closely.
> +The interfaces, for rendering and modesetting must be extremely wide and
> +flexible, and therefore it is almost always impossible to precisely define 
> them
> +for every possible corner case. This in turns makes it really practically
> +infeasible to differentiate between behaviour that's required by userspace, 
> and
> +which must not be changed to avoid regressions, and behaviour which is only 
> an
> +accidental artifact of the current implementation.
> +
> +Without access to the full source code of all userspace users that means it
> +becomes impossible to change the implementation details, since userspace 
> could
> +depend upon the accidental behaviour of the current implementation in minute
> +details. And debugging such regressions without access to source code is 
> pretty
> +much impossible. As a consequence this means:
> +
> +- The Linux kernel's "no regression" policy holds in practice only for
> +  open-source userspace of the DRM subsystem. DRM developers are perfectly 
> fine
> +  if closed-source blob drivers in userspace use the same uAPI as the open
> +  drivers, but they must do so in the exact same way as the open drivers.
> +  Creative (ab)use of the interfaces will, and in the past routinely has, 
> lead
> +  to breakage.
> +
> +- Any new userspace interface must have an open-source implementation as
> +  demonstration vehicle.
> +
> +The other reason for requiring open-source userspace is uAPI review. Since 
> the
> +kernel and userspace parts of a GFX stack must work together so closely, code
> +review can only assess whether a new interface achieves its goals by looking 
> at
> +both sides. Making sure that the interface indeed

[PATCH 5/5] drm/vmwgfx: Remove call to reservation_object_test_signaled_rcu before wait

2016-08-26 Thread Sinclair Yeh
Reviewed-by: Sinclair Yeh 

On Thu, Aug 11, 2016 at 03:46:22PM +0100, Chris Wilson wrote:
> Since fence_wait_timeout_reservation_object_wait_timeout_rcu() with a
> timeout of 0 becomes reservation_object_test_signaled_rcu(), we do not
> need to handle such conversion in the caller. The only challenge are
> those callers that wish to differentiate the error code between the
> nonblocking busy check and potentially blocking wait.
> 
> Signed-off-by: Chris Wilson 
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
> index 6a328d507a28..afda2a57a094 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c
> @@ -574,10 +574,8 @@ static int vmw_user_dmabuf_synccpu_grab(struct 
> vmw_user_dma_buffer *user_bo,
>   bool nonblock = !!(flags & drm_vmw_synccpu_dontblock);
>   long lret;
>  
> - if (nonblock)
> - return reservation_object_test_signaled_rcu(bo->resv, 
> true) ? 0 : -EBUSY;
> -
> - lret = reservation_object_wait_timeout_rcu(bo->resv, true, 
> true, MAX_SCHEDULE_TIMEOUT);
> + lret = reservation_object_wait_timeout_rcu(bo->resv, true, true,
> +nonblock ? 0 
> :MAX_SCHEDULE_TIMEOUT);
>   if (!lret)
>   return -EBUSY;
>   else if (lret < 0)
> -- 
> 2.8.1
> 


[PATCH] drm/vmwgfx: Switch to mode_cmd2

2016-12-01 Thread Sinclair Yeh
One defect below otherwise:  Reviewed-by: Sinclair Yeh 

On Wed, Nov 30, 2016 at 06:00:04PM +0100, Daniel Vetter wrote:
> Surprisingly few changes needed to make it happen. Compile-tested
> only. The idea is that this replaces the 2 patches from Ville's big
> fb->format patch series as a prep patch. Only impact to later patches
> should be the one instace added in this patch where we look at
> fb->pixel_format (instead of fb->bpp and fb->depth), so minor
> adjustements in the cocci-generated patches needed.
> 
> Cc: ville.syrjala at linux.intel.com
> Cc: Laurent Pinchart 
> Cc: linux-graphics-maintainer at vmware.com
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> Signed-off-by: Daniel Vetter 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_fb.c  |  18 +++---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 116 
> +---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.h |   2 +-
>  3 files changed, 52 insertions(+), 84 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
> index d2d93959b119..4b1defc7aa6d 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
> @@ -465,33 +465,33 @@ static int vmw_fb_kms_detach(struct vmw_fb_par *par,
>  
>  static int vmw_fb_kms_framebuffer(struct fb_info *info)
>  {
> - struct drm_mode_fb_cmd mode_cmd;
> + struct drm_mode_fb_cmd2 mode_cmd;
>   struct vmw_fb_par *par = info->par;
>   struct fb_var_screeninfo *var = &info->var;
>   struct drm_framebuffer *cur_fb;
>   struct vmw_framebuffer *vfb;
> - int ret = 0;
> + int ret = 0, depth;
>   size_t new_bo_size;
>  
> - ret = vmw_fb_compute_depth(var, &mode_cmd.depth);
> + ret = vmw_fb_compute_depth(var, &depth);
>   if (ret)
>   return ret;
>  
>   mode_cmd.width = var->xres;
>   mode_cmd.height = var->yres;
> - mode_cmd.bpp = var->bits_per_pixel;
> - mode_cmd.pitch = ((mode_cmd.bpp + 7) / 8) * mode_cmd.width;

mode_cmd.pitches[0] needs to be initialized before being used below.

Maybe something like:
mode_cmd.pitches[0] = ((var->bits_per_pixel + 7) / 8) * mode_cmd.width;

> + mode_cmd.pixel_format =
> + drm_mode_legacy_fb_format(var->bits_per_pixel,
> + ((var->bits_per_pixel + 7) / 8) * mode_cmd.width);
>  
>   cur_fb = par->set_fb;
>   if (cur_fb && cur_fb->width == mode_cmd.width &&
>   cur_fb->height == mode_cmd.height &&
> - cur_fb->bits_per_pixel == mode_cmd.bpp &&
> - cur_fb->depth == mode_cmd.depth &&
> - cur_fb->pitches[0] == mode_cmd.pitch)
> + cur_fb->pixel_format == mode_cmd.pixel_format &&
> + cur_fb->pitches[0] == mode_cmd.pitches[0])
>   return 0;
>  
>   /* Need new buffer object ? */
> - new_bo_size = (size_t) mode_cmd.pitch * (size_t) mode_cmd.height;
> + new_bo_size = (size_t) mode_cmd.pitches[0] * (size_t) mode_cmd.height;
>   ret = vmw_fb_kms_detach(par,
>   par->bo_size < new_bo_size ||
>   par->bo_size > 2*new_bo_size,
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index e3f68cc9bb4b..e7daf59bac80 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -516,7 +516,7 @@ static const struct drm_framebuffer_funcs 
> vmw_framebuffer_surface_funcs = {
>  static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv,
>  struct vmw_surface *surface,
>  struct vmw_framebuffer **out,
> -const struct drm_mode_fb_cmd
> +const struct drm_mode_fb_cmd2
>  *mode_cmd,
>  bool is_dmabuf_proxy)
>  
> @@ -525,6 +525,7 @@ static int vmw_kms_new_framebuffer_surface(struct 
> vmw_private *dev_priv,
>   struct vmw_framebuffer_surface *vfbs;
>   enum SVGA3dSurfaceFormat format;
>   int ret;
> + struct drm_format_name_buf format_name;
>  
>   /* 3D is only supported on HWv8 and newer hosts */
>   if (dev_priv->active_display_unit == vmw_du_legacy)
> @@ -548,21 +549,22 @@ static int vmw_kms_new_framebuffer_surface(struct 
> vmw_private *dev_priv,
>   return -EINVAL;
>   }
>  
> - switch (mode_cmd->depth) {
> - case 32:
> + switch (mode_cmd->pixel_forma

[PATCH] gpu: vmwgfx: Use dma_pool_zalloc

2016-12-01 Thread Sinclair Yeh
Applied.  Thanks.

Reviewed-by: Sinclair Yeh 

On Fri, Dec 02, 2016 at 01:25:45AM +0530, Souptick Joarder wrote:
> We should use dma_pool_zalloc instead of dma_pool_alloc/memset
> 
> Signed-off-by: Souptick joarder 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c | 10 --
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
> index aa04fb0..fa097cc 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
> @@ -784,8 +784,8 @@ static int vmw_cmdbuf_space_pool(struct vmw_cmdbuf_man 
> *man,
>   if (ret)
>   return ret;
> 
> - header->cb_header = dma_pool_alloc(man->headers, GFP_KERNEL,
> -&header->handle);
> + header->cb_header = dma_pool_zalloc(man->headers, GFP_KERNEL,
> + &header->handle);
>   if (!header->cb_header) {
>   ret = -ENOMEM;
>   goto out_no_cb_header;
> @@ -795,7 +795,6 @@ static int vmw_cmdbuf_space_pool(struct vmw_cmdbuf_man 
> *man,
>   cb_hdr = header->cb_header;
>   offset = header->node.start << PAGE_SHIFT;
>   header->cmd = man->map + offset;
> - memset(cb_hdr, 0, sizeof(*cb_hdr));
>   if (man->using_mob) {
>   cb_hdr->flags = SVGA_CB_FLAG_MOB;
>   cb_hdr->ptr.mob.mobid = man->cmd_space->mem.start;
> @@ -832,8 +831,8 @@ static int vmw_cmdbuf_space_inline(struct vmw_cmdbuf_man 
> *man,
>   if (WARN_ON_ONCE(size > VMW_CMDBUF_INLINE_SIZE))
>   return -ENOMEM;
> 
> - dheader = dma_pool_alloc(man->dheaders, GFP_KERNEL,
> -  &header->handle);
> + dheader = dma_pool_zalloc(man->dheaders, GFP_KERNEL,
> +   &header->handle);
>   if (!dheader)
>   return -ENOMEM;
> 
> @@ -842,7 +841,6 @@ static int vmw_cmdbuf_space_inline(struct vmw_cmdbuf_man 
> *man,
>   cb_hdr = &dheader->cb_header;
>   header->cb_header = cb_hdr;
>   header->cmd = dheader->cmd;
> - memset(dheader, 0, sizeof(*dheader));
>   cb_hdr->status = SVGA_CB_STATUS_NONE;
>   cb_hdr->flags = SVGA_CB_FLAG_NONE;
>   cb_hdr->ptr.pa = (u64)header->handle +
> --
> 1.9.1
> 


[PATCH] drm/vmwgfx: Switch to mode_cmd2

2016-12-02 Thread Sinclair Yeh
On Fri, Dec 02, 2016 at 08:00:22AM +0100, Daniel Vetter wrote:
> On Thu, Dec 01, 2016 at 03:09:40PM -0800, Sinclair Yeh wrote:
> > One defect below otherwise:  Reviewed-by: Sinclair Yeh 
> > 
> > On Wed, Nov 30, 2016 at 06:00:04PM +0100, Daniel Vetter wrote:
> > > Surprisingly few changes needed to make it happen. Compile-tested
> > > only. The idea is that this replaces the 2 patches from Ville's big
> > > fb->format patch series as a prep patch. Only impact to later patches
> > > should be the one instace added in this patch where we look at
> > > fb->pixel_format (instead of fb->bpp and fb->depth), so minor
> > > adjustements in the cocci-generated patches needed.
> > > 
> > > Cc: ville.syrjala at linux.intel.com
> > > Cc: Laurent Pinchart 
> > > Cc: linux-graphics-maintainer at vmware.com
> > > Cc: Sinclair Yeh 
> > > Cc: Thomas Hellstrom 
> > > Signed-off-by: Daniel Vetter 
> > > ---
> > >  drivers/gpu/drm/vmwgfx/vmwgfx_fb.c  |  18 +++---
> > >  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 116 
> > > +---
> > >  drivers/gpu/drm/vmwgfx/vmwgfx_kms.h |   2 +-
> > >  3 files changed, 52 insertions(+), 84 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c 
> > > b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
> > > index d2d93959b119..4b1defc7aa6d 100644
> > > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
> > > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
> > > @@ -465,33 +465,33 @@ static int vmw_fb_kms_detach(struct vmw_fb_par *par,
> > >  
> > >  static int vmw_fb_kms_framebuffer(struct fb_info *info)
> > >  {
> > > - struct drm_mode_fb_cmd mode_cmd;
> > > + struct drm_mode_fb_cmd2 mode_cmd;
> > >   struct vmw_fb_par *par = info->par;
> > >   struct fb_var_screeninfo *var = &info->var;
> > >   struct drm_framebuffer *cur_fb;
> > >   struct vmw_framebuffer *vfb;
> > > - int ret = 0;
> > > + int ret = 0, depth;
> > >   size_t new_bo_size;
> > >  
> > > - ret = vmw_fb_compute_depth(var, &mode_cmd.depth);
> > > + ret = vmw_fb_compute_depth(var, &depth);
> > >   if (ret)
> > >   return ret;
> > >  
> > >   mode_cmd.width = var->xres;
> > >   mode_cmd.height = var->yres;
> > > - mode_cmd.bpp = var->bits_per_pixel;
> > > - mode_cmd.pitch = ((mode_cmd.bpp + 7) / 8) * mode_cmd.width;
> > 
> > mode_cmd.pitches[0] needs to be initialized before being used below.
> > 
> > Maybe something like:
> > mode_cmd.pitches[0] = ((var->bits_per_pixel + 7) / 8) * mode_cmd.width;
> 
> Oh right, I deleted a bit too much here. Once fixed, ok if I merge this
> through drm-misc so that Ville can throw his fb->format conversion on top?

Sure, thanks for doing this!



[PATCH v3 01/13] drm: Don't include in

2016-12-02 Thread Sinclair Yeh

vmwgfx part:  Reviewed-by: Sinclair Yeh 

On Tue, Nov 29, 2016 at 11:04:31AM +0200, Laurent Pinchart wrote:
>  used to define most of the in-kernel KMS API. It has
> now been split into separate files for each object type, but still
> includes most other KMS headers to avoid breaking driver compilation.
> 
> As a step towards fixing that problem, remove the inclusion of
>  from  and include it instead where
> appropriate. Also remove the forward declarations of the drm_encoder and
> drm_encoder_helper_funcs structures from  as they're not
> needed in the header.
> 
>  now has to include  and contain a
> forward declaration of struct drm_encoder in order to allow including it
> as the first header in a compilation unit.
> 
> Signed-off-by: Laurent Pinchart 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h| 1 +
>  drivers/gpu/drm/ast/ast_drv.h   | 1 +
>  drivers/gpu/drm/bochs/bochs.h   | 1 +
>  drivers/gpu/drm/cirrus/cirrus_drv.h | 1 +
>  drivers/gpu/drm/drm_connector.c | 1 +
>  drivers/gpu/drm/drm_crtc_helper.c   | 1 +
>  drivers/gpu/drm/drm_edid.c  | 1 +
>  drivers/gpu/drm/drm_mode_config.c   | 1 +
>  drivers/gpu/drm/drm_of.c| 1 +
>  drivers/gpu/drm/drm_plane_helper.c  | 1 +
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.h   | 2 ++
>  drivers/gpu/drm/gma500/psb_intel_drv.h  | 1 +
>  drivers/gpu/drm/i915/intel_drv.h| 1 +
>  drivers/gpu/drm/mgag200/mgag200_drv.h   | 1 +
>  drivers/gpu/drm/nouveau/nouveau_connector.h | 1 +
>  drivers/gpu/drm/qxl/qxl_drv.h   | 1 +
>  drivers/gpu/drm/radeon/radeon_mode.h| 1 +
>  drivers/gpu/drm/rcar-du/rcar_du_encoder.h   | 1 +
>  drivers/gpu/drm/shmobile/shmob_drm_crtc.h   | 1 +
>  drivers/gpu/drm/tegra/drm.h | 1 +
>  drivers/gpu/drm/vc4/vc4_drv.h   | 2 ++
>  drivers/gpu/drm/virtio/virtgpu_drv.h| 1 +
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 1 +
>  include/drm/drm_crtc.h  | 3 ---
>  include/drm/drm_encoder.h   | 3 +++
>  include/drm/drm_encoder_slave.h | 1 +
>  include/drm/drm_modeset_helper_vtables.h| 1 +
>  27 files changed, 30 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> index 1e23334b07fb..fac06064a8f5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h
> @@ -32,6 +32,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/gpu/drm/ast/ast_drv.h b/drivers/gpu/drm/ast/ast_drv.h
> index 908011d2c8f5..6f3b6f50cf52 100644
> --- a/drivers/gpu/drm/ast/ast_drv.h
> +++ b/drivers/gpu/drm/ast/ast_drv.h
> @@ -28,6 +28,7 @@
>  #ifndef __AST_DRV_H__
>  #define __AST_DRV_H__
>  
> +#include 
>  #include 
>  
>  #include 
> diff --git a/drivers/gpu/drm/bochs/bochs.h b/drivers/gpu/drm/bochs/bochs.h
> index 32dfe418cc98..f626bab7f5e3 100644
> --- a/drivers/gpu/drm/bochs/bochs.h
> +++ b/drivers/gpu/drm/bochs/bochs.h
> @@ -4,6 +4,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include 
> diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h 
> b/drivers/gpu/drm/cirrus/cirrus_drv.h
> index 2188d6b61b3e..b59aeef4635a 100644
> --- a/drivers/gpu/drm/cirrus/cirrus_drv.h
> +++ b/drivers/gpu/drm/cirrus/cirrus_drv.h
> @@ -13,6 +13,7 @@
>  
>  #include 
>  
> +#include 
>  #include 
>  
>  #include 
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index b5c6a8ee831e..5f1e1f190d30 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -23,6 +23,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include "drm_crtc_internal.h"
>  #include "drm_internal.h"
> diff --git a/drivers/gpu/drm/drm_crtc_helper.c 
> b/drivers/gpu/drm/drm_crtc_helper.c
> index 5d2cb138eba6..b3fc23313cc3 100644
> --- a/drivers/gpu/drm/drm_crtc_helper.c
> +++ b/drivers/gpu/drm/drm_crtc_helper.c
> @@ -36,6 +36,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 7eec18925b70..a9e3cc3990c1 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -35,6 +35,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #define version_greater(edid, maj, min) \
> diff --git a/drivers/gpu/drm/drm_mode_config.c 
> b/drive

[git pull] vmwgfx-fixes

2016-12-13 Thread Sinclair Yeh
Hi Dave,

The following changes since commit ab7cd8d83e5dba13027de66f1b008b08b30b71a4:

  Merge tag 'drm-intel-fixes-2016-12-01' of 
git://anongit.freedesktop.org/git/drm-intel into drm-fixes (2016-12-04 06:31:26 
+1000)

are available in the git repository at:

  git://people.freedesktop.org/~syeh/repos_linux drm-vmwgfx-fixes

for you to fetch changes up to c013d6ef71a85e01033bcc02da2e07bbdcd6baec:

  drm/vmwgfx: Use dma_pool_zalloc (2016-12-13 07:58:21 -0800)


Arnd Bergmann (1):
  drm/vmwgfx: avoid gcc-7 parentheses warning

Christophe JAILLET (1):
  drm/vmwgfx: Fix handling of errors returned by 'vmw_cotable_alloc()'

Ravikant B Sharma (1):
  drm/vmwgfx : Fix NULL pointer comparison

Souptick Joarder (1):
  drm/vmwgfx: Use dma_pool_zalloc

 drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c| 10 --
 drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c|  4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_context.c   |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c   |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c   |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 10 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_mob.c   |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c   |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c  |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c  |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_shader.c|  6 +++---
 13 files changed, 35 insertions(+), 37 deletions(-)



[PATCH] drm/vmwgfx: use designated initializers

2016-12-19 Thread Sinclair Yeh
Reviewed-by: Sinclair Yeh 

thanks!

On Fri, Dec 16, 2016 at 05:04:02PM -0800, Kees Cook wrote:
> Prepare to mark sensitive kernel structures for randomization by making
> sure they're using designated initializers. These were identified during
> allyesconfig builds of x86, arm, and arm64, with most initializer fixes
> extracted from grsecurity.
> 
> Signed-off-by: Kees Cook 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> index 170b61be1e4e..fec7348cea2c 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c
> @@ -164,9 +164,9 @@ static void vmw_gmrid_man_debug(struct 
> ttm_mem_type_manager *man,
>  }
>  
>  const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
> - vmw_gmrid_man_init,
> - vmw_gmrid_man_takedown,
> - vmw_gmrid_man_get_node,
> - vmw_gmrid_man_put_node,
> - vmw_gmrid_man_debug
> + .init = vmw_gmrid_man_init,
> + .takedown = vmw_gmrid_man_takedown,
> + .get_node = vmw_gmrid_man_get_node,
> + .put_node = vmw_gmrid_man_put_node,
> + .debug = vmw_gmrid_man_debug
>  };
> -- 
> 2.7.4
> 
> 
> -- 
> Kees Cook
> Nexus Security


[PATCH] gpu: drm: vmwgfx: Use kmemdup instead of kmalloc and memcpy

2016-12-29 Thread Sinclair Yeh
Thanks, applied.

Reviewed-by: Sinclair Yeh 


On Sat, Dec 24, 2016 at 01:21:10AM +0530, Shyam Saini wrote:
> When some other buffer is immediately copied into allocated region.
> Replace calls to kmalloc followed by a memcpy with a direct
> call to kmemdup.
> 
> Signed-off-by: Shyam Saini 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_mob.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
> index b6126a5..941bcfd 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_mob.c
> @@ -319,18 +319,17 @@ int vmw_otables_setup(struct vmw_private *dev_priv)
>   int ret;
>  
>   if (dev_priv->has_dx) {
> - *otables = kmalloc(sizeof(dx_tables), GFP_KERNEL);
> + *otables = kmemdup(dx_tables, sizeof(dx_tables), GFP_KERNEL);
>   if (*otables == NULL)
>   return -ENOMEM;
>  
> - memcpy(*otables, dx_tables, sizeof(dx_tables));
>   dev_priv->otable_batch.num_otables = ARRAY_SIZE(dx_tables);
>   } else {
> - *otables = kmalloc(sizeof(pre_dx_tables), GFP_KERNEL);
> + *otables = kmemdup(pre_dx_tables, sizeof(pre_dx_tables),
> +GFP_KERNEL);
>   if (*otables == NULL)
>   return -ENOMEM;
>  
> - memcpy(*otables, pre_dx_tables, sizeof(pre_dx_tables));
>   dev_priv->otable_batch.num_otables = ARRAY_SIZE(pre_dx_tables);
>   }
>  
> -- 
> 2.7.4
> 


[PATCH 1/7] drm/ttm: don't wait for BO on initial allocation

2016-04-06 Thread Sinclair Yeh
I don't know much about AMD gpu.  Patches 1-6 look good to me.


On Wed, Apr 06, 2016 at 11:12:02AM +0200, Christian König wrote:
> From: Christian König 
> 
> When we use an extern reservation object that otherwise waits for every
> fence registered with it.
> 
> Signed-off-by: Christian König 
> Reviewed-by: Alex Deucher 
> ---
>  drivers/gpu/drm/ttm/ttm_bo.c | 18 --
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 4cbf265..367b87b 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -998,13 +998,19 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object 
> *bo,
>   lockdep_assert_held(&bo->resv->lock.base);
>  
>   /*
> -  * FIXME: It's possible to pipeline buffer moves.
> -  * Have the driver move function wait for idle when necessary,
> -  * instead of doing it here.
> +  * Don't wait for the BO on initial allocation. This is important when
> +  * the BO has an imported reservation object.
>*/
> - ret = ttm_bo_wait(bo, false, interruptible, no_wait_gpu);
> - if (ret)
> - return ret;
> + if (bo->mem.mem_type != TTM_PL_SYSTEM || bo->ttm != NULL) {
> + /*
> +  * FIXME: It's possible to pipeline buffer moves.
> +  * Have the driver move function wait for idle when necessary,
> +  * instead of doing it here.
> +  */
> + ret = ttm_bo_wait(bo, false, interruptible, no_wait_gpu);
> + if (ret)
> + return ret;
> + }
>   mem.num_pages = bo->num_pages;
>   mem.size = mem.num_pages << PAGE_SHIFT;
>   mem.page_alignment = bo->mem.page_alignment;
> -- 
> 2.5.0
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/7] drm/ttm: don't wait for BO on initial allocation

2016-04-13 Thread Sinclair Yeh
rb for 1-6.

I can't really comment on 7.

On Wed, Apr 13, 2016 at 07:38:22PM +0200, Christian König wrote:
> Am 06.04.2016 um 18:06 schrieb Sinclair Yeh:
> >I don't know much about AMD gpu.  Patches 1-6 look good to me.
> 
> Does that count as a Reviewed-by or at least Acked-by?
> 
> Thanks for taking a look,
> Christian.
> 
> >
> >
> >On Wed, Apr 06, 2016 at 11:12:02AM +0200, Christian König wrote:
> >>From: Christian König 
> >>
> >>When we use an extern reservation object that otherwise waits for every
> >>fence registered with it.
> >>
> >>Signed-off-by: Christian König 
> >>Reviewed-by: Alex Deucher 
> >>---
> >>  drivers/gpu/drm/ttm/ttm_bo.c | 18 --
> >>  1 file changed, 12 insertions(+), 6 deletions(-)
> >>
> >>diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> >>index 4cbf265..367b87b 100644
> >>--- a/drivers/gpu/drm/ttm/ttm_bo.c
> >>+++ b/drivers/gpu/drm/ttm/ttm_bo.c
> >>@@ -998,13 +998,19 @@ static int ttm_bo_move_buffer(struct 
> >>ttm_buffer_object *bo,
> >>lockdep_assert_held(&bo->resv->lock.base);
> >>/*
> >>-* FIXME: It's possible to pipeline buffer moves.
> >>-* Have the driver move function wait for idle when necessary,
> >>-* instead of doing it here.
> >>+* Don't wait for the BO on initial allocation. This is important when
> >>+* the BO has an imported reservation object.
> >> */
> >>-   ret = ttm_bo_wait(bo, false, interruptible, no_wait_gpu);
> >>-   if (ret)
> >>-   return ret;
> >>+   if (bo->mem.mem_type != TTM_PL_SYSTEM || bo->ttm != NULL) {
> >>+   /*
> >>+* FIXME: It's possible to pipeline buffer moves.
> >>+* Have the driver move function wait for idle when necessary,
> >>+* instead of doing it here.
> >>+*/
> >>+   ret = ttm_bo_wait(bo, false, interruptible, no_wait_gpu);
> >>+   if (ret)
> >>+   return ret;
> >>+   }
> >>mem.num_pages = bo->num_pages;
> >>mem.size = mem.num_pages << PAGE_SHIFT;
> >>mem.page_alignment = bo->mem.page_alignment;
> >>-- 
> >>2.5.0
> >>
> >>___
> >>dri-devel mailing list
> >>dri-devel at lists.freedesktop.org
> >>https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedesktop.org_mailman_listinfo_dri-2Ddevel&d=BQID-g&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=w9Iu3o4zAy-3-s8MFvrNSQ&m=Zo5YNBtGT5RrPrdJp7kSFSPuSK1Lqnix7D0IkGfYbLs&s=oRLwDN0-euwuXivbCj29GleUbAb6tZnkp5UQZOmDCnM&e=
> 


[PATCH 12/14] MAINTAINERS: Add maintainer entry for the VMWGFX DRM driver

2016-04-22 Thread Sinclair Yeh
Hi,

On Fri, Apr 22, 2016 at 12:04:00AM +0100, Emil Velikov wrote:
> Thomas is one of the original authors of the driver, with recent
> contributions from Sinclair and Brian.
> 
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> Cc: Brian Paul 
> Cc: "VMware Graphics" 
> Signed-off-by: Emil Velikov 
> ---
> Gents can anyone confirm if the data is correct ?

You can also add me as a maintainer for vmwgfx if you like.

> 
> I'm thinking that the status should be Supported, although the driver
> hasn't see much action recently.
> 
> NOTE: The following email linux-graphics-maintainer at vmware.com is also
> listed for the VMMOUSE driver. Is that correct ?

Yes, correct since it's the same team that maintains the vmmouse driver.

Sinclair

> ---
>  MAINTAINERS | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index da88d74..e8ad8b1 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -3909,6 +3909,14 @@ F: drivers/gpu/drm/etnaviv/
>  F:   include/uapi/drm/etnaviv_drm.h
>  F:   Documentation/devicetree/bindings/display/etnaviv/
>  
> +DRM DRIVER FOR VMWARE VIRTUAL GPU
> +M:   "VMware Graphics" 
> +M:   Thomas Hellstrom 
> +L:   dri-devel at lists.freedesktop.org
> +S:   Maintained / Supported
> +F:   drivers/gpu/drm/vmwgfx/
> +F:   include/uapi/drm/vmwgfx_drm.h
> +
>  DSBR100 USB FM RADIO DRIVER
>  M:   Alexey Klimov 
>  L:   linux-media at vger.kernel.org
> -- 
> 2.6.2
> 


[PATCH 24/24] drm/vmwgfx: add extern C guard for the UAPI header

2016-04-22 Thread Sinclair Yeh
Are these going to be ported over to corresponding files in libdrm?

Reviewed-by: Sinclair Yeh 

On Thu, Apr 21, 2016 at 08:42:45PM +0100, Emil Velikov wrote:
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> Cc: Brian Paul 
> Signed-off-by: Emil Velikov 
> ---
>  include/uapi/drm/vmwgfx_drm.h | 9 +
>  1 file changed, 9 insertions(+)
> 
> diff --git a/include/uapi/drm/vmwgfx_drm.h b/include/uapi/drm/vmwgfx_drm.h
> index 5b68b4d..d325a41 100644
> --- a/include/uapi/drm/vmwgfx_drm.h
> +++ b/include/uapi/drm/vmwgfx_drm.h
> @@ -30,6 +30,10 @@
>  
>  #include "drm.h"
>  
> +#if defined(__cplusplus)
> +extern "C" {
> +#endif
> +
>  #define DRM_VMW_MAX_SURFACE_FACES 6
>  #define DRM_VMW_MAX_MIP_LEVELS 24
>  
> @@ -1087,4 +1091,9 @@ union drm_vmw_extended_context_arg {
>   enum drm_vmw_extended_context req;
>   struct drm_vmw_context_arg rep;
>  };
> +
> +#if defined(__cplusplus)
> +}
> +#endif
> +
>  #endif
> -- 
> 2.6.2
> 


Re: [PATCH][drm-next] drm/vmwgfx: remove redundant return ret statement

2018-10-04 Thread Sinclair Yeh
Good catch.

Reviewed-by: Sinclair Yeh 

On Thu, Oct 04, 2018 at 06:49:53PM +0100, Colin King wrote:
> From: Colin Ian King 
> 
> The return statement is redundant as there is a return statement
> immediately before it so we have dead code that can be removed.
> Also remove the unused declaration of ret.
> 
> Detected by CoverityScan, CID#1473793 ("Structurally dead code")
> 
> Signed-off-by: Colin Ian King 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> index 5a6b70ba137a..260650bb5560 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> @@ -1738,7 +1738,6 @@ static int vmw_cmd_check_define_gmrfb(struct 
> vmw_private *dev_priv,
> void *buf)
>  {
>   struct vmw_buffer_object *vmw_bo;
> - int ret;
>  
>   struct {
>   uint32_t header;
> @@ -1748,7 +1747,6 @@ static int vmw_cmd_check_define_gmrfb(struct 
> vmw_private *dev_priv,
>   return vmw_translate_guest_ptr(dev_priv, sw_context,
>  &cmd->body.ptr,
>  &vmw_bo);
> - return ret;
>  }
>  
>  
> -- 
> 2.17.1
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH -next] drm/vmwgfx: Remove set but not used variable 'file_priv'

2018-10-05 Thread Sinclair Yeh

Reviewed-by: Sinclair Yeh 

On Fri, Oct 05, 2018 at 11:36:58AM +, YueHaibing wrote:
> Fixes gcc '-Wunused-but-set-variable' warning:
> 
> drivers/gpu/drm/vmwgfx/vmwgfx_fence.c: In function 
> 'vmw_event_fence_action_seq_passed':
> drivers/gpu/drm/vmwgfx/vmwgfx_fence.c:909:19: warning:
>  variable 'file_priv' set but not used [-Wunused-but-set-variable]
>   struct drm_file *file_priv;
>   
> It not used any more since 
> commit fb740cf2492c ("drm: Create drm_send_event helpers")
> 
> Signed-off-by: YueHaibing 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> index f872615..301260e 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> @@ -906,13 +906,10 @@ static void vmw_event_fence_action_seq_passed(struct 
> vmw_fence_action *action)
>   container_of(action, struct vmw_event_fence_action, action);
>   struct drm_device *dev = eaction->dev;
>   struct drm_pending_event *event = eaction->event;
> - struct drm_file *file_priv;
> -
>  
>   if (unlikely(event == NULL))
>   return;
>  
> - file_priv = event->file_priv;
>   spin_lock_irq(&dev->event_lock);
>  
>   if (likely(eaction->tv_sec != NULL)) {
> 
> 
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


  1   2   >