Skip to content

Commit 621a422

Browse files
committed
drm/xe/guc: Don't allocate temporary policies object
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 <[email protected]> Cc: Matthew Brost <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1fbe023 commit 621a422

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

drivers/gpu/drm/xe/xe_guc_ads.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -995,16 +995,6 @@ static int guc_ads_action_update_policies(struct xe_guc_ads *ads, u32 policy_off
995995
return xe_guc_ct_send(ct, action, ARRAY_SIZE(action), 0, 0);
996996
}
997997

998-
static int guc_ads_update_policies(struct xe_guc_ads *ads, const struct guc_policies *policies)
999-
{
1000-
CLASS(xe_guc_buf_from_data, buf)(&ads_to_guc(ads)->buf, policies, sizeof(*policies));
1001-
1002-
if (!xe_guc_buf_is_valid(buf))
1003-
return -ENOBUFS;
1004-
1005-
return guc_ads_action_update_policies(ads, xe_guc_buf_flush(buf));
1006-
}
1007-
1008998
/**
1009999
* xe_guc_ads_scheduler_policy_toggle_reset - Toggle reset policy
10101000
* @ads: Additional data structures object
@@ -1015,13 +1005,16 @@ static int guc_ads_update_policies(struct xe_guc_ads *ads, const struct guc_poli
10151005
*/
10161006
int xe_guc_ads_scheduler_policy_toggle_reset(struct xe_guc_ads *ads)
10171007
{
1018-
struct xe_device *xe = ads_to_xe(ads);
10191008
struct guc_policies *policies;
1020-
int ret;
1009+
struct xe_guc *guc = ads_to_guc(ads);
1010+
struct xe_device *xe = ads_to_xe(ads);
1011+
CLASS(xe_guc_buf, buf)(&guc->buf, sizeof(*policies));
10211012

1022-
policies = kmalloc(sizeof(*policies), GFP_KERNEL);
1023-
if (!policies)
1024-
return -ENOMEM;
1013+
if (!xe_guc_buf_is_valid(buf))
1014+
return -ENOBUFS;
1015+
1016+
policies = xe_guc_buf_cpu_ptr(buf);
1017+
memset(policies, 0, sizeof(*policies));
10251018

10261019
policies->dpc_promote_time = ads_blob_read(ads, policies.dpc_promote_time);
10271020
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)
10311024
else
10321025
policies->global_flags &= ~GLOBAL_POLICY_DISABLE_ENGINE_RESET;
10331026

1034-
ret = guc_ads_update_policies(ads, policies);
1035-
kfree(policies);
1036-
return ret;
1027+
return guc_ads_action_update_policies(ads, xe_guc_buf_flush(buf));
10371028
}

0 commit comments

Comments
 (0)