public inbox for intel-xe@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>,
	<intel-xe@lists.freedesktop.org>
Cc: "Matthew Brost" <matthew.brost@intel.com>,
	"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	"Maarten Lankhorst" <dev@lankhorst.se>
Subject: Re: [PATCH v3 2/3] drm/xe/mm: Add batch buffer allocation functions for xe_mem_pool manager
Date: Thu, 2 Apr 2026 17:30:52 +0200	[thread overview]
Message-ID: <104fcd4c-0655-4122-af6e-34e0198213e2@intel.com> (raw)
In-Reply-To: <20260401161528.1990499-3-satyanarayana.k.v.p@intel.com>



On 4/1/2026 6:15 PM, Satyanarayana K V P wrote:
> New APIs xe_pool_bb_alloc(), xe_pool_bb_insert() and
> xe_pool_bb_free() are created to manage allocations from the
> xe_mem_pool manager.

if those are generic "allocations" from the pool, then don't call them BB

> 
> Signed-off-by: Satyanarayana K V P <satyanarayana.k.v.p@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Maarten Lankhorst <dev@lankhorst.se>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> 
> ---
> V2 -> V3:
> - Renamed xe_mm_suballoc to xe_mem_pool.
> 
> V1 -> V2:
> - Renamed xe_drm_mm to xe_mm_suballoc (Thomas)
> - Removed memset from xe_drm_mm_bb_insert() (Matt).
> ---
>  drivers/gpu/drm/xe/xe_bb.c | 58 ++++++++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/xe/xe_bb.h |  6 ++++
>  2 files changed, 64 insertions(+)
> 
> diff --git a/drivers/gpu/drm/xe/xe_bb.c b/drivers/gpu/drm/xe/xe_bb.c
> index b896b6f6615c..26e2430c0dc1 100644
> --- a/drivers/gpu/drm/xe/xe_bb.c
> +++ b/drivers/gpu/drm/xe/xe_bb.c
> @@ -10,6 +10,7 @@
>  #include "xe_device_types.h"
>  #include "xe_exec_queue_types.h"
>  #include "xe_gt.h"
> +#include "xe_mem_pool.h"
>  #include "xe_sa.h"
>  #include "xe_sched_job.h"
>  #include "xe_vm_types.h"
> @@ -172,3 +173,60 @@ void xe_bb_free(struct xe_bb *bb, struct dma_fence *fence)
>  	xe_sa_bo_free(bb->bo, fence);
>  	kfree(bb);
>  }

why all of this is in xe_bo.c and not in xe_mem_pool.c ?

> +
> +/**
> + * xe_pool_bb_alloc() - Allocate a new batch buffer structure for drm_mm

xe_mem_pool_alloc_node() - Allocate new sub-allocation node for use in xe_mem_pool

> + *
> + * Allocates a new xe_pool_bb structure for use with xe_pool memory
> + * management.
> + *
> + * Returns: Batch buffer structure or an ERR_PTR(-ENOMEM).
> + */
> +struct xe_mem_pool_bb *xe_pool_bb_alloc(void)
> +{
> +	struct xe_mem_pool_bb *bb = kzalloc_obj(*bb);
> +
> +	if (!bb)
> +		return ERR_PTR(-ENOMEM);
> +
> +	return bb;
> +}
> +
> +/**
> + * xe_pool_bb_insert() - Initialize a batch buffer and insert a hole

xe_mem_pool_insert_node(pool, node)

> + * @bb: Batch buffer structure to initialize
> + * @bb_pool: drm_mm manager to allocate from
> + * @dwords: Number of dwords to be allocated

why not bytes?

> + *
> + * Initializes the batch buffer by allocating memory from the specified
> + * drm_mm manager.

drm_mm ?

> + *
> + * Return: 0 on success, negative error code on failure.
> + */
> +int xe_pool_bb_insert(struct xe_mem_pool_bb *bb,
> +		      struct xe_mem_pool_manager *bb_pool, u32 dwords)
> +{
> +	int err;
> +
> +	err = xe_mem_pool_insert_node(bb_pool, &bb->node, 4 * dwords);

this magic 4 is sizeof(u32)

> +	if (err)
> +		return err;
> +
> +	bb->cs = xe_mem_pool_manager_cpu_addr(bb_pool) + bb->node.start;
> +	bb->len = 0;
> +
> +	return 0;
> +}
> +
> +/**
> + * xe_pool_bb_free() - Free a batch buffer allocated with drm_mm
> + * @bb: Batch buffer structure to free
> + */
> +void xe_pool_bb_free(struct xe_mem_pool_bb *bb)
> +{
> +	if (!bb)
> +		return;
> +
> +	xe_mem_pool_remove_node(&bb->node);
> +	kfree(bb);
> +}
> diff --git a/drivers/gpu/drm/xe/xe_bb.h b/drivers/gpu/drm/xe/xe_bb.h
> index 231870b24c2f..638d8fc53f1a 100644
> --- a/drivers/gpu/drm/xe/xe_bb.h
> +++ b/drivers/gpu/drm/xe/xe_bb.h
> @@ -12,6 +12,8 @@ struct dma_fence;
>  
>  struct xe_gt;
>  struct xe_exec_queue;
> +struct xe_mem_pool_bb;
> +struct xe_mem_pool_manager;
>  struct xe_sa_manager;
>  struct xe_sched_job;
>  
> @@ -24,5 +26,9 @@ struct xe_sched_job *xe_bb_create_migration_job(struct xe_exec_queue *q,
>  						struct xe_bb *bb, u64 batch_ofs,
>  						u32 second_idx);
>  void xe_bb_free(struct xe_bb *bb, struct dma_fence *fence);
> +struct xe_mem_pool_bb *xe_pool_bb_alloc(void);
> +int xe_pool_bb_insert(struct xe_mem_pool_bb *bb,
> +		      struct xe_mem_pool_manager *bb_pool, u32 dwords);
> +void xe_pool_bb_free(struct xe_mem_pool_bb *bb);

wrong .h ?

>  
>  #endif


  parent reply	other threads:[~2026-04-02 15:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01 16:15 [PATCH v3 0/3] USE drm mm instead of drm SA for CCS read/write Satyanarayana K V P
2026-04-01 16:15 ` [PATCH v3 1/3] drm/xe/mm: add XE MEM POOL manager with shadow support Satyanarayana K V P
2026-04-02  1:20   ` Matthew Brost
2026-04-02  8:18   ` Thomas Hellström
2026-04-02 15:17   ` Michal Wajdeczko
2026-04-01 16:15 ` [PATCH v3 2/3] drm/xe/mm: Add batch buffer allocation functions for xe_mem_pool manager Satyanarayana K V P
2026-04-02  1:22   ` Matthew Brost
2026-04-02  8:21   ` Thomas Hellström
2026-04-02 15:30   ` Michal Wajdeczko [this message]
2026-04-01 16:15 ` [PATCH v3 3/3] drm/xe/vf: Use drm mm instead of drm sa for CCS read/write Satyanarayana K V P
2026-04-02  8:29   ` Thomas Hellström
2026-04-01 16:20 ` ✗ CI.checkpatch: warning for USE drm mm instead of drm SA for CCS read/write (rev3) Patchwork
2026-04-01 16:21 ` ✓ CI.KUnit: success " Patchwork
2026-04-01 16:56 ` ✗ Xe.CI.BAT: failure " Patchwork
2026-04-01 21:11 ` ✗ Xe.CI.FULL: " 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=104fcd4c-0655-4122-af6e-34e0198213e2@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=dev@lankhorst.se \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    --cc=satyanarayana.k.v.p@intel.com \
    --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