[RFC,2/2] drm/i915: implement dumb_size_available callback
diff mbox series

Message ID 20200121015305.10597-3-ramalingam.c@intel.com
State New
Headers show
Series
  • dumb buffer max size available
Related show

Commit Message

Ramalingam C Jan. 21, 2020, 1:53 a.m. UTC
dumb_size_available callback for drm_driver is implemented at I915.

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.c |  1 +
 drivers/gpu/drm/i915/i915_drv.h |  3 +++
 drivers/gpu/drm/i915/i915_gem.c | 17 +++++++++++++++++
 3 files changed, 21 insertions(+)

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index f7385abdd74b..8889e635d17d 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -2773,6 +2773,7 @@  static struct drm_driver driver = {
 	.get_scanout_position = i915_get_crtc_scanoutpos,
 
 	.dumb_create = i915_gem_dumb_create,
+	.dumb_size_available = i915_gem_dumb_size_available,
 	.dumb_map_offset = i915_gem_dumb_mmap_offset,
 
 	.ioctls = i915_ioctls,
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index e7be4c3e43c6..c6912453be67 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1865,6 +1865,9 @@  i915_mutex_lock_interruptible(struct drm_device *dev)
 int i915_gem_dumb_create(struct drm_file *file_priv,
 			 struct drm_device *dev,
 			 struct drm_mode_create_dumb *args);
+int i915_gem_dumb_size_available(struct drm_file *file_priv,
+				 struct drm_device *dev,
+				 uint64_t *avail_size);
 
 int __must_check i915_gem_set_global_seqno(struct drm_device *dev, u32 seqno);
 
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 94f993e4c12f..b8fbc4af7e6d 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -277,6 +277,23 @@  i915_gem_dumb_create(struct drm_file *file,
 			       &args->size, &args->handle);
 }
 
+int i915_gem_dumb_size_available(struct drm_file *file,
+				 struct drm_device *dev, uint64_t *avail_size)
+{
+	enum intel_memory_type mem_type = HAS_LMEM(to_i915(dev)) ?
+						INTEL_MEMORY_LOCAL :
+						INTEL_MEMORY_SYSTEM;
+	struct intel_memory_region *mr;
+
+	mr = intel_memory_region_by_type(to_i915(dev), mem_type);
+	if (!mr)
+		return -EINVAL;
+
+	*avail_size = mr->avail;
+
+	return 0;
+}
+
 /**
  * Creates a new mm object and returns a handle to it.
  * @dev: drm device pointer