Commit d65ff1ec authored by Piotr Piórkowski's avatar Piotr Piórkowski Committed by Lucas De Marchi
Browse files

drm/xe: Split xe_migrate allocation from initialization



Currently, xe_migrate_init handled both allocation and initialization,
Lets moves allocation to xe_tile_alloc via a new xe_migrate_alloc
function, and keep initialization in xe_migrate_init.
This will allow the migration pointers to be passed to other structures
before full initialization.
Also replaces devm_kzalloc with drmm_kzalloc for better
DRM-managed memory.

Signed-off-by: default avatarPiotr Piórkowski <piotr.piorkowski@intel.com>
Reviewed-by: default avatarMatthew Brost <matthew.brost@intel.com>
Link: https://lore.kernel.org/r/20250714184818.89201-5-piotr.piorkowski@intel.com


Signed-off-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
parent 7a20b4f5
Loading
Loading
Loading
Loading
+18 −7
Original line number Diff line number Diff line
@@ -389,6 +389,23 @@ static bool xe_migrate_needs_ccs_emit(struct xe_device *xe)
	return xe_device_has_flat_ccs(xe) && !(GRAPHICS_VER(xe) >= 20 && IS_DGFX(xe));
}

/**
 * xe_migrate_alloc - Allocate a migrate struct for a given &xe_tile
 * @tile: &xe_tile
 *
 * Allocates a &xe_migrate for a given tile.
 *
 * Return: &xe_migrate on success, or NULL when out of memory.
 */
struct xe_migrate *xe_migrate_alloc(struct xe_tile *tile)
{
	struct xe_migrate *m = drmm_kzalloc(&tile_to_xe(tile)->drm, sizeof(*m), GFP_KERNEL);

	if (m)
		m->tile = tile;
	return m;
}

/**
 * xe_migrate_init() - Initialize a migrate context
 * @tile: Back-pointer to the tile we're initializing for.
@@ -399,16 +416,10 @@ struct xe_migrate *xe_migrate_init(struct xe_tile *tile)
{
	struct xe_device *xe = tile_to_xe(tile);
	struct xe_gt *primary_gt = tile->primary_gt;
	struct xe_migrate *m;
	struct xe_migrate *m = tile->migrate;
	struct xe_vm *vm;
	int err;

	m = devm_kzalloc(xe->drm.dev, sizeof(*m), GFP_KERNEL);
	if (!m)
		return ERR_PTR(-ENOMEM);

	m->tile = tile;

	/* Special layout, prepared below.. */
	vm = xe_vm_create(xe, XE_VM_FLAG_MIGRATION |
			  XE_VM_FLAG_SET_TILE_ID(tile));
+1 −0
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ struct xe_migrate_pt_update {
	u8 tile_id;
};

struct xe_migrate *xe_migrate_alloc(struct xe_tile *tile);
struct xe_migrate *xe_migrate_init(struct xe_tile *tile);

struct dma_fence *xe_migrate_to_vram(struct xe_migrate *m,
+4 −0
Original line number Diff line number Diff line
@@ -94,6 +94,10 @@ static int xe_tile_alloc(struct xe_tile *tile)
	if (!tile->mem.ggtt)
		return -ENOMEM;

	tile->migrate = xe_migrate_alloc(tile);
	if (!tile->migrate)
		return -ENOMEM;

	return 0;
}