[PATCH 09/10] wa trim unused

Tvrtko Ursulin tvrtko.ursulin at linux.intel.com
Wed Nov 28 19:28:42 UTC 2018


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
 drivers/gpu/drm/i915/intel_workarounds.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_workarounds.c b/drivers/gpu/drm/i915/intel_workarounds.c
index 5cd273a730ee..0f519b535450 100644
--- a/drivers/gpu/drm/i915/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/intel_workarounds.c
@@ -523,6 +523,17 @@ static void wa_init_finish(struct i915_wa_list *wal)
 	struct i915_wa *wa;
 	unsigned int i;
 
+	/* Trim unused entries. */
+	if (wal->count < wal->__size) {
+		wa = kcalloc(wal->count, sizeof(*wa), GFP_KERNEL);
+		if (wa) {
+			memcpy(wa, wal->list, sizeof(*wa) * wal->count);
+			kfree(wal->list);
+			wal->list = wa;
+			wal->__size = wal->count;
+		}
+	}
+
 for (i = 0, wa = wal->list; i < wal->count; i++, wa++) {
 printk("===wa-%s<%u/%u>: type=%u reg=%x mask=%x val=%x\n",
        wal->name, i, wal->count,
-- 
2.19.1



More information about the Intel-gfx-trybot mailing list