Commit 8ec8ad0f authored by Matthew Auld's avatar Matthew Auld Committed by Daniel Vetter

drm/i915: cleanup the region class/instance encoding

Get rid of the strange REGION_MAP encoding stuff and just use an
explicit class/instance pair for each region. This better matches our
future uAPI where all queryable regions are identified with a u16 class
and u16 instance.

v2: fix whitespace
Signed-off-by: default avatarMatthew Auld <matthew.auld@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/20210205102026.806699-1-matthew.auld@intel.comSigned-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 2827ce6e
...@@ -6,14 +6,22 @@ ...@@ -6,14 +6,22 @@
#include "intel_memory_region.h" #include "intel_memory_region.h"
#include "i915_drv.h" #include "i915_drv.h"
/* XXX: Hysterical raisins. BIT(inst) needs to just be (inst) at some point. */ static const struct {
#define REGION_MAP(type, inst) \ u16 class;
BIT((type) + INTEL_MEMORY_TYPE_SHIFT) | BIT(inst) u16 instance;
} intel_region_map[] = {
static const u32 intel_region_map[] = { [INTEL_REGION_SMEM] = {
[INTEL_REGION_SMEM] = REGION_MAP(INTEL_MEMORY_SYSTEM, 0), .class = INTEL_MEMORY_SYSTEM,
[INTEL_REGION_LMEM] = REGION_MAP(INTEL_MEMORY_LOCAL, 0), .instance = 0,
[INTEL_REGION_STOLEN] = REGION_MAP(INTEL_MEMORY_STOLEN, 0), },
[INTEL_REGION_LMEM] = {
.class = INTEL_MEMORY_LOCAL,
.instance = 0,
},
[INTEL_REGION_STOLEN] = {
.class = INTEL_MEMORY_STOLEN,
.instance = 0,
},
}; };
struct intel_memory_region * struct intel_memory_region *
...@@ -259,12 +267,13 @@ int intel_memory_regions_hw_probe(struct drm_i915_private *i915) ...@@ -259,12 +267,13 @@ int intel_memory_regions_hw_probe(struct drm_i915_private *i915)
for (i = 0; i < ARRAY_SIZE(i915->mm.regions); i++) { for (i = 0; i < ARRAY_SIZE(i915->mm.regions); i++) {
struct intel_memory_region *mem = ERR_PTR(-ENODEV); struct intel_memory_region *mem = ERR_PTR(-ENODEV);
u32 type; u16 type, instance;
if (!HAS_REGION(i915, BIT(i))) if (!HAS_REGION(i915, BIT(i)))
continue; continue;
type = MEMORY_TYPE_FROM_REGION(intel_region_map[i]); type = intel_region_map[i].class;
instance = intel_region_map[i].instance;
switch (type) { switch (type) {
case INTEL_MEMORY_SYSTEM: case INTEL_MEMORY_SYSTEM:
mem = i915_gem_shmem_setup(i915); mem = i915_gem_shmem_setup(i915);
...@@ -284,9 +293,9 @@ int intel_memory_regions_hw_probe(struct drm_i915_private *i915) ...@@ -284,9 +293,9 @@ int intel_memory_regions_hw_probe(struct drm_i915_private *i915)
goto out_cleanup; goto out_cleanup;
} }
mem->id = intel_region_map[i]; mem->id = i;
mem->type = type; mem->type = type;
mem->instance = MEMORY_INSTANCE_FROM_REGION(intel_region_map[i]); mem->instance = instance;
i915->mm.regions[i] = mem; i915->mm.regions[i] = mem;
} }
......
...@@ -39,11 +39,6 @@ enum intel_region_id { ...@@ -39,11 +39,6 @@ enum intel_region_id {
#define REGION_LMEM BIT(INTEL_REGION_LMEM) #define REGION_LMEM BIT(INTEL_REGION_LMEM)
#define REGION_STOLEN BIT(INTEL_REGION_STOLEN) #define REGION_STOLEN BIT(INTEL_REGION_STOLEN)
#define INTEL_MEMORY_TYPE_SHIFT 16
#define MEMORY_TYPE_FROM_REGION(r) (ilog2((r) >> INTEL_MEMORY_TYPE_SHIFT))
#define MEMORY_INSTANCE_FROM_REGION(r) (ilog2((r) & 0xffff))
#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)
...@@ -84,9 +79,9 @@ struct intel_memory_region { ...@@ -84,9 +79,9 @@ struct intel_memory_region {
resource_size_t total; resource_size_t total;
resource_size_t avail; resource_size_t avail;
unsigned int type; u16 type;
unsigned int instance; u16 instance;
unsigned int id; enum intel_region_id id;
char name[8]; char name[8];
struct list_head reserved; struct list_head reserved;
......
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