-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drm/i915: support creating LMEM objects
We currently define LMEM, or local memory, as just another memory region, like system memory or stolen, which we can expose to userspace and can be mapped to the CPU via some BAR. Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Abdiel Janulgue <abdiel.janulgue@linux.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/20191025153728.23689-1-chris@chris-wilson.co.uk
- Loading branch information
Matthew Auld
authored and
Chris Wilson
committed
Oct 25, 2019
1 parent
7be8782
commit b908be5
Showing
8 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// SPDX-License-Identifier: MIT | ||
/* | ||
* Copyright © 2019 Intel Corporation | ||
*/ | ||
|
||
#include "intel_memory_region.h" | ||
#include "gem/i915_gem_region.h" | ||
#include "gem/i915_gem_lmem.h" | ||
#include "i915_drv.h" | ||
|
||
const struct drm_i915_gem_object_ops i915_gem_lmem_obj_ops = { | ||
.get_pages = i915_gem_object_get_pages_buddy, | ||
.put_pages = i915_gem_object_put_pages_buddy, | ||
.release = i915_gem_object_release_memory_region, | ||
}; | ||
|
||
bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj) | ||
{ | ||
return obj->ops == &i915_gem_lmem_obj_ops; | ||
} | ||
|
||
struct drm_i915_gem_object * | ||
i915_gem_object_create_lmem(struct drm_i915_private *i915, | ||
resource_size_t size, | ||
unsigned int flags) | ||
{ | ||
return i915_gem_object_create_region(i915->mm.regions[INTEL_REGION_LMEM], | ||
size, flags); | ||
} | ||
|
||
struct drm_i915_gem_object * | ||
__i915_gem_lmem_object_create(struct intel_memory_region *mem, | ||
resource_size_t size, | ||
unsigned int flags) | ||
{ | ||
static struct lock_class_key lock_class; | ||
struct drm_i915_private *i915 = mem->i915; | ||
struct drm_i915_gem_object *obj; | ||
|
||
if (size > BIT(mem->mm.max_order) * mem->mm.chunk_size) | ||
return ERR_PTR(-E2BIG); | ||
|
||
obj = i915_gem_object_alloc(); | ||
if (!obj) | ||
return ERR_PTR(-ENOMEM); | ||
|
||
drm_gem_private_object_init(&i915->drm, &obj->base, size); | ||
i915_gem_object_init(obj, &i915_gem_lmem_obj_ops, &lock_class); | ||
|
||
obj->read_domains = I915_GEM_DOMAIN_WC | I915_GEM_DOMAIN_GTT; | ||
|
||
i915_gem_object_set_cache_coherency(obj, I915_CACHE_NONE); | ||
|
||
i915_gem_object_init_memory_region(obj, mem, flags); | ||
|
||
return obj; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* SPDX-License-Identifier: MIT */ | ||
/* | ||
* Copyright © 2019 Intel Corporation | ||
*/ | ||
|
||
#ifndef __I915_GEM_LMEM_H | ||
#define __I915_GEM_LMEM_H | ||
|
||
#include <linux/types.h> | ||
|
||
struct drm_i915_private; | ||
struct drm_i915_gem_object; | ||
struct intel_memory_region; | ||
|
||
extern const struct drm_i915_gem_object_ops i915_gem_lmem_obj_ops; | ||
|
||
bool i915_gem_object_is_lmem(struct drm_i915_gem_object *obj); | ||
|
||
struct drm_i915_gem_object * | ||
i915_gem_object_create_lmem(struct drm_i915_private *i915, | ||
resource_size_t size, | ||
unsigned int flags); | ||
|
||
struct drm_i915_gem_object * | ||
__i915_gem_lmem_object_create(struct intel_memory_region *mem, | ||
resource_size_t size, | ||
unsigned int flags); | ||
|
||
#endif /* !__I915_GEM_LMEM_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// SPDX-License-Identifier: MIT | ||
/* | ||
* Copyright © 2019 Intel Corporation | ||
*/ | ||
|
||
#include "i915_drv.h" | ||
#include "intel_memory_region.h" | ||
#include "gem/i915_gem_lmem.h" | ||
#include "gem/i915_gem_region.h" | ||
#include "intel_region_lmem.h" | ||
|
||
const struct intel_memory_region_ops intel_region_lmem_ops = { | ||
.init = intel_memory_region_init_buddy, | ||
.release = intel_memory_region_release_buddy, | ||
.create_object = __i915_gem_lmem_object_create, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* SPDX-License-Identifier: MIT */ | ||
/* | ||
* Copyright © 2019 Intel Corporation | ||
*/ | ||
|
||
#ifndef __INTEL_REGION_LMEM_H | ||
#define __INTEL_REGION_LMEM_H | ||
|
||
extern const struct intel_memory_region_ops intel_region_lmem_ops; | ||
|
||
#endif /* !__INTEL_REGION_LMEM_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters