uC fw path unification + misc clean-up
Subsystems (2)
v2 cover uC fw path unification + misc clean-up
Compared to v1 I've pushed a bith further with the fe selection unification, moving to a unified list for both GuC and HuC. Checkpatch isn't however too happy with the macros involved!
Apart for the above I've mainly addressed review feedback.
Daniele Ceraolo Spurio (8):
drm/i915/uc: Unify uC platform check drm/i915/uc: Unify uC FW selection drm/i915/uc: Unify uc_fw status tracking drm/i915/uc: Move xfer rsa logic to common function drm/i915/huc: Copy huc rsa only once drm/i915/guc: Set GuC init params only once drm/i915/uc: Plumb the gt through fw_upload drm/i915/uc: Unify uC firmware upload
drivers/gpu/drm/i915/gt/intel_reset.c | 2 +- drivers/gpu/drm/i915/gt/uc/intel_guc.c | 143 ++++---- drivers/gpu/drm/i915/gt/uc/intel_guc.h | 9 +- drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c | 215 ++--------- .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 2 +- drivers/gpu/drm/i915/gt/uc/intel_huc.c | 35 +- drivers/gpu/drm/i915/gt/uc/intel_huc.h | 6 +- drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c | 170 +-------- drivers/gpu/drm/i915/gt/uc/intel_uc.c | 14 +- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 342 ++++++++++++++---- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h | 92 ++--- drivers/gpu/drm/i915/gt/uc/selftest_guc.c | 4 +- drivers/gpu/drm/i915/i915_debugfs.c | 6 +- drivers/gpu/drm/i915/i915_drv.h | 15 +- drivers/gpu/drm/i915/i915_gpu_error.c | 4 +- drivers/gpu/drm/i915/i915_irq.c | 2 +- drivers/gpu/drm/i915/i915_pci.c | 4 +- drivers/gpu/drm/i915/intel_device_info.h | 2 +- drivers/gpu/drm/i915/intel_pm.c | 4 +- drivers/gpu/drm/i915/intel_wopcm.c | 4 +- 20 files changed, 501 insertions(+), 574 deletions(-)
Signature · 6 lines
2.22.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/8 drm/i915/uc: Unify uC platform check
We have several HAS_* checks for GuC and HuC but we mostly use HAS_GUC and HAS_HUC, with only 1 exception. Since our HW always has either both uC or neither of them, just replace all the checks with a unified HAS_UC.
v2: use HAS_GT_UC (Michal)
--- drivers/gpu/drm/i915/gt/intel_reset.c | 2 +- drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c | 2 +- drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c | 2 +- drivers/gpu/drm/i915/gt/uc/intel_uc.c | 2 +- drivers/gpu/drm/i915/gt/uc/selftest_guc.c | 4 ++-- drivers/gpu/drm/i915/i915_debugfs.c | 6 +++--- drivers/gpu/drm/i915/i915_drv.h | 15 ++------------- drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++-- drivers/gpu/drm/i915/i915_irq.c | 2 +- drivers/gpu/drm/i915/i915_pci.c | 4 ++-- drivers/gpu/drm/i915/intel_device_info.h | 2 +- drivers/gpu/drm/i915/intel_pm.c | 4 ++-- drivers/gpu/drm/i915/intel_wopcm.c | 4 ++-- 13 files changed, 21 insertions(+), 32 deletions(-)
drivers/gpu/drm/i915/gt/intel_reset.c +1 -1
@@ -595,7 +595,7 @@ int intel_reset_guc(struct intel_gt *gt)INTEL_GEN (gt->i915) >=11 ?GEN11_GRDOM_GUC :GEN9_GRDOM_GUC ;int ret; -GEM_BUG_ON (!HAS_GUC (gt->i915)); +GEM_BUG_ON (!HAS_GT_UC (gt->i915));intel_uncore_forcewake_get (gt->uncore,FORCEWAKE_ALL ); ret =gen6_hw_domain_reset (gt, guc_domain);
drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +1 -1
@@ -80,7 +80,7 @@ static void guc_fw_select(struct intel_uc_fw *guc_fw)GEM_BUG_ON (guc_fw->type !=INTEL_UC_FW_TYPE_GUC ); -if (!HAS_GUC (i915)) { +if (!HAS_GT_UC (i915)) { guc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_SUPPORTED ;return ; }
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +1 -1
@@ -74,7 +74,7 @@ static void huc_fw_select(struct intel_uc_fw *huc_fw)GEM_BUG_ON (huc_fw->type !=INTEL_UC_FW_TYPE_HUC ); -if (!HAS_HUC (dev_priv)) { +if (!HAS_GT_UC (dev_priv)) { huc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_SUPPORTED ;return ; }
drivers/gpu/drm/i915/gt/uc/intel_uc.c +1 -1
@@ -61,7 +61,7 @@ static int __get_platform_enable_guc(struct intel_uc *uc)struct intel_uc_fw *huc_fw = &uc->huc.fw;int enable_guc =0 ; -if (!HAS_GUC (uc_to_gt (uc)->i915)) +if (!HAS_GT_UC (uc_to_gt (uc)->i915))return 0 ;/* We don't want to enable GuC/HuC on pre-Gen11 by default */
drivers/gpu/drm/i915/gt/uc/selftest_guc.c +2 -2
@@ -134,7 +134,7 @@ static int igt_guc_clients(void *args)struct intel_guc *guc;int err =0 ; -GEM_BUG_ON (!HAS_GUC (dev_priv)); +GEM_BUG_ON (!HAS_GT_UC (dev_priv));mutex_lock (&dev_priv->drm.struct_mutex); wakeref =intel_runtime_pm_get (&dev_priv->runtime_pm);
@@ -226,7 +226,7 @@ static int igt_guc_doorbells(void *arg)int i, err =0 ;u16 db_id; -GEM_BUG_ON (!HAS_GUC (dev_priv)); +GEM_BUG_ON (!HAS_GT_UC (dev_priv));mutex_lock (&dev_priv->drm.struct_mutex); wakeref =intel_runtime_pm_get (&dev_priv->runtime_pm);
drivers/gpu/drm/i915/i915_debugfs.c +3 -3
@@ -1865,7 +1865,7 @@ static int i915_huc_load_status_info(struct seq_file *m, void *data)intel_wakeref_t wakeref;struct drm_printer p; -if (!HAS_HUC (dev_priv)) +if (!HAS_GT_UC (dev_priv))return -ENODEV ; p =drm_seq_file_printer (m);
@@ -1883,7 +1883,7 @@ static int i915_guc_load_status_info(struct seq_file *m, void *data)intel_wakeref_t wakeref;struct drm_printer p; -if (!HAS_GUC (dev_priv)) +if (!HAS_GT_UC (dev_priv))return -ENODEV ; p =drm_seq_file_printer (m);
@@ -2062,7 +2062,7 @@ static int i915_guc_log_dump(struct seq_file *m, void *data)u32 *log;int i =0 ; -if (!HAS_GUC (dev_priv)) +if (!HAS_GT_UC (dev_priv))return -ENODEV ;if (dump_load_err)
drivers/gpu/drm/i915/i915_drv.h +2 -13
@@ -2271,20 +2271,9 @@ IS_SUBPLATFORM(const struct drm_i915_private *i915,#define HAS_IPC (dev_priv) (INTEL_INFO(dev_priv)->display.has_ipc) -/* -* For now, anything with a GuC requires uCode loading, and then supports -* command submission once loaded. But these are logically independent -* properties, so we have separate macros to test them. -*/ -#define HAS_GUC (dev_priv) (INTEL_INFO(dev_priv)->has_guc) -#define HAS_GUC_UCODE (dev_priv) (HAS_GUC(dev_priv)) -#define HAS_GUC_SCHED (dev_priv) (HAS_GUC(dev_priv)) - -/* For now, anything with a GuC has also HuC */ -#define HAS_HUC (dev_priv) (HAS_GUC(dev_priv)) -#define HAS_HUC_UCODE (dev_priv) (HAS_GUC(dev_priv)) +#define HAS_GT_UC (dev_priv) (INTEL_INFO(dev_priv)->has_gt_uc) -/* Having a GuC is not the same as using a GuC */ +/* Having a uC is not the same as using a uC */ #define USES_GUC (dev_priv) intel_uc_is_using_guc(&(dev_priv)->gt.uc)#define USES_GUC_SUBMISSION (dev_priv) intel_uc_is_using_guc_submission(&(dev_priv)->gt.uc)#define USES_HUC (dev_priv) intel_uc_is_using_huc(&(dev_priv)->gt.uc)
drivers/gpu/drm/i915/i915_gpu_error.c +2 -2
@@ -651,7 +651,7 @@ static void err_print_uc(struct drm_i915_error_state_buf *m,const struct i915_gpu_state *error =container_of (error_uc,typeof (*error), uc); -if (!error->device_info.has_guc) +if (!error->device_info.has_gt_uc)return ;intel_uc_fw_dump (&error_uc->guc_fw, &p);
@@ -1455,7 +1455,7 @@ capture_uc_state(struct i915_gpu_state *error, struct compress *compress)struct intel_uc *uc = &i915->gt.uc;/* Capturing uC state won't be useful if there is no GuC */ -if (!error->device_info.has_guc) +if (!error->device_info.has_gt_uc)return ; error_uc->guc_fw = uc->guc.fw;
drivers/gpu/drm/i915/i915_irq.c +1 -1
@@ -4766,7 +4766,7 @@ void intel_irq_init(struct drm_i915_private *dev_priv) dev_priv->l3_parity.remap_info[i] =NULL ;/* pre-gen11 the guc irqs bits are in the upper 16 bits of the pm reg */ -if (HAS_GUC_SCHED (dev_priv) &&INTEL_GEN (dev_priv) <11 ) +if (HAS_GT_UC (dev_priv) &&INTEL_GEN (dev_priv) <11 ) dev_priv->gt.pm_guc_events =GUC_INTR_GUC2HOST <<16 ;/* Let's track the enabled rps events */
drivers/gpu/drm/i915/i915_pci.c +2 -2
@@ -595,7 +595,7 @@ static const struct intel_device_info intel_cherryview_info = { GEN9_DEFAULT_PAGE_SIZES, \ .has_logical_ring_preemption = 1, \ .display.has_csr = 1, \ - .has_guc = 1, \ + .has_gt_uc = 1, \ .display.has_ipc =1 , \ .ddb_size = 896
@@ -647,7 +647,7 @@ static const struct intel_device_info intel_skylake_gt4_info = { .display.has_dp_mst = 1, \ .has_logical_ring_contexts = 1, \ .has_logical_ring_preemption = 1, \ - .has_guc = 1, \ + .has_gt_uc = 1, \ .ppgtt_type = INTEL_PPGTT_FULL, \ .ppgtt_size = 48, \ .has_reset_engine = 1, \
drivers/gpu/drm/i915/intel_device_info.h +1 -1
@@ -112,7 +112,7 @@ enum intel_ppgtt_type {func (gpu_reset_clobbers_display); \func (has_reset_engine); \func (has_fpga_dbg); \ -func (has_guc); \ +func (has_gt_uc); \func (has_l3_dpf); \func (has_llc); \func (has_logical_ring_contexts); \
drivers/gpu/drm/i915/intel_pm.c +2 -2
@@ -7162,7 +7162,7 @@ static void gen11_enable_rc6(struct drm_i915_private *dev_priv)for_each_engine (engine, dev_priv, id)I915_WRITE (RING_MAX_IDLE (engine->mmio_base),10 ); -if (HAS_GUC (dev_priv)) +if (HAS_GT_UC (dev_priv))I915_WRITE (GUC_MAX_IDLE_COUNT ,0xA );I915_WRITE (GEN6_RC_SLEEP ,0 );
@@ -7243,7 +7243,7 @@ static void gen9_enable_rc6(struct drm_i915_private *dev_priv)for_each_engine (engine, dev_priv, id)I915_WRITE (RING_MAX_IDLE (engine->mmio_base),10 ); -if (HAS_GUC (dev_priv)) +if (HAS_GT_UC (dev_priv))I915_WRITE (GUC_MAX_IDLE_COUNT ,0xA );I915_WRITE (GEN6_RC_SLEEP ,0 );
drivers/gpu/drm/i915/intel_wopcm.c +2 -2
@@ -74,7 +74,7 @@ void intel_wopcm_init_early(struct intel_wopcm *wopcm) {struct drm_i915_private *i915 =wopcm_to_i915 (wopcm); -if (!HAS_GUC (i915)) +if (!HAS_GT_UC (i915))return ;if (INTEL_GEN (i915) >=11 )
@@ -263,7 +263,7 @@ int intel_wopcm_init_hw(struct intel_wopcm *wopcm, struct intel_gt *gt)if (!USES_GUC (i915))return 0 ; -GEM_BUG_ON (!HAS_GUC (i915)); +GEM_BUG_ON (!HAS_GT_UC (i915));GEM_BUG_ON (!wopcm->guc.size);GEM_BUG_ON (!wopcm->guc.base);
Signature · 6 lines
2.22.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 1/8] drm/i915/uc: Unify uC platform check
Quoted 130 lines · Daniele Ceraolo Spurio
We have several HAS_* checks for GuC and HuC but we mostly use
HAS_GUCandHAS_HUC, with only 1 exception. Since our HW always has either both uC or neither of them, just replace all the checks with a unifiedHAS_UC.v2: use
HAS_GT_UC(Michal)Signed-off-by Daniele Ceraolo Spurio <[email protected]>Cc Michal Wajdeczko <[email protected]>Acked-by Chris Wilson <[email protected]>--- drivers/gpu/drm/i915/gt/intel_reset.c | 2 +- drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c | 2 +- drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c | 2 +- drivers/gpu/drm/i915/gt/uc/intel_uc.c | 2 +- drivers/gpu/drm/i915/gt/uc/selftest_guc.c | 4 ++-- drivers/gpu/drm/i915/i915_debugfs.c | 6 +++--- drivers/gpu/drm/i915/i915_drv.h | 15 ++------------- drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++-- drivers/gpu/drm/i915/i915_irq.c | 2 +- drivers/gpu/drm/i915/i915_pci.c | 4 ++-- drivers/gpu/drm/i915/intel_device_info.h | 2 +- drivers/gpu/drm/i915/intel_pm.c | 4 ++-- drivers/gpu/drm/i915/intel_wopcm.c | 4 ++-- 13 files changed, 21 insertions(+), 32 deletions(-)drivers/gpu/drm/i915/gt/intel_reset.c +1
-1@@ -595,7 +595,7 @@ int intel_reset_guc(struct intel_gt *gt)INTEL_GEN (gt->i915) >=11 ?GEN11_GRDOM_GUC :GEN9_GRDOM_GUC ;int ret; -GEM_BUG_ON (!HAS_GUC (gt->i915)); +GEM_BUG_ON (!HAS_GT_UC (gt->i915));intel_uncore_forcewake_get (gt->uncore,FORCEWAKE_ALL ); ret =gen6_hw_domain_reset (gt, guc_domain);drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +1
-1@@ -80,7 +80,7 @@ static void guc_fw_select(struct intel_uc_fw *guc_fw)GEM_BUG_ON (guc_fw->type !=INTEL_UC_FW_TYPE_GUC ); -if (!HAS_GUC (i915)) { +if (!HAS_GT_UC (i915)) { guc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_SUPPORTED ;return ; }drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +1
-1@@ -74,7 +74,7 @@ static void huc_fw_select(struct intel_uc_fw *huc_fw)GEM_BUG_ON (huc_fw->type !=INTEL_UC_FW_TYPE_HUC ); -if (!HAS_HUC (dev_priv)) { +if (!HAS_GT_UC (dev_priv)) { huc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_SUPPORTED ;return ; }drivers/gpu/drm/i915/gt/uc/intel_uc.c +1
-1@@ -61,7 +61,7 @@ static int __get_platform_enable_guc(struct intel_uc *uc)struct intel_uc_fw *huc_fw = &uc->huc.fw;int enable_guc =0 ; -if (!HAS_GUC (uc_to_gt (uc)->i915)) +if (!HAS_GT_UC (uc_to_gt (uc)->i915))return 0 ;/* We don't want to enable GuC/HuC on pre-Gen11 by default */ drivers/gpu/drm/i915/gt/uc/selftest_guc.c +2
-2@@ -134,7 +134,7 @@ static int igt_guc_clients(void *args)struct intel_guc *guc;int err =0 ; -GEM_BUG_ON (!HAS_GUC (dev_priv)); +GEM_BUG_ON (!HAS_GT_UC (dev_priv));mutex_lock (&dev_priv->drm.struct_mutex); wakeref =intel_runtime_pm_get (&dev_priv->runtime_pm);@@ -226,7 +226,7 @@ static int igt_guc_doorbells(void *arg)int i, err =0 ;u16 db_id; -GEM_BUG_ON (!HAS_GUC (dev_priv)); +GEM_BUG_ON (!HAS_GT_UC (dev_priv));mutex_lock (&dev_priv->drm.struct_mutex); wakeref =intel_runtime_pm_get (&dev_priv->runtime_pm);drivers/gpu/drm/i915/i915_debugfs.c +3
-3@@ -1865,7 +1865,7 @@ static int i915_huc_load_status_info(struct seq_file *m, void *data)intel_wakeref_t wakeref;struct drm_printer p; -if (!HAS_HUC (dev_priv)) +if (!HAS_GT_UC (dev_priv))return -ENODEV ; p =drm_seq_file_printer (m);@@ -1883,7 +1883,7 @@ static int i915_guc_load_status_info(struct seq_file *m, void *data)intel_wakeref_t wakeref;struct drm_printer p; -if (!HAS_GUC (dev_priv)) +if (!HAS_GT_UC (dev_priv))return -ENODEV ; p =drm_seq_file_printer (m);@@ -2062,7 +2062,7 @@ static int i915_guc_log_dump(struct seq_file *m, void *data) u32 *log;int i =0 ; -if (!HAS_GUC (dev_priv)) +if (!HAS_GT_UC (dev_priv))return -ENODEV ;if (dump_load_err)drivers/gpu/drm/i915/i915_drv.h +0
-2@@ -2271,20 +2271,9 @@ IS_SUBPLATFORM(const struct drm_i915_private *i915, #define HAS_IPC(dev_priv) (INTEL_INFO(dev_priv)->display.has_ipc) -/* -* For now, anything with a GuC requires uCode loading, and then supports
- * command submission once loaded. But these are logically independent
- * properties, so we have separate macros to test them.
- */
drivers/gpu/drm/i915/i915_drv.h IS_SUBPLATFORM(const struct drm_i915_private *i915, · line 2276
Quoted 10 lines
drivers/gpu/drm/i915/i915_drv.h +2
-8-#define HAS_GUC (dev_priv) (INTEL_INFO(dev_priv)->has_guc) -#define HAS_GUC_UCODE (dev_priv) (HAS_GUC(dev_priv)) -#define HAS_GUC_SCHED (dev_priv) (HAS_GUC(dev_priv)) - -/* For now, anything with a GuC has also HuC */ -#define HAS_HUC (dev_priv) (HAS_GUC(dev_priv)) -#define HAS_HUC_UCODE (dev_priv) (HAS_GUC(dev_priv)) +#define HAS_GT_UC (dev_priv) (INTEL_INFO(dev_priv)->has_gt_uc) -/* Having a GuC is not the same as using a GuC */ +/* Having a uC is not the same as using a uC */
nit: "Having GuC/HuC is not the same as using GuC/HuC" but not a blocker
Quoted 104 lines
#define
USES_GUC(dev_priv)intel_uc_is_using_guc(&(dev_priv)->gt.uc)
#defineUSES_GUC_SUBMISSION(dev_priv)intel_uc_is_using_guc_submission(&(dev_priv)->gt.uc)
#defineUSES_HUC(dev_priv)intel_uc_is_using_huc(&(dev_priv)->gt.uc)drivers/gpu/drm/i915/i915_gpu_error.c +2
-2@@ -651,7 +651,7 @@ static void err_print_uc(structdrm_i915_error_state_buf *m, const struct i915_gpu_state *error =container_of (error_uc,typeof (*error), uc); -if (!error->device_info.has_guc) +if (!error->device_info.has_gt_uc)return ;intel_uc_fw_dump (&error_uc->guc_fw, &p);@@ -1455,7 +1455,7 @@ capture_uc_state(struct i915_gpu_state *error, struct compress *compress)struct intel_uc *uc = &i915->gt.uc;/* Capturing uC state won't be useful if there is no GuC */ -if (!error->device_info.has_guc) +if (!error->device_info.has_gt_uc)return ; error_uc->guc_fw = uc->guc.fw;drivers/gpu/drm/i915/i915_irq.c +1
-1@@ -4766,7 +4766,7 @@ void intel_irq_init(struct drm_i915_private *dev_priv) dev_priv->l3_parity.remap_info[i] =NULL ;/* pre-gen11 the guc irqs bits are in the upper 16 bits of the pm reg */ -if (HAS_GUC_SCHED (dev_priv) &&INTEL_GEN (dev_priv) <11 ) +if (HAS_GT_UC (dev_priv) &&INTEL_GEN (dev_priv) <11 ) dev_priv->gt.pm_guc_events =GUC_INTR_GUC2HOST <<16 ;/* Let's track the enabled rps events */ drivers/gpu/drm/i915/i915_pci.c +2
-2@@ -595,7 +595,7 @@ static const struct intel_device_info intel_cherryview_info = { GEN9_DEFAULT_PAGE_SIZES, \ .has_logical_ring_preemption = 1, \ .display.has_csr = 1, \ - .has_guc = 1, \ + .has_gt_uc = 1, \ .display.has_ipc =1 , \ .ddb_size = 896@@ -647,7 +647,7 @@ static const struct intel_device_info intel_skylake_gt4_info = { .display.has_dp_mst = 1, \ .has_logical_ring_contexts = 1, \ .has_logical_ring_preemption = 1, \ - .has_guc = 1, \ + .has_gt_uc = 1, \ .ppgtt_type = INTEL_PPGTT_FULL, \ .ppgtt_size = 48, \drivers/gpu/drm/i915/i915_pci.c +0
-0.has_reset_engine = 1, \drivers/gpu/drm/i915/intel_device_info.h +1
-1@@ -112,7 +112,7 @@ enum intel_ppgtt_type {func (gpu_reset_clobbers_display); \func (has_reset_engine); \func (has_fpga_dbg); \ -func (has_guc); \ +func (has_gt_uc); \func (has_l3_dpf); \func (has_llc); \func (has_logical_ring_contexts); \drivers/gpu/drm/i915/intel_pm.c +2
-2@@ -7162,7 +7162,7 @@ static void gen11_enable_rc6(struct drm_i915_private *dev_priv) for_each_engine(engine, dev_priv, id) I915_WRITE(RING_MAX_IDLE(engine->mmio_base), 10); - if (HAS_GUC(dev_priv)) + if (HAS_GT_UC(dev_priv)) I915_WRITE(GUC_MAX_IDLE_COUNT, 0xA);I915_WRITE (GEN6_RC_SLEEP ,0 );@@ -7243,7 +7243,7 @@ static void gen9_enable_rc6(struct drm_i915_private *dev_priv) for_each_engine(engine, dev_priv, id) I915_WRITE(RING_MAX_IDLE(engine->mmio_base), 10); - if (HAS_GUC(dev_priv)) + if (HAS_GT_UC(dev_priv)) I915_WRITE(GUC_MAX_IDLE_COUNT, 0xA);I915_WRITE (GEN6_RC_SLEEP ,0 );drivers/gpu/drm/i915/intel_wopcm.c +1
-1@@ -74,7 +74,7 @@ void intel_wopcm_init_early(struct intel_wopcm *wopcm) {struct drm_i915_private *i915 =wopcm_to_i915 (wopcm); -if (!HAS_GUC (i915)) +if (!HAS_GT_UC (i915))return ;if (INTEL_GEN (i915) >=11 )
drivers/gpu/drm/i915/intel_wopcm.c int intel_wopcm_init_hw(struct intel_wopcm *wopcm, · line 268
Quoted 7 lines
drivers/gpu/drm/i915/intel_wopcm.c +1
-1@@ -263,7 +263,7 @@ int intel_wopcm_init_hw(struct intel_wopcm *wopcm, struct intel_gt *gt)if (!USES_GUC (i915))return 0 ; -GEM_BUG_ON (!HAS_GUC (i915)); +GEM_BUG_ON (!HAS_GT_UC (i915));GEM_BUG_ON (!wopcm->guc.size);GEM_BUG_ON (!wopcm->guc.base);
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 2/8 drm/i915/uc: Unify uC FW selection
In reply to Daniele Ceraolo SpurioInstead of having 2 identical functions for GuC and HuC firmware selection, we can unify the selection logic and just use different lists based on FW type.
Note that the revid is not relevant for current blobs, but the upcoming CML will be identified as CFL rev 5, so by considering the revid we're ready for that.
v2: rework blob list defs (Michal), add order check (Chris), fuse GuC
and HuC lists into one.
--- drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c | 86 +----------- drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c | 88 +----------- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 156 ++++++++++++++++++++++ drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h | 29 ++-- 4 files changed, 167 insertions(+), 192 deletions(-)
drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +1 -85
@@ -31,89 +31,6 @@#include "intel_guc_fw.h" #include "i915_drv.h" -#define __MAKE_GUC_FW_PATH (KEY ) \ - "i915/" \ - __stringify(KEY##_GUC_FW_PREFIX) "_guc_" \ - __stringify(KEY##_GUC_FW_MAJOR) "." \ - __stringify(KEY##_GUC_FW_MINOR) "." \ - __stringify(KEY##_GUC_FW_PATCH) ".bin" - -#define SKL_GUC_FW_PREFIX skl -#define SKL_GUC_FW_MAJOR 33 -#define SKL_GUC_FW_MINOR 0 -#define SKL_GUC_FW_PATCH 0 -#define SKL_GUC_FIRMWARE_PATH __MAKE_GUC_FW_PATH(SKL) -MODULE_FIRMWARE (SKL_GUC_FIRMWARE_PATH ); - -#define BXT_GUC_FW_PREFIX bxt -#define BXT_GUC_FW_MAJOR 33 -#define BXT_GUC_FW_MINOR 0 -#define BXT_GUC_FW_PATCH 0 -#define BXT_GUC_FIRMWARE_PATH __MAKE_GUC_FW_PATH(BXT) -MODULE_FIRMWARE (BXT_GUC_FIRMWARE_PATH ); - -#define KBL_GUC_FW_PREFIX kbl -#define KBL_GUC_FW_MAJOR 33 -#define KBL_GUC_FW_MINOR 0 -#define KBL_GUC_FW_PATCH 0 -#define KBL_GUC_FIRMWARE_PATH __MAKE_GUC_FW_PATH(KBL) -MODULE_FIRMWARE (KBL_GUC_FIRMWARE_PATH ); - -#define GLK_GUC_FW_PREFIX glk -#define GLK_GUC_FW_MAJOR 33 -#define GLK_GUC_FW_MINOR 0 -#define GLK_GUC_FW_PATCH 0 -#define GLK_GUC_FIRMWARE_PATH __MAKE_GUC_FW_PATH(GLK) -MODULE_FIRMWARE (GLK_GUC_FIRMWARE_PATH ); - -#define ICL_GUC_FW_PREFIX icl -#define ICL_GUC_FW_MAJOR 33 -#define ICL_GUC_FW_MINOR 0 -#define ICL_GUC_FW_PATCH 0 -#define ICL_GUC_FIRMWARE_PATH __MAKE_GUC_FW_PATH(ICL) -MODULE_FIRMWARE (ICL_GUC_FIRMWARE_PATH ); - -static void guc_fw_select (struct intel_uc_fw *guc_fw) -{ - struct intel_guc *guc = container_of(guc_fw, struct intel_guc, fw); -struct drm_i915_private *i915 =guc_to_gt (guc)->i915; - -GEM_BUG_ON (guc_fw->type !=INTEL_UC_FW_TYPE_GUC ); - -if (!HAS_GT_UC (i915)) { - guc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_SUPPORTED ; -return ; - } - - guc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_STARTED ; - -if (i915_modparams.guc_firmware_path) { - guc_fw->path = i915_modparams.guc_firmware_path; - guc_fw->major_ver_wanted =0 ; - guc_fw->minor_ver_wanted =0 ; - }else if (IS_ICELAKE (i915)) { - guc_fw->path =ICL_GUC_FIRMWARE_PATH ; - guc_fw->major_ver_wanted =ICL_GUC_FW_MAJOR ; - guc_fw->minor_ver_wanted =ICL_GUC_FW_MINOR ; - }else if (IS_GEMINILAKE (i915)) { - guc_fw->path =GLK_GUC_FIRMWARE_PATH ; - guc_fw->major_ver_wanted =GLK_GUC_FW_MAJOR ; - guc_fw->minor_ver_wanted =GLK_GUC_FW_MINOR ; - }else if (IS_KABYLAKE (i915) ||IS_COFFEELAKE (i915)) { - guc_fw->path =KBL_GUC_FIRMWARE_PATH ; - guc_fw->major_ver_wanted =KBL_GUC_FW_MAJOR ; - guc_fw->minor_ver_wanted =KBL_GUC_FW_MINOR ; - }else if (IS_BROXTON (i915)) { - guc_fw->path =BXT_GUC_FIRMWARE_PATH ; - guc_fw->major_ver_wanted =BXT_GUC_FW_MAJOR ; - guc_fw->minor_ver_wanted =BXT_GUC_FW_MINOR ; - }else if (IS_SKYLAKE (i915)) { - guc_fw->path =SKL_GUC_FIRMWARE_PATH ; - guc_fw->major_ver_wanted =SKL_GUC_FW_MAJOR ; - guc_fw->minor_ver_wanted =SKL_GUC_FW_MINOR ; - } -} -/** * intel_guc_fw_init_early() - initializes GuC firmware struct * @guc: intel_guc struct
@@ -124,8 +41,7 @@ void intel_guc_fw_init_early(struct intel_guc *guc) {struct intel_uc_fw *guc_fw = &guc->fw; -intel_uc_fw_init_early (guc_fw,INTEL_UC_FW_TYPE_GUC ); -guc_fw_select (guc_fw); +intel_uc_fw_init_early (guc_to_gt (guc)->i915, guc_fw,INTEL_UC_FW_TYPE_GUC ); }static void guc_prepare_xfer (struct intel_guc *guc)
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +1 -87
100 lines not on this page · raw message
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +156 -0
162 lines not on this page · raw message
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +9 -20
@@ -44,8 +44,9 @@ enum intel_uc_fw_status { };enum intel_uc_fw_type { -INTEL_UC_FW_TYPE_GUC , -INTEL_UC_FW_TYPE_HUC +INTEL_UC_FW_TYPE_GUC =0 , +INTEL_UC_FW_TYPE_HUC , +INTEL_UC_NUM_TYPES };/*
@@ -105,24 +106,9 @@ static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type)return "GuC" ;case INTEL_UC_FW_TYPE_HUC :return "HuC" ; +default : +return "uC" ; } -return "uC" ; -} - -static inline -void intel_uc_fw_init_early (struct intel_uc_fw *uc_fw, -enum intel_uc_fw_type type) -{ -/* -* we use FIRMWARE_UNINITIALIZED to detect checks against fetch_status -* before we're looked at the HW caps to see if we have uc support -*/ -BUILD_BUG_ON (INTEL_UC_FIRMWARE_UNINITIALIZED ); - - uc_fw->path =NULL ; - uc_fw->fetch_status =INTEL_UC_FIRMWARE_UNINITIALIZED ; - uc_fw->load_status =INTEL_UC_FIRMWARE_NOT_STARTED ; - uc_fw->type = type; }static inline bool intel_uc_fw_is_selected (struct intel_uc_fw *uc_fw)
@@ -164,7 +150,10 @@ static inline u32 intel_uc_fw_get_upload_size(struct intel_uc_fw *uc_fw)return uc_fw->header_size + uc_fw->ucode_size; } -void intel_uc_fw_fetch (struct drm_i915_private *dev_priv, +void intel_uc_fw_init_early (struct drm_i915_private *i915, +struct intel_uc_fw *uc_fw, +enum intel_uc_fw_type type); +void intel_uc_fw_fetch (struct drm_i915_private *i915,struct intel_uc_fw *uc_fw);void intel_uc_fw_cleanup_fetch (struct intel_uc_fw *uc_fw); int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,
Signature · 6 lines
2.22.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 2/8] drm/i915/uc: Unify uC FW selection
Quoting Daniele Ceraolo Spurio (2019-07-24 03:21:47)
Quoted 22 lines
Instead of having 2 identical functions for GuC and HuC firmware selection, we can unify the selection logic and just use different lists based on FW type.
Note that the revid is not relevant for current blobs, but the upcoming CML will be identified as CFL rev 5, so by considering the revid we're ready for that.
v2: rework blob list defs (Michal), add order check (Chris), fuse GuC
and HuC lists into one.Signed-off-by Daniele Ceraolo Spurio <[email protected]>Cc Michal Wajdeczko <[email protected]>Cc Anusha Srivatsa <[email protected]>Cc Chris Wilson <[email protected]>---
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +0
-0@@ -23,91 +23,6 @@* Note that HuC firmware loading must be done before GuC loading.
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c
Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +5
-3*/ -#define SKL_HUC_FW_MAJOR 01 -#define SKL_HUC_FW_MINOR 07 -#define SKL_BLD_NUM 1398 + * List of required GuC and HuC binaries per-platform. + * Must be ordered based on platform + revid, from newer to older. + */ +#define INTEL_UC_FIRMWARE_DEFS (fw_def, guc_def, huc_def) \ + fw_def(ICELAKE, 0, guc_def(icl, 33, 0, 0), huc_def(icl, 8, 4, 3238)) \
✓
Quoted 1 line
+
fw_def(COFFEELAKE, 0, guc_def(kbl, 33, 0, 0), huc_def(kbl, 02, 00, 1810))\
✓
Oh we still don't have the new version. Hmm, I think you have planned for it well enough.
Quoted 1 line
+
fw_def(GEMINILAKE, 0, guc_def(glk, 33, 0, 0), huc_def(glk, 03, 01, 2893))\
✓
Quoted 1 line
+
fw_def(KABYLAKE, 0, guc_def(kbl, 33, 0, 0), huc_def(kbl, 02, 00, 1810))\
✓
Quoted 1 line
+
fw_def(BROXTON, 0, guc_def(bxt, 33, 0, 0), huc_def(bxt, 01, 8, 2893))\
✓
Quoted 1 line
+
fw_def(SKYLAKE, 0, guc_def(skl, 33, 0, 0), huc_def(skl, 01, 07, 1398))
✓
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c
Quoted 6 lines
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +6
-0+#define __MAKE_UC_FW_PATH (prefix_, name_, separator_, major_, minor_, patch_) \ + "i915/" \ + __stringify(prefix_) name_ \ + __stringify(major_) separator_ \ + __stringify(minor_) separator_ \ + __stringify(patch_) ".bin"
I still can't believe that encoding version strings into paths is the best solution but whatever.
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c
Quoted 12 lines
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +12
-0+#define MAKE_GUC_FW_PATH (prefix_, major_, minor_, patch_) \ + __MAKE_UC_FW_PATH(prefix_, "_guc_", ".", major_, minor_, patch_) + +#define MAKE_HUC_FW_PATH (prefix_, major_, minor_, bld_num_) \ + __MAKE_UC_FW_PATH(prefix_, "_huc_ver", "_", major_, minor_, bld_num_) + +/* All blobs need to be declared via MODULE_FIRMWARE() */ +#define INTEL_UC_MODULE_FW (platform_, revid_, guc_, huc_) \ + MODULE_FIRMWARE(guc_); \ + MODULE_FIRMWARE(huc_); + +INTEL_UC_FIRMWARE_DEFS (INTEL_UC_MODULE_FW ,MAKE_GUC_FW_PATH ,MAKE_HUC_FW_PATH )
Ok. That was fun.
Quoted 65 lines
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +65
-0+ +/* +* The below defs and macros are used to iterate across the list of blobs. See +* __uc_fw_select() below for details. +*/ +struct __packed intel_uc_fw_blob { +u8 major; +u8 minor; +const char *path; +}; + +#define UC_FW_BLOB (major_, minor_, path_) \ + { .major = major_, .minor = minor_, .path = path_ } + +#define GUC_FW_BLOB (prefix_, major_, minor_, patch_) \ + UC_FW_BLOB(major_, minor_, \ + MAKE_GUC_FW_PATH(prefix_, major_, minor_, patch_)) + +#define HUC_FW_BLOB (prefix_, major_, minor_, bld_num_) \ + UC_FW_BLOB(major_, minor_, \ + MAKE_HUC_FW_PATH(prefix_, major_, minor_, bld_num_)) + +#define MAKE_FW_LIST (platform_, revid_, guc_, huc_) \ +{ \ + .p = INTEL_##platform_, \ + .first_rev = revid_, \ + .blobs[INTEL_UC_FW_TYPE_GUC] = guc_, \ + .blobs[INTEL_UC_FW_TYPE_HUC] = huc_, \ +}, + +static void +__uc_fw_select (struct intel_uc_fw *uc_fw,enum intel_platform p,u8 rev) +{ +static const struct __packed { +enum intel_platform p; +u8 first_rev; +const struct intel_uc_fw_blob blobs[INTEL_UC_NUM_TYPES ]; + } fw_blobs[] = { +INTEL_UC_FIRMWARE_DEFS (MAKE_FW_LIST ,GUC_FW_BLOB ,HUC_FW_BLOB ) + }; +int i; + +for (i =0 ; i <ARRAY_SIZE (fw_blobs) && p <= fw_blobs[i].p; i++) { +if (p == fw_blobs[i].p && rev >= fw_blobs[i].first_rev) { +const struct intel_uc_fw_blob *blob = + &fw_blobs[i].blobs[uc_fw->type]; + uc_fw->path = blob->path; + uc_fw->major_ver_wanted = blob->major; + uc_fw->minor_ver_wanted = blob->minor; +break ; + } + } + +/* make sure the list is ordered as expected */ +if (IS_ENABLED (CONFIG_DRM_I915_SELFTEST )) { +for (i =1 ; i <ARRAY_SIZE (fw_blobs); i++) { +if (fw_blobs[i].p < fw_blobs[i -1 ].p) +continue ; + +if (fw_blobs[i].p == fw_blobs[i -1 ].p && + fw_blobs[i].first_rev < fw_blobs[i -1 ].first_rev) +continue ; + + pr_err("invalid FW blob order: %s r%u comes before %s r%u\n", + intel_platform_name(fw_blobs[i - 1].p),
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c
Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +10
-0+ fw_blobs[i -1 ].first_rev, +intel_platform_name (fw_blobs[i].p), + fw_blobs[i].first_rev); + + uc_fw->path =NULL ; + uc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_SUPPORTED ; +return ; + } + } +}
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 2/8] drm/i915/uc: Unify uC FW selection
In reply to Daniele Ceraolo SpurioQuoted 280 lines · Daniele Ceraolo Spurio
Instead of having 2 identical functions for GuC and HuC firmware selection, we can unify the selection logic and just use different lists based on FW type.
Note that the revid is not relevant for current blobs, but the upcoming CML will be identified as CFL rev 5, so by considering the revid we're ready for that.
v2: rework blob list defs (Michal), add order check (Chris), fuse GuC
and HuC lists into one.Signed-off-by Daniele Ceraolo Spurio <[email protected]>Cc Michal Wajdeczko <[email protected]>Cc Anusha Srivatsa <[email protected]>Cc Chris Wilson <[email protected]>--- drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c | 86 +----------- drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c | 88 +----------- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 156 ++++++++++++++++++++++ drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h | 29 ++-- 4 files changed, 167 insertions(+), 192 deletions(-)drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +1
-85@@ -31,89 +31,6 @@#include "intel_guc_fw.h" #include "i915_drv.h" -#define __MAKE_GUC_FW_PATH (KEY ) \ - "i915/" \ - __stringify(KEY##_GUC_FW_PREFIX) "_guc_" \ - __stringify(KEY##_GUC_FW_MAJOR) "." \ - __stringify(KEY##_GUC_FW_MINOR) "." \ - __stringify(KEY##_GUC_FW_PATCH) ".bin" - -#define SKL_GUC_FW_PREFIX skl -#define SKL_GUC_FW_MAJOR 33 -#define SKL_GUC_FW_MINOR 0 -#define SKL_GUC_FW_PATCH 0 -#define SKL_GUC_FIRMWARE_PATH __MAKE_GUC_FW_PATH(SKL) -MODULE_FIRMWARE (SKL_GUC_FIRMWARE_PATH ); - -#define BXT_GUC_FW_PREFIX bxt -#define BXT_GUC_FW_MAJOR 33 -#define BXT_GUC_FW_MINOR 0 -#define BXT_GUC_FW_PATCH 0 -#define BXT_GUC_FIRMWARE_PATH __MAKE_GUC_FW_PATH(BXT) -MODULE_FIRMWARE (BXT_GUC_FIRMWARE_PATH ); - -#define KBL_GUC_FW_PREFIX kbl -#define KBL_GUC_FW_MAJOR 33 -#define KBL_GUC_FW_MINOR 0 -#define KBL_GUC_FW_PATCH 0 -#define KBL_GUC_FIRMWARE_PATH __MAKE_GUC_FW_PATH(KBL) -MODULE_FIRMWARE (KBL_GUC_FIRMWARE_PATH ); - -#define GLK_GUC_FW_PREFIX glk -#define GLK_GUC_FW_MAJOR 33 -#define GLK_GUC_FW_MINOR 0 -#define GLK_GUC_FW_PATCH 0 -#define GLK_GUC_FIRMWARE_PATH __MAKE_GUC_FW_PATH(GLK) -MODULE_FIRMWARE (GLK_GUC_FIRMWARE_PATH ); - -#define ICL_GUC_FW_PREFIX icl -#define ICL_GUC_FW_MAJOR 33 -#define ICL_GUC_FW_MINOR 0 -#define ICL_GUC_FW_PATCH 0 -#define ICL_GUC_FIRMWARE_PATH __MAKE_GUC_FW_PATH(ICL) -MODULE_FIRMWARE (ICL_GUC_FIRMWARE_PATH ); - -static void guc_fw_select (struct intel_uc_fw *guc_fw) -{ - struct intel_guc *guc = container_of(guc_fw, struct intel_guc, fw); -struct drm_i915_private *i915 =guc_to_gt (guc)->i915; - -GEM_BUG_ON (guc_fw->type !=INTEL_UC_FW_TYPE_GUC ); - -if (!HAS_GT_UC (i915)) { - guc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_SUPPORTED ; -return ; - } - - guc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_STARTED ; - -if (i915_modparams.guc_firmware_path) { - guc_fw->path = i915_modparams.guc_firmware_path; - guc_fw->major_ver_wanted =0 ; - guc_fw->minor_ver_wanted =0 ; - }else if (IS_ICELAKE (i915)) { - guc_fw->path =ICL_GUC_FIRMWARE_PATH ; - guc_fw->major_ver_wanted =ICL_GUC_FW_MAJOR ; - guc_fw->minor_ver_wanted =ICL_GUC_FW_MINOR ; - }else if (IS_GEMINILAKE (i915)) { - guc_fw->path =GLK_GUC_FIRMWARE_PATH ; - guc_fw->major_ver_wanted =GLK_GUC_FW_MAJOR ; - guc_fw->minor_ver_wanted =GLK_GUC_FW_MINOR ; - }else if (IS_KABYLAKE (i915) ||IS_COFFEELAKE (i915)) { - guc_fw->path =KBL_GUC_FIRMWARE_PATH ; - guc_fw->major_ver_wanted =KBL_GUC_FW_MAJOR ; - guc_fw->minor_ver_wanted =KBL_GUC_FW_MINOR ; - }else if (IS_BROXTON (i915)) { - guc_fw->path =BXT_GUC_FIRMWARE_PATH ; - guc_fw->major_ver_wanted =BXT_GUC_FW_MAJOR ; - guc_fw->minor_ver_wanted =BXT_GUC_FW_MINOR ; - }else if (IS_SKYLAKE (i915)) { - guc_fw->path =SKL_GUC_FIRMWARE_PATH ; - guc_fw->major_ver_wanted =SKL_GUC_FW_MAJOR ; - guc_fw->minor_ver_wanted =SKL_GUC_FW_MINOR ; - } -} -/** * intel_guc_fw_init_early() - initializes GuC firmware struct * @guc: intel_guc struct @@ -124,8 +41,7 @@ void intel_guc_fw_init_early(struct intel_guc *guc) {struct intel_uc_fw *guc_fw = &guc->fw; -intel_uc_fw_init_early (guc_fw,INTEL_UC_FW_TYPE_GUC ); -guc_fw_select (guc_fw); +intel_uc_fw_init_early (guc_to_gt (guc)->i915, guc_fw,INTEL_UC_FW_TYPE_GUC ); }static void guc_prepare_xfer (struct intel_guc *guc)drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +1
-87@@ -23,91 +23,6 @@* Note that HuC firmware loading must be done before GuC loading. */ -#define BXT_HUC_FW_MAJOR 01 -#define BXT_HUC_FW_MINOR 8 -#define BXT_BLD_NUM 2893 - -#define SKL_HUC_FW_MAJOR 01 -#define SKL_HUC_FW_MINOR 07 -#define SKL_BLD_NUM 1398 - -#define KBL_HUC_FW_MAJOR 02 -#define KBL_HUC_FW_MINOR 00 -#define KBL_BLD_NUM 1810 - -#define GLK_HUC_FW_MAJOR 03 -#define GLK_HUC_FW_MINOR 01 -#define GLK_BLD_NUM 2893 - -#define ICL_HUC_FW_MAJOR 8 -#define ICL_HUC_FW_MINOR 4 -#define ICL_BLD_NUM 3238 - -#define HUC_FW_PATH (platform, major, minor, bld_num) \ - "i915/" __stringify(platform) "_huc_ver" __stringify(major) "_" \ - __stringify(minor) "_" __stringify(bld_num) ".bin" - -#define I915_SKL_HUC_UCODE HUC_FW_PATH(skl, SKL_HUC_FW_MAJOR, \ - SKL_HUC_FW_MINOR, SKL_BLD_NUM) -MODULE_FIRMWARE (I915_SKL_HUC_UCODE ); - -#define I915_BXT_HUC_UCODE HUC_FW_PATH(bxt, BXT_HUC_FW_MAJOR, \ - BXT_HUC_FW_MINOR, BXT_BLD_NUM) -MODULE_FIRMWARE (I915_BXT_HUC_UCODE ); - -#define I915_KBL_HUC_UCODE HUC_FW_PATH(kbl, KBL_HUC_FW_MAJOR, \ - KBL_HUC_FW_MINOR, KBL_BLD_NUM) -MODULE_FIRMWARE (I915_KBL_HUC_UCODE ); - -#define I915_GLK_HUC_UCODE HUC_FW_PATH(glk, GLK_HUC_FW_MAJOR, \ - GLK_HUC_FW_MINOR, GLK_BLD_NUM) -MODULE_FIRMWARE (I915_GLK_HUC_UCODE ); - -#define I915_ICL_HUC_UCODE HUC_FW_PATH(icl, ICL_HUC_FW_MAJOR, \ - ICL_HUC_FW_MINOR, ICL_BLD_NUM) -MODULE_FIRMWARE (I915_ICL_HUC_UCODE ); - -static void huc_fw_select (struct intel_uc_fw *huc_fw) -{ - struct intel_huc *huc = container_of(huc_fw, struct intel_huc, fw); -struct drm_i915_private *dev_priv =huc_to_gt (huc)->i915; - -GEM_BUG_ON (huc_fw->type !=INTEL_UC_FW_TYPE_HUC ); - -if (!HAS_GT_UC (dev_priv)) { - huc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_SUPPORTED ; -return ; - } - - huc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_STARTED ; - -if (i915_modparams.huc_firmware_path) { - huc_fw->path = i915_modparams.huc_firmware_path; - huc_fw->major_ver_wanted =0 ; - huc_fw->minor_ver_wanted =0 ; - }else if (IS_SKYLAKE (dev_priv)) { - huc_fw->path =I915_SKL_HUC_UCODE ; - huc_fw->major_ver_wanted =SKL_HUC_FW_MAJOR ; - huc_fw->minor_ver_wanted =SKL_HUC_FW_MINOR ; - }else if (IS_BROXTON (dev_priv)) { - huc_fw->path =I915_BXT_HUC_UCODE ; - huc_fw->major_ver_wanted =BXT_HUC_FW_MAJOR ; - huc_fw->minor_ver_wanted =BXT_HUC_FW_MINOR ; - }else if (IS_KABYLAKE (dev_priv) ||IS_COFFEELAKE (dev_priv)) { - huc_fw->path =I915_KBL_HUC_UCODE ; - huc_fw->major_ver_wanted =KBL_HUC_FW_MAJOR ; - huc_fw->minor_ver_wanted =KBL_HUC_FW_MINOR ; - }else if (IS_GEMINILAKE (dev_priv)) { - huc_fw->path =I915_GLK_HUC_UCODE ; - huc_fw->major_ver_wanted =GLK_HUC_FW_MAJOR ; - huc_fw->minor_ver_wanted =GLK_HUC_FW_MINOR ; - }else if (IS_ICELAKE (dev_priv)) { - huc_fw->path =I915_ICL_HUC_UCODE ; - huc_fw->major_ver_wanted =ICL_HUC_FW_MAJOR ; - huc_fw->minor_ver_wanted =ICL_HUC_FW_MINOR ; - } -} -/** * intel_huc_fw_init_early() - initializes HuC firmware struct * @huc: intel_huc struct @@ -118,8 +33,7 @@ void intel_huc_fw_init_early(struct intel_huc *huc) {struct intel_uc_fw *huc_fw = &huc->fw; -intel_uc_fw_init_early (huc_fw,INTEL_UC_FW_TYPE_HUC ); -huc_fw_select (huc_fw); +intel_uc_fw_init_early (huc_to_gt (huc)->i915, huc_fw,INTEL_UC_FW_TYPE_HUC ); }static void huc_xfer_rsa (struct intel_huc *huc)drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +10
-0@@ -29,6 +29,162 @@#include "intel_uc_fw.h" #include "i915_drv.h" +/* +* List of required GuC and HuC binaries per-platform. +* Must be ordered based on platform + revid, from newer to older. +*/ +#define INTEL_UC_FIRMWARE_DEFS (fw_def, guc_def, huc_def) \ + fw_def(ICELAKE, 0, guc_def(icl, 33, 0, 0), huc_def(icl, 8, 4, 3238)) \ +fw_def (COFFEELAKE ,0 ,guc_def (kbl,33 ,0 ,0 ),huc_def (kbl,02 ,00 , 1810)) \ +fw_def (GEMINILAKE ,0 ,guc_def (glk,33 ,0 ,0 ),huc_def (glk,03 ,01 , 2893)) \ +fw_def (KABYLAKE ,0 ,guc_def (kbl,33 ,0 ,0 ),huc_def (kbl,02 ,00 , 1810)) \ + fw_def(BROXTON, 0, guc_def(bxt, 33, 0, 0), huc_def(bxt, 01, 8,2893)) \
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +1
-0+ fw_def(SKYLAKE, 0, guc_def(skl, 33, 0, 0), huc_def(skl, 01, 07,1398))
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +2
-0+ +#define __MAKE_UC_FW_PATH(prefix_, name_, separator_, major_, minor_,
patch_) \drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +18
-0+"i915/" \ + __stringify(prefix_) name_ \ + __stringify(major_) separator_ \ + __stringify(minor_) separator_ \ + __stringify(patch_) ".bin" + +#define MAKE_GUC_FW_PATH (prefix_, major_, minor_, patch_) \ + __MAKE_UC_FW_PATH(prefix_, "_guc_", ".", major_, minor_, patch_) + +#define MAKE_HUC_FW_PATH (prefix_, major_, minor_, bld_num_) \ + __MAKE_UC_FW_PATH(prefix_, "_huc_ver", "_", major_, minor_, bld_num_) + +/* All blobs need to be declared via MODULE_FIRMWARE() */ +#define INTEL_UC_MODULE_FW (platform_, revid_, guc_, huc_) \ + MODULE_FIRMWARE(guc_); \ + MODULE_FIRMWARE(huc_); + +INTEL_UC_FIRMWARE_DEFS(INTEL_UC_MODULE_FW, MAKE_GUC_FW_PATH,
MAKE_HUC_FW_PATH)drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +3
-0+ +/* +* The below defs and macros are used to iterate across the list of blobs. See
+ *__uc_fw_select()below for details.
+ */
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c line 70
Quoted 3 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +3
-0+struct __packed intel_uc_fw_blob { +u8 major; +u8 minor;
HuC firmware is using 16 bits for major/minor but I guess we have some time until we get to version 255
Quoted 11 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +11
-0+const char *path; +}; + +#define UC_FW_BLOB (major_, minor_, path_) \ + { .major = major_, .minor = minor_, .path = path_ } + +#define GUC_FW_BLOB (prefix_, major_, minor_, patch_) \ + UC_FW_BLOB(major_, minor_, \ + MAKE_GUC_FW_PATH(prefix_, major_, minor_, patch_)) + +#define HUC_FW_BLOB (prefix_, major_, minor_, bld_num_) \
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c line 91
Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +10
-0+UC_FW_BLOB (major_, minor_, \ + MAKE_HUC_FW_PATH(prefix_, major_, minor_, bld_num_)) + +#define MAKE_FW_LIST (platform_, revid_, guc_, huc_) \ +{ \ + .p = INTEL_##platform_, \ + .first_rev = revid_, \ + .blobs[INTEL_UC_FW_TYPE_GUC] = guc_, \ + .blobs[INTEL_UC_FW_TYPE_HUC] = huc_, \ +},
nit: unnamed struct on which above macro operates is defined inside function below - either keep this macro private to the function or move struct definition outside function,
btw, above you've already provided definition for struct intel_uc_fw_blob
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c line 97
Quoted 6 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +6
-0+ +static void +__uc_fw_select (struct intel_uc_fw *uc_fw,enum intel_platform p,u8 rev) +{ + static const struct __packed { + enum intel_platform p;
nit: using full "platform" word instead of "p" will not hurt
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c line 98
Quoted 1 line
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +1
-0+u8 first_rev;
nit: maybe just "rev", from comment above we know that this is first one
Quoted 25 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +25
-0+const struct intel_uc_fw_blob blobs[INTEL_UC_NUM_TYPES ]; + } fw_blobs[] = { +INTEL_UC_FIRMWARE_DEFS (MAKE_FW_LIST ,GUC_FW_BLOB ,HUC_FW_BLOB ) + }; +int i; + +for (i =0 ; i <ARRAY_SIZE (fw_blobs) && p <= fw_blobs[i].p; i++) { +if (p == fw_blobs[i].p && rev >= fw_blobs[i].first_rev) { +const struct intel_uc_fw_blob *blob = + &fw_blobs[i].blobs[uc_fw->type]; + uc_fw->path = blob->path; + uc_fw->major_ver_wanted = blob->major; + uc_fw->minor_ver_wanted = blob->minor; +break ; + } + } + +/* make sure the list is ordered as expected */ +if (IS_ENABLED (CONFIG_DRM_I915_SELFTEST )) { +for (i =1 ; i <ARRAY_SIZE (fw_blobs); i++) { +if (fw_blobs[i].p < fw_blobs[i -1 ].p) +continue ; + +if (fw_blobs[i].p == fw_blobs[i -1 ].p && + fw_blobs[i].first_rev < fw_blobs[i -1 ].first_rev)
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c line 133
Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +10
-0+continue ; + +pr_err ("invalid FW blob order: %s r%u comes before %s r%u\n" , +intel_platform_name (fw_blobs[i -1 ].p), + fw_blobs[i -1 ].first_rev, +intel_platform_name (fw_blobs[i].p), + fw_blobs[i].first_rev); + + uc_fw->path =NULL ; + uc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_SUPPORTED ;
if we reorder this selftest with actual search then maybe we can skip resetting path (btw, major/minor are untouched) and return
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
Quoted 1 line
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +1
-0+return ;
maybe for full selftest we should scan whole table instead of returning on first mismatch ?
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c line 145
Quoted 11 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +11
-0+ } + } +} + +static void +uc_fw_select (struct drm_i915_private *i915,struct intel_uc_fw *uc_fw) +{ +GEM_BUG_ON (uc_fw->fetch_status !=INTEL_UC_FIRMWARE_UNINITIALIZED ); + +if (!HAS_GT_UC (i915)) { + uc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_SUPPORTED ;
maybe we should check this in 'init_early' before calling 'select' function ?
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c line 158
Quoted 13 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +13
-0+return ; + } + + uc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_STARTED ; + +if (unlikely (i915_modparams.guc_firmware_path && + uc_fw->type ==INTEL_UC_FW_TYPE_GUC )) + uc_fw->path = i915_modparams.guc_firmware_path; +else if (unlikely (i915_modparams.huc_firmware_path && + uc_fw->type ==INTEL_UC_FW_TYPE_HUC )) + uc_fw->path = i915_modparams.huc_firmware_path; +else +__uc_fw_select (uc_fw,INTEL_INFO (i915)->platform,INTEL_REVID (i915));
if we don't select anything (no override, no hardcoded path) then we will stay with fetch_status = NOT_STARTED, but I think for such case we should use NOT_SUPPORTED
Quoted 13 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +4
-0+} + +/** +* intel_uc_fw_init_early - initialize the uC object and select the firmware
+ * @i915: device private
+ * @uc_fw: uC firmware
+ * @type: type of uC
+ *
+ * Initialize the state of our uC object and relevant tracking and select the
+ * firmware to fetch and load.
+ */
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c line 172
Quoted 3 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +3
-0+void intel_uc_fw_init_early (struct drm_i915_private *i915, +struct intel_uc_fw *uc_fw, +enum intel_uc_fw_type type)
void intel_uc_fw_init_early(
struct intel_uc_fw *uc_fw,
enum intel_uc_fw_type type,
struct drm_i915_private *i915)
to use correct object/subject ordering
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c line 185
Quoted 13 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +13
-0+{ +/* +* we use FIRMWARE_UNINITIALIZED to detect checks against fetch_status +* before we're looked at the HW caps to see if we have uc support +*/ +BUILD_BUG_ON (INTEL_UC_FIRMWARE_UNINITIALIZED ); + + uc_fw->path =NULL ; + uc_fw->fetch_status =INTEL_UC_FIRMWARE_UNINITIALIZED ; + uc_fw->load_status =INTEL_UC_FIRMWARE_NOT_STARTED ; + uc_fw->type = type; + +uc_fw_select (i915, uc_fw);
maybe:
BUILD_BUG_ON(INTEL_UC_FIRMWARE_UNINITIALIZED); GEM_BUG_ON(uc_fw->fetch_status); GEM_BUG_ON(uc_fw->load_status); GEM_BUG_ON(uc_fw->path); uc_fw->type = type; if (HAS_GT_UC(i915) && !__uc_fw_override(uc_fw)) __uc_fw_auto_select(uc_fw, INTEL_INFO(i915)->platform,
INTEL_REVID(i915));
if (uc_fw->path) {
uc_fw->fetch_status = INTEL_UC_FIRMWARE_NOT_STARTED;
uc_fw->load_status = INTEL_UC_FIRMWARE_NOT_STARTED;
} else {
uc_fw->fetch_status = INTEL_UC_FIRMWARE_NOT_SUPPORTED;
uc_fw->load_status = INTEL_UC_FIRMWARE_NOT_SUPPORTED;
}Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +2
-0+} +/** * intel_uc_fw_fetch - fetch uC firmware * drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +0
-0
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h enum intel_uc_fw_status { · line 48
Quoted 7 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +3
-2@@ -44,8 +44,9 @@ enum intel_uc_fw_status { };enum intel_uc_fw_type { -INTEL_UC_FW_TYPE_GUC , -INTEL_UC_FW_TYPE_HUC +INTEL_UC_FW_TYPE_GUC =0 , +INTEL_UC_FW_TYPE_HUC , +INTEL_UC_NUM_TYPES
this is bad idea, as now we have NUM_TYPES as valid fw type #define INTEL_UC_NUM_TYPES 2
Quoted 31 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +2
-17};/* @@ -105,24 +106,9 @@ static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type)return "GuC" ;case INTEL_UC_FW_TYPE_HUC :return "HuC" ; +default : +return "uC" ; } -return "uC" ; -} - -static inline -void intel_uc_fw_init_early (struct intel_uc_fw *uc_fw, -enum intel_uc_fw_type type) -{ -/* -* we use FIRMWARE_UNINITIALIZED to detect checks against fetch_status -* before we're looked at the HW caps to see if we have uc support -*/ -BUILD_BUG_ON (INTEL_UC_FIRMWARE_UNINITIALIZED ); - - uc_fw->path =NULL ; - uc_fw->fetch_status =INTEL_UC_FIRMWARE_UNINITIALIZED ; - uc_fw->load_status =INTEL_UC_FIRMWARE_NOT_STARTED ; - uc_fw->type = type; }static inline bool intel_uc_fw_is_selected (struct intel_uc_fw *uc_fw)@@ -164,7 +150,10 @@ static inline u32 intel_uc_fw_get_upload_size(struct intel_uc_fw *uc_fw)
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h static inline u32 · line 159
Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +4
-1return uc_fw->header_size + uc_fw->ucode_size; } -void intel_uc_fw_fetch (struct drm_i915_private *dev_priv, +void intel_uc_fw_init_early (struct drm_i915_private *i915, +struct intel_uc_fw *uc_fw, +enum intel_uc_fw_type type); +void intel_uc_fw_fetch (struct drm_i915_private *i915,struct intel_uc_fw *uc_fw);void intel_uc_fw_cleanup_fetch (struct intel_uc_fw *uc_fw); int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 2/8] drm/i915/uc: Unify uC FW selection
Quoted 363 lines · Michal Wajdeczko
Quoted 278 lines · Daniele Ceraolo Spurio
Instead of having 2 identical functions for GuC and HuC firmware selection, we can unify the selection logic and just use different lists based on FW type.
Note that the revid is not relevant for current blobs, but the upcoming CML will be identified as CFL rev 5, so by considering the revid we're ready for that.
v2: rework blob list defs (Michal), add order check (Chris), fuse GuC and HuC lists into one.
Signed-off-by Daniele Ceraolo Spurio <[email protected]>Cc Michal Wajdeczko <[email protected]>Cc Anusha Srivatsa <[email protected]>Cc Chris Wilson <[email protected]>---
drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c | 86 +-----------drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c| 88 +----------- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 156 ++++++++++++++++++++++ drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h | 29 ++--4 files changed, 167 insertions(+), 192 deletions(-)drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +1
-85@@ -31,89 +31,6 @@ #include "intel_guc_fw.h" #include "i915_drv.h" -#define __MAKE_GUC_FW_PATH (KEY ) \ - "i915/" \ - __stringify(KEY##_GUC_FW_PREFIX) "_guc_" \ - __stringify(KEY##_GUC_FW_MAJOR) "." \ - __stringify(KEY##_GUC_FW_MINOR) "." \ - __stringify(KEY##_GUC_FW_PATCH) ".bin" - -#define SKL_GUC_FW_PREFIX skl -#define SKL_GUC_FW_MAJOR 33 -#define SKL_GUC_FW_MINOR 0 -#define SKL_GUC_FW_PATCH 0 -#define SKL_GUC_FIRMWARE_PATH __MAKE_GUC_FW_PATH(SKL) -MODULE_FIRMWARE (SKL_GUC_FIRMWARE_PATH ); - -#define BXT_GUC_FW_PREFIX bxt -#define BXT_GUC_FW_MAJOR 33 -#define BXT_GUC_FW_MINOR 0 -#define BXT_GUC_FW_PATCH 0 -#define BXT_GUC_FIRMWARE_PATH __MAKE_GUC_FW_PATH(BXT) -MODULE_FIRMWARE (BXT_GUC_FIRMWARE_PATH ); - -#define KBL_GUC_FW_PREFIX kbl -#define KBL_GUC_FW_MAJOR 33 -#define KBL_GUC_FW_MINOR 0 -#define KBL_GUC_FW_PATCH 0 -#define KBL_GUC_FIRMWARE_PATH __MAKE_GUC_FW_PATH(KBL) -MODULE_FIRMWARE (KBL_GUC_FIRMWARE_PATH ); - -#define GLK_GUC_FW_PREFIX glk -#define GLK_GUC_FW_MAJOR 33 -#define GLK_GUC_FW_MINOR 0 -#define GLK_GUC_FW_PATCH 0 -#define GLK_GUC_FIRMWARE_PATH __MAKE_GUC_FW_PATH(GLK) -MODULE_FIRMWARE (GLK_GUC_FIRMWARE_PATH ); - -#define ICL_GUC_FW_PREFIX icl -#define ICL_GUC_FW_MAJOR 33 -#define ICL_GUC_FW_MINOR 0 -#define ICL_GUC_FW_PATCH 0 -#define ICL_GUC_FIRMWARE_PATH __MAKE_GUC_FW_PATH(ICL) -MODULE_FIRMWARE (ICL_GUC_FIRMWARE_PATH ); - -static void guc_fw_select (struct intel_uc_fw *guc_fw) -{ - struct intel_guc *guc = container_of(guc_fw, struct intel_guc, fw); - struct drm_i915_private *i915 = guc_to_gt(guc)->i915; - - GEM_BUG_ON(guc_fw->type != INTEL_UC_FW_TYPE_GUC); - - if (!HAS_GT_UC(i915)) { - guc_fw->fetch_status = INTEL_UC_FIRMWARE_NOT_SUPPORTED; - return; - } - - guc_fw->fetch_status = INTEL_UC_FIRMWARE_NOT_STARTED; - - if (i915_modparams.guc_firmware_path) { - guc_fw->path = i915_modparams.guc_firmware_path; - guc_fw->major_ver_wanted = 0; - guc_fw->minor_ver_wanted = 0; - } else if (IS_ICELAKE(i915)) { - guc_fw->path = ICL_GUC_FIRMWARE_PATH; - guc_fw->major_ver_wanted = ICL_GUC_FW_MAJOR; - guc_fw->minor_ver_wanted = ICL_GUC_FW_MINOR; - } else if (IS_GEMINILAKE(i915)) { - guc_fw->path = GLK_GUC_FIRMWARE_PATH; - guc_fw->major_ver_wanted = GLK_GUC_FW_MAJOR; - guc_fw->minor_ver_wanted = GLK_GUC_FW_MINOR; - } else if (IS_KABYLAKE(i915) || IS_COFFEELAKE(i915)) { - guc_fw->path = KBL_GUC_FIRMWARE_PATH; - guc_fw->major_ver_wanted = KBL_GUC_FW_MAJOR; - guc_fw->minor_ver_wanted = KBL_GUC_FW_MINOR; - } else if (IS_BROXTON(i915)) { - guc_fw->path = BXT_GUC_FIRMWARE_PATH; - guc_fw->major_ver_wanted = BXT_GUC_FW_MAJOR; - guc_fw->minor_ver_wanted = BXT_GUC_FW_MINOR; - } else if (IS_SKYLAKE(i915)) { - guc_fw->path = SKL_GUC_FIRMWARE_PATH; - guc_fw->major_ver_wanted = SKL_GUC_FW_MAJOR; - guc_fw->minor_ver_wanted = SKL_GUC_FW_MINOR; - } -} - /*** intel_guc_fw_init_early() - initializes GuC firmware struct * @guc: intel_guc struct @@ -124,8 +41,7 @@ void intel_guc_fw_init_early(struct intel_guc *guc) { struct intel_uc_fw *guc_fw = &guc->fw; - intel_uc_fw_init_early(guc_fw, INTEL_UC_FW_TYPE_GUC); - guc_fw_select(guc_fw); + intel_uc_fw_init_early(guc_to_gt(guc)->i915, guc_fw,INTEL_UC_FW_TYPE_GUC ); }static void guc_prepare_xfer (struct intel_guc *guc)drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +1
-87@@ -23,91 +23,6 @@* Note that HuC firmware loading must be done before GuC loading. */ -#define BXT_HUC_FW_MAJOR 01 -#define BXT_HUC_FW_MINOR 8 -#define BXT_BLD_NUM 2893 - -#define SKL_HUC_FW_MAJOR 01 -#define SKL_HUC_FW_MINOR 07 -#define SKL_BLD_NUM 1398 - -#define KBL_HUC_FW_MAJOR 02 -#define KBL_HUC_FW_MINOR 00 -#define KBL_BLD_NUM 1810 - -#define GLK_HUC_FW_MAJOR 03 -#define GLK_HUC_FW_MINOR 01 -#define GLK_BLD_NUM 2893 - -#define ICL_HUC_FW_MAJOR 8 -#define ICL_HUC_FW_MINOR 4 -#define ICL_BLD_NUM 3238 - -#define HUC_FW_PATH (platform, major, minor, bld_num) \ - "i915/" __stringify(platform) "_huc_ver" __stringify(major) "_" \ - __stringify(minor) "_" __stringify(bld_num) ".bin" - -#define I915_SKL_HUC_UCODE HUC_FW_PATH(skl, SKL_HUC_FW_MAJOR, \ - SKL_HUC_FW_MINOR, SKL_BLD_NUM) -MODULE_FIRMWARE (I915_SKL_HUC_UCODE ); - -#define I915_BXT_HUC_UCODE HUC_FW_PATH(bxt, BXT_HUC_FW_MAJOR, \ - BXT_HUC_FW_MINOR, BXT_BLD_NUM) -MODULE_FIRMWARE (I915_BXT_HUC_UCODE ); - -#define I915_KBL_HUC_UCODE HUC_FW_PATH(kbl, KBL_HUC_FW_MAJOR, \ - KBL_HUC_FW_MINOR, KBL_BLD_NUM) -MODULE_FIRMWARE (I915_KBL_HUC_UCODE ); - -#define I915_GLK_HUC_UCODE HUC_FW_PATH(glk, GLK_HUC_FW_MAJOR, \ - GLK_HUC_FW_MINOR, GLK_BLD_NUM) -MODULE_FIRMWARE (I915_GLK_HUC_UCODE ); - -#define I915_ICL_HUC_UCODE HUC_FW_PATH(icl, ICL_HUC_FW_MAJOR, \ - ICL_HUC_FW_MINOR, ICL_BLD_NUM) -MODULE_FIRMWARE (I915_ICL_HUC_UCODE ); - -static void huc_fw_select (struct intel_uc_fw *huc_fw) -{ - struct intel_huc *huc = container_of(huc_fw, struct intel_huc, fw); - struct drm_i915_private *dev_priv = huc_to_gt(huc)->i915; - - GEM_BUG_ON(huc_fw->type != INTEL_UC_FW_TYPE_HUC); - - if (!HAS_GT_UC(dev_priv)) { - huc_fw->fetch_status = INTEL_UC_FIRMWARE_NOT_SUPPORTED; - return; - } - - huc_fw->fetch_status = INTEL_UC_FIRMWARE_NOT_STARTED; - - if (i915_modparams.huc_firmware_path) { - huc_fw->path = i915_modparams.huc_firmware_path; - huc_fw->major_ver_wanted = 0; - huc_fw->minor_ver_wanted = 0; - } else if (IS_SKYLAKE(dev_priv)) { - huc_fw->path = I915_SKL_HUC_UCODE; - huc_fw->major_ver_wanted = SKL_HUC_FW_MAJOR; - huc_fw->minor_ver_wanted = SKL_HUC_FW_MINOR; - } else if (IS_BROXTON(dev_priv)) { - huc_fw->path = I915_BXT_HUC_UCODE; - huc_fw->major_ver_wanted = BXT_HUC_FW_MAJOR; - huc_fw->minor_ver_wanted = BXT_HUC_FW_MINOR; - } else if (IS_KABYLAKE(dev_priv) || IS_COFFEELAKE(dev_priv)) { - huc_fw->path = I915_KBL_HUC_UCODE; - huc_fw->major_ver_wanted = KBL_HUC_FW_MAJOR; - huc_fw->minor_ver_wanted = KBL_HUC_FW_MINOR; - } else if (IS_GEMINILAKE(dev_priv)) { - huc_fw->path = I915_GLK_HUC_UCODE; - huc_fw->major_ver_wanted = GLK_HUC_FW_MAJOR; - huc_fw->minor_ver_wanted = GLK_HUC_FW_MINOR; - } else if (IS_ICELAKE(dev_priv)) { - huc_fw->path = I915_ICL_HUC_UCODE; - huc_fw->major_ver_wanted = ICL_HUC_FW_MAJOR; - huc_fw->minor_ver_wanted = ICL_HUC_FW_MINOR; - } -} - /*** intel_huc_fw_init_early() - initializes HuC firmware struct * @huc: intel_huc struct @@ -118,8 +33,7 @@ void intel_huc_fw_init_early(struct intel_huc *huc) { struct intel_uc_fw *huc_fw = &huc->fw; - intel_uc_fw_init_early(huc_fw, INTEL_UC_FW_TYPE_HUC); - huc_fw_select(huc_fw); + intel_uc_fw_init_early(huc_to_gt(huc)->i915, huc_fw,INTEL_UC_FW_TYPE_HUC ); }static void huc_xfer_rsa (struct intel_huc *huc)drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +10
-0@@ -29,6 +29,162 @@ #include "intel_uc_fw.h" #include "i915_drv.h" +/* +* List of required GuC and HuC binaries per-platform. +* Must be ordered based on platform + revid, from newer to older. +*/ +#define INTEL_UC_FIRMWARE_DEFS (fw_def, guc_def, huc_def) \ + fw_def(ICELAKE, 0, guc_def(icl, 33, 0, 0), huc_def(icl, 8, 4, 3238)) \ + fw_def(COFFEELAKE, 0, guc_def(kbl, 33, 0, 0), huc_def(kbl, 02, 00, 1810)) \ + fw_def(GEMINILAKE, 0, guc_def(glk, 33, 0, 0), huc_def(glk, 03, 01, 2893)) \ + fw_def(KABYLAKE, 0, guc_def(kbl, 33, 0, 0), huc_def(kbl, 02, 00, 1810)) \ + fw_def(BROXTON, 0, guc_def(bxt, 33, 0, 0), huc_def(bxt, 01,8, 2893)) \
+fw_def(SKYLAKE, 0, guc_def(skl, 33, 0, 0), huc_def(skl, 01, 07, 1398))drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +2
-0+ +#define __MAKE_UC_FW_PATH(prefix_, name_, separator_, major_,
minor_,patch_) \
+ "i915/" \
+__stringify(prefix_)name_\
+__stringify(major_)separator_\
+__stringify(minor_)separator_\
+__stringify(patch_)".bin"drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +6
-0+ +#define MAKE_GUC_FW_PATH (prefix_, major_, minor_, patch_) \ + __MAKE_UC_FW_PATH(prefix_, "_guc_", ".", major_, minor_, patch_) + +#define MAKE_HUC_FW_PATH (prefix_, major_, minor_, bld_num_) \ + __MAKE_UC_FW_PATH(prefix_, "_huc_ver", "_", major_, minor_,
bld_num_)drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +7
-0+ +/* All blobs need to be declared via MODULE_FIRMWARE() */ +#define INTEL_UC_MODULE_FW (platform_, revid_, guc_, huc_) \ + MODULE_FIRMWARE(guc_); \ + MODULE_FIRMWARE(huc_); + +INTEL_UC_FIRMWARE_DEFS(INTEL_UC_MODULE_FW, MAKE_GUC_FW_PATH,
MAKE_HUC_FW_PATH)drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +3
-0+ +/* +* The below defs and macros are used to iterate across the list of Quoted 6 lines
blobs. See
+ *__uc_fw_select()below for details.
+ */
+struct__packedintel_uc_fw_blob{
+ u8 major;
+ u8 minor;HuC firmware is using 16 bits for major/minor but I guess we have some time until we get to version 255
Quoted 11 lines
+ const char *path;
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +10
-0+}; + +#define UC_FW_BLOB (major_, minor_, path_) \ + { .major = major_, .minor = minor_, .path = path_ } + +#define GUC_FW_BLOB (prefix_, major_, minor_, patch_) \ + UC_FW_BLOB(major_, minor_, \ + MAKE_GUC_FW_PATH(prefix_, major_, minor_, patch_)) + +#define HUC_FW_BLOB (prefix_, major_, minor_, bld_num_) \drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c line 91
Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +10
-0+ UC_FW_BLOB(major_, minor_, \ + MAKE_HUC_FW_PATH(prefix_, major_, minor_, bld_num_)) + +#define MAKE_FW_LIST (platform_, revid_, guc_, huc_) \ +{ \ + .p = INTEL_##platform_, \ + .first_rev = revid_, \ + .blobs[INTEL_UC_FW_TYPE_GUC] = guc_, \ + .blobs[INTEL_UC_FW_TYPE_HUC] = huc_, \ +},nit: unnamed struct on which above macro operates is defined inside function below - either keep this macro private to the function or move struct definition outside function,
btw, above you've already provided definition for struct
intel_uc_fw_blobQuoted 7 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +3
-0+ +static void +__uc_fw_select(struct intel_uc_fw *uc_fw, enum intel_platform p, u8rev)
+{
+ static const struct__packed{
+ enumintel_platformp;nit: using full "platform" word instead of "p" will not hurt
Quoted 1 line
+ u8
first_rev;nit: maybe just "rev", from comment above we know that this is first one
Quoted 31 lines
+ const struct
intel_uc_fw_blobblobs[INTEL_UC_NUM_TYPES]; + } fw_blobs[] = {
+INTEL_UC_FIRMWARE_DEFS(MAKE_FW_LIST, GUC_FW_BLOB, HUC_FW_BLOB)+ };
+ int i;drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +23
-0+ + for (i = 0; i < ARRAY_SIZE(fw_blobs) && p <= fw_blobs[i].p; i++) { + if (p == fw_blobs[i].p && rev >= fw_blobs[i].first_rev) { + const struct intel_uc_fw_blob *blob = + &fw_blobs[i].blobs[uc_fw->type]; + uc_fw->path = blob->path; + uc_fw->major_ver_wanted = blob->major; + uc_fw->minor_ver_wanted = blob->minor; + break; + } + } + + /* make sure the list is ordered as expected */ + if (IS_ENABLED(CONFIG_DRM_I915_SELFTEST)) { + for (i = 1; i < ARRAY_SIZE(fw_blobs); i++) { + if (fw_blobs[i].p < fw_blobs[i - 1].p) + continue; + + if (fw_blobs[i].p == fw_blobs[i - 1].p && + fw_blobs[i].first_rev < fw_blobs[i - 1].first_rev) + continue; + + pr_err("invalid FW blob order: %s r%u comes before %sr%u\n",
+intel_platform_name(fw_blobs[i - 1].p), + fw_blobs[i - 1].first_rev,
Quoted 9 lines
Quoted 5 lines
+
intel_platform_name(fw_blobs[i].p), + fw_blobs[i].first_rev);
+
+uc_fw->path= NULL;
+uc_fw->fetch_status=INTEL_UC_FIRMWARE_NOT_SUPPORTED;if we reorder this selftest with actual search then maybe we can skip resetting path (btw, major/minor are untouched) and return
Actually better to always scan the whole table (as you mentioned below)
Quoted 29 lines
Quoted 1 line
+ return;
maybe for full selftest we should scan whole table instead of returning on first mismatch ?
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c line 145
Quoted 11 lines
+ }
+ }drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +9
-0+} + +static void +uc_fw_select (struct drm_i915_private *i915,struct intel_uc_fw *uc_fw) +{ + GEM_BUG_ON(uc_fw->fetch_status != INTEL_UC_FIRMWARE_UNINITIALIZED); + + if (!HAS_GT_UC(i915)) { + uc_fw->fetch_status = INTEL_UC_FIRMWARE_NOT_SUPPORTED;maybe we should check this in '
init_early' before calling 'select' function ?Quoted 10 lines
+ return;
+ }drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +8
-0+ + uc_fw->fetch_status = INTEL_UC_FIRMWARE_NOT_STARTED; + + if (unlikely(i915_modparams.guc_firmware_path && + uc_fw->type == INTEL_UC_FW_TYPE_GUC)) + uc_fw->path = i915_modparams.guc_firmware_path; + else if (unlikely(i915_modparams.huc_firmware_path && + uc_fw->type == INTEL_UC_FW_TYPE_HUC))
Quoted 8 lines
Quoted 4 lines
+
uc_fw->path= i915_modparams.huc_firmware_path; + else
+__uc_fw_select(uc_fw, INTEL_INFO(i915)->platform, INTEL_REVID(i915));if we don't select anything (no override, no hardcoded path) then we will stay with
fetch_status=NOT_STARTED, but I think for such case we should useNOT_SUPPORTED
I'm not changing any of the status flow in this patch ;)
Anyway, I agree with you, but we can't do that at the moment as we still need a way to differentiate between no uC HW (NOT_SUPPORTED) and HW available but no FW (NOT_STARTED/SELECTION_DONE && path == NULL) for the error logging in sanitize options. As we've discussed offline, Once we've cleaned up the sanitizing we can make those 2 states converge into one. Alternatively, we can just drop the log difference since the user won't really care why the support is not there and a developer should be able to quickly spot the reason. Thoughts?
Quoted 23 lines
Quoted 9 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +4
-0+} + +/** +* intel_uc_fw_init_early - initialize the uC object and select the firmware
+ * @i915: device private
+ * @uc_fw: uC firmware
+ * @type: type of uCQuoted 8 lines
+ *
+ * Initialize the state of our uC object and relevant tracking and select the
+ * firmware to fetch and load.
+ */
+void intel_uc_fw_init_early(structdrm_i915_private*i915, + structintel_uc_fw*uc_fw,
+ enumintel_uc_fw_typetype)void intel_uc_fw_init_early(
structintel_uc_fw*uc_fw,
enumintel_uc_fw_typetype,
structdrm_i915_private*i915)
Quoted 2 lines
to use correct object/subject ordering
Will flip. I had it like this to match the intel_uc_fw_fetch function.
Quoted 26 lines
Quoted 7 lines
+{
+ /*
+ * we useFIRMWARE_UNINITIALIZEDto detect checks againstfetch_status
+ * before we're looked at the HW caps to see if we have uc support + */
+BUILD_BUG_ON(INTEL_UC_FIRMWARE_UNINITIALIZED);drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c line 185
Quoted 7 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +7
-0+ + uc_fw->path = NULL; + uc_fw->fetch_status = INTEL_UC_FIRMWARE_UNINITIALIZED; + uc_fw->load_status = INTEL_UC_FIRMWARE_NOT_STARTED; + uc_fw->type = type; + + uc_fw_select(i915, uc_fw);maybe:
BUILD_BUG_ON(INTEL_UC_FIRMWARE_UNINITIALIZED);GEM_BUG_ON(uc_fw->fetch_status);GEM_BUG_ON(uc_fw->load_status);GEM_BUG_ON(uc_fw->path);uc_fw->type = type;
if (
HAS_GT_UC(i915)&& !__uc_fw_override(uc_fw))__uc_fw_auto_select(uc_fw, INTEL_INFO(i915)->platform, INTEL_REVID(i915));
Quoted 7 lines
if (
uc_fw->path) {
uc_fw->fetch_status=INTEL_UC_FIRMWARE_NOT_STARTED;uc_fw->load_status=INTEL_UC_FIRMWARE_NOT_STARTED; } else {
uc_fw->fetch_status=INTEL_UC_FIRMWARE_NOT_SUPPORTED;uc_fw->load_status=INTEL_UC_FIRMWARE_NOT_SUPPORTED; }
I can't do it like this for the logging reasons mentioned above, but I can rework it as:
if (!HAS_GT_UC(i915)) {
uc_fw->fetch_status = INTEL_UC_FIRMWARE_NOT_SUPPORTED; return;
}
if(!__uc_fw_override(uc_fw))
__uc_fw_auto_select(uc_fw, INTEL_INFO(i915)->platform, INTEL_REVID(i915));
uc_fw->fetch_status = INTEL_UC_FIRMWARE_NOT_STARTED;
return;
Quoted 12 lines
Quoted 12 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +2
-0+} +/**
*intel_uc_fw_fetch- fetch uC firmware
*drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +0
-0@@ -44,8 +44,9 @@ enum intel_uc_fw_status { };enum intel_uc_fw_type {
Quoted 9 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h enum intel_uc_fw_status { · line 49
Quoted 5 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +3
-2- INTEL_UC_FW_TYPE_GUC, - INTEL_UC_FW_TYPE_HUC + INTEL_UC_FW_TYPE_GUC = 0, + INTEL_UC_FW_TYPE_HUC, + INTEL_UC_NUM_TYPESthis is bad idea, as now we have
NUM_TYPESas valid fw type #defineINTEL_UC_NUM_TYPES2
ok
Daniele
Quoted 34 lines
Quoted 34 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +0
-0};/* @@ -105,24 +106,9 @@ static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type) return "GuC";case
INTEL_UC_FW_TYPE_HUC:
return "HuC";
+ default:
+ return "uC";
}
- return "uC";drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +0
-8-} - -static inline -void intel_uc_fw_init_early (struct intel_uc_fw *uc_fw, - enum intel_uc_fw_type type) -{ - /* -* we use FIRMWARE_UNINITIALIZED to detect checks against
fetch_status
- * before we're looked at the HW caps to see if we have uc support - */
-BUILD_BUG_ON(INTEL_UC_FIRMWARE_UNINITIALIZED);
-
-uc_fw->path= NULL;
-uc_fw->fetch_status=INTEL_UC_FIRMWARE_UNINITIALIZED; -uc_fw->load_status=INTEL_UC_FIRMWARE_NOT_STARTED;
-uc_fw->type= type;
}
static inline boolintel_uc_fw_is_selected(struct intel_uc_fw *uc_fw)drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +0
-0@@ -164,7 +150,10 @@ static inline u32 intel_uc_fw_get_upload_size(struct intel_uc_fw *uc_fw) return uc_fw->header_size + uc_fw->ucode_size; }
Quoted 8 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h static inline u32 intel_uc_fw_get_upload_size(struct intel_uc_fw *uc_fw) · line 159
Quoted 8 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +4
-1-void intel_uc_fw_fetch (struct drm_i915_private *dev_priv, +void intel_uc_fw_init_early (struct drm_i915_private *i915, + struct intel_uc_fw *uc_fw, + enum intel_uc_fw_type type); +void intel_uc_fw_fetch (struct drm_i915_private *i915, struct intel_uc_fw *uc_fw); void intel_uc_fw_cleanup_fetch(struct intel_uc_fw *uc_fw); int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 3/8 drm/i915/uc: Unify uc_fw status tracking
In reply to Daniele Ceraolo SpurioWe currently track fetch and load status separately, but the 2 are actually sequential in the uc lifetime (fetch must complete before we can attempt the load!). Unifying the 2 variables we can better follow the sequential states and improve our trackng of the uC state.
Also, sprinkle some GEM_BUG_ON to make sure we transition correctly between states.
v2: rename states, add the running state (Michal), drop some logs in
the fetch path (Michal, Chris)
--- drivers/gpu/drm/i915/gt/uc/intel_guc.h | 4 +- drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c | 6 +- .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 2 +- drivers/gpu/drm/i915/gt/uc/intel_huc.c | 8 +- drivers/gpu/drm/i915/gt/uc/intel_huc.h | 5 ++ drivers/gpu/drm/i915/gt/uc/intel_uc.c | 10 +-- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 86 +++++++------------ drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h | 58 ++++++++----- 8 files changed, 89 insertions(+), 90 deletions(-)
drivers/gpu/drm/i915/gt/uc/intel_guc.h +2 -2
@@ -169,9 +169,9 @@ int intel_guc_suspend(struct intel_guc *guc);int intel_guc_resume (struct intel_guc *guc);struct i915_vma *intel_guc_allocate_vma (struct intel_guc *guc,u32 size); -static inline bool intel_guc_is_loaded (struct intel_guc *guc) +static inline bool intel_guc_is_running (struct intel_guc *guc) { -return intel_uc_fw_is_loaded (&guc->fw); +return intel_uc_fw_is_running (&guc->fw); }static inline int intel_guc_sanitize (struct intel_guc *guc)
drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +5 -1
@@ -232,5 +232,9 @@ static int guc_fw_xfer(struct intel_uc_fw *guc_fw)*/ int intel_guc_fw_upload (struct intel_guc *guc) { -return intel_uc_fw_upload (&guc->fw, guc_fw_xfer); +int ret =intel_uc_fw_upload (&guc->fw, guc_fw_xfer); +if (!ret) + guc->fw.status =INTEL_UC_FIRMWARE_RUNNING ; + +return ret; }
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +1 -1
@@ -941,7 +941,7 @@ static void __guc_client_disable(struct intel_guc_client *client)* the case, instead of trying (in vain) to communicate with it, let's * just cleanup the doorbell HW and our internal state. */ -if (intel_guc_is_loaded (client->guc)) +if (intel_guc_is_running (client->guc))destroy_doorbell (client);else __fini_doorbell (client);
drivers/gpu/drm/i915/gt/uc/intel_huc.c +5 -3
@@ -117,8 +117,8 @@ int intel_huc_auth(struct intel_huc *huc)struct intel_guc *guc = >->uc.guc;int ret; -if (huc->fw.load_status !=INTEL_UC_FIRMWARE_SUCCESS ) -return -ENOEXEC ; +GEM_BUG_ON (!intel_uc_fw_is_loaded (&huc->fw)); +GEM_BUG_ON (intel_huc_is_authenticated (huc)); ret =intel_guc_auth_huc (guc,intel_guc_ggtt_offset (guc, huc->rsa_data));
@@ -138,10 +138,12 @@ int intel_huc_auth(struct intel_huc *huc) goto fail; } + huc->fw.status =INTEL_UC_FIRMWARE_RUNNING ; +return 0 ; fail: - huc->fw.load_status =INTEL_UC_FIRMWARE_FAIL ; + huc->fw.status =INTEL_UC_FIRMWARE_LOAD_FAIL ;DRM_ERROR ("HuC: Authentication failed %d\n" , ret);return ret;
drivers/gpu/drm/i915/gt/uc/intel_huc.h +5 -0
@@ -56,4 +56,9 @@ static inline int intel_huc_sanitize(struct intel_huc *huc) return 0; } +static inline bool intel_huc_is_authenticated (struct intel_huc *huc) +{ +return intel_uc_fw_is_running (&huc->fw); +} +#endif
drivers/gpu/drm/i915/gt/uc/intel_uc.c +5 -5
@@ -559,7 +559,7 @@ void intel_uc_fini_hw(struct intel_uc *uc) {struct intel_guc *guc = &uc->guc; -if (!intel_guc_is_loaded (guc)) +if (!intel_guc_is_running (guc))return ;GEM_BUG_ON (!intel_uc_fw_supported (&guc->fw));
@@ -581,7 +581,7 @@ void intel_uc_reset_prepare(struct intel_uc *uc) {struct intel_guc *guc = &uc->guc; -if (!intel_guc_is_loaded (guc)) +if (!intel_guc_is_running (guc))return ;guc_stop_communication (guc);
@@ -593,7 +593,7 @@ void intel_uc_runtime_suspend(struct intel_uc *uc)struct intel_guc *guc = &uc->guc;int err; -if (!intel_guc_is_loaded (guc)) +if (!intel_guc_is_running (guc))return ; err =intel_guc_suspend (guc);
@@ -608,7 +608,7 @@ void intel_uc_suspend(struct intel_uc *uc)struct intel_guc *guc = &uc->guc;intel_wakeref_t wakeref; -if (!intel_guc_is_loaded (guc)) +if (!intel_guc_is_running (guc))return ;with_intel_runtime_pm (&uc_to_gt (uc)->i915->runtime_pm, wakeref)
@@ -620,7 +620,7 @@ int intel_uc_resume(struct intel_uc *uc)struct intel_guc *guc = &uc->guc;int err; -if (!intel_guc_is_loaded (guc)) +if (!intel_guc_is_running (guc))return 0 ;guc_enable_communication (guc);
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +29 -57
183 lines not on this page · raw message
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +37 -21
107 lines not on this page · raw message
Signature · 6 lines
2.22.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/8] drm/i915/uc: Unify uc_fw status tracking
Quoted 46 lines · Daniele Ceraolo Spurio
We currently track fetch and load status separately, but the 2 are actually sequential in the uc lifetime (fetch must complete before we can attempt the load!). Unifying the 2 variables we can better follow the sequential states and improve our trackng of the uC state.
Also, sprinkle some
GEM_BUG_ONto make sure we transition correctly between states.v2: rename states, add the running state (Michal), drop some logs in
the fetch path (Michal, Chris)Suggested-by Michal Wajdeczko <[email protected]>Signed-off-by Daniele Ceraolo Spurio <[email protected]>Cc Michal Wajdeczko <[email protected]>Cc Chris Wilson <[email protected]>--- drivers/gpu/drm/i915/gt/uc/intel_guc.h | 4 +- drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c | 6 +- .../gpu/drm/i915/gt/uc/intel_guc_submission.c | 2 +- drivers/gpu/drm/i915/gt/uc/intel_huc.c | 8 +- drivers/gpu/drm/i915/gt/uc/intel_huc.h | 5 ++ drivers/gpu/drm/i915/gt/uc/intel_uc.c | 10 +-- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 86 +++++++------------ drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h | 58 ++++++++----- 8 files changed, 89 insertions(+), 90 deletions(-)drivers/gpu/drm/i915/gt/uc/intel_guc.h +2
-2@@ -169,9 +169,9 @@ int intel_guc_suspend(struct intel_guc *guc);int intel_guc_resume (struct intel_guc *guc);struct i915_vma *intel_guc_allocate_vma (struct intel_guc *guc,u32 size); -static inline bool intel_guc_is_loaded (struct intel_guc *guc) +static inline bool intel_guc_is_running (struct intel_guc *guc) { -return intel_uc_fw_is_loaded (&guc->fw); +return intel_uc_fw_is_running (&guc->fw); }static inline int intel_guc_sanitize (struct intel_guc *guc)drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +0
-0
drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c static int guc_fw_xfer(struct intel_uc_fw *guc_fw) · line 237
Quoted 7 lines
drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +3
-1@@ -232,5 +232,9 @@ static int guc_fw_xfer(struct intel_uc_fw *guc_fw)*/ int intel_guc_fw_upload (struct intel_guc *guc) { -return intel_uc_fw_upload (&guc->fw, guc_fw_xfer); +int ret =intel_uc_fw_upload (&guc->fw, guc_fw_xfer); +if (!ret) + guc->fw.status =INTEL_UC_FIRMWARE_RUNNING ;
we should already know that in guc_fw_xfer/guc_xfer_ucode see below for details
Quoted 216 lines
drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +2
-0+ +return ret; }drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +1
-1@@ -941,7 +941,7 @@ static void __guc_client_disable(structintel_guc_client *client) * the case, instead of trying (in vain) to communicate with it, let's * just cleanup the doorbell HW and our internal state. */ -if (intel_guc_is_loaded (client->guc)) +if (intel_guc_is_running (client->guc))destroy_doorbell (client);else drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +0
-0__fini_doorbell (client);drivers/gpu/drm/i915/gt/uc/intel_huc.c +4
-2@@ -117,8 +117,8 @@ int intel_huc_auth(struct intel_huc *huc)struct intel_guc *guc = >->uc.guc;int ret; -if (huc->fw.load_status !=INTEL_UC_FIRMWARE_SUCCESS ) -return -ENOEXEC ; +GEM_BUG_ON (!intel_uc_fw_is_loaded (&huc->fw)); +GEM_BUG_ON (intel_huc_is_authenticated (huc)); ret =intel_guc_auth_huc (guc,intel_guc_ggtt_offset (guc, huc->rsa_data));@@ -138,10 +138,12 @@ int intel_huc_auth(struct intel_huc *huc) goto fail; } + huc->fw.status =INTEL_UC_FIRMWARE_RUNNING ; +return 0 ;fail:
drivers/gpu/drm/i915/gt/uc/intel_huc.c +1
-1- huc->fw.load_status =INTEL_UC_FIRMWARE_FAIL ; + huc->fw.status =INTEL_UC_FIRMWARE_LOAD_FAIL ;DRM_ERROR("HuC: Authentication failed %d\n", ret);drivers/gpu/drm/i915/gt/uc/intel_huc.c +0
-0return ret;drivers/gpu/drm/i915/gt/uc/intel_huc.h +5
-0@@ -56,4 +56,9 @@ static inline int intel_huc_sanitize(struct intel_huc *huc) return 0; } +static inline bool intel_huc_is_authenticated (struct intel_huc *huc) +{ +return intel_uc_fw_is_running (&huc->fw); +} +#endif drivers/gpu/drm/i915/gt/uc/intel_uc.c +5
-5@@ -559,7 +559,7 @@ void intel_uc_fini_hw(struct intel_uc *uc) {struct intel_guc *guc = &uc->guc; -if (!intel_guc_is_loaded (guc)) +if (!intel_guc_is_running (guc))return ;GEM_BUG_ON (!intel_uc_fw_supported (&guc->fw));@@ -581,7 +581,7 @@ void intel_uc_reset_prepare(struct intel_uc *uc) {struct intel_guc *guc = &uc->guc; -if (!intel_guc_is_loaded (guc)) +if (!intel_guc_is_running (guc))return ;guc_stop_communication (guc);@@ -593,7 +593,7 @@ void intel_uc_runtime_suspend(struct intel_uc *uc)struct intel_guc *guc = &uc->guc;int err; -if (!intel_guc_is_loaded (guc)) +if (!intel_guc_is_running (guc))return ; err =intel_guc_suspend (guc);@@ -608,7 +608,7 @@ void intel_uc_suspend(struct intel_uc *uc)struct intel_guc *guc = &uc->guc;intel_wakeref_t wakeref; -if (!intel_guc_is_loaded (guc)) +if (!intel_guc_is_running (guc))return ;with_intel_runtime_pm (&uc_to_gt (uc)->i915->runtime_pm, wakeref)@@ -620,7 +620,7 @@ int intel_uc_resume(struct intel_uc *uc)struct intel_guc *guc = &uc->guc;int err; -if (!intel_guc_is_loaded (guc)) +if (!intel_guc_is_running (guc))return 0 ;guc_enable_communication (guc);drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +10
-32@@ -130,7 +130,7 @@ __uc_fw_select(struct intel_uc_fw *uc_fw, enum intel_platform p, u8 rev) fw_blobs[i].first_rev); uc_fw->path =NULL ; - uc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_SUPPORTED ; + uc_fw->status =INTEL_UC_FIRMWARE_NOT_SUPPORTED ;return ; } }@@ -139,15 +139,13 @@ __uc_fw_select(struct intel_uc_fw *uc_fw, enum intel_platform p, u8 rev) static void uc_fw_select(struct drm_i915_private *i915, struct intel_uc_fw *uc_fw) { - GEM_BUG_ON(uc_fw->fetch_status != INTEL_UC_FIRMWARE_UNINITIALIZED); + GEM_BUG_ON(uc_fw->status != INTEL_UC_FIRMWARE_UNINITIALIZED);if (!HAS_GT_UC (i915)) { - uc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_SUPPORTED ; + uc_fw->status =INTEL_UC_FIRMWARE_NOT_SUPPORTED ;return ; } - uc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_STARTED ; -if (unlikely (i915_modparams.guc_firmware_path && uc_fw->type ==INTEL_UC_FW_TYPE_GUC )) uc_fw->path = i915_modparams.guc_firmware_path;@@ -156,6 +154,8 @@ uc_fw_select(struct drm_i915_private *i915, struct intel_uc_fw *uc_fw) uc_fw->path = i915_modparams.huc_firmware_path; else __uc_fw_select(uc_fw, INTEL_INFO(i915)->platform, INTEL_REVID(i915)); + + uc_fw->status =INTEL_UC_FIRMWARE_SELECTION_DONE ; }/** @@ -172,14 +172,13 @@ void intel_uc_fw_init_early(struct drm_i915_private *i915, enum intel_uc_fw_type type) {/* -* we use FIRMWARE_UNINITIALIZED to detect checks against fetch_status +* we use FIRMWARE_UNINITIALIZED to detect checks against uc_fw->status * before we're looked at the HW caps to see if we have uc support */ BUILD_BUG_ON (INTEL_UC_FIRMWARE_UNINITIALIZED ); uc_fw->path =NULL ; - uc_fw->fetch_status =INTEL_UC_FIRMWARE_UNINITIALIZED ; - uc_fw->load_status =INTEL_UC_FIRMWARE_NOT_STARTED ; + uc_fw->status =INTEL_UC_FIRMWARE_UNINITIALIZED ; uc_fw->type = type;uc_fw_select (i915, uc_fw);@@ -204,29 +203,11 @@ void intel_uc_fw_fetch(struct drm_i915_private *dev_priv, int err;GEM_BUG_ON (!intel_uc_fw_supported (uc_fw)); - -if (!uc_fw->path) { -dev_info (dev_priv->drm.dev, -"%s: No firmware was defined for %s!\n" , -intel_uc_fw_type_repr (uc_fw->type), -intel_platform_name (INTEL_INFO (dev_priv)->platform)); -return ; - } - -DRM_DEBUG_DRIVER ("%s fw fetch %s\n" , -intel_uc_fw_type_repr (uc_fw->type), uc_fw->path); - - uc_fw->fetch_status =INTEL_UC_FIRMWARE_PENDING ; -DRM_DEBUG_DRIVER ("%s fw fetch %s\n" , -intel_uc_fw_type_repr (uc_fw->type), -intel_uc_fw_status_repr (uc_fw->fetch_status)); +GEM_BUG_ON (!intel_uc_fw_is_selected (uc_fw)); err =request_firmware (&fw, uc_fw->path, &pdev->dev); -if (err) { -DRM_DEBUG_DRIVER ("%s fw request_firmware err=%d\n" , -intel_uc_fw_type_repr (uc_fw->type), err); +if (err) goto fail; - }DRM_DEBUG_DRIVER ("%s fw size %zu ptr %p\n" ,intel_uc_fw_type_repr (uc_fw->type), fw->size, fw);@@ -328,19 +309,13 @@ void intel_uc_fw_fetch(struct drm_i915_private *dev_priv, uc_fw->obj = obj; uc_fw->size = fw->size; - uc_fw->fetch_status =INTEL_UC_FIRMWARE_SUCCESS ; -DRM_DEBUG_DRIVER ("%s fw fetch %s\n" , -intel_uc_fw_type_repr (uc_fw->type), -intel_uc_fw_status_repr (uc_fw->fetch_status)); + uc_fw->status =INTEL_UC_FIRMWARE_AVAILABLE ;release_firmware (fw);return ;fail:
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +1
-4- uc_fw->fetch_status =INTEL_UC_FIRMWARE_FAIL ; -DRM_DEBUG_DRIVER ("%s fw fetch %s\n" , -intel_uc_fw_type_repr (uc_fw->type), -intel_uc_fw_status_repr (uc_fw->fetch_status)); + uc_fw->status =INTEL_UC_FIRMWARE_FETCH_FAIL ;DRM_WARN("%s: Failed to fetch firmware %s (error %d)\n",
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +4
-7intel_uc_fw_type_repr(uc_fw->type), uc_fw->path, err);@@ -396,14 +371,11 @@ int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,DRM_DEBUG_DRIVER ("%s fw load %s\n" ,intel_uc_fw_type_repr (uc_fw->type), uc_fw->path); -if (uc_fw->fetch_status !=INTEL_UC_FIRMWARE_SUCCESS ) -return -ENOEXEC ; - - uc_fw->load_status =INTEL_UC_FIRMWARE_PENDING ; -DRM_DEBUG_DRIVER ("%s fw load %s\n" , -intel_uc_fw_type_repr (uc_fw->type), -intel_uc_fw_status_repr (uc_fw->load_status)); +/* make sure the status was cleared the last time we reset the uc */ +GEM_BUG_ON (intel_uc_fw_is_loaded (uc_fw)); +if (!intel_uc_fw_is_available (uc_fw)) +return -ENOEXEC ;/* Call custom loader */ intel_uc_fw_ggtt_bind (uc_fw); err =xfer (uc_fw);
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c int intel_uc_fw_upload(struct intel_uc_fw *uc_fw, · line 385
Quoted 7 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +1
-4@@ -411,10 +383,9 @@ int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,if (err) goto fail; - uc_fw->load_status =INTEL_UC_FIRMWARE_SUCCESS ; -DRM_DEBUG_DRIVER ("%s fw load %s\n" , -intel_uc_fw_type_repr (uc_fw->type), -intel_uc_fw_status_repr (uc_fw->load_status)); + uc_fw->status =INTEL_UC_FIRMWARE_LOADED ;
maybe we can slightly modify xfer function agreement and use -EINPROGRESS to indicate whether fw is just loaded (HuC) or is already authenticated and running (GuC):
if (!err) uc_fw->status = INTEL_UC_FIRMWARE_RUNNING; else if (err == -EINPROGRESS) uc_fw->status = INTEL_UC_FIRMWARE_LOADED; else goto fail;
Quoted 73 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +2
-0+DRM_DEBUG_DRIVER ("%s fw load completed\n" , +intel_uc_fw_type_repr (uc_fw->type)); DRM_INFO("%s: Loaded firmware %s (version %u.%u)\n", intel_uc_fw_type_repr(uc_fw->type),@@ -424,10 +395,9 @@ int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,return 0 ;fail:
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +3
-4- uc_fw->load_status =INTEL_UC_FIRMWARE_FAIL ; -DRM_DEBUG_DRIVER ("%s fw load %s\n" , -intel_uc_fw_type_repr (uc_fw->type), -intel_uc_fw_status_repr (uc_fw->load_status)); + uc_fw->status =INTEL_UC_FIRMWARE_LOAD_FAIL ; +DRM_DEBUG_DRIVER ("%s fw load failed\n" , +intel_uc_fw_type_repr (uc_fw->type));DRM_WARN("%s: Failed to load firmware %s (error %d)\n",
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +8
-6intel_uc_fw_type_repr(uc_fw->type), uc_fw->path, err);@@ -439,7 +409,10 @@ int intel_uc_fw_init(struct intel_uc_fw *uc_fw) {int err; -if (uc_fw->fetch_status !=INTEL_UC_FIRMWARE_SUCCESS ) +/* this should happen before the load! */ +GEM_BUG_ON (intel_uc_fw_is_loaded (uc_fw)); + +if (!intel_uc_fw_is_available (uc_fw))return -ENOEXEC ; err =i915_gem_object_pin_pages (uc_fw->obj);@@ -452,7 +425,7 @@ int intel_uc_fw_init(struct intel_uc_fw *uc_fw)void intel_uc_fw_fini (struct intel_uc_fw *uc_fw) { -if (uc_fw->fetch_status !=INTEL_UC_FIRMWARE_SUCCESS ) +if (!intel_uc_fw_is_available (uc_fw))return ;i915_gem_object_unpin_pages (uc_fw->obj);@@ -486,7 +459,7 @@ void intel_uc_fw_cleanup_fetch(struct intel_uc_fw *uc_fw)if (obj)i915_gem_object_put (obj); - uc_fw->fetch_status =INTEL_UC_FIRMWARE_NOT_STARTED ; + uc_fw->status =INTEL_UC_FIRMWARE_SELECTION_DONE ; }/** @@ -500,9 +473,8 @@ void intel_uc_fw_dump(const struct intel_uc_fw *uc_fw, struct drm_printer *p) {drm_printf (p,"%s firmware: %s\n" ,intel_uc_fw_type_repr (uc_fw->type), uc_fw->path); -drm_printf (p,"\tstatus: fetch %s, load %s\n" , -intel_uc_fw_status_repr (uc_fw->fetch_status), -intel_uc_fw_status_repr (uc_fw->load_status)); +drm_printf (p,"\tstatus: %s\n" , +intel_uc_fw_status_repr (uc_fw->status)); drm_printf(p, "\tversion: wanted %u.%u, found %u.%u\n", uc_fw->major_ver_wanted, uc_fw->minor_ver_wanted,drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +0
-0uc_fw->major_ver_found, uc_fw->minor_ver_found);drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +0
-0@@ -35,12 +35,14 @@ struct drm_i915_private;#define INTEL_UC_FIRMWARE_URL "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915" enum
intel_uc_fw_status{drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +3
-2-INTEL_UC_FIRMWARE_NOT_SUPPORTED =-2 ,/* no uc HW */ -INTEL_UC_FIRMWARE_FAIL =-1 , +INTEL_UC_FIRMWARE_LOAD_FAIL =-3 , +INTEL_UC_FIRMWARE_FETCH_FAIL =-2 , +INTEL_UC_FIRMWARE_NOT_SUPPORTED =-1 ,/* no uc HW */ INTEL_UC_FIRMWARE_UNINITIALIZED = 0, /* used to catch checks done tooearly */
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +1
-3-INTEL_UC_FIRMWARE_NOT_STARTED =1 , -INTEL_UC_FIRMWARE_PENDING , -INTEL_UC_FIRMWARE_SUCCESS + INTEL_UC_FIRMWARE_SELECTION_DONE, /* selection include the "no FW"
Quoted 1 line
case */
why do you want to keep "No FW" case here ?
when we know that there is no fw, we should not attempt to fetch it. so this is different state than "fw was selected, awaiting fetch"
Quoted 28 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +3
-0+INTEL_UC_FIRMWARE_AVAILABLE ,/* fetch done */ +INTEL_UC_FIRMWARE_LOADED ,/* dma xfer done */ + INTEL_UC_FIRMWARE_RUNNING /* fw init/auth done */ };enum
intel_uc_fw_type{drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +1
-2@@ -57,8 +59,7 @@ struct intel_uc_fw {const char *path;size_t size;struct drm_i915_gem_object *obj; -enum intel_uc_fw_status fetch_status; -enum intel_uc_fw_status load_status; +enum intel_uc_fw_status status;/* * The firmware build process will generate a version header file with major and
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +5
-3@@ -83,18 +84,22 @@ static inlineconst char *intel_uc_fw_status_repr (enum intel_uc_fw_status status) {switch (status) { +case INTEL_UC_FIRMWARE_LOAD_FAIL : +return "LOAD FAIL" ; +case INTEL_UC_FIRMWARE_FETCH_FAIL : +return "FETCH FAIL" ;case INTEL_UC_FIRMWARE_NOT_SUPPORTED : -return "N/A - uc HW not available" ; -case INTEL_UC_FIRMWARE_FAIL : -return "FAIL" ; +return "N/A" ;
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h static inline · line 96
Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +2
-6case INTEL_UC_FIRMWARE_UNINITIALIZED :return "UNINITIALIZED" ; -case INTEL_UC_FIRMWARE_NOT_STARTED : -return "NOT_STARTED" ; -case INTEL_UC_FIRMWARE_PENDING : -return "PENDING" ; -case INTEL_UC_FIRMWARE_SUCCESS : -return "SUCCESS" ; +case INTEL_UC_FIRMWARE_SELECTION_DONE : +return "SELECTION DONE" ;
nit: this is not my favorite, what was wrong with "PENDING" (known, awaiting fetch/load, look it's transient state!) "SELECTED" (shorter, applies to this fw object vs step)
Quoted 28 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +15
-1+case INTEL_UC_FIRMWARE_AVAILABLE : +return "AVAILABLE" ; +case INTEL_UC_FIRMWARE_LOADED : +return "LOADED" ; +case INTEL_UC_FIRMWARE_RUNNING : +return "RUNNING" ; }return "<invalid>" ; }@@ -113,25 +118,36 @@ static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type)static inline bool intel_uc_fw_is_selected (struct intel_uc_fw *uc_fw) { +GEM_BUG_ON (uc_fw->path && uc_fw->status <INTEL_UC_FIRMWARE_SELECTION_DONE );return uc_fw->path !=NULL ; } +static inline bool intel_uc_fw_is_available (struct intel_uc_fw *uc_fw) +{ +return uc_fw->status >=INTEL_UC_FIRMWARE_AVAILABLE ; +} +static inline bool intel_uc_fw_is_loaded (struct intel_uc_fw *uc_fw) { -return uc_fw->load_status ==INTEL_UC_FIRMWARE_SUCCESS ; +return uc_fw->status >=INTEL_UC_FIRMWARE_LOADED ; +} +
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h static inline const char · line 142
Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +4
-2+static inline bool intel_uc_fw_is_running (struct intel_uc_fw *uc_fw) +{ +return uc_fw->status ==INTEL_UC_FIRMWARE_RUNNING ; }static inline bool intel_uc_fw_supported (struct intel_uc_fw *uc_fw) {/* shouldn't call this before checking hw/blob availability */ -GEM_BUG_ON (uc_fw->fetch_status ==INTEL_UC_FIRMWARE_UNINITIALIZED ); -return uc_fw->fetch_status !=INTEL_UC_FIRMWARE_NOT_SUPPORTED ; +GEM_BUG_ON (uc_fw->status ==INTEL_UC_FIRMWARE_UNINITIALIZED );
shouldn't we have this check on all uc_fw_is_xxx() functions ?
Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +2
-1+return uc_fw->status !=INTEL_UC_FIRMWARE_NOT_SUPPORTED ; }static inline void intel_uc_fw_sanitize (struct intel_uc_fw *uc_fw) {if (intel_uc_fw_is_loaded (uc_fw)) - uc_fw->load_status =INTEL_UC_FIRMWARE_PENDING ; + uc_fw->status =INTEL_UC_FIRMWARE_AVAILABLE ; }/**
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h static inline void intel_uc_fw_sanitize(struct · line 166
Quoted 8 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +1
-1@@ -144,7 +160,7 @@ static inline void intel_uc_fw_sanitize(structintel_uc_fw *uc_fw) */ static inline u32 intel_uc_fw_get_upload_size (struct intel_uc_fw *uc_fw) { -if (uc_fw->fetch_status !=INTEL_UC_FIRMWARE_SUCCESS ) +if (!intel_uc_fw_is_available (uc_fw))return 0 ;return uc_fw->header_size + uc_fw->ucode_size;
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/8] drm/i915/uc: Unify uc_fw status tracking
Quoted 289 lines · Michal Wajdeczko
Quoted 45 lines · Daniele Ceraolo Spurio
We currently track fetch and load status separately, but the 2 are actually sequential in the uc lifetime (fetch must complete before we can attempt the load!). Unifying the 2 variables we can better follow the sequential states and improve our trackng of the uC state.
Also, sprinkle some
GEM_BUG_ONto make sure we transition correctly between states.v2: rename states, add the running state (Michal), drop some logs in the fetch path (Michal, Chris)
Suggested-by Michal Wajdeczko <[email protected]>Signed-off-by Daniele Ceraolo Spurio <[email protected]>Cc Michal Wajdeczko <[email protected]>Cc Chris Wilson <[email protected]>---
drivers/gpu/drm/i915/gt/uc/intel_guc.h | 4 +- drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c | 6 +-.../gpu/drm/i915/gt/uc/intel_guc_submission.c| 2 +- drivers/gpu/drm/i915/gt/uc/intel_huc.c | 8 +- drivers/gpu/drm/i915/gt/uc/intel_huc.h | 5 ++ drivers/gpu/drm/i915/gt/uc/intel_uc.c | 10 +-- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 86 +++++++------------ drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h | 58 ++++++++-----8 files changed, 89 insertions(+), 90 deletions(-)drivers/gpu/drm/i915/gt/uc/intel_guc.h +2
-2@@ -169,9 +169,9 @@ int intel_guc_suspend(struct intel_guc *guc); int intel_guc_resume(struct intel_guc *guc); struct i915_vma *intel_guc_allocate_vma(struct intel_guc *guc, u32 size); -static inline bool intel_guc_is_loaded (struct intel_guc *guc) +static inline bool intel_guc_is_running (struct intel_guc *guc) { - return intel_uc_fw_is_loaded(&guc->fw); + return intel_uc_fw_is_running(&guc->fw); }static inline int intel_guc_sanitize (struct intel_guc *guc)drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +0
-0drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c static int guc_fw_xfer(struct intel_uc_fw *guc_fw) · line 237
Quoted 7 lines
drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +3
-1@@ -232,5 +232,9 @@ static int guc_fw_xfer(struct intel_uc_fw *guc_fw)*/ int intel_guc_fw_upload(struct intel_guc *guc) { - return intel_uc_fw_upload(&guc->fw, guc_fw_xfer); + int ret = intel_uc_fw_upload(&guc->fw, guc_fw_xfer); + if (!ret) + guc->fw.status = INTEL_UC_FIRMWARE_RUNNING;we should already know that in guc_fw_xfer/guc_xfer_ucode see below for details
Quoted 219 lines
drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +2
-0+ + return ret; }drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c +1
-1@@ -941,7 +941,7 @@ static void __guc_client_disable(structintel_guc_client *client) * the case, instead of trying (in vain) to communicate with it, let's * just cleanup the doorbell HW and our internal state. */ - if (intel_guc_is_loaded(client->guc)) + if (intel_guc_is_running(client->guc)) destroy_doorbell(client);else
__fini_doorbell(client);drivers/gpu/drm/i915/gt/uc/intel_huc.c +4
-2@@ -117,8 +117,8 @@ int intel_huc_auth(struct intel_huc *huc) struct intel_guc *guc = >->uc.guc; int ret; - if (huc->fw.load_status != INTEL_UC_FIRMWARE_SUCCESS) - return -ENOEXEC; + GEM_BUG_ON(!intel_uc_fw_is_loaded(&huc->fw)); + GEM_BUG_ON(intel_huc_is_authenticated(huc)); ret = intel_guc_auth_huc(guc, intel_guc_ggtt_offset(guc, huc->rsa_data));@@ -138,10 +138,12 @@ int intel_huc_auth(struct intel_huc *huc) goto fail; } + huc->fw.status = INTEL_UC_FIRMWARE_RUNNING; + return 0;fail:
-huc->fw.load_status=INTEL_UC_FIRMWARE_FAIL; +huc->fw.status=INTEL_UC_FIRMWARE_LOAD_FAIL;DRM_ERROR("HuC: Authentication failed %d\n", ret); return ret;drivers/gpu/drm/i915/gt/uc/intel_huc.h +5
-0@@ -56,4 +56,9 @@ static inline int intel_huc_sanitize(struct intel_huc *huc) return 0; } +static inline bool intel_huc_is_authenticated (struct intel_huc *huc) +{ + return intel_uc_fw_is_running(&huc->fw); +} + #endifdrivers/gpu/drm/i915/gt/uc/intel_uc.c +5
-5@@ -559,7 +559,7 @@ void intel_uc_fini_hw(struct intel_uc *uc) { struct intel_guc *guc = &uc->guc; - if (!intel_guc_is_loaded(guc)) + if (!intel_guc_is_running(guc)) return; GEM_BUG_ON(!intel_uc_fw_supported(&guc->fw));@@ -581,7 +581,7 @@ void intel_uc_reset_prepare(struct intel_uc *uc) { struct intel_guc *guc = &uc->guc; - if (!intel_guc_is_loaded(guc)) + if (!intel_guc_is_running(guc)) return; guc_stop_communication(guc);@@ -593,7 +593,7 @@ void intel_uc_runtime_suspend(struct intel_uc *uc) struct intel_guc *guc = &uc->guc; int err; - if (!intel_guc_is_loaded(guc)) + if (!intel_guc_is_running(guc)) return; err = intel_guc_suspend(guc);@@ -608,7 +608,7 @@ void intel_uc_suspend(struct intel_uc *uc) struct intel_guc *guc = &uc->guc; intel_wakeref_t wakeref; - if (!intel_guc_is_loaded(guc)) + if (!intel_guc_is_running(guc)) return; with_intel_runtime_pm(&uc_to_gt(uc)->i915->runtime_pm, wakeref)@@ -620,7 +620,7 @@ int intel_uc_resume(struct intel_uc *uc) struct intel_guc *guc = &uc->guc; int err; - if (!intel_guc_is_loaded(guc)) + if (!intel_guc_is_running(guc)) return 0; guc_enable_communication(guc);drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +1
-1@@ -130,7 +130,7 @@ __uc_fw_select(struct intel_uc_fw *uc_fw, enum intel_platform p, u8 rev) fw_blobs[i].first_rev); uc_fw->path = NULL; - uc_fw->fetch_status = INTEL_UC_FIRMWARE_NOT_SUPPORTED; + uc_fw->status = INTEL_UC_FIRMWARE_NOT_SUPPORTED; return; } }@@ -139,15 +139,13 @@ __uc_fw_select(struct intel_uc_fw *uc_fw, enum intel_platform p, u8 rev)static void
uc_fw_select(structdrm_i915_private*i915, structintel_uc_fw*uc_fw) {
-GEM_BUG_ON(uc_fw->fetch_status != INTEL_UC_FIRMWARE_UNINITIALIZED); +GEM_BUG_ON(uc_fw->status != INTEL_UC_FIRMWARE_UNINITIALIZED); if (!HAS_GT_UC(i915)) {
-uc_fw->fetch_status=INTEL_UC_FIRMWARE_NOT_SUPPORTED; +uc_fw->status=INTEL_UC_FIRMWARE_NOT_SUPPORTED; return;
}
-uc_fw->fetch_status=INTEL_UC_FIRMWARE_NOT_STARTED;
-
if (unlikely(i915_modparams.guc_firmware_path && uc_fw->type == INTEL_UC_FW_TYPE_GUC))uc_fw->path= i915_modparams.guc_firmware_path;drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +0
-0@@ -156,6 +154,8 @@ uc_fw_select(struct drm_i915_private *i915, struct intel_uc_fw *uc_fw) uc_fw->path = i915_modparams.huc_firmware_path;else
__uc_fw_select(uc_fw, INTEL_INFO(i915)->platform, INTEL_REVID(i915)); +
+uc_fw->status=INTEL_UC_FIRMWARE_SELECTION_DONE;
}
/**drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +0
-1@@ -172,14 +172,13 @@ void intel_uc_fw_init_early(struct drm_i915_private *i915, enum intel_uc_fw_type type) { /* -* we use FIRMWARE_UNINITIALIZED to detect checks against
fetch_status
+ * we useFIRMWARE_UNINITIALIZEDto detect checks againstuc_fw->status
* before we're looked at the HW caps to see if we have uc support */
BUILD_BUG_ON(INTEL_UC_FIRMWARE_UNINITIALIZED);uc_fw->path= NULL;
-uc_fw->fetch_status=INTEL_UC_FIRMWARE_UNINITIALIZED; -uc_fw->load_status=INTEL_UC_FIRMWARE_NOT_STARTED;
+uc_fw->status=INTEL_UC_FIRMWARE_UNINITIALIZED;uc_fw->type= type;
uc_fw_select(i915,uc_fw);drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +3
-24@@ -204,29 +203,11 @@ void intel_uc_fw_fetch(struct drm_i915_private *dev_priv, int err; GEM_BUG_ON(!intel_uc_fw_supported(uc_fw)); - - if (!uc_fw->path) { - dev_info(dev_priv->drm.dev, - "%s: No firmware was defined for %s!\n", - intel_uc_fw_type_repr(uc_fw->type), -intel_platform_name (INTEL_INFO (dev_priv)->platform)); - return; - } - - DRM_DEBUG_DRIVER("%s fw fetch %s\n", - intel_uc_fw_type_repr(uc_fw->type), uc_fw->path); - - uc_fw->fetch_status = INTEL_UC_FIRMWARE_PENDING; - DRM_DEBUG_DRIVER("%s fw fetch %s\n", - intel_uc_fw_type_repr(uc_fw->type), - intel_uc_fw_status_repr(uc_fw->fetch_status)); + GEM_BUG_ON(!intel_uc_fw_is_selected(uc_fw)); err = request_firmware(&fw, uc_fw->path, &pdev->dev); - if (err) { - DRM_DEBUG_DRIVER("%s fw request_firmware err=%d\n", - intel_uc_fw_type_repr(uc_fw->type), err); + if (err) goto fail; - } DRM_DEBUG_DRIVER("%s fw size %zu ptr %p\n", intel_uc_fw_type_repr(uc_fw->type), fw->size, fw);@@ -328,19 +309,13 @@ void intel_uc_fw_fetch(struct drm_i915_private *dev_priv, uc_fw->obj = obj; uc_fw->size = fw->size; - uc_fw->fetch_status = INTEL_UC_FIRMWARE_SUCCESS; - DRM_DEBUG_DRIVER("%s fw fetch %s\n", - intel_uc_fw_type_repr(uc_fw->type), - intel_uc_fw_status_repr(uc_fw->fetch_status)); + uc_fw->status = INTEL_UC_FIRMWARE_AVAILABLE; release_firmware(fw); return;fail:
-uc_fw->fetch_status=INTEL_UC_FIRMWARE_FAIL;
- DRM_DEBUG_DRIVER("%s fw fetch %s\n",
-intel_uc_fw_type_repr(uc_fw->type),
-intel_uc_fw_status_repr(uc_fw->fetch_status)); +uc_fw->status=INTEL_UC_FIRMWARE_FETCH_FAIL; DRM_WARN("%s: Failed to fetch firmware %s (error %d)\n",intel_uc_fw_type_repr(uc_fw->type),uc_fw->path, err);drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +1
-7@@ -396,14 +371,11 @@ int intel_uc_fw_upload(struct intel_uc_fw *uc_fw, DRM_DEBUG_DRIVER("%s fw load %s\n", intel_uc_fw_type_repr(uc_fw->type), uc_fw->path); - if (uc_fw->fetch_status != INTEL_UC_FIRMWARE_SUCCESS) - return -ENOEXEC; - - uc_fw->load_status = INTEL_UC_FIRMWARE_PENDING; - DRM_DEBUG_DRIVER("%s fw load %s\n", - intel_uc_fw_type_repr(uc_fw->type), - intel_uc_fw_status_repr(uc_fw->load_status)); + /* make sure the status was cleared the last time we reset theuc */
+ GEM_BUG_ON(intel_uc_fw_is_loaded(uc_fw));
+ if (!intel_uc_fw_is_available(uc_fw))
+ return-ENOEXEC;
/* Call custom loader */
intel_uc_fw_ggtt_bind(uc_fw);
err =xfer(uc_fw);drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c int intel_uc_fw_upload(struct intel_uc_fw *uc_fw, · line 385
Quoted 7 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +1
-4@@ -411,10 +383,9 @@ int intel_uc_fw_upload(struct intel_uc_fw *uc_fw, if (err) goto fail; - uc_fw->load_status = INTEL_UC_FIRMWARE_SUCCESS; - DRM_DEBUG_DRIVER("%s fw load %s\n", - intel_uc_fw_type_repr(uc_fw->type), - intel_uc_fw_status_repr(uc_fw->load_status)); + uc_fw->status = INTEL_UC_FIRMWARE_LOADED;maybe we can slightly modify xfer function agreement and use
-EINPROGRESSto indicate whether fw is just loaded (HuC) or is already authenticated and running (GuC):
Quoted 7 lines
if (!err)
uc_fw->status=INTEL_UC_FIRMWARE_RUNNING; else if (err ==-EINPROGRESS)uc_fw->status=INTEL_UC_FIRMWARE_LOADED; else
goto fail;
I've purposely kept the RUNNING state outside because in patch 8 I move the wait outside the xfer, so the switch to the running state will be done outside of here for both uC. Seemed like less churn to go directly with that.
Quoted 68 lines
Quoted 68 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +2
-0+ DRM_DEBUG_DRIVER("%s fw load completed\n", + intel_uc_fw_type_repr(uc_fw->type)); DRM_INFO("%s: Loaded firmware %s (version %u.%u)\n", intel_uc_fw_type_repr(uc_fw->type),@@ -424,10 +395,9 @@ int intel_uc_fw_upload(struct intel_uc_fw *uc_fw, return 0;fail:
-uc_fw->load_status=INTEL_UC_FIRMWARE_FAIL;
- DRM_DEBUG_DRIVER("%s fw load %s\n",
-intel_uc_fw_type_repr(uc_fw->type),
-intel_uc_fw_status_repr(uc_fw->load_status)); +uc_fw->status=INTEL_UC_FIRMWARE_LOAD_FAIL;
+ DRM_DEBUG_DRIVER("%s fw load failed\n",
+intel_uc_fw_type_repr(uc_fw->type)); DRM_WARN("%s: Failed to load firmware %s (error %d)\n",intel_uc_fw_type_repr(uc_fw->type),uc_fw->path, err);drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +8
-6@@ -439,7 +409,10 @@ int intel_uc_fw_init(struct intel_uc_fw *uc_fw) { int err; - if (uc_fw->fetch_status != INTEL_UC_FIRMWARE_SUCCESS) + /* this should happen before the load! */ + GEM_BUG_ON(intel_uc_fw_is_loaded(uc_fw)); + + if (!intel_uc_fw_is_available(uc_fw)) return -ENOEXEC; err = i915_gem_object_pin_pages(uc_fw->obj);@@ -452,7 +425,7 @@ int intel_uc_fw_init(struct intel_uc_fw *uc_fw)void intel_uc_fw_fini (struct intel_uc_fw *uc_fw) { - if (uc_fw->fetch_status != INTEL_UC_FIRMWARE_SUCCESS) + if (!intel_uc_fw_is_available(uc_fw)) return; i915_gem_object_unpin_pages(uc_fw->obj);@@ -486,7 +459,7 @@ void intel_uc_fw_cleanup_fetch(struct intel_uc_fw *uc_fw) if (obj) i915_gem_object_put(obj); - uc_fw->fetch_status = INTEL_UC_FIRMWARE_NOT_STARTED; + uc_fw->status = INTEL_UC_FIRMWARE_SELECTION_DONE; }/** @@ -500,9 +473,8 @@ void intel_uc_fw_dump(const struct intel_uc_fw *uc_fw, struct drm_printer *p) { drm_printf(p, "%s firmware: %s\n", intel_uc_fw_type_repr(uc_fw->type), uc_fw->path); - drm_printf(p, "\tstatus: fetch %s, load %s\n", - intel_uc_fw_status_repr(uc_fw->fetch_status), - intel_uc_fw_status_repr(uc_fw->load_status)); + drm_printf(p, "\tstatus: %s\n", + intel_uc_fw_status_repr(uc_fw->status)); drm_printf(p, "\tversion: wanted %u.%u, found %u.%u\n", uc_fw->major_ver_wanted, uc_fw->minor_ver_wanted,
uc_fw->major_ver_found,uc_fw->minor_ver_found);drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +3
-2@@ -35,12 +35,14 @@ struct drm_i915_private; #define INTEL_UC_FIRMWARE_URL "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915"enum intel_uc_fw_status { - INTEL_UC_FIRMWARE_NOT_SUPPORTED = -2, /* no uc HW */ - INTEL_UC_FIRMWARE_FAIL = -1, + INTEL_UC_FIRMWARE_LOAD_FAIL = -3, + INTEL_UC_FIRMWARE_FETCH_FAIL = -2, + INTEL_UC_FIRMWARE_NOT_SUPPORTED = -1, /* no uc HW */
INTEL_UC_FIRMWARE_UNINITIALIZED= 0, /* used to catch checks done too early */ -INTEL_UC_FIRMWARE_NOT_STARTED= 1,
Quoted 8 lines
Quoted 4 lines
-
INTEL_UC_FIRMWARE_PENDING,
-INTEL_UC_FIRMWARE_SUCCESS
+INTEL_UC_FIRMWARE_SELECTION_DONE, /* selection include the "no FW" case */why do you want to keep "No FW" case here ?
when we know that there is no fw, we should not attempt to fetch it. so this is different state than "fw was selected, awaiting fetch"
We need a way to differentiate for the logging and I didn't want an extra state since we check fw->path anyway to make sure the fw was actually selected.
Quoted 34 lines
Quoted 34 lines
+
INTEL_UC_FIRMWARE_AVAILABLE, /* fetch done */ +INTEL_UC_FIRMWARE_LOADED, /* dma xfer done */ +INTEL_UC_FIRMWARE_RUNNING/* fw init/auth done */ };
enumintel_uc_fw_type{drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +5
-2@@ -57,8 +59,7 @@ struct intel_uc_fw { const char *path; size_t size; struct drm_i915_gem_object *obj; - enum intel_uc_fw_status fetch_status; - enum intel_uc_fw_status load_status; + enum intel_uc_fw_status status; /** The firmware build process will generate a version header file with major and @@ -83,18 +84,22 @@ static inline const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status) { switch (status) { + case INTEL_UC_FIRMWARE_LOAD_FAIL: + return "LOAD FAIL"; + case INTEL_UC_FIRMWARE_FETCH_FAIL: + return "FETCH FAIL";case
INTEL_UC_FIRMWARE_NOT_SUPPORTED:
- return "N/A - uc HW not available";
- caseINTEL_UC_FIRMWARE_FAIL:
- return "FAIL";
+ return "N/A";
caseINTEL_UC_FIRMWARE_UNINITIALIZED:
return "UNINITIALIZED";
- caseINTEL_UC_FIRMWARE_NOT_STARTED:
- return "NOT_STARTED";
- caseINTEL_UC_FIRMWARE_PENDING:
- return "PENDING";
Quoted 8 lines
Quoted 4 lines
- case
INTEL_UC_FIRMWARE_SUCCESS:
- return "SUCCESS";
+ caseINTEL_UC_FIRMWARE_SELECTION_DONE:
+ return "SELECTION DONE";nit: this is not my favorite, what was wrong with "PENDING" (known, awaiting fetch/load, look it's transient state!) "SELECTED" (shorter, applies to this fw object vs step)
I wanted to highlight the fact that the selection included the "no FW" case, the fw wasn't necessarily "selected". We just know that we've run through the selection code.
Quoted 33 lines
Quoted 33 lines
+ case
INTEL_UC_FIRMWARE_AVAILABLE:
+ return "AVAILABLE";
+ caseINTEL_UC_FIRMWARE_LOADED:
+ return "LOADED";
+ caseINTEL_UC_FIRMWARE_RUNNING:
+ return "RUNNING";
}
return "<invalid>";
}drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +12
-1@@ -113,25 +118,36 @@ static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type)static inline bool intel_uc_fw_is_selected (struct intel_uc_fw *uc_fw) { + GEM_BUG_ON(uc_fw->path && uc_fw->status <INTEL_UC_FIRMWARE_SELECTION_DONE ); return uc_fw->path != NULL; } +static inline bool intel_uc_fw_is_available (struct intel_uc_fw *uc_fw) +{ + return uc_fw->status >= INTEL_UC_FIRMWARE_AVAILABLE; +} + static inline bool intel_uc_fw_is_loaded(struct intel_uc_fw *uc_fw) { - return uc_fw->load_status == INTEL_UC_FIRMWARE_SUCCESS; + return uc_fw->status >= INTEL_UC_FIRMWARE_LOADED; +} + +static inline bool intel_uc_fw_is_running (struct intel_uc_fw *uc_fw) +{ + return uc_fw->status == INTEL_UC_FIRMWARE_RUNNING; }
Quoted 9 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h static inline const char *intel_uc_fw_type_repr(enum intel_uc_fw_type type) · line 143
Quoted 6 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +1
-2static inline bool intel_uc_fw_supported (struct intel_uc_fw *uc_fw) { /* shouldn't call this before checking hw/blob availability */ - GEM_BUG_ON(uc_fw->fetch_status == INTEL_UC_FIRMWARE_UNINITIALIZED); - return uc_fw->fetch_status != INTEL_UC_FIRMWARE_NOT_SUPPORTED; + GEM_BUG_ON(uc_fw->status == INTEL_UC_FIRMWARE_UNINITIALIZED);shouldn't we have this check on all
uc_fw_is_xxx()functions ?
I can add that in.
Daniele
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +2
-1+ return uc_fw->status != INTEL_UC_FIRMWARE_NOT_SUPPORTED; }static inline void intel_uc_fw_sanitize (struct intel_uc_fw *uc_fw) { if (intel_uc_fw_is_loaded(uc_fw)) - uc_fw->load_status = INTEL_UC_FIRMWARE_PENDING; + uc_fw->status = INTEL_UC_FIRMWARE_AVAILABLE; }/** @@ -144,7 +160,7 @@ static inline void intel_uc_fw_sanitize(struct
Quoted 8 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h static inline void intel_uc_fw_sanitize(struct intel_uc_fw *uc_fw) · line 166
Quoted 8 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +1
-1intel_uc_fw *uc_fw) */ static inline u32 intel_uc_fw_get_upload_size(struct intel_uc_fw *uc_fw) { - if (uc_fw->fetch_status != INTEL_UC_FIRMWARE_SUCCESS) + if (!intel_uc_fw_is_available(uc_fw)) return 0; return uc_fw->header_size + uc_fw->ucode_size;
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/8] drm/i915/uc: Unify uc_fw status tracking
Quoted 18 lines · Daniele Ceraolo Spurio
Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c int intel_uc_fw_upload(struct intel_uc_fw *uc_fw, · line 386
Quoted 5 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +1
-4- uc_fw->load_status =INTEL_UC_FIRMWARE_SUCCESS ; -DRM_DEBUG_DRIVER ("%s fw load %s\n" , -intel_uc_fw_type_repr (uc_fw->type), -intel_uc_fw_status_repr (uc_fw->load_status)); + uc_fw->status =INTEL_UC_FIRMWARE_LOADED ;maybe we can slightly modify xfer function agreement and use
-EINPROGRESSto indicate whether fw is just loaded (HuC) or is already authenticated and running (GuC):Quoted 7 lines
if (!err) uc_fw->status = INTEL_UC_FIRMWARE_RUNNING; else if (err == -EINPROGRESS) uc_fw->status = INTEL_UC_FIRMWARE_LOADED; else goto fail;
Quoted 1 line
I've purposely kept the RUNNING state outside because in patch 8 I move the wait outside the xfer, so the switch to the running state will be done outside of here for both uC. Seemed like less churn to go directly with that.
ok, I missed that move in diff 8/8
Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
(quoted diff) +0
-0@@ -35,12 +35,14 @@ struct drm_i915_private; #define INTEL_UC_FIRMWARE_URL"https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915" enum
intel_uc_fw_status{drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +3
-2-INTEL_UC_FIRMWARE_NOT_SUPPORTED =-2 ,/* no uc HW */ -INTEL_UC_FIRMWARE_FAIL =-1 , +INTEL_UC_FIRMWARE_LOAD_FAIL =-3 , +INTEL_UC_FIRMWARE_FETCH_FAIL =-2 , +INTEL_UC_FIRMWARE_NOT_SUPPORTED =-1 ,/* no uc HW */ INTEL_UC_FIRMWARE_UNINITIALIZED = 0, /* used to catch checks donetoo early */
-INTEL_UC_FIRMWARE_NOT_STARTED= 1,Quoted 8 lines
Quoted 4 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +1
-2-INTEL_UC_FIRMWARE_PENDING , -INTEL_UC_FIRMWARE_SUCCESS + INTEL_UC_FIRMWARE_SELECTION_DONE, /* selection include the "noFW" case */
why do you want to keep "No FW" case here ?
when we know that there is no fw, we should not attempt to fetch it. so this is different state than "fw was selected, awaiting fetch"
Quoted 1 line
We need a way to differentiate for the logging and I didn't want an extra state since we check
fw->pathanyway to make sure the fw was actually selected.
But "N/A" state also means that we already pass over init_early step that includes selection, so we don't need to add any extra state.
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +3
-0+INTEL_UC_FIRMWARE_AVAILABLE ,/* fetch done */ +INTEL_UC_FIRMWARE_LOADED ,/* dma xfer done */ + INTEL_UC_FIRMWARE_RUNNING /* fw init/auth done */ };enum
intel_uc_fw_type{drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +1
-2@@ -57,8 +59,7 @@ struct intel_uc_fw {const char *path;size_t size;struct drm_i915_gem_object *obj; -enum intel_uc_fw_status fetch_status; -enum intel_uc_fw_status load_status; +enum intel_uc_fw_status status;/*
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h static inline · line 88
Quoted 8 lines
(quoted diff) +0
-0* The firmware build process will generate a version header filewith major and
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +2
-0@@ -83,18 +84,22 @@ static inlineconst char *intel_uc_fw_status_repr (enum intel_uc_fw_status status) {switch (status) { +case INTEL_UC_FIRMWARE_LOAD_FAIL : +return "LOAD FAIL" ;
sorry for second thoughts, but with these names we could have:
LOADED (user: hurray!) --> NOT_LOADED (user: but we were already loaded?!?)
so maybe plain "FAIL" as this is user facing status ?
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h static inline · line 90
Quoted 2 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +2
-0+case INTEL_UC_FIRMWARE_FETCH_FAIL : +return "FETCH FAIL" ;
same here, "fetch" it's name of our internal step, "MISSING" sounds better imno
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +3
-9case INTEL_UC_FIRMWARE_NOT_SUPPORTED : -return "N/A - uc HW not available" ; -case INTEL_UC_FIRMWARE_FAIL : -return "FAIL" ; +return "N/A" ;case INTEL_UC_FIRMWARE_UNINITIALIZED :return "UNINITIALIZED" ; -case INTEL_UC_FIRMWARE_NOT_STARTED : -return "NOT_STARTED" ; -case INTEL_UC_FIRMWARE_PENDING : -return "PENDING" ; -case INTEL_UC_FIRMWARE_SUCCESS : -return "SUCCESS" ; +case INTEL_UC_FIRMWARE_SELECTION_DONE : +return "SELECTION DONE" ;
Quoted 5 lines
Quoted 3 lines
nit: this is not my favorite, what was wrong with "PENDING" (known, awaiting fetch/load, look it's transient state!) "SELECTED" (shorter, applies to this fw object vs step)
I wanted to highlight the fact that the selection included the "no FW" case, the fw wasn't necessarily "selected". We just know that we've run through the selection code.
but from the user pov this is internal detail, not sure if we should expose that, on other hand, PENDING clearly indicates that we are still going to do something with that firmware (fetch/xfer/auth) until we reach end state.
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h static inline · line 102
Quoted 8 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +6
-0+case INTEL_UC_FIRMWARE_AVAILABLE : +return "AVAILABLE" ; +case INTEL_UC_FIRMWARE_LOADED : +return "LOADED" ; +case INTEL_UC_FIRMWARE_RUNNING : +return "RUNNING" ;
hmm, the difference between LOADED/RUNNING might be unnoticed by the user, as he may also treat LOADED as full success.
so maybe s/LOADED/TRANSFERRED ?
Quoted 3 lines
Quoted 3 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h static inline · line 105
Quoted 3 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +0
-0}return "<invalid>" ; }
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 3/8] drm/i915/uc: Unify uc_fw status tracking
Quoted 45 lines · Michal Wajdeczko
Quoted 18 lines · Daniele Ceraolo Spurio
Quoted 10 lines
Quoted 5 lines
-
uc_fw->load_status=INTEL_UC_FIRMWARE_SUCCESS; - DRM_DEBUG_DRIVER("%s fw load %s\n",
-intel_uc_fw_type_repr(uc_fw->type), -intel_uc_fw_status_repr(uc_fw->load_status)); +uc_fw->status=INTEL_UC_FIRMWARE_LOADED;maybe we can slightly modify xfer function agreement and use
-EINPROGRESSto indicate whether fw is just loaded (HuC) or is already authenticated and running (GuC):Quoted 7 lines
if (!err)
uc_fw->status=INTEL_UC_FIRMWARE_RUNNING; else if (err ==-EINPROGRESS)uc_fw->status=INTEL_UC_FIRMWARE_LOADED; else
goto fail;Quoted 1 line
I've purposely kept the RUNNING state outside because in patch 8 I move the wait outside the xfer, so the switch to the running state will be done outside of here for both uC. Seemed like less churn to go directly with that.
ok, I missed that move in diff 8/8
Quoted 20 lines
Quoted 19 lines
Quoted 9 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +3
-2@@ -35,12 +35,14 @@ struct drm_i915_private; #define INTEL_UC_FIRMWARE_URL "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915"enum intel_uc_fw_status { - INTEL_UC_FIRMWARE_NOT_SUPPORTED = -2, /* no uc HW */ - INTEL_UC_FIRMWARE_FAIL = -1, + INTEL_UC_FIRMWARE_LOAD_FAIL = -3, + INTEL_UC_FIRMWARE_FETCH_FAIL = -2, + INTEL_UC_FIRMWARE_NOT_SUPPORTED = -1, /* no uc HW */Quoted 6 lines
INTEL_UC_FIRMWARE_UNINITIALIZED= 0, /* used to catch checks done too early */ -INTEL_UC_FIRMWARE_NOT_STARTED= 1,
-INTEL_UC_FIRMWARE_PENDING,
-INTEL_UC_FIRMWARE_SUCCESS
+INTEL_UC_FIRMWARE_SELECTION_DONE, /* selection include the "no FW" case */why do you want to keep "No FW" case here ?
when we know that there is no fw, we should not attempt to fetch it. so this is different state than "fw was selected, awaiting fetch"
Quoted 5 lines
Quoted 1 line
We need a way to differentiate for the logging and I didn't want an extra state since we check
fw->pathanyway to make sure the fw was actually selected.But "N/A" state also means that we already pass over
init_earlystep that includes selection, so we don't need to add any extra state.
Yes, but we wouldn't know if N/A was set because we are on a platform with no uC HW or because the FW was not defined. I'm going to drop that distinction in the logs and be done with it, it's quite easy to find out based on the gen anyway (anything gen9+ has GuC/HuC HW)
Quoted 25 lines
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
+
INTEL_UC_FIRMWARE_AVAILABLE, /* fetch done */ +INTEL_UC_FIRMWARE_LOADED, /* dma xfer done */ +INTEL_UC_FIRMWARE_RUNNING/* fw init/auth done */ };
enumintel_uc_fw_type{drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +1
-2@@ -57,8 +59,7 @@ struct intel_uc_fw { const char *path; size_t size; struct drm_i915_gem_object *obj; - enum intel_uc_fw_status fetch_status; - enum intel_uc_fw_status load_status; + enum intel_uc_fw_status status;Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h static inline · line 88
Quoted 8 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +2
-0/** The firmware build process will generate a version header file with major and @@ -83,18 +84,22 @@ static inline const char *intel_uc_fw_status_repr(enum intel_uc_fw_status status) { switch (status) { + case INTEL_UC_FIRMWARE_LOAD_FAIL: + return "LOAD FAIL";sorry for second thoughts, but with these names we could have:
Quoted 4 lines
LOADED (user: hurray!) -->
NOT_LOADED(user: but we were already loaded?!?)so maybe plain "FAIL" as this is user facing status ?
ok
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h static inline · line 90
Quoted 2 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +2
-0+ case INTEL_UC_FIRMWARE_FETCH_FAIL: + return "FETCH FAIL";same here, "fetch" it's name of our internal step, "MISSING" sounds better imno
ok
Quoted 35 lines
Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
case
INTEL_UC_FIRMWARE_NOT_SUPPORTED:
- return "N/A - uc HW not available";
- caseINTEL_UC_FIRMWARE_FAIL:
- return "FAIL";
+ return "N/A";
caseINTEL_UC_FIRMWARE_UNINITIALIZED:
return "UNINITIALIZED";
- caseINTEL_UC_FIRMWARE_NOT_STARTED:
- return "NOT_STARTED";
- caseINTEL_UC_FIRMWARE_PENDING:
- return "PENDING";
- caseINTEL_UC_FIRMWARE_SUCCESS:
- return "SUCCESS";
+ caseINTEL_UC_FIRMWARE_SELECTION_DONE:
+ return "SELECTION DONE";Quoted 5 lines
Quoted 3 lines
nit: this is not my favorite, what was wrong with "PENDING" (known, awaiting fetch/load, look it's transient state!) "SELECTED" (shorter, applies to this fw object vs step)
I wanted to highlight the fact that the selection included the "no FW" case, the fw wasn't necessarily "selected". We just know that we've run through the selection code.
but from the user pov this is internal detail, not sure if we should expose that, on other hand, PENDING clearly indicates that we are still going to do something with that firmware (fetch/xfer/auth) until we reach end state.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
+ case
INTEL_UC_FIRMWARE_AVAILABLE:
+ return "AVAILABLE";
+ caseINTEL_UC_FIRMWARE_LOADED:
+ return "LOADED";
+ caseINTEL_UC_FIRMWARE_RUNNING:
+ return "RUNNING";
Quoted 5 lines
hmm, the difference between LOADED/RUNNING might be unnoticed by the user, as he may also treat LOADED as full success.
so maybe s/LOADED/TRANSFERRED ?
ok
Daniele
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
}
return "<invalid>";
}
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 4/8 drm/i915/uc: Move xfer rsa logic to common function
In reply to Daniele Ceraolo SpurioThe way we copy the RSA is the same for GuC and HuC, so we can move the logic in a common function. this will also make any update needed for local memory easier.
v2: return the number of copied bytes and check it (Chris)
--- drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c | 7 +++---- drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c | 10 +++++----- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 18 ++++++++++++++++++ drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h | 1 + 4 files changed, 27 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +3 -4
@@ -77,13 +77,12 @@ static void guc_prepare_xfer(struct intel_guc *guc)static void guc_xfer_rsa (struct intel_guc *guc) {struct intel_uncore *uncore =guc_to_gt (guc)->uncore; -struct intel_uc_fw *fw = &guc->fw; -struct sg_table *pages = fw->obj->mm.pages;u32 rsa[UOS_RSA_SCRATCH_COUNT ]; +size_t copied;int i; -sg_pcopy_to_buffer (pages->sgl, pages->nents, - rsa,sizeof (rsa), fw->rsa_offset); + copied =intel_uc_fw_copy_rsa (&guc->fw, rsa,sizeof (rsa)); +GEM_BUG_ON (copied <sizeof (rsa));for (i =0 ; i <UOS_RSA_SCRATCH_COUNT ; i++)intel_uncore_write (uncore,UOS_RSA_SCRATCH (i), rsa[i]);
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +5 -5
@@ -38,17 +38,17 @@ void intel_huc_fw_init_early(struct intel_huc *huc)static void huc_xfer_rsa (struct intel_huc *huc) { -struct intel_uc_fw *fw = &huc->fw; -struct sg_table *pages = fw->obj->mm.pages; +size_t copied;/* * HuC firmware image is outside GuC accessible range. * Copy the RSA signature out of the image into * the perma-pinned region set aside for it */ -sg_pcopy_to_buffer (pages->sgl, pages->nents, - huc->rsa_data_vaddr, fw->rsa_size, - fw->rsa_offset); +GEM_BUG_ON (huc->fw.rsa_size > huc->rsa_data->size); + copied =intel_uc_fw_copy_rsa (&huc->fw, huc->rsa_data_vaddr, + huc->rsa_data->size); +GEM_BUG_ON (copied < huc->fw.rsa_size); }static int huc_xfer_ucode (struct intel_huc *huc)
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +18 -0
@@ -462,6 +462,24 @@ void intel_uc_fw_cleanup_fetch(struct intel_uc_fw *uc_fw) uc_fw->status =INTEL_UC_FIRMWARE_SELECTION_DONE ; } +/** +* intel_uc_fw_copy_rsa - copy fw RSA to buffer +* +* @uc_fw: uC firmware +* @dst: dst buffer +* @max_len: max number of bytes to copy +* +* Return: number of copied bytes. +*/ +size_t intel_uc_fw_copy_rsa (struct intel_uc_fw *uc_fw,void *dst,u32 max_len) +{ +struct sg_table *pages = uc_fw->obj->mm.pages; +u32 size =min_t (u32, uc_fw->rsa_size, max_len); + +return sg_pcopy_to_buffer (pages->sgl, pages->nents, + dst, size, uc_fw->rsa_offset); +} +/** * intel_uc_fw_dump - dump information about uC firmware * @uc_fw: uC firmware
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +1 -0
@@ -177,6 +177,7 @@ int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,int intel_uc_fw_init (struct intel_uc_fw *uc_fw);void intel_uc_fw_fini (struct intel_uc_fw *uc_fw);u32 intel_uc_fw_ggtt_offset (struct intel_uc_fw *uc_fw); +size_t intel_uc_fw_copy_rsa (struct intel_uc_fw *uc_fw,void *dst,u32 max_len);void intel_uc_fw_dump (const struct intel_uc_fw *uc_fw,struct drm_printer *p);#endif
Signature · 6 lines
2.22.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 4/8] drm/i915/uc: Move xfer rsa logic to common function
Quoted 8 lines · Daniele Ceraolo Spurio
The way we copy the RSA is the same for GuC and HuC, so we can move the logic in a common function. this will also make any update needed for local memory easier.
v2: return the number of copied bytes and check it (Chris)
Signed-off-by Daniele Ceraolo Spurio <[email protected]>Reviewed-by Chris Wilson <[email protected]> #v1
with small nit below
Quoted 59 lines
--- drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c | 7 +++---- drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c | 10 +++++----- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 18 ++++++++++++++++++ drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h | 1 + 4 files changed, 27 insertions(+), 9 deletions(-)drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +3
-4@@ -77,13 +77,12 @@ static void guc_prepare_xfer(struct intel_guc *guc)static void guc_xfer_rsa (struct intel_guc *guc) {struct intel_uncore *uncore =guc_to_gt (guc)->uncore; -struct intel_uc_fw *fw = &guc->fw; -struct sg_table *pages = fw->obj->mm.pages;u32 rsa[UOS_RSA_SCRATCH_COUNT ]; +size_t copied;int i; -sg_pcopy_to_buffer (pages->sgl, pages->nents, - rsa,sizeof (rsa), fw->rsa_offset); + copied =intel_uc_fw_copy_rsa (&guc->fw, rsa,sizeof (rsa)); +GEM_BUG_ON (copied <sizeof (rsa));for (i =0 ; i <UOS_RSA_SCRATCH_COUNT ; i++)intel_uncore_write (uncore,UOS_RSA_SCRATCH (i), rsa[i]);drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +5
-5@@ -38,17 +38,17 @@ void intel_huc_fw_init_early(struct intel_huc *huc)static void huc_xfer_rsa (struct intel_huc *huc) { -struct intel_uc_fw *fw = &huc->fw; -struct sg_table *pages = fw->obj->mm.pages; +size_t copied;/* * HuC firmware image is outside GuC accessible range. * Copy the RSA signature out of the image into * the perma-pinned region set aside for it */ -sg_pcopy_to_buffer (pages->sgl, pages->nents, - huc->rsa_data_vaddr, fw->rsa_size, - fw->rsa_offset); +GEM_BUG_ON (huc->fw.rsa_size > huc->rsa_data->size); + copied =intel_uc_fw_copy_rsa (&huc->fw, huc->rsa_data_vaddr, + huc->rsa_data->size); +GEM_BUG_ON (copied < huc->fw.rsa_size); }static int huc_xfer_ucode (struct intel_huc *huc)drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +1
-0@@ -462,6 +462,24 @@ void intel_uc_fw_cleanup_fetch(struct intel_uc_fw *uc_fw) uc_fw->status =INTEL_UC_FIRMWARE_SELECTION_DONE ; } +/**
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c void intel_uc_fw_cleanup_fetch(struct intel_uc_fw · line 475
Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +9
-0+* intel_uc_fw_copy_rsa - copy fw RSA to buffer +* +* @uc_fw: uC firmware +* @dst: dst buffer +* @max_len: max number of bytes to copy +* +* Return: number of copied bytes. +*/ +size_t intel_uc_fw_copy_rsa (struct intel_uc_fw *uc_fw,void *dst,u32 max_len)
did you check if maybe inline would generate better code?
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c void intel_uc_fw_cleanup_fetch(struct intel_uc_fw *uc_fw) · line 478
Quoted 4 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +4
-0+{ +struct sg_table *pages = uc_fw->obj->mm.pages; +u32 size =min_t (u32, uc_fw->rsa_size, max_len); +
nit:
GEM_BUG_ON(!uc_fw_is_available(uc_fw));
Quoted 19 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +4
-0+return sg_pcopy_to_buffer (pages->sgl, pages->nents, + dst, size, uc_fw->rsa_offset); +} +/** * intel_uc_fw_dump - dump information about uC firmware * @uc_fw: uC firmware
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +1
-0@@ -177,6 +177,7 @@ int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,int intel_uc_fw_init (struct intel_uc_fw *uc_fw);void intel_uc_fw_fini (struct intel_uc_fw *uc_fw);u32 intel_uc_fw_ggtt_offset (struct intel_uc_fw *uc_fw); +size_t intel_uc_fw_copy_rsa (struct intel_uc_fw *uc_fw,void *dst,u32 max_len);void intel_uc_fw_dump (const struct intel_uc_fw *uc_fw,struct drm_printer *p);
Quoted 1 line
#endif
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 5/8 drm/i915/huc: Copy huc rsa only once
In reply to Daniele Ceraolo SpurioThe binary is perma-pinned and the rsa is not going to change, so copy it only once and not on every load.
v2: onion unwind (Chris)
--- drivers/gpu/drm/i915/gt/uc/intel_huc.c | 27 +++++++++++++++++++---- drivers/gpu/drm/i915/gt/uc/intel_huc.h | 1 - drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c | 17 -------------- 3 files changed, 23 insertions(+), 22 deletions(-)
drivers/gpu/drm/i915/gt/uc/intel_huc.c +23 -4
@@ -50,6 +50,7 @@ static int intel_huc_rsa_data_create(struct intel_huc *huc)struct intel_gt *gt =huc_to_gt (huc);struct intel_guc *guc = >->uc.guc;struct i915_vma *vma; +size_t copied;void *vaddr;/*
@@ -62,6 +63,7 @@ static int intel_huc_rsa_data_create(struct intel_huc *huc)* the authentication since its GGTT offset will be GuC * accessible. */ +GEM_BUG_ON (huc->fw.rsa_size >PAGE_SIZE ); vma =intel_guc_allocate_vma (guc,PAGE_SIZE );if (IS_ERR (vma))return PTR_ERR (vma);
@@ -72,26 +74,43 @@ static int intel_huc_rsa_data_create(struct intel_huc *huc)return PTR_ERR (vaddr); } + copied =intel_uc_fw_copy_rsa (&huc->fw, vaddr, vma->size); +GEM_BUG_ON (copied < huc->fw.rsa_size); + +i915_gem_object_unpin_map (vma->obj); + huc->rsa_data = vma; - huc->rsa_data_vaddr = vaddr;return 0 ; }static void intel_huc_rsa_data_destroy (struct intel_huc *huc) { -i915_vma_unpin_and_release (&huc->rsa_data,I915_VMA_RELEASE_MAP ); +i915_vma_unpin_and_release (&huc->rsa_data,0 ); }int intel_huc_init (struct intel_huc *huc) {int err; - err =intel_huc_rsa_data_create (huc); + err =intel_uc_fw_init (&huc->fw);if (err)return err; -return intel_uc_fw_init (&huc->fw); +/* +* HuC firmware image is outside GuC accessible range. +* Copy the RSA signature out of the image into +* a perma-pinned region set aside for it +*/ + err =intel_huc_rsa_data_create (huc); +if (err) + goto out_fini; + +return 0 ; + +out_fini: +intel_uc_fw_fini (&huc->fw); +return err; }void intel_huc_fini (struct intel_huc *huc)
drivers/gpu/drm/i915/gt/uc/intel_huc.h +0 -1
@@ -35,7 +35,6 @@ struct intel_huc {/* HuC-specific additions */ struct i915_vma *rsa_data; -void *rsa_data_vaddr;struct {i915_reg_t reg;
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +0 -17
@@ -36,21 +36,6 @@ void intel_huc_fw_init_early(struct intel_huc *huc)intel_uc_fw_init_early (huc_to_gt (huc)->i915, huc_fw,INTEL_UC_FW_TYPE_HUC ); } -static void huc_xfer_rsa (struct intel_huc *huc) -{ -size_t copied; - -/* -* HuC firmware image is outside GuC accessible range. -* Copy the RSA signature out of the image into -* the perma-pinned region set aside for it -*/ -GEM_BUG_ON (huc->fw.rsa_size > huc->rsa_data->size); - copied =intel_uc_fw_copy_rsa (&huc->fw, huc->rsa_data_vaddr, - huc->rsa_data->size); -GEM_BUG_ON (copied < huc->fw.rsa_size); -} -static int huc_xfer_ucode (struct intel_huc *huc) {struct intel_uc_fw *huc_fw = &huc->fw;
@@ -110,8 +95,6 @@ static int huc_fw_xfer(struct intel_uc_fw *huc_fw) { struct intel_huc *huc = container_of(huc_fw, struct intel_huc, fw); -huc_xfer_rsa (huc); -return huc_xfer_ucode (huc); }
Signature · 6 lines
2.22.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 5/8] drm/i915/huc: Copy huc rsa only once
Quoted 2 lines · Daniele Ceraolo Spurio
The binary is perma-pinned and the rsa is not going to change, so copy it only once and not on every load.
as this new location is accessible from the GuC, what if GuC (or whoever else) corrupts it ? with stale RSA we will fail to authenticate HuC on subsequent resets.
Quoted 112 lines
v2: onion unwind (Chris)
Signed-off-by Daniele Ceraolo Spurio <[email protected]>Cc Fernando Pacheco <[email protected]>Reviewed-by Chris Wilson <[email protected]> #v1--- drivers/gpu/drm/i915/gt/uc/intel_huc.c | 27 +++++++++++++++++++---- drivers/gpu/drm/i915/gt/uc/intel_huc.h | 1 - drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c | 17 -------------- 3 files changed, 23 insertions(+), 22 deletions(-)drivers/gpu/drm/i915/gt/uc/intel_huc.c +2
-0@@ -50,6 +50,7 @@ static int intel_huc_rsa_data_create(struct intel_huc *huc)struct intel_gt *gt =huc_to_gt (huc);struct intel_guc *guc = >->uc.guc;struct i915_vma *vma; +size_t copied;void *vaddr;/* @@ -62,6 +63,7 @@ static int intel_huc_rsa_data_create(struct intel_huc*huc) * the authentication since its GGTT offset will be GuC * accessible. */ +GEM_BUG_ON (huc->fw.rsa_size >PAGE_SIZE ); vma =intel_guc_allocate_vma (guc,PAGE_SIZE );if (IS_ERR (vma))drivers/gpu/drm/i915/gt/uc/intel_huc.c +21
-4return PTR_ERR (vma);@@ -72,26 +74,43 @@ static int intel_huc_rsa_data_create(struct intel_huc *huc)return PTR_ERR (vaddr); } + copied =intel_uc_fw_copy_rsa (&huc->fw, vaddr, vma->size); +GEM_BUG_ON (copied < huc->fw.rsa_size); + +i915_gem_object_unpin_map (vma->obj); + huc->rsa_data = vma; - huc->rsa_data_vaddr = vaddr;return 0 ; }static void intel_huc_rsa_data_destroy (struct intel_huc *huc) { -i915_vma_unpin_and_release (&huc->rsa_data,I915_VMA_RELEASE_MAP ); +i915_vma_unpin_and_release (&huc->rsa_data,0 ); }int intel_huc_init (struct intel_huc *huc) {int err; - err =intel_huc_rsa_data_create (huc); + err =intel_uc_fw_init (&huc->fw);if (err)return err; -return intel_uc_fw_init (&huc->fw); +/* +* HuC firmware image is outside GuC accessible range. +* Copy the RSA signature out of the image into +* a perma-pinned region set aside for it +*/ + err =intel_huc_rsa_data_create (huc); +if (err) + goto out_fini; + +return 0 ; + +out_fini: +intel_uc_fw_fini (&huc->fw); +return err; }void intel_huc_fini (struct intel_huc *huc)drivers/gpu/drm/i915/gt/uc/intel_huc.h +0
-1@@ -35,7 +35,6 @@ struct intel_huc {/* HuC-specific additions */ struct i915_vma *rsa_data; -void *rsa_data_vaddr;struct {i915_reg_t reg;drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +0
-15@@ -36,21 +36,6 @@ void intel_huc_fw_init_early(struct intel_huc *huc)intel_uc_fw_init_early (huc_to_gt (huc)->i915, huc_fw,INTEL_UC_FW_TYPE_HUC ); } -static void huc_xfer_rsa (struct intel_huc *huc) -{ -size_t copied; - -/* -* HuC firmware image is outside GuC accessible range. -* Copy the RSA signature out of the image into -* the perma-pinned region set aside for it -*/ -GEM_BUG_ON (huc->fw.rsa_size > huc->rsa_data->size); - copied =intel_uc_fw_copy_rsa (&huc->fw, huc->rsa_data_vaddr, - huc->rsa_data->size); -GEM_BUG_ON (copied < huc->fw.rsa_size); -} -static int huc_xfer_ucode (struct intel_huc *huc) {struct intel_uc_fw *huc_fw = &huc->fw;
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c static int huc_fw_xfer(struct intel_uc_fw *huc_fw) · line 98
Quoted 6 lines
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +0
-2@@ -110,8 +95,6 @@ static int huc_fw_xfer(struct intel_uc_fw *huc_fw) { struct intel_huc *huc = container_of(huc_fw, struct intel_huc, fw); -huc_xfer_rsa (huc); -return huc_xfer_ucode (huc); }
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 5/8] drm/i915/huc: Copy huc rsa only once
Quoting Michal Wajdeczko (2019-07-24 13:55:23)
Quoted 9 lines
Quoted 2 lines · Daniele Ceraolo Spurio
The binary is perma-pinned and the rsa is not going to change, so copy it only once and not on every load.
as this new location is accessible from the GuC, what if GuC (or whoever else) corrupts it ? with stale RSA we will fail to authenticate HuC on subsequent resets.
Refusing to run after misbehaviour is reasonable, and probably better than running with a successful adversary. We can equally conjecture how to respond to an attack against any other GGTT or even ppGTT object, where we have no idea on the identity of the culprit. That's before we even start on hidden hypervisors and microcontrollers. -Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 6/8 drm/i915/guc: Set GuC init params only once
In reply to Daniele Ceraolo SpurioAll the GuC objects are perma-pinned, so their offset can't change at runtime. We can therefore set (and log!) the parameters only once during boot.
--- drivers/gpu/drm/i915/gt/uc/intel_guc.c | 143 ++++++++++++++----------- drivers/gpu/drm/i915/gt/uc/intel_guc.h | 5 +- drivers/gpu/drm/i915/gt/uc/intel_uc.c | 2 +- 3 files changed, 83 insertions(+), 67 deletions(-)
drivers/gpu/drm/i915/gt/uc/intel_guc.c +78 -65
@@ -126,66 +126,6 @@ static void guc_shared_data_destroy(struct intel_guc *guc)i915_vma_unpin_and_release (&guc->shared_data,I915_VMA_RELEASE_MAP ); } -int intel_guc_init (struct intel_guc *guc) -{ -struct intel_gt *gt =guc_to_gt (guc); -int ret; - - ret =intel_uc_fw_init (&guc->fw); -if (ret) - goto err_fetch; - - ret =guc_shared_data_create (guc); -if (ret) - goto err_fw; -GEM_BUG_ON (!guc->shared_data); - - ret =intel_guc_log_create (&guc->log); -if (ret) - goto err_shared; - - ret =intel_guc_ads_create (guc); -if (ret) - goto err_log; -GEM_BUG_ON (!guc->ads_vma); - - ret =intel_guc_ct_init (&guc->ct); -if (ret) - goto err_ads; - -/* We need to notify the guc whenever we change the GGTT */ -i915_ggtt_enable_guc (gt->ggtt); - -return 0 ; - -err_ads: -intel_guc_ads_destroy (guc); -err_log: -intel_guc_log_destroy (&guc->log); -err_shared: -guc_shared_data_destroy (guc); -err_fw: -intel_uc_fw_fini (&guc->fw); -err_fetch: -intel_uc_fw_cleanup_fetch (&guc->fw); -return ret; -} - -void intel_guc_fini (struct intel_guc *guc) -{ -struct intel_gt *gt =guc_to_gt (guc); - -i915_ggtt_disable_guc (gt->ggtt); - -intel_guc_ct_fini (&guc->ct); - -intel_guc_ads_destroy (guc); -intel_guc_log_destroy (&guc->log); -guc_shared_data_destroy (guc); -intel_uc_fw_fini (&guc->fw); -intel_uc_fw_cleanup_fetch (&guc->fw); -} -static u32 guc_ctl_debug_flags (struct intel_guc *guc) {u32 level =intel_guc_log_get_level (&guc->log);
@@ -281,13 +221,12 @@ static u32 guc_ctl_ads_flags(struct intel_guc *guc)* transfer. These parameters are read by the firmware on startup * and cannot be changed thereafter. */ -void intel_guc_init_params (struct intel_guc *guc) +static void guc_init_params (struct intel_guc *guc) { -struct intel_uncore *uncore =guc_to_gt (guc)->uncore; -u32 params[GUC_CTL_MAX_DWORDS ]; +u32 *params = guc->params;int i; -memset (params,0 ,sizeof (params)); +BUILD_BUG_ON (sizeof (guc->params) !=GUC_CTL_MAX_DWORDS *sizeof (u32)); params[GUC_CTL_CTXINFO ] =guc_ctl_ctxinfo_flags (guc); params[GUC_CTL_LOG_PARAMS ] =guc_ctl_log_params_flags (guc);
@@ -297,6 +236,17 @@ void intel_guc_init_params(struct intel_guc *guc)for (i =0 ; i <GUC_CTL_MAX_DWORDS ; i++)DRM_DEBUG_DRIVER ("param[%2d] = %#x\n" , i, params[i]); +} + +/* +* Initialise the GuC parameter block before starting the firmware +* transfer. These parameters are read by the firmware on startup +* and cannot be changed thereafter. +*/ +void intel_guc_write_params (struct intel_guc *guc) +{ +struct intel_uncore *uncore =guc_to_gt (guc)->uncore; +int i;/* * All SOFT_SCRATCH registers are in FORCEWAKE_BLITTER domain and
@@ -308,11 +258,74 @@ void intel_guc_init_params(struct intel_guc *guc)intel_uncore_write (uncore,SOFT_SCRATCH (0 ),0 );for (i =0 ; i <GUC_CTL_MAX_DWORDS ; i++) -intel_uncore_write (uncore,SOFT_SCRATCH (1 + i), params[i]); +intel_uncore_write (uncore,SOFT_SCRATCH (1 + i), guc->params[i]);intel_uncore_forcewake_put (uncore,FORCEWAKE_BLITTER ); } +int intel_guc_init (struct intel_guc *guc) +{ +struct intel_gt *gt =guc_to_gt (guc); +int ret; + + ret =intel_uc_fw_init (&guc->fw); +if (ret) + goto err_fetch; + + ret =guc_shared_data_create (guc); +if (ret) + goto err_fw; +GEM_BUG_ON (!guc->shared_data); + + ret =intel_guc_log_create (&guc->log); +if (ret) + goto err_shared; + + ret =intel_guc_ads_create (guc); +if (ret) + goto err_log; +GEM_BUG_ON (!guc->ads_vma); + + ret =intel_guc_ct_init (&guc->ct); +if (ret) + goto err_ads; + +/* now that everything is perma-pinned, initialize the parameters */ +guc_init_params (guc); + +/* We need to notify the guc whenever we change the GGTT */ +i915_ggtt_enable_guc (gt->ggtt); + +return 0 ; + +err_ads: +intel_guc_ads_destroy (guc); +err_log: +intel_guc_log_destroy (&guc->log); +err_shared: +guc_shared_data_destroy (guc); +err_fw: +intel_uc_fw_fini (&guc->fw); +err_fetch: +intel_uc_fw_cleanup_fetch (&guc->fw); +return ret; +} + +void intel_guc_fini (struct intel_guc *guc) +{ +struct intel_gt *gt =guc_to_gt (guc); + +i915_ggtt_disable_guc (gt->ggtt); + +intel_guc_ct_fini (&guc->ct); + +intel_guc_ads_destroy (guc); +intel_guc_log_destroy (&guc->log); +guc_shared_data_destroy (guc); +intel_uc_fw_fini (&guc->fw); +intel_uc_fw_cleanup_fetch (&guc->fw); +} +int intel_guc_send_nop (struct intel_guc *guc,const u32 *action,u32 len,u32 *response_buf,u32 response_buf_size) {
drivers/gpu/drm/i915/gt/uc/intel_guc.h +4 -1
@@ -76,6 +76,9 @@ struct intel_guc {/* Cyclic counter mod pagesize */ u32 db_cacheline; +/* Control params for fw initialization */ +u32 params[GUC_CTL_MAX_DWORDS ]; +/* GuC's FW specific registers used in MMIO send */ struct {u32 base;
@@ -152,7 +155,7 @@ static inline u32 intel_guc_ggtt_offset(struct intel_guc *guc,void intel_guc_init_early (struct intel_guc *guc);void intel_guc_init_send_regs (struct intel_guc *guc); -void intel_guc_init_params (struct intel_guc *guc); +void intel_guc_write_params (struct intel_guc *guc);int intel_guc_init (struct intel_guc *guc);void intel_guc_fini (struct intel_guc *guc); int intel_guc_send_nop(struct intel_guc *guc, const u32 *action, u32 len,
drivers/gpu/drm/i915/gt/uc/intel_uc.c +1 -1
@@ -492,7 +492,7 @@ int intel_uc_init_hw(struct intel_uc *uc) }intel_guc_ads_reset (guc); -intel_guc_init_params (guc); +intel_guc_write_params (guc); ret =intel_guc_fw_upload (guc);if (ret ==0 )break ;
Signature · 6 lines
2.22.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 6/8] drm/i915/guc: Set GuC init params only once
Quoting Daniele Ceraolo Spurio (2019-07-24 03:21:51)
Quoted 3 lines
All the GuC objects are perma-pinned, so their offset can't change at runtime. We can therefore set (and log!) the parameters only once during boot.
Much better, but I still have the same information (fw loaded) repeated.
<7>[ 345.432995] [drm:intel_uc_fw_upload [i915]] HuC fw load i915/kbl_huc_ver02_00_1810.bin <7>[ 345.433589] [drm:intel_uc_fw_upload [i915]] HuC fw load completed <6>[ 345.433592] [drm] HuC: Loaded firmware i915/kbl_huc_ver02_00_1810.bin (version 2.0) <7>[ 345.433686] [drm:intel_uc_fw_upload [i915]] GuC fw load i915/kbl_guc_33.0.0.bin <7>[ 345.434046] [drm:intel_uc_fw_upload [i915]] GuC fw load completed <6>[ 345.434048] [drm] GuC: Loaded firmware i915/kbl_guc_33.0.0.bin (version 33.0) <7>[ 345.436578] [drm:intel_guc_fw_upload [i915]] GuC status 0x8002f0ec <6>[ 345.436643] [drm] GuC communication enabled <6>[ 345.436718] i915 0000:00:02.0: GuC firmware version 33.0 <6>[ 345.436719] i915 0000:00:02.0: GuC submission disabled <6>[ 345.436720] i915 0000:00:02.0: HuC enabled <7>[ 345.437910] [drm:intel_uc_fw_upload [i915]] HuC fw load i915/kbl_huc_ver02_00_1810.bin <7>[ 345.438591] [drm:intel_uc_fw_upload [i915]] HuC fw load completed <6>[ 345.438593] [drm] HuC: Loaded firmware i915/kbl_huc_ver02_00_1810.bin (version 2.0) <7>[ 345.438724] [drm:intel_uc_fw_upload [i915]] GuC fw load i915/kbl_guc_33.0.0.bin <7>[ 345.439085] [drm:intel_uc_fw_upload [i915]] GuC fw load completed <6>[ 345.439086] [drm] GuC: Loaded firmware i915/kbl_guc_33.0.0.bin (version 33.0) <7>[ 345.441594] [drm:intel_guc_fw_upload [i915]] GuC status 0x8002f0ec <6>[ 345.441652] [drm] GuC communication enabled <6>[ 345.441727] i915 0000:00:02.0: GuC firmware version 33.0 <6>[ 345.441728] i915 0000:00:02.0: GuC submission disabled <6>[ 345.441729] i915 0000:00:02.0: HuC enabled
Also note that we are repeating at KERN_INFO the same information (fw loaded).
Having the path before loading is reasonable (or rather I expect reasonable object to any request to drop it until error), but the repeated completion information could be whittled down :)
Quoted 11 lines
Suggested-by Chris Wilson <[email protected]>Signed-off-by Daniele Ceraolo Spurio <[email protected]>Cc Chris Wilson <[email protected]>Cc Michal Wajdeczko <[email protected]>---
drivers/gpu/drm/i915/gt/uc/intel_guc.h +0
-0
drivers/gpu/drm/i915/gt/uc/intel_guc.h struct intel_guc { · line 81
Quoted 6 lines
drivers/gpu/drm/i915/gt/uc/intel_guc.h +3
-0@@ -76,6 +76,9 @@ struct intel_guc {/* Cyclic counter mod pagesize */ u32 db_cacheline; +/* Control params for fw initialization */ +u32 params[GUC_CTL_MAX_DWORDS ]; +
Upon init, save parameters to intel_guc. Then write from guc->params instead of the local stack.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 6/8] drm/i915/guc: Set GuC init params only once
Quoting Chris Wilson (2019-07-24 09:19:44)
Quoted 9 lines
Quoting Daniele Ceraolo Spurio (2019-07-24 03:21:51)
Quoted 7 lines
All the GuC objects are perma-pinned, so their offset can't change at runtime. We can therefore set (and log!) the parameters only once during boot.
Suggested-by Chris Wilson <[email protected]>Signed-off-by Daniele Ceraolo Spurio <[email protected]>Cc Chris Wilson <[email protected]>Cc Michal Wajdeczko <[email protected]>Reviewed-by Chris Wilson <[email protected]>
This was standalone and I hope noncontroversial, so pushed. -Chris
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 7/8 drm/i915/uc: Plumb the gt through fw_upload
In reply to Daniele Ceraolo SpurioThe gt is our new central structure for uc-related code, so we can use that instead of jumping back to i915 via the fw object. Since we have it in the upload function it is easy to pass it through the lower levels of the xfer process instead of continuosly jumping via uc_fw->uc->gt, which will also make things a bit cleaner for the next patch.
--- drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c | 35 +++++++++++------------ drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c | 32 ++++++++------------- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 29 ++++++++++--------- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h | 8 ++++-- 4 files changed, 48 insertions(+), 56 deletions(-)
drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +16 -19
@@ -44,10 +44,8 @@ void intel_guc_fw_init_early(struct intel_guc *guc)intel_uc_fw_init_early (guc_to_gt (guc)->i915, guc_fw,INTEL_UC_FW_TYPE_GUC ); } -static void guc_prepare_xfer (struct intel_guc *guc) +static void guc_prepare_xfer (struct intel_uncore *uncore) { -struct intel_gt *gt =guc_to_gt (guc); -struct intel_uncore *uncore = gt->uncore;u32 shim_flags =GUC_DISABLE_SRAM_INIT_TO_ZEROES |GUC_ENABLE_READ_CACHE_LOGIC | GUC_ENABLE_MIA_CACHING |
@@ -58,12 +56,12 @@ static void guc_prepare_xfer(struct intel_guc *guc)/* Must program this register before loading the ucode with DMA */ intel_uncore_write (uncore,GUC_SHIM_CONTROL , shim_flags); -if (IS_GEN9_LP (gt->i915)) +if (IS_GEN9_LP (uncore->i915))intel_uncore_write (uncore,GEN9LP_GT_PM_CONFIG ,GT_DOORBELL_ENABLE );else intel_uncore_write (uncore,GEN9_GT_PM_CONFIG ,GT_DOORBELL_ENABLE ); -if (IS_GEN (gt->i915,9 )) { +if (IS_GEN (uncore->i915,9 )) {/* DOP Clock Gating Enable for GuC clocks */ intel_uncore_rmw (uncore,GEN7_MISCCPCTL ,0 ,GEN8_DOP_CLOCK_GATE_GUC_ENABLE );
@@ -74,14 +72,14 @@ static void guc_prepare_xfer(struct intel_guc *guc) }/* Copy RSA signature from the fw image to HW for verification */ -static void guc_xfer_rsa (struct intel_guc *guc) +static void guc_xfer_rsa (struct intel_uc_fw *guc_fw, +struct intel_uncore *uncore) { -struct intel_uncore *uncore =guc_to_gt (guc)->uncore;u32 rsa[UOS_RSA_SCRATCH_COUNT ];size_t copied;int i; - copied =intel_uc_fw_copy_rsa (&guc->fw, rsa,sizeof (rsa)); + copied =intel_uc_fw_copy_rsa (guc_fw, rsa,sizeof (rsa));GEM_BUG_ON (copied <sizeof (rsa));for (i =0 ; i <UOS_RSA_SCRATCH_COUNT ; i++)
@@ -157,10 +155,10 @@ static int guc_wait_ucode(struct intel_uncore *uncore)* transfer between GTT locations. This functionality is left out of the API * for now as there is no need for it. */ -static int guc_xfer_ucode (struct intel_guc *guc) +static int guc_xfer_ucode (struct intel_uc_fw *guc_fw, +struct intel_gt *gt) { -struct intel_uncore *uncore =guc_to_gt (guc)->uncore; -struct intel_uc_fw *guc_fw = &guc->fw; +struct intel_uncore *uncore = gt->uncore;unsigned long offset;/*
@@ -171,7 +169,7 @@ static int guc_xfer_ucode(struct intel_guc *guc) guc_fw->header_size + guc_fw->ucode_size);/* Set the source address for the new blob */ - offset =intel_uc_fw_ggtt_offset (guc_fw) + guc_fw->header_offset; + offset =intel_uc_fw_ggtt_offset (guc_fw, gt->ggtt) + guc_fw->header_offset;intel_uncore_write (uncore,DMA_ADDR_0_LOW ,lower_32_bits (offset));intel_uncore_write (uncore,DMA_ADDR_0_HIGH ,upper_32_bits (offset) &0xFFFF );
@@ -191,26 +189,25 @@ static int guc_xfer_ucode(struct intel_guc *guc)/* * Load the GuC firmware blob into the MinuteIA. */ -static int guc_fw_xfer (struct intel_uc_fw *guc_fw) +static int guc_fw_xfer (struct intel_uc_fw *guc_fw,struct intel_gt *gt) { - struct intel_guc *guc = container_of(guc_fw, struct intel_guc, fw); -struct intel_uncore *uncore =guc_to_gt (guc)->uncore; +struct intel_uncore *uncore = gt->uncore;int ret;GEM_BUG_ON (guc_fw->type !=INTEL_UC_FW_TYPE_GUC );intel_uncore_forcewake_get (uncore,FORCEWAKE_ALL ); -guc_prepare_xfer (guc); +guc_prepare_xfer (uncore);/* * Note that GuC needs the CSS header plus uKernel code to be copied * by the DMA engine in one operation, whereas the RSA signature is * loaded via MMIO. */ -guc_xfer_rsa (guc); +guc_xfer_rsa (guc_fw, uncore); - ret =guc_xfer_ucode (guc); + ret =guc_xfer_ucode (guc_fw, gt);intel_uncore_forcewake_put (uncore,FORCEWAKE_ALL );
@@ -231,7 +228,7 @@ static int guc_fw_xfer(struct intel_uc_fw *guc_fw)*/ int intel_guc_fw_upload (struct intel_guc *guc) { -int ret =intel_uc_fw_upload (&guc->fw, guc_fw_xfer); +int ret =intel_uc_fw_upload (&guc->fw,guc_to_gt (guc), guc_fw_xfer);if (!ret) guc->fw.status =INTEL_UC_FIRMWARE_RUNNING ;
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +12 -20
@@ -36,10 +36,17 @@ void intel_huc_fw_init_early(struct intel_huc *huc)intel_uc_fw_init_early (huc_to_gt (huc)->i915, huc_fw,INTEL_UC_FW_TYPE_HUC ); } -static int huc_xfer_ucode (struct intel_huc *huc) +/** +* huc_fw_xfer() - DMA's the firmware +* @huc_fw: the firmware descriptor +* +* Transfer the firmware image to RAM for execution by the microcontroller. +* +* Return: 0 on success, non-zero on failure +*/ +static int huc_fw_xfer (struct intel_uc_fw *huc_fw,struct intel_gt *gt) { -struct intel_uc_fw *huc_fw = &huc->fw; -struct intel_uncore *uncore =huc_to_gt (huc)->uncore; +struct intel_uncore *uncore = gt->uncore;unsigned long offset =0 ;u32 size;int ret;
@@ -49,7 +56,7 @@ static int huc_xfer_ucode(struct intel_huc *huc)intel_uncore_forcewake_get (uncore,FORCEWAKE_ALL );/* Set the source address for the uCode */ - offset =intel_uc_fw_ggtt_offset (huc_fw) + + offset =intel_uc_fw_ggtt_offset (huc_fw, gt->ggtt) + huc_fw->header_offset;intel_uncore_write (uncore,DMA_ADDR_0_LOW ,lower_32_bits (offset));
@@ -83,21 +90,6 @@ static int huc_xfer_ucode(struct intel_huc *huc)return ret; } -/** -* huc_fw_xfer() - DMA's the firmware -* @huc_fw: the firmware descriptor -* -* Transfer the firmware image to RAM for execution by the microcontroller. -* -* Return: 0 on success, non-zero on failure -*/ -static int huc_fw_xfer (struct intel_uc_fw *huc_fw) -{ - struct intel_huc *huc = container_of(huc_fw, struct intel_huc, fw); - -return huc_xfer_ucode (huc); -} -/** * intel_huc_fw_upload() - load HuC uCode to device * @huc: intel_huc structure
@@ -112,5 +104,5 @@ static int huc_fw_xfer(struct intel_uc_fw *huc_fw)*/ int intel_huc_fw_upload (struct intel_huc *huc) { -return intel_uc_fw_upload (&huc->fw, huc_fw_xfer); +return intel_uc_fw_upload (&huc->fw,huc_to_gt (huc), huc_fw_xfer); }
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +15 -14
@@ -325,12 +325,13 @@ void intel_uc_fw_fetch(struct drm_i915_private *dev_priv,release_firmware (fw);/* OK even if fw is NULL */ } -static void intel_uc_fw_ggtt_bind (struct intel_uc_fw *uc_fw) +static void intel_uc_fw_ggtt_bind (struct intel_uc_fw *uc_fw, +struct intel_gt *gt) {struct drm_i915_gem_object *obj = uc_fw->obj; -struct i915_ggtt *ggtt = &to_i915 (obj->base.dev)->ggtt; +struct i915_ggtt *ggtt = gt->ggtt;struct i915_vma dummy = { - .node.start =intel_uc_fw_ggtt_offset (uc_fw), + .node.start =intel_uc_fw_ggtt_offset (uc_fw, ggtt), .node.size = obj->base.size, .pages = obj->mm.pages, .vm = &ggtt->vm,
@@ -345,11 +346,12 @@ static void intel_uc_fw_ggtt_bind(struct intel_uc_fw *uc_fw) ggtt->vm.insert_entries (&ggtt->vm, &dummy,I915_CACHE_NONE ,0 ); } -static void intel_uc_fw_ggtt_unbind (struct intel_uc_fw *uc_fw) +static void intel_uc_fw_ggtt_unbind (struct intel_uc_fw *uc_fw, +struct intel_gt *gt) {struct drm_i915_gem_object *obj = uc_fw->obj; -struct i915_ggtt *ggtt = &to_i915 (obj->base.dev)->ggtt; -u64 start =intel_uc_fw_ggtt_offset (uc_fw); +struct i915_ggtt *ggtt = gt->ggtt; +u64 start =intel_uc_fw_ggtt_offset (uc_fw, ggtt); ggtt->vm.clear_range (&ggtt->vm, start, obj->base.size); }
@@ -357,14 +359,15 @@ static void intel_uc_fw_ggtt_unbind(struct intel_uc_fw *uc_fw)/** * intel_uc_fw_upload - load uC firmware using custom loader * @uc_fw: uC firmware +* @gt: the intel_gt structure * @xfer: custom uC firmware loader function * * Loads uC firmware using custom loader and updates internal flags. * * Return: 0 on success, non-zero on failure. */ -int intel_uc_fw_upload (struct intel_uc_fw *uc_fw, -int (*xfer)(struct intel_uc_fw *uc_fw)) +int intel_uc_fw_upload (struct intel_uc_fw *uc_fw,struct intel_gt *gt, +int (*xfer)(struct intel_uc_fw *uc_fw,struct intel_gt *gt)) {int err;
@@ -377,9 +380,9 @@ int intel_uc_fw_upload(struct intel_uc_fw *uc_fw,if (!intel_uc_fw_is_available (uc_fw))return -ENOEXEC ;/* Call custom loader */ -intel_uc_fw_ggtt_bind (uc_fw); - err =xfer (uc_fw); -intel_uc_fw_ggtt_unbind (uc_fw); +intel_uc_fw_ggtt_bind (uc_fw, gt); + err =xfer (uc_fw, gt); +intel_uc_fw_ggtt_unbind (uc_fw, gt);if (err) goto fail;
@@ -431,10 +434,8 @@ void intel_uc_fw_fini(struct intel_uc_fw *uc_fw)i915_gem_object_unpin_pages (uc_fw->obj); } -u32 intel_uc_fw_ggtt_offset (struct intel_uc_fw *uc_fw) +u32 intel_uc_fw_ggtt_offset (struct intel_uc_fw *uc_fw,struct i915_ggtt *ggtt) { -struct drm_i915_private *i915 =to_i915 (uc_fw->obj->base.dev); -struct i915_ggtt *ggtt = &i915->ggtt;struct drm_mm_node *node = &ggtt->uc_fw;GEM_BUG_ON (!node->allocated);
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +5 -3
@@ -30,6 +30,8 @@struct drm_printer ;struct drm_i915_private ; +struct intel_gt ; +struct i915_ggtt ;/* Home of GuC, HuC and DMC firmwares */ #define INTEL_UC_FIRMWARE_URL "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915"
@@ -172,11 +174,11 @@ void intel_uc_fw_init_early(struct drm_i915_private *i915,void intel_uc_fw_fetch (struct drm_i915_private *i915,struct intel_uc_fw *uc_fw);void intel_uc_fw_cleanup_fetch (struct intel_uc_fw *uc_fw); -int intel_uc_fw_upload (struct intel_uc_fw *uc_fw, -int (*xfer)(struct intel_uc_fw *uc_fw)); +int intel_uc_fw_upload (struct intel_uc_fw *uc_fw,struct intel_gt *gt, +int (*xfer)(struct intel_uc_fw *uc_fw,struct intel_gt *gt));int intel_uc_fw_init (struct intel_uc_fw *uc_fw);void intel_uc_fw_fini (struct intel_uc_fw *uc_fw); -u32 intel_uc_fw_ggtt_offset (struct intel_uc_fw *uc_fw); +u32 intel_uc_fw_ggtt_offset (struct intel_uc_fw *uc_fw,struct i915_ggtt *ggtt);size_t intel_uc_fw_copy_rsa (struct intel_uc_fw *uc_fw,void *dst,u32 max_len);void intel_uc_fw_dump (const struct intel_uc_fw *uc_fw,struct drm_printer *p);
Signature · 6 lines
2.22.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 8/8 drm/i915/uc: Unify uC firmware upload
In reply to Daniele Ceraolo SpurioThe way we load the firmwares is the same for both GuC and HuC, the only difference is in the wopcm destination address and the dma flags, so we easily can move the logic to a common function and pass in offset and flags. The only other difference in the uplaod path are some the extra steps that guc does before and after the xfer, but those don't require the guc fw to be pinned in ggtt and can safely be performed before calling the uc_upload function.
Note that this patch re-introduces the dma xfer wait for guc loading that was removed with "drm/i915/guc: Propagate the fw xfer timeout". This is not going to slow us down on a successful load (the dma has to complete before fw init can start), but could slightly increase the timeout in case of a fw init error.
v2: use _fw variants for uncore accesses (Chris), fix guc_fw status on
failed wait.
--- drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c | 107 ++++++---------------- drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c | 57 +----------- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 79 ++++++++++++---- drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h | 4 +- 4 files changed, 92 insertions(+), 155 deletions(-)
drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c +27 -80
@@ -86,13 +86,6 @@ static void guc_xfer_rsa(struct intel_uc_fw *guc_fw,intel_uncore_write (uncore,UOS_RSA_SCRATCH (i), rsa[i]); } -static bool guc_xfer_completed (struct intel_uncore *uncore,u32 *status) -{ -/* Did we complete the xfer? */ - *status =intel_uncore_read (uncore,DMA_CTRL ); -return !(*status &START_DMA ); -} -/* * Read the GuC status register (GUC_STATUS) and store it in the * specified location; then return a boolean indicating whether
@@ -139,65 +132,27 @@ static int guc_wait_ucode(struct intel_uncore *uncore) ret = -ENXIO ; } -if (ret ==0 && !guc_xfer_completed (uncore, &status)) { -DRM_ERROR ("GuC is ready, but the xfer %08x is incomplete\n" , - status); - ret = -ENXIO ; - } -return ret; } -/* -* Transfer the firmware image to RAM for execution by the microcontroller. +/** +* intel_guc_fw_upload() - load GuC uCode to device +* @guc: intel_guc structure * -* Architecturally, the DMA engine is bidirectional, and can potentially even -* transfer between GTT locations. This functionality is left out of the API -* for now as there is no need for it. -*/ -static int guc_xfer_ucode (struct intel_uc_fw *guc_fw, -struct intel_gt *gt) -{ -struct intel_uncore *uncore = gt->uncore; -unsigned long offset; - -/* -* The header plus uCode will be copied to WOPCM via DMA, excluding any -* other components -*/ -intel_uncore_write (uncore,DMA_COPY_SIZE , - guc_fw->header_size + guc_fw->ucode_size); - -/* Set the source address for the new blob */ - offset =intel_uc_fw_ggtt_offset (guc_fw, gt->ggtt) + guc_fw->header_offset; -intel_uncore_write (uncore,DMA_ADDR_0_LOW ,lower_32_bits (offset)); -intel_uncore_write (uncore,DMA_ADDR_0_HIGH ,upper_32_bits (offset) &0xFFFF ); - -/* -* Set the DMA destination. Current uCode expects the code to be -* loaded at 8k; locations below this are used for the stack. -*/ -intel_uncore_write (uncore,DMA_ADDR_1_LOW ,0x2000 ); -intel_uncore_write (uncore,DMA_ADDR_1_HIGH ,DMA_ADDRESS_SPACE_WOPCM ); - -/* Finally start the DMA */ -intel_uncore_write (uncore,DMA_CTRL , -_MASKED_BIT_ENABLE (UOS_MOVE |START_DMA )); - -return guc_wait_ucode (uncore); -} -/* -* Load the GuC firmware blob into the MinuteIA. +* Called from intel_uc_init_hw() during driver load, resume from sleep and +* after a GPU reset. +* +* The firmware image should have already been fetched into memory, so only +* check that fetch succeeded, and then transfer the image to the h/w. +* +* Return: non-zero code on error */ -static int guc_fw_xfer (struct intel_uc_fw *guc_fw,struct intel_gt *gt) +int intel_guc_fw_upload (struct intel_guc *guc) { +struct intel_gt *gt =guc_to_gt (guc);struct intel_uncore *uncore = gt->uncore;int ret; -GEM_BUG_ON (guc_fw->type !=INTEL_UC_FW_TYPE_GUC ); - -intel_uncore_forcewake_get (uncore,FORCEWAKE_ALL ); -guc_prepare_xfer (uncore);/*
@@ -205,32 +160,24 @@ static int guc_fw_xfer(struct intel_uc_fw *guc_fw, struct intel_gt *gt)* by the DMA engine in one operation, whereas the RSA signature is * loaded via MMIO. */ -guc_xfer_rsa (guc_fw, uncore); +guc_xfer_rsa (&guc->fw, uncore); - ret =guc_xfer_ucode (guc_fw, gt); - -intel_uncore_forcewake_put (uncore,FORCEWAKE_ALL ); +/* +* Current uCode expects the code to be loaded at 8k; locations below +* this are used for the stack. +*/ + ret =intel_uc_fw_upload (&guc->fw, gt,0x2000 ,UOS_MOVE ); +if (ret) + goto out; -return ret; -} + ret =guc_wait_ucode (uncore); +if (ret) + goto out; -/** -* intel_guc_fw_upload() - load GuC uCode to device -* @guc: intel_guc structure -* -* Called from intel_uc_init_hw() during driver load, resume from sleep and -* after a GPU reset. -* -* The firmware image should have already been fetched into memory, so only -* check that fetch succeeded, and then transfer the image to the h/w. -* -* Return: non-zero code on error -*/ -int intel_guc_fw_upload (struct intel_guc *guc) -{ -int ret =intel_uc_fw_upload (&guc->fw,guc_to_gt (guc), guc_fw_xfer); -if (!ret) - guc->fw.status =INTEL_UC_FIRMWARE_RUNNING ; + guc->fw.status =INTEL_UC_FIRMWARE_RUNNING ; +return 0 ; +out: + guc->fw.status =INTEL_UC_FIRMWARE_LOAD_FAIL ;return ret; }
drivers/gpu/drm/i915/gt/uc/intel_huc_fw.c +2 -55
67 lines not on this page · raw message
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +62 -17
122 lines not on this page · raw message
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.h +1 -3
@@ -31,7 +31,6 @@struct drm_printer ;struct drm_i915_private ;struct intel_gt ; -struct i915_ggtt ;/* Home of GuC, HuC and DMC firmwares */ #define INTEL_UC_FIRMWARE_URL "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915"
@@ -175,10 +174,9 @@ void intel_uc_fw_fetch(struct drm_i915_private *i915, struct intel_uc_fw *uc_fw);void intel_uc_fw_cleanup_fetch (struct intel_uc_fw *uc_fw);int intel_uc_fw_upload (struct intel_uc_fw *uc_fw,struct intel_gt *gt, -int (*xfer)(struct intel_uc_fw *uc_fw,struct intel_gt *gt)); +u32 wopcm_offset,u32 dma_flags);int intel_uc_fw_init (struct intel_uc_fw *uc_fw);void intel_uc_fw_fini (struct intel_uc_fw *uc_fw); -u32 intel_uc_fw_ggtt_offset (struct intel_uc_fw *uc_fw,struct i915_ggtt *ggtt);size_t intel_uc_fw_copy_rsa (struct intel_uc_fw *uc_fw,void *dst,u32 max_len);void intel_uc_fw_dump (const struct intel_uc_fw *uc_fw,struct drm_printer *p);
Signature · 6 lines
2.22.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 8/8] drm/i915/uc: Unify uC firmware upload
Quoting Daniele Ceraolo Spurio (2019-07-24 03:21:53)
Quoted 25 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +25
-0+static int uc_fw_xfer (struct intel_uc_fw *uc_fw,struct intel_gt *gt, +u32 wopcm_offset,u32 dma_flags) +{ +struct intel_uncore *uncore = gt->uncore; +u64 offset; +int ret; + +intel_uncore_forcewake_get (uncore,FORCEWAKE_ALL ); + +/* Set the source address for the uCode */ + offset =uc_fw_ggtt_offset (uc_fw, gt->ggtt) + uc_fw->header_offset; +GEM_BUG_ON (upper_32_bits (offset) &0xFFFF0000 ); +intel_uncore_write_fw (uncore,DMA_ADDR_0_LOW ,lower_32_bits (offset)); +intel_uncore_write_fw (uncore,DMA_ADDR_0_HIGH ,upper_32_bits (offset)); + +/* Set the DMA destination */ +intel_uncore_write_fw (uncore,DMA_ADDR_1_LOW , wopcm_offset); +intel_uncore_write_fw (uncore,DMA_ADDR_1_HIGH ,DMA_ADDRESS_SPACE_WOPCM ); + +/* +* Set the transfer size. The header plus uCode will be copied to WOPCM +* via DMA, excluding any other components +*/ +intel_uncore_write_fw (uncore,DMA_COPY_SIZE , + uc_fw->header_size + uc_fw->ucode_size);
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c static void intel_uc_fw_ggtt_unbind(struct intel_uc_fw *uc_fw, · line 404
Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c +10
-0+ +/* Start the DMA */ +intel_uncore_write_fw (uncore,DMA_CTRL , +_MASKED_BIT_ENABLE (dma_flags |START_DMA )); + +/* Wait for DMA to finish */ + ret =intel_wait_for_register_fw (uncore,DMA_CTRL ,START_DMA ,0 ,100 ); +if (ret) +DRM_ERROR ("DMA for %s fw failed, err=%d\n" , +intel_uc_fw_type_repr (uc_fw->type), ret);
Note the errno will never be that interesting here, it's a wait. I would suggest including DMA_CTL as that looks like it contains status bits as well as control.
And let's note use DRM_ERROR() if we can help it, and use dev_err() when applicable. (Might be time for a new crusade.)
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.CHECKPATCH: warning for uC fw path unification + misc clean-up (rev2)
In reply to Daniele Ceraolo Spurio== Series Details ==
== Series Details ==
Series: uC fw path unification + misc clean-up (rev2)
URL : https://patchwork.freedesktop.org/series/64039/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip eb041c6704a9 drm/i915/uc: Unify uC platform check e49692394e57 drm/i915/uc: Unify uC FW selection -:244: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses #244: FILE: drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c:36: +#define INTEL_UC_FIRMWARE_DEFS(fw_def, guc_def, huc_def) \ + fw_def(ICELAKE, 0, guc_def(icl, 33, 0, 0), huc_def(icl, 8, 4, 3238)) \ + fw_def(COFFEELAKE, 0, guc_def(kbl, 33, 0, 0), huc_def(kbl, 02, 00, 1810)) \ + fw_def(GEMINILAKE, 0, guc_def(glk, 33, 0, 0), huc_def(glk, 03, 01, 2893)) \ + fw_def(KABYLAKE, 0, guc_def(kbl, 33, 0, 0), huc_def(kbl, 02, 00, 1810)) \ + fw_def(BROXTON, 0, guc_def(bxt, 33, 0, 0), huc_def(bxt, 01, 8, 2893)) \ + fw_def(SKYLAKE, 0, guc_def(skl, 33, 0, 0), huc_def(skl, 01, 07, 1398))
-:244: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'fw_def' - possible side-effects? #244: FILE: drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c:36:
+#define INTEL_UC_FIRMWARE_DEFS(fw_def, guc_def, huc_def) \
+ fw_def(ICELAKE, 0, guc_def(icl, 33, 0, 0), huc_def(icl, 8, 4, 3238)) \
+ fw_def(COFFEELAKE, 0, guc_def(kbl, 33, 0, 0), huc_def(kbl, 02, 00, 1810)) \
+ fw_def(GEMINILAKE, 0, guc_def(glk, 33, 0, 0), huc_def(glk, 03, 01, 2893)) \
+ fw_def(KABYLAKE, 0, guc_def(kbl, 33, 0, 0), huc_def(kbl, 02, 00, 1810)) \ + fw_def(BROXTON, 0, guc_def(bxt, 33, 0, 0), huc_def(bxt, 01, 8, 2893)) \ + fw_def(SKYLAKE, 0, guc_def(skl, 33, 0, 0), huc_def(skl, 01, 07, 1398))
-:244: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'guc_def' - possible side-effects? #244: FILE: drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c:36:
+#define INTEL_UC_FIRMWARE_DEFS(fw_def, guc_def, huc_def) \
+ fw_def(ICELAKE, 0, guc_def(icl, 33, 0, 0), huc_def(icl, 8, 4, 3238)) \
+ fw_def(COFFEELAKE, 0, guc_def(kbl, 33, 0, 0), huc_def(kbl, 02, 00, 1810)) \
+ fw_def(GEMINILAKE, 0, guc_def(glk, 33, 0, 0), huc_def(glk, 03, 01, 2893)) \
+ fw_def(KABYLAKE, 0, guc_def(kbl, 33, 0, 0), huc_def(kbl, 02, 00, 1810)) \ + fw_def(BROXTON, 0, guc_def(bxt, 33, 0, 0), huc_def(bxt, 01, 8, 2893)) \ + fw_def(SKYLAKE, 0, guc_def(skl, 33, 0, 0), huc_def(skl, 01, 07, 1398))
-:244: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'huc_def' - possible side-effects? #244: FILE: drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c:36:
+#define INTEL_UC_FIRMWARE_DEFS(fw_def, guc_def, huc_def) \
+ fw_def(ICELAKE, 0, guc_def(icl, 33, 0, 0), huc_def(icl, 8, 4, 3238)) \
+ fw_def(COFFEELAKE, 0, guc_def(kbl, 33, 0, 0), huc_def(kbl, 02, 00, 1810)) \
+ fw_def(GEMINILAKE, 0, guc_def(glk, 33, 0, 0), huc_def(glk, 03, 01, 2893)) \
+ fw_def(KABYLAKE, 0, guc_def(kbl, 33, 0, 0), huc_def(kbl, 02, 00, 1810)) \ + fw_def(BROXTON, 0, guc_def(bxt, 33, 0, 0), huc_def(bxt, 01, 8, 2893)) \ + fw_def(SKYLAKE, 0, guc_def(skl, 33, 0, 0), huc_def(skl, 01, 07, 1398))
-:252: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'separator_' - possible side-effects? #252: FILE: drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c:44:
+#define __MAKE_UC_FW_PATH(prefix_, name_, separator_, major_, minor_, patch_) \
+ "i915/" \
+ __stringify(prefix_) name_ \
+ __stringify(major_) separator_ \
+ __stringify(minor_) separator_ \
+ __stringify(patch_) ".bin"
-:266: ERROR:MULTISTATEMENT_MACRO_USE_DO_WHILE: Macros with multiple statements should be enclosed in a do - while loop #266: FILE: drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c:58:
+#define INTEL_UC_MODULE_FW(platform_, revid_, guc_, huc_) \
+ MODULE_FIRMWARE(guc_); \
+ MODULE_FIRMWARE(huc_);
-:266: WARNING:TRAILING_SEMICOLON: macros should not use a trailing semicolon #266: FILE: drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c:58:
+#define INTEL_UC_MODULE_FW(platform_, revid_, guc_, huc_) \
+ MODULE_FIRMWARE(guc_); \
+ MODULE_FIRMWARE(huc_);
-:285: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'major_' - possible side-effects? #285: FILE: drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c:77:
+#define GUC_FW_BLOB(prefix_, major_, minor_, patch_) \
+ UC_FW_BLOB(major_, minor_, \
+ MAKE_GUC_FW_PATH(prefix_, major_, minor_, patch_))
-:285: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'minor_' - possible side-effects? #285: FILE: drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c:77:
+#define GUC_FW_BLOB(prefix_, major_, minor_, patch_) \
+ UC_FW_BLOB(major_, minor_, \
+ MAKE_GUC_FW_PATH(prefix_, major_, minor_, patch_))
-:289: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'major_' - possible side-effects? #289: FILE: drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c:81:
+#define HUC_FW_BLOB(prefix_, major_, minor_, bld_num_) \
+ UC_FW_BLOB(major_, minor_, \
+ MAKE_HUC_FW_PATH(prefix_, major_, minor_, bld_num_))
-:289: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'minor_' - possible side-effects? #289: FILE: drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c:81:
+#define HUC_FW_BLOB(prefix_, major_, minor_, bld_num_) \
+ UC_FW_BLOB(major_, minor_, \
+ MAKE_HUC_FW_PATH(prefix_, major_, minor_, bld_num_))
total: 2 errors, 1 warnings, 8 checks, 408 lines checked 0de179e2f693 drm/i915/uc: Unify uc_fw status tracking -:48: WARNING:LINE_SPACING: Missing a blank line after declarations #48: FILE: drivers/gpu/drm/i915/gt/uc/intel_guc_fw.c:236:
+ int ret = intel_uc_fw_upload(&guc->fw, guc_fw_xfer);
+ if (!ret)
total: 0 errors, 1 warnings, 0 checks, 391 lines checked f9e37db54a35 drm/i915/uc: Move xfer rsa logic to common function dbfa2f355568 drm/i915/huc: Copy huc rsa only once be285c278fbb drm/i915/guc: Set GuC init params only once 44723e28e673 drm/i915/uc: Plumb the gt through fw_upload 30835ba789c4 drm/i915/uc: Unify uC firmware upload
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.SPARSE: warning for uC fw path unification + misc clean-up (rev2)
In reply to Daniele Ceraolo Spurio== Series Details ==
== Series Details ==
Series: uC fw path unification + misc clean-up (rev2)
URL : https://patchwork.freedesktop.org/series/64039/
State : warning
== Summary ==
$ dim sparse origin/drm-tip Sparse version: v0.5.2 Commit: drm/i915/uc: Unify uC platform check Okay!
Commit: drm/i915/uc: Unify uC FW selection
Okay!
Commit: drm/i915/uc: Unify uc_fw status tracking
Okay!
Commit: drm/i915/uc: Move xfer rsa logic to common function +drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c:477:20: warning: expression using sizeof(void) +drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c:477:20: warning: expression using sizeof(void)
Commit: drm/i915/huc: Copy huc rsa only once
Okay!
Commit: drm/i915/guc: Set GuC init params only once Okay!
Commit: drm/i915/uc: Plumb the gt through fw_upload Okay!
Commit: drm/i915/uc: Unify uC firmware upload
Okay!
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for uC fw path unification + misc clean-up (rev2)
In reply to Daniele Ceraolo Spurio== Series Details ==
== Series Details ==
Series: uC fw path unification + misc clean-up (rev2)
URL : https://patchwork.freedesktop.org/series/64039/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_6543 -> Patchwork_13731
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13731/
Known issues
------------
Here are the changes found in Patchwork_13731 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@kms_chamelium@common-hpd-after-suspend:
- fi-kbl-7567u: [PASS][1] -> [WARN][2] ([fdo#109380])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6543/fi-kbl-7567u/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13731/fi-kbl-7567u/igt@[email protected]
* igt@kms_chamelium@dp-crc-fast:
- fi-kbl-7500u: [PASS][3] -> [WARN][4] ([fdo#111156])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6543/fi-kbl-7500u/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13731/fi-kbl-7500u/igt@[email protected]
* igt@kms_frontbuffer_tracking@basic:
- fi-icl-u2: [PASS][5] -> [FAIL][6] ([fdo#103167])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6543/fi-icl-u2/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13731/fi-icl-u2/igt@[email protected]
* igt@kms_pipe_crc_basic@read-crc-pipe-c:
- fi-kbl-7567u: [PASS][7] -> [SKIP][8] ([fdo#109271]) +23 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6543/fi-kbl-7567u/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13731/fi-kbl-7567u/igt@[email protected]
* igt@prime_vgem@basic-fence-flip:
- fi-icl-u3: [PASS][9] -> [DMESG-WARN][10] ([fdo#107724])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6543/fi-icl-u3/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13731/fi-icl-u3/igt@[email protected]
#### Possible fixes ####
* igt@kms_busy@basic-flip-a:
- fi-kbl-7567u: [SKIP][11] ([fdo#109271] / [fdo#109278]) -> [PASS][12] +2 similar issues
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6543/fi-kbl-7567u/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13731/fi-kbl-7567u/igt@[email protected]
* igt@kms_busy@basic-flip-c:
- fi-kbl-7500u: [SKIP][13] ([fdo#109271] / [fdo#109278]) -> [PASS][14] +2 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6543/fi-kbl-7500u/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13731/fi-kbl-7500u/igt@[email protected]
* igt@prime_vgem@basic-fence-flip:
- fi-kbl-7500u: [SKIP][15] ([fdo#109271]) -> [PASS][16] +23 similar issues
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6543/fi-kbl-7500u/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13731/fi-kbl-7500u/igt@[email protected]
* igt@prime_vgem@basic-fence-read:
- fi-icl-u3: [DMESG-WARN][17] ([fdo#107724]) -> [PASS][18] +1 similar issue
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6543/fi-icl-u3/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13731/fi-icl-u3/igt@[email protected]
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109380]: https://bugs.freedesktop.org/show_bug.cgi?id=109380
[fdo#111156]: https://bugs.freedesktop.org/show_bug.cgi?id=111156
Participating hosts (56 -> 44)
------------------------------
Missing (12): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-byt-clapper fi-gdg-551 fi-icl-y fi-icl-guc fi-icl-dsi fi-bdw-samus
Build changes
-------------
* CI: CI-20190529 -> None
* Linux: CI_DRM_6543 -> Patchwork_13731
CI-20190529: 20190529
CI_DRM_6543: ef1bb6d271fab3750ce23b548954df7b28da8ce7 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5109: e5fd509e16ec649436be31f38eaa5b85cb7f72f1 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_13731: 30835ba789c4c08348b82a31c932065c60ebbc8d @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
30835ba789c4 drm/i915/uc: Unify uC firmware upload 44723e28e673 drm/i915/uc: Plumb the gt through fw_upload be285c278fbb drm/i915/guc: Set GuC init params only once dbfa2f355568 drm/i915/huc: Copy huc rsa only once f9e37db54a35 drm/i915/uc: Move xfer rsa logic to common function 0de179e2f693 drm/i915/uc: Unify uc_fw status tracking e49692394e57 drm/i915/uc: Unify uC FW selection eb041c6704a9 drm/i915/uc: Unify uC platform check
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13731/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx