Skip to content

Commit 5d0c938

Browse files
committed
drm/i915/gen11+: Only load DRAM information from pcode
Up to now we were reading some DRAM information from MCHBAR register and from pcode what is already not good but some GEN12(TGL-H and ADL-S) platforms have MCHBAR DRAM information in different offsets. This was notified to HW team that decided that the best alternative is always apply the 16gb_dimm watermark adjustment for GEN12+ platforms and read the remaning DRAM information needed to other display programming from pcode. So here moving the DRAM pcode function to intel_dram.c, removing the duplicated fields from intel_qgv_info, setting and using information from dram_info. v2: - bring back num_points to intel_qgv_info as num_qgv_point can be overwritten in icl_get_qgv_points() - add gen12_get_dram_info() and simplify gen11_get_dram_info() Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com> Signed-off-by: José Roberto de Souza <jose.souza@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210128164312.91160-2-jose.souza@intel.com
1 parent f0b2970 commit 5d0c938

4 files changed

Lines changed: 93 additions & 75 deletions

File tree

‎drivers/gpu/drm/i915/display/intel_bw.c‎

Lines changed: 8 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -20,76 +20,9 @@ struct intel_qgv_point {
2020
struct intel_qgv_info {
2121
struct intel_qgv_point points[I915_NUM_QGV_POINTS];
2222
u8 num_points;
23-
u8 num_channels;
2423
u8 t_bl;
25-
enum intel_dram_type dram_type;
2624
};
2725

28-
static int icl_pcode_read_mem_global_info(struct drm_i915_private *dev_priv,
29-
struct intel_qgv_info *qi)
30-
{
31-
u32 val = 0;
32-
int ret;
33-
34-
ret = sandybridge_pcode_read(dev_priv,
35-
ICL_PCODE_MEM_SUBSYSYSTEM_INFO |
36-
ICL_PCODE_MEM_SS_READ_GLOBAL_INFO,
37-
&val, NULL);
38-
if (ret)
39-
return ret;
40-
41-
if (IS_GEN(dev_priv, 12)) {
42-
switch (val & 0xf) {
43-
case 0:
44-
qi->dram_type = INTEL_DRAM_DDR4;
45-
break;
46-
case 3:
47-
qi->dram_type = INTEL_DRAM_LPDDR4;
48-
break;
49-
case 4:
50-
qi->dram_type = INTEL_DRAM_DDR3;
51-
break;
52-
case 5:
53-
qi->dram_type = INTEL_DRAM_LPDDR3;
54-
break;
55-
default:
56-
MISSING_CASE(val & 0xf);
57-
break;
58-
}
59-
} else if (IS_GEN(dev_priv, 11)) {
60-
switch (val & 0xf) {
61-
case 0:
62-
qi->dram_type = INTEL_DRAM_DDR4;
63-
break;
64-
case 1:
65-
qi->dram_type = INTEL_DRAM_DDR3;
66-
break;
67-
case 2:
68-
qi->dram_type = INTEL_DRAM_LPDDR3;
69-
break;
70-
case 3:
71-
qi->dram_type = INTEL_DRAM_LPDDR4;
72-
break;
73-
default:
74-
MISSING_CASE(val & 0xf);
75-
break;
76-
}
77-
} else {
78-
MISSING_CASE(INTEL_GEN(dev_priv));
79-
qi->dram_type = INTEL_DRAM_LPDDR3; /* Conservative default */
80-
}
81-
82-
qi->num_channels = (val & 0xf0) >> 4;
83-
qi->num_points = (val & 0xf00) >> 8;
84-
85-
if (IS_GEN(dev_priv, 12))
86-
qi->t_bl = qi->dram_type == INTEL_DRAM_DDR4 ? 4 : 16;
87-
else if (IS_GEN(dev_priv, 11))
88-
qi->t_bl = qi->dram_type == INTEL_DRAM_DDR4 ? 4 : 8;
89-
90-
return 0;
91-
}
92-
9326
static int icl_pcode_read_qgv_point_info(struct drm_i915_private *dev_priv,
9427
struct intel_qgv_point *sp,
9528
int point)
@@ -139,11 +72,15 @@ int icl_pcode_restrict_qgv_points(struct drm_i915_private *dev_priv,
13972
static int icl_get_qgv_points(struct drm_i915_private *dev_priv,
14073
struct intel_qgv_info *qi)
14174
{
75+
const struct dram_info *dram_info = &dev_priv->dram_info;
14276
int i, ret;
14377

144-
ret = icl_pcode_read_mem_global_info(dev_priv, qi);
145-
if (ret)
146-
return ret;
78+
qi->num_points = dram_info->num_qgv_points;
79+
80+
if (IS_GEN(dev_priv, 12))
81+
qi->t_bl = dev_priv->dram_info.type == INTEL_DRAM_DDR4 ? 4 : 16;
82+
else if (IS_GEN(dev_priv, 11))
83+
qi->t_bl = dev_priv->dram_info.type == INTEL_DRAM_DDR4 ? 4 : 8;
14784

14885
if (drm_WARN_ON(&dev_priv->drm,
14986
qi->num_points > ARRAY_SIZE(qi->points)))
@@ -209,7 +146,7 @@ static int icl_get_bw_info(struct drm_i915_private *dev_priv, const struct intel
209146
{
210147
struct intel_qgv_info qi = {};
211148
bool is_y_tile = true; /* assume y tile may be used */
212-
int num_channels;
149+
int num_channels = dev_priv->dram_info.num_channels;
213150
int deinterleave;
214151
int ipqdepth, ipqdepthpch;
215152
int dclk_max;
@@ -222,7 +159,6 @@ static int icl_get_bw_info(struct drm_i915_private *dev_priv, const struct intel
222159
"Failed to get memory subsystem information, ignoring bandwidth limits");
223160
return ret;
224161
}
225-
num_channels = qi.num_channels;
226162

227163
deinterleave = DIV_ROUND_UP(num_channels, is_y_tile ? 4 : 2);
228164
dclk_max = icl_sagv_max_dclk(&qi);

‎drivers/gpu/drm/i915/i915_drv.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,14 +609,15 @@ static int i915_driver_hw_probe(struct drm_i915_private *dev_priv)
609609
goto err_msi;
610610

611611
intel_opregion_setup(dev_priv);
612+
613+
intel_pcode_init(dev_priv);
614+
612615
/*
613616
* Fill the dram structure to get the system dram info. This will be
614617
* used for memory latency calculation.
615618
*/
616619
intel_dram_detect(dev_priv);
617620

618-
intel_pcode_init(dev_priv);
619-
620621
intel_bw_init_hw(dev_priv);
621622

622623
return 0;

‎drivers/gpu/drm/i915/i915_drv.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,7 @@ struct drm_i915_private {
11351135
INTEL_DRAM_LPDDR3,
11361136
INTEL_DRAM_LPDDR4
11371137
} type;
1138+
u8 num_qgv_points;
11381139
} dram_info;
11391140

11401141
struct intel_bw_info {

‎drivers/gpu/drm/i915/intel_dram.c‎

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "i915_drv.h"
77
#include "intel_dram.h"
8+
#include "intel_sideband.h"
89

910
struct dram_dimm_info {
1011
u16 size;
@@ -408,6 +409,81 @@ static int bxt_get_dram_info(struct drm_i915_private *i915)
408409
return 0;
409410
}
410411

412+
static int icl_pcode_read_mem_global_info(struct drm_i915_private *dev_priv)
413+
{
414+
struct dram_info *dram_info = &dev_priv->dram_info;
415+
u32 val = 0;
416+
int ret;
417+
418+
ret = sandybridge_pcode_read(dev_priv,
419+
ICL_PCODE_MEM_SUBSYSYSTEM_INFO |
420+
ICL_PCODE_MEM_SS_READ_GLOBAL_INFO,
421+
&val, NULL);
422+
if (ret)
423+
return ret;
424+
425+
if (IS_GEN(dev_priv, 12)) {
426+
switch (val & 0xf) {
427+
case 0:
428+
dram_info->type = INTEL_DRAM_DDR4;
429+
break;
430+
case 3:
431+
dram_info->type = INTEL_DRAM_LPDDR4;
432+
break;
433+
case 4:
434+
dram_info->type = INTEL_DRAM_DDR3;
435+
break;
436+
case 5:
437+
dram_info->type = INTEL_DRAM_LPDDR3;
438+
break;
439+
default:
440+
MISSING_CASE(val & 0xf);
441+
return -1;
442+
}
443+
} else {
444+
switch (val & 0xf) {
445+
case 0:
446+
dram_info->type = INTEL_DRAM_DDR4;
447+
break;
448+
case 1:
449+
dram_info->type = INTEL_DRAM_DDR3;
450+
break;
451+
case 2:
452+
dram_info->type = INTEL_DRAM_LPDDR3;
453+
break;
454+
case 3:
455+
dram_info->type = INTEL_DRAM_LPDDR4;
456+
break;
457+
default:
458+
MISSING_CASE(val & 0xf);
459+
return -1;
460+
}
461+
}
462+
463+
dram_info->num_channels = (val & 0xf0) >> 4;
464+
dram_info->num_qgv_points = (val & 0xf00) >> 8;
465+
466+
return 0;
467+
}
468+
469+
static int gen11_get_dram_info(struct drm_i915_private *i915)
470+
{
471+
int ret = skl_get_dram_info(i915);
472+
473+
if (ret)
474+
return ret;
475+
476+
return icl_pcode_read_mem_global_info(i915);
477+
}
478+
479+
static int gen12_get_dram_info(struct drm_i915_private *i915)
480+
{
481+
/* Always needed for GEN12+ */
482+
i915->dram_info.is_16gb_dimm = true;
483+
484+
return icl_pcode_read_mem_global_info(i915);
485+
}
486+
411487
void intel_dram_detect(struct drm_i915_private *i915)
412488
{
413489
struct dram_info *dram_info = &i915->dram_info;
@@ -423,7 +499,11 @@ void intel_dram_detect(struct drm_i915_private *i915)
423499
if (INTEL_GEN(i915) < 9 || !HAS_DISPLAY(i915))
424500
return;
425501

426-
if (IS_GEN9_LP(i915))
502+
if (INTEL_GEN(i915) >= 12)
503+
ret = gen12_get_dram_info(i915);
504+
else if (INTEL_GEN(i915) >= 11)
505+
ret = gen11_get_dram_info(i915);
506+
else if (IS_GEN9_LP(i915))
427507
ret = bxt_get_dram_info(i915);
428508
else
429509
ret = skl_get_dram_info(i915);

0 commit comments

Comments
 (0)