drm/i915: Add lmem_bar_size modparam
authorPriyanka Dandamudi <priyanka.dandamudi@intel.com>
Wed, 13 Jul 2022 13:02:09 +0000 (18:32 +0530)
committerMatthew Auld <matthew.auld@intel.com>
Wed, 13 Jul 2022 16:47:51 +0000 (17:47 +0100)
For testing purposes, support forcing the lmem_bar_size through a new
modparam. In CI we only have a limited number of configurations for DG2,
but we still need to be reasonably sure we get a usable device (also
verifying we report the correct values for things like
probed_cpu_visible_size etc) with all the potential lmem_bar sizes that
we might expect see in the wild.

v2: Update commit message and a minor modification.(Matt)

v3: Optimised lmem bar size code and modified code to resize
bar maximum upto lmem_size instead of maximum supported size.(Nirmoy)

v4: Optimised lmem bar size code.(Nirmoy)

Signed-off-by: Priyanka Dandamudi <priyanka.dandamudi@intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Nirmoy Das <nirmoy.das@intel.com>
Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220713130209.2573233-3-priyanka.dandamudi@intel.com
drivers/gpu/drm/i915/gt/intel_region_lmem.c
drivers/gpu/drm/i915/i915_params.c
drivers/gpu/drm/i915/i915_params.h

index 0cce4b2fcf60b96b02376090ffbbef9b2a35dd98..6e90032e12e9b790e7f1f3bc1b6d228d8e017faa 100644 (file)
@@ -51,15 +51,39 @@ static void i915_resize_lmem_bar(struct drm_i915_private *i915, resource_size_t
        struct pci_bus *root = pdev->bus;
        struct resource *root_res;
        resource_size_t rebar_size;
+       resource_size_t current_size;
        u32 pci_cmd;
        int i;
 
-       rebar_size = roundup_pow_of_two(pci_resource_len(pdev, LMEM_BAR_NUM));
+       current_size = roundup_pow_of_two(pci_resource_len(pdev, LMEM_BAR_NUM));
 
-       if (rebar_size != roundup_pow_of_two(lmem_size))
-               rebar_size = lmem_size;
-       else
-               return;
+       if (i915->params.lmem_bar_size) {
+               u32 bar_sizes;
+
+               rebar_size = i915->params.lmem_bar_size *
+                       (resource_size_t)SZ_1M;
+               bar_sizes = pci_rebar_get_possible_sizes(pdev,
+                                                        LMEM_BAR_NUM);
+
+               if (rebar_size == current_size)
+                       return;
+
+               if (!(bar_sizes & BIT(pci_rebar_bytes_to_size(rebar_size))) ||
+                   rebar_size >= roundup_pow_of_two(lmem_size)) {
+                       rebar_size = lmem_size;
+
+                       drm_info(&i915->drm,
+                                "Given bar size is not within supported size, setting it to default: %llu\n",
+                                (u64)lmem_size >> 20);
+               }
+       } else {
+               rebar_size = current_size;
+
+               if (rebar_size != roundup_pow_of_two(lmem_size))
+                       rebar_size = lmem_size;
+               else
+                       return;
+       }
 
        /* Find out if root bus contains 64bit memory addressing */
        while (root->parent)
index 701fbc98afa049475d4b8a01074d8554f4ac4d03..6fc475a5db615c36a0115fef1ac3e5268453ae5c 100644 (file)
@@ -204,6 +204,8 @@ i915_param_named_unsafe(request_timeout_ms, uint, 0600,
 
 i915_param_named_unsafe(lmem_size, uint, 0400,
                        "Set the lmem size(in MiB) for each region. (default: 0, all memory)");
+i915_param_named_unsafe(lmem_bar_size, uint, 0400,
+                       "Set the lmem bar size(in MiB).");
 
 static __always_inline void _print_param(struct drm_printer *p,
                                         const char *name,
index b5e7ea45d191d78d6c1e97f746c2cf0d01829848..2733cb6cfe0941a52c95228237022799e24275ea 100644 (file)
@@ -74,6 +74,7 @@ struct drm_printer;
        param(char *, force_probe, CONFIG_DRM_I915_FORCE_PROBE, 0400) \
        param(unsigned int, request_timeout_ms, CONFIG_DRM_I915_REQUEST_TIMEOUT, CONFIG_DRM_I915_REQUEST_TIMEOUT ? 0600 : 0) \
        param(unsigned int, lmem_size, 0, 0400) \
+       param(unsigned int, lmem_bar_size, 0, 0400) \
        /* leave bools at the end to not create holes */ \
        param(bool, enable_hangcheck, true, 0600) \
        param(bool, load_detect_test, false, 0600) \