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: Matthew Auld <matthew.auld@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Link: https://patchwork.freedesktop.org/patch/msgid/20210205102026.806699-1-matthew.auld@intel.com Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
2827ce6e54
commit
8ec8ad0f2f
@ -6,14 +6,22 @@
|
||||
#include "intel_memory_region.h"
|
||||
#include "i915_drv.h"
|
||||
|
||||
/* XXX: Hysterical raisins. BIT(inst) needs to just be (inst) at some point. */
|
||||
#define REGION_MAP(type, inst) \
|
||||
BIT((type) + INTEL_MEMORY_TYPE_SHIFT) | BIT(inst)
|
||||
|
||||
static const u32 intel_region_map[] = {
|
||||
[INTEL_REGION_SMEM] = REGION_MAP(INTEL_MEMORY_SYSTEM, 0),
|
||||
[INTEL_REGION_LMEM] = REGION_MAP(INTEL_MEMORY_LOCAL, 0),
|
||||
[INTEL_REGION_STOLEN] = REGION_MAP(INTEL_MEMORY_STOLEN, 0),
|
||||
static const struct {
|
||||
u16 class;
|
||||
u16 instance;
|
||||
} intel_region_map[] = {
|
||||
[INTEL_REGION_SMEM] = {
|
||||
.class = INTEL_MEMORY_SYSTEM,
|
||||
.instance = 0,
|
||||
},
|
||||
[INTEL_REGION_LMEM] = {
|
||||
.class = INTEL_MEMORY_LOCAL,
|
||||
.instance = 0,
|
||||
},
|
||||
[INTEL_REGION_STOLEN] = {
|
||||
.class = INTEL_MEMORY_STOLEN,
|
||||
.instance = 0,
|
||||
},
|
||||
};
|
||||
|
||||
struct intel_memory_region *
|
||||
@ -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++) {
|
||||
struct intel_memory_region *mem = ERR_PTR(-ENODEV);
|
||||
u32 type;
|
||||
u16 type, instance;
|
||||
|
||||
if (!HAS_REGION(i915, BIT(i)))
|
||||
continue;
|
||||
|
||||
type = MEMORY_TYPE_FROM_REGION(intel_region_map[i]);
|
||||
type = intel_region_map[i].class;
|
||||
instance = intel_region_map[i].instance;
|
||||
switch (type) {
|
||||
case INTEL_MEMORY_SYSTEM:
|
||||
mem = i915_gem_shmem_setup(i915);
|
||||
@ -284,9 +293,9 @@ int intel_memory_regions_hw_probe(struct drm_i915_private *i915)
|
||||
goto out_cleanup;
|
||||
}
|
||||
|
||||
mem->id = intel_region_map[i];
|
||||
mem->id = i;
|
||||
mem->type = type;
|
||||
mem->instance = MEMORY_INSTANCE_FROM_REGION(intel_region_map[i]);
|
||||
mem->instance = instance;
|
||||
|
||||
i915->mm.regions[i] = mem;
|
||||
}
|
||||
|
@ -39,11 +39,6 @@ enum intel_region_id {
|
||||
#define REGION_LMEM BIT(INTEL_REGION_LMEM)
|
||||
#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_CONTIGUOUS BIT(1)
|
||||
|
||||
@ -84,9 +79,9 @@ struct intel_memory_region {
|
||||
resource_size_t total;
|
||||
resource_size_t avail;
|
||||
|
||||
unsigned int type;
|
||||
unsigned int instance;
|
||||
unsigned int id;
|
||||
u16 type;
|
||||
u16 instance;
|
||||
enum intel_region_id id;
|
||||
char name[8];
|
||||
|
||||
struct list_head reserved;
|
||||
|
Loading…
Reference in New Issue
Block a user