Commit d75434bc authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Generalize intel_is_dram_symmetric()

Decouple intel_is_dram_symmetric() from the raw register values
by comparing just the dram_channel_info structs.
Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190306203551.24592-9-ville.syrjala@linux.intel.com
parent 198b8dd9
...@@ -1156,14 +1156,12 @@ skl_dram_get_channel_info(struct dram_channel_info *ch, ...@@ -1156,14 +1156,12 @@ skl_dram_get_channel_info(struct dram_channel_info *ch,
} }
static bool static bool
intel_is_dram_symmetric(u32 val_ch0, u32 val_ch1, intel_is_dram_symmetric(const struct dram_channel_info *ch0,
struct dram_channel_info *ch0) const struct dram_channel_info *ch1)
{ {
return (val_ch0 == val_ch1 && return !memcmp(ch0, ch1, sizeof(*ch0)) &&
(ch0->s_info.size == 0 || (ch0->s_info.size == 0 ||
(ch0->l_info.size == ch0->s_info.size && !memcmp(&ch0->l_info, &ch0->s_info, sizeof(ch0->l_info)));
ch0->l_info.width == ch0->s_info.width &&
ch0->l_info.ranks == ch0->s_info.ranks)));
} }
static int static int
...@@ -1171,16 +1169,16 @@ skl_dram_get_channels_info(struct drm_i915_private *dev_priv) ...@@ -1171,16 +1169,16 @@ skl_dram_get_channels_info(struct drm_i915_private *dev_priv)
{ {
struct dram_info *dram_info = &dev_priv->dram_info; struct dram_info *dram_info = &dev_priv->dram_info;
struct dram_channel_info ch0 = {}, ch1 = {}; struct dram_channel_info ch0 = {}, ch1 = {};
u32 val_ch0, val_ch1; u32 val;
int ret; int ret;
val_ch0 = I915_READ(SKL_MAD_DIMM_CH0_0_0_0_MCHBAR_MCMAIN); val = I915_READ(SKL_MAD_DIMM_CH0_0_0_0_MCHBAR_MCMAIN);
ret = skl_dram_get_channel_info(&ch0, 0, val_ch0); ret = skl_dram_get_channel_info(&ch0, 0, val);
if (ret == 0) if (ret == 0)
dram_info->num_channels++; dram_info->num_channels++;
val_ch1 = I915_READ(SKL_MAD_DIMM_CH1_0_0_0_MCHBAR_MCMAIN); val = I915_READ(SKL_MAD_DIMM_CH1_0_0_0_MCHBAR_MCMAIN);
ret = skl_dram_get_channel_info(&ch1, 1, val_ch1); ret = skl_dram_get_channel_info(&ch1, 1, val);
if (ret == 0) if (ret == 0)
dram_info->num_channels++; dram_info->num_channels++;
...@@ -1206,12 +1204,10 @@ skl_dram_get_channels_info(struct drm_i915_private *dev_priv) ...@@ -1206,12 +1204,10 @@ skl_dram_get_channels_info(struct drm_i915_private *dev_priv)
dram_info->is_16gb_dimm = ch0.is_16gb_dimm || ch1.is_16gb_dimm; dram_info->is_16gb_dimm = ch0.is_16gb_dimm || ch1.is_16gb_dimm;
dev_priv->dram_info.symmetric_memory = intel_is_dram_symmetric(val_ch0, dram_info->symmetric_memory = intel_is_dram_symmetric(&ch0, &ch1);
val_ch1,
&ch0);
DRM_DEBUG_KMS("memory configuration is %sSymmetric memory\n", DRM_DEBUG_KMS("Memory configuration is symmetric? %s\n",
dev_priv->dram_info.symmetric_memory ? "" : "not "); yesno(dram_info->symmetric_memory));
return 0; return 0;
} }
......
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