[PATCH] drm/xe/guc: Don't allocate temporary policies object
Matthew Brost
matthew.brost at intel.com
Wed Jul 2 16:11:54 UTC 2025
On Wed, Jul 02, 2025 at 04:25:04PM +0200, Michal Wajdeczko wrote:
> Since we are already using reusable buffer objects from the GuC
> buffer cache, we can directly write into their CPU pointers and
> spare unnecessary temporary allocation.
>
> While around, also make sure to clear obtained buffer, to avoid
> sending some stale data.
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>
> Cc: Matthew Brost <matthew.brost at intel.com>
Patch LGTM:
Reviewed-by: Matthew Brost <matthew.brost at intel.com>
QQ semi-related though - guc_ads_action_update_policies. The GGTT
address passed in is 32 bits. I thought the GuC firmware interface
changed everywhere to use 64 bit GGTT addresses to future proof. Did
this H2G get missed?
Matt
> ---
> drivers/gpu/drm/xe/xe_guc_ads.c | 27 +++++++++------------------
> 1 file changed, 9 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_guc_ads.c b/drivers/gpu/drm/xe/xe_guc_ads.c
> index b4d81f4bd548..131cfc56be00 100644
> --- a/drivers/gpu/drm/xe/xe_guc_ads.c
> +++ b/drivers/gpu/drm/xe/xe_guc_ads.c
> @@ -995,16 +995,6 @@ static int guc_ads_action_update_policies(struct xe_guc_ads *ads, u32 policy_off
> return xe_guc_ct_send(ct, action, ARRAY_SIZE(action), 0, 0);
> }
>
> -static int guc_ads_update_policies(struct xe_guc_ads *ads, const struct guc_policies *policies)
> -{
> - CLASS(xe_guc_buf_from_data, buf)(&ads_to_guc(ads)->buf, policies, sizeof(*policies));
> -
> - if (!xe_guc_buf_is_valid(buf))
> - return -ENOBUFS;
> -
> - return guc_ads_action_update_policies(ads, xe_guc_buf_flush(buf));
> -}
> -
> /**
> * xe_guc_ads_scheduler_policy_toggle_reset - Toggle reset policy
> * @ads: Additional data structures object
> @@ -1015,13 +1005,16 @@ static int guc_ads_update_policies(struct xe_guc_ads *ads, const struct guc_poli
> */
> int xe_guc_ads_scheduler_policy_toggle_reset(struct xe_guc_ads *ads)
> {
> - struct xe_device *xe = ads_to_xe(ads);
> struct guc_policies *policies;
> - int ret;
> + struct xe_guc *guc = ads_to_guc(ads);
> + struct xe_device *xe = ads_to_xe(ads);
> + CLASS(xe_guc_buf, buf)(&guc->buf, sizeof(*policies));
>
> - policies = kmalloc(sizeof(*policies), GFP_KERNEL);
> - if (!policies)
> - return -ENOMEM;
> + if (!xe_guc_buf_is_valid(buf))
> + return -ENOBUFS;
> +
> + policies = xe_guc_buf_cpu_ptr(buf);
> + memset(policies, 0, sizeof(*policies));
>
> policies->dpc_promote_time = ads_blob_read(ads, policies.dpc_promote_time);
> policies->max_num_work_items = ads_blob_read(ads, policies.max_num_work_items);
> @@ -1031,7 +1024,5 @@ int xe_guc_ads_scheduler_policy_toggle_reset(struct xe_guc_ads *ads)
> else
> policies->global_flags &= ~GLOBAL_POLICY_DISABLE_ENGINE_RESET;
>
> - ret = guc_ads_update_policies(ads, policies);
> - kfree(policies);
> - return ret;
> + return guc_ads_action_update_policies(ads, xe_guc_buf_flush(buf));
> }
> --
> 2.47.1
>
More information about the Intel-xe
mailing list