Skip to content

Commit c02e85a

Browse files
committed
drm/i915: Calculate edram size
With gen9+ the edram capabilities are defined so that we can calculate the edram (ellc) size accordingly. Note that there are undefined combinations for some subset of edram capability bits. Return the closest size for undefined indexes. Even if we get it wrong with beginning of future gen enabling, the size information is currently only used for boot message and in debugfs entry. v2: Use function instead of hard to read macro (Daniel) v3: s/INTEL_INFO/INTEL_GEN (Matthew) Signed-off-by: Mika Kuoppala <[email protected]> Reviewed-by: Matthew Auld <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 3accaf7 commit c02e85a

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

drivers/gpu/drm/i915/i915_reg.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6884,6 +6884,9 @@ enum skl_disp_power_wells {
68846884
#define IDIHASHMSK(x) (((x) & 0x3f) << 16)
68856885
#define HSW_EDRAM_CAP _MMIO(0x120010)
68866886
#define EDRAM_ENABLED 0x1
6887+
#define EDRAM_NUM_BANKS(cap) (((cap) >> 1) & 0xf)
6888+
#define EDRAM_WAYS_IDX(cap) (((cap) >> 5) & 0x7)
6889+
#define EDRAM_SETS_IDX(cap) (((cap) >> 8) & 0x3)
68876890

68886891
#define GEN6_UCGCTL1 _MMIO(0x9400)
68896892
# define GEN6_EU_TCUNIT_CLOCK_GATE_DISABLE (1 << 16)

drivers/gpu/drm/i915/intel_uncore.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,17 +315,30 @@ void intel_uncore_forcewake_reset(struct drm_device *dev, bool restore)
315315
spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);
316316
}
317317

318+
static u64 gen9_edram_size(struct drm_i915_private *dev_priv)
319+
{
320+
const unsigned int ways[8] = { 4, 8, 12, 16, 16, 16, 16, 16 };
321+
const unsigned int sets[4] = { 1, 1, 2, 2 };
322+
const u32 cap = dev_priv->edram_cap;
323+
324+
return EDRAM_NUM_BANKS(cap) *
325+
ways[EDRAM_WAYS_IDX(cap)] *
326+
sets[EDRAM_SETS_IDX(cap)] *
327+
1024 * 1024;
328+
}
329+
318330
u64 intel_uncore_edram_size(struct drm_i915_private *dev_priv)
319331
{
320332
if (!HAS_EDRAM(dev_priv))
321333
return 0;
322334

323-
/* The docs do not explain exactly how the calculation can be
324-
* made. It is somewhat guessable, but for now, it's always
325-
* 128MB.
335+
/* The needed capability bits for size calculation
336+
* are not there with pre gen9 so return 128MB always.
326337
*/
338+
if (INTEL_GEN(dev_priv) < 9)
339+
return 128 * 1024 * 1024;
327340

328-
return 128 * 1024 * 1024;
341+
return gen9_edram_size(dev_priv);
329342
}
330343

331344
static void intel_uncore_edram_detect(struct drm_i915_private *dev_priv)

0 commit comments

Comments
 (0)