summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_drv.c
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2019-03-06 22:35:42 +0200
committerVille Syrjälä <ville.syrjala@linux.intel.com>2019-03-07 23:16:29 +0200
commit54561b238b1994d7ffe586b9d85ddf3c39a5a37c (patch)
tree384567e70ab29b04f69d5f53a475f9e226793be5 /drivers/gpu/drm/i915/i915_drv.c
parentea411e6b85df938eaa3ec4e3e34e885ff496a3ce (diff)
downloadlinux-stable-54561b238b1994d7ffe586b9d85ddf3c39a5a37c.tar.gz
linux-stable-54561b238b1994d7ffe586b9d85ddf3c39a5a37c.tar.bz2
linux-stable-54561b238b1994d7ffe586b9d85ddf3c39a5a37c.zip
drm/i915: Polish skl_is_16gb_dimm()
Pass the dimm struct to skl_is_16gb_dimm() rather than passing each value separately. And let's replace the hardcoded set of values with some simple arithmetic. Also fix the byte vs. bit inconsistency in the debug message, and polish the wording otherwise as well. v2: Deobfuscate the math (Chris) Reviewed-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190306203551.24592-4-ville.syrjala@linux.intel.com
Diffstat (limited to 'drivers/gpu/drm/i915/i915_drv.c')
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 45d70ecd9037..e35a75be3a2a 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1068,6 +1068,11 @@ static void intel_sanitize_options(struct drm_i915_private *dev_priv)
intel_gvt_sanitize_options(dev_priv);
}
+static int intel_dimm_num_devices(const struct dram_dimm_info *dimm)
+{
+ return dimm->ranks * 64 / (dimm->width ?: 1);
+}
+
/* Returns total GB for the whole DIMM */
static int skl_get_dimm_size(u16 val)
{
@@ -1102,18 +1107,10 @@ static int skl_get_dimm_ranks(u16 val)
}
static bool
-skl_is_16gb_dimm(u8 ranks, u8 size, u8 width)
+skl_is_16gb_dimm(const struct dram_dimm_info *dimm)
{
- if (ranks == 1 && width == 8 && size == 16)
- return true;
- else if (ranks == 2 && width == 8 && size == 32)
- return true;
- else if (ranks == 1 && width == 16 && size == 8)
- return true;
- else if (ranks == 2 && width == 16 && size == 16)
- return true;
-
- return false;
+ /* Convert total GB to Gb per DRAM device */
+ return 8 * dimm->size / (intel_dimm_num_devices(dimm) ?: 1) == 16;
}
static int
@@ -1143,10 +1140,9 @@ skl_dram_get_channel_info(struct dram_channel_info *ch, u32 val)
else
ch->ranks = 1;
- ch->is_16gb_dimm = skl_is_16gb_dimm(ch->l_info.ranks, ch->l_info.size,
- ch->l_info.width) ||
- skl_is_16gb_dimm(ch->s_info.ranks, ch->s_info.size,
- ch->s_info.width);
+ ch->is_16gb_dimm =
+ skl_is_16gb_dimm(&ch->l_info) ||
+ skl_is_16gb_dimm(&ch->s_info);
DRM_DEBUG_KMS("(size:width:ranks) L(%uGB:X%u:%u) S(%uGB:X%u:%u)\n",
ch->l_info.size, ch->l_info.width, ch->l_info.ranks,
@@ -1364,7 +1360,7 @@ intel_get_dram_info(struct drm_i915_private *dev_priv)
sprintf(bandwidth_str, "unknown");
DRM_DEBUG_KMS("DRAM bandwidth:%s, total-channels: %u\n",
bandwidth_str, dram_info->num_channels);
- DRM_DEBUG_KMS("DRAM ranks: %u, 16GB-dimm:%s\n",
+ DRM_DEBUG_KMS("DRAM ranks: %u, 16Gb DIMMs: %s\n",
dram_info->ranks, yesno(dram_info->is_16gb_dimm));
}