mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 09:04:39 +02:00
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: Piotr Piórkowski <piotr.piorkowski@intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://lore.kernel.org/r/20250714184818.89201-5-piotr.piorkowski@intel.com Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
This commit is contained in:
parent
7a20b4f558
commit
d65ff1ec85
|
|
@ -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));
|
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
|
* xe_migrate_init() - Initialize a migrate context
|
||||||
* @tile: Back-pointer to the tile we're initializing for.
|
* @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_device *xe = tile_to_xe(tile);
|
||||||
struct xe_gt *primary_gt = tile->primary_gt;
|
struct xe_gt *primary_gt = tile->primary_gt;
|
||||||
struct xe_migrate *m;
|
struct xe_migrate *m = tile->migrate;
|
||||||
struct xe_vm *vm;
|
struct xe_vm *vm;
|
||||||
int err;
|
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.. */
|
/* Special layout, prepared below.. */
|
||||||
vm = xe_vm_create(xe, XE_VM_FLAG_MIGRATION |
|
vm = xe_vm_create(xe, XE_VM_FLAG_MIGRATION |
|
||||||
XE_VM_FLAG_SET_TILE_ID(tile));
|
XE_VM_FLAG_SET_TILE_ID(tile));
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ struct xe_migrate_pt_update {
|
||||||
u8 tile_id;
|
u8 tile_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct xe_migrate *xe_migrate_alloc(struct xe_tile *tile);
|
||||||
struct xe_migrate *xe_migrate_init(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,
|
struct dma_fence *xe_migrate_to_vram(struct xe_migrate *m,
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,10 @@ static int xe_tile_alloc(struct xe_tile *tile)
|
||||||
if (!tile->mem.ggtt)
|
if (!tile->mem.ggtt)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
tile->migrate = xe_migrate_alloc(tile);
|
||||||
|
if (!tile->migrate)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user