Skip to content

Commit 651d794

Browse files
ickledanvet
authored andcommitted
drm/i915: Use Write-Through cacheing for the display plane on Iris
Haswell GT3e has the unique feature of supporting Write-Through cacheing of objects within the eLLC/LLC. The purpose of this is to enable the display plane to remain coherent whilst objects lie resident in the eLLC/LLC - so that we, in theory, get the best of both worlds, perfect display and fast access. However, we still need to be careful as the CPU does not see the WT when accessing the cache. In particular, this means that we need to flush the cache lines after writing to an object through the CPU, and on transitioning from a cached state to WT. v2: Actually do the clflush on transition to WT, nagging by Ville. v3: Flush the CPU cache after writes into WT objects. v4: Rease onto LLC updates and report WT as "uncached" for get_cache_level_ioctl to remain symmetric with set_cache_level_ioctl. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Cc: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent ea04cb3 commit 651d794

5 files changed

Lines changed: 29 additions & 4 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,9 @@ static int i915_getparam(struct drm_device *dev, void *data,
976976
case I915_PARAM_HAS_LLC:
977977
value = HAS_LLC(dev);
978978
break;
979+
case I915_PARAM_HAS_WT:
980+
value = HAS_WT(dev);
981+
break;
979982
case I915_PARAM_HAS_ALIASING_PPGTT:
980983
value = dev_priv->mm.aliasing_ppgtt ? 1 : 0;
981984
break;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ enum i915_cache_level {
454454
caches, eg sampler/render caches, and the
455455
large Last-Level-Cache. LLC is coherent with
456456
the CPU, but L3 is only visible to the GPU. */
457+
I915_CACHE_WT, /* hsw:gt3e WriteThrough for scanouts */
457458
};
458459

459460
typedef uint32_t gen6_gtt_pte_t;
@@ -1385,7 +1386,7 @@ struct drm_i915_gem_object {
13851386
unsigned int pending_fenced_gpu_access:1;
13861387
unsigned int fenced_gpu_access:1;
13871388

1388-
unsigned int cache_level:2;
1389+
unsigned int cache_level:3;
13891390

13901391
unsigned int has_aliasing_ppgtt_mapping:1;
13911392
unsigned int has_global_gtt_mapping:1;
@@ -1530,6 +1531,7 @@ struct drm_i915_file_private {
15301531
#define HAS_BLT(dev) (INTEL_INFO(dev)->has_blt_ring)
15311532
#define HAS_VEBOX(dev) (INTEL_INFO(dev)->has_vebox_ring)
15321533
#define HAS_LLC(dev) (INTEL_INFO(dev)->has_llc)
1534+
#define HAS_WT(dev) (IS_HASWELL(dev) && to_i915(dev)->ellc_size)
15331535
#define I915_NEED_GFX_HWS(dev) (INTEL_INFO(dev)->need_gfx_hws)
15341536

15351537
#define HAS_HW_CONTEXTS(dev) (INTEL_INFO(dev)->gen >= 6)

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3471,7 +3471,16 @@ int i915_gem_get_caching_ioctl(struct drm_device *dev, void *data,
34713471
goto unlock;
34723472
}
34733473

3474-
args->caching = obj->cache_level != I915_CACHE_NONE;
3474+
switch (obj->cache_level) {
3475+
case I915_CACHE_LLC:
3476+
case I915_CACHE_L3_LLC:
3477+
args->caching = I915_CACHING_CACHED;
3478+
break;
3479+
3480+
default:
3481+
args->caching = I915_CACHING_NONE;
3482+
break;
3483+
}
34753484

34763485
drm_gem_object_unreference(&obj->base);
34773486
unlock:
@@ -3565,7 +3574,8 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
35653574
* of uncaching, which would allow us to flush all the LLC-cached data
35663575
* with that bit in the PTE to main memory with just one PIPE_CONTROL.
35673576
*/
3568-
ret = i915_gem_object_set_cache_level(obj, I915_CACHE_NONE);
3577+
ret = i915_gem_object_set_cache_level(obj,
3578+
HAS_WT(obj->base.dev) ? I915_CACHE_WT : I915_CACHE_NONE);
35693579
if (ret)
35703580
goto err_unpin_display;
35713581

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#define HSW_WB_LLC_AGE3 HSW_CACHEABILITY_CONTROL(0x2)
5656
#define HSW_WB_LLC_AGE0 HSW_CACHEABILITY_CONTROL(0x3)
5757
#define HSW_WB_ELLC_LLC_AGE0 HSW_CACHEABILITY_CONTROL(0xb)
58+
#define HSW_WT_ELLC_LLC_AGE0 HSW_CACHEABILITY_CONTROL(0x6)
5859

5960
static gen6_gtt_pte_t snb_pte_encode(dma_addr_t addr,
6061
enum i915_cache_level level)
@@ -138,8 +139,16 @@ static gen6_gtt_pte_t iris_pte_encode(dma_addr_t addr,
138139
gen6_gtt_pte_t pte = GEN6_PTE_VALID;
139140
pte |= HSW_PTE_ADDR_ENCODE(addr);
140141

141-
if (level != I915_CACHE_NONE)
142+
switch (level) {
143+
case I915_CACHE_NONE:
144+
break;
145+
case I915_CACHE_WT:
146+
pte |= HSW_WT_ELLC_LLC_AGE0;
147+
break;
148+
default:
142149
pte |= HSW_WB_ELLC_LLC_AGE0;
150+
break;
151+
}
143152

144153
return pte;
145154
}

‎include/uapi/drm/i915_drm.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ typedef struct drm_i915_irq_wait {
334334
#define I915_PARAM_HAS_PINNED_BATCHES 24
335335
#define I915_PARAM_HAS_EXEC_NO_RELOC 25
336336
#define I915_PARAM_HAS_EXEC_HANDLE_LUT 26
337+
#define I915_PARAM_HAS_WT 27
337338

338339
typedef struct drm_i915_getparam {
339340
int param;

0 commit comments

Comments
 (0)