From 7b2d654517e1669fd08af26e620ef8da640fe8d6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 5 Nov 2020 16:05:52 +0100 Subject: [PATCH] 5.9-stable patches added patches: drm-i915-avoid-mixing-integer-types-during-batch-copies.patch drm-i915-break-up-error-capture-compression-loops-with-cond_resched.patch drm-i915-cancel-outstanding-work-after-disabling-heartbeats-on-an-engine.patch drm-i915-fix-tgl-dkl-phy-dp-vswing-handling.patch --- ...ng-integer-types-during-batch-copies.patch | 113 ++++++++++++++++++ ...-compression-loops-with-cond_resched.patch | 48 ++++++++ ...er-disabling-heartbeats-on-an-engine.patch | 68 +++++++++++ ...5-fix-tgl-dkl-phy-dp-vswing-handling.patch | 48 ++++++++ queue-5.9/series | 4 + 5 files changed, 281 insertions(+) create mode 100644 queue-5.9/drm-i915-avoid-mixing-integer-types-during-batch-copies.patch create mode 100644 queue-5.9/drm-i915-break-up-error-capture-compression-loops-with-cond_resched.patch create mode 100644 queue-5.9/drm-i915-cancel-outstanding-work-after-disabling-heartbeats-on-an-engine.patch create mode 100644 queue-5.9/drm-i915-fix-tgl-dkl-phy-dp-vswing-handling.patch diff --git a/queue-5.9/drm-i915-avoid-mixing-integer-types-during-batch-copies.patch b/queue-5.9/drm-i915-avoid-mixing-integer-types-during-batch-copies.patch new file mode 100644 index 00000000000..61c8f10bce2 --- /dev/null +++ b/queue-5.9/drm-i915-avoid-mixing-integer-types-during-batch-copies.patch @@ -0,0 +1,113 @@ +From c60b93cd4862d108214a14e655358ea714d7a12a Mon Sep 17 00:00:00 2001 +From: Chris Wilson +Date: Mon, 28 Sep 2020 22:59:42 +0100 +Subject: drm/i915: Avoid mixing integer types during batch copies + +From: Chris Wilson + +commit c60b93cd4862d108214a14e655358ea714d7a12a upstream. + +Be consistent and use unsigned long throughout the chunk copies to +avoid the inherent clumsiness of mixing integer types of different +widths and signs. Failing to take acount of a wider unsigned type when +using min_t can lead to treating it as a negative, only for it flip back +to a large unsigned value after passing a boundary check. + +Fixes: ed13033f0287 ("drm/i915/cmdparser: Only cache the dst vmap") +Testcase: igt/gen9_exec_parse/bb-large +Reported-by: "Candelaria, Jared" +Signed-off-by: Chris Wilson +Cc: Mika Kuoppala +Cc: Joonas Lahtinen +Cc: "Candelaria, Jared" +Cc: "Bloomfield, Jon" +Cc: # v4.9+ +Reviewed-by: Mika Kuoppala +Link: https://patchwork.freedesktop.org/patch/msgid/20200928215942.31917-1-chris@chris-wilson.co.uk +(cherry picked from commit b7eeb2b4132ccf1a7d38f434cde7043913d1ed3c) +Signed-off-by: Rodrigo Vivi +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c | 7 +++++-- + drivers/gpu/drm/i915/i915_cmd_parser.c | 10 +++++----- + drivers/gpu/drm/i915/i915_drv.h | 4 ++-- + 3 files changed, 12 insertions(+), 9 deletions(-) + +--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c ++++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +@@ -1962,8 +1962,8 @@ struct eb_parse_work { + struct i915_vma *batch; + struct i915_vma *shadow; + struct i915_vma *trampoline; +- unsigned int batch_offset; +- unsigned int batch_length; ++ unsigned long batch_offset; ++ unsigned long batch_length; + }; + + static int __eb_parse(struct dma_fence_work *work) +@@ -2033,6 +2033,9 @@ static int eb_parse_pipeline(struct i915 + struct eb_parse_work *pw; + int err; + ++ GEM_BUG_ON(overflows_type(eb->batch_start_offset, pw->batch_offset)); ++ GEM_BUG_ON(overflows_type(eb->batch_len, pw->batch_length)); ++ + pw = kzalloc(sizeof(*pw), GFP_KERNEL); + if (!pw) + return -ENOMEM; +--- a/drivers/gpu/drm/i915/i915_cmd_parser.c ++++ b/drivers/gpu/drm/i915/i915_cmd_parser.c +@@ -1136,7 +1136,7 @@ find_reg(const struct intel_engine_cs *e + /* Returns a vmap'd pointer to dst_obj, which the caller must unmap */ + static u32 *copy_batch(struct drm_i915_gem_object *dst_obj, + struct drm_i915_gem_object *src_obj, +- u32 offset, u32 length) ++ unsigned long offset, unsigned long length) + { + bool needs_clflush; + void *dst, *src; +@@ -1166,8 +1166,8 @@ static u32 *copy_batch(struct drm_i915_g + } + } + if (IS_ERR(src)) { ++ unsigned long x, n; + void *ptr; +- int x, n; + + /* + * We can avoid clflushing partial cachelines before the write +@@ -1184,7 +1184,7 @@ static u32 *copy_batch(struct drm_i915_g + ptr = dst; + x = offset_in_page(offset); + for (n = offset >> PAGE_SHIFT; length; n++) { +- int len = min_t(int, length, PAGE_SIZE - x); ++ int len = min(length, PAGE_SIZE - x); + + src = kmap_atomic(i915_gem_object_get_page(src_obj, n)); + if (needs_clflush) +@@ -1414,8 +1414,8 @@ static bool shadow_needs_clflush(struct + */ + int intel_engine_cmd_parser(struct intel_engine_cs *engine, + struct i915_vma *batch, +- u32 batch_offset, +- u32 batch_length, ++ unsigned long batch_offset, ++ unsigned long batch_length, + struct i915_vma *shadow, + bool trampoline) + { +--- a/drivers/gpu/drm/i915/i915_drv.h ++++ b/drivers/gpu/drm/i915/i915_drv.h +@@ -1903,8 +1903,8 @@ void intel_engine_init_cmd_parser(struct + void intel_engine_cleanup_cmd_parser(struct intel_engine_cs *engine); + int intel_engine_cmd_parser(struct intel_engine_cs *engine, + struct i915_vma *batch, +- u32 batch_offset, +- u32 batch_length, ++ unsigned long batch_offset, ++ unsigned long batch_length, + struct i915_vma *shadow, + bool trampoline); + #define I915_CMD_PARSER_TRAMPOLINE_SIZE 8 diff --git a/queue-5.9/drm-i915-break-up-error-capture-compression-loops-with-cond_resched.patch b/queue-5.9/drm-i915-break-up-error-capture-compression-loops-with-cond_resched.patch new file mode 100644 index 00000000000..0c2f74c3c3a --- /dev/null +++ b/queue-5.9/drm-i915-break-up-error-capture-compression-loops-with-cond_resched.patch @@ -0,0 +1,48 @@ +From 7d5553147613b50149238ac1385c60e5c7cacb34 Mon Sep 17 00:00:00 2001 +From: Chris Wilson +Date: Wed, 16 Sep 2020 10:00:58 +0100 +Subject: drm/i915: Break up error capture compression loops with cond_resched() + +From: Chris Wilson + +commit 7d5553147613b50149238ac1385c60e5c7cacb34 upstream. + +As the error capture will compress user buffers as directed to by the +user, it can take an arbitrary amount of time and space. Break up the +compression loops with a call to cond_resched(), that will allow other +processes to schedule (avoiding the soft lockups) and also serve as a +warning should we try to make this loop atomic in the future. + +Testcase: igt/gem_exec_capture/many-* +Signed-off-by: Chris Wilson +Cc: Mika Kuoppala +Cc: stable@vger.kernel.org +Reviewed-by: Mika Kuoppala +Link: https://patchwork.freedesktop.org/patch/msgid/20200916090059.3189-2-chris@chris-wilson.co.uk +(cherry picked from commit 293f43c80c0027ff9299036c24218ac705ce584e) +Signed-off-by: Rodrigo Vivi +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpu/drm/i915/i915_gpu_error.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/gpu/drm/i915/i915_gpu_error.c ++++ b/drivers/gpu/drm/i915/i915_gpu_error.c +@@ -311,6 +311,8 @@ static int compress_page(struct i915_vma + + if (zlib_deflate(zstream, Z_NO_FLUSH) != Z_OK) + return -EIO; ++ ++ cond_resched(); + } while (zstream->avail_in); + + /* Fallback to uncompressed if we increase size? */ +@@ -397,6 +399,7 @@ static int compress_page(struct i915_vma + if (!(wc && i915_memcpy_from_wc(ptr, src, PAGE_SIZE))) + memcpy(ptr, src, PAGE_SIZE); + dst->pages[dst->page_count++] = ptr; ++ cond_resched(); + + return 0; + } diff --git a/queue-5.9/drm-i915-cancel-outstanding-work-after-disabling-heartbeats-on-an-engine.patch b/queue-5.9/drm-i915-cancel-outstanding-work-after-disabling-heartbeats-on-an-engine.patch new file mode 100644 index 00000000000..a636dadb218 --- /dev/null +++ b/queue-5.9/drm-i915-cancel-outstanding-work-after-disabling-heartbeats-on-an-engine.patch @@ -0,0 +1,68 @@ +From 7d442ea7c504adcc9798b07cd8f6a0d235fca2da Mon Sep 17 00:00:00 2001 +From: Chris Wilson +Date: Mon, 28 Sep 2020 23:15:08 +0100 +Subject: drm/i915: Cancel outstanding work after disabling heartbeats on an engine + +From: Chris Wilson + +commit 7d442ea7c504adcc9798b07cd8f6a0d235fca2da upstream. + +We only allow persistent requests to remain on the GPU past the closure +of their containing context (and process) so long as they are continuously +checked for hangs or allow other requests to preempt them, as we need to +ensure forward progress of the system. If we allow persistent contexts +to remain on the system after the the hangcheck mechanism is disabled, +the system may grind to a halt. On disabling the mechanism, we sent a +pulse along the engine to remove all executing contexts from the engine +which would check for hung contexts -- but we did not prevent those +contexts from being resubmitted if they survived the final hangcheck. + +Fixes: 9a40bddd47ca ("drm/i915/gt: Expose heartbeat interval via sysfs") +Testcase: igt/gem_ctx_persistence/heartbeat-stop +Signed-off-by: Chris Wilson +Cc: Joonas Lahtinen +Cc: # v5.7+ +Reviewed-by: Tvrtko Ursulin +Acked-by: Joonas Lahtinen +Link: https://patchwork.freedesktop.org/patch/msgid/20200928221510.26044-1-chris@chris-wilson.co.uk +(cherry picked from commit 7a991cd3e3da9a56d5616b62d425db000a3242f2) +Signed-off-by: Rodrigo Vivi +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpu/drm/i915/gt/intel_engine.h | 9 +++++++++ + drivers/gpu/drm/i915/i915_request.c | 5 +++++ + 2 files changed, 14 insertions(+) + +--- a/drivers/gpu/drm/i915/gt/intel_engine.h ++++ b/drivers/gpu/drm/i915/gt/intel_engine.h +@@ -357,4 +357,13 @@ intel_engine_has_preempt_reset(const str + return intel_engine_has_preemption(engine); + } + ++static inline bool ++intel_engine_has_heartbeat(const struct intel_engine_cs *engine) ++{ ++ if (!IS_ACTIVE(CONFIG_DRM_I915_HEARTBEAT_INTERVAL)) ++ return false; ++ ++ return READ_ONCE(engine->props.heartbeat_interval_ms); ++} ++ + #endif /* _INTEL_RINGBUFFER_H_ */ +--- a/drivers/gpu/drm/i915/i915_request.c ++++ b/drivers/gpu/drm/i915/i915_request.c +@@ -549,8 +549,13 @@ bool __i915_request_submit(struct i915_r + if (i915_request_completed(request)) + goto xfer; + ++ if (unlikely(intel_context_is_closed(request->context) && ++ !intel_engine_has_heartbeat(engine))) ++ intel_context_set_banned(request->context); ++ + if (unlikely(intel_context_is_banned(request->context))) + i915_request_set_error_once(request, -EIO); ++ + if (unlikely(fatal_error(request->fence.error))) + __i915_request_skip(request); + diff --git a/queue-5.9/drm-i915-fix-tgl-dkl-phy-dp-vswing-handling.patch b/queue-5.9/drm-i915-fix-tgl-dkl-phy-dp-vswing-handling.patch new file mode 100644 index 00000000000..1dcae286e90 --- /dev/null +++ b/queue-5.9/drm-i915-fix-tgl-dkl-phy-dp-vswing-handling.patch @@ -0,0 +1,48 @@ +From f0b707c125a2e228bcc047cd46040943bef61931 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= +Date: Thu, 1 Oct 2020 01:36:42 +0300 +Subject: drm/i915: Fix TGL DKL PHY DP vswing handling +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ville Syrjälä + +commit f0b707c125a2e228bcc047cd46040943bef61931 upstream. + +The HDMI vs. not-HDMI check got inverted whem the bogus encoder->type +checks were eliminated. So now we're using 0 as the link rate on DP +and potentially non-zero on HDMI, which is exactly the opposite of +what we want. The original bogus check actually worked more correctly +by accident since if would always evaluate to true. Due to this we +now always use the RBR/HBR1 vswing table and never ever the HBR2+ +vswing table. That is probably not a good way to get a high quality +signal at HBR2+ rates. Fix the check so we pick the right table. + +Cc: stable@vger.kernel.org +Cc: Vandita Kulkarni +Cc: Uma Shankar +Fixes: 94641eb6c696 ("drm/i915/display: Fix the encoder type check") +Signed-off-by: Ville Syrjälä +Link: https://patchwork.freedesktop.org/patch/msgid/20200930223642.28565-1-ville.syrjala@linux.intel.com +Reviewed-by: José Roberto de Souza +Reviewed-by: Vandita Kulkarni +(cherry picked from commit 945b18fb4803b01e822ade6aef6cc0b6e4bd644f) +Signed-off-by: Rodrigo Vivi +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/gpu/drm/i915/display/intel_ddi.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/gpu/drm/i915/display/intel_ddi.c ++++ b/drivers/gpu/drm/i915/display/intel_ddi.c +@@ -2655,7 +2655,7 @@ tgl_dkl_phy_ddi_vswing_sequence(struct i + u32 n_entries, val, ln, dpcnt_mask, dpcnt_val; + int rate = 0; + +- if (type == INTEL_OUTPUT_HDMI) { ++ if (type != INTEL_OUTPUT_HDMI) { + struct intel_dp *intel_dp = enc_to_intel_dp(encoder); + + rate = intel_dp->link_rate; diff --git a/queue-5.9/series b/queue-5.9/series index 39ff16f246d..5c36518719e 100644 --- a/queue-5.9/series +++ b/queue-5.9/series @@ -2,3 +2,7 @@ drm-i915-gem-avoid-implicit-vmap-for-highmem-on-x86-32.patch drm-i915-gem-prevent-using-pgprot_writecombine-if-pat-is-not-supported.patch drm-i915-gem-always-test-execution-status-on-closing-the-context.patch drm-i915-gt-always-send-a-pulse-down-the-engine-after-disabling-heartbeat.patch +drm-i915-break-up-error-capture-compression-loops-with-cond_resched.patch +drm-i915-cancel-outstanding-work-after-disabling-heartbeats-on-an-engine.patch +drm-i915-avoid-mixing-integer-types-during-batch-copies.patch +drm-i915-fix-tgl-dkl-phy-dp-vswing-handling.patch -- 2.47.3