Skip to content

Commit ff6f11a

Browse files
guludorodrigovivi
authored andcommitted
drm/i915/dmc: Prepare to use unversioned paths
New DMC releases in linux-firmware will stop using version number in blob filenames. This new convention provides the following benefits: 1. It simplifies code maintenance, as new DMC releases for a platform using the new convention will always use the same filename for the blob. 2. It allows DMC to be loaded even if the target system does not have the most recent firmware installed. Prepare the driver by: - Using the new convention for DMC_PATH() and renaming the currently used one to make it clear it is for the legacy scheme. - Implementing a fallback mechanism for future transitions from versioned to unversioned paths so that we do not cause a regression for systems not having the most up-to-date linux-firmware files. v2: - Keep using request_firmware() instead of firmware_request_nowarn(). (Jani) v3: - Keep current DMC paths instead of directly using unversioned ones, so that we do not disturb initrd generation. (Lucas, Rodrigo) Signed-off-by: Gustavo Sousa <gustavo.sousa@intel.com> Cc: Jani Nikula <jani.nikula@intel.com> Cc: Lucas De Marchi <lucas.demarchi@intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230123182021.31239-2-gustavo.sousa@intel.com
1 parent 21e18fe commit ff6f11a

File tree

1 file changed

+46
-16
lines changed

1 file changed

+46
-16
lines changed

drivers/gpu/drm/i915/display/intel_dmc.c

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,51 +42,59 @@
4242
#define DMC_VERSION_MAJOR(version) ((version) >> 16)
4343
#define DMC_VERSION_MINOR(version) ((version) & 0xffff)
4444

45-
#define DMC_PATH(platform, major, minor) \
46-
"i915/" \
47-
__stringify(platform) "_dmc_ver" \
48-
__stringify(major) "_" \
45+
#define DMC_PATH(platform) \
46+
"i915/" __stringify(platform) "_dmc.bin"
47+
48+
/*
49+
* New DMC additions should not use this. This is used solely to remain
50+
* compatible with systems that have not yet updated DMC blobs to use
51+
* unversioned file names.
52+
*/
53+
#define DMC_LEGACY_PATH(platform, major, minor) \
54+
"i915/" \
55+
__stringify(platform) "_dmc_ver" \
56+
__stringify(major) "_" \
4957
__stringify(minor) ".bin"
5058

5159
#define DISPLAY_VER13_DMC_MAX_FW_SIZE 0x20000
5260

5361
#define DISPLAY_VER12_DMC_MAX_FW_SIZE ICL_DMC_MAX_FW_SIZE
5462

55-
#define DG2_DMC_PATH DMC_PATH(dg2, 2, 08)
63+
#define DG2_DMC_PATH DMC_LEGACY_PATH(dg2, 2, 08)
5664
MODULE_FIRMWARE(DG2_DMC_PATH);
5765

58-
#define ADLP_DMC_PATH DMC_PATH(adlp, 2, 16)
66+
#define ADLP_DMC_PATH DMC_LEGACY_PATH(adlp, 2, 16)
5967
MODULE_FIRMWARE(ADLP_DMC_PATH);
6068

61-
#define ADLS_DMC_PATH DMC_PATH(adls, 2, 01)
69+
#define ADLS_DMC_PATH DMC_LEGACY_PATH(adls, 2, 01)
6270
MODULE_FIRMWARE(ADLS_DMC_PATH);
6371

64-
#define DG1_DMC_PATH DMC_PATH(dg1, 2, 02)
72+
#define DG1_DMC_PATH DMC_LEGACY_PATH(dg1, 2, 02)
6573
MODULE_FIRMWARE(DG1_DMC_PATH);
6674

67-
#define RKL_DMC_PATH DMC_PATH(rkl, 2, 03)
75+
#define RKL_DMC_PATH DMC_LEGACY_PATH(rkl, 2, 03)
6876
MODULE_FIRMWARE(RKL_DMC_PATH);
6977

70-
#define TGL_DMC_PATH DMC_PATH(tgl, 2, 12)
78+
#define TGL_DMC_PATH DMC_LEGACY_PATH(tgl, 2, 12)
7179
MODULE_FIRMWARE(TGL_DMC_PATH);
7280

73-
#define ICL_DMC_PATH DMC_PATH(icl, 1, 09)
81+
#define ICL_DMC_PATH DMC_LEGACY_PATH(icl, 1, 09)
7482
#define ICL_DMC_MAX_FW_SIZE 0x6000
7583
MODULE_FIRMWARE(ICL_DMC_PATH);
7684

77-
#define GLK_DMC_PATH DMC_PATH(glk, 1, 04)
85+
#define GLK_DMC_PATH DMC_LEGACY_PATH(glk, 1, 04)
7886
#define GLK_DMC_MAX_FW_SIZE 0x4000
7987
MODULE_FIRMWARE(GLK_DMC_PATH);
8088

81-
#define KBL_DMC_PATH DMC_PATH(kbl, 1, 04)
89+
#define KBL_DMC_PATH DMC_LEGACY_PATH(kbl, 1, 04)
8290
#define KBL_DMC_MAX_FW_SIZE BXT_DMC_MAX_FW_SIZE
8391
MODULE_FIRMWARE(KBL_DMC_PATH);
8492

85-
#define SKL_DMC_PATH DMC_PATH(skl, 1, 27)
93+
#define SKL_DMC_PATH DMC_LEGACY_PATH(skl, 1, 27)
8694
#define SKL_DMC_MAX_FW_SIZE BXT_DMC_MAX_FW_SIZE
8795
MODULE_FIRMWARE(SKL_DMC_PATH);
8896

89-
#define BXT_DMC_PATH DMC_PATH(bxt, 1, 07)
97+
#define BXT_DMC_PATH DMC_LEGACY_PATH(bxt, 1, 07)
9098
#define BXT_DMC_MAX_FW_SIZE 0x3000
9199
MODULE_FIRMWARE(BXT_DMC_PATH);
92100

@@ -845,16 +853,38 @@ static void intel_dmc_runtime_pm_put(struct drm_i915_private *dev_priv)
845853
intel_display_power_put(dev_priv, POWER_DOMAIN_INIT, wakeref);
846854
}
847855

856+
static const char *dmc_fallback_path(struct drm_i915_private *i915)
857+
{
858+
/* No fallback paths for now. */
859+
return NULL;
860+
}
861+
848862
static void dmc_load_work_fn(struct work_struct *work)
849863
{
850864
struct drm_i915_private *dev_priv;
851865
struct intel_dmc *dmc;
852866
const struct firmware *fw = NULL;
867+
const char *fallback_path;
868+
int err;
853869

854870
dev_priv = container_of(work, typeof(*dev_priv), display.dmc.work);
855871
dmc = &dev_priv->display.dmc;
856872

857-
request_firmware(&fw, dev_priv->display.dmc.fw_path, dev_priv->drm.dev);
873+
err = request_firmware(&fw, dev_priv->display.dmc.fw_path, dev_priv->drm.dev);
874+
875+
if (err == -ENOENT && !dev_priv->params.dmc_firmware_path) {
876+
fallback_path = dmc_fallback_path(dev_priv);
877+
if (fallback_path) {
878+
drm_dbg_kms(&dev_priv->drm,
879+
"%s not found, falling back to %s\n",
880+
dmc->fw_path,
881+
fallback_path);
882+
err = request_firmware(&fw, fallback_path, dev_priv->drm.dev);
883+
if (err == 0)
884+
dev_priv->display.dmc.fw_path = fallback_path;
885+
}
886+
}
887+
858888
parse_dmc_fw(dev_priv, fw);
859889

860890
if (intel_dmc_has_payload(dev_priv)) {

0 commit comments

Comments
 (0)