All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Ville Syrjala <ville.syrjala@linux.intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 04/12] drm/i915: Extract BXT DIMM helpers
Date: Mon, 04 Mar 2019 20:26:53 +0200	[thread overview]
Message-ID: <87va0y3382.fsf@intel.com> (raw)
In-Reply-To: <20190226152717.4495-1-ville.syrjala@linux.intel.com>

On Tue, 26 Feb 2019, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Polish the bxt DIMM parsing by extracting a few small helpers.
>
> v2: Use struct dram_dimm_info
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Reviewed-by: Jani Nikula <jani.nikula@intel.com>

> ---
>  drivers/gpu/drm/i915/i915_drv.c | 93 ++++++++++++++++++++++-----------
>  1 file changed, 62 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index d84f3485e775..f948d475bdf4 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -1243,6 +1243,59 @@ skl_get_dram_info(struct drm_i915_private *dev_priv)
>  	return 0;
>  }
>  
> +static int bxt_get_dimm_size(u32 val)
> +{
> +	switch (val & BXT_DRAM_SIZE_MASK) {
> +	case BXT_DRAM_SIZE_4GB:
> +		return 4;
> +	case BXT_DRAM_SIZE_6GB:
> +		return 6;
> +	case BXT_DRAM_SIZE_8GB:
> +		return 8;
> +	case BXT_DRAM_SIZE_12GB:
> +		return 12;
> +	case BXT_DRAM_SIZE_16GB:
> +		return 16;
> +	default:
> +		MISSING_CASE(val);
> +		return 0;
> +	}
> +}
> +
> +static int bxt_get_dimm_width(u32 val)
> +{
> +	if (!bxt_get_dimm_size(val))
> +		return 0;
> +
> +	val = (val & BXT_DRAM_WIDTH_MASK) >> BXT_DRAM_WIDTH_SHIFT;
> +
> +	return 8 << val;
> +}
> +
> +static int bxt_get_dimm_ranks(u32 val)
> +{
> +	if (!bxt_get_dimm_size(val))
> +		return 0;
> +
> +	switch (val & BXT_DRAM_RANK_MASK) {
> +	case BXT_DRAM_RANK_SINGLE:
> +		return 1;
> +	case BXT_DRAM_RANK_DUAL:
> +		return 2;
> +	default:
> +		MISSING_CASE(val);
> +		return 0;
> +	}
> +}
> +
> +static void bxt_get_dimm_info(struct dram_dimm_info *dimm,
> +			      u32 val)
> +{
> +	dimm->size = bxt_get_dimm_size(val);
> +	dimm->width = bxt_get_dimm_width(val);
> +	dimm->ranks = bxt_get_dimm_ranks(val);
> +}
> +
>  static int
>  bxt_get_dram_info(struct drm_i915_private *dev_priv)
>  {
> @@ -1271,41 +1324,19 @@ bxt_get_dram_info(struct drm_i915_private *dev_priv)
>  	 * Now read each DUNIT8/9/10/11 to check the rank of each dimms.
>  	 */
>  	for (i = BXT_D_CR_DRP0_DUNIT_START; i <= BXT_D_CR_DRP0_DUNIT_END; i++) {
> -		u8 size, width, ranks;
> -		u32 tmp;
> +		struct dram_dimm_info dimm;
>  
>  		val = I915_READ(BXT_D_CR_DRP0_DUNIT(i));
>  		if (val == 0xFFFFFFFF)
>  			continue;
>  
>  		dram_info->num_channels++;
> -		tmp = val & BXT_DRAM_RANK_MASK;
> -
> -		if (tmp == BXT_DRAM_RANK_SINGLE)
> -			ranks = 1;
> -		else if (tmp == BXT_DRAM_RANK_DUAL)
> -			ranks = 2;
> -		else
> -			ranks = 0;
> -
> -		tmp = val & BXT_DRAM_SIZE_MASK;
> -		if (tmp == BXT_DRAM_SIZE_4GB)
> -			size = 4;
> -		else if (tmp == BXT_DRAM_SIZE_6GB)
> -			size = 6;
> -		else if (tmp == BXT_DRAM_SIZE_8GB)
> -			size = 8;
> -		else if (tmp == BXT_DRAM_SIZE_12GB)
> -			size = 12;
> -		else if (tmp == BXT_DRAM_SIZE_16GB)
> -			size = 16;
> -		else
> -			size = 0;
> -
> -		tmp = (val & BXT_DRAM_WIDTH_MASK) >> BXT_DRAM_WIDTH_SHIFT;
> -		width = (1 << tmp) * 8;
> -		DRM_DEBUG_KMS("dram size:%dGB width:X%d ranks:%d\n",
> -			      size, width, ranks);
> +
> +		bxt_get_dimm_info(&dimm, val);
> +
> +		DRM_DEBUG_KMS("CH%d DIMM size: %d GB, width: X%d, ranks: %d\n",
> +			      i - BXT_D_CR_DRP0_DUNIT_START,
> +			      dimm.size, dimm.width, dimm.ranks);
>  
>  		/*
>  		 * If any of the channel is single rank channel,
> @@ -1313,8 +1344,8 @@ bxt_get_dram_info(struct drm_i915_private *dev_priv)
>  		 * memory, so consider single rank memory.
>  		 */
>  		if (dram_info->ranks == 0)
> -			dram_info->ranks = ranks;
> -		else if (ranks == 1)
> +			dram_info->ranks = dimm.ranks;
> +		else if (dimm.ranks == 1)
>  			dram_info->ranks = 1;
>  	}

-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-03-04 18:24 UTC|newest]

Thread overview: 47+ 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 [this message]
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ä
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
2019-03-06 20:35 [PATCH v2 00/12] Polish DRAM information readout code Ville Syrjala
2019-03-06 20:35 ` [PATCH v2 04/12] drm/i915: Extract BXT DIMM helpers Ville Syrjala

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=87va0y3382.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ville.syrjala@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.