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=1796350861; b=BpjlXzkh7WXO0PSFYDHjtiOIcz1iDqFhD/QMzA83rnsQC2likYHw2qJiWlbEpkj4UDVu +Ke68h2MaqTizRwNe4WI8OVW2q+OxPIcG9wrt+RYdIZ00Gya37m5trWtjQz8mkiOmnZ+M XeCDnxqYELofuDCCZE/bzIs3W37d78mycXDnYn9wc85rgCJdL9qNezY3O/Geuwf2vGg7z 8PoNBJhdjg1Axg/gy+SQeynMgk5Sg4lEUh5elidol+l/wAx0grUuoIavoN3qWp05OQW4E klaLVYulvZkxqIDcUMsy24fdnrPzSApUdX+/ZTRjTw8HIxjDUeQbCDDGH22kySR33Ww== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796350861; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=jDETkyCf/SDz0k1TWn7H6r94D3WY2GKgYy5Lr/jMTHw=; b=rTX1H02eicfgIEWETozxG4FTOEeh9gZ/gV5Q9JtYknozBeP1rAz6M4aqTjgb70rXggto LVtWKc2fob2kZ/t9/hQ1YAqP9ZxVqU3CkU2O9+0yw7xHVeMcYarWFp1OeJL7j6ezPOwfq vW2VAyXPm7io6Z6k0UIMGD2wz7j9ezYylsvb054cZ8XAmK1+x9TR0ehAjAL5TgfhpegyA U5azVtVsonmk/hJe6M7LyEAKa8+9ZguQIrt9HrVywWHY3HvV04X8bYMberIAqIiDKbuCL zvhlZJdNBGdr7D2ptsI4knJp3EcXjpkqYWMKYMJ5F17Fu1iuwBcp0nGFqoQ3oZ/qwew== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Z1bFGbpe; 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 1E8F260A260D for ; Fri, 4 Dec 2026 02:21:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Z1bFGbpe Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F7601F00A02; Fri, 4 Dec 2026 02:21:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796350861; bh=jDETkyCf/SDz0k1TWn7H6r94D3WY2GKgYy5Lr/jMTHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Z1bFGbpejGcxVyiWWgMH4ZWP2CQBm/a2gvbY/kMoEsmBBmbqEeBFKwv94erWzGWln Zb7+NWnFxDvDmSGZ4j7xI88howtD8CKTnGuAQywUdynxIuDFmMbA9470ee1ODQ1YFk y7EEplqm+Z3MeLsq9dUCSEhj1fUn17GEeE683vXMzUhWY0yWXI67fZN0ntVqJiMQnP HUziXlqsDcdBeQoIRkR4sM2iDHPWVww3h19j8I/AE7vnsoRRYGX7oIWPMqjFwpoOAa 3srZZkooHEC2hry9QCZ2kntchdA/cmHVW07oCh9DdPAjfXrbOjPFuVR+HuQKspN3Hg 4TnUAll9qahaA== From: Sasha Levin To: stable@vger.kernel.org Cc: Zack Rusin , Maaz Mombasawala , Sasha Levin Subject: [PATCH 6.6.y 2/2] drm/vmwgfx: log MOB limits outside the manager spinlock Date: Thu, 3 Dec 2026 21:20:58 -0500 Message-ID: <20261204022021.1992989-2-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261204022021.1992989-1-sashal@kernel.org> References: <2026120217-blob-aloha-1ce7@gregkh> <20261204022021.1992989-1-sashal@kernel.org> 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 From: Zack Rusin [ Upstream commit eee4285a8c3c918bbd21791e17f2bb261a709792 ] 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: Sasha Levin --- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 55 ++++++++++++------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c index 5bd967fbcf554..04eddb19e6d9d 100644 --- 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 ttm_resource_manager *man, 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 ttm_resource_manager *man, 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, -- 2.53.0