[PATCH 2/2] drm/vmwgfx: Add SPDX header to vmwgfx_drm.h

2023-10-09 Thread Maaz Mombasawala (VMware)
From: Maaz Mombasawala Update vmwgfx_drm.h with SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT Signed-off-by: Maaz Mombasawala Reviewed-by: Martin Krastev Signed-off-by: Maaz Mombasawala (VMware) --- include/uapi/drm/vmwgfx_drm.h | 1 + 1 file changed, 1 insertion

[PATCH 1/2] drm/vmwgfx: Make all surfaces shareable

2023-10-09 Thread Maaz Mombasawala (VMware)
: Maaz Mombasawala (VMware) --- drivers/gpu/drm/vmwgfx/ttm_object.c | 6 +++--- drivers/gpu/drm/vmwgfx/ttm_object.h | 3 +-- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 17 ++--- include/uapi/drm/vmwgfx_drm.h | 5 +++-- 4 files changed, 13 insertions(+), 18 deletions

Re: [PATCH] drm/vmwgfx: Fix possible invalid drm gem put calls

2023-08-23 Thread Maaz Mombasawala (VMWare)
LGTM! Reviewed-by: Maaz Mombasawala Maaz Mombasawala (VMware) On 8/17/2023 9:13 PM, Zack Rusin wrote: From: Zack Rusin vmw_bo_unreference sets the input buffer to null on exit, resulting in null ptr deref's on the subsequent drm gem put calls. This went unnoticed because only ver

Re: [PATCH] drm/vmwgfx: Fix shader stage validation

2023-06-16 Thread Maaz Mombasawala (VMWare)
LGTM. Reviewed-by: Maaz Mombasawala Maaz Mombasawala (VMware) On 6/16/2023 12:09 PM, Zack Rusin wrote: From: Zack Rusin For multiple commands the driver was not correctly validating the shader stages resulting in possible kernel oopses. The validation code was only. if ever, checking the

Re: [PATCH 2/3] drm/vmwgfx: Print errors when running on broken/unsupported configs

2023-03-21 Thread "Maaz Mombasawala (VMware)
> __printf(1, 2) int vmw_host_printf(const char *fmt, ...); > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c > b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c > index ca1a3fe44fa5..2651fe0ef518 100644 > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c > @@ -1179,3 +1179,12 @@ int vmw_mksstat_remove_ioctl(struct drm_device *dev, > void *data, > > return -EAGAIN; > } > + > +/** > + * vmw_disable_backdoor: Disables all backdoor communication > + * with the hypervisor. > + */ > +void vmw_disable_backdoor(void) > +{ > + vmw_msg_enabled = 0; > +} LGTM Reviewed-by: Maaz Mombasawala -- Maaz Mombasawala (VMware)

Re: [PATCH] drm/vmwgfx: Stop accessing buffer objects which failed init

2023-02-08 Thread "Maaz Mombasawala (VMware)
vmw_bo_create(dev_priv, ¶ms, p_vbo); > - > - (*p_vbo)->tbo.base.funcs = &vmw_gem_object_funcs; > if (ret != 0) > goto out_no_bo; > > + (*p_vbo)->tbo.base.funcs = &vmw_gem_object_funcs; > + > ret = drm_gem_handle_create(filp, &(*p_vbo)->tbo.base, handle); > /* drop reference from allocate - handle holds it now */ > drm_gem_object_put(&(*p_vbo)->tbo.base); LGTM! Reviewed-by: Maaz Mombasawala -- Maaz Mombasawala (VMware)

Re: [PATCH] drm/vmwgfx: Do not drop the reference to the handle too soon

2023-02-08 Thread "Maaz Mombasawala (VMware)
x/vmwgfx_surface.c > @@ -867,7 +867,6 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void > *data, > goto out_unlock; > } > vmw_bo_reference(res->guest_memory_bo); > - drm_gem_object_get(&res->guest_memory_bo->tbo.base); > } > > tmp = vmw_resource_reference(&srf->res); LGTM! Reviewed-by: Maaz Mombasawala -- Maaz Mombasawala (VMware)

Re: [PATCH v2 8/8] drm/vmwgfx: Stop using raw ttm_buffer_object's

2023-01-31 Thread "Maaz Mombasawala (VMware)
On 1/30/23 19:35, Zack Rusin wrote: > From: Zack Rusin > > Various bits of the driver used raw ttm_buffer_object instead of the > driver specific vmw_bo object. All those places used to duplicate > the mapped bo caching policy of vmw_bo. > > Instead of duplicating all of that code and special ca

Re: [PATCH v2 7/8] drm/vmwgfx: Abstract placement selection

2023-01-31 Thread "Maaz Mombasawala (VMware)
On 1/30/23 19:35, Zack Rusin wrote: > From: Zack Rusin > > Problem with explicit placement selection in vmwgfx is that by the time > the buffer object needs to be validated the information about which > placement was supposed to be used is lost. To workaround this the driver > had a bunch of stat

Re: [PATCH v2 6/8] drm/vmwgfx: Rename dummy to is_iomem

2023-01-31 Thread "Maaz Mombasawala (VMware)
_mapped) { > vmw_bo_unmap(vps->surf->res.backup); > vps->surf_mapped = false; > } > > - if (vps->bo && ttm_kmap_obj_virtual(&vps->bo->map, &dummy)) { > + if (vps->bo && ttm_kmap_obj_virtual(&vps->bo->map, &is_iomem)) { > const int ret = ttm_bo_reserve(&vps->bo->base, true, false, > NULL); > > if (likely(ret == 0)) { LGTM! Reviewed-by: Maaz Mombasawala -- Maaz Mombasawala (VMware)

Re: [PATCH v2 5/8] drm/vmwgfx: Cleanup the vmw bo usage in the cursor paths

2023-01-31 Thread "Maaz Mombasawala (VMware)
gt; *plane, > hotspot_x, hotspot_y); > } > > - if (vps->bo) { > - if (ttm_kmap_obj_virtual(&vps->bo->map, &dummy)) > - atomic_dec(&vps->bo->base_mapped_count); > - } > - > du->cursor_x = new_state->crtc_x + du->set_gui_x; > du->cursor_y = new_state->crtc_y + du->set_gui_y; > LGTM! Reviewed-by: Maaz Mombasawala -- Maaz Mombasawala (VMware)

Re: [PATCH v2 4/8] drm/vmwgfx: Simplify fb pinning

2023-01-31 Thread "Maaz Mombasawala (VMware)
; +} > + > static int vmw_ldu_del_active(struct vmw_private *vmw_priv, > struct vmw_legacy_display_unit *ldu) > { > @@ -145,8 +188,7 @@ static int vmw_ldu_del_active(struct vmw_private > *vmw_priv, > list_del_init(&ldu->active); > if (--(ld->num_active) == 0) { > BUG_ON(!ld->fb); > - if (ld->fb->unpin) > - ld->fb->unpin(ld->fb); > + WARN_ON(vmw_ldu_fb_unpin(ld->fb)); > ld->fb = NULL; > } > > @@ -163,11 +205,10 @@ static int vmw_ldu_add_active(struct vmw_private > *vmw_priv, > > BUG_ON(!ld->num_active && ld->fb); > if (vfb != ld->fb) { > - if (ld->fb && ld->fb->unpin) > - ld->fb->unpin(ld->fb); > + if (ld->fb) > + WARN_ON(vmw_ldu_fb_unpin(ld->fb)); > vmw_svga_enable(vmw_priv); > - if (vfb->pin) > - vfb->pin(vfb); > + WARN_ON(vmw_ldu_fb_pin(vfb)); > ld->fb = vfb; > } > LGTM! Reviewed-by: Maaz Mombasawala -- Maaz Mombasawala (VMware)

Re: [PATCH v2 3/8] drm/vmwgfx: Rename vmw_buffer_object to vmw_bo

2023-01-31 Thread "Maaz Mombasawala (VMware)
On 1/30/23 19:35, Zack Rusin wrote: > From: Zack Rusin > > The rest of the drivers which are using ttm have mostly standardized on > driver_prefix_bo as the name for subclasses of the TTM buffer object. > Make vmwgfx match the rest of the drivers and follow the same naming > semantics. > > This

Re: [PATCH v2 2/8] drm/vmwgfx: Remove the duplicate bo_free function

2023-01-31 Thread "Maaz Mombasawala (VMware)
scrn.c > @@ -445,7 +445,7 @@ vmw_sou_primary_plane_prepare_fb(struct drm_plane *plane, > vmw_overlay_pause_all(dev_priv); > ret = vmw_bo_create(dev_priv, size, > &vmw_vram_placement, > - false, true, &vmw_bo_bo_free, &vps->bo); > + false, true, &vps->bo); > vmw_overlay_resume_all(dev_priv); > if (ret) { > vps->bo = NULL; /* vmw_bo_init frees on error */ > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c > b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c > index 108a496b5d18..93b1400aed4a 100644 > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c > @@ -893,7 +893,7 @@ int vmw_compat_shader_add(struct vmw_private *dev_priv, > return -EINVAL; > > ret = vmw_bo_create(dev_priv, size, &vmw_sys_placement, > - true, true, vmw_bo_bo_free, &buf); > + true, true, &buf); > if (unlikely(ret != 0)) > goto out; > LGTM! Reviewed-by: Maaz Mombasawala -- Maaz Mombasawala (VMware)

Re: [PATCH v2 1/8] drm/vmwgfx: Use the common gem mmap instead of the custom code

2023-01-31 Thread "Maaz Mombasawala (VMware)
m_buffer_object *bo; > - int ret; > - > - if (unlikely(vma->vm_pgoff < DRM_FILE_PAGE_OFFSET_START)) > - return -EINVAL; > - > - ret = vmw_bo_vm_lookup(bdev, file_priv, vma->vm_pgoff, vma_pages(vma), > &bo); > - if (unlikely(ret != 0)) > - return ret; > - > - ret = ttm_bo_mmap_obj(vma, bo); > - if (unlikely(ret != 0)) > - goto out_unref; > - > - vma->vm_ops = &vmw_vm_ops; > - > - /* Use VM_PFNMAP rather than VM_MIXEDMAP if not a COW mapping */ > - if (!is_cow_mapping(vma->vm_flags)) > - vma->vm_flags = (vma->vm_flags & ~VM_MIXEDMAP) | VM_PFNMAP; > - > - ttm_bo_put(bo); /* release extra ref taken by ttm_bo_mmap_obj() */ > - > - return 0; > - > -out_unref: > - ttm_bo_put(bo); > - return ret; > -} > - LGTM! Reviewed-by: Maaz Mombasawala -- Maaz Mombasawala (VMware)

Re: [PATCH] drm/vmwgfx: Remove rcu locks from user resources

2022-12-07 Thread &quot;Maaz Mombasawala (VMware)
+ vmw_val_add_flag_none); > + if (unlikely(ret != 0)){ > + vmw_resource_unreference(&res); > return ret; > + } > > sw_context->dx_ctx_node = vmw_execbuf_info_from_res(sw_context, res); > sw_context->man = vmw_context_res_man(res); > > + vmw_resource_unreference(&res); > return 0; > } > > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c > b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c > index f66caa540e14..c7d645e5ec7b 100644 > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c > @@ -281,39 +281,6 @@ int vmw_user_resource_lookup_handle(struct vmw_private > *dev_priv, > return ret; > } > > -/** > - * vmw_user_resource_noref_lookup_handle - lookup a struct resource from a > - * TTM user-space handle and perform basic type checks > - * > - * @dev_priv: Pointer to a device private struct > - * @tfile:Pointer to a struct ttm_object_file identifying the caller > - * @handle: The TTM user-space handle > - * @converter:Pointer to an object describing the resource type > - * > - * If the handle can't be found or is associated with an incorrect resource > - * type, -EINVAL will be returned. > - */ > -struct vmw_resource * > -vmw_user_resource_noref_lookup_handle(struct vmw_private *dev_priv, > - struct ttm_object_file *tfile, > - uint32_t handle, > - const struct vmw_user_resource_conv > - *converter) > -{ > - struct ttm_base_object *base; > - > - base = ttm_base_object_noref_lookup(tfile, handle); > - if (!base) > - return ERR_PTR(-ESRCH); > - > - if (unlikely(ttm_base_object_type(base) != converter->object_type)) { > - ttm_base_object_noref_release(); > - return ERR_PTR(-EINVAL); > - } > - > - return converter->base_obj_to_res(base); > -} > - > /* > * Helper function that looks either a surface or bo. > * -- Maaz Mombasawala (VMware)

Re: [PATCH] drm/vmwgfx: Don't use screen objects when SEV is active

2022-12-01 Thread &quot;Maaz Mombasawala (VMware)
gt; struct drm_device *dev = &dev_priv->drm; > int i; > > + /* Screen objects won't work if GMR's aren't available */ > + if (!dev_priv->has_gmr) > + return -ENOSYS; > + > if (!(dev_priv->capabilities & SVGA_CAP_SCREEN_OBJECT_2)) { > return -ENOSYS; > } LGTM -- Maaz Mombasawala (VMware)

Re: [PATCH v3 17/17] drm/vmwgfx: Fix a sparse warning in kernel docs

2022-10-21 Thread &quot;Maaz Mombasawala (VMware)
> * This function copies fence information to user-space. If copying fails, > the > * user-space struct drm_vmw_fence_rep::error member is hopefully left -- Looks good. Reviewed-by: Maaz Mombasawala Maaz Mombasawala (VMware)