Takashi Iwai 99c725
From 7d5553147613b50149238ac1385c60e5c7cacb34 Mon Sep 17 00:00:00 2001
Takashi Iwai 99c725
From: Chris Wilson <chris@chris-wilson.co.uk>
Takashi Iwai 99c725
Date: Wed, 16 Sep 2020 10:00:58 +0100
Takashi Iwai 99c725
Subject: [PATCH] drm/i915: Break up error capture compression loops with cond_resched()
Takashi Iwai 99c725
Git-commit: 7d5553147613b50149238ac1385c60e5c7cacb34
Takashi Iwai 99c725
Patch-mainline: v5.10-rc1
Takashi Iwai 99c725
No-fix: 293f43c80c0027ff9299036c24218ac705ce584e
Takashi Iwai 99c725
References: git-fixes
Takashi Iwai 99c725
Takashi Iwai 99c725
As the error capture will compress user buffers as directed to by the
Takashi Iwai 99c725
user, it can take an arbitrary amount of time and space. Break up the
Takashi Iwai 99c725
compression loops with a call to cond_resched(), that will allow other
Takashi Iwai 99c725
processes to schedule (avoiding the soft lockups) and also serve as a
Takashi Iwai 99c725
warning should we try to make this loop atomic in the future.
Takashi Iwai 99c725
Takashi Iwai 99c725
Testcase: igt/gem_exec_capture/many-*
Takashi Iwai 99c725
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Takashi Iwai 99c725
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Takashi Iwai 99c725
Cc: stable@vger.kernel.org
Takashi Iwai 99c725
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Takashi Iwai 99c725
Link: https://patchwork.freedesktop.org/patch/msgid/20200916090059.3189-2-chris@chris-wilson.co.uk
Takashi Iwai 99c725
(cherry picked from commit 293f43c80c0027ff9299036c24218ac705ce584e)
Takashi Iwai 99c725
Takashi Iwai 99c725
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Takashi Iwai 99c725
Acked-by: Takashi Iwai <tiwai@suse.de>
Takashi Iwai 99c725
Takashi Iwai 99c725
---
Takashi Iwai 99c725
 drivers/gpu/drm/i915/i915_gpu_error.c |    3 +++
Takashi Iwai 99c725
 1 file changed, 3 insertions(+)
Takashi Iwai 99c725
Takashi Iwai 99c725
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
Takashi Iwai 99c725
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
Takashi Iwai 99c725
@@ -268,6 +268,8 @@ static int compress_page(struct compress
Takashi Iwai 99c725
 
Takashi Iwai 99c725
 		if (zlib_deflate(zstream, Z_NO_FLUSH) != Z_OK)
Takashi Iwai 99c725
 			return -EIO;
Takashi Iwai 99c725
+
Takashi Iwai 99c725
+		cond_resched();
Takashi Iwai 99c725
 	} while (zstream->avail_in);
Takashi Iwai 99c725
 
Takashi Iwai 99c725
 	/* Fallback to uncompressed if we increase size? */
Takashi Iwai 99c725
@@ -347,6 +349,7 @@ static int compress_page(struct compress
Takashi Iwai 99c725
 	if (!i915_memcpy_from_wc(ptr, src, PAGE_SIZE))
Takashi Iwai 99c725
 		memcpy(ptr, src, PAGE_SIZE);
Takashi Iwai 99c725
 	dst->pages[dst->page_count++] = ptr;
Takashi Iwai 99c725
+	cond_resched();
Takashi Iwai 99c725
 
Takashi Iwai 99c725
 	return 0;
Takashi Iwai 99c725
 }