Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: intel-xe@lists.freedesktop.org
Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Matthew Brost" <matthew.brost@intel.com>,
	dri-devel@lists.freedesktop.org
Subject: [RFC PATCH] drm/ttm: Forward -ENOSPC to drivers requesting it
Date: Tue,  3 Sep 2024 15:38:49 +0200	[thread overview]
Message-ID: <20240903133849.17119-1-thomas.hellstrom@linux.intel.com> (raw)

Some user-space APIs distinguison between graphics memory OOMs and
system (host) memory OOMs. To aid UMDs in determining the type of
OOM, allow forwarding the ENOSPC from resource managers to drivers
on calls to ttm_bo_validate().

Cc: Christian König <christian.koenig@amd.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 2 +-
 include/drm/ttm/ttm_bo.h     | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index dd867b5e744c..d9a320dc8130 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -836,7 +836,7 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
 	} while (ret && force_space);
 
 	/* For backward compatibility with userspace */
-	if (ret == -ENOSPC)
+	if (ret == -ENOSPC && !ctx->forward_enospc)
 		return -ENOMEM;
 
 	/*
diff --git a/include/drm/ttm/ttm_bo.h b/include/drm/ttm/ttm_bo.h
index 5804408815be..d3e12318d336 100644
--- a/include/drm/ttm/ttm_bo.h
+++ b/include/drm/ttm/ttm_bo.h
@@ -174,6 +174,8 @@ struct ttm_bo_kmap_obj {
  * BOs share the same reservation object.
  * @force_alloc: Don't check the memory account during suspend or CPU page
  * faults. Should only be used by TTM internally.
+ * @forward_enospc: Don't translate -ENOSPC errors from resource managers to
+ * -ENOMEM, but forward them to the driver.
  * @resv: Reservation object to allow reserved evictions with.
  * @bytes_moved: Statistics on how many bytes have been moved.
  *
@@ -185,6 +187,7 @@ struct ttm_operation_ctx {
 	bool no_wait_gpu;
 	bool gfp_retry_mayfail;
 	bool allow_res_evict;
+	bool forward_enospc;
 	bool force_alloc;
 	struct dma_resv *resv;
 	uint64_t bytes_moved;
-- 
2.46.0


             reply	other threads:[~2024-09-03 13:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-03 13:38 Thomas Hellström [this message]
2024-09-03 15:14 ` [RFC PATCH] drm/ttm: Forward -ENOSPC to drivers requesting it Christian König
2024-09-03 15:22   ` Thomas Hellström
2024-09-03 15:24     ` Christian König
2024-09-03 18:41 ` ✓ CI.Patch_applied: success for " Patchwork
2024-09-03 18:41 ` ✓ CI.checkpatch: " Patchwork
2024-09-03 18:42 ` ✓ CI.KUnit: " Patchwork
2024-09-03 18:54 ` ✓ CI.Build: " Patchwork
2024-09-03 18:56 ` ✓ CI.Hooks: " Patchwork
2024-09-03 18:58 ` ✗ CI.checksparse: warning " Patchwork
2024-09-03 19:17 ` ✓ CI.BAT: success " Patchwork
2024-09-03 20:47 ` ✗ CI.FULL: failure " Patchwork

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=20240903133849.17119-1-thomas.hellstrom@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@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