[Intel-gfx] [PATCH 4/6] drm/i915/gt: Refactor _wa_add to reuse wa_index and wa_list_grow
Tvrtko Ursulin
tvrtko.ursulin at linux.intel.com
Fri Nov 13 10:40:07 UTC 2020
On 12/11/2020 19:44, Chris Wilson wrote:
> Quoting Umesh Nerlige Ramappa (2020-10-10 01:21:03)
>> Switch the search and grow code of the _wa_add to use _wa_index and
>> _wa_list_grow.
>>
>> Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>
>> ---
>> drivers/gpu/drm/i915/gt/intel_workarounds.c | 54 +++++++--------------
>> 1 file changed, 17 insertions(+), 37 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c b/drivers/gpu/drm/i915/gt/intel_workarounds.c
>> index 801fcb60f46b..e49283bffa33 100644
>> --- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
>> +++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
>> @@ -174,53 +174,33 @@ static void _wa_remove(struct i915_wa_list *wal, i915_reg_t reg, u32 flags)
>>
>> static void _wa_add(struct i915_wa_list *wal, const struct i915_wa *wa)
>> {
>> - unsigned int addr = i915_mmio_reg_offset(wa->reg);
>> - unsigned int start = 0, end = wal->count;
>> + int index;
>> const unsigned int grow = WA_LIST_CHUNK;
>> struct i915_wa *wa_;
>>
>> GEM_BUG_ON(!is_power_of_2(grow));
>>
>> - if (IS_ALIGNED(wal->count, grow)) { /* Either uninitialized or full. */
>> - struct i915_wa *list;
>> -
>> - list = kmalloc_array(ALIGN(wal->count + 1, grow), sizeof(*wa),
>> - GFP_KERNEL);
>> - if (!list) {
>> - DRM_ERROR("No space for workaround init!\n");
>> + if (IS_ALIGNED(wal->count, grow)) /* Either uninitialized or full. */
>> + if (_wa_list_grow(wal, wal->count) < 0)
>> return;
>> - }
>> -
>> - if (wal->list)
>> - memcpy(list, wal->list, sizeof(*wa) * wal->count);
>>
>> - wal->list = list;
>
> An inherited problem, but I'm a little unnerved by the apparent leak of
> wa->list here.
>
> Paging Tvrtko to see if he can remember if there's a hidden trick.
I don't see any tricks, just a memory leak for all lists with more than
16 unique registers on the wa list. :(
Regards,
Tvrtko
More information about the Intel-gfx
mailing list