From: Matthew Brost <matthew.brost@intel.com>
To: Matthew Auld <matthew.auld@intel.com>
Cc: intel-xe@lists.freedesktop.org,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
stable@vger.kernel.org,
"Christian König" <christian.koenig@amd.com>
Subject: Re: [PATCH] drm/xe/dma_buf: stop relying on placement in unmap
Date: Wed, 16 Apr 2025 22:01:55 -0700 [thread overview]
Message-ID: <aACLQ/DBwpoeR1+H@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20250410162716.159403-2-matthew.auld@intel.com>
On Thu, Apr 10, 2025 at 05:27:17PM +0100, Matthew Auld wrote:
> The is_vram() is checking the current placement, however if we consider
> exported VRAM with dynamic dma-buf, it looks possible for the xe driver
> to async evict the memory, notifying the importer, however importer does
> not have to call unmap_attachment() immediately, but rather just as
> "soon as possible", like when the dma-resv idles. Following from this we
> would then pipeline the move, attaching the fence to the manager, and
> then update the current placement. But when the unmap_attachment() runs
> at some later point we might see that is_vram() is now false, and take
> the complete wrong path when dma-unmapping the sg, leading to
> explosions.
>
> To fix this check if the sgl was mapping a struct page.
>
> v2:
> - The attachment can be mapped multiple times it seems, so we can't
> really rely on encoding something in the attachment->priv. Instead
> see if the page_link has an encoded struct page. For vram we expect
> this to be NULL.
>
> Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/4563
> Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs")
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> Cc: <stable@vger.kernel.org> # v6.8+
> Acked-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/xe/xe_dma_buf.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_dma_buf.c b/drivers/gpu/drm/xe/xe_dma_buf.c
> index f67803e15a0e..f7a20264ea33 100644
> --- a/drivers/gpu/drm/xe/xe_dma_buf.c
> +++ b/drivers/gpu/drm/xe/xe_dma_buf.c
> @@ -145,10 +145,7 @@ static void xe_dma_buf_unmap(struct dma_buf_attachment *attach,
> struct sg_table *sgt,
> enum dma_data_direction dir)
> {
> - struct dma_buf *dma_buf = attach->dmabuf;
> - struct xe_bo *bo = gem_to_xe_bo(dma_buf->priv);
> -
> - if (!xe_bo_is_vram(bo)) {
> + if (sg_page(sgt->sgl)) {
> dma_unmap_sgtable(attach->dev, sgt, dir, 0);
> sg_free_table(sgt);
> kfree(sgt);
> --
> 2.49.0
>
next prev parent reply other threads:[~2025-04-17 5:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-10 16:27 [PATCH] drm/xe/dma_buf: stop relying on placement in unmap Matthew Auld
2025-04-10 18:02 ` ✓ CI.Patch_applied: success for drm/xe/dma_buf: stop relying on placement in unmap (rev2) Patchwork
2025-04-10 18:02 ` ✓ CI.checkpatch: " Patchwork
2025-04-10 18:03 ` ✓ CI.KUnit: " Patchwork
2025-04-10 18:12 ` ✓ CI.Build: " Patchwork
2025-04-10 18:14 ` ✓ CI.Hooks: " Patchwork
2025-04-10 18:15 ` ✓ CI.checksparse: " Patchwork
2025-04-10 18:37 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-04-10 23:38 ` ✗ Xe.CI.Full: " Patchwork
2025-04-17 5:01 ` Matthew Brost [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-04-03 14:07 [PATCH] drm/xe/dma_buf: stop relying on placement in unmap Matthew Auld
2025-04-03 14:56 ` Matthew Auld
2025-04-03 21:13 ` Matthew Brost
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=aACLQ/DBwpoeR1+H@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=christian.koenig@amd.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--cc=stable@vger.kernel.org \
--cc=thomas.hellstrom@linux.intel.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