[v3] drm/i915: Create dumb buffer from LMEM
diff mbox series

Message ID 20191105113029.4328-1-ramalingam.c@intel.com
State New
Headers show
Series
  • [v3] drm/i915: Create dumb buffer from LMEM
Related show

Commit Message

Ramalingam C Nov. 5, 2019, 11:30 a.m. UTC
When LMEM is supported, dumb buffer preferred to be created from LMEM.

v2:
  Parameters are reshuffled. [Chris]
v3:
  s/region_id/mem_type

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
cc: Matthew Auld <matthew.auld@intel.com>
---
 drivers/gpu/drm/i915/i915_gem.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

Comments

Chris Wilson Nov. 5, 2019, 11:47 a.m. UTC | #1
Quoting Ramalingam C (2019-11-05 11:30:29)
> When LMEM is supported, dumb buffer preferred to be created from LMEM.
> 
> v2:
>   Parameters are reshuffled. [Chris]
> v3:
>   s/region_id/mem_type
> 
> Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
> cc: Matthew Auld <matthew.auld@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 143a8952b736..db72af98905f 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -44,6 +44,7 @@
>  #include "gem/i915_gem_clflush.h"
>  #include "gem/i915_gem_context.h"
>  #include "gem/i915_gem_ioctls.h"
> +#include "gem/i915_gem_lmem.h"
>  #include "gem/i915_gem_pm.h"
>  #include "gt/intel_engine_user.h"
>  #include "gt/intel_gt.h"
> @@ -175,6 +176,7 @@ i915_gem_phys_pwrite(struct drm_i915_gem_object *obj,
>  static int
>  i915_gem_create(struct drm_file *file,
>                 struct drm_i915_private *dev_priv,
> +               enum intel_memory_type mem_type,
>                 u64 *size_p,
>                 u32 *handle_p)
>  {
> @@ -188,7 +190,11 @@ i915_gem_create(struct drm_file *file,
>                 return -EINVAL;
>  
>         /* Allocate the new object */
> -       obj = i915_gem_object_create_shmem(dev_priv, size);
> +       if (mem_type == INTEL_MEMORY_LOCAL)
> +               obj = i915_gem_object_create_lmem(dev_priv, size, 0);
> +       else
> +               obj = i915_gem_object_create_shmem(dev_priv, size);

Have you not talked Matthew into creating a
i915_gem_object_create_region(?dev_priv?,
			      intel_memory_region_lookup(dev_priv, mem_type),
			      size, flags)
yet?
-Chris
Ramalingam C Nov. 6, 2019, 11:42 a.m. UTC | #2
On 2019-11-05 at 11:47:16 +0000, Chris Wilson wrote:
> Quoting Ramalingam C (2019-11-05 11:30:29)
> > When LMEM is supported, dumb buffer preferred to be created from LMEM.
> > 
> > v2:
> >   Parameters are reshuffled. [Chris]
> > v3:
> >   s/region_id/mem_type
> > 
> > Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
> > cc: Matthew Auld <matthew.auld@intel.com>
> > ---
> >  drivers/gpu/drm/i915/i915_gem.c | 17 ++++++++++++++---
> >  1 file changed, 14 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> > index 143a8952b736..db72af98905f 100644
> > --- a/drivers/gpu/drm/i915/i915_gem.c
> > +++ b/drivers/gpu/drm/i915/i915_gem.c
> > @@ -44,6 +44,7 @@
> >  #include "gem/i915_gem_clflush.h"
> >  #include "gem/i915_gem_context.h"
> >  #include "gem/i915_gem_ioctls.h"
> > +#include "gem/i915_gem_lmem.h"
> >  #include "gem/i915_gem_pm.h"
> >  #include "gt/intel_engine_user.h"
> >  #include "gt/intel_gt.h"
> > @@ -175,6 +176,7 @@ i915_gem_phys_pwrite(struct drm_i915_gem_object *obj,
> >  static int
> >  i915_gem_create(struct drm_file *file,
> >                 struct drm_i915_private *dev_priv,
> > +               enum intel_memory_type mem_type,
> >                 u64 *size_p,
> >                 u32 *handle_p)
> >  {
> > @@ -188,7 +190,11 @@ i915_gem_create(struct drm_file *file,
> >                 return -EINVAL;
> >  
> >         /* Allocate the new object */
> > -       obj = i915_gem_object_create_shmem(dev_priv, size);
> > +       if (mem_type == INTEL_MEMORY_LOCAL)
> > +               obj = i915_gem_object_create_lmem(dev_priv, size, 0);
> > +       else
> > +               obj = i915_gem_object_create_shmem(dev_priv, size);
> 
> Have you not talked Matthew into creating a
> i915_gem_object_create_region(?dev_priv?,
> 			      intel_memory_region_lookup(dev_priv, mem_type),
> 			      size, flags)
Sounds a good idea to skip a wrapper function.

Matt, Is that ok with you?

-Ram
> yet?
> -Chris
Matthew Auld Nov. 6, 2019, 12:12 p.m. UTC | #3
On 06/11/2019 11:42, Ramalingam C wrote:
> On 2019-11-05 at 11:47:16 +0000, Chris Wilson wrote:
>> Quoting Ramalingam C (2019-11-05 11:30:29)
>>> When LMEM is supported, dumb buffer preferred to be created from LMEM.
>>>
>>> v2:
>>>    Parameters are reshuffled. [Chris]
>>> v3:
>>>    s/region_id/mem_type
>>>
>>> Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
>>> cc: Matthew Auld <matthew.auld@intel.com>
>>> ---
>>>   drivers/gpu/drm/i915/i915_gem.c | 17 ++++++++++++++---
>>>   1 file changed, 14 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
>>> index 143a8952b736..db72af98905f 100644
>>> --- a/drivers/gpu/drm/i915/i915_gem.c
>>> +++ b/drivers/gpu/drm/i915/i915_gem.c
>>> @@ -44,6 +44,7 @@
>>>   #include "gem/i915_gem_clflush.h"
>>>   #include "gem/i915_gem_context.h"
>>>   #include "gem/i915_gem_ioctls.h"
>>> +#include "gem/i915_gem_lmem.h"
>>>   #include "gem/i915_gem_pm.h"
>>>   #include "gt/intel_engine_user.h"
>>>   #include "gt/intel_gt.h"
>>> @@ -175,6 +176,7 @@ i915_gem_phys_pwrite(struct drm_i915_gem_object *obj,
>>>   static int
>>>   i915_gem_create(struct drm_file *file,
>>>                  struct drm_i915_private *dev_priv,
>>> +               enum intel_memory_type mem_type,
>>>                  u64 *size_p,
>>>                  u32 *handle_p)
>>>   {
>>> @@ -188,7 +190,11 @@ i915_gem_create(struct drm_file *file,
>>>                  return -EINVAL;
>>>   
>>>          /* Allocate the new object */
>>> -       obj = i915_gem_object_create_shmem(dev_priv, size);
>>> +       if (mem_type == INTEL_MEMORY_LOCAL)
>>> +               obj = i915_gem_object_create_lmem(dev_priv, size, 0);
>>> +       else
>>> +               obj = i915_gem_object_create_shmem(dev_priv, size);
>>
>> Have you not talked Matthew into creating a
>> i915_gem_object_create_region(?dev_priv?,
>> 			      intel_memory_region_lookup(dev_priv, mem_type),
>> 			      size, flags)
> Sounds a good idea to skip a wrapper function.
> 
> Matt, Is that ok with you?

Sure.

> 
> -Ram
>> yet?
>> -Chris

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 143a8952b736..db72af98905f 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -44,6 +44,7 @@ 
 #include "gem/i915_gem_clflush.h"
 #include "gem/i915_gem_context.h"
 #include "gem/i915_gem_ioctls.h"
+#include "gem/i915_gem_lmem.h"
 #include "gem/i915_gem_pm.h"
 #include "gt/intel_engine_user.h"
 #include "gt/intel_gt.h"
@@ -175,6 +176,7 @@  i915_gem_phys_pwrite(struct drm_i915_gem_object *obj,
 static int
 i915_gem_create(struct drm_file *file,
 		struct drm_i915_private *dev_priv,
+		enum intel_memory_type mem_type,
 		u64 *size_p,
 		u32 *handle_p)
 {
@@ -188,7 +190,11 @@  i915_gem_create(struct drm_file *file,
 		return -EINVAL;
 
 	/* Allocate the new object */
-	obj = i915_gem_object_create_shmem(dev_priv, size);
+	if (mem_type == INTEL_MEMORY_LOCAL)
+		obj = i915_gem_object_create_lmem(dev_priv, size, 0);
+	else
+		obj = i915_gem_object_create_shmem(dev_priv, size);
+
 	if (IS_ERR(obj))
 		return PTR_ERR(obj);
 
@@ -208,6 +214,7 @@  i915_gem_dumb_create(struct drm_file *file,
 		     struct drm_device *dev,
 		     struct drm_mode_create_dumb *args)
 {
+	enum intel_memory_type mem_type = INTEL_MEMORY_SYSTEM;
 	int cpp = DIV_ROUND_UP(args->bpp, 8);
 	u32 format;
 
@@ -234,7 +241,11 @@  i915_gem_dumb_create(struct drm_file *file,
 		args->pitch = ALIGN(args->pitch, 4096);
 
 	args->size = args->pitch * args->height;
-	return i915_gem_create(file, to_i915(dev),
+
+	if (HAS_LMEM(to_i915(dev)))
+		mem_type = INTEL_MEMORY_LOCAL;
+
+	return i915_gem_create(file, to_i915(dev), mem_type,
 			       &args->size, &args->handle);
 }
 
@@ -253,7 +264,7 @@  i915_gem_create_ioctl(struct drm_device *dev, void *data,
 
 	i915_gem_flush_free_objects(dev_priv);
 
-	return i915_gem_create(file, dev_priv,
+	return i915_gem_create(file, dev_priv, INTEL_MEMORY_SYSTEM,
 			       &args->size, &args->handle);
 }