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

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

Commit Message

Ramalingam C Sept. 19, 2019, 6:04 p.m. UTC
When LMEM is supported, dumb buffer preferred to be created from LMEM.

This is developed on top of v3 LMEM series
https://patchwork.freedesktop.org/series/56683/.

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

Comments

Chris Wilson Sept. 19, 2019, 8:05 p.m. UTC | #1
Quoting Ramalingam C (2019-09-19 19:04:33)
> When LMEM is supported, dumb buffer preferred to be created from LMEM.
> 
> This is developed on top of v3 LMEM series
> https://patchwork.freedesktop.org/series/56683/.
> 
> Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
> cc: Matthew Auld <matthew.auld@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_gem.c | 18 ++++++++++++++----
>  1 file changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index e458507b1558..c0decbd020ce 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -161,7 +161,7 @@ static int
>  i915_gem_create(struct drm_file *file,
>                 struct drm_i915_private *dev_priv,
>                 u64 *size_p,
> -               u32 *handle_p)
> +               u32 *handle_p, enum intel_region_id mem_region)

General pattern is to keep outparams last.
-Chris
kbuild test robot Sept. 21, 2019, 3:33 p.m. UTC | #2
Hi Ramalingam,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm-intel/for-linux-next]
[cannot apply to v5.3 next-20190919]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Ramalingam-C/drm-i915-Create-dumb-buffer-from-LMEM/20190920-020825
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: x86_64-rhel (attached as .config)
compiler: gcc-7 (Debian 7.4.0-13) 7.4.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 
:::::: branch date: 2 hours ago
:::::: commit date: 2 hours ago

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

>> drivers/gpu/drm/i915/i915_gem.c:162:23: warning: 'enum intel_region_id' declared inside parameter list will not be visible outside of this definition or declaration
      u32 *handle_p, enum intel_region_id mem_region)
                          ^~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/i915_gem.c:162:39: error: parameter 5 ('mem_region') has incomplete type
      u32 *handle_p, enum intel_region_id mem_region)
                                          ^~~~~~~~~~
>> drivers/gpu/drm/i915/i915_gem.c:159:1: error: function declaration isn't a prototype [-Werror=strict-prototypes]
    i915_gem_create(struct drm_file *file,
    ^~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/i915_gem.c: In function 'i915_gem_create':
>> drivers/gpu/drm/i915/i915_gem.c:174:20: error: 'INTEL_MEMORY_LMEM' undeclared (first use in this function); did you mean 'INTEL_GEMINILAKE'?
     if (mem_region == INTEL_MEMORY_LMEM)
                       ^~~~~~~~~~~~~~~~~
                       INTEL_GEMINILAKE
   drivers/gpu/drm/i915/i915_gem.c:174:20: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/gpu/drm/i915/i915_gem.c:175:9: error: implicit declaration of function 'i915_gem_object_create_lmem'; did you mean 'i915_gem_object_create_shmem'? [-Werror=implicit-function-declaration]
      obj = i915_gem_object_create_lmem(dev_priv, size, 0);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
            i915_gem_object_create_shmem
>> drivers/gpu/drm/i915/i915_gem.c:175:7: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
      obj = i915_gem_object_create_lmem(dev_priv, size, 0);
          ^
>> drivers/gpu/drm/i915/i915_gem.c:176:25: error: 'INTEL_MEMORY_STOLEN' undeclared (first use in this function); did you mean 'INTEL_MEMORY_LMEM'?
     else if (mem_region == INTEL_MEMORY_STOLEN)
                            ^~~~~~~~~~~~~~~~~~~
                            INTEL_MEMORY_LMEM
   drivers/gpu/drm/i915/i915_gem.c: In function 'i915_gem_dumb_create':
>> drivers/gpu/drm/i915/i915_gem.c:199:7: error: variable 'mem_region' has initializer but incomplete type
     enum intel_region_id mem_region = INTEL_MEMORY_UKNOWN;
          ^~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/i915_gem.c:199:36: error: 'INTEL_MEMORY_UKNOWN' undeclared (first use in this function); did you mean 'INTEL_DRAM_UNKNOWN'?
     enum intel_region_id mem_region = INTEL_MEMORY_UKNOWN;
                                       ^~~~~~~~~~~~~~~~~~~
                                       INTEL_DRAM_UNKNOWN
>> drivers/gpu/drm/i915/i915_gem.c:199:23: error: storage size of 'mem_region' isn't known
     enum intel_region_id mem_region = INTEL_MEMORY_UKNOWN;
                          ^~~~~~~~~~
>> drivers/gpu/drm/i915/i915_gem.c:227:6: error: implicit declaration of function 'HAS_LMEM'; did you mean 'HAS_GMCH'? [-Werror=implicit-function-declaration]
     if (HAS_LMEM(to_i915(dev)))
         ^~~~~~~~
         HAS_GMCH
>> drivers/gpu/drm/i915/i915_gem.c:228:16: error: 'INTEL_MEMORY_LMEM' undeclared (first use in this function); did you mean 'INTEL_MEMORY_UKNOWN'?
      mem_region = INTEL_MEMORY_LMEM;
                   ^~~~~~~~~~~~~~~~~
                   INTEL_MEMORY_UKNOWN
   drivers/gpu/drm/i915/i915_gem.c:199:23: warning: unused variable 'mem_region' [-Wunused-variable]
     enum intel_region_id mem_region = INTEL_MEMORY_UKNOWN;
                          ^~~~~~~~~~
   drivers/gpu/drm/i915/i915_gem.c: In function 'i915_gem_create_ioctl':
   drivers/gpu/drm/i915/i915_gem.c:250:39: error: 'INTEL_MEMORY_UKNOWN' undeclared (first use in this function); did you mean 'INTEL_DRAM_UNKNOWN'?
              &args->size, &args->handle, INTEL_MEMORY_UKNOWN);
                                          ^~~~~~~~~~~~~~~~~~~
                                          INTEL_DRAM_UNKNOWN
   drivers/gpu/drm/i915/i915_gem.c: In function 'i915_gem_dumb_create':
>> drivers/gpu/drm/i915/i915_gem.c:232:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
   drivers/gpu/drm/i915/i915_gem.c: In function 'i915_gem_create_ioctl':
   drivers/gpu/drm/i915/i915_gem.c:251:1: warning: control reaches end of non-void function [-Wreturn-type]
    }
    ^
   cc1: some warnings being treated as errors

# https://github.com/0day-ci/linux/commit/3b75523cb0b12a5692ef98d5dbe775070204c3cb
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 3b75523cb0b12a5692ef98d5dbe775070204c3cb
vim +162 drivers/gpu/drm/i915/i915_gem.c

00731155a73020 Chris Wilson     2014-05-21  157  
ff72145badb834 Dave Airlie      2011-02-07  158  static int
ff72145badb834 Dave Airlie      2011-02-07 @159  i915_gem_create(struct drm_file *file,
12d79d78287cdc Tvrtko Ursulin   2016-12-01  160  		struct drm_i915_private *dev_priv,
e163484afa8d6b Michał Winiarski 2019-03-26  161  		u64 *size_p,
3b75523cb0b12a Ramalingam C     2019-09-19 @162  		u32 *handle_p, enum intel_region_id mem_region)
673a394b1e3b69 Eric Anholt      2008-07-30  163  {
05394f3975dceb Chris Wilson     2010-11-08  164  	struct drm_i915_gem_object *obj;
a1a2d1d32250f6 Pekka Paalanen   2009-08-23  165  	u32 handle;
e163484afa8d6b Michał Winiarski 2019-03-26  166  	u64 size;
e163484afa8d6b Michał Winiarski 2019-03-26  167  	int ret;
673a394b1e3b69 Eric Anholt      2008-07-30  168  
e163484afa8d6b Michał Winiarski 2019-03-26  169  	size = round_up(*size_p, PAGE_SIZE);
8ffc02468145ac Chris Wilson     2011-09-14  170  	if (size == 0)
8ffc02468145ac Chris Wilson     2011-09-14  171  		return -EINVAL;
673a394b1e3b69 Eric Anholt      2008-07-30  172  
673a394b1e3b69 Eric Anholt      2008-07-30  173  	/* Allocate the new object */
3b75523cb0b12a Ramalingam C     2019-09-19 @174  	if (mem_region == INTEL_MEMORY_LMEM)
3b75523cb0b12a Ramalingam C     2019-09-19 @175  		obj = i915_gem_object_create_lmem(dev_priv, size, 0);
3b75523cb0b12a Ramalingam C     2019-09-19 @176  	else if (mem_region == INTEL_MEMORY_STOLEN)
3b75523cb0b12a Ramalingam C     2019-09-19  177  		obj = i915_gem_object_create_stolen(dev_priv, size);
3b75523cb0b12a Ramalingam C     2019-09-19  178  	else
8475355f7a2645 Chris Wilson     2019-05-28  179  		obj = i915_gem_object_create_shmem(dev_priv, size);
fe3db79b0b5019 Chris Wilson     2016-04-25  180  	if (IS_ERR(obj))
fe3db79b0b5019 Chris Wilson     2016-04-25  181  		return PTR_ERR(obj);
673a394b1e3b69 Eric Anholt      2008-07-30  182  
05394f3975dceb Chris Wilson     2010-11-08  183  	ret = drm_gem_handle_create(file, &obj->base, &handle);
202f2fef7a1aa6 Chris Wilson     2010-10-14  184  	/* drop reference from allocate - handle holds it now */
f0cd518206e1a4 Chris Wilson     2016-10-28  185  	i915_gem_object_put(obj);
d861e338765029 Daniel Vetter    2013-07-24  186  	if (ret)
d861e338765029 Daniel Vetter    2013-07-24  187  		return ret;
202f2fef7a1aa6 Chris Wilson     2010-10-14  188  
ff72145badb834 Dave Airlie      2011-02-07  189  	*handle_p = handle;
99534023490686 Chris Wilson     2019-04-17  190  	*size_p = size;
673a394b1e3b69 Eric Anholt      2008-07-30  191  	return 0;
673a394b1e3b69 Eric Anholt      2008-07-30  192  }
673a394b1e3b69 Eric Anholt      2008-07-30  193  
ff72145badb834 Dave Airlie      2011-02-07  194  int
ff72145badb834 Dave Airlie      2011-02-07  195  i915_gem_dumb_create(struct drm_file *file,
ff72145badb834 Dave Airlie      2011-02-07  196  		     struct drm_device *dev,
ff72145badb834 Dave Airlie      2011-02-07  197  		     struct drm_mode_create_dumb *args)
ff72145badb834 Dave Airlie      2011-02-07  198  {
3b75523cb0b12a Ramalingam C     2019-09-19 @199  	enum intel_region_id mem_region = INTEL_MEMORY_UKNOWN;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  200  	int cpp = DIV_ROUND_UP(args->bpp, 8);
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  201  	u32 format;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  202  
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  203  	switch (cpp) {
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  204  	case 1:
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  205  		format = DRM_FORMAT_C8;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  206  		break;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  207  	case 2:
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  208  		format = DRM_FORMAT_RGB565;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  209  		break;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  210  	case 4:
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  211  		format = DRM_FORMAT_XRGB8888;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  212  		break;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  213  	default:
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  214  		return -EINVAL;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  215  	}
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  216  
ff72145badb834 Dave Airlie      2011-02-07  217  	/* have to work out size/pitch and return them */
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  218  	args->pitch = ALIGN(args->width * cpp, 64);
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  219  
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  220  	/* align stride to page size so that we can remap */
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  221  	if (args->pitch > intel_plane_fb_max_stride(to_i915(dev), format,
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  222  						    DRM_FORMAT_MOD_LINEAR))
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  223  		args->pitch = ALIGN(args->pitch, 4096);
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  224  
ff72145badb834 Dave Airlie      2011-02-07  225  	args->size = args->pitch * args->height;
3b75523cb0b12a Ramalingam C     2019-09-19  226  
3b75523cb0b12a Ramalingam C     2019-09-19 @227  	if (HAS_LMEM(to_i915(dev)))
3b75523cb0b12a Ramalingam C     2019-09-19 @228  		mem_region = INTEL_MEMORY_LMEM;
3b75523cb0b12a Ramalingam C     2019-09-19  229  
12d79d78287cdc Tvrtko Ursulin   2016-12-01  230  	return i915_gem_create(file, to_i915(dev),
3b75523cb0b12a Ramalingam C     2019-09-19  231  			       &args->size, &args->handle, mem_region);
ff72145badb834 Dave Airlie      2011-02-07 @232  }
ff72145badb834 Dave Airlie      2011-02-07  233  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kbuild test robot Sept. 21, 2019, 3:42 p.m. UTC | #3
Hi Ramalingam,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on drm-intel/for-linux-next]
[cannot apply to v5.3 next-20190919]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Ramalingam-C/drm-i915-Create-dumb-buffer-from-LMEM/20190920-020825
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
config: i386-randconfig-f003-201937 (attached as .config)
compiler: gcc-7 (Debian 7.4.0-13) 7.4.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 
:::::: branch date: 4 hours ago
:::::: commit date: 4 hours ago

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/gpu//drm/i915/i915_gem.c:162:23: error: 'enum intel_region_id' declared inside parameter list will not be visible outside of this definition or declaration [-Werror]
      u32 *handle_p, enum intel_region_id mem_region)
                          ^~~~~~~~~~~~~~~
   drivers/gpu//drm/i915/i915_gem.c:162:39: error: parameter 5 ('mem_region') has incomplete type
      u32 *handle_p, enum intel_region_id mem_region)
                                          ^~~~~~~~~~
   drivers/gpu//drm/i915/i915_gem.c:159:1: error: function declaration isn't a prototype [-Werror=strict-prototypes]
    i915_gem_create(struct drm_file *file,
    ^~~~~~~~~~~~~~~
   drivers/gpu//drm/i915/i915_gem.c: In function 'i915_gem_create':
   drivers/gpu//drm/i915/i915_gem.c:174:20: error: 'INTEL_MEMORY_LMEM' undeclared (first use in this function); did you mean 'INTEL_GEMINILAKE'?
     if (mem_region == INTEL_MEMORY_LMEM)
                       ^~~~~~~~~~~~~~~~~
                       INTEL_GEMINILAKE
   drivers/gpu//drm/i915/i915_gem.c:174:20: note: each undeclared identifier is reported only once for each function it appears in
   drivers/gpu//drm/i915/i915_gem.c:175:9: error: implicit declaration of function 'i915_gem_object_create_lmem'; did you mean 'i915_gem_object_create_shmem'? [-Werror=implicit-function-declaration]
      obj = i915_gem_object_create_lmem(dev_priv, size, 0);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
            i915_gem_object_create_shmem
>> drivers/gpu//drm/i915/i915_gem.c:175:7: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
      obj = i915_gem_object_create_lmem(dev_priv, size, 0);
          ^
   drivers/gpu//drm/i915/i915_gem.c:176:25: error: 'INTEL_MEMORY_STOLEN' undeclared (first use in this function); did you mean 'INTEL_MEMORY_LMEM'?
     else if (mem_region == INTEL_MEMORY_STOLEN)
                            ^~~~~~~~~~~~~~~~~~~
                            INTEL_MEMORY_LMEM
   drivers/gpu//drm/i915/i915_gem.c: In function 'i915_gem_dumb_create':
   drivers/gpu//drm/i915/i915_gem.c:199:7: error: variable 'mem_region' has initializer but incomplete type
     enum intel_region_id mem_region = INTEL_MEMORY_UKNOWN;
          ^~~~~~~~~~~~~~~
   drivers/gpu//drm/i915/i915_gem.c:199:36: error: 'INTEL_MEMORY_UKNOWN' undeclared (first use in this function); did you mean 'INTEL_DRAM_UNKNOWN'?
     enum intel_region_id mem_region = INTEL_MEMORY_UKNOWN;
                                       ^~~~~~~~~~~~~~~~~~~
                                       INTEL_DRAM_UNKNOWN
   drivers/gpu//drm/i915/i915_gem.c:199:23: error: storage size of 'mem_region' isn't known
     enum intel_region_id mem_region = INTEL_MEMORY_UKNOWN;
                          ^~~~~~~~~~
   drivers/gpu//drm/i915/i915_gem.c:227:6: error: implicit declaration of function 'HAS_LMEM'; did you mean 'HAS_GMCH'? [-Werror=implicit-function-declaration]
     if (HAS_LMEM(to_i915(dev)))
         ^~~~~~~~
         HAS_GMCH
   drivers/gpu//drm/i915/i915_gem.c:228:16: error: 'INTEL_MEMORY_LMEM' undeclared (first use in this function); did you mean 'INTEL_MEMORY_UKNOWN'?
      mem_region = INTEL_MEMORY_LMEM;
                   ^~~~~~~~~~~~~~~~~
                   INTEL_MEMORY_UKNOWN
>> drivers/gpu//drm/i915/i915_gem.c:199:23: error: unused variable 'mem_region' [-Werror=unused-variable]
     enum intel_region_id mem_region = INTEL_MEMORY_UKNOWN;
                          ^~~~~~~~~~
   drivers/gpu//drm/i915/i915_gem.c: In function 'i915_gem_create_ioctl':
   drivers/gpu//drm/i915/i915_gem.c:250:39: error: 'INTEL_MEMORY_UKNOWN' undeclared (first use in this function); did you mean 'INTEL_DRAM_UNKNOWN'?
              &args->size, &args->handle, INTEL_MEMORY_UKNOWN);
                                          ^~~~~~~~~~~~~~~~~~~
                                          INTEL_DRAM_UNKNOWN
   drivers/gpu//drm/i915/i915_gem.c: In function 'i915_gem_dumb_create':
   drivers/gpu//drm/i915/i915_gem.c:232:1: error: control reaches end of non-void function [-Werror=return-type]
    }
    ^
   drivers/gpu//drm/i915/i915_gem.c: In function 'i915_gem_create_ioctl':
   drivers/gpu//drm/i915/i915_gem.c:251:1: error: control reaches end of non-void function [-Werror=return-type]
    }
    ^
   cc1: all warnings being treated as errors

# https://github.com/0day-ci/linux/commit/3b75523cb0b12a5692ef98d5dbe775070204c3cb
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 3b75523cb0b12a5692ef98d5dbe775070204c3cb
vim +/mem_region +199 drivers/gpu//drm/i915/i915_gem.c

00731155a73020 Chris Wilson     2014-05-21  157  
ff72145badb834 Dave Airlie      2011-02-07  158  static int
ff72145badb834 Dave Airlie      2011-02-07  159  i915_gem_create(struct drm_file *file,
12d79d78287cdc Tvrtko Ursulin   2016-12-01  160  		struct drm_i915_private *dev_priv,
e163484afa8d6b Michał Winiarski 2019-03-26  161  		u64 *size_p,
3b75523cb0b12a Ramalingam C     2019-09-19  162  		u32 *handle_p, enum intel_region_id mem_region)
673a394b1e3b69 Eric Anholt      2008-07-30  163  {
05394f3975dceb Chris Wilson     2010-11-08  164  	struct drm_i915_gem_object *obj;
a1a2d1d32250f6 Pekka Paalanen   2009-08-23  165  	u32 handle;
e163484afa8d6b Michał Winiarski 2019-03-26  166  	u64 size;
e163484afa8d6b Michał Winiarski 2019-03-26  167  	int ret;
673a394b1e3b69 Eric Anholt      2008-07-30  168  
e163484afa8d6b Michał Winiarski 2019-03-26  169  	size = round_up(*size_p, PAGE_SIZE);
8ffc02468145ac Chris Wilson     2011-09-14  170  	if (size == 0)
8ffc02468145ac Chris Wilson     2011-09-14  171  		return -EINVAL;
673a394b1e3b69 Eric Anholt      2008-07-30  172  
673a394b1e3b69 Eric Anholt      2008-07-30  173  	/* Allocate the new object */
3b75523cb0b12a Ramalingam C     2019-09-19 @174  	if (mem_region == INTEL_MEMORY_LMEM)
3b75523cb0b12a Ramalingam C     2019-09-19 @175  		obj = i915_gem_object_create_lmem(dev_priv, size, 0);
3b75523cb0b12a Ramalingam C     2019-09-19  176  	else if (mem_region == INTEL_MEMORY_STOLEN)
3b75523cb0b12a Ramalingam C     2019-09-19  177  		obj = i915_gem_object_create_stolen(dev_priv, size);
3b75523cb0b12a Ramalingam C     2019-09-19  178  	else
8475355f7a2645 Chris Wilson     2019-05-28  179  		obj = i915_gem_object_create_shmem(dev_priv, size);
fe3db79b0b5019 Chris Wilson     2016-04-25  180  	if (IS_ERR(obj))
fe3db79b0b5019 Chris Wilson     2016-04-25  181  		return PTR_ERR(obj);
673a394b1e3b69 Eric Anholt      2008-07-30  182  
05394f3975dceb Chris Wilson     2010-11-08  183  	ret = drm_gem_handle_create(file, &obj->base, &handle);
202f2fef7a1aa6 Chris Wilson     2010-10-14  184  	/* drop reference from allocate - handle holds it now */
f0cd518206e1a4 Chris Wilson     2016-10-28  185  	i915_gem_object_put(obj);
d861e338765029 Daniel Vetter    2013-07-24  186  	if (ret)
d861e338765029 Daniel Vetter    2013-07-24  187  		return ret;
202f2fef7a1aa6 Chris Wilson     2010-10-14  188  
ff72145badb834 Dave Airlie      2011-02-07  189  	*handle_p = handle;
99534023490686 Chris Wilson     2019-04-17  190  	*size_p = size;
673a394b1e3b69 Eric Anholt      2008-07-30  191  	return 0;
673a394b1e3b69 Eric Anholt      2008-07-30  192  }
673a394b1e3b69 Eric Anholt      2008-07-30  193  
ff72145badb834 Dave Airlie      2011-02-07  194  int
ff72145badb834 Dave Airlie      2011-02-07  195  i915_gem_dumb_create(struct drm_file *file,
ff72145badb834 Dave Airlie      2011-02-07  196  		     struct drm_device *dev,
ff72145badb834 Dave Airlie      2011-02-07  197  		     struct drm_mode_create_dumb *args)
ff72145badb834 Dave Airlie      2011-02-07  198  {
3b75523cb0b12a Ramalingam C     2019-09-19 @199  	enum intel_region_id mem_region = INTEL_MEMORY_UKNOWN;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  200  	int cpp = DIV_ROUND_UP(args->bpp, 8);
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  201  	u32 format;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  202  
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  203  	switch (cpp) {
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  204  	case 1:
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  205  		format = DRM_FORMAT_C8;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  206  		break;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  207  	case 2:
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  208  		format = DRM_FORMAT_RGB565;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  209  		break;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  210  	case 4:
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  211  		format = DRM_FORMAT_XRGB8888;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  212  		break;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  213  	default:
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  214  		return -EINVAL;
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  215  	}
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  216  
ff72145badb834 Dave Airlie      2011-02-07  217  	/* have to work out size/pitch and return them */
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  218  	args->pitch = ALIGN(args->width * cpp, 64);
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  219  
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  220  	/* align stride to page size so that we can remap */
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  221  	if (args->pitch > intel_plane_fb_max_stride(to_i915(dev), format,
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  222  						    DRM_FORMAT_MOD_LINEAR))
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  223  		args->pitch = ALIGN(args->pitch, 4096);
aa5ca8b7421cdb Ville Syrjälä    2019-05-09  224  
ff72145badb834 Dave Airlie      2011-02-07  225  	args->size = args->pitch * args->height;
3b75523cb0b12a Ramalingam C     2019-09-19  226  
3b75523cb0b12a Ramalingam C     2019-09-19 @227  	if (HAS_LMEM(to_i915(dev)))
3b75523cb0b12a Ramalingam C     2019-09-19  228  		mem_region = INTEL_MEMORY_LMEM;
3b75523cb0b12a Ramalingam C     2019-09-19  229  
12d79d78287cdc Tvrtko Ursulin   2016-12-01  230  	return i915_gem_create(file, to_i915(dev),
3b75523cb0b12a Ramalingam C     2019-09-19  231  			       &args->size, &args->handle, mem_region);
ff72145badb834 Dave Airlie      2011-02-07  232  }
ff72145badb834 Dave Airlie      2011-02-07  233  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Ramalingam C Sept. 23, 2019, 10:01 a.m. UTC | #4
On 2019-09-19 at 21:05:09 +0100, Chris Wilson wrote:
> Quoting Ramalingam C (2019-09-19 19:04:33)
> > When LMEM is supported, dumb buffer preferred to be created from LMEM.
> > 
> > This is developed on top of v3 LMEM series
> > https://patchwork.freedesktop.org/series/56683/.
> > 
> > Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
> > cc: Matthew Auld <matthew.auld@intel.com>
> > ---
> >  drivers/gpu/drm/i915/i915_gem.c | 18 ++++++++++++++----
> >  1 file changed, 14 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> > index e458507b1558..c0decbd020ce 100644
> > --- a/drivers/gpu/drm/i915/i915_gem.c
> > +++ b/drivers/gpu/drm/i915/i915_gem.c
> > @@ -161,7 +161,7 @@ static int
> >  i915_gem_create(struct drm_file *file,
> >                 struct drm_i915_private *dev_priv,
> >                 u64 *size_p,
> > -               u32 *handle_p)
> > +               u32 *handle_p, enum intel_region_id mem_region)
> 
> General pattern is to keep outparams last.

Modified the order of the parameters. Thanks Chris!

-Ram
> -Chris

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index e458507b1558..c0decbd020ce 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -161,7 +161,7 @@  static int
 i915_gem_create(struct drm_file *file,
 		struct drm_i915_private *dev_priv,
 		u64 *size_p,
-		u32 *handle_p)
+		u32 *handle_p, enum intel_region_id mem_region)
 {
 	struct drm_i915_gem_object *obj;
 	u32 handle;
@@ -173,7 +173,12 @@  i915_gem_create(struct drm_file *file,
 		return -EINVAL;
 
 	/* Allocate the new object */
-	obj = i915_gem_object_create_shmem(dev_priv, size);
+	if (mem_region == INTEL_MEMORY_LMEM)
+		obj = i915_gem_object_create_lmem(dev_priv, size, 0);
+	else if (mem_region == INTEL_MEMORY_STOLEN)
+		obj = i915_gem_object_create_stolen(dev_priv, size);
+	else
+		obj = i915_gem_object_create_shmem(dev_priv, size);
 	if (IS_ERR(obj))
 		return PTR_ERR(obj);
 
@@ -193,6 +198,7 @@  i915_gem_dumb_create(struct drm_file *file,
 		     struct drm_device *dev,
 		     struct drm_mode_create_dumb *args)
 {
+	enum intel_region_id mem_region = INTEL_MEMORY_UKNOWN;
 	int cpp = DIV_ROUND_UP(args->bpp, 8);
 	u32 format;
 
@@ -219,8 +225,12 @@  i915_gem_dumb_create(struct drm_file *file,
 		args->pitch = ALIGN(args->pitch, 4096);
 
 	args->size = args->pitch * args->height;
+
+	if (HAS_LMEM(to_i915(dev)))
+		mem_region = INTEL_MEMORY_LMEM;
+
 	return i915_gem_create(file, to_i915(dev),
-			       &args->size, &args->handle);
+			       &args->size, &args->handle, mem_region);
 }
 
 /**
@@ -239,7 +249,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,
-			       &args->size, &args->handle);
+			       &args->size, &args->handle, INTEL_MEMORY_UKNOWN);
 }
 
 static int