From: sashiko-bot@kernel.org
To: "Matthew Schwartz" <matthew.schwartz@linux.dev>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [RFC PATCH] drm/amd/display: Pin native scanout to VRAM on large-carveout APUs
Date: Tue, 16 Jun 2026 07:21:22 +0000 [thread overview]
Message-ID: <20260616072122.8632F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260616071037.26718-1-matthew.schwartz@linux.dev>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The GTT fallback logic fails to handle `-EINVAL` for shared framebuffers and `-ENOSPC` when VRAM is full, breaking atomic commits.
- [High] Unconditional pinning to VRAM causes severe CPU thrashing and dmesg spam on every page flip under memory pressure.
--
commit 56a58731a1850c7efcd10ad3db0b21ff08dd0a48
Author: Matthew Schwartz <matthew.schwartz@linux.dev>
Subject: drm/amd/display: Pin native scanout to VRAM on large-carveout APUs
This patch modifies the framebuffer preparation logic to pin native scanout
buffers in VRAM for APUs with large carveouts. If the VRAM allocation fails,
it falls back to GTT to ensure the swapchain remains in a single memory domain.
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
> index 23a9faa2ea89f..8a5d03185c479 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
> @@ -958,13 +959,35 @@ static int amdgpu_dm_plane_helper_prepare_fb(struct drm_plane *plane,
> if (r)
> goto error_unlock;
>
> - if (plane->type != DRM_PLANE_TYPE_CURSOR)
> - domain = amdgpu_display_supported_domains(adev, rbo->flags);
> - else
> + /*
> + * Pin native scanout in VRAM on APUs so a swapchain stays in one
> + * memory domain. A VRAM/GTT split changes its mem_type between flips
> + * and amdgpu_dm_crtc_mem_type_changed() rejects the async flip. Skip
> + * small carveouts that may not fit, and imported buffers.
> + */
> + pin_vram_only = plane->type != DRM_PLANE_TYPE_CURSOR &&
> + (adev->flags & AMD_IS_APU) &&
> + !rbo->tbo.base.import_attach &&
> + adev->gmc.real_vram_size > AMDGPU_SG_THRESHOLD;
> +
> + if (plane->type == DRM_PLANE_TYPE_CURSOR || pin_vram_only)
> domain = AMDGPU_GEM_DOMAIN_VRAM;
> + else
> + domain = amdgpu_display_supported_domains(adev, rbo->flags);
>
> rbo->flags |= AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS;
> r = amdgpu_bo_pin(rbo, domain);
[Severity: High]
Does this unconditional VRAM pinning attempt cause severe CPU thrashing and
dmesg spam on every page flip under memory pressure?
Since prepare_fb runs on every page flip for unpinned swapchain buffers, a
full VRAM might cause amdgpu_bo_pin() to perform an expensive memory eviction
search and log a hard error via dev_err() 60 times a second.
Additionally, if a buffer was previously placed in GTT via the fallback and
unpinned, the next page flip will attempt to migrate it back to VRAM, causing
an eviction storm.
> + if (r == -ENOMEM && pin_vram_only) {
[Severity: High]
Will this strict check for -ENOMEM fail to handle -EINVAL and -ENOSPC, causing
the VRAM-to-GTT fallback to be skipped?
When VRAM is full, TTM's allocation often returns -ENOSPC instead of -ENOMEM.
If a framebuffer is shared across planes (e.g., cloned displays) and the first
plane falls back to GTT, the buffer is pinned in GTT with pin_count = 1.
When the second plane calls amdgpu_bo_pin() with AMDGPU_GEM_DOMAIN_VRAM,
it returns -EINVAL.
Skipping the fallback in these cases would break the atomic commit.
> + /*
> + * VRAM could not fit the buffer. Fall back to GTT where
> + * allowed so the swapchain stays in one domain.
> + */
> + domain = amdgpu_display_supported_domains(adev, rbo->flags);
> + if (domain & AMDGPU_GEM_DOMAIN_GTT) {
> + domain = AMDGPU_GEM_DOMAIN_GTT;
> + r = amdgpu_bo_pin(rbo, domain);
> + }
> + }
> if (unlikely(r != 0)) {
> if (r != -ERESTARTSYS)
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260616071037.26718-1-matthew.schwartz@linux.dev?part=1
next prev parent reply other threads:[~2026-06-16 7:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 7:10 [RFC PATCH] drm/amd/display: Pin native scanout to VRAM on large-carveout APUs Matthew Schwartz
2026-06-16 7:21 ` sashiko-bot [this message]
2026-06-16 7:31 ` Christian König
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=20260616072122.8632F1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=matthew.schwartz@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.