[PATCH 11/16] [DEBUG] dump before data for comparison
Robert Beckett
bob.beckett at collabora.com
Sun Jun 26 17:50:00 UTC 2022
---
drivers/gpu/drm/i915/gt/selftest_reset.c | 69 ++++++++++++++++++++++--
1 file changed, 66 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/selftest_reset.c b/drivers/gpu/drm/i915/gt/selftest_reset.c
index 75bc7d90c9dc..1d353576bb6b 100644
--- a/drivers/gpu/drm/i915/gt/selftest_reset.c
+++ b/drivers/gpu/drm/i915/gt/selftest_reset.c
@@ -4,6 +4,8 @@
*/
#include <linux/crc32.h>
+#include <linux/highmem.h>
+#include <linux/sched/mm.h>
#include "gem/i915_gem_stolen.h"
#include "intel_region_ttm.h"
@@ -15,6 +17,47 @@
#include "selftests/igt_atomic.h"
#include "selftests/igt_spinner.h"
+static void free_orig(struct page ** pages, unsigned long num_pages)
+{
+ unsigned long page;
+ for (page = 0; page < num_pages && pages[page]; page++)
+ __free_page(pages[page]);
+
+ kvfree(pages);
+}
+
+static struct page ** alloc_orig(unsigned long num_pages)
+{
+ struct page ** pages;
+ unsigned long allocated;
+
+ pages = kvmalloc_array(num_pages, sizeof(struct page *), GFP_KERNEL | __GFP_ZERO);
+ if (!pages) {
+ pr_err("BOB_DEBUG: %s(): failed to alloc array. num_pages=%lu\n",
+ __func__, num_pages);
+ return NULL;
+ }
+
+ for (allocated = 0; allocated < num_pages; ) {
+ unsigned long previous = allocated;
+
+ allocated = alloc_pages_bulk_array(GFP_KERNEL, num_pages, pages);
+ if (previous == allocated)
+ break;
+
+ memalloc_retry_wait(GFP_KERNEL);
+ }
+
+ if (allocated < num_pages) {
+ pr_err("BOB_DEBUG: %s(): failed to alloc pages. num_pages=%lu allocated=%lu\n",
+ __func__, num_pages, allocated);
+ free_orig(pages, num_pages);
+ return NULL;
+ }
+
+ return pages;
+}
+
static int
__igt_reset_stolen(struct intel_gt *gt,
intel_engine_mask_t mask,
@@ -31,6 +74,7 @@ __igt_reset_stolen(struct intel_gt *gt,
void *tmp;
u32 *crc;
int err;
+ struct page **orig;
if (!drm_mm_node_allocated(&ggtt->error_capture))
return 0;
@@ -39,9 +83,17 @@ __igt_reset_stolen(struct intel_gt *gt,
if (!num_pages)
return 0;
- crc = kmalloc_array(num_pages, sizeof(u32), GFP_KERNEL);
- if (!crc)
+ orig = alloc_orig(num_pages);
+ if (!orig) {
+ pr_err("BOB_DEBUG: %s(): failed to alloc orig. sz=0x%llx\n", __func__, num_pages * sizeof(struct page*));
return -ENOMEM;
+ }
+
+ crc = kmalloc_array(num_pages, sizeof(u32), GFP_KERNEL);
+ if (!crc) {
+ err = -ENOMEM;
+ goto err_orig;
+ }
tmp = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!tmp) {
@@ -103,7 +155,11 @@ __igt_reset_stolen(struct intel_gt *gt,
in = (void __force *)s;
if (i915_memcpy_from_wc(tmp, in, PAGE_SIZE))
in = tmp;
+ else
+ pr_err("BOB_DEBUG: %s(): i915_memcpy_from_wc() returned false. page=%ld\n", __func__, (long)page);
+
crc[page] = crc32_le(0, in, PAGE_SIZE);
+ memcpy_to_page(orig[page], 0, in, PAGE_SIZE);
io_mapping_unmap(s);
}
@@ -147,8 +203,13 @@ __igt_reset_stolen(struct intel_gt *gt,
if (x != crc[page] && !busy) {
pr_debug("unused stolen page %pa modified by GPU reset\n",
&page);
- if (count++ == 0)
+ if (count++ == 0) {
+ igt_hexdump(in, PAGE_SIZE);
+ pr_debug("BOB_DEBUG: %s(): orig:\n", __func__);
+ in = kmap(orig[page]);
igt_hexdump(in, PAGE_SIZE);
+ kunmap(orig[page]);
+ }
max = page;
}
@@ -177,6 +238,8 @@ __igt_reset_stolen(struct intel_gt *gt,
kfree(tmp);
err_crc:
kfree(crc);
+err_orig:
+ free_orig(orig, num_pages);
return err;
}
--
2.25.1
More information about the Intel-gfx-trybot
mailing list