Re: [Intel-gfx] [PATCH 8/8] drm/i915: Trim unused workaround list entries

2018-11-30 Thread Tvrtko Ursulin


On 30/11/2018 11:49, Chris Wilson wrote:

Quoting Tvrtko Ursulin (2018-11-30 11:32:01)

From: Tvrtko Ursulin 

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.

Signed-off-by: Tvrtko Ursulin 
---
  drivers/gpu/drm/i915/intel_workarounds.c | 13 +
  1 file changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_workarounds.c 
b/drivers/gpu/drm/i915/intel_workarounds.c
index de2bddbc64b4..abfe4b530c23 100644
--- a/drivers/gpu/drm/i915/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/intel_workarounds.c
@@ -55,6 +55,19 @@ static void wa_init_start(struct i915_wa_list *wal, const 
char *name)
  
  static void wa_init_finish(struct i915_wa_list *wal)

  {
+   /* Trim unused entries. */
+   if (wal->count < wal->__size) {
+   struct i915_wa *wa =
+   kcalloc(wal->count, sizeof(*wa), GFP_KERNEL);


kcalloc followed by memcpy, what have you done with Tvrtko?
kmemdup ?


Oh well, the richer the API the easier to forget. :)

Regards,

Tvrtko

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


Re: [Intel-gfx] [PATCH 8/8] drm/i915: Trim unused workaround list entries

2018-11-30 Thread Chris Wilson
Quoting Tvrtko Ursulin (2018-11-30 11:32:01)
> From: Tvrtko Ursulin 
> 
> 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.
> 
> Signed-off-by: Tvrtko Ursulin 
> ---
>  drivers/gpu/drm/i915/intel_workarounds.c | 13 +
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/intel_workarounds.c 
> b/drivers/gpu/drm/i915/intel_workarounds.c
> index de2bddbc64b4..abfe4b530c23 100644
> --- a/drivers/gpu/drm/i915/intel_workarounds.c
> +++ b/drivers/gpu/drm/i915/intel_workarounds.c
> @@ -55,6 +55,19 @@ static void wa_init_start(struct i915_wa_list *wal, const 
> char *name)
>  
>  static void wa_init_finish(struct i915_wa_list *wal)
>  {
> +   /* Trim unused entries. */
> +   if (wal->count < wal->__size) {
> +   struct i915_wa *wa =
> +   kcalloc(wal->count, sizeof(*wa), GFP_KERNEL);

kcalloc followed by memcpy, what have you done with Tvrtko?
kmemdup ?
-Chris
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 8/8] drm/i915: Trim unused workaround list entries

2018-11-30 Thread Tvrtko Ursulin
From: Tvrtko Ursulin 

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.

Signed-off-by: Tvrtko Ursulin 
---
 drivers/gpu/drm/i915/intel_workarounds.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_workarounds.c 
b/drivers/gpu/drm/i915/intel_workarounds.c
index de2bddbc64b4..abfe4b530c23 100644
--- a/drivers/gpu/drm/i915/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/intel_workarounds.c
@@ -55,6 +55,19 @@ static void wa_init_start(struct i915_wa_list *wal, const 
char *name)
 
 static void wa_init_finish(struct i915_wa_list *wal)
 {
+   /* Trim unused entries. */
+   if (wal->count < wal->__size) {
+   struct i915_wa *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;
+   }
+   }
+
if (wal->count)
DRM_DEBUG_DRIVER("Initialized %u %s workarounds\n",
 wal->wa_count, wal->name);
-- 
2.19.1

___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx