diff options
author | Jani Nikula <jani.nikula@intel.com> | 2021-03-26 16:21:34 +0300 |
---|---|---|
committer | Jani Nikula <jani.nikula@intel.com> | 2021-03-29 14:56:08 +0300 |
commit | ef47b7ab1faa6d32af351690e0bf664f6c6721b8 (patch) | |
tree | 9136470f63998ce2bf7d24bae599249fce716efd /drivers/gpu/drm/i915/intel_step.c | |
parent | 439c8dccb6a7f74bf6b3721fa509ab202c66f899 (diff) | |
download | linux-ef47b7ab1faa6d32af351690e0bf664f6c6721b8.tar.xz |
drm/i915: switch KBL to the new stepping scheme
Add new symbolic names for revision ids, and convert KBL revids to use
them via the new stepping check macros.
This also fixes theoretical out of bounds access to kbl_revids array.
v3: upgrade dbg to warn on unknown revid (José)
v2: Rename stepping->step
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/79b6c48211c6b214165391d350d556bad748f747.1616764798.git.jani.nikula@intel.com
Diffstat (limited to 'drivers/gpu/drm/i915/intel_step.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_step.c | 69 |
1 files changed, 60 insertions, 9 deletions
diff --git a/drivers/gpu/drm/i915/intel_step.c b/drivers/gpu/drm/i915/intel_step.c index e19820cbe8e3..e9ff481b2eda 100644 --- a/drivers/gpu/drm/i915/intel_step.c +++ b/drivers/gpu/drm/i915/intel_step.c @@ -13,15 +13,17 @@ * can test against in a regular manner. */ -const struct i915_rev_steppings kbl_revids[] = { - [0] = { .gt_stepping = KBL_REVID_A0, .disp_stepping = KBL_REVID_A0 }, - [1] = { .gt_stepping = KBL_REVID_B0, .disp_stepping = KBL_REVID_B0 }, - [2] = { .gt_stepping = KBL_REVID_C0, .disp_stepping = KBL_REVID_B0 }, - [3] = { .gt_stepping = KBL_REVID_D0, .disp_stepping = KBL_REVID_B0 }, - [4] = { .gt_stepping = KBL_REVID_F0, .disp_stepping = KBL_REVID_C0 }, - [5] = { .gt_stepping = KBL_REVID_C0, .disp_stepping = KBL_REVID_B1 }, - [6] = { .gt_stepping = KBL_REVID_D1, .disp_stepping = KBL_REVID_B1 }, - [7] = { .gt_stepping = KBL_REVID_G0, .disp_stepping = KBL_REVID_C0 }, + +/* FIXME: what about REVID_E0 */ +static const struct i915_rev_steppings kbl_revids[] = { + [0] = { .gt_stepping = STEP_A0, .disp_stepping = STEP_A0 }, + [1] = { .gt_stepping = STEP_B0, .disp_stepping = STEP_B0 }, + [2] = { .gt_stepping = STEP_C0, .disp_stepping = STEP_B0 }, + [3] = { .gt_stepping = STEP_D0, .disp_stepping = STEP_B0 }, + [4] = { .gt_stepping = STEP_F0, .disp_stepping = STEP_C0 }, + [5] = { .gt_stepping = STEP_C0, .disp_stepping = STEP_B1 }, + [6] = { .gt_stepping = STEP_D1, .disp_stepping = STEP_B1 }, + [7] = { .gt_stepping = STEP_G0, .disp_stepping = STEP_C0 }, }; const struct i915_rev_steppings tgl_uy_revid_step_tbl[] = { @@ -44,3 +46,52 @@ const struct i915_rev_steppings adls_revid_step_tbl[] = { [0x8] = { .gt_stepping = STEP_C0, .disp_stepping = STEP_B0 }, [0xC] = { .gt_stepping = STEP_D0, .disp_stepping = STEP_C0 }, }; + +void intel_step_init(struct drm_i915_private *i915) +{ + const struct i915_rev_steppings *revids = NULL; + int size = 0; + int revid = INTEL_REVID(i915); + struct i915_rev_steppings step = {}; + + if (IS_KABYLAKE(i915)) { + revids = kbl_revids; + size = ARRAY_SIZE(kbl_revids); + } + + /* Not using the stepping scheme for the platform yet. */ + if (!revids) + return; + + if (revid < size && revids[revid].gt_stepping != STEP_NONE) { + step = revids[revid]; + } else { + drm_warn(&i915->drm, "Unknown revid 0x%02x\n", revid); + + /* + * If we hit a gap in the revid array, use the information for + * the next revid. + * + * This may be wrong in all sorts of ways, especially if the + * steppings in the array are not monotonically increasing, but + * it's better than defaulting to 0. + */ + while (revid < size && revids[revid].gt_stepping == STEP_NONE) + revid++; + + if (revid < size) { + drm_dbg(&i915->drm, "Using steppings for revid 0x%02x\n", + revid); + step = revids[revid]; + } else { + drm_dbg(&i915->drm, "Using future steppings\n"); + step.gt_stepping = STEP_FUTURE; + step.disp_stepping = STEP_FUTURE; + } + } + + if (drm_WARN_ON(&i915->drm, step.gt_stepping == STEP_NONE)) + return; + + RUNTIME_INFO(i915)->step = step; +} |