Commit 3aae9d08 authored by Abdiel Janulgue's avatar Abdiel Janulgue Committed by Chris Wilson

drm/i915: enumerate and init each supported region

Nothing to enumerate yet...
Signed-off-by: default avatarAbdiel Janulgue <abdiel.janulgue@linux.intel.com>
Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20191018090751.28295-1-matthew.auld@intel.com
parent 253a774b
...@@ -684,6 +684,8 @@ struct i915_gem_mm { ...@@ -684,6 +684,8 @@ struct i915_gem_mm {
*/ */
struct vfsmount *gemfs; struct vfsmount *gemfs;
struct intel_memory_region *regions[INTEL_REGION_UNKNOWN];
struct notifier_block oom_notifier; struct notifier_block oom_notifier;
struct notifier_block vmap_notifier; struct notifier_block vmap_notifier;
struct shrinker shrinker; struct shrinker shrinker;
...@@ -1783,6 +1785,8 @@ IS_SUBPLATFORM(const struct drm_i915_private *i915, ...@@ -1783,6 +1785,8 @@ IS_SUBPLATFORM(const struct drm_i915_private *i915,
#define HAS_IPC(dev_priv) (INTEL_INFO(dev_priv)->display.has_ipc) #define HAS_IPC(dev_priv) (INTEL_INFO(dev_priv)->display.has_ipc)
#define HAS_REGION(i915, i) (INTEL_INFO(i915)->memory_regions & (i))
#define HAS_GT_UC(dev_priv) (INTEL_INFO(dev_priv)->has_gt_uc) #define HAS_GT_UC(dev_priv) (INTEL_INFO(dev_priv)->has_gt_uc)
/* Having GuC is not the same as using GuC */ /* Having GuC is not the same as using GuC */
...@@ -2001,6 +2005,9 @@ int __must_check i915_gem_evict_for_node(struct i915_address_space *vm, ...@@ -2001,6 +2005,9 @@ int __must_check i915_gem_evict_for_node(struct i915_address_space *vm,
unsigned int flags); unsigned int flags);
int i915_gem_evict_vm(struct i915_address_space *vm); int i915_gem_evict_vm(struct i915_address_space *vm);
void i915_gem_cleanup_memory_regions(struct drm_i915_private *i915);
int i915_gem_init_memory_regions(struct drm_i915_private *i915);
/* i915_gem_internal.c */ /* i915_gem_internal.c */
struct drm_i915_gem_object * struct drm_i915_gem_object *
i915_gem_object_create_internal(struct drm_i915_private *dev_priv, i915_gem_object_create_internal(struct drm_i915_private *dev_priv,
......
...@@ -2744,6 +2744,52 @@ int i915_init_ggtt(struct drm_i915_private *i915) ...@@ -2744,6 +2744,52 @@ int i915_init_ggtt(struct drm_i915_private *i915)
return 0; return 0;
} }
void i915_gem_cleanup_memory_regions(struct drm_i915_private *i915)
{
int i;
i915_gem_cleanup_stolen(i915);
for (i = 0; i < INTEL_REGION_UNKNOWN; i++) {
struct intel_memory_region *region = i915->mm.regions[i];
if (region)
intel_memory_region_put(region);
}
}
int i915_gem_init_memory_regions(struct drm_i915_private *i915)
{
int err, i;
/*
* Initialise stolen early so that we may reserve preallocated
* objects for the BIOS to KMS transition.
*/
/* XXX: stolen will become a region at some point */
err = i915_gem_init_stolen(i915);
if (err)
return err;
for (i = 0; i < INTEL_REGION_UNKNOWN; i++) {
struct intel_memory_region *mem = ERR_PTR(-ENODEV);
if (!HAS_REGION(i915, BIT(i)))
continue;
if (IS_ERR(mem)) {
err = PTR_ERR(mem);
goto out_cleanup;
}
}
return 0;
out_cleanup:
i915_gem_cleanup_memory_regions(i915);
return err;
}
static void ggtt_cleanup_hw(struct i915_ggtt *ggtt) static void ggtt_cleanup_hw(struct i915_ggtt *ggtt)
{ {
struct i915_vma *vma, *vn; struct i915_vma *vma, *vn;
...@@ -2781,6 +2827,8 @@ void i915_ggtt_driver_release(struct drm_i915_private *i915) ...@@ -2781,6 +2827,8 @@ void i915_ggtt_driver_release(struct drm_i915_private *i915)
{ {
struct pagevec *pvec; struct pagevec *pvec;
i915_gem_cleanup_memory_regions(i915);
fini_aliasing_ppgtt(&i915->ggtt); fini_aliasing_ppgtt(&i915->ggtt);
ggtt_cleanup_hw(&i915->ggtt); ggtt_cleanup_hw(&i915->ggtt);
...@@ -2790,8 +2838,6 @@ void i915_ggtt_driver_release(struct drm_i915_private *i915) ...@@ -2790,8 +2838,6 @@ void i915_ggtt_driver_release(struct drm_i915_private *i915)
set_pages_array_wb(pvec->pages, pvec->nr); set_pages_array_wb(pvec->pages, pvec->nr);
__pagevec_release(pvec); __pagevec_release(pvec);
} }
i915_gem_cleanup_stolen(i915);
} }
static unsigned int gen6_get_total_gtt_size(u16 snb_gmch_ctl) static unsigned int gen6_get_total_gtt_size(u16 snb_gmch_ctl)
...@@ -3240,11 +3286,7 @@ int i915_ggtt_init_hw(struct drm_i915_private *dev_priv) ...@@ -3240,11 +3286,7 @@ int i915_ggtt_init_hw(struct drm_i915_private *dev_priv)
if (ret) if (ret)
return ret; return ret;
/* ret = i915_gem_init_memory_regions(dev_priv);
* Initialise stolen early so that we may reserve preallocated
* objects for the BIOS to KMS transition.
*/
ret = i915_gem_init_stolen(dev_priv);
if (ret) if (ret)
goto out_gtt_cleanup; goto out_gtt_cleanup;
......
...@@ -160,6 +160,8 @@ struct intel_device_info { ...@@ -160,6 +160,8 @@ struct intel_device_info {
unsigned int page_sizes; /* page sizes supported by the HW */ unsigned int page_sizes; /* page sizes supported by the HW */
u32 memory_regions; /* regions supported by the HW */
u32 display_mmio_offset; u32 display_mmio_offset;
u8 pipe_mask; u8 pipe_mask;
......
...@@ -18,6 +18,10 @@ struct drm_i915_gem_object; ...@@ -18,6 +18,10 @@ struct drm_i915_gem_object;
struct intel_memory_region; struct intel_memory_region;
struct sg_table; struct sg_table;
enum intel_region_id {
INTEL_REGION_UNKNOWN = 0, /* Should be last */
};
#define I915_ALLOC_MIN_PAGE_SIZE BIT(0) #define I915_ALLOC_MIN_PAGE_SIZE BIT(0)
#define I915_ALLOC_CONTIGUOUS BIT(1) #define I915_ALLOC_CONTIGUOUS BIT(1)
......
...@@ -74,6 +74,8 @@ static void mock_device_release(struct drm_device *dev) ...@@ -74,6 +74,8 @@ static void mock_device_release(struct drm_device *dev)
i915_gemfs_fini(i915); i915_gemfs_fini(i915);
i915_gem_cleanup_memory_regions(i915);
drm_mode_config_cleanup(&i915->drm); drm_mode_config_cleanup(&i915->drm);
drm_dev_fini(&i915->drm); drm_dev_fini(&i915->drm);
...@@ -196,6 +198,10 @@ struct drm_i915_private *mock_gem_device(void) ...@@ -196,6 +198,10 @@ struct drm_i915_private *mock_gem_device(void)
WARN_ON(i915_gemfs_init(i915)); WARN_ON(i915_gemfs_init(i915));
err = i915_gem_init_memory_regions(i915);
if (err)
goto err_context;
return i915; return i915;
err_context: err_context:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment