diff mbox series

[1/2] drm/i915: Turn dram_info.num_channels into a bitmask

Message ID 20190320214635.27814-1-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/i915: Turn dram_info.num_channels into a bitmask | expand

Commit Message

Ville Syrjälä March 20, 2019, 9:46 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

We want to know out which channels are actually occupied so that
later on we can read the memory timings from the right registers.
To that end convert num_channels into a bitmask.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_drv.c | 28 +++++++++++++++-------------
 drivers/gpu/drm/i915/i915_drv.h |  2 +-
 2 files changed, 16 insertions(+), 14 deletions(-)

Comments

Saarinen, Jani March 21, 2019, 7:50 a.m. UTC | #1
Finally, now need shards data ;). 

> -----Original Message-----
> From: Intel-gfx [mailto:intel-gfx-bounces@lists.freedesktop.org] On Behalf Of
> Patchwork
> Sent: torstai 21. maaliskuuta 2019 8.34
> To: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: intel-gfx@lists.freedesktop.org
> Subject: [Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915: Turn
> dram_info.num_channels into a bitmask (rev3)
> 
> == Series Details ==
> 
> Series: series starting with [1/2] drm/i915: Turn dram_info.num_channels into a
> bitmask (rev3)
> URL   : https://patchwork.freedesktop.org/series/58299/
> State : success
> 
> == Summary ==
> 
> CI Bug Log - changes from CI_DRM_5785 -> Patchwork_12540
> ====================================================
> 
> Summary
> -------
> 
>   **SUCCESS**
> 
>   No regressions found.
> 
>   External URL:
> https://patchwork.freedesktop.org/api/1.0/series/58299/revisions/3/mbox/
> 
> Known issues
> ------------
> 
>   Here are the changes found in Patchwork_12540 that come from known issues:
> 
> ### IGT changes ###
> 
> #### Issues hit ####
> 
>   * igt@gem_exec_suspend@basic-s4-devices:
>     - fi-blb-e6850:       PASS -> INCOMPLETE [fdo#107718]
> 
>   * igt@i915_pm_rpm@basic-pci-d3-state:
>     - fi-hsw-4770:        PASS -> SKIP [fdo#109271] +3
> 
>   * igt@i915_pm_rpm@module-reload:
>     - fi-skl-6770hq:      PASS -> FAIL [fdo#108511]
>     - fi-skl-6600u:       PASS -> INCOMPLETE [fdo#107807]
> 
>   * igt@i915_selftest@live_evict:
>     - fi-bsw-kefka:       PASS -> DMESG-WARN [fdo#107709]
> 
>   * igt@prime_vgem@basic-fence-flip:
>     - fi-gdg-551:         PASS -> FAIL [fdo#103182]
> 
>   * igt@runner@aborted:
>     - fi-bxt-j4205:       NOTRUN -> FAIL [fdo#109516]
>     - fi-bsw-kefka:       NOTRUN -> FAIL [fdo#107709]
>     - fi-apl-guc:         NOTRUN -> FAIL [fdo#109373]
> 
> 
> #### Possible fixes ####
> 
>   * igt@kms_busy@basic-flip-b:
>     - fi-gdg-551:         FAIL [fdo#103182] -> PASS
> 
>   * igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a-frame-sequence:
>     - fi-byt-clapper:     FAIL [fdo#103191] / [fdo#107362] -> PASS
> 
>   * igt@prime_vgem@basic-fence-flip:
>     - fi-ilk-650:         FAIL [fdo#104008] -> PASS
> 
> 
>   [fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
>   [fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
>   [fdo#104008]: https://bugs.freedesktop.org/show_bug.cgi?id=104008
>   [fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
>   [fdo#107709]: https://bugs.freedesktop.org/show_bug.cgi?id=107709
>   [fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
>   [fdo#107807]: https://bugs.freedesktop.org/show_bug.cgi?id=107807
>   [fdo#108511]: https://bugs.freedesktop.org/show_bug.cgi?id=108511
>   [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
>   [fdo#109373]: https://bugs.freedesktop.org/show_bug.cgi?id=109373
>   [fdo#109516]: https://bugs.freedesktop.org/show_bug.cgi?id=109516
> 
> 
> Participating hosts (47 -> 38)
> ------------------------------
> 
>   Missing    (9): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-hsw-peppy fi-byt-squawks fi-
> bsw-cyan fi-ctg-p8600 fi-pnv-d510 fi-bdw-samus
> 
> 
> Build changes
> -------------
> 
>     * Linux: CI_DRM_5785 -> Patchwork_12540
> 
>   CI_DRM_5785: 1e3d80c25878b7d97ad6c0680a452d55baeb28e0 @
> git://anongit.freedesktop.org/gfx-ci/linux
>   IGT_4894: fedd92f4022837e2c20e472b65bd7d0849f484a3 @
> git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
>   Patchwork_12540: 155ce7c6724938faf44c0c40a5d77581be26512f @
> git://anongit.freedesktop.org/gfx-ci/linux
> 
> 
> == Linux commits ==
> 
> 155ce7c67249 drm/i915: Make sure we have enough memory bandwidth on ICL
> 77f4b2fd475a drm/i915: Turn dram_info.num_channels into a bitmask
> 
> == Logs ==
> 
> For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12540/
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 9e380cd317dc..8b37ec0e0676 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1209,14 +1209,14 @@  skl_dram_get_channels_info(struct drm_i915_private *dev_priv)
 	val = I915_READ(SKL_MAD_DIMM_CH0_0_0_0_MCHBAR_MCMAIN);
 	ret = skl_dram_get_channel_info(dev_priv, &ch0, 0, val);
 	if (ret == 0)
-		dram_info->num_channels++;
+		dram_info->channels |= BIT(0);
 
 	val = I915_READ(SKL_MAD_DIMM_CH1_0_0_0_MCHBAR_MCMAIN);
 	ret = skl_dram_get_channel_info(dev_priv, &ch1, 1, val);
 	if (ret == 0)
-		dram_info->num_channels++;
+		dram_info->channels |= BIT(1);
 
-	if (dram_info->num_channels == 0) {
+	if (dram_info->channels == 0) {
 		DRM_INFO("Number of memory channels is zero\n");
 		return -EINVAL;
 	}
@@ -1285,8 +1285,8 @@  skl_get_dram_info(struct drm_i915_private *dev_priv)
 	mem_freq_khz = DIV_ROUND_UP((val & SKL_REQ_DATA_MASK) *
 				    SKL_MEMORY_FREQ_MULTIPLIER_HZ, 1000);
 
-	dram_info->bandwidth_kbps = dram_info->num_channels *
-							mem_freq_khz * 8;
+	dram_info->bandwidth_kbps = mem_freq_khz *
+		hweight8(dram_info->channels) * 8;
 
 	if (dram_info->bandwidth_kbps == 0) {
 		DRM_INFO("Couldn't get system memory bandwidth\n");
@@ -1380,20 +1380,20 @@  static int
 bxt_get_dram_info(struct drm_i915_private *dev_priv)
 {
 	struct dram_info *dram_info = &dev_priv->dram_info;
-	u32 dram_channels;
 	u32 mem_freq_khz, val;
-	u8 num_active_channels;
+	u8 num_channels = 0;
 	int i;
 
 	val = I915_READ(BXT_P_CR_MC_BIOS_REQ_0_0_0);
 	mem_freq_khz = DIV_ROUND_UP((val & BXT_REQ_DATA_MASK) *
 				    BXT_MEMORY_FREQ_MULTIPLIER_HZ, 1000);
 
-	dram_channels = val & BXT_DRAM_CHANNEL_ACTIVE_MASK;
-	num_active_channels = hweight32(dram_channels);
+	dram_info->channels = (val & BXT_DRAM_CHANNEL_ACTIVE_MASK) >>
+		BXT_DRAM_CHANNEL_ACTIVE_SHIFT;
 
 	/* Each active bit represents 4-byte channel */
-	dram_info->bandwidth_kbps = (mem_freq_khz * num_active_channels * 4);
+	dram_info->bandwidth_kbps = mem_freq_khz *
+		hweight8(dram_info->channels) * 4;
 
 	if (dram_info->bandwidth_kbps == 0) {
 		DRM_INFO("Couldn't get system memory bandwidth\n");
@@ -1411,7 +1411,7 @@  bxt_get_dram_info(struct drm_i915_private *dev_priv)
 		if (val == 0xFFFFFFFF)
 			continue;
 
-		dram_info->num_channels++;
+		num_channels++;
 
 		bxt_get_dimm_info(&dimm, val);
 		type = bxt_get_dimm_type(val);
@@ -1439,6 +1439,8 @@  bxt_get_dram_info(struct drm_i915_private *dev_priv)
 			dram_info->type = type;
 	}
 
+	WARN_ON(num_channels != hweight8(dram_info->channels));
+
 	if (dram_info->type == INTEL_DRAM_UNKNOWN ||
 	    dram_info->ranks == 0) {
 		DRM_INFO("couldn't get memory information\n");
@@ -1472,9 +1474,9 @@  intel_get_dram_info(struct drm_i915_private *dev_priv)
 	if (ret)
 		return;
 
-	DRM_DEBUG_KMS("DRAM bandwidth: %u kBps, channels: %u\n",
+	DRM_DEBUG_KMS("DRAM bandwidth: %u kBps, channels: 0x%x\n",
 		      dram_info->bandwidth_kbps,
-		      dram_info->num_channels);
+		      dram_info->channels);
 
 	DRM_DEBUG_KMS("DRAM ranks: %u, 16Gb DIMMs: %s\n",
 		      dram_info->ranks, yesno(dram_info->is_16gb_dimm));
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 363b2d3e4d50..f638c0c74955 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1832,7 +1832,7 @@  struct drm_i915_private {
 	struct dram_info {
 		bool valid;
 		bool is_16gb_dimm;
-		u8 num_channels;
+		u8 channels; /* bitmask */
 		u8 ranks;
 		u32 bandwidth_kbps;
 		bool symmetric_memory;