]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/guc: Don't allocate temporary policies object
authorMichal Wajdeczko <michal.wajdeczko@intel.com>
Wed, 2 Jul 2025 14:25:04 +0000 (16:25 +0200)
committerMichal Wajdeczko <michal.wajdeczko@intel.com>
Thu, 10 Jul 2025 14:00:13 +0000 (16:00 +0200)
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@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Link: https://lore.kernel.org/r/20250702142504.1656-1-michal.wajdeczko@intel.com
drivers/gpu/drm/xe/xe_guc_ads.c

index b4d81f4bd548c4e1038b331e776ea8a0b2436d3c..131cfc56be00a58832f044e93534e0a9aed7c4c8 100644 (file)
@@ -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));
 }