[Intel-gfx] [RFC PATCH 126/162] drm/i915/gem: Update shmem available memory

Matthew Auld matthew.auld at intel.com
Fri Nov 27 12:06:42 UTC 2020


From: Bommu Krishnaiah <krishnaiah.bommu at intel.com>

Update shmem available memory in “intel_memory_region”

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

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);
 }
-- 
2.26.2



More information about the Intel-gfx mailing list