Skip to content

Commit 17cd10a

Browse files
pdandamu-starmatt-auld
authored andcommitted
drm/i915: Add lmem_bar_size modparam
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
1 parent a91d1a1 commit 17cd10a

3 files changed

Lines changed: 32 additions & 5 deletions

File tree

drivers/gpu/drm/i915/gt/intel_region_lmem.c

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,39 @@ static void i915_resize_lmem_bar(struct drm_i915_private *i915, resource_size_t
5151
struct pci_bus *root = pdev->bus;
5252
struct resource *root_res;
5353
resource_size_t rebar_size;
54+
resource_size_t current_size;
5455
u32 pci_cmd;
5556
int i;
5657

57-
rebar_size = roundup_pow_of_two(pci_resource_len(pdev, LMEM_BAR_NUM));
58+
current_size = roundup_pow_of_two(pci_resource_len(pdev, LMEM_BAR_NUM));
5859

59-
if (rebar_size != roundup_pow_of_two(lmem_size))
60-
rebar_size = lmem_size;
61-
else
62-
return;
60+
if (i915->params.lmem_bar_size) {
61+
u32 bar_sizes;
62+
63+
rebar_size = i915->params.lmem_bar_size *
64+
(resource_size_t)SZ_1M;
65+
bar_sizes = pci_rebar_get_possible_sizes(pdev,
66+
LMEM_BAR_NUM);
67+
68+
if (rebar_size == current_size)
69+
return;
70+
71+
if (!(bar_sizes & BIT(pci_rebar_bytes_to_size(rebar_size))) ||
72+
rebar_size >= roundup_pow_of_two(lmem_size)) {
73+
rebar_size = lmem_size;
74+
75+
drm_info(&i915->drm,
76+
"Given bar size is not within supported size, setting it to default: %llu\n",
77+
(u64)lmem_size >> 20);
78+
}
79+
} else {
80+
rebar_size = current_size;
81+
82+
if (rebar_size != roundup_pow_of_two(lmem_size))
83+
rebar_size = lmem_size;
84+
else
85+
return;
86+
}
6387

6488
/* Find out if root bus contains 64bit memory addressing */
6589
while (root->parent)

drivers/gpu/drm/i915/i915_params.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ i915_param_named_unsafe(request_timeout_ms, uint, 0600,
204204

205205
i915_param_named_unsafe(lmem_size, uint, 0400,
206206
"Set the lmem size(in MiB) for each region. (default: 0, all memory)");
207+
i915_param_named_unsafe(lmem_bar_size, uint, 0400,
208+
"Set the lmem bar size(in MiB).");
207209

208210
static __always_inline void _print_param(struct drm_printer *p,
209211
const char *name,

drivers/gpu/drm/i915/i915_params.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ struct drm_printer;
7474
param(char *, force_probe, CONFIG_DRM_I915_FORCE_PROBE, 0400) \
7575
param(unsigned int, request_timeout_ms, CONFIG_DRM_I915_REQUEST_TIMEOUT, CONFIG_DRM_I915_REQUEST_TIMEOUT ? 0600 : 0) \
7676
param(unsigned int, lmem_size, 0, 0400) \
77+
param(unsigned int, lmem_bar_size, 0, 0400) \
7778
/* leave bools at the end to not create holes */ \
7879
param(bool, enable_hangcheck, true, 0600) \
7980
param(bool, load_detect_test, false, 0600) \

0 commit comments

Comments
 (0)