AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>,
	amd-gfx@lists.freedesktop.org, 	dri-devel@lists.freedesktop.org
Cc: kernel-dev@igalia.com,
	"Christian König" <christian.koenig@amd.com>,
	"Matthew Brost" <matthew.brost@intel.com>
Subject: Re: [PATCH v5 6/6] drm/ttm: Add an allocation flag to propagate -ENOSPC on OOM
Date: Tue, 21 Oct 2025 16:11:14 +0200	[thread overview]
Message-ID: <1ddcf0013b858e3bad20de420632259ad4d8a616.camel@linux.intel.com> (raw)
In-Reply-To: <20251020115411.36818-7-tvrtko.ursulin@igalia.com>

On Mon, 2025-10-20 at 12:54 +0100, Tvrtko Ursulin wrote:
> Some graphics APIs differentiate between out-of-graphics-memory and
> out-of-host-memory (system memory). Add a device init flag to have -
> ENOSPC
> propagated from the resource managers instead of being converted to
> -ENOMEM, to aid driver stacks in determining what error code to
> return or
> whether corrective action can be taken at the driver level.
> 
> Co-developed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
> ---
> Thomas, feel free to take the ownership if you end up liking this
> version.
> As you can see I lifted your commit text as is and the implementation
> is
> the same on the high level.

Let's keep it like this. Thanks for doing this. I'll follow up with
xeKMD change once this gets backmerged.

FWIW:
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>


> ---
>  drivers/gpu/drm/ttm/ttm_bo.c     | 4 +++-
>  drivers/gpu/drm/ttm/ttm_device.c | 1 +
>  include/drm/ttm/ttm_allocation.h | 1 +
>  include/drm/ttm/ttm_device.h     | 5 +++++
>  4 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c
> b/drivers/gpu/drm/ttm/ttm_bo.c
> index fba2a68a556e..15b3cb199d45 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -31,6 +31,7 @@
>  
>  #define pr_fmt(fmt) "[TTM] " fmt
>  
> +#include <drm/ttm/ttm_allocation.h>
>  #include <drm/ttm/ttm_bo.h>
>  #include <drm/ttm/ttm_placement.h>
>  #include <drm/ttm/ttm_tt.h>
> @@ -877,7 +878,8 @@ int ttm_bo_validate(struct ttm_buffer_object *bo,
>  
>  	/* For backward compatibility with userspace */
>  	if (ret == -ENOSPC)
> -		return -ENOMEM;
> +		return bo->bdev->alloc_flags &
> TTM_ALLOCATION_PROPAGATE_ENOSPC ?
> +		       ret : -ENOMEM;
>  
>  	/*
>  	 * We might need to add a TTM.
> diff --git a/drivers/gpu/drm/ttm/ttm_device.c
> b/drivers/gpu/drm/ttm/ttm_device.c
> index 87c85ccb21ac..5c10e5fbf43b 100644
> --- a/drivers/gpu/drm/ttm/ttm_device.c
> +++ b/drivers/gpu/drm/ttm/ttm_device.c
> @@ -227,6 +227,7 @@ int ttm_device_init(struct ttm_device *bdev,
> const struct ttm_device_funcs *func
>  		return -ENOMEM;
>  	}
>  
> +	bdev->alloc_flags = alloc_flags;
>  	bdev->funcs = funcs;
>  
>  	ttm_sys_man_init(bdev);
> diff --git a/include/drm/ttm/ttm_allocation.h
> b/include/drm/ttm/ttm_allocation.h
> index 8f8544760306..655d1e44aba7 100644
> --- a/include/drm/ttm/ttm_allocation.h
> +++ b/include/drm/ttm/ttm_allocation.h
> @@ -7,5 +7,6 @@
>  #define TTM_ALLOCATION_POOL_BENEFICIAL_ORDER(n)	((n) & 0xff)
> /* Max order which caller can benefit from */
>  #define TTM_ALLOCATION_POOL_USE_DMA_ALLOC 	BIT(8) /* Use
> coherent DMA allocations. */
>  #define TTM_ALLOCATION_POOL_USE_DMA32		BIT(9) /* Use
> GFP_DMA32 allocations. */
> +#define TTM_ALLOCATION_PROPAGATE_ENOSPC		BIT(10) /*
> Do not convert ENOSPC from resource managers to ENOMEM. */
>  
>  #endif
> diff --git a/include/drm/ttm/ttm_device.h
> b/include/drm/ttm/ttm_device.h
> index 074b98572275..d016360e5ceb 100644
> --- a/include/drm/ttm/ttm_device.h
> +++ b/include/drm/ttm/ttm_device.h
> @@ -220,6 +220,11 @@ struct ttm_device {
>  	 */
>  	struct list_head device_list;
>  
> +	/**
> +	 * @alloc_flags: TTM_ALLOCATION_ flags.
> +	 */
> +	unsigned int alloc_flags;
> +
>  	/**
>  	 * @funcs: Function table for the device.
>  	 * Constant after bo device init


  reply	other threads:[~2025-10-22  7:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-20 11:54 [PATCH v5 0/6] Improving the worst case TTM large allocation latency Tvrtko Ursulin
2025-10-20 11:54 ` [PATCH v5 1/6] drm/ttm: Add getter for some pool properties Tvrtko Ursulin
2025-10-20 11:54 ` [PATCH v5 2/6] drm/ttm: Replace multiple booleans with flags in pool init Tvrtko Ursulin
2025-10-20 11:54 ` [PATCH v5 3/6] drm/ttm: Replace multiple booleans with flags in device init Tvrtko Ursulin
2025-10-21 14:16   ` Thomas Hellström
2025-10-22  3:56   ` Zack Rusin
2025-10-20 11:54 ` [PATCH v5 4/6] drm/ttm: Allow drivers to specify maximum beneficial TTM pool size Tvrtko Ursulin
2025-10-20 11:54 ` [PATCH v5 5/6] drm/amdgpu: Configure max beneficial TTM pool allocation order Tvrtko Ursulin
2025-10-20 11:54 ` [PATCH v5 6/6] drm/ttm: Add an allocation flag to propagate -ENOSPC on OOM Tvrtko Ursulin
2025-10-21 14:11   ` Thomas Hellström [this message]
2025-10-23 13:37     ` Tvrtko Ursulin
2025-10-27 10:21 ` [PATCH v5 0/6] Improving the worst case TTM large allocation latency Christian König
2025-10-31  9:32   ` Tvrtko Ursulin

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=1ddcf0013b858e3bad20de420632259ad4d8a616.camel@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kernel-dev@igalia.com \
    --cc=matthew.brost@intel.com \
    --cc=tvrtko.ursulin@igalia.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