Commit 03256487 authored by Anusha Srivatsa's avatar Anusha Srivatsa Committed by Lucas De Marchi

drm/i915/dmc: Add intel_dmc_has_payload() helper

We check for dmc_payload being there at various points in the driver.
Replace it with the helper.

v2: rebased.
v3: Move intel_dmc to intel_dmc.h in another patch (Lucas)
v4: Remove headers not needed from intel_dmc.h

Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: default avatarAnusha Srivatsa <anusha.srivatsa@intel.com>
Reviewed-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210526220256.4097-3-anusha.srivatsa@intel.com
parent ec7dfdfc
...@@ -542,10 +542,10 @@ static int i915_dmc_info(struct seq_file *m, void *unused) ...@@ -542,10 +542,10 @@ static int i915_dmc_info(struct seq_file *m, void *unused)
wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm); wakeref = intel_runtime_pm_get(&dev_priv->runtime_pm);
seq_printf(m, "fw loaded: %s\n", yesno(dmc->dmc_payload)); seq_printf(m, "fw loaded: %s\n", yesno(intel_dmc_has_payload(dev_priv)));
seq_printf(m, "path: %s\n", dmc->fw_path); seq_printf(m, "path: %s\n", dmc->fw_path);
if (!dmc->dmc_payload) if (!intel_dmc_has_payload(dev_priv))
goto out; goto out;
seq_printf(m, "version: %d.%d\n", DMC_VERSION_MAJOR(dmc->version), seq_printf(m, "version: %d.%d\n", DMC_VERSION_MAJOR(dmc->version),
......
...@@ -1218,7 +1218,7 @@ static void gen9_dc_off_power_well_enable(struct drm_i915_private *dev_priv, ...@@ -1218,7 +1218,7 @@ static void gen9_dc_off_power_well_enable(struct drm_i915_private *dev_priv,
static void gen9_dc_off_power_well_disable(struct drm_i915_private *dev_priv, static void gen9_dc_off_power_well_disable(struct drm_i915_private *dev_priv,
struct i915_power_well *power_well) struct i915_power_well *power_well)
{ {
if (!dev_priv->dmc.dmc_payload) if (!intel_dmc_has_payload(dev_priv))
return; return;
switch (dev_priv->dmc.target_dc_state) { switch (dev_priv->dmc.target_dc_state) {
...@@ -5581,7 +5581,7 @@ static void skl_display_core_init(struct drm_i915_private *dev_priv, ...@@ -5581,7 +5581,7 @@ static void skl_display_core_init(struct drm_i915_private *dev_priv,
gen9_dbuf_enable(dev_priv); gen9_dbuf_enable(dev_priv);
if (resume && dev_priv->dmc.dmc_payload) if (resume && intel_dmc_has_payload(dev_priv))
intel_dmc_load_program(dev_priv); intel_dmc_load_program(dev_priv);
} }
...@@ -5648,7 +5648,7 @@ static void bxt_display_core_init(struct drm_i915_private *dev_priv, bool resume ...@@ -5648,7 +5648,7 @@ static void bxt_display_core_init(struct drm_i915_private *dev_priv, bool resume
gen9_dbuf_enable(dev_priv); gen9_dbuf_enable(dev_priv);
if (resume && dev_priv->dmc.dmc_payload) if (resume && intel_dmc_has_payload(dev_priv))
intel_dmc_load_program(dev_priv); intel_dmc_load_program(dev_priv);
} }
...@@ -5714,7 +5714,7 @@ static void cnl_display_core_init(struct drm_i915_private *dev_priv, bool resume ...@@ -5714,7 +5714,7 @@ static void cnl_display_core_init(struct drm_i915_private *dev_priv, bool resume
/* 6. Enable DBUF */ /* 6. Enable DBUF */
gen9_dbuf_enable(dev_priv); gen9_dbuf_enable(dev_priv);
if (resume && dev_priv->dmc.dmc_payload) if (resume && intel_dmc_has_payload(dev_priv))
intel_dmc_load_program(dev_priv); intel_dmc_load_program(dev_priv);
} }
...@@ -5871,7 +5871,7 @@ static void icl_display_core_init(struct drm_i915_private *dev_priv, ...@@ -5871,7 +5871,7 @@ static void icl_display_core_init(struct drm_i915_private *dev_priv,
if (DISPLAY_VER(dev_priv) >= 12) if (DISPLAY_VER(dev_priv) >= 12)
tgl_bw_buddy_init(dev_priv); tgl_bw_buddy_init(dev_priv);
if (resume && dev_priv->dmc.dmc_payload) if (resume && intel_dmc_has_payload(dev_priv))
intel_dmc_load_program(dev_priv); intel_dmc_load_program(dev_priv);
/* Wa_14011508470 */ /* Wa_14011508470 */
...@@ -6232,7 +6232,7 @@ void intel_power_domains_suspend(struct drm_i915_private *i915, ...@@ -6232,7 +6232,7 @@ void intel_power_domains_suspend(struct drm_i915_private *i915,
*/ */
if (!(i915->dmc.allowed_dc_mask & DC_STATE_EN_DC9) && if (!(i915->dmc.allowed_dc_mask & DC_STATE_EN_DC9) &&
suspend_mode == I915_DRM_SUSPEND_IDLE && suspend_mode == I915_DRM_SUSPEND_IDLE &&
i915->dmc.dmc_payload) { intel_dmc_has_payload(i915)) {
intel_display_power_flush_work(i915); intel_display_power_flush_work(i915);
intel_power_domains_verify_state(i915); intel_power_domains_verify_state(i915);
return; return;
...@@ -6422,7 +6422,7 @@ void intel_display_power_resume(struct drm_i915_private *i915) ...@@ -6422,7 +6422,7 @@ void intel_display_power_resume(struct drm_i915_private *i915)
if (DISPLAY_VER(i915) >= 11) { if (DISPLAY_VER(i915) >= 11) {
bxt_disable_dc9(i915); bxt_disable_dc9(i915);
icl_display_core_init(i915, true); icl_display_core_init(i915, true);
if (i915->dmc.dmc_payload) { if (intel_dmc_has_payload(i915)) {
if (i915->dmc.allowed_dc_mask & if (i915->dmc.allowed_dc_mask &
DC_STATE_EN_UPTO_DC6) DC_STATE_EN_UPTO_DC6)
skl_enable_dc6(i915); skl_enable_dc6(i915);
...@@ -6433,7 +6433,7 @@ void intel_display_power_resume(struct drm_i915_private *i915) ...@@ -6433,7 +6433,7 @@ void intel_display_power_resume(struct drm_i915_private *i915)
} else if (IS_GEMINILAKE(i915) || IS_BROXTON(i915)) { } else if (IS_GEMINILAKE(i915) || IS_BROXTON(i915)) {
bxt_disable_dc9(i915); bxt_disable_dc9(i915);
bxt_display_core_init(i915, true); bxt_display_core_init(i915, true);
if (i915->dmc.dmc_payload && if (intel_dmc_has_payload(i915) &&
(i915->dmc.allowed_dc_mask & DC_STATE_EN_UPTO_DC5)) (i915->dmc.allowed_dc_mask & DC_STATE_EN_UPTO_DC5))
gen9_enable_dc5(i915); gen9_enable_dc5(i915);
} else if (IS_HASWELL(i915) || IS_BROADWELL(i915)) { } else if (IS_HASWELL(i915) || IS_BROADWELL(i915)) {
......
...@@ -237,6 +237,11 @@ struct stepping_info { ...@@ -237,6 +237,11 @@ struct stepping_info {
char substepping; char substepping;
}; };
bool intel_dmc_has_payload(struct drm_i915_private *i915)
{
return i915->dmc.dmc_payload;
}
static const struct stepping_info skl_stepping_info[] = { static const struct stepping_info skl_stepping_info[] = {
{'A', '0'}, {'B', '0'}, {'C', '0'}, {'A', '0'}, {'B', '0'}, {'C', '0'},
{'D', '0'}, {'E', '0'}, {'F', '0'}, {'D', '0'}, {'E', '0'}, {'F', '0'},
...@@ -320,7 +325,7 @@ void intel_dmc_load_program(struct drm_i915_private *dev_priv) ...@@ -320,7 +325,7 @@ void intel_dmc_load_program(struct drm_i915_private *dev_priv)
return; return;
} }
if (!dev_priv->dmc.dmc_payload) { if (!intel_dmc_has_payload(dev_priv)) {
drm_err(&dev_priv->drm, drm_err(&dev_priv->drm,
"Tried to program CSR with empty payload\n"); "Tried to program CSR with empty payload\n");
return; return;
...@@ -654,7 +659,7 @@ static void dmc_load_work_fn(struct work_struct *work) ...@@ -654,7 +659,7 @@ static void dmc_load_work_fn(struct work_struct *work)
request_firmware(&fw, dev_priv->dmc.fw_path, dev_priv->drm.dev); request_firmware(&fw, dev_priv->dmc.fw_path, dev_priv->drm.dev);
parse_dmc_fw(dev_priv, fw); parse_dmc_fw(dev_priv, fw);
if (dev_priv->dmc.dmc_payload) { if (intel_dmc_has_payload(dev_priv)) {
intel_dmc_load_program(dev_priv); intel_dmc_load_program(dev_priv);
intel_dmc_runtime_pm_put(dev_priv); intel_dmc_runtime_pm_put(dev_priv);
...@@ -783,7 +788,7 @@ void intel_dmc_ucode_suspend(struct drm_i915_private *dev_priv) ...@@ -783,7 +788,7 @@ void intel_dmc_ucode_suspend(struct drm_i915_private *dev_priv)
flush_work(&dev_priv->dmc.work); flush_work(&dev_priv->dmc.work);
/* Drop the reference held in case DMC isn't loaded. */ /* Drop the reference held in case DMC isn't loaded. */
if (!dev_priv->dmc.dmc_payload) if (!intel_dmc_has_payload(dev_priv))
intel_dmc_runtime_pm_put(dev_priv); intel_dmc_runtime_pm_put(dev_priv);
} }
...@@ -803,7 +808,7 @@ void intel_dmc_ucode_resume(struct drm_i915_private *dev_priv) ...@@ -803,7 +808,7 @@ void intel_dmc_ucode_resume(struct drm_i915_private *dev_priv)
* Reacquire the reference to keep RPM disabled in case DMC isn't * Reacquire the reference to keep RPM disabled in case DMC isn't
* loaded. * loaded.
*/ */
if (!dev_priv->dmc.dmc_payload) if (!intel_dmc_has_payload(dev_priv))
intel_dmc_runtime_pm_get(dev_priv); intel_dmc_runtime_pm_get(dev_priv);
} }
......
...@@ -17,5 +17,6 @@ void intel_dmc_load_program(struct drm_i915_private *i915); ...@@ -17,5 +17,6 @@ void intel_dmc_load_program(struct drm_i915_private *i915);
void intel_dmc_ucode_fini(struct drm_i915_private *i915); void intel_dmc_ucode_fini(struct drm_i915_private *i915);
void intel_dmc_ucode_suspend(struct drm_i915_private *i915); void intel_dmc_ucode_suspend(struct drm_i915_private *i915);
void intel_dmc_ucode_resume(struct drm_i915_private *i915); void intel_dmc_ucode_resume(struct drm_i915_private *i915);
bool intel_dmc_has_payload(struct drm_i915_private *i915);
#endif /* __INTEL_DMC_H__ */ #endif /* __INTEL_DMC_H__ */
...@@ -792,7 +792,7 @@ static void __err_print_to_sgl(struct drm_i915_error_state_buf *m, ...@@ -792,7 +792,7 @@ static void __err_print_to_sgl(struct drm_i915_error_state_buf *m,
struct intel_dmc *dmc = &m->i915->dmc; struct intel_dmc *dmc = &m->i915->dmc;
err_printf(m, "DMC loaded: %s\n", err_printf(m, "DMC loaded: %s\n",
yesno(dmc->dmc_payload)); yesno(intel_dmc_has_payload(m->i915) != 0));
err_printf(m, "DMC fw version: %d.%d\n", err_printf(m, "DMC fw version: %d.%d\n",
DMC_VERSION_MAJOR(dmc->version), DMC_VERSION_MAJOR(dmc->version),
DMC_VERSION_MINOR(dmc->version)); DMC_VERSION_MINOR(dmc->version));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment