]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915/guc: Hook GuC scheduling policies up
authorJohn Harrison <John.C.Harrison@Intel.com>
Tue, 27 Jul 2021 00:23:35 +0000 (17:23 -0700)
committerJohn Harrison <John.C.Harrison@Intel.com>
Wed, 28 Jul 2021 00:32:05 +0000 (17:32 -0700)
Use the official driver default scheduling policies for configuring
the GuC scheduler rather than a bunch of hardcoded values.

v2:
 (Matthew Brost)
  - Move I915_ENGINE_WANT_FORCED_PREEMPTION to later patch

Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
Cc: Jose Souza <jose.souza@intel.com>
Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210727002348.97202-21-matthew.brost@intel.com
drivers/gpu/drm/i915/gt/uc/intel_guc.h
drivers/gpu/drm/i915/gt/uc/intel_guc_ads.c
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c

index f355a70bbec45713992512adfc1dcf9c08f08937..8c8cf842c29addd290cc8b42b32c010b2c179939 100644 (file)
@@ -277,6 +277,8 @@ int intel_guc_engine_failure_process_msg(struct intel_guc *guc,
 
 void intel_guc_find_hung_context(struct intel_engine_cs *engine);
 
+int intel_guc_global_policies_update(struct intel_guc *guc);
+
 void intel_guc_submission_reset_prepare(struct intel_guc *guc);
 void intel_guc_submission_reset(struct intel_guc *guc, bool stalled);
 void intel_guc_submission_reset_finish(struct intel_guc *guc);
index 97cfaaaf23972a17a874296dc1693ee5e36e1fcc..60b73625f686a6e0f7323f57b7cfea903e6e9d85 100644 (file)
@@ -77,14 +77,54 @@ static u32 guc_ads_blob_size(struct intel_guc *guc)
               guc_ads_private_data_size(guc);
 }
 
-static void guc_policies_init(struct guc_policies *policies)
+static void guc_policies_init(struct intel_guc *guc, struct guc_policies *policies)
 {
+       struct intel_gt *gt = guc_to_gt(guc);
+       struct drm_i915_private *i915 = gt->i915;
+
        policies->dpc_promote_time = GLOBAL_POLICY_DEFAULT_DPC_PROMOTE_TIME_US;
        policies->max_num_work_items = GLOBAL_POLICY_MAX_NUM_WI;
+
        policies->global_flags = 0;
+       if (i915->params.reset < 2)
+               policies->global_flags |= GLOBAL_POLICY_DISABLE_ENGINE_RESET;
+
        policies->is_valid = 1;
 }
 
+static int guc_action_policies_update(struct intel_guc *guc, u32 policy_offset)
+{
+       u32 action[] = {
+               INTEL_GUC_ACTION_GLOBAL_SCHED_POLICY_CHANGE,
+               policy_offset
+       };
+
+       return intel_guc_send(guc, action, ARRAY_SIZE(action));
+}
+
+int intel_guc_global_policies_update(struct intel_guc *guc)
+{
+       struct __guc_ads_blob *blob = guc->ads_blob;
+       struct intel_gt *gt = guc_to_gt(guc);
+       intel_wakeref_t wakeref;
+       int ret;
+
+       if (!blob)
+               return -EOPNOTSUPP;
+
+       GEM_BUG_ON(!blob->ads.scheduler_policies);
+
+       guc_policies_init(guc, &blob->policies);
+
+       if (!intel_guc_is_ready(guc))
+               return 0;
+
+       with_intel_runtime_pm(&gt->i915->runtime_pm, wakeref)
+               ret = guc_action_policies_update(guc, blob->ads.scheduler_policies);
+
+       return ret;
+}
+
 static void guc_mapping_table_init(struct intel_gt *gt,
                                   struct guc_gt_system_info *system_info)
 {
@@ -281,7 +321,7 @@ static void __guc_ads_init(struct intel_guc *guc)
        u8 engine_class, guc_class;
 
        /* GuC scheduling policies */
-       guc_policies_init(&blob->policies);
+       guc_policies_init(guc, &blob->policies);
 
        /*
         * GuC expects a per-engine-class context image and size
index 76c2d927e1c3490bc6d3193393df54efcaa27d7d..cea3e3073a71901db4c13f204e3be38b00d02c66 100644 (file)
@@ -874,6 +874,7 @@ void intel_guc_submission_reset_finish(struct intel_guc *guc)
        GEM_WARN_ON(atomic_read(&guc->outstanding_submission_g2h));
        atomic_set(&guc->outstanding_submission_g2h, 0);
 
+       intel_guc_global_policies_update(guc);
        enable_submission(guc);
        intel_gt_unpark_heartbeats(guc_to_gt(guc));
 }
@@ -1170,8 +1171,9 @@ static void guc_context_policy_init(struct intel_engine_cs *engine,
 {
        desc->policy_flags = 0;
 
-       desc->execution_quantum = CONTEXT_POLICY_DEFAULT_EXECUTION_QUANTUM_US;
-       desc->preemption_timeout = CONTEXT_POLICY_DEFAULT_PREEMPTION_TIME_US;
+       /* NB: For both of these, zero means disabled. */
+       desc->execution_quantum = engine->props.timeslice_duration_ms * 1000;
+       desc->preemption_timeout = engine->props.preempt_timeout_ms * 1000;
 }
 
 static int guc_lrc_desc_pin(struct intel_context *ce, bool loop)
@@ -1942,13 +1944,13 @@ static void guc_default_vfuncs(struct intel_engine_cs *engine)
        engine->set_default_submission = guc_set_default_submission;
 
        engine->flags |= I915_ENGINE_HAS_PREEMPTION;
+       engine->flags |= I915_ENGINE_HAS_TIMESLICES;
 
        /*
         * TODO: GuC supports timeslicing and semaphores as well, but they're
         * handled by the firmware so some minor tweaks are required before
         * enabling.
         *
-        * engine->flags |= I915_ENGINE_HAS_TIMESLICES;
         * engine->flags |= I915_ENGINE_HAS_SEMAPHORES;
         */