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=1796382271; b=JvTk+RkHQs2HFqgHo5wJYESrYUKDhclmhDqLb0xCiVNfzjxLZuNvrv7a0jtlCNo5kB9v t8z/Vi06LI8p6LjcNHD3TwnniHdte5LqWchHoxZ7UOcR6u/pdHoZxY9r0o6/NxsTWLtiD 5WSEPxOdqJ1OzxGz98phI0bLDlPXPznXloJnlD/s4GAcAUV8RZorvMLvG/N6w/kJ2jmku iOnY4h5bC0uvhQqMao5etQfoVygvYfgf3oSaFCeUiGGYxi1jeJoCoDaj9uIvUujgPLP1j /4FtH4i78yJnR792RDozi0uhzriRIO/61qLk1/o1SA63ym/elcgfIUzF/Z3tKN/SvfA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796382271; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=TJwPN1Q0WZF3Y3RdrNLerTViKcDvr0DOxHvVmEQjEw8=; b=Rsh/szW5PGPPnrOJp92akkez3VzZFixjHP6GVlRDbHWEcqIiQtcFfwWQoDjA6jcFZutT bw+wg247J24lyAmmY0vtTjCxL3+NDNSA2dhnODrBtWtMj03BRa2g3NSRH+m7Yo5ZD4oAm cPNHS23mwzK+8VQVKcrPFzRORxBGSlSuGjLKXrZBkLSdoX9kKSm09TMzNXI4INaxoT1tc M3rcdGP87O35UYBd0Fc7w3CAcHSHQsukSj9fv8jJX95aLxlO8v1K0+HcKi5Qa4gPkBo1J FBVHYg5ODSfev1JHErojPVFzjw6KAzenRpUlJOkribVGbMBPgpjQUKrwAbavXyCd/8A== 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=N8eNXag+; 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 C86AA606A322; Fri, 4 Dec 2026 11:04:31 +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=N8eNXag+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40A881F000CE; Fri, 4 Dec 2026 11:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796382271; bh=TJwPN1Q0WZF3Y3RdrNLerTViKcDvr0DOxHvVmEQjEw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=N8eNXag+B+4oi5egtGkp81g3niXE2EFoplHnQyfgGXuPxNfw4AFvAvjjBnoLBiXnk oj4Dzi/aq8nFf1z0GUqeWn5tkRQwFd4C0XCeyfUC/GJ5Eu1BixdCO4cbHdYlyJwxjl 59OuHmyEmq35nelhLEntrr+BhZqGTGc8tAh/EZkQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zack Rusin , Maaz Mombasawala Subject: [PATCH 6.18 382/703] drm/vmwgfx: log MOB limits outside the manager spinlock Date: Fri, 4 Dec 2026 19:04:41 +0900 Message-ID: <20261204100638.005766085@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore 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-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zack Rusin commit eee4285a8c3c918bbd21791e17f2bb261a709792 upstream. vmw_gmrid_man_get_node reports MOB limit expansion and allocation failures through vmw_host_printf while holding gman->lock. The helper formats its messages with GFP_KERNEL allocations, which may sleep. KDE startup and desktop mode changes can reach this path, producing "BUG: sleeping function called from invalid context" from kvasprintf() while the manager spinlock is held. That's likely a separate bug because KDE shouldn't be using that much memory but to debug that properly stop filling kernel logs with warnings. Defer both host messages until after dropping the spinlock. Capture the failed allocation's page limit and roll back its accounting while locked, then report the error and free the resource after unlocking. Use drm_warn for the guest messages so they identify the device. Fixes: cfdc3458db8a ("drm/vmwgfx: Be a lot more flexible with MOB limits") Cc: stable@vger.kernel.org Assisted-by: LLM Signed-off-by: Zack Rusin Reviewed-by: Maaz Mombasawala Link: https://patch.msgid.link/20261029215700.3009996-1-zack.rusin@broadcom.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 55 ++++++++++++++++---------- 1 file changed, 34 insertions(+), 21 deletions(-) --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c @@ -54,8 +54,11 @@ static int vmw_gmrid_man_get_node(struct const struct ttm_place *place, struct ttm_resource **res) { + struct vmw_private *vmw = vmw_priv_from_ttm(bo->bdev); struct vmwgfx_gmrid_man *gman = to_gmrid_manager(man); - int id; + u32 max_gmr_pages = 0; + bool mob_overflow = false; + int id, ret = 0; *res = kmalloc(sizeof(**res), GFP_KERNEL); if (!*res) @@ -85,43 +88,53 @@ static int vmw_gmrid_man_get_node(struct const unsigned long max_graphics_pages = totalram_pages() / 2; uint32_t new_max_pages = 0; - DRM_WARN("vmwgfx: mob memory overflow. Consider increasing guest RAM and graphicsMemory.\n"); - vmw_host_printf("vmwgfx, warning: mob memory overflow. Consider increasing guest RAM and graphicsMemory.\n"); + mob_overflow = true; + drm_warn(&vmw->drm, + "vmwgfx: mob memory overflow. Consider increasing guest RAM and graphicsMemory.\n"); if (gman->max_gmr_pages > (max_graphics_pages / 2)) { - DRM_WARN("vmwgfx: guest requires more than half of RAM for graphics.\n"); + drm_warn(&vmw->drm, + "vmwgfx: guest requires more than half of RAM for graphics.\n"); new_max_pages = max_graphics_pages; } else new_max_pages = gman->max_gmr_pages * 2; if (new_max_pages > gman->max_gmr_pages && new_max_pages >= gman->used_gmr_pages) { - DRM_WARN("vmwgfx: increasing guest mob limits to %u KiB.\n", - ((new_max_pages) << (PAGE_SHIFT - 10))); + drm_warn(&vmw->drm, + "vmwgfx: increasing guest mob limits to %u KiB.\n", + new_max_pages << (PAGE_SHIFT - 10)); gman->max_gmr_pages = new_max_pages; } else { - char buf[256]; - snprintf(buf, sizeof(buf), - "vmwgfx, error: guest graphics is out of memory (mob limit at: %u KiB).\n", - ((gman->max_gmr_pages) << (PAGE_SHIFT - 10))); - vmw_host_printf(buf); - DRM_WARN("%s", buf); - goto nospace; + max_gmr_pages = gman->max_gmr_pages; + gman->used_gmr_pages -= PFN_UP((*res)->size); + ret = -ENOSPC; + goto out_unlock; } } } (*res)->start = id; +out_unlock: spin_unlock(&gman->lock); - return 0; -nospace: - gman->used_gmr_pages -= PFN_UP((*res)->size); - spin_unlock(&gman->lock); - ida_free(&gman->gmr_ida, id); - ttm_resource_fini(man, *res); - kfree(*res); - return -ENOSPC; + /* Host logging allocates with GFP_KERNEL and must run unlocked. */ + if (mob_overflow) + vmw_host_printf("%s", + "vmwgfx, warning: mob memory overflow. Consider increasing guest RAM and graphicsMemory.\n"); + if (ret) { + char buf[256]; + + snprintf(buf, sizeof(buf), + "vmwgfx, error: guest graphics is out of memory (mob limit at: %u KiB).\n", + max_gmr_pages << (PAGE_SHIFT - 10)); + vmw_host_printf("%s", buf); + drm_warn(&vmw->drm, "%s", buf); + ida_free(&gman->gmr_ida, id); + ttm_resource_fini(man, *res); + kfree(*res); + } + return ret; } static void vmw_gmrid_man_put_node(struct ttm_resource_manager *man,