[PATCH] drm/xe: Get hwe domain specific FW to read RING_TIMESTAMP
Matt Roper
matthew.d.roper at intel.com
Tue Jun 25 22:13:54 UTC 2024
On Tue, Jun 25, 2024 at 11:38:42PM +0800, Umesh Nerlige Ramappa wrote:
> Per client engine utilization uses RING_TIMESTAMP to return drm-total-cycles to
> the user. Current code uses XE_FW_GT to read this register on the first
> available engine in a GT. When testing on DG2, it is observed that this value is
> 0 when running test on some engines. To resolve that, get the hwe domain
> specific FW for reading the engine timestamp.
>
> v2:
> - update commit message
> - use domain specific FW (Matt)
>
> Fixes: 188ced1e0ff8 ("drm/xe/client: Print runtime to fdinfo")
> Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>
> ---
> drivers/gpu/drm/xe/xe_drm_client.c | 7 +++++--
> drivers/gpu/drm/xe/xe_hw_engine.c | 5 +++++
> drivers/gpu/drm/xe/xe_hw_engine.h | 1 +
> 3 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_drm_client.c b/drivers/gpu/drm/xe/xe_drm_client.c
> index 4a19b771e3a0..886965e81465 100644
> --- a/drivers/gpu/drm/xe/xe_drm_client.c
> +++ b/drivers/gpu/drm/xe/xe_drm_client.c
> @@ -260,13 +260,16 @@ static void show_run_ticks(struct drm_printer *p, struct drm_file *file)
>
> /* Get the total GPU cycles */
> for_each_gt(gt, xe, gt_id) {
> + enum xe_force_wake_domains fw;
> +
> hwe = xe_gt_any_hw_engine(gt);
> if (!hwe)
> continue;
>
> - xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
> + fw = xe_hw_engine_to_fw_domain(hwe);
> + xe_force_wake_get(gt_to_fw(gt), fw);
> gpu_timestamp = xe_hw_engine_read_timestamp(hwe);
> - xe_force_wake_put(gt_to_fw(gt), XE_FW_GT);
> + xe_force_wake_put(gt_to_fw(gt), fw);
> break;
> }
>
> diff --git a/drivers/gpu/drm/xe/xe_hw_engine.c b/drivers/gpu/drm/xe/xe_hw_engine.c
> index 78b50d3a6501..97f43ba3a00f 100644
> --- a/drivers/gpu/drm/xe/xe_hw_engine.c
> +++ b/drivers/gpu/drm/xe/xe_hw_engine.c
> @@ -1130,3 +1130,8 @@ u64 xe_hw_engine_read_timestamp(struct xe_hw_engine *hwe)
> {
> return xe_mmio_read64_2x32(hwe->gt, RING_TIMESTAMP(hwe->mmio_base));
> }
> +
> +enum xe_force_wake_domains xe_hw_engine_to_fw_domain(struct xe_hw_engine *hwe)
> +{
> + return hwe ? engine_infos[hwe->engine_id].domain : 0;
Not sure if we really need the ternary operator here since it wouldn't
really make sense to call this function with a NULL hwe. But it doesn't
hurt anything either, so
Reviewed-by: Matt Roper <matthew.d.roper at intel.com>
> +}
> diff --git a/drivers/gpu/drm/xe/xe_hw_engine.h b/drivers/gpu/drm/xe/xe_hw_engine.h
> index 7f2d27c0ba1a..900c8c991430 100644
> --- a/drivers/gpu/drm/xe/xe_hw_engine.h
> +++ b/drivers/gpu/drm/xe/xe_hw_engine.h
> @@ -69,5 +69,6 @@ static inline bool xe_hw_engine_is_valid(struct xe_hw_engine *hwe)
>
> const char *xe_hw_engine_class_to_str(enum xe_engine_class class);
> u64 xe_hw_engine_read_timestamp(struct xe_hw_engine *hwe);
> +enum xe_force_wake_domains xe_hw_engine_to_fw_domain(struct xe_hw_engine *hwe);
>
> #endif
> --
> 2.34.1
>
--
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation
More information about the Intel-xe
mailing list