drm/i915: Move a bunch of workaround-related code to its own file
Subsystems (4)
PATCH 1/2 drm/i915: Move a bunch of workaround-related code to its own file
This has grown to be a sizable amount of code, so move it to its own file before we try to refactor anything. For the moment, we are leaving behind the WA BB code and the WAs that get applied (incorrectly) in init_clock_gating, but we will deal with it later.
v2: Use intel_ prefix for code that deals with the hardware (Chris)
v3: Rebased
v4:
- Rebased
- New license header
v5:
- Rebased
- Added some organisational notes to the file (Chris)
v6: Include DOC section in the documentation build (Jani)
--- Documentation/gpu/i915.rst | 6 + drivers/gpu/drm/i915/Makefile | 3 +- drivers/gpu/drm/i915/intel_engine_cs.c | 634 ---------------------------- drivers/gpu/drm/i915/intel_lrc.c | 1 + drivers/gpu/drm/i915/intel_ringbuffer.c | 1 + drivers/gpu/drm/i915/intel_ringbuffer.h | 3 - drivers/gpu/drm/i915/intel_workarounds.c | 684 +++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_workarounds.h | 13 + 8 files changed, 707 insertions(+), 638 deletions(-) create mode 100644 drivers/gpu/drm/i915/intel_workarounds.c create mode 100644 drivers/gpu/drm/i915/intel_workarounds.h
Documentation/gpu/i915.rst +6 -0
@@ -58,6 +58,12 @@ Intel GVT-g Host Support(vGPU device model) .. kernel-doc:: drivers/gpu/drm/i915/intel_gvt.c :internal: +Workarounds +----------- + +.. kernel-doc:: drivers/gpu/drm/i915/intel_workarounds.c + :doc: Hardware workarounds + Display Hardware Handling =========================
drivers/gpu/drm/i915/Makefile +2 -1
@@ -43,7 +43,8 @@ i915-y := i915_drv.o \ intel_csr.o \ intel_device_info.o \ intel_pm.o \ - intel_runtime_pm.o + intel_runtime_pm.o \ + intel_workarounds.o i915-$(CONFIG_COMPAT) += i915_ioc32.o i915-$(CONFIG_DEBUG_FS) += i915_debugfs.o intel_pipe_crc.o
drivers/gpu/drm/i915/intel_engine_cs.c +0 -634
640 lines not on this page · raw message
drivers/gpu/drm/i915/intel_lrc.c +1 -0
@@ -139,6 +139,7 @@#include "i915_gem_render_state.h" #include "intel_lrc_reg.h" #include "intel_mocs.h" +#include "intel_workarounds.h" #define RING_EXECLIST_QFULL (1 << 0x2)#define RING_EXECLIST1_VALID (1 << 0x3)
drivers/gpu/drm/i915/intel_ringbuffer.c +1 -0
@@ -36,6 +36,7 @@#include "i915_gem_render_state.h" #include "i915_trace.h" #include "intel_drv.h" +#include "intel_workarounds.h" /* Rough estimate of the typical request size, performing a flush, * set-context and then emitting the batch.
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -3
@@ -885,9 +885,6 @@ static inline u32 intel_engine_last_submit(struct intel_engine_cs *engine)return READ_ONCE (engine->timeline->seqno); } -int init_workarounds_ring (struct intel_engine_cs *engine); -int intel_ring_workarounds_emit (struct i915_request *rq); -void intel_engine_get_instdone (struct intel_engine_cs *engine,struct intel_instdone *instdone);
drivers/gpu/drm/i915/intel_workarounds.c new file +684 -0
685 lines not on this page · raw message
drivers/gpu/drm/i915/intel_workarounds.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* SPDX-License-Identifier: MIT +* +* Copyright © 2014-2018 Intel Corporation +*/ + +#ifndef _I915_WORKAROUNDS_H_ +#define _I915_WORKAROUNDS_H_ + +int init_workarounds_ring (struct intel_engine_cs *engine); +int intel_ring_workarounds_emit (struct i915_request *rq); + +#endif
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 drm/i915: Split out functions for different kinds of workarounds
There are different kind of workarounds (those that modify registers that live in the context image, those that modify global registers, those that whitelist registers, etc...) and they have different requirements in terms of where they are applied and how. Also, by splitting them apart, it should be easier to decide where a new workaround should go.
v2:
- Add multiple MISSING_CASE
- Rebased
v3:
- Rename mmio_workarounds to gt_workarounds (Chris, Mika)
- Create empty placeholders for BDW and CHV GT WAs
- Rebased
v4: Rebased
v5:
- Rebased
- FORCE_TO_NONPRIV register exists since BDW, so make a path for it to achieve universality, even if empty (Chris)
--- drivers/gpu/drm/i915/i915_gem.c | 3 + drivers/gpu/drm/i915/i915_gem_context.c | 6 + drivers/gpu/drm/i915/intel_lrc.c | 14 +- drivers/gpu/drm/i915/intel_ringbuffer.c | 8 +- drivers/gpu/drm/i915/intel_workarounds.c | 636 +++++++++++++++++++------------ drivers/gpu/drm/i915/intel_workarounds.h | 8 +- 6 files changed, 433 insertions(+), 242 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +3 -0
@@ -35,6 +35,7 @@#include "intel_drv.h" #include "intel_frontbuffer.h" #include "intel_mocs.h" +#include "intel_workarounds.h" #include "i915_gemfs.h" #include <linux/dma-fence-array.h> #include <linux/kthread.h>
@@ -5198,6 +5199,8 @@ int i915_gem_init_hw(struct drm_i915_private *dev_priv) } } +intel_gt_workarounds_apply (dev_priv); +i915_gem_init_swizzling (dev_priv);/*
drivers/gpu/drm/i915/i915_gem_context.c +6 -0
@@ -90,6 +90,7 @@#include <drm/i915_drm.h> #include "i915_drv.h" #include "i915_trace.h" +#include "intel_workarounds.h" #define ALL_L3_SLICES (dev) (1 << NUM_L3_SLICES(dev)) - 1
@@ -459,11 +460,16 @@ static bool needs_preempt_context(struct drm_i915_private *i915)int i915_gem_contexts_init (struct drm_i915_private *dev_priv) {struct i915_gem_context *ctx; +int ret;/* Reassure ourselves we are only called once */ GEM_BUG_ON (dev_priv->kernel_context);GEM_BUG_ON (dev_priv->preempt_context); + ret =intel_ctx_workarounds_init (dev_priv); +if (ret) +return ret; +INIT_LIST_HEAD (&dev_priv->contexts.list);INIT_WORK (&dev_priv->contexts.free_work, contexts_free_worker);init_llist_head (&dev_priv->contexts.free_list);
drivers/gpu/drm/i915/intel_lrc.c +11 -3
@@ -1725,6 +1725,10 @@ static int gen8_init_render_ring(struct intel_engine_cs *engine)if (ret)return ret; + ret =intel_whitelist_workarounds_apply (engine); +if (ret) +return ret; +/* We need to disable the AsyncFlip performance optimisations in order * to use MI_WAIT_FOR_EVENT within the CS. It should already be * programmed to '1' on all products.
@@ -1735,7 +1739,7 @@ static int gen8_init_render_ring(struct intel_engine_cs *engine)I915_WRITE (INSTPM ,_MASKED_BIT_ENABLE (INSTPM_FORCE_ORDERING )); -return init_workarounds_ring (engine); +return 0 ; }static int gen9_init_render_ring (struct intel_engine_cs *engine)
@@ -1746,7 +1750,11 @@ static int gen9_init_render_ring(struct intel_engine_cs *engine)if (ret)return ret; -return init_workarounds_ring (engine); + ret =intel_whitelist_workarounds_apply (engine); +if (ret) +return ret; + +return 0 ; } static void reset_common_ring(struct intel_engine_cs *engine,
@@ -2071,7 +2079,7 @@ static int gen8_init_rcs_context(struct i915_request *rq) {int ret; - ret =intel_ring_workarounds_emit (rq); + ret =intel_ctx_workarounds_emit (rq);if (ret)return ret;
drivers/gpu/drm/i915/intel_ringbuffer.c +6 -2
@@ -600,7 +600,7 @@ static int intel_rcs_ctx_init(struct i915_request *rq) {int ret; - ret =intel_ring_workarounds_emit (rq); + ret =intel_ctx_workarounds_emit (rq);if (ret !=0 )return ret;
@@ -618,6 +618,10 @@ static int init_render_ring(struct intel_engine_cs *engine)if (ret)return ret; + ret =intel_whitelist_workarounds_apply (engine); +if (ret) +return ret; +/* WaTimedSingleVertexDispatch:cl,bw,ctg,elk,ilk,snb */ if (IS_GEN (dev_priv,4 ,6 ))I915_WRITE (MI_MODE ,_MASKED_BIT_ENABLE (VS_TIMER_DISPATCH ));
@@ -659,7 +663,7 @@ static int init_render_ring(struct intel_engine_cs *engine)if (INTEL_GEN (dev_priv) >=6 )I915_WRITE_IMR (engine, ~engine->irq_keep_mask); -return init_workarounds_ring (engine); +return 0 ; }static u32 *gen6_signal (struct i915_request *rq,u32 *cs)
drivers/gpu/drm/i915/intel_workarounds.c +401 -235
824 lines not on this page · raw message
drivers/gpu/drm/i915/intel_workarounds.h +6 -2
@@ -7,7 +7,11 @@#ifndef _I915_WORKAROUNDS_H_#define _I915_WORKAROUNDS_H_ -int init_workarounds_ring (struct intel_engine_cs *engine); -int intel_ring_workarounds_emit (struct i915_request *rq); +int intel_ctx_workarounds_init (struct drm_i915_private *dev_priv); +int intel_ctx_workarounds_emit (struct i915_request *rq); + +void intel_gt_workarounds_apply (struct drm_i915_private *dev_priv); + +int intel_whitelist_workarounds_apply (struct intel_engine_cs *engine);#endif
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Oscar Mateo (2018-04-10 17:12:46)
Quoted 15 lines
This has grown to be a sizable amount of code, so move it to its own file before we try to refactor anything. For the moment, we are leaving behind the WA BB code and the WAs that get applied (incorrectly) in
init_clock_gating, but we will deal with it later.v2: Use
intel_prefix for code that deals with the hardware (Chris)
v3: Rebased
v4:
- Rebased
- New license header
v5:
- Rebased
- Added some organisational notes to the file (Chris)
v6: Include DOC section in the documentation build (Jani)
Quoted 4 lines
Signed-off-by Oscar Mateo <[email protected]>Cc Mika Kuoppala <[email protected]>Cc Jani Nikula <[email protected]>Reviewed-by Chris Wilson <[email protected]>
I presume this impacts your work. Would you rather have this patch in place or land your w/a series first? (Assuming all goes well!) -Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 16 lines · Chris Wilson
Quoting Oscar Mateo (2018-04-10 17:12:46)
Quoted 15 lines
This has grown to be a sizable amount of code, so move it to its own file before we try to refactor anything. For the moment, we are leaving behind the WA BB code and the WAs that get applied (incorrectly) in
init_clock_gating, but we will deal with it later.v2: Use
intel_prefix for code that deals with the hardware (Chris)
v3: Rebased
v4:
- Rebased
- New license header
v5:
- Rebased
- Added some organisational notes to the file (Chris)
v6: Include DOC section in the documentation build (Jani)
Quoted 7 lines
Quoted 4 lines
Signed-off-by Oscar Mateo <[email protected]>Cc Mika Kuoppala <[email protected]>Cc Jani Nikula <[email protected]>Reviewed-by Chris Wilson <[email protected]>I presume this impacts your work. Would you rather have this patch in place or land your w/a series first? (Assuming all goes well!) -Chris
I can do this patch first and I'll rebase the Gen11 WAs series later, no problem (in fact, this refactoring started because it was quite problematic to decide where each Gen11 WA should go).
Thanks for asking!
Oscar
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Oscar Mateo (2018-04-10 17:24:42)
Quoted 23 lines · Chris Wilson
Quoted 20 lines
Quoting Oscar Mateo (2018-04-10 17:12:46)
Quoted 19 lines
This has grown to be a sizable amount of code, so move it to its own file before we try to refactor anything. For the moment, we are leaving behind the WA BB code and the WAs that get applied (incorrectly) in
init_clock_gating, but we will deal with it later.v2: Use
intel_prefix for code that deals with the hardware (Chris)
v3: Rebased
v4:
- Rebased
- New license header
v5:
- Rebased
- Added some organisational notes to the file (Chris)
v6: Include DOC section in the documentation build (Jani)Signed-off-by Oscar Mateo <[email protected]>Cc Mika Kuoppala <[email protected]>Cc Jani Nikula <[email protected]>Reviewed-by Chris Wilson <[email protected]>
Quoted 7 lines
Quoted 3 lines
I presume this impacts your work. Would you rather have this patch in place or land your w/a series first? (Assuming all goes well!) -Chris
I can do this patch first and I'll rebase the Gen11 WAs series later, no problem (in fact, this refactoring started because it was quite problematic to decide where each Gen11 WA should go).
I did a pass to try and make checkpatch happier and pushed. Thanks for the patches, hopefully not causing too much work for you! -Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.CHECKPATCH: warning for series starting with [1/2] drm/i915: Move a bunch of workaround-related code to its own file
In reply to Oscar Mateo== Series Details ==
== Series Details ==
Series: series starting with [1/2] drm/i915: Move a bunch of workaround-related code to its own file
URL : https://patchwork.freedesktop.org/series/41486/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip 8044c5a3e8e3 drm/i915: Move a bunch of workaround-related code to its own file -:742: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #742: new file mode 100644
-:791: ERROR:TRAILING_WHITESPACE: trailing whitespace #791: FILE: drivers/gpu/drm/i915/intel_workarounds.c:45:
+ * $
-:816: WARNING:MACRO_WITH_FLOW_CONTROL: Macros with flow control statements should be avoided #816: FILE: drivers/gpu/drm/i915/intel_workarounds.c:70:
+#define WA_REG(addr, mask, val) do { \
+ const int r = wa_add(dev_priv, (addr), (mask), (val)); \
+ if (r) \
+ return r; \
+ } while (0)
-:822: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'mask' - possible side-effects? #822: FILE: drivers/gpu/drm/i915/intel_workarounds.c:76:
+#define WA_SET_BIT_MASKED(addr, mask) \
+ WA_REG(addr, (mask), _MASKED_BIT_ENABLE(mask))
-:825: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'mask' - possible side-effects? #825: FILE: drivers/gpu/drm/i915/intel_workarounds.c:79:
+#define WA_CLR_BIT_MASKED(addr, mask) \
+ WA_REG(addr, (mask), _MASKED_BIT_DISABLE(mask))
-:828: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'mask' - possible side-effects? #828: FILE: drivers/gpu/drm/i915/intel_workarounds.c:82:
+#define WA_SET_FIELD_MASKED(addr, mask, value) \
+ WA_REG(addr, mask, _MASKED_FIELD(mask, value))
-:955: WARNING:LONG_LINE: line over 100 characters #955: FILE: drivers/gpu/drm/i915/intel_workarounds.c:209:
+ I915_WRITE(GEN9_CSFE_CHICKEN1_RCS, _MASKED_BIT_ENABLE(GEN9_PREEMPT_GPGPU_SYNC_SWITCH_DISABLE));
-:1246: ERROR:SPACING: spaces required around that '=' (ctx:VxW) #1246: FILE: drivers/gpu/drm/i915/intel_workarounds.c:500:
+ ret= wa_ring_whitelist_reg(engine, GEN8_CS_CHICKEN1);
^
-:1290: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #1290: FILE: drivers/gpu/drm/i915/intel_workarounds.c:544:
+ WA_SET_BIT_MASKED(
-:1350: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #1350: FILE: drivers/gpu/drm/i915/intel_workarounds.c:604:
+ WA_SET_BIT_MASKED(
-:1430: WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file #1430: FILE: drivers/gpu/drm/i915/intel_workarounds.c:684:
+}
total: 2 errors, 4 warnings, 5 checks, 1381 lines checked e9f5cebfbf56 drm/i915: Split out functions for different kinds of workarounds -:409: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #409: FILE: drivers/gpu/drm/i915/intel_workarounds.c:364:
+ WA_SET_BIT_MASKED(
-:456: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #456: FILE: drivers/gpu/drm/i915/intel_workarounds.c:399:
+ WA_SET_BIT_MASKED(
-:512: CHECK:BRACES: braces {} should be used on all arms of this statement #512: FILE: drivers/gpu/drm/i915/intel_workarounds.c:450:
+ if (INTEL_GEN(dev_priv) < 8)
[...]
+ else if (IS_BROADWELL(dev_priv))
[...]
+ else if (IS_CHERRYVIEW(dev_priv))
[...]
+ else if (IS_SKYLAKE(dev_priv))
[...]
+ else if (IS_BROXTON(dev_priv))
[...]
+ else if (IS_KABYLAKE(dev_priv))
[...]
+ else if (IS_GEMINILAKE(dev_priv))
[...]
+ else if (IS_COFFEELAKE(dev_priv))
[...]
+ else if (IS_CANNONLAKE(dev_priv))
[...]
+ else {
[...]
-:530: CHECK:BRACES: Unbalanced braces around else statement #530: FILE: drivers/gpu/drm/i915/intel_workarounds.c:468:
+ else {
-:822: WARNING:LINE_SPACING: Missing a blank line after declarations #822: FILE: drivers/gpu/drm/i915/intel_workarounds.c:744:
+ int ret = gen9_whitelist_workarounds_apply(engine);
+ if (ret)
-:851: WARNING:LINE_SPACING: Missing a blank line after declarations #851: FILE: drivers/gpu/drm/i915/intel_workarounds.c:767:
+ int ret = gen9_whitelist_workarounds_apply(engine);
+ if (ret)
-:868: WARNING:LINE_SPACING: Missing a blank line after declarations #868: FILE: drivers/gpu/drm/i915/intel_workarounds.c:781:
+ int ret = gen9_whitelist_workarounds_apply(engine);
+ if (ret)
-:889: WARNING:LINE_SPACING: Missing a blank line after declarations #889: FILE: drivers/gpu/drm/i915/intel_workarounds.c:795:
+ int ret = gen9_whitelist_workarounds_apply(engine);
+ if (ret)
-:933: CHECK:BRACES: braces {} should be used on all arms of this statement #933: FILE: drivers/gpu/drm/i915/intel_workarounds.c:822:
+ if (INTEL_GEN(dev_priv) < 8)
[...]
+ else if (IS_BROADWELL(dev_priv))
[...]
else if (IS_CHERRYVIEW(dev_priv))
[...]
+ err = chv_whitelist_workarounds_apply(engine);
[...]
- err = skl_init_workarounds(engine);
[...]
else if (IS_BROXTON(dev_priv))
[...]
+ err = bxt_whitelist_workarounds_apply(engine);
[...]
- err = kbl_init_workarounds(engine);
[...]
else if (IS_GEMINILAKE(dev_priv))
[...]
+ err = glk_whitelist_workarounds_apply(engine);
[...]
-:959: CHECK:BRACES: Unbalanced braces around else statement #959: FILE: drivers/gpu/drm/i915/intel_workarounds.c:840:
+ else {
total: 0 errors, 4 warnings, 6 checks, 905 lines checked
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.SPARSE: warning for series starting with [1/2] drm/i915: Move a bunch of workaround-related code to its own file
In reply to Oscar Mateo== Series Details ==
== Series Details ==
Series: series starting with [1/2] drm/i915: Move a bunch of workaround-related code to its own file
URL : https://patchwork.freedesktop.org/series/41486/
State : warning
== Summary ==
$ dim sparse origin/drm-tip Commit: drm/i915: Move a bunch of workaround-related code to its own file +drivers/gpu/drm/i915/intel_workarounds.c:684:1: warning: no newline at end of file
Commit: drm/i915: Split out functions for different kinds of workarounds -O:drivers/gpu/drm/i915/intel_workarounds.c:684:1: warning: no newline at end of file +
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx