From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Zack Rusin <zack.rusin@broadcom.com>,
Maaz Mombasawala <maaz.mombasawala@broadcom.com>,
Sasha Levin <sashal@kernel.org>
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 [thread overview]
Message-ID: <20261204022021.1992989-2-sashal@kernel.org> (raw)
In-Reply-To: <20261204022021.1992989-1-sashal@kernel.org>
From: Zack Rusin <zack.rusin@broadcom.com>
[ 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 <zack.rusin@broadcom.com>
Reviewed-by: Maaz Mombasawala <maaz.mombasawala@broadcom.com>
Link: https://patch.msgid.link/20261029215700.3009996-1-zack.rusin@broadcom.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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
prev parent reply other threads:[~2026-12-04 2:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 12:52 FAILED: patch "[PATCH] drm/vmwgfx: log MOB limits outside the manager spinlock" failed to apply to 6.6-stable tree gregkh
2026-12-04 2:20 ` [PATCH 6.6.y 1/2] drm/vmwgfx: Standardize use of kibibytes when logging Sasha Levin
2026-12-04 2:20 ` Sasha Levin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204022021.1992989-2-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=maaz.mombasawala@broadcom.com \
--cc=stable@vger.kernel.org \
--cc=zack.rusin@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox