From: Matthew Brost <matthew.brost@intel.com>
To: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
Cc: dri-devel@lists.freedesktop.org,
"Tomasz Rusinowicz" <tomasz.rusinowicz@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Lucas De Marchi" <lucas.demarchi@intel.com>,
"Michal Wajdeczko" <michal.wajdeczko@intel.com>,
"Matthew Auld" <matthew.auld@intel.com>,
"Nirmoy Das" <nirmoy.das@intel.com>,
"Jani Nikula" <jani.nikula@intel.com>,
intel-xe@lists.freedesktop.org, stable@vger.kernel.org
Subject: Re: [PATCH] drm/xe: Fix exporting xe buffers multiple times
Date: Tue, 18 Feb 2025 19:40:37 -0800 [thread overview]
Message-ID: <Z7VStWVBzGAY2yAf@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20250218100353.2137964-1-jacek.lawrynowicz@linux.intel.com>
On Tue, Feb 18, 2025 at 11:03:53AM +0100, Jacek Lawrynowicz wrote:
> From: Tomasz Rusinowicz <tomasz.rusinowicz@intel.com>
>
> The `struct ttm_resource->placement` contains TTM_PL_FLAG_* flags, but
> it was incorrectly tested for XE_PL_* flags.
> This caused xe_dma_buf_pin() to always fail when invoked for
> the second time. Fix this by checking the `mem_type` field instead.
>
> Fixes: 7764222d54b7 ("drm/xe: Disallow pinning dma-bufs in VRAM")
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Cc: Nirmoy Das <nirmoy.das@intel.com>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: intel-xe@lists.freedesktop.org
> Cc: <stable@vger.kernel.org> # v6.8+
> Signed-off-by: Tomasz Rusinowicz <tomasz.rusinowicz@intel.com>
> Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
> ---
> drivers/gpu/drm/xe/xe_bo.h | 2 --
> drivers/gpu/drm/xe/xe_dma_buf.c | 2 +-
> 2 files changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
> index d9386ab031404..43bf6f140d40d 100644
> --- a/drivers/gpu/drm/xe/xe_bo.h
> +++ b/drivers/gpu/drm/xe/xe_bo.h
> @@ -341,7 +341,6 @@ static inline unsigned int xe_sg_segment_size(struct device *dev)
> return round_down(max / 2, PAGE_SIZE);
> }
>
> -#if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
> /**
> * xe_bo_is_mem_type - Whether the bo currently resides in the given
> * TTM memory type
> @@ -356,4 +355,3 @@ static inline bool xe_bo_is_mem_type(struct xe_bo *bo, u32 mem_type)
> return bo->ttm.resource->mem_type == mem_type;
> }
> #endif
> -#endif
> diff --git a/drivers/gpu/drm/xe/xe_dma_buf.c b/drivers/gpu/drm/xe/xe_dma_buf.c
> index c5b95470fa324..f67803e15a0e6 100644
> --- a/drivers/gpu/drm/xe/xe_dma_buf.c
> +++ b/drivers/gpu/drm/xe/xe_dma_buf.c
> @@ -58,7 +58,7 @@ static int xe_dma_buf_pin(struct dma_buf_attachment *attach)
> * 1) Avoid pinning in a placement not accessible to some importers.
> * 2) Pinning in VRAM requires PIN accounting which is a to-do.
> */
> - if (xe_bo_is_pinned(bo) && bo->ttm.resource->placement != XE_PL_TT) {
> + if (xe_bo_is_pinned(bo) && !xe_bo_is_mem_type(bo, XE_PL_TT)) {
This fix looks correct. With that:
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
But question for Thomas. I'm thinking as a follow up we rename this
variable in TTM to something like placement_flags to avoid confusion
like this. What do you think?
Matt
> drm_dbg(&xe->drm, "Can't migrate pinned bo for dma-buf pin.\n");
> return -EINVAL;
> }
> --
> 2.45.1
>
prev parent reply other threads:[~2025-02-19 3:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-18 10:03 [PATCH] drm/xe: Fix exporting xe buffers multiple times Jacek Lawrynowicz
2025-02-18 11:07 ` ✓ CI.Patch_applied: success for " Patchwork
2025-02-18 11:07 ` ✓ CI.checkpatch: " Patchwork
2025-02-18 11:08 ` ✓ CI.KUnit: " Patchwork
2025-02-18 11:25 ` ✓ CI.Build: " Patchwork
2025-02-18 11:27 ` ✓ CI.Hooks: " Patchwork
2025-02-18 11:29 ` ✓ CI.checksparse: " Patchwork
2025-02-18 11:49 ` ✓ Xe.CI.BAT: " Patchwork
2025-02-18 23:56 ` ✗ Xe.CI.Full: failure " Patchwork
2025-02-19 3:40 ` Matthew Brost [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=Z7VStWVBzGAY2yAf@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jacek.lawrynowicz@linux.intel.com \
--cc=jani.nikula@intel.com \
--cc=lucas.demarchi@intel.com \
--cc=matthew.auld@intel.com \
--cc=michal.wajdeczko@intel.com \
--cc=nirmoy.das@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=stable@vger.kernel.org \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tomasz.rusinowicz@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