]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: Test all device memory on probing
authorChris Wilson <chris@chris-wilson.co.uk>
Wed, 8 Dec 2021 15:34:04 +0000 (21:04 +0530)
committerRamalingam C <ramalingam.c@intel.com>
Tue, 14 Dec 2021 09:38:20 +0000 (15:08 +0530)
This extends the previous sanitychecking of device memory to read/write
all the memory on the device during the device probe, ala memtest86,
as an optional module parameter: i915.memtest=1. This is not expected to
be fast, but a reasonably thorough verfification that the device memory
is accessible and doesn't return bit errors.

v2: Rebased.

Suggested-by: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20211208153404.27546-4-ramalingam.c@intel.com
drivers/gpu/drm/i915/i915_params.c
drivers/gpu/drm/i915/i915_params.h
drivers/gpu/drm/i915/intel_memory_region.c

index e07f4cfea63a8c9d79cd95a4841aa7d5d02eff98..525ae832aa9a256a9516a8d5f83f9a9e50fd1318 100644 (file)
@@ -140,6 +140,9 @@ i915_param_named_unsafe(invert_brightness, int, 0400,
 i915_param_named(disable_display, bool, 0400,
        "Disable display (default: false)");
 
+i915_param_named(memtest, bool, 0400,
+       "Perform a read/write test of all device memory on module load (default: off)");
+
 i915_param_named(mmio_debug, int, 0400,
        "Enable the MMIO debug code for the first N failures (default: off). "
        "This may negatively affect performance.");
index 8d725b64592d81f1b4cbcb45fe36e23fe967a990..c9d53ff910a0ef7037066fc01472a796cf3c67e9 100644 (file)
@@ -64,6 +64,7 @@ struct drm_printer;
        param(char *, guc_firmware_path, NULL, 0400) \
        param(char *, huc_firmware_path, NULL, 0400) \
        param(char *, dmc_firmware_path, NULL, 0400) \
+       param(bool, memtest, false, 0400) \
        param(int, mmio_debug, -IS_ENABLED(CONFIG_DRM_I915_DEBUG_MMIO), 0600) \
        param(int, edp_vswing, 0, 0400) \
        param(unsigned int, reset, 3, 0600) \
index 7bfb6df02e725a20a4a53c5eabbc206c940b0d7b..c70d7e286a51248c618b8e8535289ed58b074156 100644 (file)
@@ -93,9 +93,12 @@ static resource_size_t random_page(resource_size_t last)
        return prandom_u32_max(last >> PAGE_SHIFT) << PAGE_SHIFT;
 }
 
-static int iomemtest(struct intel_memory_region *mem, const void *caller)
+static int iomemtest(struct intel_memory_region *mem,
+                    bool test_all,
+                    const void *caller)
 {
        resource_size_t last = resource_size(&mem->region) - PAGE_SIZE;
+       resource_size_t page;
        int err;
 
        /*
@@ -109,17 +112,25 @@ static int iomemtest(struct intel_memory_region *mem, const void *caller)
         * a random offset within as a quick spot check for bad memory.
         */
 
-       err = iopagetest(mem, 0, caller);
-       if (err)
-               return err;
+       if (test_all) {
+               for (page = 0; page <= last; page += PAGE_SIZE) {
+                       err = iopagetest(mem, page, caller);
+                       if (err)
+                               return err;
+               }
+       } else {
+               err = iopagetest(mem, 0, caller);
+               if (err)
+                       return err;
 
-       err = iopagetest(mem, last, caller);
-       if (err)
-               return err;
+               err = iopagetest(mem, last, caller);
+               if (err)
+                       return err;
 
-       err = iopagetest(mem, random_page(last), caller);
-       if (err)
-               return err;
+               err = iopagetest(mem, random_page(last), caller);
+               if (err)
+                       return err;
+       }
 
        return 0;
 }
@@ -188,13 +199,14 @@ void intel_memory_region_debug(struct intel_memory_region *mr,
 static int intel_memory_region_memtest(struct intel_memory_region *mem,
                                       void *caller)
 {
+       struct drm_i915_private *i915 = mem->i915;
        int err = 0;
 
        if (!mem->io_start)
                return 0;
 
-       if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM))
-               err = iomemtest(mem, caller);
+       if (IS_ENABLED(CONFIG_DRM_I915_DEBUG_GEM) || i915->params.memtest)
+               err = iomemtest(mem, i915->params.memtest, caller);
 
        return err;
 }