[PATCH v7 4/6] drm/xe/guc: Move xe_hw_engine_snapshot creation back to xe_hw_engine.c
Dong, Zhanjun
zhanjun.dong at intel.com
Wed Feb 12 17:19:11 UTC 2025
LGTM
Reviewed-by: Zhanjun Dong <zhanjun.dong at intel.com>
On 2025-02-10 6:32 p.m., Alan Previn wrote:
> xe_devcoredump calls xe_engine_snapshot_capture_for_queue() to allocate
> and populate the xe_hw_engine_snapshot structure. Move that function
> back into xe_hw_engine.c since it doesn't make sense for
> GuC-Err-Capture to allocate a structure it doesn't own.
>
> v7: Rename function to respect "xe_hw_engine" namespace (Rodrigo)
>
> Signed-off-by: Alan Previn <alan.previn.teres.alexis at intel.com>
> ---
> drivers/gpu/drm/xe/xe_devcoredump.c | 2 +-
> drivers/gpu/drm/xe/xe_guc_capture.c | 30 -----------------------
> drivers/gpu/drm/xe/xe_guc_capture.h | 1 -
> drivers/gpu/drm/xe/xe_hw_engine.c | 38 ++++++++++++++++++++++++++---
> drivers/gpu/drm/xe/xe_hw_engine.h | 3 +--
> 5 files changed, 36 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c b/drivers/gpu/drm/xe/xe_devcoredump.c
> index 7a4610d2ea4f..6cbb4fce8ef2 100644
> --- a/drivers/gpu/drm/xe/xe_devcoredump.c
> +++ b/drivers/gpu/drm/xe/xe_devcoredump.c
> @@ -311,7 +311,7 @@ static void devcoredump_snapshot(struct xe_devcoredump *coredump,
> ss->job = xe_sched_job_snapshot_capture(job);
> ss->vm = xe_vm_snapshot_capture(q->vm);
>
> - xe_engine_snapshot_capture_for_queue(q);
> + xe_hw_engine_snapshot_capture_for_queue(q);
>
> queue_work(system_unbound_wq, &ss->work);
>
> diff --git a/drivers/gpu/drm/xe/xe_guc_capture.c b/drivers/gpu/drm/xe/xe_guc_capture.c
> index 76c20ff97864..ff16bed86b77 100644
> --- a/drivers/gpu/drm/xe/xe_guc_capture.c
> +++ b/drivers/gpu/drm/xe/xe_guc_capture.c
> @@ -1867,36 +1867,6 @@ xe_guc_capture_get_matching_and_lock(struct xe_exec_queue *q,
> return NULL;
> }
>
> -/**
> - * xe_engine_snapshot_capture_for_queue - Take snapshot of associated engine
> - * @q: The exec queue object
> - *
> - * Take snapshot of associated HW Engine
> - *
> - * Returns: None.
> - */
> -void
> -xe_engine_snapshot_capture_for_queue(struct xe_exec_queue *q)
> -{
> - struct xe_device *xe = gt_to_xe(q->gt);
> - struct xe_devcoredump *coredump = &xe->devcoredump;
> - struct xe_hw_engine *hwe;
> - enum xe_hw_engine_id id;
> - u32 adj_logical_mask = q->logical_mask;
> -
> - if (IS_SRIOV_VF(xe))
> - return;
> -
> - for_each_hw_engine(hwe, q->gt, id) {
> - if (hwe->class != q->hwe->class ||
> - !(BIT(hwe->logical_instance) & adj_logical_mask)) {
> - coredump->snapshot.hwe[id] = NULL;
> - continue;
> - }
> - coredump->snapshot.hwe[id] = xe_hw_engine_snapshot_capture(hwe, q);
> - }
> -}
> -
> /*
> * xe_guc_capture_put_matched_nodes - Cleanup matched nodes
> * @guc: The GuC object
> diff --git a/drivers/gpu/drm/xe/xe_guc_capture.h b/drivers/gpu/drm/xe/xe_guc_capture.h
> index e67589ab4342..77ee35a3f205 100644
> --- a/drivers/gpu/drm/xe/xe_guc_capture.h
> +++ b/drivers/gpu/drm/xe/xe_guc_capture.h
> @@ -56,7 +56,6 @@ xe_guc_capture_get_matching_and_lock(struct xe_exec_queue *q,
> void xe_guc_capture_snapshot_store_manual_job(struct xe_guc *guc, struct xe_exec_queue *q);
> void xe_guc_capture_snapshot_print(struct xe_guc *guc, struct xe_guc_capture_snapshot *node,
> struct drm_printer *p);
> -void xe_engine_snapshot_capture_for_queue(struct xe_exec_queue *q);
> void xe_guc_capture_steered_list_init(struct xe_guc *guc);
> void xe_guc_capture_put_matched_nodes(struct xe_guc *guc, struct xe_guc_capture_snapshot *n);
> int xe_guc_capture_init(struct xe_guc *guc);
> diff --git a/drivers/gpu/drm/xe/xe_hw_engine.c b/drivers/gpu/drm/xe/xe_hw_engine.c
> index c980a5c84a8b..fef01d2086a8 100644
> --- a/drivers/gpu/drm/xe/xe_hw_engine.c
> +++ b/drivers/gpu/drm/xe/xe_hw_engine.c
> @@ -830,7 +830,7 @@ void xe_hw_engine_handle_irq(struct xe_hw_engine *hwe, u16 intr_vec)
> }
>
> /**
> - * xe_hw_engine_snapshot_capture - Take a quick snapshot of the HW Engine.
> + * hw_engine_snapshot_capture - Take a quick snapshot of the HW Engine.
> * @hwe: Xe HW Engine.
> * @q: The exec queue object.
> *
> @@ -840,8 +840,8 @@ void xe_hw_engine_handle_irq(struct xe_hw_engine *hwe, u16 intr_vec)
> * Returns: a Xe HW Engine snapshot object that must be freed by the
> * caller, using `xe_hw_engine_snapshot_free`.
> */
> -struct xe_hw_engine_snapshot *
> -xe_hw_engine_snapshot_capture(struct xe_hw_engine *hwe, struct xe_exec_queue *q)
> +static struct xe_hw_engine_snapshot *
> +hw_engine_snapshot_capture(struct xe_hw_engine *hwe, struct xe_exec_queue *q)
> {
> struct xe_hw_engine_snapshot *snapshot;
> struct xe_guc_capture_snapshot *node;
> @@ -887,6 +887,36 @@ xe_hw_engine_snapshot_capture(struct xe_hw_engine *hwe, struct xe_exec_queue *q)
> return snapshot;
> }
>
> +/**
> + * xe_hw_engine_snapshot_capture_for_queue - Take snapshot of associated engine
> + * @q: The exec queue object
> + *
> + * Take snapshot of associated HW Engine
> + *
> + * Returns: None.
> + */
> +void
> +xe_hw_engine_snapshot_capture_for_queue(struct xe_exec_queue *q)
> +{
> + struct xe_device *xe = gt_to_xe(q->gt);
> + struct xe_devcoredump *coredump = &xe->devcoredump;
> + struct xe_hw_engine *hwe;
> + enum xe_hw_engine_id id;
> + u32 adj_logical_mask = q->logical_mask;
> +
> + if (IS_SRIOV_VF(xe))
> + return;
> +
> + for_each_hw_engine(hwe, q->gt, id) {
> + if (hwe->class != q->hwe->class ||
> + !(BIT(hwe->logical_instance) & adj_logical_mask)) {
> + coredump->snapshot.hwe[id] = NULL;
> + continue;
> + }
> + coredump->snapshot.hwe[id] = hw_engine_snapshot_capture(hwe, q);
> + }
> +}
> +
> /**
> * xe_hw_engine_snapshot_free - Free all allocated objects for a given snapshot.
> * @snapshot: Xe HW Engine snapshot object.
> @@ -945,7 +975,7 @@ void xe_hw_engine_print(struct xe_hw_engine *hwe, struct drm_printer *p)
> {
> struct xe_hw_engine_snapshot *snapshot;
>
> - snapshot = xe_hw_engine_snapshot_capture(hwe, NULL);
> + snapshot = hw_engine_snapshot_capture(hwe, NULL);
> xe_hw_engine_snapshot_print(snapshot, p);
> xe_hw_engine_snapshot_free(snapshot);
> }
> diff --git a/drivers/gpu/drm/xe/xe_hw_engine.h b/drivers/gpu/drm/xe/xe_hw_engine.h
> index 069b32aa7423..74f6ea0c8d3e 100644
> --- a/drivers/gpu/drm/xe/xe_hw_engine.h
> +++ b/drivers/gpu/drm/xe/xe_hw_engine.h
> @@ -55,8 +55,7 @@ void xe_hw_engine_handle_irq(struct xe_hw_engine *hwe, u16 intr_vec);
> void xe_hw_engine_enable_ring(struct xe_hw_engine *hwe);
> u32 xe_hw_engine_mask_per_class(struct xe_gt *gt,
> enum xe_engine_class engine_class);
> -struct xe_hw_engine_snapshot *
> -xe_hw_engine_snapshot_capture(struct xe_hw_engine *hwe, struct xe_exec_queue *q);
> +void xe_hw_engine_snapshot_capture_for_queue(struct xe_exec_queue *q);
> void xe_hw_engine_snapshot_free(struct xe_hw_engine_snapshot *snapshot);
> void xe_hw_engine_snapshot_print(struct xe_hw_engine_snapshot *snapshot, struct drm_printer *p);
> void xe_hw_engine_print(struct xe_hw_engine *hwe, struct drm_printer *p);
More information about the dri-devel
mailing list