Re: [PATCH v3 02/18] drm: Add a new helper to validate damage during atomic_check

2018-10-15 Thread Sinclair Yeh
On Wed, Oct 10, 2018 at 05:16:41PM -0700, Deepak Rawat wrote:
> This helper function makes sure that damage from plane state is
> discarded for full modeset cycle. For some reason, which makes damage
> irrelevant, driver might want to do a full plane update for e.g. full
> modeset. Such cases must be checked here.
> 
> Cc: ville.syrj...@linux.intel.com
> Cc: Daniel Vetter 
> Cc: Pekka Paalanen 
> Cc: Daniel Stone 
> Signed-off-by: Deepak Rawat 
> ---
>  drivers/gpu/drm/drm_atomic_helper.c |  3 +++
>  drivers/gpu/drm/drm_damage_helper.c | 38 +
>  include/drm/drm_damage_helper.h |  2 ++
>  3 files changed, 43 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> b/drivers/gpu/drm/drm_atomic_helper.c
> index 35395577ca86..41dabb817c57 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -32,6 +32,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include "drm_crtc_helper_internal.h"
> @@ -828,6 +829,8 @@ drm_atomic_helper_check_planes(struct drm_device *dev,
>  
>   drm_atomic_helper_plane_changed(state, old_plane_state, 
> new_plane_state, plane);
>  
> + drm_atomic_helper_check_plane_damage(state, new_plane_state);
> +
>   if (!funcs || !funcs->atomic_check)
>   continue;
>  
> diff --git a/drivers/gpu/drm/drm_damage_helper.c 
> b/drivers/gpu/drm/drm_damage_helper.c
> index 8dc906a489a9..c130514bbb21 100644
> --- a/drivers/gpu/drm/drm_damage_helper.c
> +++ b/drivers/gpu/drm/drm_damage_helper.c
> @@ -29,6 +29,7 @@
>   *
>   **/
>  
> +#include 
>  #include 
>  
>  /**
> @@ -81,3 +82,40 @@ void drm_plane_enable_fb_damage_clips(struct drm_plane 
> *plane)
>  0);
>  }
>  EXPORT_SYMBOL(drm_plane_enable_fb_damage_clips);
> +
> +/**
> + * drm_atomic_helper_check_plane_damage - Verify plane damage on 
> atomic_check.
> + * @state: The driver state object.
> + * @plane_state: Plane state for which to verify damage.
> + *
> + * This helper function makes sure that damage from plane state is discarded
> + * for full modeset cycle. For some reason, which makes damage irrelevant,
  remove "cycle" ^ ^Reads weird.. maybe...

 "If there are more reasons a driver would want to do a full plane
  update rather than processing individual damage regions, then
  those cases should be taken care of here."

> + * driver might want to do a full plane update for e.g. full modeset. Such
> + * cases must be checked here. Note that NULL 
> _plane_state.fb_damage_clips
^ drm_plane_state.fb_damage_clips 
== NULL

> + * in plane state means that full update should happen. It also ensue helper
   ^ ensure(?) 
that the
> + * iterator to return _plane_state.src as damage.
   ^s/to/will


> + *
> + * Currently this helper discard damage during full modeset only. This is
^ discards

The rest of the paragraph reads kind of strange, and pretty much repeats
what has already been said, so maybe just remove it?

> + * because, presently only vmwgfx exposes damage interface, which need full
> + * plane update during full modeset only. As more driver add damage support,
> + * should any state change need full plane update, must be added here.
> + */
> +void drm_atomic_helper_check_plane_damage(struct drm_atomic_state *state,
> +   struct drm_plane_state *plane_state)
> +{
> + struct drm_crtc_state *crtc_state;
> +
> + if (plane_state->crtc) {
> + crtc_state = drm_atomic_get_new_crtc_state(state,
> +plane_state->crtc);
> +
> + if (WARN_ON(!crtc_state))
> + return;
> +
> + if (drm_atomic_crtc_needs_modeset(crtc_state)) {
> + drm_property_blob_put(plane_state->fb_damage_clips);
> + plane_state->fb_damage_clips = NULL;
> + }
> + }
> +}
> +EXPORT_SYMBOL(drm_atomic_helper_check_plane_damage);
> diff --git a/include/drm/drm_damage_helper.h b/include/drm/drm_damage_helper.h
> index 4947c614fff9..59584cbf3d40 100644
> --- a/include/drm/drm_damage_helper.h
> +++ b/include/drm/drm_damage_helper.h
> @@ -35,5 +35,7 @@
>  #include 
>  
>  void drm_plane_enable_fb_damage_clips(struct drm_plane *plane);
> +void drm_atomic_helper_check_plane_damage(struct drm_atomic_state *state,
> +   struct drm_plane_state *plane_state);
>  
>  #endif
> -- 
> 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(>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


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,
>  >body.ptr,
>  _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 v3 10/10] drm/vmwgfx: Use __drm_atomic_helper_plane_reset instead of copying the logic

2018-08-07 Thread Sinclair Yeh
On Tue, Aug 07, 2018 at 09:03:27AM +0100, Alexandru-Cosmin Gheorghe wrote:
> Hi Sinclair,
> 
> Is it ok if I merge this patch through drm-misc-next ?

Sure. Thanks for handling this.

Sinclair

> Thank you,
> Alex Gheorghe
> 
> On Mon, Aug 06, 2018 at 09:57:53AM -0700, Sinclair Yeh wrote:
> > Acked-by: Sinclair Yeh 
> > 
> > On Sat, Aug 04, 2018 at 05:15:30PM +0100, Alexandru Gheorghe wrote:
> > > A new helper function(__drm_atomic_helper_plane_reset) has been added
> > > for linking a plane with its state and resetting the core
> > > properties(alpha, rotation, etc.) to their default values.
> > > Use that instead of duplicating the logic.
> > > 
> > > Reviewed-by: Sinclair Yeh 
> > > Reviewed-by: Deepak Rawat 
> > > Signed-off-by: Alexandru Gheorghe 
> > > ---
> > >  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 4 +---
> > >  1 file changed, 1 insertion(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
> > > b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > > index 4a0f0f41afa1..61824e360619 100644
> > > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > > @@ -720,9 +720,7 @@ void vmw_du_plane_reset(struct drm_plane *plane)
> > >   return;
> > >   }
> > >  
> > > - plane->state = >base;
> > > - plane->state->plane = plane;
> > > - plane->state->rotation = DRM_MODE_ROTATE_0;
> > > + __drm_atomic_helper_plane_reset(plane, >base);
> > >  }
> > >  
> > >  
> > > -- 
> > > 2.18.0
> > > 
> 
> -- 
> Cheers,
> Alex G
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 10/10] drm/vmwgfx: Use __drm_atomic_helper_plane_reset instead of copying the logic

2018-08-06 Thread Sinclair Yeh
Acked-by: Sinclair Yeh 

On Sat, Aug 04, 2018 at 05:15:30PM +0100, Alexandru Gheorghe wrote:
> A new helper function(__drm_atomic_helper_plane_reset) has been added
> for linking a plane with its state and resetting the core
> properties(alpha, rotation, etc.) to their default values.
> Use that instead of duplicating the logic.
> 
> Reviewed-by: Sinclair Yeh 
> Reviewed-by: Deepak Rawat 
> Signed-off-by: Alexandru Gheorghe 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index 4a0f0f41afa1..61824e360619 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -720,9 +720,7 @@ void vmw_du_plane_reset(struct drm_plane *plane)
>   return;
>   }
>  
> - plane->state = >base;
> - plane->state->plane = plane;
> - plane->state->rotation = DRM_MODE_ROTATE_0;
> + __drm_atomic_helper_plane_reset(plane, >base);
>  }
>  
>  
> -- 
> 2.18.0
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 10/10] drm/vmwgfx: Use __drm_atomic_helper_plane_reset instead of copying the logic

2018-07-23 Thread Sinclair Yeh
Hello Alex,

other than adding a brief commit message to this patch,

Reviewed-by: Sinclair Yeh 

On Fri, Jul 20, 2018 at 10:15:09PM +0100, Alexandru Gheorghe wrote:
> Signed-off-by: Alexandru Gheorghe 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index 466336b34fff..1e0fb3c79b50 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -720,9 +720,7 @@ void vmw_du_plane_reset(struct drm_plane *plane)
>   return;
>   }
>  
> - plane->state = >base;
> - plane->state->plane = plane;
> - plane->state->rotation = DRM_MODE_ROTATE_0;
> + __drm_atomic_helper_plane_reset(plane, >base);
>  }
>  
>  
> -- 
> 2.18.0
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/ttm: use swap macro in ttm_bo_handle_move_mem

2018-07-13 Thread Sinclair Yeh
On Fri, Jul 13, 2018 at 08:41:37AM +0200, Christian König wrote:
> Am 13.07.2018 um 04:37 schrieb Sinclair Yeh:
> >On Mon, Jul 09, 2018 at 10:24:47AM -0500, Gustavo A. R. Silva wrote:
> >>Make use of the swap macro and remove unnecessary variable *tmp_mem*.
> >>This makes the code easier to read and maintain. Also, reduces the
> >>stack usage.
> >>
> >>This code was detected with the help of Coccinelle.
> >>
> >>Signed-off-by: Gustavo A. R. Silva 
> >>---
> >>  drivers/gpu/drm/ttm/ttm_bo.c | 7 ++-
> >>  1 file changed, 2 insertions(+), 5 deletions(-)
> >>
> >>diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> >>index 5d8688e52..5142dcb 100644
> >>--- a/drivers/gpu/drm/ttm/ttm_bo.c
> >>+++ b/drivers/gpu/drm/ttm/ttm_bo.c
> >>@@ -287,12 +287,9 @@ static int ttm_bo_handle_move_mem(struct 
> >>ttm_buffer_object *bo,
> >>if (ret) {
> >>if (bdev->driver->move_notify) {
> >>-   struct ttm_mem_reg tmp_mem = *mem;
> >>-   *mem = bo->mem;
> >>-   bo->mem = tmp_mem;
> >>+   swap(*mem, bo->mem);
> >>bdev->driver->move_notify(bo, false, mem);
> >>-   bo->mem = *mem;
> >>-   *mem = tmp_mem;
> >>+   swap(*mem, bo->mem);
> >This code assumes bo->mem is the same as tmp_mem after the call to
> >move_notify. Is this always true?
> 
> Actually the old code assumed that. Using the swap macro now fixed that
> little unclean implementation.

Ok, thanks for the clarification.  This looks good to me.

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


Re: [PATCH] drm/ttm: use swap macro in ttm_bo_handle_move_mem

2018-07-12 Thread Sinclair Yeh
On Mon, Jul 09, 2018 at 10:24:47AM -0500, Gustavo A. R. Silva wrote:
> Make use of the swap macro and remove unnecessary variable *tmp_mem*.
> This makes the code easier to read and maintain. Also, reduces the
> stack usage.
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva 
> ---
>  drivers/gpu/drm/ttm/ttm_bo.c | 7 ++-
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 5d8688e52..5142dcb 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -287,12 +287,9 @@ static int ttm_bo_handle_move_mem(struct 
> ttm_buffer_object *bo,
>  
>   if (ret) {
>   if (bdev->driver->move_notify) {
> - struct ttm_mem_reg tmp_mem = *mem;
> - *mem = bo->mem;
> - bo->mem = tmp_mem;
> + swap(*mem, bo->mem);
>   bdev->driver->move_notify(bo, false, mem);
> - bo->mem = *mem;
> - *mem = tmp_mem;
> + swap(*mem, bo->mem);

This code assumes bo->mem is the same as tmp_mem after the call to
move_notify. Is this always true?



>   }
>  
>   goto out_err;
> -- 
> 2.7.4
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-develdata=02%7C01%7Csyeh%40vmware.com%7C3bd79878de5141b5187408d5e6326e6d%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C1%7C0%7C636668026634710967sdata=2raJ6TBpcEM5W7hi8iCEnrEdcfJa3W5ct3tF%2BlSZLkQ%3Dreserved=0
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 10/10] drm/vmwgfx: Use drm_plane_mask() & co.

2018-07-02 Thread Sinclair Yeh
Reviewed-by: Sinclair Yeh 

I assume you'll upstream this as part of your series?

On Tue, Jun 26, 2018 at 10:47:16PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä 
> 
> Use drm_{plane,connector}_mask() where appropriate.
> 
> Cc: VMware Graphics 
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> Signed-off-by: Ville Syrjälä 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index ef96ba7432ad..17e01423ead1 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -535,9 +535,9 @@ 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(>connector);
> + int connector_mask = drm_connector_mask(>connector);
>   bool has_primary = new_state->plane_mask &
> -BIT(drm_plane_index(crtc->primary));
> +drm_plane_mask(crtc->primary);
>  
>   /* We always want to have an active plane with an active CRTC */
>   if (has_primary != new_state->enable)
> -- 
> 2.16.4
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 02/13] drm/vmwgfx: Stop using plane->fb in vmw_kms_helper_dirty()

2018-06-04 Thread Sinclair Yeh
On Wed, May 30, 2018 at 11:08:57PM +0300, Ville Syrjälä wrote:
> On Fri, May 25, 2018 at 09:50:34PM +0300, Ville Syrjala wrote:
> > From: Ville Syrjälä 
> > 
> > Instead of plane->fb (which we're going to deprecate for atomic drivers)
> > we need to look at plane->state->fb. The maze of code leading to
> > vmw_kms_helper_dirty() wasn't particularly clear, but my analysis
> > concluded that the calls originating from 
> > vmw_*_primary_plane_atomic_update()
> > all pass in the crtc which means we'll never end up in this branch
> > of the function. All other callers use drm_modeset_lock_all() somewhere
> > higher up, which means accessing plane->state is safe. We'll toss in
> > a lockdep assert to catch wrongdoers.
> > 
> > v2: Drop the comment and make the code do what it did before (Thomas)
> > 
> > Cc: Deepak Rawat 
> > Cc: Thomas Hellstrom 
> > Cc: Sinclair Yeh 
> > Cc: VMware Graphics 
> > Cc: Daniel Vetter 
> > Signed-off-by: Ville Syrjälä 
> > ---
> >  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 9 ++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
> > b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > index 2e4c38bb846d..5417eb1b486e 100644
> > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> > @@ -2326,9 +2326,12 @@ int vmw_kms_helper_dirty(struct vmw_private 
> > *dev_priv,
> > } else {
> > list_for_each_entry(crtc, _priv->dev->mode_config.crtc_list,
> > head) {
> > -   if (crtc->primary->fb != >base)
> > -   continue;
> > -   units[num_units++] = vmw_crtc_to_du(crtc);
> > +   struct drm_plane *plane = crtc->primary;
> > +
> > +   lockdep_assert_held(>mutex);
> 
> kbuild test robot told me
> >> include/linux/lockdep.h:347:52: error: 'struct drm_modeset_lock' has
> >> no member named 'dep_map'  
> #define lockdep_is_held(lock)  lock_is_held(&(lock)->dep_map) 
>  
> 
> Maybe I'll just drop the asserts? Or do people really want them
> (in which case I gues I need to dig out the underlying mutex)?

Eitherway is fine with me.


> 
> > +
> > +   if (plane->state->fb == >base)
> > +   units[num_units++] = vmw_crtc_to_du(crtc);
> > }
> > }
> >  
> > -- 
> > 2.16.1
> 
> -- 
> Ville Syrjälä
> Intel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 00/13] drm: Eliminate plane->fb/crtc usage for atomic drivers

2018-05-30 Thread Sinclair Yeh
Thanks Ville.

This series: Reviewed-by: Sinclair Yeh 

On Fri, May 25, 2018 at 09:50:32PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä 
> 
> Here are again the last (?) bits of eliminating the plane->fb/crtc
> usage for atomic drivers. I've pushed everything else (thanks to
> everyone who reviewed them). 
> 
> Deepak said he'd tested the vmwgfx stuff, so I think it should be
> safe to land. Just missing a bit of review...
> 
> Cc: Alex Deucher 
> Cc: amd-...@lists.freedesktop.org
> Cc: "Christian König" 
> Cc: Daniel Vetter 
> Cc: David Airlie 
> Cc: "David (ChunMing) Zhou" 
> Cc: Deepak Rawat 
> Cc: Eric Anholt 
> Cc: freedr...@lists.freedesktop.org
> Cc: Gerd Hoffmann 
> Cc: Harry Wentland 
> Cc: Inki Dae 
> Cc: Joonyoung Shim 
> Cc: Kyungmin Park 
> Cc: linux-arm-...@vger.kernel.org
> Cc: Rob Clark 
> Cc: Seung-Woo Kim 
> Cc: Sinclair Yeh 
> Cc: Thomas Hellstrom 
> Cc: virtualizat...@lists.linux-foundation.org
> Cc: VMware Graphics 
> 
> Ville Syrjälä (13):
>   drm/vmwgfx: Stop using plane->fb in vmw_kms_atomic_check_modeset()
>   drm/vmwgfx: Stop using plane->fb in vmw_kms_helper_dirty()
>   drm/vmwgfx: Stop using plane->fb in vmw_kms_update_implicit_fb()
>   drm/vmwgfx: Stop updating plane->fb
>   drm/vmwgfx: Stop using plane->fb in atomic_enable()
>   drm/vmwgfx: Stop messing about with plane->fb/old_fb/crtc
>   drm/amdgpu/dc: Stop updating plane->fb
>   drm/i915: Stop updating plane->fb/crtc
>   drm/exynos: Stop updating plane->crtc
>   drm/msm: Stop updating plane->fb/crtc
>   drm/virtio: Stop updating plane->crtc
>   drm/vc4: Stop updating plane->fb/crtc
>   drm: Stop updating plane->crtc/fb/old_fb on atomic drivers
> 
>  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  2 -
>  drivers/gpu/drm/drm_atomic.c  | 55 
> +++
>  drivers/gpu/drm/drm_atomic_helper.c   | 15 +--
>  drivers/gpu/drm/drm_crtc.c|  8 +++-
>  drivers/gpu/drm/drm_fb_helper.c   |  7 ---
>  drivers/gpu/drm/drm_framebuffer.c |  5 ---
>  drivers/gpu/drm/drm_plane.c   | 14 +++---
>  drivers/gpu/drm/drm_plane_helper.c|  4 +-
>  drivers/gpu/drm/exynos/exynos_drm_plane.c |  2 -
>  drivers/gpu/drm/i915/intel_atomic_plane.c | 12 -
>  drivers/gpu/drm/i915/intel_display.c  |  7 ++-
>  drivers/gpu/drm/msm/disp/mdp4/mdp4_crtc.c |  1 -
>  drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c|  2 -
>  drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c |  1 -
>  drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c|  2 -
>  drivers/gpu/drm/vc4/vc4_crtc.c|  3 --
>  drivers/gpu/drm/virtio/virtgpu_display.c  |  2 -
>  drivers/gpu/drm/vmwgfx/vmwgfx_fb.c| 24 --
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c   | 24 +++---
>  drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c  |  2 -
>  drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c  |  5 +--
>  include/drm/drm_atomic.h  |  3 --
>  22 files changed, 46 insertions(+), 154 deletions(-)
> 
> -- 
> 2.16.1
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [RFC 2/3] drm: Add helper iterator functions to iterate over plane damage.

2018-04-05 Thread Sinclair Yeh
On Wed, Apr 04, 2018 at 04:49:07PM -0700, Deepak Rawat wrote:
> With damage property in drm_plane_state, this patch adds helper iterator
> to traverse the damage clips. Iterator will return the damage rectangles
> in framebuffer, plane or crtc coordinates as need by driver
> implementation.
> 
> Signed-off-by: Deepak Rawat 
> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 122 
> 
>  include/drm/drm_atomic_helper.h |  39 
>  2 files changed, 161 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
> b/drivers/gpu/drm/drm_atomic_helper.c
> index 55b44e3..355b514 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -3865,3 +3865,125 @@ void 
> __drm_atomic_helper_private_obj_duplicate_state(struct drm_private_obj *obj
>   memcpy(state, obj->state, sizeof(*state));
>  }
>  EXPORT_SYMBOL(__drm_atomic_helper_private_obj_duplicate_state);
> +
> +/**
> + * drm_atomic_helper_damage_iter_init - initialize the damage iterator
> + * @iter: The iterator to initialize.
> + * @type: Coordinate type caller is interested in.
> + * @state: plane_state from which to iterate the damage clips.
> + * @hdisplay: Width of crtc on which plane is scanned out.
> + * @vdisplay: Height of crtc on which plane is scanned out.
> + *
> + * Initialize an iterator that is used to translate and clip a set of damage
> + * rectangles in framebuffer coordinates to plane and crtc coordinates. The 
> type
> + * argument specify which type of coordinate to iterate in.
> + *
> + * Returns: 0 on success and negative error code on error. If an error code 
> is
> + * returned then it means the plane state should not update.
> + */
> +int
> +drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter 
> *iter,
> +enum drm_atomic_helper_damage_clip_type type,
> +const struct drm_plane_state *state,
> +uint32_t hdisplay, uint32_t vdisplay)
> +{
> + if (!state || !state->crtc || !state->fb)
> + return -EINVAL;
> +
> + memset(iter, 0, sizeof(*iter));
> + iter->clips = (struct drm_rect *)state->damage_clips->data;
> + iter->num_clips = state->num_clips;
> + iter->type = type;
> +
> + /*
> +  * Full update in case of scaling or rotation. In future support for
> +  * scaling/rotating damage clips can be added
> +  */
> + if (state->crtc_w != (state->src_w >> 16) ||
> + state->crtc_h != state->src_h >> 16 || state->rotation != 0) {
> + iter->curr_clip = iter->num_clips;
> + return 0;
> + }
> +
> + iter->fb_src.x1 = 0;
> + iter->fb_src.y1 = 0;
> + iter->fb_src.x2 = state->fb->width;
> + iter->fb_src.y2 = state->fb->height;
> +
> + iter->plane_src.x1 = state->src_x >> 16;
> + iter->plane_src.y1 = state->src_y >> 16;
> + iter->plane_src.x2 = iter->plane_src.x1 + (state->src_w >> 16);
> + iter->plane_src.y2 = iter->plane_src.y1 + (state->src_h >> 16);
> + iter->translate_plane_x = -iter->plane_src.x1;
> + iter->translate_plane_y = -iter->plane_src.y1;
> +
> + /* Clip plane src rect to fb dimensions */
> + drm_rect_intersect(>plane_src, >fb_src);
> +
> + iter->crtc_src.x1 = 0;
> + iter->crtc_src.y1 = 0;
> + iter->crtc_src.x2 = hdisplay;
> + iter->crtc_src.y2 = vdisplay;
> + iter->translate_crtc_x = -(iter->plane_src.x1 - state->crtc_x);
> + iter->translate_crtc_x = -(iter->plane_src.y1 - state->crtc_y);
   ^
I believe you mean translate_crtc_y here


> +
> + /* Clip crtc src rect to plane dimensions */
> + drm_rect_translate(>crtc_src, -iter->translate_crtc_x,
> +-iter->translate_crtc_x);
Also here^


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


Re: [Outreachy kernel] [PATCH DRM] drm: Introduce drm_global_item_{get/put}()

2018-03-20 Thread Sinclair Yeh

LGTM

thanks!

Sinclair

On Mon, Mar 19, 2018 at 10:06:20PM +0100, Daniel Vetter wrote:
> On Tue, Mar 13, 2018 at 1:02 PM, Haneen Mohammed
>  wrote:
> > For consistency with other reference counting APIs in the kernel,
> > introduce drm_global_item_{get/put} functions instead of
> > drm_global_item_{ref/unref}.
> >
> > Compatibility aliases are added to keep existing code working.
> >
> > The semantic patch scripts/coccinelle/api/drm-get-put.cocci has been
> > extended to account for the new helpers.
> >
> > Signed-off-by: Haneen Mohammed 
> 
> Somehow this fell through the cracks. drm_global.c is only used by ttm
> and vmwgfx, adding relevant maintainers.
> -Daniel
> 
> > ---
> >  drivers/gpu/drm/drm_global.c | 43 
> > +++-
> >  include/drm/drm_global.h |  2 ++
> >  scripts/coccinelle/api/drm-get-put.cocci | 10 
> >  3 files changed, 49 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
> > index b2dc21e..76cf948 100644
> > --- a/drivers/gpu/drm/drm_global.c
> > +++ b/drivers/gpu/drm/drm_global.c
> > @@ -64,7 +64,7 @@ void drm_global_release(void)
> >  }
> >
> >  /**
> > - * drm_global_item_ref - Initialize and acquire reference to memory
> > + * drm_global_item_get - Initialize and acquire reference to memory
> >   * object
> >   * @ref: Object for initialization
> >   *
> > @@ -75,7 +75,7 @@ void drm_global_release(void)
> >   * Returns:
> >   * Zero on success, non-zero otherwise.
> >   */
> > -int drm_global_item_ref(struct drm_global_reference *ref)
> > +int drm_global_item_get(struct drm_global_reference *ref)
> >  {
> > int ret = 0;
> > struct drm_global_item *item = [ref->global_type];
> > @@ -107,10 +107,10 @@ int drm_global_item_ref(struct drm_global_reference 
> > *ref)
> > mutex_unlock(>mutex);
> > return ret;
> >  }
> > -EXPORT_SYMBOL(drm_global_item_ref);
> > +EXPORT_SYMBOL(drm_global_item_get);
> >
> >  /**
> > - * drm_global_item_unref - Drop reference to memory
> > + * drm_global_item_put - Drop reference to memory
> >   * object
> >   * @ref: Object being removed
> >   *
> > @@ -120,7 +120,7 @@ EXPORT_SYMBOL(drm_global_item_ref);
> >   *
> >   */
> >
> > -void drm_global_item_unref(struct drm_global_reference *ref)
> > +void drm_global_item_put(struct drm_global_reference *ref)
> >  {
> > struct drm_global_item *item = [ref->global_type];
> >
> > @@ -133,5 +133,36 @@ void drm_global_item_unref(struct drm_global_reference 
> > *ref)
> > }
> > mutex_unlock(>mutex);
> >  }
> > -EXPORT_SYMBOL(drm_global_item_unref);
> > +EXPORT_SYMBOL(drm_global_item_put);
> >
> > +/**
> > + * drm_global_item_ref - Initialize and acquire reference to memory
> > + * object
> > + * @ref: Object for initialization
> > + *
> > + * This is a compatibility alias for drm_global_item_get() and should
> > + * not be used by new code.
> > + *
> > + * Returns:
> > + * Zero on success, non-zero otherwise.
> > + */
> > +int drm_global_item_ref(struct drm_global_reference *ref)
> > +{
> > +   return drm_global_item_get(ref);
> > +}
> > +EXPORT_SYMBOL(drm_global_item_ref);
> > +
> > +/**
> > + * drm_global_item_unref - Drop reference to memory
> > + * object
> > + * @ref: Object being removed
> > + *
> > + * This is a compatibility alias for drm_global_item_get() and should not
> > + * be used by new code.
> > + */
> > +
> > +void drm_global_item_unref(struct drm_global_reference *ref)
> > +{
> > +   drm_global_item_put(ref);
> > +}
> > +EXPORT_SYMBOL(drm_global_item_unref);
> > diff --git a/include/drm/drm_global.h b/include/drm/drm_global.h
> > index 3a83060..5eb6f0c 100644
> > --- a/include/drm/drm_global.h
> > +++ b/include/drm/drm_global.h
> > @@ -47,6 +47,8 @@ struct drm_global_reference {
> >
> >  void drm_global_init(void);
> >  void drm_global_release(void);
> > +int drm_global_item_get(struct drm_global_reference *ref);
> > +void drm_global_item_put(struct drm_global_reference *ref);
> >  int drm_global_item_ref(struct drm_global_reference *ref);
> >  void drm_global_item_unref(struct drm_global_reference *ref);
> >
> > diff --git a/scripts/coccinelle/api/drm-get-put.cocci 
> > b/scripts/coccinelle/api/drm-get-put.cocci
> > index 91fceb8..db1c465 100644
> > --- a/scripts/coccinelle/api/drm-get-put.cocci
> > +++ b/scripts/coccinelle/api/drm-get-put.cocci
> > @@ -54,6 +54,12 @@ expression object;
> >  |
> >  - drm_dev_unref(object)
> >  + drm_dev_put(object)
> > +|
> > +- drm_global_item_ref(object)
> > ++ drm_global_item_get(object)
> > +|
> > +- drm_global_item_unref(object)
> > ++ drm_global_item_put(object)
> >  )
> >
> >  @r depends on report@
> > @@ -87,6 +93,10 @@ drm_property_unreference_blob@p(object)
> >  drm_property_reference_blob@p(object)
> >  |
> >  drm_dev_unref@p(object)
> > +|
> > +drm_global_item_ref@p(object)
> > +|
> > +drm_global_item_unref@p(object)
> >  )

Re: [PATCH] drm/vmwgfx: Use kasprintf

2018-03-12 Thread Sinclair Yeh
Thanks!

Reviewed-by: Sinclair Yeh <s...@vmware.com>

On Wed, Mar 07, 2018 at 11:33:22PM +0530, Himanshu Jha wrote:
> Use kasprintf instead of combination of kmalloc and sprintf. Also,
> remove the local variables used for storing the string length as they
> are not required now.
> 
> Signed-off-by: Himanshu Jha <himanshujha199...@gmail.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 13 +++--
>  1 file changed, 3 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
> index 9700099..cdff992 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c
> @@ -328,7 +328,7 @@ int vmw_host_get_guestinfo(const char *guest_info_param,
>  {
>   struct rpc_channel channel;
>   char *msg, *reply = NULL;
> - size_t msg_len, reply_len = 0;
> + size_t reply_len = 0;
>   int ret = 0;
>  
>  
> @@ -338,15 +338,12 @@ int vmw_host_get_guestinfo(const char *guest_info_param,
>   if (!guest_info_param || !length)
>   return -EINVAL;
>  
> - msg_len = strlen(guest_info_param) + strlen("info-get ") + 1;
> - msg = kzalloc(msg_len, GFP_KERNEL);
> + msg = kasprintf(GFP_KERNEL, "info-get %s", guest_info_param);
>   if (!msg) {
>   DRM_ERROR("Cannot allocate memory to get %s", guest_info_param);
>   return -ENOMEM;
>   }
>  
> - sprintf(msg, "info-get %s", guest_info_param);
> -
>   if (vmw_open_channel(, RPCI_PROTOCOL_NUM) ||
>   vmw_send_msg(, msg) ||
>   vmw_recv_msg(, (void *) , _len) ||
> @@ -388,7 +385,6 @@ int vmw_host_log(const char *log)
>  {
>   struct rpc_channel channel;
>   char *msg;
> - int msg_len;
>   int ret = 0;
>  
>  
> @@ -398,15 +394,12 @@ int vmw_host_log(const char *log)
>   if (!log)
>   return ret;
>  
> - msg_len = strlen(log) + strlen("log ") + 1;
> - msg = kzalloc(msg_len, GFP_KERNEL);
> + msg = kasprintf(GFP_KERNEL, "log %s", log);
>   if (!msg) {
>   DRM_ERROR("Cannot allocate memory for log message\n");
>   return -ENOMEM;
>   }
>  
> - sprintf(msg, "log %s", log);
> -
>   if (vmw_open_channel(, RPCI_PROTOCOL_NUM) ||
>   vmw_send_msg(, msg) ||
>   vmw_close_channel()) {
> -- 
> 2.7.4
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH DRM] drm/vmwgfx: replace drm_*_unreference with drm_*_put

2018-03-12 Thread Sinclair Yeh
Hi Daniel,


On Mon, Mar 12, 2018 at 06:34:43PM +0100, Daniel Vetter wrote:
> On Sun, Mar 11, 2018 at 05:33:13PM -0600, Haneen Mohammed wrote:
> > This patch replace instances of drm_framebuffer_unreference with _put()
> > suffix, because it is shorter and consistent with the kernel use of
> > *_get/put() suffixes.
> > This was done with the following Coccinelle script:
> > 
> > @r@
> > expression e;
> > @@
> > 
> > (
> > -drm_framebuffer_reference(e);
> > +drm_framebuffer_get(e);
> > |
> > -drm_framebuffer_unreference(e);
> > +drm_framebuffer_put(e);
> > )
> > 
> > Signed-off-by: Haneen Mohammed 
> 
> Reviewed-by: Daniel Vetter 
> 
> Sinclair/Thomas: Ok if I pull this in through drm-misc? Makes outreachy
> applicant book-keeping easier since iirc the vmwgfx tree isn't in
> linux-next. But ok if you want to merge it too.

Yes, drm-misc is fine.

Thanks!

Sinclair

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


Re: [PATCH 2/7] drm/ttm: use an operation ctx for ttm_mem_global_alloc

2018-01-24 Thread Sinclair Yeh
Hi,

Sorry, I've been on a leave.  Catching up on emails.

In case this is still not yet merged, my comment is
be consist with the new variable name.  In some cases
it's "ttm_opt_ctx", in others it's "ctx".

I prefer ttm_opt_ctx because it's more descriptive.

And yes, some description on why this change is necessary in the
commit message is nice, too.

Sinclair

On Wed, Dec 20, 2017 at 02:33:37PM +0100, Christian König wrote:
> Commit message needed! Something like:
> 
> Forward the operation context to ttm_mem_global_alloc as well.
> 
> Am 20.12.2017 um 11:34 schrieb Roger He:
> > Change-Id: I5279b5cd3560c4082b00f822219575a5f9c3808a
> > Signed-off-by: Roger He 
> 
> With the commit message fixed, patch is Reviewed-by: Christian König
> .
> 
> I would like to get an rb or ab from Thomas and/or Sinclair as well, since
> this is touching a lot of vmwgfx code.
> 
> Regards,
> Christian.
> 
> > ---
> >   drivers/gpu/drm/ttm/ttm_bo.c|  2 +-
> >   drivers/gpu/drm/ttm/ttm_memory.c| 15 +--
> >   drivers/gpu/drm/ttm/ttm_object.c| 13 ++---
> >   drivers/gpu/drm/vmwgfx/vmwgfx_binding.c |  6 +-
> >   drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c  | 13 ++---
> >   drivers/gpu/drm/vmwgfx/vmwgfx_context.c |  6 +-
> >   drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c |  6 +-
> >   drivers/gpu/drm/vmwgfx/vmwgfx_fence.c   |  6 +-
> >   drivers/gpu/drm/vmwgfx/vmwgfx_shader.c  | 18 +++---
> >   drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c |  6 +-
> >   drivers/gpu/drm/vmwgfx/vmwgfx_so.c  |  6 +-
> >   drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 12 ++--
> >   include/drm/ttm/ttm_memory.h|  3 ++-
> >   13 files changed, 87 insertions(+), 25 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> > index fa57aa8..c59f572 100644
> > --- a/drivers/gpu/drm/ttm/ttm_bo.c
> > +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> > @@ -1133,7 +1133,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev,
> > struct ttm_mem_global *mem_glob = bdev->glob->mem_glob;
> > bool locked;
> > -   ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false);
> > +   ret = ttm_mem_global_alloc(mem_glob, acc_size, ctx);
> > if (ret) {
> > pr_err("Out of kernel memory\n");
> > if (destroy)
> > diff --git a/drivers/gpu/drm/ttm/ttm_memory.c 
> > b/drivers/gpu/drm/ttm/ttm_memory.c
> > index 9130bdf..525d3b6 100644
> > --- a/drivers/gpu/drm/ttm/ttm_memory.c
> > +++ b/drivers/gpu/drm/ttm/ttm_memory.c
> > @@ -508,7 +508,7 @@ static int ttm_mem_global_reserve(struct ttm_mem_global 
> > *glob,
> >   static int ttm_mem_global_alloc_zone(struct ttm_mem_global *glob,
> >  struct ttm_mem_zone *single_zone,
> >  uint64_t memory,
> > -bool no_wait, bool interruptible)
> > +struct ttm_operation_ctx *ctx)
> >   {
> > int count = TTM_MEMORY_ALLOC_RETRIES;
> > @@ -516,7 +516,7 @@ static int ttm_mem_global_alloc_zone(struct 
> > ttm_mem_global *glob,
> >single_zone,
> >memory, true)
> > != 0)) {
> > -   if (no_wait)
> > +   if (ctx->no_wait_gpu)
> > return -ENOMEM;
> > if (unlikely(count-- == 0))
> > return -ENOMEM;
> > @@ -527,15 +527,14 @@ static int ttm_mem_global_alloc_zone(struct 
> > ttm_mem_global *glob,
> >   }
> >   int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory,
> > -bool no_wait, bool interruptible)
> > +struct ttm_operation_ctx *ctx)
> >   {
> > /**
> >  * Normal allocations of kernel memory are registered in
> >  * all zones.
> >  */
> > -   return ttm_mem_global_alloc_zone(glob, NULL, memory, no_wait,
> > -interruptible);
> > +   return ttm_mem_global_alloc_zone(glob, NULL, memory, ctx);
> >   }
> >   EXPORT_SYMBOL(ttm_mem_global_alloc);
> > @@ -544,6 +543,10 @@ int ttm_mem_global_alloc_page(struct ttm_mem_global 
> > *glob,
> >   {
> > struct ttm_mem_zone *zone = NULL;
> > +   struct ttm_operation_ctx ctx = {
> > +   .interruptible = false,
> > +   .no_wait_gpu = false
> > +   };
> > /**
> >  * Page allocations may be registed in a single zone
> > @@ -557,7 +560,7 @@ int ttm_mem_global_alloc_page(struct ttm_mem_global 
> > *glob,
> > if (glob->zone_dma32 && page_to_pfn(page) > 0x0010UL)
> > zone = glob->zone_kernel;
> >   #endif
> > -   return ttm_mem_global_alloc_zone(glob, zone, size, false, false);
> > +   return ttm_mem_global_alloc_zone(glob, zone, size, );
> >   }
> >   void 

Re: [PATCH 5/5] drm: Don't pass clip to drm_atomic_helper_check_plane_state()

2018-01-24 Thread Sinclair Yeh
vmwgfx part: Reviewed-by: Sinclair Yeh <s...@vmware.com>

On Tue, Jan 23, 2018 at 07:08:57PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrj...@linux.intel.com>
> 
> Move the plane clip rectangle handling into
> drm_atomic_helper_check_plane_state(). Drivers no longer
> have to worry about such mundane details.
> 
> v2: Convert armada, rcar, and sun4i as well
> 
> Cc: Liviu Dudau <liviu.du...@arm.com>
> Cc: Brian Starkey <brian.star...@arm.com>
> Cc: Mali DP Maintainers <mal...@foss.arm.com>
> Cc: Daniel Vetter <daniel.vet...@intel.com>
> Cc: Gustavo Padovan <gust...@padovan.org>
> Cc: Sean Paul <seanp...@chromium.org>
> Cc: Philipp Zabel <p.za...@pengutronix.de>
> Cc: CK Hu <ck...@mediatek.com>
> Cc: Neil Armstrong <narmstr...@baylibre.com>
> Cc: Rob Clark <robdcl...@gmail.com>
> Cc: Ben Skeggs <bske...@redhat.com>
> Cc: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
> Cc: Sandy Huang <h...@rock-chips.com>
> Cc: "Heiko Stübner" <he...@sntech.de>
> Cc: Maxime Ripard <maxime.rip...@free-electrons.com>
> Cc: Thierry Reding <thierry.red...@gmail.com>
> Cc: VMware Graphics <linux-graphics-maintai...@vmware.com>
> Cc: Sinclair Yeh <s...@vmware.com>
> Cc: Thomas Hellstrom <thellst...@vmware.com>
> Cc: Shawn Guo <shawn...@kernel.org>
> Cc: Archit Taneja <arch...@codeaurora.org>
> Cc: linux-amlo...@lists.infradead.org
> Cc: linux-arm-...@vger.kernel.org
> Cc: freedr...@lists.freedesktop.org
> Cc: nouv...@lists.freedesktop.org
> Cc: linux-renesas-...@vger.kernel.org
> Cc: linux-te...@vger.kernel.org
> Cc: Russell King <rmk+ker...@armlinux.org.uk>
> Suggested-by: Daniel Vetter <dan...@ffwll.ch>
> Signed-off-by: Ville Syrjälä <ville.syrj...@linux.intel.com>
> Reviewed-by: Daniel Vetter <daniel.vet...@ffwll.ch>
> Reviewed-by: Thierry Reding <tred...@nvidia.com>
> Reviewed-by: Archit Taneja <arch...@codeaurora.org> #msm
> ---
>  drivers/gpu/drm/arm/hdlcd_crtc.c|  7 +--
>  drivers/gpu/drm/arm/malidp_planes.c |  7 +--
>  drivers/gpu/drm/armada/armada_crtc.c|  8 ++--
>  drivers/gpu/drm/armada/armada_overlay.c |  8 ++--
>  drivers/gpu/drm/drm_atomic_helper.c | 12 +++-
>  drivers/gpu/drm/drm_plane_helper.c  | 11 +++
>  drivers/gpu/drm/drm_simple_kms_helper.c |  6 --
>  drivers/gpu/drm/i915/intel_display.c| 12 
>  drivers/gpu/drm/imx/ipuv3-plane.c   |  7 +--
>  drivers/gpu/drm/mediatek/mtk_drm_plane.c|  7 +--
>  drivers/gpu/drm/meson/meson_plane.c |  7 +--
>  drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c   | 14 ++
>  drivers/gpu/drm/nouveau/nv50_display.c  | 12 
>  drivers/gpu/drm/rcar-du/rcar_du_plane.c |  7 +--
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c |  7 +--
>  drivers/gpu/drm/sun4i/sun8i_ui_layer.c  |  7 +--
>  drivers/gpu/drm/sun4i/sun8i_vi_layer.c  |  7 +--
>  drivers/gpu/drm/tegra/plane.c   |  7 +--
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  7 +--
>  drivers/gpu/drm/zte/zx_plane.c  | 13 +
>  include/drm/drm_atomic_helper.h |  1 -
>  include/drm/drm_plane_helper.h  |  1 -
>  22 files changed, 28 insertions(+), 147 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c 
> b/drivers/gpu/drm/arm/hdlcd_crtc.c
> index 877647ef35a9..cf5cbd63ecdf 100644
> --- a/drivers/gpu/drm/arm/hdlcd_crtc.c
> +++ b/drivers/gpu/drm/arm/hdlcd_crtc.c
> @@ -229,7 +229,6 @@ static const struct drm_crtc_helper_funcs 
> hdlcd_crtc_helper_funcs = {
>  static int hdlcd_plane_atomic_check(struct drm_plane *plane,
>   struct drm_plane_state *state)
>  {
> - struct drm_rect clip = { 0 };
>   struct drm_crtc_state *crtc_state;
>   u32 src_h = state->src_h >> 16;
>  
> @@ -249,11 +248,7 @@ static int hdlcd_plane_atomic_check(struct drm_plane 
> *plane,
>   return -EINVAL;
>   }
>  
> - if (crtc_state->enable)
> - drm_mode_get_hv_timing(_state->mode,
> -, );
> -
> - return drm_atomic_helper_check_plane_state(state, crtc_state, ,
> + return drm_atomic_helper_check_plane_state(state, crtc_state,
>  DRM_PLANE_HELPER_NO_SCALING,
>  DRM_PLANE_HELPER_NO_SCALING,
>  false, true);
> diff --git a/drivers/gpu/drm/arm/malidp_planes

Re: [PATCH v.2] 4.15 vmgfx boot warning

2017-12-19 Thread Sinclair Yeh
This looks okay to me.

On Mon, Dec 18, 2017 at 07:26:03PM -0500, Woody Suwalski wrote:
> The 4.15 drm_atomic_helper driver shows a warning during boot (both 32 and
> 64 bit x86)
> It is caused by a mismatch between the result of vmw_enable_vblank() and
> what the drm_atomic_helper expects:
>    /...
>    ret = drm_crtc_vblank_get(crtc);
>    WARN_ONCE(ret != -EINVAL, "driver forgot to call
> drm_crtc_vblank_off()\n");
>    /...
> 
> Signed-off by: Woody Suwalski 
> 
> --- a/drivers/gpu/drm/drm_atomic_helper.c    2017-12-16 09:55:33.853374561
> -0500
> +++ b/drivers/gpu/drm/drm_atomic_helper.c    2017-12-16 10:55:56.089090752
> -0500
> @@ -889,7 +889,7 @@ disable_outputs(struct drm_device *dev,
>          continue;
> 
>      ret = drm_crtc_vblank_get(crtc);
> -        WARN_ONCE(ret != -EINVAL, "driver forgot to call
> drm_crtc_vblank_off()\n");
> +        WARN_ONCE((ret != -EINVAL && ret != -ENOSYS), "driver forgot to
> call drm_crtc_vblank_off()\n");
>      if (ret == 0)
>          drm_crtc_vblank_put(crtc);
>  }
> 

> --- a/drivers/gpu/drm/drm_atomic_helper.c 2017-12-16 09:55:33.853374561 
> -0500
> +++ b/drivers/gpu/drm/drm_atomic_helper.c 2017-12-16 10:55:56.089090752 
> -0500
> @@ -889,7 +889,7 @@ disable_outputs(struct drm_device *dev,
>   continue;
>  
>   ret = drm_crtc_vblank_get(crtc);
> - WARN_ONCE(ret != -EINVAL, "driver forgot to call 
> drm_crtc_vblank_off()\n");
> + WARN_ONCE((ret != -EINVAL && ret != -ENOSYS), "driver forgot to 
> call drm_crtc_vblank_off()\n");
>   if (ret == 0)
>   drm_crtc_vblank_put(crtc);
>   }

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


Re: [PATCH] 4.15 vmgfx boot warning

2017-12-13 Thread Sinclair Yeh
Hi Woody,

On Wed, Nov 22, 2017 at 04:05:50PM -0500, Woody Suwalski wrote:
> The 4.15 vmwgfx driver shows a warning during boot (32 bit x86)
> It is caused by a mismatch between the result of vmw_enable_vblank() and
> what the drm_atomic_helper expects:
>    /...
>    ret = drm_crtc_vblank_get(crtc);
>    WARN_ONCE(ret != -EINVAL, "driver forgot to call
> drm_crtc_vblank_off()\n");

This doesn't apply to us because we don't have vblank support, and so
-ENOSYS seems to be the right error.

In the commit message for 84014b0a39ee, it does state a check for this
condition, but the check itself is based on dev->irq_enabled.

Is there another way to check for vblank support?



>    /...
> 
> Signed-off by: Woody Suwalski 
> 
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c    2017-11-22 15:29:46.511674079
> -0500
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c    2017-11-22 15:30:35.344559592
> -0500
> @@ -1869,7 +1869,7 @@ u32 vmw_get_vblank_counter(struct drm_de
>   */
>  int vmw_enable_vblank(struct drm_device *dev, unsigned int pipe)
>  {
> -    return -ENOSYS;
> +    return -EINVAL;
>  }
> 
>  /**
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] vmwgfx: use monotonic event timestamps

2017-12-13 Thread Sinclair Yeh
This looks okay to me.  Although we should change eaction->tv_* type
to 64-bit as well.

I'll roll this in to our next pull request.

thanks,

Sinclair


On Mon, Nov 27, 2017 at 12:16:19PM +0100, Arnd Bergmann wrote:
> DRM_VMW_EVENT_FENCE_SIGNALED (struct drm_vmw_event_fence) and
> DRM_EVENT_VBLANK (struct drm_event_vblank) pass timestamps in 32-bit
> seconds/microseconds format.
> 
> As of commit c61eef726a78 ("drm: add support for monotonic vblank
> timestamps"), other DRM drivers use monotonic times for drm_event_vblank,
> but vmwgfx still uses CLOCK_REALTIME for both events, which suffers from
> the y2038/y2106 overflow as well as time jumps.
> 
> For consistency, this changes vmwgfx to use ktime_get_ts64 as well,
> which solves those problems and avoids the deprecated do_gettimeofday()
> function.
> 
> This should be transparent to to user space, as long as it doesn't
> compare the time against the result of gettimeofday().
> 
> Signed-off-by: Arnd Bergmann 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> index d6b1c509ae01..55214d0da66e 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> @@ -897,11 +897,12 @@ static void vmw_event_fence_action_seq_passed(struct 
> vmw_fence_action *action)
>   spin_lock_irq(>event_lock);
>  
>   if (likely(eaction->tv_sec != NULL)) {
> - struct timeval tv;
> + struct timespec64 ts;
>  
> - do_gettimeofday();
> - *eaction->tv_sec = tv.tv_sec;
> - *eaction->tv_usec = tv.tv_usec;
> + ktime_get_ts64();
> + /* monotonic time, so no y2038 overflow */
> + *eaction->tv_sec = ts.tv_sec;
> + *eaction->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
>   }
>  
>   drm_send_event_locked(dev, eaction->event);
> -- 
> 2.9.0
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 13/15] drm/vmwgfx: Use drm_mode_get_hv_timing() to populate plane clip rectangle

2017-11-27 Thread Sinclair Yeh
This looks okay to me.

Reviewed-by: Sinclair Yeh <s...@vmware.com>

On Thu, Nov 23, 2017 at 09:05:00PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrj...@linux.intel.com>
> 
> Use drm_mode_get_hv_timing() to fill out the plane clip rectangle.
> 
> Note that this replaces crtc_state->adjusted_mode usage with
> crtc_state->mode. The latter is the correct choice since that's the
> mode the user provided and it matches the plane crtc coordinates
> the user also provided.
> 
> Once everyone agrees on this we can move the clip handling into
> drm_atomic_helper_check_plane_state().
> 
> Cc: Laurent Pinchart <laurent.pinch...@ideasonboard.com>
> Cc: VMware Graphics <linux-graphics-maintai...@vmware.com>
> Cc: Sinclair Yeh <s...@vmware.com>
> Cc: Thomas Hellstrom <thellst...@vmware.com>
> Signed-off-by: Ville Syrjälä <ville.syrj...@linux.intel.com>
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> index a2a93d7e2a04..25d96560180b 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
> @@ -449,10 +449,9 @@ int vmw_du_primary_plane_atomic_check(struct drm_plane 
> *plane,
>   if (state->crtc)
>   crtc_state = drm_atomic_get_new_crtc_state(state->state, 
> state->crtc);
>  
> - if (crtc_state && crtc_state->enable) {
> - clip.x2 = crtc_state->adjusted_mode.hdisplay;
> - clip.y2 = crtc_state->adjusted_mode.vdisplay;
> - }
> + if (crtc_state && crtc_state->enable)
> + drm_mode_get_hv_timing(_state->mode,
> +, );
>  
>   ret = drm_atomic_helper_check_plane_state(state, crtc_state, ,
> DRM_PLANE_HELPER_NO_SCALING,
> -- 
> 2.13.6
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 0/5] drm: drm_plane_helper_check_state() related stuff

2017-11-20 Thread Sinclair Yeh
On Mon, Nov 20, 2017 at 08:34:50AM +0100, Daniel Vetter wrote:
> On Fri, Nov 10, 2017 at 11:42:59PM +0200, Ville Syrjälä wrote:
> > On Fri, Nov 10, 2017 at 01:26:47PM -0800, Sinclair Yeh wrote:
> > > Sorry this took so long.
> > 
> > No worries.
> > 
> > > 
> > > The vmwgfx part:  Reviewed-by: Sinclair Yeh <s...@vmware.com>
> > > 
> > > I've done some testing and the vmwgfx part looks good.  Has Daniel
> > > already taken these or should I put them in my next request?
> > 
> > You can take them, or I can push them to drm-misc-next. Whatever
> > works best for you.
> > 
> > And I'll want to revisit this topic soonish and move the clip
> > handling into the helper as discussed with Daniel. But that can
> > wait a bit until we get this round merged somewhere.
> 
> Because we're still in the merge window I think it's probably best if we
> push the entire series in through drm-misc. Tree-coordination in the merge
> window is always a bit a pain.
> -Daniel

Ok, so I'll leave this series to you then.

thanks,

Sinclair

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


Re: [PATCH 0/5] drm: drm_plane_helper_check_state() related stuff

2017-11-10 Thread Sinclair Yeh
Sorry this took so long.

The vmwgfx part:  Reviewed-by: Sinclair Yeh <s...@vmware.com>

I've done some testing and the vmwgfx part looks good.  Has Daniel
already taken these or should I put them in my next request?

Sinclair

On Wed, Nov 01, 2017 at 08:29:15PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrj...@linux.intel.com>
> 
> While trawling the tree I spotted some issues with the way vmwgfx
> uses drm_plane_helper_check_state(). Here's my attempt at fixing it.
> Do note that I haven't actually tested the resulting code at all,
> but it does build at least.
> 
> And while touching that general area I took up Daniel's suggestion from
> long ago that drm_plane_helper_check_state() should be renamed and
> relocated to better reflect its status.
> 
> Here's a branch with the entire series:
> git://github.com/vsyrjala/linux.git atomic_helper_plane_stuff
> 
> Cc: VMware Graphics <linux-graphics-maintai...@vmware.com>
> Cc: Sinclair Yeh <s...@vmware.com>
> Cc: Thomas Hellstrom <thellst...@vmware.com>
> Cc: Daniel Vetter <dan...@ffwll.ch>
> 
> Ville Syrjälä (5):
>   drm/vmwgfx: Remove bogus crtc coords vs fb size check
>   drm/vmwgfx: Use drm_plane_helper_check_state()
>   drm/vmwgfx: Try to fix plane clipping
>   drm: Check crtc_state->enable rather than crtc->enabled in
> drm_plane_helper_check_state()
>   drm: Move drm_plane_helper_check_state() into drm_atomic_helper.c
> 
>  drivers/gpu/drm/arm/hdlcd_crtc.c|   8 +-
>  drivers/gpu/drm/arm/malidp_planes.c |   3 +-
>  drivers/gpu/drm/drm_atomic_helper.c |  95 
>  drivers/gpu/drm/drm_plane_helper.c  | 111 
> +++-
>  drivers/gpu/drm/drm_simple_kms_helper.c |   9 ++-
>  drivers/gpu/drm/i915/intel_display.c|  20 ++---
>  drivers/gpu/drm/imx/ipuv3-plane.c   |   8 +-
>  drivers/gpu/drm/mediatek/mtk_drm_plane.c|   8 +-
>  drivers/gpu/drm/meson/meson_plane.c |   8 +-
>  drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c   |   5 +-
>  drivers/gpu/drm/nouveau/nv50_display.c  |  18 +++--
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c |   6 +-
>  drivers/gpu/drm/tegra/dc.c  |   4 +-
>  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  40 --
>  drivers/gpu/drm/zte/zx_plane.c  |  15 ++--
>  include/drm/drm_atomic_helper.h |   7 ++
>  include/drm/drm_plane_helper.h  |   5 --
>  17 files changed, 187 insertions(+), 183 deletions(-)
> 
> -- 
> 2.13.6
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Git PULL] vmwgfx-fixes

2017-11-03 Thread Sinclair Yeh
Hi Dave,

The following changes since commit 25dd1aa3b4cf0c361147aa45ff4dd1d335259ac1:

  Merge branch 'linux-4.14' of git://github.com/skeggsb/linux into drm-fixes 
(2017-11-01 10:05:03 +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 cef75036c40408ba3bc308bcb00a3d440da713fc:

  drm/vmwgfx: Fix Ubuntu 17.10 Wayland black screen issue (2017-11-01 10:56:53 
-0700)


Arvind Yadav (1):
  drm/vmwgfx: constify vmw_fence_ops

Sinclair Yeh (1):
  drm/vmwgfx: Fix Ubuntu 17.10 Wayland black screen issue

 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c   | 2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)



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


Re: [PATCH] drm: vmwgfx: constify vmw_fence_ops

2017-08-30 Thread Sinclair Yeh

On Wed, Aug 30, 2017 at 10:30:24AM +0200, Daniel Vetter wrote:
> On Wed, Aug 30, 2017 at 08:21:46AM +0200, Thomas Hellstrom wrote:
> > On 08/30/2017 07:47 AM, Arvind Yadav wrote:
> > > vmw_fence_ops are not supposed to change at runtime. Functions
> > > "dma_fence_init" working with const vmw_fence_ops provided
> > > by . So mark the non-const structs as const.
> > > 
> > > Signed-off-by: Arvind Yadav 
> > > ---
> > >   drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c 
> > > b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> > > index b8bc5bc..abc5f03 100644
> > > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> > > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
> > > @@ -225,7 +225,7 @@ static long vmw_fence_wait(struct dma_fence *f, bool 
> > > intr, signed long timeout)
> > >   return ret;
> > >   }
> > > -static struct dma_fence_ops vmw_fence_ops = {
> > > +static const struct dma_fence_ops vmw_fence_ops = {
> > >   .get_driver_name = vmw_fence_get_driver_name,
> > >   .get_timeline_name = vmw_fence_get_timeline_name,
> > >   .enable_signaling = vmw_fence_enable_signaling,
> > 
> > Reviewed-by: Thomas Hellstrom 
> 
> Does this mean you'll merge it, or does this mean you'll expect someone
> else to merge this?

Yes, we have this queued and will go out in the next pull request.


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


[Git PULL] vmwgfx-fixes

2017-08-29 Thread Sinclair Yeh
Hi Dave,

The following changes since commit cc4a41fe5541a73019a864883297bd5043aa6d98:

  Linux 4.13-rc7 (2017-08-27 17:20:40 -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 021aba761f2a6c12158afb9993524c300c01fae2:

  drm/vmwgfx: Fix F26 Wayland screen update issue (2017-08-29 23:19:03 +0200)


Sinclair Yeh (1):
  drm/vmwgfx: Fix F26 Wayland screen update issue

 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)


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


[Git PULL] vmwgfx-next

2017-08-28 Thread Sinclair Yeh
Hi Dave,

The following changes since commit 7c0059dd832cc686bf0febefdcf8295cdd93007f:

  Merge branch 'linux-4.14' of git://github.com/skeggsb/linux into drm-next 
(2017-08-23 05:32:26 +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 d78acfe934e3b9f533f72ee3dde0982935fc2b32:

  drm/vmwgfx: Bump the version for fence FD support (2017-08-28 17:53:32 +0200)


Sinclair Yeh (4):
  drm/vmwgfx: Prepare to support fence fd
  drm/vmwgfx: Add support for imported Fence File Descriptor
  drm/vmwgfx: Add export fence to file descriptor support
  drm/vmwgfx: Bump the version for fence FD support

Thomas Hellstrom (5):
  drm/vmwgfx: Don't use drm_irq_[un]install
  drm/vmwgfx: Move irq bottom half processing to threads
  drm/vmwgfx: Restart command buffers after errors
  drm/vmwgfx: Support the NOP_ERROR command
  drm/vmwgfx: Fix incorrect command header offset at restart

 drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c  | 242 

 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c |  11 +--
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |  39 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 148 
+
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.c   | 104 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.h   |   4 +
 drivers/gpu/drm/vmwgfx/vmwgfx_irq.c | 111 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |   2 +-
 include/uapi/drm/vmwgfx_drm.h   |  11 ++-
 9 files changed, 511 insertions(+), 161 deletions(-)

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


Re: [Git PULL] vmwgfx-next

2017-08-28 Thread Sinclair Yeh
On Tue, Aug 29, 2017 at 06:35:38AM +1000, Dave Airlie wrote:
> On 29 August 2017 at 06:22, Sinclair Yeh <s...@vmware.com> wrote:
> > Hi Dave,
> >
> > The following changes since commit 7c0059dd832cc686bf0febefdcf8295cdd93007f:
> 
> Just a reminder, -next branches need to be sent before rc6 if you want
> them in the next kernel.

Sorry about this.  We were finalizing a few patches.

> 
> I'll take a look at this branch later since it's pretty late in the
> day, but I'm merging some other stuff that was stuck so I'll see if
> this has much impact.

Ok, if it doesn't work, then we'll just get onto the next train.

thanks,

Sinclair

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


[PATCH 5/9] drm/vmwgfx: Prepare to support fence fd

2017-08-09 Thread Sinclair Yeh
Make the fields and flags available.

Signed-off-by: Sinclair Yeh <s...@vmware.com>
Reviewed-by: Deepak Singh Rawat <dra...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c |  5 -
 include/uapi/drm/vmwgfx_drm.h   | 11 ---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index 6bea718..c8d7fb0 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -4449,11 +4449,6 @@ int vmw_execbuf_ioctl(struct drm_device *dev, unsigned 
long data,
arg.context_handle = (uint32_t) -1;
break;
case 2:
-   if (arg.pad64 != 0) {
-   DRM_ERROR("Unused IOCTL data not set to zero.\n");
-   return -EINVAL;
-   }
-   break;
default:
break;
}
diff --git a/include/uapi/drm/vmwgfx_drm.h b/include/uapi/drm/vmwgfx_drm.h
index d9dfde9..0bc784f 100644
--- a/include/uapi/drm/vmwgfx_drm.h
+++ b/include/uapi/drm/vmwgfx_drm.h
@@ -297,13 +297,17 @@ union drm_vmw_surface_reference_arg {
  * @version: Allows expanding the execbuf ioctl parameters without breaking
  * backwards compatibility, since user-space will always tell the kernel
  * which version it uses.
- * @flags: Execbuf flags. None currently.
+ * @flags: Execbuf flags.
+ * @imported_fence_fd:  FD for a fence imported from another device
  *
  * Argument to the DRM_VMW_EXECBUF Ioctl.
  */
 
 #define DRM_VMW_EXECBUF_VERSION 2
 
+#define DRM_VMW_EXECBUF_FLAG_IMPORT_FENCE_FD (1 << 0)
+#define DRM_VMW_EXECBUF_FLAG_EXPORT_FENCE_FD (1 << 1)
+
 struct drm_vmw_execbuf_arg {
__u64 commands;
__u32 command_size;
@@ -312,7 +316,7 @@ struct drm_vmw_execbuf_arg {
__u32 version;
__u32 flags;
__u32 context_handle;
-   __u32 pad64;
+   __s32 imported_fence_fd;
 };
 
 /**
@@ -328,6 +332,7 @@ struct drm_vmw_execbuf_arg {
  * @passed_seqno: The highest seqno number processed by the hardware
  * so far. This can be used to mark user-space fence objects as signaled, and
  * to determine whether a fence seqno might be stale.
+ * @fd: FD associated with the fence, -1 if not exported
  * @error: This member should've been set to -EFAULT on submission.
  * The following actions should be take on completion:
  * error == -EFAULT: Fence communication failed. The host is synchronized.
@@ -345,7 +350,7 @@ struct drm_vmw_fence_rep {
__u32 mask;
__u32 seqno;
__u32 passed_seqno;
-   __u32 pad64;
+   __s32 fd;
__s32 error;
 };
 
-- 
2.7.4

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


[PATCH 9/9] drm/vmwgfx: fix comment mistake for vmw_cmd_dx_set_index_buffer()

2017-08-09 Thread Sinclair Yeh
From: Brian Paul 

Fix comment mistake

Signed-off-by: Brian Paul 
Reviewed-by: Neha Bhende 
---
 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 3cd48d1..34b0177 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -2586,7 +2586,7 @@ static int vmw_cmd_dx_set_vertex_buffers(struct 
vmw_private *dev_priv,
 
 /**
  * vmw_cmd_dx_ia_set_vertex_buffers - Validate an
- * SVGA_3D_CMD_DX_IA_SET_VERTEX_BUFFERS command.
+ * SVGA_3D_CMD_DX_IA_SET_INDEX_BUFFER command.
  *
  * @dev_priv: Pointer to a device private struct.
  * @sw_context: The software context being used for this batch.
-- 
2.7.4

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


[PATCH 7/9] drm/vmwgfx: Add export fence to file descriptor support

2017-08-09 Thread Sinclair Yeh
Added code to link a fence to a out_fence_fd file descriptor and
thread out_fence_fd down to vmw_execbuf_copy_fence_user() so it can be
copied into the IOCTL reply and be passed back up the the user.

v2:
Make sure to sync and clean up in case of failure

Signed-off-by: Sinclair Yeh <s...@vmware.com>
Reviewed-by: Deepak Singh Rawat <dra...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |  8 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 69 +
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.c   |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c |  2 +-
 4 files changed, 70 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index c4dc3fa..5269be4 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include "vmwgfx_fence.h"
+#include 
 
 #define VMWGFX_DRIVER_DATE "20170607"
 #define VMWGFX_DRIVER_MAJOR 2
@@ -825,7 +826,8 @@ extern int vmw_execbuf_process(struct drm_file *file_priv,
   uint32_t dx_context_handle,
   struct drm_vmw_fence_rep __user
   *user_fence_rep,
-  struct vmw_fence_obj **out_fence);
+  struct vmw_fence_obj **out_fence,
+  uint32_t flags);
 extern void __vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv,
struct vmw_fence_obj *fence);
 extern void vmw_execbuf_release_pinned_bo(struct vmw_private *dev_priv);
@@ -840,7 +842,9 @@ extern void vmw_execbuf_copy_fence_user(struct vmw_private 
*dev_priv,
struct drm_vmw_fence_rep __user
*user_fence_rep,
struct vmw_fence_obj *fence,
-   uint32_t fence_handle);
+   uint32_t fence_handle,
+   int32_t out_fence_fd,
+   struct sync_file *sync_file);
 extern int vmw_validate_single_buffer(struct vmw_private *dev_priv,
  struct ttm_buffer_object *bo,
  bool interruptible,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index e9cdaa4..3cd48d1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -3830,6 +3830,8 @@ int vmw_execbuf_fence_commands(struct drm_file *file_priv,
  * which the information should be copied.
  * @fence: Pointer to the fenc object.
  * @fence_handle: User-space fence handle.
+ * @out_fence_fd: exported file descriptor for the fence.  -1 if not used
+ * @sync_file:  Only used to clean up in case of an error in this function.
  *
  * This function copies fence information to user-space. If copying fails,
  * The user-space struct drm_vmw_fence_rep::error member is hopefully
@@ -3845,7 +3847,9 @@ vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
int ret,
struct drm_vmw_fence_rep __user *user_fence_rep,
struct vmw_fence_obj *fence,
-   uint32_t fence_handle)
+   uint32_t fence_handle,
+   int32_t out_fence_fd,
+   struct sync_file *sync_file)
 {
struct drm_vmw_fence_rep fence_rep;
 
@@ -3855,6 +3859,7 @@ vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
memset(_rep, 0, sizeof(fence_rep));
 
fence_rep.error = ret;
+   fence_rep.fd = out_fence_fd;
if (ret == 0) {
BUG_ON(fence == NULL);
 
@@ -3877,6 +3882,14 @@ vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
 * and unreference the handle.
 */
if (unlikely(ret != 0) && (fence_rep.error == 0)) {
+   if (sync_file)
+   fput(sync_file->file);
+
+   if (fence_rep.fd != -1) {
+   put_unused_fd(fence_rep.fd);
+   fence_rep.fd = -1;
+   }
+
ttm_ref_object_base_unref(vmw_fp->tfile,
  fence_handle, TTM_REF_USAGE);
DRM_ERROR("Fence copy error. Syncing.\n");
@@ -4052,7 +4065,8 @@ int vmw_execbuf_process(struct drm_file *file_priv,
uint64_t throttle_us,
uint32_t dx_context_handle,
struct drm_vmw_fence_rep __user *user_fence_rep,
-   struct vmw_fence_obj **out_fence)
+   struct vmw_fence_obj **out_fence,
+ 

[PATCH 1/9] drm/vmwgfx: Move irq bottom half processing to threads

2017-08-09 Thread Sinclair Yeh
From: Thomas Hellstrom <thellst...@vmware.com>

This gets rid of the irq bottom half tasklets and instead performs the
work needed in process context. We also convert irq-disabling spinlocks to
ordinary spinlocks.

This should decrease system latency for other system components, like
sound for example but has the potential to increase latency for processes
that wait on the GPU.

Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
Reviewed-by: Sinclair Yeh <s...@vmware.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c | 58 ++
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c|  1 +
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h| 21 ++-
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.c  | 46 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_irq.c| 66 --
 5 files changed, 107 insertions(+), 85 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
index 99a7f4a..01024a5 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
@@ -85,7 +85,6 @@ struct vmw_cmdbuf_context {
  * Internal protection.
  * @dheaders: Pool of DMA memory for device command buffer headers with 
trailing
  * space for inline data. Internal protection.
- * @tasklet: Tasklet struct for irq processing. Immutable.
  * @alloc_queue: Wait queue for processes waiting to allocate command buffer
  * space.
  * @idle_queue: Wait queue for processes waiting for command buffer idle.
@@ -117,7 +116,6 @@ struct vmw_cmdbuf_man {
spinlock_t lock;
struct dma_pool *headers;
struct dma_pool *dheaders;
-   struct tasklet_struct tasklet;
wait_queue_head_t alloc_queue;
wait_queue_head_t idle_queue;
bool irq_on;
@@ -278,9 +276,9 @@ void vmw_cmdbuf_header_free(struct vmw_cmdbuf_header 
*header)
vmw_cmdbuf_header_inline_free(header);
return;
}
-   spin_lock_bh(>lock);
+   spin_lock(>lock);
__vmw_cmdbuf_header_free(header);
-   spin_unlock_bh(>lock);
+   spin_unlock(>lock);
 }
 
 
@@ -468,20 +466,17 @@ static void vmw_cmdbuf_ctx_add(struct vmw_cmdbuf_man *man,
 }
 
 /**
- * vmw_cmdbuf_man_tasklet - The main part of the command buffer interrupt
- * handler implemented as a tasklet.
+ * vmw_cmdbuf_irqthread - The main part of the command buffer interrupt
+ * handler implemented as a threaded irq task.
  *
- * @data: Tasklet closure. A pointer to the command buffer manager cast to
- * an unsigned long.
+ * @man: Pointer to the command buffer manager.
  *
- * The bottom half (tasklet) of the interrupt handler simply calls into the
+ * The bottom half of the interrupt handler simply calls into the
  * command buffer processor to free finished buffers and submit any
  * queued buffers to hardware.
  */
-static void vmw_cmdbuf_man_tasklet(unsigned long data)
+void vmw_cmdbuf_irqthread(struct vmw_cmdbuf_man *man)
 {
-   struct vmw_cmdbuf_man *man = (struct vmw_cmdbuf_man *) data;
-
spin_lock(>lock);
vmw_cmdbuf_man_process(man);
spin_unlock(>lock);
@@ -504,7 +499,7 @@ static void vmw_cmdbuf_work_func(struct work_struct *work)
uint32_t dummy;
bool restart = false;
 
-   spin_lock_bh(>lock);
+   spin_lock(>lock);
list_for_each_entry_safe(entry, next, >error, list) {
restart = true;
DRM_ERROR("Command buffer error.\n");
@@ -513,7 +508,7 @@ static void vmw_cmdbuf_work_func(struct work_struct *work)
__vmw_cmdbuf_header_free(entry);
wake_up_all(>idle_queue);
}
-   spin_unlock_bh(>lock);
+   spin_unlock(>lock);
 
if (restart && vmw_cmdbuf_startstop(man, true))
DRM_ERROR("Failed restarting command buffer context 0.\n");
@@ -536,7 +531,7 @@ static bool vmw_cmdbuf_man_idle(struct vmw_cmdbuf_man *man,
bool idle = false;
int i;
 
-   spin_lock_bh(>lock);
+   spin_lock(>lock);
vmw_cmdbuf_man_process(man);
for_each_cmdbuf_ctx(man, i, ctx) {
if (!list_empty(>submitted) ||
@@ -548,7 +543,7 @@ static bool vmw_cmdbuf_man_idle(struct vmw_cmdbuf_man *man,
idle = list_empty(>error);
 
 out_unlock:
-   spin_unlock_bh(>lock);
+   spin_unlock(>lock);
 
return idle;
 }
@@ -571,7 +566,7 @@ static void __vmw_cmdbuf_cur_flush(struct vmw_cmdbuf_man 
*man)
if (!cur)
return;
 
-   spin_lock_bh(>lock);
+   spin_lock(>lock);
if (man->cur_pos == 0) {
__vmw_cmdbuf_header_free(cur);
goto out_unlock;
@@ -580,7 +575,7 @@ static void __vmw_cmdbuf_cur_flush(struct vmw_cmdbuf_man 
*man)
man->cur->cb_header->length = man->cur_pos;
vmw_cmdbuf_ctx_add(man, man->cur, SVGA_CB_CONTEXT_0);
 out_unlock:
-  

[PATCH 8/9] drm/vmwgfx: Bump the version for fence FD support

2017-08-09 Thread Sinclair Yeh
Minor version bump to indicate support for fence FD

Signed-off-by: Sinclair Yeh <s...@vmware.com>
Reviewed-by: Deepak Singh Rawat <dra...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 5269be4..f0088d1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -42,9 +42,9 @@
 #include "vmwgfx_fence.h"
 #include 
 
-#define VMWGFX_DRIVER_DATE "20170607"
+#define VMWGFX_DRIVER_DATE "20170612"
 #define VMWGFX_DRIVER_MAJOR 2
-#define VMWGFX_DRIVER_MINOR 13
+#define VMWGFX_DRIVER_MINOR 14
 #define VMWGFX_DRIVER_PATCHLEVEL 0
 #define VMWGFX_FILE_PAGE_OFFSET 0x0010
 #define VMWGFX_FIFO_STATIC_SIZE (1024*1024)
-- 
2.7.4

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


[PATCH 4/9] drm/vmwgfx: Fix incorrect command header offset at restart

2017-08-09 Thread Sinclair Yeh
From: Thomas Hellstrom <thellst...@vmware.com>

Sometimes it appears like the device modifies the command header offset
member. So explicitly clear it when restarting after an error.

Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
Reviewed-by: Sinclair Yeh <s...@vmware.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
index a916864..ce92198 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
@@ -563,6 +563,7 @@ static void vmw_cmdbuf_work_func(struct work_struct *work)
entry->cmd += new_start_offset;
cb_hdr->length -= new_start_offset;
cb_hdr->errorOffset = 0;
+   cb_hdr->offset = 0;
list_add_tail(>list, _head[entry->cb_context]);
man->ctx[entry->cb_context].block_submission = true;
}
-- 
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: Add support for imported Fence File Descriptor

2017-08-09 Thread Sinclair Yeh
This allows vmwgfx to wait on a fence created by another
device.

v2:
* Remove special handling for vmwgfx fence and just use dma_fence_wait()
* Use interruptible waits
* Added function documentation

Signed-off-by: Sinclair Yeh <s...@vmware.com>
Reviewed-by: Deepak Singh Rawat <dra...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 24 --
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.c   | 45 +
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.h   |  4 +++
 3 files changed, 71 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index c8d7fb0..e9cdaa4 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -24,6 +24,7 @@
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  **/
+#include 
 
 #include "vmwgfx_drv.h"
 #include "vmwgfx_reg.h"
@@ -4414,6 +4415,7 @@ int vmw_execbuf_ioctl(struct drm_device *dev, unsigned 
long data,
static const size_t copy_offset[] = {
offsetof(struct drm_vmw_execbuf_arg, context_handle),
sizeof(struct drm_vmw_execbuf_arg)};
+   struct dma_fence *in_fence = NULL;
 
if (unlikely(size < copy_offset[0])) {
DRM_ERROR("Invalid command size, ioctl %d\n",
@@ -4453,6 +4455,21 @@ int vmw_execbuf_ioctl(struct drm_device *dev, unsigned 
long data,
break;
}
 
+
+   /* If imported a fence FD from elsewhere, then wait on it */
+   if (arg.flags & DRM_VMW_EXECBUF_FLAG_IMPORT_FENCE_FD) {
+   in_fence = sync_file_get_fence(arg.imported_fence_fd);
+
+   if (!in_fence) {
+   DRM_ERROR("Cannot get imported fence\n");
+   return -EINVAL;
+   }
+
+   ret = vmw_wait_dma_fence(dev_priv->fman, in_fence);
+   if (ret)
+   goto out;
+   }
+
ret = ttm_read_lock(_priv->reservation_sem, true);
if (unlikely(ret != 0))
return ret;
@@ -4465,9 +4482,12 @@ int vmw_execbuf_ioctl(struct drm_device *dev, unsigned 
long data,
  NULL);
ttm_read_unlock(_priv->reservation_sem);
if (unlikely(ret != 0))
-   return ret;
+   goto out;
 
vmw_kms_cursor_post_execbuf(dev_priv);
 
-   return 0;
+out:
+   if (in_fence)
+   dma_fence_put(in_fence);
+   return ret;
 }
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
index e83841a..e62f027 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
@@ -644,6 +644,51 @@ int vmw_user_fence_create(struct drm_file *file_priv,
 
 
 /**
+ * vmw_wait_dma_fence - Wait for a dma fence
+ *
+ * @fman: pointer to a fence manager
+ * @fence: DMA fence to wait on
+ *
+ * This function handles the case when the fence is actually a fence
+ * array.  If that's the case, it'll wait on each of the child fence
+ */
+int vmw_wait_dma_fence(struct vmw_fence_manager *fman,
+  struct dma_fence *fence)
+{
+   struct dma_fence_array *fence_array;
+   int ret = 0;
+   int i;
+
+
+   if (dma_fence_is_signaled(fence))
+   return 0;
+
+   if (!dma_fence_is_array(fence))
+   return dma_fence_wait(fence, true);
+
+   /* From i915: Note that if the fence-array was created in
+* signal-on-any mode, we should *not* decompose it into its individual
+* fences. However, we don't currently store which mode the fence-array
+* is operating in. Fortunately, the only user of signal-on-any is
+* private to amdgpu and we should not see any incoming fence-array
+* from sync-file being in signal-on-any mode.
+*/
+
+   fence_array = to_dma_fence_array(fence);
+   for (i = 0; i < fence_array->num_fences; i++) {
+   struct dma_fence *child = fence_array->fences[i];
+
+   ret = dma_fence_wait(child, true);
+
+   if (ret < 0)
+   return ret;
+   }
+
+   return 0;
+}
+
+
+/**
  * vmw_fence_fifo_down - signal all unsignaled fence objects.
  */
 
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h 
b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h
index d9d85aa..20224db 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.h
@@ -28,6 +28,7 @@
 #ifndef _VMWGFX_FENCE_H_
 
 #include 
+#include 
 
 #define VMW_FENCE_WAIT_TIMEOUT (5*HZ)
 
@@ -102,6 +103,9 @@ extern int vmw_user_fence_create(struct drm_file *file_priv,
 struct vmw_fence_obj **p_fence,
   

[PATCH 3/9] drm/vmwgfx: Support the NOP_ERROR command

2017-08-09 Thread Sinclair Yeh
From: Thomas Hellstrom <thellst...@vmware.com>

Can be used by user-space applications to test and verify the kernel
command buffer error recovery functionality.

Malicious user-space apps could potentially use this command to slow down
graphics processing somewhat, but they could also accomplish the same thing
using a random malformed command so this should be considered safe.
At least as safe as it gets.

Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
Reviewed-by: Brian Paul <bri...@vmware.com>
Reviewed-by: Sinclair Yeh <s...@vmware.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index e6c6328..6bea718 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -3303,6 +3303,8 @@ static const struct vmw_cmd_entry 
vmw_cmd_entries[SVGA_3D_CMD_MAX] = {
true, false, true),
VMW_CMD_DEF(SVGA_3D_CMD_NOP, _cmd_ok,
true, false, true),
+   VMW_CMD_DEF(SVGA_3D_CMD_NOP_ERROR, _cmd_ok,
+   true, false, true),
VMW_CMD_DEF(SVGA_3D_CMD_ENABLE_GART, _cmd_invalid,
false, false, true),
VMW_CMD_DEF(SVGA_3D_CMD_DISABLE_GART, _cmd_invalid,
-- 
2.7.4

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


[PATCH 2/9] drm/vmwgfx: Restart command buffers after errors

2017-08-09 Thread Sinclair Yeh
From: Thomas Hellstrom <thellst...@vmware.com>

Previously we skipped the command buffer and added an extra fence to
avoid hangs due to skipped fence commands.
Now we instead restart the command buffer after the failing command,
if there are any commands left.
In addition we print out some information about the failing command
and its location in the command buffer.

Testing Done: ran glxgears using mesa modified to send the NOP_ERROR
command before each 10th clear and verified that we detected the device
error properly and that there were no other device errors caused by
incorrectly ordered command buffers. Also ran the piglit "quick" test
suite which generates a couple of device errors and verified that
they were handled as intended.

Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
Reviewed-by: Brian Paul <bri...@vmware.com>
Reviewed-by: Sinclair Yeh <s...@vmware.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c  | 183 +++-
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h |   2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c |  48 -
 3 files changed, 206 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
index 01024a5..a916864 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf.c
@@ -51,6 +51,7 @@ struct vmw_cmdbuf_context {
struct list_head hw_submitted;
struct list_head preempted;
unsigned num_hw_submitted;
+   bool block_submission;
 };
 
 /**
@@ -60,6 +61,9 @@ struct vmw_cmdbuf_context {
  * kernel command submissions, @cur.
  * @space_mutex: Mutex to protect against starvation when we allocate
  * main pool buffer space.
+ * @error_mutex: Mutex to serialize the work queue error handling.
+ * Note this is not needed if the same workqueue handler
+ * can't race with itself...
  * @work: A struct work_struct implementeing command buffer error handling.
  * Immutable.
  * @dev_priv: Pointer to the device private struct. Immutable.
@@ -101,6 +105,7 @@ struct vmw_cmdbuf_context {
 struct vmw_cmdbuf_man {
struct mutex cur_mutex;
struct mutex space_mutex;
+   struct mutex error_mutex;
struct work_struct work;
struct vmw_private *dev_priv;
struct vmw_cmdbuf_context ctx[SVGA_CB_CONTEXT_MAX];
@@ -179,12 +184,13 @@ struct vmw_cmdbuf_alloc_info {
 };
 
 /* Loop over each context in the command buffer manager. */
-#define for_each_cmdbuf_ctx(_man, _i, _ctx) \
+#define for_each_cmdbuf_ctx(_man, _i, _ctx)\
for (_i = 0, _ctx = &(_man)->ctx[0]; (_i) < SVGA_CB_CONTEXT_MAX; \
 ++(_i), ++(_ctx))
 
-static int vmw_cmdbuf_startstop(struct vmw_cmdbuf_man *man, bool enable);
-
+static int vmw_cmdbuf_startstop(struct vmw_cmdbuf_man *man, u32 context,
+   bool enable);
+static int vmw_cmdbuf_preempt(struct vmw_cmdbuf_man *man, u32 context);
 
 /**
  * vmw_cmdbuf_cur_lock - Helper to lock the cur_mutex.
@@ -329,7 +335,8 @@ static void vmw_cmdbuf_ctx_submit(struct vmw_cmdbuf_man 
*man,
  struct vmw_cmdbuf_context *ctx)
 {
while (ctx->num_hw_submitted < man->max_hw_submitted &&
- !list_empty(>submitted)) {
+  !list_empty(>submitted) &&
+  !ctx->block_submission) {
struct vmw_cmdbuf_header *entry;
SVGACBStatus status;
 
@@ -384,12 +391,17 @@ static void vmw_cmdbuf_ctx_process(struct vmw_cmdbuf_man 
*man,
__vmw_cmdbuf_header_free(entry);
break;
case SVGA_CB_STATUS_COMMAND_ERROR:
-   case SVGA_CB_STATUS_CB_HEADER_ERROR:
+   entry->cb_header->status = SVGA_CB_STATUS_NONE;
list_add_tail(>list, >error);
schedule_work(>work);
break;
case SVGA_CB_STATUS_PREEMPTED:
-   list_add(>list, >preempted);
+   entry->cb_header->status = SVGA_CB_STATUS_NONE;
+   list_add_tail(>list, >preempted);
+   break;
+   case SVGA_CB_STATUS_CB_HEADER_ERROR:
+   WARN_ONCE(true, "Command buffer header error.\n");
+   __vmw_cmdbuf_header_free(entry);
break;
default:
WARN_ONCE(true, "Undefined command buffer status.\n");
@@ -497,24 +509,111 @@ static void vmw_cmdbuf_work_func(struct work_struct 
*work)
container_of(work, struct vmw_cmdbuf_man, work);
struct vmw_cmdbuf_header *entry, *next;
uint32_t dummy;
-   bool restart = false;
+   bool restart[SVGA_CB_CONTEXT_MAX];
+   bool send_fence = false;
+   struct list_

[PATCH 0/9] Queued patches for vmwgfx-next

2017-08-09 Thread Sinclair Yeh
These, along with "drm: Support drivers with threaded irqs", are
queued for the next vmwgfx-next pull request.


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


[PATCH] drm: Support drivers with threaded irqs

2017-08-09 Thread Sinclair Yeh
From: Thomas Hellstrom <thellst...@vmware.com>

See LWN article at
https://lwn.net/Articles/302043/

Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
Reviewed-by: Deepak Singh Rawat <dra...@vmware.com>
Reviewed-by: Sinclair Yeh <s...@vmware.com>
---
 drivers/gpu/drm/drm_irq.c | 6 --
 include/drm/drm_drv.h | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 3b04c2510..ef9b4be 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -127,8 +127,10 @@ int drm_irq_install(struct drm_device *dev, int irq)
if (drm_core_check_feature(dev, DRIVER_IRQ_SHARED))
sh_flags = IRQF_SHARED;
 
-   ret = request_irq(irq, dev->driver->irq_handler,
- sh_flags, dev->driver->name, dev);
+   ret = request_threaded_irq(irq,
+  dev->driver->irq_handler,
+  dev->driver->irq_thread_fn,
+  sh_flags, dev->driver->name, dev);
 
if (ret < 0) {
dev->irq_enabled = false;
diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h
index 81971dc..c47abbf 100644
--- a/include/drm/drm_drv.h
+++ b/include/drm/drm_drv.h
@@ -333,6 +333,7 @@ struct drm_driver {
 * drivers which implement their own interrupt handling.
 */
irqreturn_t(*irq_handler) (int irq, void *arg);
+   irqreturn_t (*irq_thread_fn)(int irq, void *arg);
 
/**
 * @irq_preinstall:
-- 
2.7.4

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


[git pull] vmwgfx-fixes

2017-07-21 Thread Sinclair Yeh
Hi Dave,

The following changes since commit 9ff1beb1d19ffe2b26bf9cd2d33e6073d4f4b5fe:

  Merge tag 'drm-intel-fixes-2017-06-27' of 
git://anongit.freedesktop.org/git/drm-intel into drm-fixes (2017-06-28 17:07:15 
+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 8046306fb9dedf216fc37a7dadc0e35ce37e9567:

  drm/vmwgfx: constify pci_device_id. (2017-07-17 23:41:22 -0700)


Arvind Yadav (2):
  drm/vmwgfx: dma-buf: Constify ttm_place structures.
  drm/vmwgfx: constify pci_device_id.

Brian Paul (1):
  drm/vmwgfx: fix comment mistake for vmw_cmd_dx_set_index_buffer()

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

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

Sinclair Yeh (3):
  drm/vmwgfx: Limit max desktop dimensions to 8Kx8K
  drm/vmwgfx: Fix cursor hotspot issue with Wayland on Fedora
  drm/vmwgfx: Fix gcc-7.1.1 warning

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

 drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c| 24 
 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   |  8 
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c   |  8 
 drivers/gpu/drm/vmwgfx/vmwgfx_fence.c | 10 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_kms.c   |  9 +
 drivers/gpu/drm/vmwgfx/vmwgfx_mob.c   |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_msg.c   |  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_resource.c  |  4 ++--
 drivers/gpu/drm/vmwgfx/vmwgfx_shader.c|  6 +++---
 drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c  |  4 ++--
 15 files changed, 58 insertions(+), 51 deletions(-)

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


Re: [PATCH 2/5] drm: vmwgfx: constify pci_device_id.

2017-07-18 Thread Sinclair Yeh
Thanks.  Queued.

On Sat, Jul 15, 2017 at 12:44:53PM +0530, Arvind Yadav wrote:
> pci_device_id are not supposed to change at runtime. All functions
> working with pci_device_id provided by  work with
> const pci_device_id. So mark the non-const structs as const.
> 
> File size before:
>text  data bss dec hex filename
>   13765   800  20   1458538f9 gpu/drm/vmwgfx/vmwgfx_drv.o
> 
> File size After adding 'const':
>text  data bss dec hex filename
>   13829   736  20   1458538f9 gpu/drm/vmwgfx/vmwgfx_drv.o
> 
> Signed-off-by: Arvind Yadav 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> index 4a64155..f5fe28f 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
> @@ -227,7 +227,7 @@ static const struct drm_ioctl_desc vmw_ioctls[] = {
> DRM_AUTH | DRM_RENDER_ALLOW),
>  };
>  
> -static struct pci_device_id vmw_pci_id_list[] = {
> +static const struct pci_device_id vmw_pci_id_list[] = {
>   {0x15ad, 0x0405, PCI_ANY_ID, PCI_ANY_ID, 0, 0, VMWGFX_CHIP_SVGAII},
>   {0, 0, 0}
>  };
> -- 
> 2.7.4
> 
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH, RESEND 03/14] drm/vmwgfx: avoid gcc-7 parentheses warning

2017-07-17 Thread Sinclair Yeh
On Fri, Jul 14, 2017 at 10:28:29PM +0200, Arnd Bergmann wrote:
> On Fri, Jul 14, 2017 at 9:23 PM, Linus Torvalds
>  wrote:
> > On Fri, Jul 14, 2017 at 12:21 PM, Linus Torvalds
> >  wrote:
> >>
> >> NAK. This takes unintentionally insane code and turns it intentionally
> >> insane. Any non-zero return is considered an error.
> >>
> >> The right fix is almost certainly to just return -EINVAL unconditionally.

Correct.  I'll fix this.

> >
> > Btw, this is why I hate compiler warning fix patch series. Even when
> > they don't actually break the code (and sometimes they do that too),
> > they can actually end up making the code worse.
> 
> I generally agree, and this is also why I held up sending patches for the
> -Wformat warnings until you brought those up. I also frequently send
> patches for recently introduced warnings, which tend to have a better
> chance of getting reviewed by the person that just introduced the code,
> to catch this kind of mistake in my patches.
> 
> I also regularly run into cases where I send a correct patch and find
> that another broken patch has been applied the following day ;-)
> 
> > The *intent* of that code was to return zero for the CAP_SYS_ADMIN.
> > But the code has never done that in its lifetime and nobody ever
> > noticed, so clearly the code shouldn't even have tried.
> 
> Makes sense, yes. In this case, the review process has failed as
> well, as one of the maintainers even gave an Ack on the wrong patch,
> and then the patch got dropped without any feedback.

I've done some digging and noticed that my -fixes pull request
didn't get picked up last December.  It's most likely because I
initially made an address typo in the original request, and then
followed it up with a direct email with the correct address.

Sinclair


___
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 <maarten.lankho...@linux.intel.com>
> > Cc: VMware Graphics <linux-graphics-maintai...@vmware.com>
> > Cc: Sinclair Yeh <s...@vmware.com>
> > Cc: Thomas Hellstrom <thellst...@vmware.com>
> > ---
> >  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 <daniel.vet...@ffwll.ch>

Yeah, good point.

___
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 <s...@vmware.com>

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 <maarten.lankho...@linux.intel.com>
> Cc: VMware Graphics <linux-graphics-maintai...@vmware.com>
> Cc: Sinclair Yeh <s...@vmware.com>
> Cc: Thomas Hellstrom <thellst...@vmware.com>
> ---
>  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: [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 = _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 = _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 = _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 1/2] drm/vmwgfx: Drop drm_vblank_cleanup

2017-07-03 Thread Sinclair Yeh
Thanks!

Minor typo "dsiplay", otherwise:  Reviewed-by: Sinclair Yeh <s...@vmware.com>

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 <s...@vmware.com>
> Cc: Thomas Hellstrom <thellst...@vmware.com>
> Reviewed-by: Sean Paul <seanp...@chromium.org>
> Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
> Signed-off-by: Daniel Vetter <daniel.vet...@intel.com>
> ---
>  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(_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,
>   

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 <s...@vmware.com>
> Cc: Thomas Hellstrom <thellst...@vmware.com>
> Signed-off-by: Daniel Vetter <daniel.vet...@intel.com>
> ---
>  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(_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/g

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 v3] drm: Add DRM_MODE_ROTATE_ and DRM_MODE_REFLECT_ to UAPI

2017-05-18 Thread Sinclair Yeh
vmwgfx part: Reviewed-by: Sinclair Yeh <s...@vmware.com>

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 <robert.f...@collabora.com>
> ---
> 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 = >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)

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_=DwICAg=uilaK90D4TOVoH58JNXRgQ=j2ey7nuAQ5d6NbMmCOnRsTIJfmv7blo3UCKagbsM9o2-No8JdlhkKK3ty481ErVu=DWnNRbcrxMhc78PIvembLdV3OsJi3vPwcdG03kqVpJo=mc7-KF2t4BktXs11MShGZBf9bzgxumqhmVQ0ocAIS0k=
> > >  
> > > 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] drm/vmwgfx: Handle vmalloc() failure in vmw_local_fifo_reserve()

2017-05-01 Thread Sinclair Yeh
Thanks Dan!

Reviewed-by: Sinclair Yeh <s...@vmware.com>

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 <dan.carpen...@oracle.com>
> 
> 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


[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 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 <s...@vmware.com>

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=DwIBAg=uilaK90D4TOVoH58JNXRgQ=HaJ2a6NYExoV0cntAYcoqA=D9ZabTkAbhTqB-puuJ1a4SnWKUIGw0oXestkhJG6dCQ=6PZxBQ8MQjy-uc5pd6vyZg3D5yrG0jlSPi5pPE0oFK4=
>  
> Signed-off-by: Vladis Dronov <vdro...@redhat.com>
> ---
>  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


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 <s...@vmware.com>

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=DwIBAg=uilaK90D4TOVoH58JNXRgQ=HaJ2a6NYExoV0cntAYcoqA=QP_jolGTC4ofBnHRnAs0tFIXHnVWaTT0AdMyCL9SM64=un2hxBL1283iOTtJeJnvyyvtAu1d5Imyh5Q7AzljrfQ=
>  
> 
> Signed-off-by: Logan Gunthorpe <log...@deltatee.com>
> ---
>  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,
> - 

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 <s...@vmware.com>

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 <s...@vmware.com>
> Cc: Thomas Hellstrom <thellst...@vmware.com>
> Cc: Ben Skeggs <bske...@redhat.com>
> Cc: Patrik Jakobsson <patrik.r.jakobs...@gmail.com>
> Cc: Alex Deucher <alexander.deuc...@amd.com>
> Cc: Christian König <christian.koe...@amd.com>
> 
> Signed-off-by: Daniel Vetter <daniel.vet...@ffwll.ch>
> ---
>  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, >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/

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 12/15] drm: Add acquire ctx to ->gamma_set hook

2017-04-03 Thread Sinclair Yeh
vmwgfx part:  Reviewed-by: Sinclair Yeh <s...@vmware.com>

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 <airl...@redhat.com>
> Cc: Alex Deucher <alexander.deuc...@amd.com>
> Cc: Christian König <christian.koe...@amd.com>
> Cc: Gerd Hoffmann <kra...@redhat.com>
> Cc: Ben Skeggs <bske...@redhat.com>
> Cc: Sinclair Yeh <s...@vmware.com>
> Cc: Thomas Hellstrom <thellst...@vmware.com>
> Cc: Eric Anholt <e...@anholt.net>
> Signed-off-by: Daniel Vetter <daniel.vet...@intel.com>
> ---
>  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

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 <s...@vmware.com>

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 <s...@canb.auug.org.au>
> 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 <s...@canb.auug.org.au>
> ---
>  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 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 <su...@sunbase.org>
> >
> > 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 <su...@sunbase.org> - 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


[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] 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=DwIBAg=uilaK90D4TOVoH58JNXRgQ=HaJ2a6NYExoV0cntAYcoqA=5yR87BuuU86aoAjCveInxh6jvgOyumqIHQhTs0xLo38=tWQs7vwNLgD_b2RWMddVtusEKh9FQTIF5rKFOWudslE=
>  
> 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


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 <s...@vmware.com>
> > Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
> > Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
> > ---
> >  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


[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 <s...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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(>guest_map, 0, sizeof(vps->guest_map));
+   memset(>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(>guest_map);
+   }
+
+   if (vps->host_map.virtual) {
+   DRM_ERROR("Host mapping not freed\n");
+   ttm_bo_kunmap(>host_map);
+   }
+
if (vps->surf)
vmw_surface_unreference(>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, );
@@ -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 <s...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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


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

2017-03-27 Thread Sinclair Yeh
From: Thomas Hellstrom <thellst...@vmware.com>

Provide and document a reference implementation.

Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
Reviewed-by: Sinclair Yeh <s...@vmware.com>
---
 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(_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(_priv->resource_lock);
-   res = idr_find(idr, id);
-   if (!res || !res->avail || !kref_get_unless_zero(>kref))
-   res = NULL;
-
-   read_unlock(_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 = >res;
-   int ret;
-
-   ret = vmw_resource_init(dev_priv, res, false, res_free,
-   _stream_func);
-
-   if (unlikely(ret != 0)) {
-   if (res_free == NULL)
-   kfree(stream);
-   else
-   res_free(>res);
-   return ret;
-   }
-
-   ret = vmw_overlay_claim(dev_priv, >stream_id);
-   if (ret) {
-   vmw_resource_unreference();
-   return ret;
-   }
-
-   DRM_INFO("%s: claimed\n", __func__);
-
-   vmw_resource_activate(>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 = *p_base;
-   struct v

[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 <su...@sunbase.org>

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 <su...@sunbase.org>
Reviewed-by: Sinclair Yeh <s...@vmware.com>
---
 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 5/9] drm/vmwgfx: Introduce a simple resource type

2017-03-27 Thread Sinclair Yeh
From: Thomas Hellstrom <thellst...@vmware.com>

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 <thellst...@vmware.com>
Reviewed-by: Sinclair Yeh <s...@vmware.com>
---
 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 WARRANT

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

2017-03-27 Thread Sinclair Yeh
From: Thomas Hellstrom <thellst...@vmware.com>

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 <thellst...@vmware.com>
Reviewed-by: Sinclair Yeh <s...@vmware.com>
---
 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 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 <s...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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


[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 <s...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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(>map);
par->bo_ptr = NULL;
}
if (unref_bo)
vmw_dmabuf_unreference(>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(>vmw_bo->base, 0,
  par->vmw_bo->base.num_pages, >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 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 <s...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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 = >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


[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 <s...@vmware.com>
Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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(>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] != >base.connector) {
-   DRM_ERROR("connector doesn't match %p %p\n",
-   set->connectors[0], >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(>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 = >base.connector;
-   encoder = >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

[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 <s...@vmware.com>
Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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 = >display_srf->res;
-
-   vmw_resource_unpin(res);
-   vmw_surface_unreference(>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 n

[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 <s...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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 >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, _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, _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

[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 <s...@vmware.com>
Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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 >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 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 <s...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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 = >con;
ret = drm_mode_set_config_internal();
if (ret) {
@@ -822,7 +822,9 @@ int vmw_fb_off(struct vmw_private *vmw_priv)
flush_delayed_work(>local_work);
 
mutex_lock(>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(>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 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 <s...@vmware.com>
Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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(>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(>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(>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(str

[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 <s...@vmware.com>
Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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(>surf->res);
+   vps->pinned--;
+   }
+
+   if (unreference) {
+   if (vps->pinned)
+   DRM_ERROR("Surface still pinned\n");
+   vmw_surface_unreference(>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(>surf);
+
+   if (vps->dmabuf)
+   vmw_dmabuf_unreference(>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_

[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 <s...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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(>primary);
drm_plane_cleanup(>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 = >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 = >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(>surf);
+
+   if (vps->dmabuf)
+   vmw_dmabuf_unreference(>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 *plane,
  

[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 <s...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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 = >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, >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);
+  

[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 <s...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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 = >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 = >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);
 i

[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 <s...@vmware.com>
Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
---
 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(_priv->waiter_lock);
spin_lock_init(_priv->cap_lock);
spin_lock_init(_priv->svga_lock);
+   spin_lock_init(_priv->cursor_lock);
 
for (i = vmw_res_context; i < vmw_res_max; ++i) {
idr_init(_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(>cursor_surface);
-   if (du->cursor_dmabuf)
-   vmw_dmabuf_unreference(>cursor_dmabuf);
+   drm_plane_cleanup(>primary);
+   drm_plane_cleanup(>cursor);
+
drm_connector_unregister(>connector);
drm_crtc_cleanup(>crtc);
drm_encoder_cleanup(>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(_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(_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);
-   struct vmw_display_unit *du = vmw_c

[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


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

2017-03-25 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=DwIBAg=uilaK90D4TOVoH58JNXRgQ=HaJ2a6NYExoV0cntAYcoqA=OW9cIAAez9eRIxEYMaToDu2szuR_YrfQcOzAH6L8dXo=-3P2pG3n1YW6-8NG6mLC7kyxmx7mMxJmXgY79ZgQeo4=
>  
> 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


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 <s...@vmware.com>

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 <j...@perches.com>
> ---
>  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(>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_inf

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 <su...@sunbase.org>
> > ---
> > 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
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] drm/vmwgfx: Work around drm removal of control nodes

2017-02-21 Thread Sinclair Yeh
Reviewed-by: Sinclair Yeh <s...@vmware.com>


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: <sta...@vger.kernel.org>
> Signed-off-by: Thomas Hellstrom <thellst...@vmware.com>
> ---
>  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: [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(, 0);
> > +   state->acquire_ctx = 
> > +
> > +retry:
> > +   plane_mask = 0;
> > +   ret = drm_modeset_lock_all_ctx(dev, );
> > +   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);
> > +
> > 

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 <maarten.lankho...@linux.intel.com>
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 <daniel.vet...@ffwll.ch>
>>>>>>>>>
>>>>>>>>> This was somehow lost between v3 and the merged version in Maarten's
>>>>>>>>> patch merged as:
>>>>>>>>>
>>>>>>>>> commit f2d580b9a8149735cbc4b59c4a8df60173658140
>>>>>>>>> Author: Maarten Lankhorst <maarten.lankho...@linux.intel.com>
>>>>>>>>> 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 <daniel.vet...@intel.com>
>>>>>>>>> Signed-off-by: Daniel Vetter <daniel.vet...@ffwll.ch>
>>>>>>>>> Signed-off-by: Maarten Lankhorst <maarten.lankho...@linux.intel.com>
>>>>>>>> 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: [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 <s...@vmware.com>

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 <ch...@chris-wilson.co.uk>
> Reviewed-by: Joonas Lahtinen <joonas.lahti...@linux.intel.com>
> Cc: Alex Deucher <alexander.deuc...@amd.com>
> Cc: "Christian König" <christian.koe...@amd.com>
> Cc: David Airlie <airl...@linux.ie>
> Cc: Russell King <rmk+ker...@armlinux.org.uk>
> Cc: Daniel Vetter <daniel.vet...@intel.com>
> Cc: Jani Nikula <jani.nik...@linux.intel.com>
> Cc: Sean Paul <seanp...@chromium.org>
> Cc: Lucas Stach <l.st...@pengutronix.de>
> Cc: Christian Gmeiner <christian.gmei...@gmail.com>
> Cc: Rob Clark <robdcl...@gmail.com>
> Cc: Thierry Reding <thierry.red...@gmail.com>
> Cc: Stephen Warren <swar...@wwwdotorg.org>
> Cc: Alexandre Courbot <gnu...@gmail.com>
> Cc: Eric Anholt <e...@anholt.net>
> Cc: Sinclair Yeh <s...@vmware.com>
> Cc: Thomas Hellstrom <thellst...@vmware.com>
> ---
>  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(>lock);
> - r = drm_mm_insert_node_in_range_generic(>mm, node, mem->num_pages,
> - mem->page_alignment, 0,
> - fpfn, lpfn, sflags, aflags);
> + r = drm_mm_insert_node_in_range(>mm, node,
> + mem->num_pages, mem->page_alignment, 0,
> +

[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 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 <daniel.vet...@ffwll.ch>
> >>>>>>>
> >>>>>>> This was somehow lost between v3 and the merged version in Maarten's
> >>>>>>> patch merged as:
> >>>>>>>
> >>>>>>> commit f2d580b9a8149735cbc4b59c4a8df60173658140
> >>>>>>> Author: Maarten Lankhorst <maarten.lankho...@linux.intel.com>
> >>>>>>> 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 <daniel.vet...@intel.com>
> >>>>>>> Signed-off-by: Daniel Vetter <daniel.vet...@ffwll.ch>
> >>>>>>> Signed-off-by: Maarten Lankhorst <maarten.lankho...@linux.intel.com>
> >>>>>> 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


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 <michel.daen...@amd.com>
> >>
> >>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 <michel.daen...@amd.com>
> >Reviewed-by: Thomas Hellstrom <thellst...@vmware.com>
> 
> Reviewed-by: Christian König <christian.koe...@amd.com>.

Reviewed-by: Sinclair Yeh <s...@vmware.com>

> 
> >
> >>---
> >>  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(>lru_lock);
> >>list_for_each_entry(bo, >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-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 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 <s...@vmware.com>

On Fri, Jan 13, 2017 at 10:51:11AM +0100, Christian König wrote:
> From: Christian König <christian.koe...@amd.com>
> 
> Without the custom LRU management the callback is not used any more.
> 
> Signed-off-by: Christian König <christian.koe...@amd.com>
> ---
>  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(>swap)) {
>   list_del_init(>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(>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 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 = _bo_fault_reserve_notify,
>   .io_mem_reserve = _ttm_io_mem_reserve,
>   .io_mem_free = _ttm_io_mem_free,
> - .lru_tail = _bo_default_lru_tail,
> - .swap_lru_tail = _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 = _ttm_io_mem_reserve,
>   .io_mem_free = _ttm_io_mem_free,
> - .lru_tail = _bo_default_lru_tail,
> - .swap_lru_tail = _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 = _ttm_io_mem_reserve,
>   .io_mem_free = _ttm_io_mem_free,
> - .lru_tail = _bo_default_lru_tail,
> - .swap_lru_tail = _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 = _ttm_io_mem_reserve,
>   .io_mem_free = _ttm_io_mem_free,
> - .lru_tail = _bo_default_lru_tail,
> - .swap_lru_tail = _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 = _ttm_io_mem_reserve,
>   .io_mem_free = _ttm_io_mem_free,
> - .lru_tail = _bo_default_lru_tail,
> - .swap_lru_tail = _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 = _ttm_fault_reserve_notify,
>   .io_mem_reserve = _ttm_io_mem_reserve,
>   .io_mem_free = _ttm_io_mem_free,
> - .lru_tail = _bo_default_lru_tail,
> - .swap_lru_tail = _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 = _ttm_io_mem_reserve,
>   .io_mem_free = _ttm_io_mem_free,
>   .move_notify = _bo_move_notify,
> - .lru_tail = _bo_default_lru_tail,
> - .swap_lru_tail = _bo_default_swap_lru_tail,
>  };
>  
>  int qxl_ttm_init(struct qxl_device *qdev)
> diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c 
> 

[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] 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
> 


  1   2   >