Message ID | 8695aca8a6643e36bb680bc2dcab97c637e70b00.1713519628.git.jani.nikula@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/i915/dmc: firmware path handling changes | expand |
Quoting Jani Nikula (2024-04-19 06:41:57-03:00) >The distinction between the dmc_firmware_path module param being NULL >and the empty string "" is problematic. It's not possible to set the >parameter back to NULL via sysfs or debugfs. Remove the distinction, and >consider NULL and the empty string to be the same thing, and use the >platform default for them. > >This removes the possibility to disable DMC (and runtime PM) via >i915.dmc_firmware_path="". Instead, use "/dev/null" as the magic >firmware path to skip DMC firmware loading and disable runtime PM. > >v2: Add support for i915.dmc_firmware_path="/dev/null" (Gustavo) > >Cc: Gustavo Sousa <gustavo.sousa@intel.com> >Cc: Lucas De Marchi <lucas.demarchi@intel.com> >Signed-off-by: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com> >--- > drivers/gpu/drm/i915/display/intel_dmc.c | 31 +++++++++++++++++------- > drivers/gpu/drm/i915/i915_params.c | 3 ++- > 2 files changed, 24 insertions(+), 10 deletions(-) > >diff --git a/drivers/gpu/drm/i915/display/intel_dmc.c b/drivers/gpu/drm/i915/display/intel_dmc.c >index a2027c6cf4f1..7dabfaa636e4 100644 >--- a/drivers/gpu/drm/i915/display/intel_dmc.c >+++ b/drivers/gpu/drm/i915/display/intel_dmc.c >@@ -73,6 +73,21 @@ static struct intel_dmc *i915_to_dmc(struct drm_i915_private *i915) > return i915->display.dmc.dmc; > } > >+static const char *dmc_firmware_param(struct drm_i915_private *i915) >+{ >+ const char *p = i915->params.dmc_firmware_path; >+ >+ return p && *p ? p : NULL; >+} >+ >+static bool dmc_firmware_param_disabled(struct drm_i915_private *i915) >+{ >+ const char *p = dmc_firmware_param(i915); >+ >+ /* Magic path to indicate disabled */ >+ return p && !strcmp(p, "/dev/null"); >+} >+ > #define DMC_VERSION(major, minor) ((major) << 16 | (minor)) > #define DMC_VERSION_MAJOR(version) ((version) >> 16) > #define DMC_VERSION_MINOR(version) ((version) & 0xffff) >@@ -991,7 +1006,7 @@ static void dmc_load_work_fn(struct work_struct *work) > > err = request_firmware(&fw, dmc->fw_path, i915->drm.dev); > >- if (err == -ENOENT && !i915->params.dmc_firmware_path) { >+ if (err == -ENOENT && !dmc_firmware_param(i915)) { > fallback_path = dmc_fallback_path(i915); > if (fallback_path) { > drm_dbg_kms(&i915->drm, "%s not found, falling back to %s\n", >@@ -1064,16 +1079,14 @@ void intel_dmc_init(struct drm_i915_private *i915) > > dmc->fw_path = dmc_firmware_default(i915, &dmc->max_fw_size); > >- if (i915->params.dmc_firmware_path) { >- if (strlen(i915->params.dmc_firmware_path) == 0) { >- drm_info(&i915->drm, >- "Disabling DMC firmware and runtime PM\n"); >- goto out; >- } >- >- dmc->fw_path = i915->params.dmc_firmware_path; >+ if (dmc_firmware_param_disabled(i915)) { >+ drm_info(&i915->drm, "Disabling DMC firmware and runtime PM\n"); >+ goto out; > } > >+ if (dmc_firmware_param(i915)) >+ dmc->fw_path = dmc_firmware_param(i915); >+ > if (!dmc->fw_path) { > drm_dbg_kms(&i915->drm, > "No known DMC firmware for platform, disabling runtime PM\n"); >diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c >index de43048543e8..edfd1f54a882 100644 >--- a/drivers/gpu/drm/i915/i915_params.c >+++ b/drivers/gpu/drm/i915/i915_params.c >@@ -109,7 +109,8 @@ i915_param_named_unsafe(huc_firmware_path, charp, 0400, > "HuC firmware path to use instead of the default one"); > > i915_param_named_unsafe(dmc_firmware_path, charp, 0400, >- "DMC firmware path to use instead of the default one"); >+ "DMC firmware path to use instead of the default one. " >+ "Use /dev/null to disable DMC and runtime PM."); > > i915_param_named_unsafe(gsc_firmware_path, charp, 0400, > "GSC firmware path to use instead of the default one"); >-- >2.39.2 >
diff --git a/drivers/gpu/drm/i915/display/intel_dmc.c b/drivers/gpu/drm/i915/display/intel_dmc.c index a2027c6cf4f1..7dabfaa636e4 100644 --- a/drivers/gpu/drm/i915/display/intel_dmc.c +++ b/drivers/gpu/drm/i915/display/intel_dmc.c @@ -73,6 +73,21 @@ static struct intel_dmc *i915_to_dmc(struct drm_i915_private *i915) return i915->display.dmc.dmc; } +static const char *dmc_firmware_param(struct drm_i915_private *i915) +{ + const char *p = i915->params.dmc_firmware_path; + + return p && *p ? p : NULL; +} + +static bool dmc_firmware_param_disabled(struct drm_i915_private *i915) +{ + const char *p = dmc_firmware_param(i915); + + /* Magic path to indicate disabled */ + return p && !strcmp(p, "/dev/null"); +} + #define DMC_VERSION(major, minor) ((major) << 16 | (minor)) #define DMC_VERSION_MAJOR(version) ((version) >> 16) #define DMC_VERSION_MINOR(version) ((version) & 0xffff) @@ -991,7 +1006,7 @@ static void dmc_load_work_fn(struct work_struct *work) err = request_firmware(&fw, dmc->fw_path, i915->drm.dev); - if (err == -ENOENT && !i915->params.dmc_firmware_path) { + if (err == -ENOENT && !dmc_firmware_param(i915)) { fallback_path = dmc_fallback_path(i915); if (fallback_path) { drm_dbg_kms(&i915->drm, "%s not found, falling back to %s\n", @@ -1064,16 +1079,14 @@ void intel_dmc_init(struct drm_i915_private *i915) dmc->fw_path = dmc_firmware_default(i915, &dmc->max_fw_size); - if (i915->params.dmc_firmware_path) { - if (strlen(i915->params.dmc_firmware_path) == 0) { - drm_info(&i915->drm, - "Disabling DMC firmware and runtime PM\n"); - goto out; - } - - dmc->fw_path = i915->params.dmc_firmware_path; + if (dmc_firmware_param_disabled(i915)) { + drm_info(&i915->drm, "Disabling DMC firmware and runtime PM\n"); + goto out; } + if (dmc_firmware_param(i915)) + dmc->fw_path = dmc_firmware_param(i915); + if (!dmc->fw_path) { drm_dbg_kms(&i915->drm, "No known DMC firmware for platform, disabling runtime PM\n"); diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c index de43048543e8..edfd1f54a882 100644 --- a/drivers/gpu/drm/i915/i915_params.c +++ b/drivers/gpu/drm/i915/i915_params.c @@ -109,7 +109,8 @@ i915_param_named_unsafe(huc_firmware_path, charp, 0400, "HuC firmware path to use instead of the default one"); i915_param_named_unsafe(dmc_firmware_path, charp, 0400, - "DMC firmware path to use instead of the default one"); + "DMC firmware path to use instead of the default one. " + "Use /dev/null to disable DMC and runtime PM."); i915_param_named_unsafe(gsc_firmware_path, charp, 0400, "GSC firmware path to use instead of the default one");
The distinction between the dmc_firmware_path module param being NULL and the empty string "" is problematic. It's not possible to set the parameter back to NULL via sysfs or debugfs. Remove the distinction, and consider NULL and the empty string to be the same thing, and use the platform default for them. This removes the possibility to disable DMC (and runtime PM) via i915.dmc_firmware_path="". Instead, use "/dev/null" as the magic firmware path to skip DMC firmware loading and disable runtime PM. v2: Add support for i915.dmc_firmware_path="/dev/null" (Gustavo) Cc: Gustavo Sousa <gustavo.sousa@intel.com> Cc: Lucas De Marchi <lucas.demarchi@intel.com> Signed-off-by: Jani Nikula <jani.nikula@intel.com> --- drivers/gpu/drm/i915/display/intel_dmc.c | 31 +++++++++++++++++------- drivers/gpu/drm/i915/i915_params.c | 3 ++- 2 files changed, 24 insertions(+), 10 deletions(-)