diff mbox series

[RFC,126/162] drm/i915/gem: Update shmem available memory

Message ID 20201127120718.454037-127-matthew.auld@intel.com (mailing list archive)
State New, archived
Headers show
Series DG1 + LMEM enabling | expand

Commit Message

Matthew Auld Nov. 27, 2020, 12:06 p.m. UTC
From: Bommu Krishnaiah <krishnaiah.bommu@intel.com>

Update shmem available memory in “intel_memory_region”

Signed-off-by: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: CQ Tang <cq.tang@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Chris Wilson Nov. 27, 2020, 2:04 p.m. UTC | #1
Quoting Matthew Auld (2020-11-27 12:06:42)
> From: Bommu Krishnaiah <krishnaiah.bommu@intel.com>
> 
> Update shmem available memory in “intel_memory_region”

Was avail ever set?
-Chris
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
index b4dd7a709800..f4bac72b3ccd 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
@@ -30,6 +30,7 @@  static int shmem_get_pages(struct drm_i915_gem_object *obj)
 	struct drm_i915_private *i915 = to_i915(obj->base.dev);
 	struct intel_memory_region *mem = obj->mm.region;
 	const unsigned long page_count = obj->base.size / PAGE_SIZE;
+	resource_size_t size = obj->base.size;
 	unsigned long i;
 	struct address_space *mapping;
 	struct sg_table *st;
@@ -184,6 +185,8 @@  static int shmem_get_pages(struct drm_i915_gem_object *obj)
 
 	__i915_gem_object_set_pages(obj, st, sg_page_sizes);
 
+	mem->avail -= size;
+
 	return 0;
 
 err_sg:
@@ -298,6 +301,8 @@  __i915_gem_object_release_shmem(struct drm_i915_gem_object *obj,
 
 void i915_gem_object_put_pages_shmem(struct drm_i915_gem_object *obj, struct sg_table *pages)
 {
+	struct intel_memory_region *mem = obj->mm.region;
+	resource_size_t size = obj->base.size;
 	struct sgt_iter sgt_iter;
 	struct pagevec pvec;
 	struct page *page;
@@ -326,6 +331,8 @@  void i915_gem_object_put_pages_shmem(struct drm_i915_gem_object *obj, struct sg_
 		check_release_pagevec(&pvec);
 	obj->mm.dirty = false;
 
+	mem->avail += size;
+
 	sg_free_table(pages);
 	kfree(pages);
 }