drm/i915: SKL+ render decompression support
Subsystems (3)
v4 cover drm/i915: SKL+ render decompression support
From: Ville Syrjälä <[email protected]>
Here's yet another iteration of CCS support.
The first major change is that we now treat fb->offsets[] as raw byte offsets instead of linear offsets since that's what userspace seems to want. This means we'll not allow non-tile aligned offsets except with linear buffers. I still think non-tile aligned offsets are potentially useful for planar formats, but in order to support that we'd either need to pretend that the non-aligned part of the offset is a linear offset within the tile, or we'd need to deal with the actual internal structure of the tile.
The other change is that we now use the LLC/eLLC hotspot avoidance hash mode. The spec is super confusing when it comes to documenting this. In places it claims that we needa to align everything to 2MiB, but in other places it seems to be telling us that we don't need to do that. I've tried to confirm this empirically by randomizing the ppgtt address between rendering to and sampling from the same compressed buffer, and so far I've not seen any corruption. The only minor caveat is that I've not tried this on a machine with eLLC.
Series available here:git://github.com/vsyrjala/linux.git ccs_leftovers_2
Ville Syrjälä (2):
drm/i915: Implement .get_format_info() hook for CCS drm/i915: Add render decompression support
drivers/gpu/drm/i915/i915_reg.h | 29 +++ drivers/gpu/drm/i915/intel_display.c | 386 ++++++++++++++++++++++++++++----- drivers/gpu/drm/i915/intel_engine_cs.c | 13 ++ drivers/gpu/drm/i915/intel_pm.c | 29 ++- drivers/gpu/drm/i915/intel_sprite.c | 5 + include/uapi/drm/drm_fourcc.h | 20 ++ 6 files changed, 422 insertions(+), 60 deletions(-)
Signature · 6 lines
2.13.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v5 2/2 drm/i915: Add render decompression support
From: Ville Syrjälä <[email protected]>
SKL+ display engine can scan out certain kinds of compressed surfaces produced by the render engine. This involved telling the display engine the location of the color control surfae (CCS) which describes which parts of the main surface are compressed and which are not. The location of CCS is provided by userspace as just another plane with its own offset.
Add the required stuff to validate the user provided AUX plane metadata and convert the user provided linear offset into something the hardware can consume.
Due to hardware limitations we require that the main surface and the AUX surface (CCS) be part of the same bo. The hardware also makes life hard by not allowing you to provide separate x/y offsets for the main and AUX surfaces (excpet with NV12), so finding suitable offsets for both requires a bit of work. Assuming we still want keep playing tricks with the offsets. I've just gone with a dumb "search backward for suitable offsets" approach, which is far from optimal, but it works.
Also not all planes will be capable of scanning out compressed surfaces, and eg. 90/270 degree rotation is not supported in combination with decompression either.
This patch may contain work from at least the following people:
* Vandana Kannan <[email protected]>
* Daniel Vetter <[email protected]>
* Ben Widawsky <[email protected]>
v2: Deal with display workarounds 0390, 0531, 1125 (Paulo)
v3: Pretend CCS tiles are regular 128 byte wide Y tiles (Jason)
Put the AUX register defines to the correct place Fix up the slightly bogus rotation check
v4: Use I915_WRITE_FW() due to plane update locking changes
s/return -EINVAL/goto err/ in intel_framebuffer_init() Eliminate a bunch hardcoded numbers in CCS code
v5: Switch to the LLC/eLLC hotspot avoidance hash mode
Skip fence alignemnt check for CCS
Treat fb->offsets[] as a raw byte offset instead of a linear offset
--- drivers/gpu/drm/i915/i915_reg.h | 29 +++ drivers/gpu/drm/i915/intel_display.c | 343 +++++++++++++++++++++++++++------ drivers/gpu/drm/i915/intel_engine_cs.c | 13 ++ drivers/gpu/drm/i915/intel_pm.c | 29 ++- drivers/gpu/drm/i915/intel_sprite.c | 5 + 5 files changed, 359 insertions(+), 60 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +29 -0
@@ -5909,6 +5909,10 @@ enum {#define _PLANE_KEYMSK_2_A 0x70298#define _PLANE_KEYMAX_1_A 0x701a0#define _PLANE_KEYMAX_2_A 0x702a0 +#define _PLANE_AUX_DIST_1_A 0x701c0 +#define _PLANE_AUX_DIST_2_A 0x702c0 +#define _PLANE_AUX_OFFSET_1_A 0x701c4 +#define _PLANE_AUX_OFFSET_2_A 0x702c4#define _PLANE_COLOR_CTL_1_A 0x701CC/* GLK+ */ #define _PLANE_COLOR_CTL_2_A 0x702CC/* GLK+ */ #define _PLANE_COLOR_CTL_3_A 0x703CC/* GLK+ */
@@ -6015,6 +6019,24 @@ enum {#define PLANE_NV12_BUF_CFG (pipe, plane) \ _MMIO_PLANE(plane, _PLANE_NV12_BUF_CFG_1(pipe), _PLANE_NV12_BUF_CFG_2(pipe)) +#define _PLANE_AUX_DIST_1_B 0x711c0 +#define _PLANE_AUX_DIST_2_B 0x712c0 +#define _PLANE_AUX_DIST_1 (pipe) \ + _PIPE(pipe, _PLANE_AUX_DIST_1_A, _PLANE_AUX_DIST_1_B) +#define _PLANE_AUX_DIST_2 (pipe) \ + _PIPE(pipe, _PLANE_AUX_DIST_2_A, _PLANE_AUX_DIST_2_B) +#define PLANE_AUX_DIST (pipe, plane) \ + _MMIO_PLANE(plane, _PLANE_AUX_DIST_1(pipe), _PLANE_AUX_DIST_2(pipe)) + +#define _PLANE_AUX_OFFSET_1_B 0x711c4 +#define _PLANE_AUX_OFFSET_2_B 0x712c4 +#define _PLANE_AUX_OFFSET_1 (pipe) \ + _PIPE(pipe, _PLANE_AUX_OFFSET_1_A, _PLANE_AUX_OFFSET_1_B) +#define _PLANE_AUX_OFFSET_2 (pipe) \ + _PIPE(pipe, _PLANE_AUX_OFFSET_2_A, _PLANE_AUX_OFFSET_2_B) +#define PLANE_AUX_OFFSET (pipe, plane) \ + _MMIO_PLANE(plane, _PLANE_AUX_OFFSET_1(pipe), _PLANE_AUX_OFFSET_2(pipe)) +#define _PLANE_COLOR_CTL_1_B 0x711CC#define _PLANE_COLOR_CTL_2_B 0x712CC#define _PLANE_COLOR_CTL_3_B 0x713CC
@@ -6498,6 +6520,7 @@ enum {# define CHICKEN3_DGMG_DONE_FIX_DISABLE (1 << 2)#define CHICKEN_PAR1_1 _MMIO(0x42080) +#define SKL_DE_COMPRESSED_HASH_MODE (1 << 15)#define DPA_MASK_VBLANK_SRD (1 << 15)#define FORCE_ARB_IDLE_PLANES (1 << 14)#define SKL_EDP_PSR_FIX_RDWRAP (1 << 3)
@@ -6566,6 +6589,7 @@ enum {# define GEN7_CSC1_RHWO_OPT_DISABLE_IN_RCC ((1<<10) | (1<<26))# define GEN9_RHWO_OPTIMIZATION_DISABLE (1<<14)#define COMMON_SLICE_CHICKEN2 _MMIO(0x7014) +# define GEN9_PBE_COMPRESSED_HASH_SELECTION (1<<13)# define GEN9_DISABLE_GATHER_AT_SET_SHADER_COMMON_SLICE (1<<12)# define GEN8_SBE_DISABLE_REPLAY_BUF_OPTIMIZATION (1<<8)# define GEN8_CSC2_SBE_VUE_CACHE_CONSERVATIVE (1<<0)
@@ -7653,6 +7677,7 @@ enum {#define GEN8_SAMPLER_POWER_BYPASS_DIS (1<<1)#define GEN9_HALF_SLICE_CHICKEN7 _MMIO(0xe194) +#define GEN9_SAMPLER_HASH_COMPRESSED_READ_ADDR (1<<8)#define GEN9_ENABLE_YV12_BUGFIX (1<<4)#define GEN9_ENABLE_GPGPU_PREEMPTION (1<<2)
@@ -8869,4 +8894,8 @@ enum {#define GEN9_L3_LRA_1_GPGPU_DEFAULT_VALUE_SKL 0x67F1427F/* " " */ #define GEN9_L3_LRA_1_GPGPU_DEFAULT_VALUE_BXT 0x5FF101FF/* " " */ +#define MMCD_MISC_CTRL _MMIO(0x4ddc)/* skl+ */ +#define MMCD_PCLA (1 << 31) +#define MMCD_HOTSPOT_EN (1 << 27) +#endif /* _I915_REG_H_ */
drivers/gpu/drm/i915/intel_display.c +285 -58
543 lines not on this page · raw message
drivers/gpu/drm/i915/intel_engine_cs.c +13 -0
@@ -825,6 +825,19 @@ static int gen9_init_workarounds(struct intel_engine_cs *engine)I915_WRITE (GAM_ECOCHK ,I915_READ (GAM_ECOCHK ) |ECOCHK_DIS_TLB ); +if (HAS_LLC (dev_priv)) { +/* WaCompressedResourceSamplerPbeMediaNewHashMode:skl,kbl +* +* Must match Display Engine. See +* WaCompressedResourceDisplayNewHashMode. +*/ +WA_SET_BIT_MASKED (COMMON_SLICE_CHICKEN2 , +GEN9_PBE_COMPRESSED_HASH_SELECTION ); +WA_SET_BIT_MASKED (GEN9_HALF_SLICE_CHICKEN7 , +GEN9_SAMPLER_HASH_COMPRESSED_READ_ADDR ); +WA_SET_BIT (MMCD_MISC_CTRL ,MMCD_PCLA |MMCD_HOTSPOT_EN ); + } +/* WaClearFlowControlGpgpuContextSave:skl,bxt,kbl,glk */ /* WaDisablePartialInstShootdown:skl,bxt,kbl,glk */ WA_SET_BIT_MASKED(GEN8_ROW_CHICKEN,
drivers/gpu/drm/i915/intel_pm.c +27 -2
@@ -58,10 +58,24 @@static void gen9_init_clock_gating (struct drm_i915_private *dev_priv) { +if (HAS_LLC (dev_priv)) { +/* +* WaCompressedResourceDisplayNewHashMode:skl,kbl +* Display WA#0390: skl,kbl +* +* Must match Sampler, Pixel Back End, and Media. See +* WaCompressedResourceSamplerPbeMediaNewHashMode. +*/ +I915_WRITE (CHICKEN_PAR1_1 , +I915_READ (CHICKEN_PAR1_1 ) | +SKL_DE_COMPRESSED_HASH_MODE ); + } +/* See Bspec note for PSR2_CTL bit 31, Wa#828:skl,bxt,kbl,cfl */ I915_WRITE (CHICKEN_PAR1_1 ,I915_READ (CHICKEN_PAR1_1 ) |SKL_EDP_PSR_FIX_RDWRAP ); +I915_WRITE (GEN8_CONFIG0 ,I915_READ (GEN8_CONFIG0 ) |GEN9_DEFAULT_FIXES );
@@ -4071,7 +4085,9 @@ skl_ddb_min_alloc(const struct drm_plane_state *pstate,/* For Non Y-tile return 8-blocks */ if (fb->modifier !=I915_FORMAT_MOD_Y_TILED && - fb->modifier != I915_FORMAT_MOD_Yf_TILED) + fb->modifier != I915_FORMAT_MOD_Yf_TILED && + fb->modifier !=I915_FORMAT_MOD_Y_TILED_CCS && + fb->modifier != I915_FORMAT_MOD_Yf_TILED_CCS)return 8 ;/*
@@ -4456,7 +4472,9 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,return 0 ; y_tiled = fb->modifier ==I915_FORMAT_MOD_Y_TILED || - fb->modifier == I915_FORMAT_MOD_Yf_TILED; + fb->modifier == I915_FORMAT_MOD_Yf_TILED || + fb->modifier ==I915_FORMAT_MOD_Y_TILED_CCS || + fb->modifier == I915_FORMAT_MOD_Yf_TILED_CCS; x_tiled = fb->modifier ==I915_FORMAT_MOD_X_TILED ;/* Display WA #1141: kbl,cfl */
@@ -4552,6 +4570,13 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv, res_lines =div_round_up_fixed16 (selected_result, plane_blocks_per_line); +/* Display WA #1125: skl,bxt,kbl,glk */ +if (level ==0 && + (fb->modifier ==I915_FORMAT_MOD_Y_TILED_CCS || + fb->modifier == I915_FORMAT_MOD_Yf_TILED_CCS)) + res_blocks +=fixed_16_16_to_u32_round_up (y_tile_minimum); + +/* Display WA #1126: skl,bxt,kbl,glk */ if (level >=1 && level <=7 ) {if (y_tiled) { res_blocks +=fixed_16_16_to_u32_round_up (y_tile_minimum);
drivers/gpu/drm/i915/intel_sprite.c +5 -0
@@ -244,6 +244,7 @@ skl_update_plane(struct intel_plane *plane,u32 surf_addr = plane_state->main.offset;unsigned int rotation = plane_state->base.rotation;u32 stride =skl_plane_stride (fb,0 , rotation); +u32 aux_stride =skl_plane_stride (fb,1 , rotation);int crtc_x = plane_state->base.dst.x1;int crtc_y = plane_state->base.dst.y1;uint32_t crtc_w =drm_rect_width (&plane_state->base.dst);
@@ -278,6 +279,10 @@ skl_update_plane(struct intel_plane *plane,I915_WRITE_FW (PLANE_OFFSET (pipe, plane_id), (y <<16 ) | x);I915_WRITE_FW (PLANE_STRIDE (pipe, plane_id), stride);I915_WRITE_FW (PLANE_SIZE (pipe, plane_id), (src_h <<16 ) | src_w); +I915_WRITE_FW (PLANE_AUX_DIST (pipe, plane_id), + (plane_state->aux.offset - surf_addr) | aux_stride); +I915_WRITE_FW (PLANE_AUX_OFFSET (pipe, plane_id), + (plane_state->aux.y <<16 ) | plane_state->aux.x);/* program plane scaler */ if (plane_state->scaler_id >=0 ) {
Signature · 6 lines
2.13.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 1/2 drm/i915: Implement .get_format_info() hook for CCS
In reply to [email protected]From: Ville Syrjälä <[email protected]>
SKL+ display engine can scan out certain kinds of compressed surfaces produced by the render engine. This involved telling the display engine the location of the color control surfae (CCS) which describes which parts of the main surface are compressed and which are not. The location of CCS is provided by userspace as just another plane with its own offset.
By providing our own format information for the CCS formats, we should be able to make framebuffer_check() do the right thing for the CCS surface as well.
Note that we'll return the same format info for both Y and Yf tiled format as that's what happens with the non-CCS Y vs. Yf as well. If desired, we could potentially return a unique pointer for each pixel_format+tiling+ccs combination, in which case we immediately be able to tell if any of that stuff changed by just comparing the pointers. But that does sound a bit wasteful space wise.
v2: Drop the 'dev' argument from the hook
v3: Include the description of the CCS surface layout
v4: Pretend CCS tiles are regular 128 byte wide Y tiles (Jason)
--- drivers/gpu/drm/i915/intel_display.c | 43 ++++++++++++++++++++++++++++++++++++ include/uapi/drm/drm_fourcc.h | 20 +++++++++++++++++ 2 files changed, 63 insertions(+)
drivers/gpu/drm/i915/intel_display.c +43 -0
@@ -2438,6 +2438,48 @@ static unsigned int intel_fb_modifier_to_tiling(uint64_t fb_modifier) } } +/* +* 1 byte of CCS actually corresponds to 16x8 pixels on the main +* surface, and the memory layout for the CCS tile is 64x64 bytes. +* But since we're pretending the CCS tile is 128 bytes wide we +* adjust hsub/vsub here accordingly to 8x16 so that the +* bytes<->x/y conversions come out correct. +*/ +static const struct drm_format_info ccs_formats[] = { + { .format =DRM_FORMAT_XRGB8888 , .depth =24 , .num_planes =2 , .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, + { .format =DRM_FORMAT_XBGR8888 , .depth =24 , .num_planes =2 , .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, + { .format =DRM_FORMAT_ARGB8888 , .depth =32 , .num_planes =2 , .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, + { .format =DRM_FORMAT_ABGR8888 , .depth =32 , .num_planes =2 , .cpp = {4 ,1 , }, .hsub =8 , .vsub =16 , }, +}; + +static const struct drm_format_info * +lookup_format_info (const struct drm_format_info formats[], +int num_formats,u32 format) +{ +int i; + +for (i =0 ; i < num_formats; i++) { +if (formats[i].format == format) +return &formats[i]; + } + +return NULL ; +} + +static const struct drm_format_info * +intel_get_format_info (const struct drm_mode_fb_cmd2 *cmd) +{ +switch (cmd->modifier[0 ]) { +case I915_FORMAT_MOD_Y_TILED_CCS : +case I915_FORMAT_MOD_Yf_TILED_CCS: +return lookup_format_info (ccs_formats, +ARRAY_SIZE (ccs_formats), + cmd->pixel_format); +default : +return NULL ; + } +} +static int intel_fill_fb_info (struct drm_i915_private *dev_priv,struct drm_framebuffer *fb)
@@ -14590,6 +14632,7 @@ static void intel_atomic_state_free(struct drm_atomic_state *state)static const struct drm_mode_config_funcs intel_mode_funcs = { .fb_create = intel_user_framebuffer_create, + .get_format_info = intel_get_format_info, .output_poll_changed = intel_fbdev_output_poll_changed, .atomic_check = intel_atomic_check, .atomic_commit = intel_atomic_commit,
include/uapi/drm/drm_fourcc.h +20 -0
@@ -252,6 +252,26 @@ extern "C" {#define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3)/* +* Intel color control surface (CCS) for render compression +* +* The framebuffer format must be one of the 8:8:8:8 RGB formats. +* The main surface will be plane index 0 and must be Y/Yf-tiled, +* the CCS will be plane index 1. +* +* Each CCS tile matches a 1024x512 pixel area of the main surface. +* To match certain aspects of the 3D hardware the CCS is +* considered to be made up of normal 128Bx32 Y tiles, Thus +* the CCS pitch must be specified in multiples of 128 bytes. +* +* In reality the CCS tile appears to be a 64Bx64 Y tile, composed +* of QWORD (8 bytes) chunks instead of OWORD (16 bytes) chunks. +* But that fact is not relevant unless the memory is accessed +* directly. +*/ +#define I915_FORMAT_MOD_Y_TILED_CCS fourcc_mod_code(INTEL, 4) +#define I915_FORMAT_MOD_Yf_TILED_CCS fourcc_mod_code(INTEL, 5) + +/* * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks * * Macroblocks are laid in a Z-shape, and each pixel data is following the
Signature · 6 lines
2.13.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/i915: SKL+ render decompression support (rev5)
In reply to [email protected]== Series Details ==
== Series Details ==
Series: drm/i915: SKL+ render decompression support (rev5)
URL : https://patchwork.freedesktop.org/series/17507/
State : success
== Summary ==
Series 17507v5 drm/i915: SKL+ render decompression support
https://patchwork.freedesktop.org/api/1.0/series/17507/revisions/5/mbox/
Test gem_exec_suspend:
Subgroup basic-s4-devices:
dmesg-warn -> PASS (fi-kbl-7560u) fdo#100125 +1fdo#100125 https://bugs.freedesktop.org/show_bug.cgi?id=100125
fi-bdw-5557u total:278 pass:267 dwarn:0 dfail:0 fail:0 skip:11 time:445s fi-bdw-gvtdvm total:278 pass:256 dwarn:8 dfail:0 fail:0 skip:14 time:437s fi-bsw-n3050 total:278 pass:242 dwarn:0 dfail:0 fail:0 skip:36 time:585s fi-bxt-j4205 total:278 pass:259 dwarn:0 dfail:0 fail:0 skip:19 time:522s fi-byt-j1900 total:278 pass:254 dwarn:0 dfail:0 fail:0 skip:24 time:493s fi-byt-n2820 total:278 pass:250 dwarn:0 dfail:0 fail:0 skip:28 time:484s fi-glk-2a total:278 pass:259 dwarn:0 dfail:0 fail:0 skip:19 time:585s fi-hsw-4770 total:278 pass:262 dwarn:0 dfail:0 fail:0 skip:16 time:430s fi-hsw-4770r total:278 pass:262 dwarn:0 dfail:0 fail:0 skip:16 time:408s fi-ilk-650 total:278 pass:228 dwarn:0 dfail:0 fail:0 skip:50 time:419s fi-ivb-3520m total:278 pass:260 dwarn:0 dfail:0 fail:0 skip:18 time:497s fi-ivb-3770 total:278 pass:260 dwarn:0 dfail:0 fail:0 skip:18 time:463s fi-kbl-7500u total:278 pass:260 dwarn:0 dfail:0 fail:0 skip:18 time:469s fi-kbl-7560u total:278 pass:268 dwarn:0 dfail:0 fail:0 skip:10 time:568s fi-kbl-r total:278 pass:259 dwarn:1 dfail:0 fail:0 skip:18 time:570s fi-skl-6260u total:278 pass:268 dwarn:0 dfail:0 fail:0 skip:10 time:467s fi-skl-6700hq total:278 pass:228 dwarn:1 dfail:0 fail:27 skip:22 time:411s fi-skl-6700k total:278 pass:256 dwarn:4 dfail:0 fail:0 skip:18 time:467s fi-skl-6770hq total:278 pass:268 dwarn:0 dfail:0 fail:0 skip:10 time:479s fi-skl-gvtdvm total:278 pass:265 dwarn:0 dfail:0 fail:0 skip:13 time:430s fi-snb-2520m total:278 pass:250 dwarn:0 dfail:0 fail:0 skip:28 time:532s fi-snb-2600 total:278 pass:248 dwarn:0 dfail:0 fail:1 skip:29 time:403s
d4bedb8b0f9ba91df2e8cb136a489145a83e96a7 drm-tip: 2017y-06m-13d-14h-22m-46s UTC integration manifest 576fe47 drm/i915: Add render decompression support
ce0fbb3 drm/i915: Implement .get_format_info() hook for CCS
== Logs ==
For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4942/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx