[Intel-xe] [PATCH v5 22/23] drm/xe/guc: Move GuC power control init to "post-hwconfig"
Matthew Brost
matthew.brost at intel.com
Wed Nov 29 18:16:47 UTC 2023
On Wed, Nov 29, 2023 at 11:35:07PM +0100, Michał Winiarski wrote:
> SLPC is not used at "hwconfig" stage. Move the initialization of data
> structures used for SLPC to a later point in probe.
> Also - move the xe_guc_pc_init_early to happen just prior to initial
> "hwconfig" load.
>
> Signed-off-by: Michał Winiarski <michal.winiarski at intel.com>
Reviewed-by: Matthew Brost <matthew.brost at intel.com>
> ---
> v3 -> v4:
> - Convert xe_guc_pc_fini to act as drm-managed release function
>
> drivers/gpu/drm/xe/xe_gt.c | 3 ---
> drivers/gpu/drm/xe/xe_guc.c | 14 ++++++++------
> drivers/gpu/drm/xe/xe_guc_pc.c | 16 +++++++++++++---
> drivers/gpu/drm/xe/xe_guc_pc.h | 1 -
> 4 files changed, 21 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
> index a9c71da985d30..7498d36a97e44 100644
> --- a/drivers/gpu/drm/xe/xe_gt.c
> +++ b/drivers/gpu/drm/xe/xe_gt.c
> @@ -349,9 +349,6 @@ static int gt_fw_domain_init(struct xe_gt *gt)
> if (err)
> goto err_force_wake;
>
> - /* Raise GT freq to speed up HuC/GuC load */
> - xe_guc_pc_init_early(>->uc.guc.pc);
> -
> err = xe_uc_init_hwconfig(>->uc);
> if (err)
> goto err_force_wake;
> diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
> index b85defa941e85..7dcc438b38436 100644
> --- a/drivers/gpu/drm/xe/xe_guc.c
> +++ b/drivers/gpu/drm/xe/xe_guc.c
> @@ -236,7 +236,6 @@ static void guc_fini(struct drm_device *drm, void *arg)
> struct xe_guc *guc = arg;
>
> xe_force_wake_get(gt_to_fw(guc_to_gt(guc)), XE_FORCEWAKE_ALL);
> - xe_guc_pc_fini(&guc->pc);
> xe_uc_fini_hw(&guc_to_gt(guc)->uc);
> xe_force_wake_put(gt_to_fw(guc_to_gt(guc)), XE_FORCEWAKE_ALL);
> }
> @@ -309,11 +308,7 @@ int xe_guc_init(struct xe_guc *guc)
> if (ret)
> goto out;
>
> - ret = xe_guc_pc_init(&guc->pc);
> - if (ret)
> - goto out;
> -
> - ret = drmm_add_action_or_reset(>_to_xe(gt)->drm, guc_fini, guc);
> + ret = drmm_add_action_or_reset(&xe->drm, guc_fini, guc);
> if (ret)
> goto out;
>
> @@ -349,6 +344,10 @@ int xe_guc_init_post_hwconfig(struct xe_guc *guc)
>
> guc_init_params_post_hwconfig(guc);
>
> + ret = xe_guc_pc_init(&guc->pc);
> + if (ret)
> + return ret;
> +
> return xe_guc_ads_init_post_hwconfig(&guc->ads);
> }
>
> @@ -559,6 +558,9 @@ int xe_guc_min_load_for_hwconfig(struct xe_guc *guc)
>
> xe_guc_ads_populate_minimal(&guc->ads);
>
> + /* Raise GT freq to speed up HuC/GuC load */
> + xe_guc_pc_init_early(&guc->pc);
> +
> ret = __xe_guc_upload(guc);
> if (ret)
> return ret;
> diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
> index d2605a684b1c5..69fa7a533b75d 100644
> --- a/drivers/gpu/drm/xe/xe_guc_pc.c
> +++ b/drivers/gpu/drm/xe/xe_guc_pc.c
> @@ -952,8 +952,9 @@ int xe_guc_pc_stop(struct xe_guc_pc *pc)
> return ret;
> }
>
> -void xe_guc_pc_fini(struct xe_guc_pc *pc)
> +static void xe_guc_pc_fini(struct drm_device *drm, void *arg)
> {
> + struct xe_guc_pc *pc = arg;
> struct xe_device *xe = pc_to_xe(pc);
>
> if (xe->info.skip_guc_pc) {
> @@ -961,10 +962,11 @@ void xe_guc_pc_fini(struct xe_guc_pc *pc)
> return;
> }
>
> + xe_force_wake_get(gt_to_fw(pc_to_gt(pc)), XE_FORCEWAKE_ALL);
> XE_WARN_ON(xe_guc_pc_gucrc_disable(pc));
> XE_WARN_ON(xe_guc_pc_stop(pc));
> sysfs_remove_files(pc_to_gt(pc)->sysfs, pc_attrs);
> - mutex_destroy(&pc->freq_lock);
> + xe_force_wake_put(gt_to_fw(pc_to_gt(pc)), XE_FORCEWAKE_ALL);
> }
>
> /**
> @@ -983,7 +985,9 @@ int xe_guc_pc_init(struct xe_guc_pc *pc)
> if (xe->info.skip_guc_pc)
> return 0;
>
> - mutex_init(&pc->freq_lock);
> + err = drmm_mutex_init(&xe->drm, &pc->freq_lock);
> + if (err)
> + return err;
>
> bo = xe_managed_bo_create_pin_map(xe, tile, size,
> XE_BO_CREATE_VRAM_IF_DGFX(tile) |
> @@ -997,5 +1001,11 @@ int xe_guc_pc_init(struct xe_guc_pc *pc)
> if (err)
> return err;
>
> + err = drmm_add_action_or_reset(&xe->drm, xe_guc_pc_fini, pc);
> + if (err) {
> + sysfs_remove_files(gt->sysfs, pc_attrs);
> + return err;
> + }
> +
> return 0;
> }
> diff --git a/drivers/gpu/drm/xe/xe_guc_pc.h b/drivers/gpu/drm/xe/xe_guc_pc.h
> index 054788e006f32..4cd023d9e8bec 100644
> --- a/drivers/gpu/drm/xe/xe_guc_pc.h
> +++ b/drivers/gpu/drm/xe/xe_guc_pc.h
> @@ -9,7 +9,6 @@
> #include "xe_guc_pc_types.h"
>
> int xe_guc_pc_init(struct xe_guc_pc *pc);
> -void xe_guc_pc_fini(struct xe_guc_pc *pc);
> int xe_guc_pc_start(struct xe_guc_pc *pc);
> int xe_guc_pc_stop(struct xe_guc_pc *pc);
> int xe_guc_pc_gucrc_disable(struct xe_guc_pc *pc);
> --
> 2.43.0
>
More information about the Intel-xe
mailing list