From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796220899; b=jC24/09L2wWHzRRRX/4m9TYETaJkHCHDwAaNrNLj69ssjkNfk2jn/uBPXSvgKKY15ESr WvPJnm7RG9ro0+PYtkCgFiFX60rukhX6cGVSOJhLW85/XRysDzifwLzoK/Nw+nlzSn8EU M0/OAG4RxDbC1Y13zmkDIt1HogfgBJrmmsJ78+BXANPxz4ixo9IubqiePdy2v/XB/bes0 pGD2haE4LcZnGcdq6oCea97tR+VvPdvEesSKTXKq6O0vnCBEN2rlqRF10px1b7c0LeT34 feerzwxoKN2jUfv0ZMqBJADeVWAjSZ2ww43+YynoqcEXSMNn9Ei/l6jDNeSpuzYtJyg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796220899; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=YpDCP8HCUnxwpvAFfBEVmQUzAbOQ0v+1IXsIJ6PYG68=; b=zwW9flDvOeTiDJARm+JGvSSnjUtnNnNJRmlLzGljjtNs/CkCqqTQ+6QpR4fZyFiePNCX rpfSnvLxeX3gjM7XLFjTApuFMCA4ITQy6qi0iZtJjV/JlHtiZXK65pt4xwXcujQ3G9ESL 6af7j/3R5OjXL1rS/DGug5afDHQkg8Is8kb0QoViNFsQf4G8AH1QFDsDC5+AALMM0xEtN miZ7Yp/lZW2EumNxeIHLIMEk+tHxs7ertAJVcVfOQ6j8peAd40YnMhzwp4xKdJWfIcCXq At1rgiqmb48BiWZozWavRsp2hUiRYNuk2vp/oxV+3NBPCKPhR8hH9zLFuTg/IgDblzA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=MjB6Ku9l; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4231F606A322 for ; Wed, 2 Dec 2026 14:14:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=MjB6Ku9l Received: by smtp.kernel.org (Postfix) with ESMTPSA id 795CD1F000C1; Wed, 2 Dec 2026 14:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796220899; bh=YpDCP8HCUnxwpvAFfBEVmQUzAbOQ0v+1IXsIJ6PYG68=; h=Subject:To:Cc:From:Date; b=MjB6Ku9l3PpD5Fj5ZkyP1rZowAx/WVzjIqjQgbAyK6WgRxlBJGjQlt3xHNxTn0+7f 89rZxLjwU0r1d6jeJ7M5hMkI2iteLxgdFnYKKztMBK/aC+zd3PSk/V66Ha1CTEhxvo d2Rt/U5yO1oed2cI4VrhSSyW6B42VvBehByMNuq8= Subject: FAILED: patch "[PATCH] drm/vmwgfx: keep cursor mappings and pins with each plane" failed to apply to 6.6-stable tree To: zack.rusin@broadcom.com,maaz.mombasawala@broadcom.com,yunfeng.li.nb@gmail.com Cc: From: Date: Wed, 02 Dec 2026 13:51:52 +0100 Message-ID: <2026120252-promoter-rebuilt-369e@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.6-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y git checkout FETCH_HEAD git cherry-pick -x 556271f0ade9d3f1ed0a386f29d3363be294c1fc # git commit -s git send-email --to '' --in-reply-to '2026120252-promoter-rebuilt-369e@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 556271f0ade9d3f1ed0a386f29d3363be294c1fc Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 27 Oct 2026 02:07:05 -0400 Subject: [PATCH] drm/vmwgfx: keep cursor mappings and pins with each plane state Cursor plane states duplicate the user object reference without acquiring its mapping or pin. Preparing the duplicated state nevertheless unmaps that object, and only pins the new buffer if it is not already pinned. Cleanup of an older state can therefore remove a mapping or pin still needed by another cursor commit. Repeated cursor updates from KMS clients can then access an unmapped or movable buffer. Give each prepared state its own mapping, buffer reference and pin, and reset the mapping when duplicating a state. Release only the resources owned by that state in cleanup_fb(). Map the required image extent for every state so resizing a cursor on the same buffer cannot reuse a smaller cached mapping. Unwind the pin and reservation if preparation fails. Fixes: 965544150d1c ("drm/vmwgfx: Refactor cursor handling") Cc: stable@vger.kernel.org Assisted-by: LLM Signed-off-by: Zack Rusin Reviewed-by: Maaz Mombasawala Tested-by: fausten Link: https://patch.msgid.link/20261027211729.646988-2-zack.rusin@broadcom.com diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c index 5a69606a0593..942d07079ef7 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c @@ -112,8 +112,7 @@ static void vmw_cursor_update_mob(struct vmw_private *vmw, { SVGAGBCursorHeader *header; SVGAGBAlphaCursorHeader *alpha_header; - struct vmw_bo *bo = vmw_user_object_buffer(&vps->uo); - u32 *image = vmw_bo_map_and_cache(bo); + u32 *image = vps->cursor.map.virtual; const u32 image_size = vps->base.crtc_w * vps->base.crtc_h * sizeof(*image); header = vmw_bo_map_and_cache(vps->cursor.mob); @@ -132,7 +131,6 @@ static void vmw_cursor_update_mob(struct vmw_private *vmw, memcpy(header + 1, image, image_size); vmw_write(vmw, SVGA_REG_CURSOR_MOBID, vmw_bo_mobid(vps->cursor.mob)); - vmw_bo_unmap(bo); vmw_bo_unmap(vps->cursor.mob); } @@ -490,9 +488,21 @@ vmw_cursor_plane_cleanup_fb(struct drm_plane *plane, { struct vmw_cursor_plane *vcp = vmw_plane_to_vcp(plane); struct vmw_plane_state *vps = vmw_plane_state_to_vps(old_state); + struct vmw_bo *bo; + int ret; - if (!vmw_user_object_is_null(&vps->uo)) - vmw_user_object_unmap(&vps->uo); + if (vps->cursor.map.bo) { + bo = to_vmw_bo(&vps->cursor.map.bo->base); + ret = ttm_bo_reserve(&bo->tbo, false, false, NULL); + if (WARN_ON_ONCE(ret)) + return; + + ttm_bo_kunmap(&vps->cursor.map); + vps->cursor.map.bo = NULL; + ttm_bo_unpin(&bo->tbo); + ttm_bo_unreserve(&bo->tbo); + vmw_bo_unreference(&bo); + } vmw_cursor_mob_unmap(vps); vmw_cursor_mob_put(vcp, vps); @@ -625,10 +635,12 @@ int vmw_cursor_plane_prepare_fb(struct drm_plane *plane, struct vmw_surface *surface; int ret = 0; - if (!vmw_user_object_is_null(&vps->uo)) { - vmw_user_object_unmap(&vps->uo); + /* + * A duplicated state only owns the user object reference. Its mappings + * and pins belong to the old state until cleanup_fb(). + */ + if (!vmw_user_object_is_null(&vps->uo)) vmw_user_object_unref(&vps->uo); - } if (fb) { if (vmw_framebuffer_to_vfb(fb)->bo) { @@ -652,31 +664,34 @@ int vmw_cursor_plane_prepare_fb(struct drm_plane *plane, bo = vmw_user_object_buffer(&vps->uo); if (bo) { struct ttm_operation_ctx ctx = { false, false }; + size_t size = (size_t)new_state->crtc_w * + new_state->crtc_h * sizeof(u32); ret = ttm_bo_reserve(&bo->tbo, true, false, NULL); if (ret != 0) - return -ENOMEM; + return ret; ret = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx); if (ret != 0) - return -ENOMEM; + goto out_unreserve; /* - * vmw_bo_pin_reserved also validates, so to skip - * the extra validation use ttm_bo_pin directly + * vmw_bo_pin_reserved() also validates, so to skip + * the extra validation use ttm_bo_pin directly. + * Every state takes its own pin, the buffer can + * still be in use by an older state whose commit + * hasn't been cleaned up yet. */ - if (!bo->tbo.pin_count) - ttm_bo_pin(&bo->tbo); + ttm_bo_pin(&bo->tbo); - if (vmw_framebuffer_to_vfb(fb)->bo) { - const u32 size = new_state->crtc_w * - new_state->crtc_h * - sizeof(u32); - - (void)vmw_bo_map_and_cache_size(bo, size); - } else { - vmw_bo_map_and_cache(bo); + ret = ttm_bo_kmap(&bo->tbo, 0, PFN_UP(size), + &vps->cursor.map); + if (ret) { + vps->cursor.map.bo = NULL; + ttm_bo_unpin(&bo->tbo); + goto out_unreserve; } + vmw_bo_reference(bo); ttm_bo_unreserve(&bo->tbo); } if (!vmw_user_object_is_null(&vps->uo)) { @@ -703,6 +718,10 @@ int vmw_cursor_plane_prepare_fb(struct drm_plane *plane, } return 0; + +out_unreserve: + ttm_bo_unreserve(&bo->tbo); + return ret; } /** @@ -796,7 +815,6 @@ void vmw_cursor_plane_atomic_update(struct drm_plane *plane, struct drm_atomic_commit *state) { - struct vmw_bo *bo; struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state, plane); struct drm_plane_state *old_state = @@ -823,9 +841,8 @@ vmw_cursor_plane_atomic_update(struct drm_plane *plane, vmw_cursor_update_mob(dev_priv, vps); break; case VMW_CURSOR_UPDATE_GB_ONLY: - bo = vmw_user_object_buffer(&vps->uo); - if (bo) - vmw_send_define_cursor_cmd(dev_priv, bo->map.virtual, + if (vps->cursor.map.virtual) + vmw_send_define_cursor_cmd(dev_priv, vps->cursor.map.virtual, vps->base.crtc_w, vps->base.crtc_h, vps->base.hotspot_x, diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.h b/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.h index d32cf17d013b..9b50f80f9635 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.h @@ -14,6 +14,8 @@ #include "drm/drm_fourcc.h" #include "drm/drm_plane.h" +#include + #include struct SVGA3dCmdHeader; @@ -41,6 +43,8 @@ struct vmw_cursor_plane_state { enum vmw_cursor_update_type update_type; bool changed; bool surface_changed; + /* The mapped buffer is referenced and pinned by this state. */ + struct ttm_bo_kmap_obj map; struct vmw_bo *mob; struct { s32 hotspot_x; diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index a6c3304e1a67..f196e29f1b3b 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -275,6 +275,7 @@ vmw_du_plane_duplicate_state(struct drm_plane *plane) vps->cpp = 0; vps->cursor.mob = NULL; + memset(&vps->cursor.map, 0, sizeof(vps->cursor.map)); /* Each ref counted resource needs to be acquired again */ vmw_user_object_ref(&vps->uo);