From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Jani Nikula <jani.nikula@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 11/12] drm/i915: Extract DIMM info on cnl+
Date: Wed, 6 Mar 2019 21:25:09 +0200 [thread overview]
Message-ID: <20190306192509.GO3888@intel.com> (raw)
In-Reply-To: <87woldb8jq.fsf@intel.com>
On Tue, Mar 05, 2019 at 06:16:57PM +0200, Jani Nikula wrote:
> On Mon, 25 Feb 2019, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > We'll need information about the memory configuration on cnl+ too.
> > Extend the code to parse the slightly changed register layout.
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> > drivers/gpu/drm/i915/i915_drv.c | 69 ++++++++++++++++++++++++---------
> > drivers/gpu/drm/i915/i915_reg.h | 17 +++++++-
> > 2 files changed, 66 insertions(+), 20 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> > index e3aafe2bf3b7..95361814b531 100644
> > --- a/drivers/gpu/drm/i915/i915_drv.c
> > +++ b/drivers/gpu/drm/i915/i915_drv.c
> > @@ -1095,17 +1095,43 @@ static int skl_get_dimm_ranks(u16 val)
> > if (skl_get_dimm_size(val) == 0)
> > return 0;
> >
> > - switch (val & SKL_DRAM_RANK_MASK) {
> > - case SKL_DRAM_RANK_SINGLE:
> > - case SKL_DRAM_RANK_DUAL:
> > - val = (val & SKL_DRAM_RANK_MASK) >> SKL_DRAM_RANK_SHIFT;
> > - return val + 1;
> > + val = (val & SKL_DRAM_RANK_MASK) >> SKL_DRAM_RANK_SHIFT;
> > +
> > + return val + 1;
>
> This part is a bit out of place. Rebase fail?
Aye. Moved to patch 02 where it belongs.
>
> > +}
> > +
> > +static int cnl_get_dimm_size(u16 val)
> > +{
> > + return (val & CNL_DRAM_SIZE_MASK) / 2;
>
> Multiples of 0.5 GB... what an odd unit. What if there's an odd value?
The worst thing that could happen is that the 16 Gb detection
gives us the wrong answer. The other thing is that we'd print
out the wrong size.
I'm not sure if there is any chance of having such oddly sized
DRAM chips on any modern DIMM that we'd hit this. I didn't
really want to change everything just for this at this time.
We can always revisit it later if necesary.
>
> > +}
> > +
> > +static int cnl_get_dimm_width(u16 val)
> > +{
> > + if (cnl_get_dimm_size(val) == 0)
> > + return 0;
> > +
> > + switch (val & CNL_DRAM_WIDTH_MASK) {
> > + case CNL_DRAM_WIDTH_X8:
> > + case CNL_DRAM_WIDTH_X16:
> > + case CNL_DRAM_WIDTH_X32:
> > + val = (val & CNL_DRAM_WIDTH_MASK) >> CNL_DRAM_WIDTH_SHIFT;
> > + return 8 << val;
> > default:
> > MISSING_CASE(val);
> > return 0;
> > }
> > }
> >
> > +static int cnl_get_dimm_ranks(u16 val)
> > +{
> > + if (cnl_get_dimm_size(val) == 0)
> > + return 0;
> > +
> > + val = (val & CNL_DRAM_RANK_MASK) >> CNL_DRAM_RANK_SHIFT;
> > +
> > + return val + 1;
> > +}
> > +
> > static bool
> > skl_is_16gb_dimm(const struct dram_dimm_info *dimm)
> > {
> > @@ -1113,12 +1139,19 @@ skl_is_16gb_dimm(const struct dram_dimm_info *dimm)
> > }
> >
> > static void
> > -skl_dram_get_dimm_info(struct dram_dimm_info *dimm,
> > +skl_dram_get_dimm_info(struct drm_i915_private *dev_priv,
> > + struct dram_dimm_info *dimm,
> > int channel, char dimm_name, u16 val)
> > {
> > - dimm->size = skl_get_dimm_size(val);
> > - dimm->width = skl_get_dimm_width(val);
> > - dimm->ranks = skl_get_dimm_ranks(val);
> > + if (INTEL_GEN(dev_priv) >= 10) {
> > + dimm->size = cnl_get_dimm_size(val);
> > + dimm->width = cnl_get_dimm_width(val);
> > + dimm->ranks = cnl_get_dimm_ranks(val);
> > + } else {
> > + dimm->size = skl_get_dimm_size(val);
> > + dimm->width = skl_get_dimm_width(val);
> > + dimm->ranks = skl_get_dimm_ranks(val);
> > + }
> >
> > DRM_DEBUG_KMS("CH%d DIMM %c size: %d GB, width: X%d, ranks: %d, 16Gb DIMMs: %s\n",
> > channel, dimm_name, dimm->size, dimm->width, dimm->ranks,
> > @@ -1126,11 +1159,14 @@ skl_dram_get_dimm_info(struct dram_dimm_info *dimm,
> > }
> >
> > static int
> > -skl_dram_get_channel_info(struct dram_channel_info *ch,
> > +skl_dram_get_channel_info(struct drm_i915_private *dev_priv,
> > + struct dram_channel_info *ch,
> > int channel, u32 val)
> > {
> > - skl_dram_get_dimm_info(&ch->dimm_l, channel, 'L', val & 0xffff);
> > - skl_dram_get_dimm_info(&ch->dimm_s, channel, 'S', val >> 16);
> > + skl_dram_get_dimm_info(dev_priv, &ch->dimm_l,
> > + channel, 'L', val & 0xffff);
> > + skl_dram_get_dimm_info(dev_priv, &ch->dimm_s,
> > + channel, 'S', val >> 16);
> >
> > if (ch->dimm_l.size == 0 && ch->dimm_s.size == 0) {
> > DRM_DEBUG_KMS("CH%d not populated\n", channel);
> > @@ -1172,12 +1208,12 @@ skl_dram_get_channels_info(struct drm_i915_private *dev_priv)
> > int ret;
> >
> > val = I915_READ(SKL_MAD_DIMM_CH0_0_0_0_MCHBAR_MCMAIN);
> > - ret = skl_dram_get_channel_info(&ch0, 0, val);
> > + ret = skl_dram_get_channel_info(dev_priv, &ch0, 0, val);
> > if (ret == 0)
> > dram_info->num_channels++;
> >
> > val = I915_READ(SKL_MAD_DIMM_CH1_0_0_0_MCHBAR_MCMAIN);
> > - ret = skl_dram_get_channel_info(&ch1, 1, val);
> > + ret = skl_dram_get_channel_info(dev_priv, &ch1, 1, val);
> > if (ret == 0)
> > dram_info->num_channels++;
> >
> > @@ -1369,13 +1405,10 @@ intel_get_dram_info(struct drm_i915_private *dev_priv)
> > if (INTEL_GEN(dev_priv) < 9)
> > return;
> >
> > - /* Need to calculate bandwidth only for Gen9 */
> > if (IS_GEN9_LP(dev_priv))
> > ret = bxt_get_dram_info(dev_priv);
> > - else if (IS_GEN(dev_priv, 9))
> > - ret = skl_get_dram_info(dev_priv);
> > else
> > - ret = skl_dram_get_channels_info(dev_priv);
> > + ret = skl_get_dram_info(dev_priv);
>
> The part that's hidden here is the use of the common parts in
> skl_get_dram_info() and in particular
> SKL_MEMORY_FREQ_MULTIPLIER_HZ. Spec says "The value is given in units of
> 133.33 MHz". But it says the same for SKL too. What am I missing?
The whole DRAM clocking is a bit of a mystery to me. So far I didn't
find any good docs on the subject. The registers talk about QCLK (which
is the data clock IIUC) but bunch of stuff is interested in the DCLK
(the command clock) though. I guess there's 1:1 relationship, and I
suppose the factor of two here is maybe just due to the DDR.
>
> Tentative Reviewed-by: Jani Nikula <jani.nikula@intel.com>
>
> > if (ret)
> > return;
> >
> > diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> > index 730bb1917fd1..b35b0220764f 100644
> > --- a/drivers/gpu/drm/i915/i915_reg.h
> > +++ b/drivers/gpu/drm/i915/i915_reg.h
> > @@ -9875,8 +9875,21 @@ enum skl_power_gate {
> > #define SKL_DRAM_WIDTH_X32 (0x2 << 8)
> > #define SKL_DRAM_RANK_MASK (0x1 << 10)
> > #define SKL_DRAM_RANK_SHIFT 10
> > -#define SKL_DRAM_RANK_SINGLE (0x0 << 10)
> > -#define SKL_DRAM_RANK_DUAL (0x1 << 10)
> > +#define SKL_DRAM_RANK_1 (0x0 << 10)
> > +#define SKL_DRAM_RANK_2 (0x1 << 10)
> > +#define SKL_DRAM_RANK_MASK (0x1 << 10)
> > +#define CNL_DRAM_SIZE_MASK 0x7F
> > +#define CNL_DRAM_WIDTH_MASK (0x3 << 7)
> > +#define CNL_DRAM_WIDTH_SHIFT 7
> > +#define CNL_DRAM_WIDTH_X8 (0x0 << 7)
> > +#define CNL_DRAM_WIDTH_X16 (0x1 << 7)
> > +#define CNL_DRAM_WIDTH_X32 (0x2 << 7)
> > +#define CNL_DRAM_RANK_MASK (0x3 << 9)
> > +#define CNL_DRAM_RANK_SHIFT 9
> > +#define CNL_DRAM_RANK_1 (0x0 << 9)
> > +#define CNL_DRAM_RANK_2 (0x1 << 9)
> > +#define CNL_DRAM_RANK_3 (0x2 << 9)
> > +#define CNL_DRAM_RANK_4 (0x3 << 9)
> >
> > /* Please see hsw_read_dcomp() and hsw_write_dcomp() before using this register,
> > * since on HSW we can't write to it using I915_WRITE. */
>
> --
> Jani Nikula, Intel Open Source Graphics Center
--
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-03-06 19:25 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-25 20:28 [PATCH 00/12] Polish DRAM information readout code Ville Syrjala
2019-02-25 20:28 ` [PATCH 01/12] drm/i915: Store DIMM rank information as a number Ville Syrjala
2019-03-04 16:17 ` Jani Nikula
2019-03-04 16:32 ` Ville Syrjälä
2019-02-25 20:28 ` [PATCH 02/12] drm/i915: Extract functions to derive SKL+ DIMM info Ville Syrjala
2019-03-04 16:32 ` Jani Nikula
2019-03-04 16:44 ` Ville Syrjälä
2019-02-25 20:28 ` [PATCH 03/12] drm/i915: Polish skl_is_16gb_dimm() Ville Syrjala
2019-02-26 15:26 ` [PATCH v2 " Ville Syrjala
2019-03-04 18:19 ` Jani Nikula
2019-02-25 20:28 ` [PATCH 04/12] drm/i915: Extract BXT DIMM helpers Ville Syrjala
2019-02-26 15:27 ` [PATCH v2 " Ville Syrjala
2019-03-04 18:26 ` Jani Nikula
2019-02-25 20:29 ` [PATCH 05/12] drm/i915: Fix DRAM size reporting for BXT Ville Syrjala
2019-02-25 20:35 ` Chris Wilson
2019-02-25 20:48 ` Ville Syrjälä
2019-02-25 20:57 ` Chris Wilson
2019-02-25 21:06 ` Ville Syrjälä
2019-02-26 15:27 ` [PATCH v2 " Ville Syrjala
2019-03-04 18:56 ` Jani Nikula
2019-02-25 20:29 ` [PATCH 06/12] drm/i915: Extract DIMM info on GLK too Ville Syrjala
2019-03-05 17:00 ` Jani Nikula
2019-02-25 20:29 ` [PATCH 07/12] drm/i915: Use dram_dimm_info more Ville Syrjala
2019-03-04 19:13 ` Jani Nikula
2019-02-25 20:29 ` [PATCH 08/12] drm/i915: Generalize intel_is_dram_symmetric() Ville Syrjala
2019-03-04 19:57 ` Jani Nikula
2019-02-25 20:29 ` [PATCH 09/12] drm/i914: s/l_info/dimm_l/ etc Ville Syrjala
2019-03-04 19:58 ` Jani Nikula
2019-02-25 20:29 ` [PATCH 10/12] drm/i915: Clean up intel_get_dram_info() a bit Ville Syrjala
2019-03-04 20:01 ` Jani Nikula
2019-02-25 20:29 ` [PATCH 11/12] drm/i915: Extract DIMM info on cnl+ Ville Syrjala
2019-03-05 16:16 ` Jani Nikula
2019-03-06 19:25 ` Ville Syrjälä [this message]
2019-03-06 19:48 ` Jani Nikula
2019-02-25 20:29 ` [PATCH 12/12] drm/i915: Read out memory type Ville Syrjala
2019-02-26 17:57 ` [PATCH v2 " Ville Syrjala
2019-03-05 16:35 ` Jani Nikula
2019-02-25 21:00 ` ✗ Fi.CI.CHECKPATCH: warning for Polish DRAM information readout code Patchwork
2019-02-25 21:04 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-02-25 21:21 ` ✓ Fi.CI.BAT: success " Patchwork
2019-02-26 5:52 ` ✓ Fi.CI.IGT: " Patchwork
2019-02-26 15:37 ` ✗ Fi.CI.BAT: failure for Polish DRAM information readout code (rev4) Patchwork
2019-02-26 19:13 ` ✗ Fi.CI.CHECKPATCH: warning for Polish DRAM information readout code (rev5) Patchwork
2019-02-26 19:18 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-02-26 19:42 ` ✓ Fi.CI.BAT: success " Patchwork
2019-02-26 23:33 ` ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190306192509.GO3888@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox