diff mbox series

[08/19] drm/i915: Return error value when bo not in LMEM for discrete

Message ID 20210412090526.30547-9-matthew.auld@intel.com (mailing list archive)
State New
Headers show
Series More DG1 enabling | expand

Commit Message

Matthew Auld April 12, 2021, 9:05 a.m. UTC
From: Mohammed Khajapasha <mohammed.khajapasha@intel.com>

Return EREMOTE value when frame buffer object is not backed by LMEM
for discrete. If Local memory is supported by hardware the framebuffer
backing gem objects should be from local memory.

Signed-off-by: Mohammed Khajapasha <mohammed.khajapasha@intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Tvrtko Ursulin April 14, 2021, 3:16 p.m. UTC | #1
On 12/04/2021 10:05, Matthew Auld wrote:
> From: Mohammed Khajapasha <mohammed.khajapasha@intel.com>
> 
> Return EREMOTE value when frame buffer object is not backed by LMEM
> for discrete. If Local memory is supported by hardware the framebuffer
> backing gem objects should be from local memory.
> 
> Signed-off-by: Mohammed Khajapasha <mohammed.khajapasha@intel.com>
> ---
>   drivers/gpu/drm/i915/display/intel_display.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 411b46c012f8..57b06d8728af 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -63,6 +63,7 @@
>   #include "display/intel_vdsc.h"
>   #include "display/intel_vrr.h"
>   
> +#include "gem/i915_gem_lmem.h"
>   #include "gem/i915_gem_object.h"
>   
>   #include "gt/intel_rps.h"
> @@ -11279,11 +11280,20 @@ intel_user_framebuffer_create(struct drm_device *dev,
>   	struct drm_framebuffer *fb;
>   	struct drm_i915_gem_object *obj;
>   	struct drm_mode_fb_cmd2 mode_cmd = *user_mode_cmd;
> +	struct drm_i915_private *i915;
>   
>   	obj = i915_gem_object_lookup(filp, mode_cmd.handles[0]);
>   	if (!obj)
>   		return ERR_PTR(-ENOENT);
>   
> +	/* object is backed with LMEM for discrete */
> +	i915 = to_i915(obj->base.dev);
> +	if (HAS_LMEM(i915) && !i915_gem_object_is_lmem(obj)) {
> +		/* object is "remote", not in local memory */
> +		i915_gem_object_put(obj);
> +		return ERR_PTR(-EREMOTE);

I am a fan of rich errnos and this one feels appropriately descriptive, 
but please get an ack from Daniel or so.

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko

> +	}
> +
>   	fb = intel_framebuffer_create(obj, &mode_cmd);
>   	i915_gem_object_put(obj);
>   
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 411b46c012f8..57b06d8728af 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -63,6 +63,7 @@ 
 #include "display/intel_vdsc.h"
 #include "display/intel_vrr.h"
 
+#include "gem/i915_gem_lmem.h"
 #include "gem/i915_gem_object.h"
 
 #include "gt/intel_rps.h"
@@ -11279,11 +11280,20 @@  intel_user_framebuffer_create(struct drm_device *dev,
 	struct drm_framebuffer *fb;
 	struct drm_i915_gem_object *obj;
 	struct drm_mode_fb_cmd2 mode_cmd = *user_mode_cmd;
+	struct drm_i915_private *i915;
 
 	obj = i915_gem_object_lookup(filp, mode_cmd.handles[0]);
 	if (!obj)
 		return ERR_PTR(-ENOENT);
 
+	/* object is backed with LMEM for discrete */
+	i915 = to_i915(obj->base.dev);
+	if (HAS_LMEM(i915) && !i915_gem_object_is_lmem(obj)) {
+		/* object is "remote", not in local memory */
+		i915_gem_object_put(obj);
+		return ERR_PTR(-EREMOTE);
+	}
+
 	fb = intel_framebuffer_create(obj, &mode_cmd);
 	i915_gem_object_put(obj);