Skip to content

Commit

Permalink
drm/i915/gt: Allocate i915_fence_reg array
Browse files Browse the repository at this point in the history
Since the number of fence regs can vary dramactically between platforms,
allocate the array on demand so we don't waste as much space.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200316113846.4974-4-chris@chris-wilson.co.uk
  • Loading branch information
Chris Wilson committed Mar 16, 2020
1 parent bd9a4db commit 0b6bc81
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
6 changes: 4 additions & 2 deletions drivers/gpu/drm/i915/gt/intel_ggtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,11 +698,13 @@ static void ggtt_cleanup_hw(struct i915_ggtt *ggtt)
*/
void i915_ggtt_driver_release(struct drm_i915_private *i915)
{
struct i915_ggtt *ggtt = &i915->ggtt;
struct pagevec *pvec;

fini_aliasing_ppgtt(&i915->ggtt);
fini_aliasing_ppgtt(ggtt);

ggtt_cleanup_hw(&i915->ggtt);
intel_ggtt_fini_fences(ggtt);
ggtt_cleanup_hw(ggtt);

pvec = &i915->mm.wc_stash.pvec;
if (pvec->nr) {
Expand Down
10 changes: 10 additions & 0 deletions drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,11 @@ void intel_ggtt_init_fences(struct i915_ggtt *ggtt)
if (intel_vgpu_active(i915))
num_fences = intel_uncore_read(uncore,
vgtif_reg(avail_rs.fence_num));
ggtt->fence_regs = kcalloc(num_fences,
sizeof(*ggtt->fence_regs),
GFP_KERNEL);
if (!ggtt->fence_regs)
num_fences = 0;

/* Initialize fence registers to zero */
for (i = 0; i < num_fences; i++) {
Expand All @@ -871,6 +876,11 @@ void intel_ggtt_init_fences(struct i915_ggtt *ggtt)
intel_ggtt_restore_fences(ggtt);
}

void intel_ggtt_fini_fences(struct i915_ggtt *ggtt)
{
kfree(ggtt->fence_regs);
}

void intel_gt_init_swizzling(struct intel_gt *gt)
{
struct drm_i915_private *i915 = gt->i915;
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/gt/intel_ggtt_fencing.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void i915_gem_object_save_bit_17_swizzle(struct drm_i915_gem_object *obj,
struct sg_table *pages);

void intel_ggtt_init_fences(struct i915_ggtt *ggtt);
void intel_ggtt_fini_fences(struct i915_ggtt *ggtt);

void intel_gt_init_swizzling(struct intel_gt *gt);

Expand Down
5 changes: 3 additions & 2 deletions drivers/gpu/drm/i915/gt/intel_gtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <drm/drm_mm.h>

#include "gt/intel_reset.h"
#include "gt/intel_ggtt_fencing.h"
#include "i915_selftest.h"
#include "i915_vma_types.h"

Expand Down Expand Up @@ -135,6 +134,8 @@ typedef u64 gen8_pte_t;
#define GEN8_PDE_IPS_64K BIT(11)
#define GEN8_PDE_PS_2M BIT(7)

struct i915_fence_reg;

#define for_each_sgt_daddr(__dp, __iter, __sgt) \
__for_each_sgt_daddr(__dp, __iter, __sgt, I915_GTT_PAGE_SIZE)

Expand Down Expand Up @@ -333,7 +334,7 @@ struct i915_ggtt {
u32 pin_bias;

unsigned int num_fences;
struct i915_fence_reg fence_regs[I915_MAX_NUM_FENCES];
struct i915_fence_reg *fence_regs;
struct list_head fence_list;

/**
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/i915/i915_vma.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <drm/drm_mm.h>

#include "gt/intel_ggtt_fencing.h"
#include "gem/i915_gem_object.h"

#include "i915_gem_gtt.h"
Expand Down

0 comments on commit 0b6bc81

Please sign in to comment.