aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>2018-12-03 07:50:14 -0500
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>2018-12-04 07:24:18 -0500
commit4d8d9fc7050106cbac8141bd5ed5db3e4abbd5fa (patch)
tree74266b62061efedb8bb004fcb8c855bc164aa6bf /drivers/gpu
parent452420d22d5b41256a0bb82402a797295e525da9 (diff)
drm/i915: Trim unused workaround list entries
The new workaround list allocator grows the list in chunks so will end up with some unused space. Trim it when the initialization phase is done to free up a tiny bit of slab. v2: * Simplify with kmemdup. (Chris Wilson) v3: * Refactor for __size removal. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Link: https://patchwork.freedesktop.org/patch/msgid/20181203125014.3219-8-tvrtko.ursulin@linux.intel.com
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/i915/intel_workarounds.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/gpu/drm/i915/intel_workarounds.c b/drivers/gpu/drm/i915/intel_workarounds.c
index e52bd3f5d526..4f41e326f3f3 100644
--- a/drivers/gpu/drm/i915/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/intel_workarounds.c
@@ -53,8 +53,22 @@ static void wa_init_start(struct i915_wa_list *wal, const char *name)
53 wal->name = name; 53 wal->name = name;
54} 54}
55 55
56#define WA_LIST_CHUNK (1 << 4)
57
56static void wa_init_finish(struct i915_wa_list *wal) 58static void wa_init_finish(struct i915_wa_list *wal)
57{ 59{
60 /* Trim unused entries. */
61 if (!IS_ALIGNED(wal->count, WA_LIST_CHUNK)) {
62 struct i915_wa *list = kmemdup(wal->list,
63 wal->count * sizeof(*list),
64 GFP_KERNEL);
65
66 if (list) {
67 kfree(wal->list);
68 wal->list = list;
69 }
70 }
71
58 if (!wal->count) 72 if (!wal->count)
59 return; 73 return;
60 74
@@ -66,7 +80,7 @@ static void _wa_add(struct i915_wa_list *wal, const struct i915_wa *wa)
66{ 80{
67 unsigned int addr = i915_mmio_reg_offset(wa->reg); 81 unsigned int addr = i915_mmio_reg_offset(wa->reg);
68 unsigned int start = 0, end = wal->count; 82 unsigned int start = 0, end = wal->count;
69 const unsigned int grow = 1 << 4; 83 const unsigned int grow = WA_LIST_CHUNK;
70 struct i915_wa *wa_; 84 struct i915_wa *wa_;
71 85
72 GEM_BUG_ON(!is_power_of_2(grow)); 86 GEM_BUG_ON(!is_power_of_2(grow));