public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] Refactor radeon driver to use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have a generic implementation, we don't need the custom function and it is better to standardize the code.
@ 2024-01-06 14:14 Dipam Turkar
  2024-01-07 17:56 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dipam Turkar @ 2024-01-06 14:14 UTC (permalink / raw)
  To: alexander.deucher
  Cc: christian.koenig, Xinhui.Pan, airlied, daniel, amd-gfx, dri-devel,
	linux-kernel, Dipam Turkar

Signed-off-by: Dipam Turkar <dipamt1729@gmail.com>
---
 drivers/gpu/drm/radeon/radeon_drv.c |  2 +-
 drivers/gpu/drm/radeon/radeon_gem.c | 24 ++----------------------
 2 files changed, 3 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index fa531493b111..f590ed65ffba 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -578,7 +578,7 @@ static const struct drm_driver kms_driver = {
 	.ioctls = radeon_ioctls_kms,
 	.num_ioctls = ARRAY_SIZE(radeon_ioctls_kms),
 	.dumb_create = radeon_mode_dumb_create,
-	.dumb_map_offset = radeon_mode_dumb_mmap,
+	.dumb_map_offset = drm_gem_dumb_map_offset,
 	.fops = &radeon_driver_kms_fops,
 
 	.gem_prime_import_sg_table = radeon_gem_prime_import_sg_table,
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index 358d19242f4b..99794c550d2c 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -31,6 +31,7 @@
 
 #include <drm/drm_device.h>
 #include <drm/drm_file.h>
+#include <drm/dem_gem.h>
 #include <drm/drm_gem_ttm_helper.h>
 #include <drm/radeon_drm.h>
 
@@ -480,33 +481,12 @@ int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data,
 	return r;
 }
 
-int radeon_mode_dumb_mmap(struct drm_file *filp,
-			  struct drm_device *dev,
-			  uint32_t handle, uint64_t *offset_p)
-{
-	struct drm_gem_object *gobj;
-	struct radeon_bo *robj;
-
-	gobj = drm_gem_object_lookup(filp, handle);
-	if (gobj == NULL) {
-		return -ENOENT;
-	}
-	robj = gem_to_radeon_bo(gobj);
-	if (radeon_ttm_tt_has_userptr(robj->rdev, robj->tbo.ttm)) {
-		drm_gem_object_put(gobj);
-		return -EPERM;
-	}
-	*offset_p = radeon_bo_mmap_offset(robj);
-	drm_gem_object_put(gobj);
-	return 0;
-}
-
 int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data,
 			  struct drm_file *filp)
 {
 	struct drm_radeon_gem_mmap *args = data;
 
-	return radeon_mode_dumb_mmap(filp, dev, args->handle, &args->addr_ptr);
+	return drm_gem_dumb_map_offset(filp, dev, args->handle, &args->addr_ptr);
 }
 
 int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] Refactor radeon driver to use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have a generic implementation, we don't need the custom function and it is better to standardize the code.
  2024-01-06 14:14 [PATCH 1/1] Refactor radeon driver to use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have a generic implementation, we don't need the custom function and it is better to standardize the code Dipam Turkar
@ 2024-01-07 17:56 ` kernel test robot
  2024-01-07 19:41 ` kernel test robot
  2024-01-08  6:45 ` Christian König
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2024-01-07 17:56 UTC (permalink / raw)
  To: Dipam Turkar, alexander.deucher
  Cc: oe-kbuild-all, christian.koenig, Xinhui.Pan, airlied, daniel,
	amd-gfx, dri-devel, linux-kernel, Dipam Turkar

Hi Dipam,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on linus/master v6.7-rc8 next-20240105]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Dipam-Turkar/Refactor-radeon-driver-to-use-drm_gem_create_map_offset-instead-of-its-custom-implementation-for-associating-GEM-object-/20240106-221755
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:    https://lore.kernel.org/r/20240106141422.10734-1-dipamt1729%40gmail.com
patch subject: [PATCH 1/1] Refactor radeon driver to use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have a generic implementation, we don't need the custom function and it is better to standardize the code.
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20240108/202401080151.JsIVh6p0-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240108/202401080151.JsIVh6p0-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401080151.JsIVh6p0-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/radeon/radeon_gem.c:34:10: fatal error: drm/dem_gem.h: No such file or directory
      34 | #include <drm/dem_gem.h>
         |          ^~~~~~~~~~~~~~~
   compilation terminated.


vim +34 drivers/gpu/drm/radeon/radeon_gem.c

    31	
    32	#include <drm/drm_device.h>
    33	#include <drm/drm_file.h>
  > 34	#include <drm/dem_gem.h>
    35	#include <drm/drm_gem_ttm_helper.h>
    36	#include <drm/radeon_drm.h>
    37	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] Refactor radeon driver to use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have a generic implementation, we don't need the custom function and it is better to standardize the code.
  2024-01-06 14:14 [PATCH 1/1] Refactor radeon driver to use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have a generic implementation, we don't need the custom function and it is better to standardize the code Dipam Turkar
  2024-01-07 17:56 ` kernel test robot
@ 2024-01-07 19:41 ` kernel test robot
  2024-01-08  6:45 ` Christian König
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2024-01-07 19:41 UTC (permalink / raw)
  To: Dipam Turkar, alexander.deucher
  Cc: llvm, oe-kbuild-all, christian.koenig, Xinhui.Pan, airlied,
	daniel, amd-gfx, dri-devel, linux-kernel, Dipam Turkar

Hi Dipam,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on linus/master v6.7-rc8 next-20240105]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Dipam-Turkar/Refactor-radeon-driver-to-use-drm_gem_create_map_offset-instead-of-its-custom-implementation-for-associating-GEM-object-/20240106-221755
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:    https://lore.kernel.org/r/20240106141422.10734-1-dipamt1729%40gmail.com
patch subject: [PATCH 1/1] Refactor radeon driver to use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have a generic implementation, we don't need the custom function and it is better to standardize the code.
config: x86_64-allmodconfig (https://download.01.org/0day-ci/archive/20240108/202401080333.6PSOtuIK-lkp@intel.com/config)
compiler: ClangBuiltLinux clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240108/202401080333.6PSOtuIK-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401080333.6PSOtuIK-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/radeon/radeon_gem.c:34:10: fatal error: 'drm/dem_gem.h' file not found
      34 | #include <drm/dem_gem.h>
         |          ^~~~~~~~~~~~~~~
   1 error generated.


vim +34 drivers/gpu/drm/radeon/radeon_gem.c

    31	
    32	#include <drm/drm_device.h>
    33	#include <drm/drm_file.h>
  > 34	#include <drm/dem_gem.h>
    35	#include <drm/drm_gem_ttm_helper.h>
    36	#include <drm/radeon_drm.h>
    37	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] Refactor radeon driver to use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have a generic implementation, we don't need the custom function and it is better to standardize the code.
  2024-01-06 14:14 [PATCH 1/1] Refactor radeon driver to use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have a generic implementation, we don't need the custom function and it is better to standardize the code Dipam Turkar
  2024-01-07 17:56 ` kernel test robot
  2024-01-07 19:41 ` kernel test robot
@ 2024-01-08  6:45 ` Christian König
  2 siblings, 0 replies; 4+ messages in thread
From: Christian König @ 2024-01-08  6:45 UTC (permalink / raw)
  To: Dipam Turkar, alexander.deucher
  Cc: Xinhui.Pan, airlied, daniel, amd-gfx, dri-devel, linux-kernel

Am 06.01.24 um 15:14 schrieb Dipam Turkar:
> Signed-off-by: Dipam Turkar <dipamt1729@gmail.com>
> ---
>   drivers/gpu/drm/radeon/radeon_drv.c |  2 +-
>   drivers/gpu/drm/radeon/radeon_gem.c | 24 ++----------------------
>   2 files changed, 3 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
> index fa531493b111..f590ed65ffba 100644
> --- a/drivers/gpu/drm/radeon/radeon_drv.c
> +++ b/drivers/gpu/drm/radeon/radeon_drv.c
> @@ -578,7 +578,7 @@ static const struct drm_driver kms_driver = {
>   	.ioctls = radeon_ioctls_kms,
>   	.num_ioctls = ARRAY_SIZE(radeon_ioctls_kms),
>   	.dumb_create = radeon_mode_dumb_create,
> -	.dumb_map_offset = radeon_mode_dumb_mmap,
> +	.dumb_map_offset = drm_gem_dumb_map_offset,
>   	.fops = &radeon_driver_kms_fops,
>   
>   	.gem_prime_import_sg_table = radeon_gem_prime_import_sg_table,
> diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
> index 358d19242f4b..99794c550d2c 100644
> --- a/drivers/gpu/drm/radeon/radeon_gem.c
> +++ b/drivers/gpu/drm/radeon/radeon_gem.c
> @@ -31,6 +31,7 @@
>   
>   #include <drm/drm_device.h>
>   #include <drm/drm_file.h>
> +#include <drm/dem_gem.h>
>   #include <drm/drm_gem_ttm_helper.h>
>   #include <drm/radeon_drm.h>
>   
> @@ -480,33 +481,12 @@ int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data,
>   	return r;
>   }
>   
> -int radeon_mode_dumb_mmap(struct drm_file *filp,
> -			  struct drm_device *dev,
> -			  uint32_t handle, uint64_t *offset_p)
> -{
> -	struct drm_gem_object *gobj;
> -	struct radeon_bo *robj;
> -
> -	gobj = drm_gem_object_lookup(filp, handle);
> -	if (gobj == NULL) {
> -		return -ENOENT;
> -	}
> -	robj = gem_to_radeon_bo(gobj);
> -	if (radeon_ttm_tt_has_userptr(robj->rdev, robj->tbo.ttm)) {

Well apart from the obvious typos, the missing commit message and the 
mangled subject line this also removes this important check for userptrs 
here.

This in turn is a complete no-go since it can lead to kernel crashes.

Regards,
Christian.

> -		drm_gem_object_put(gobj);
> -		return -EPERM;
> -	}
> -	*offset_p = radeon_bo_mmap_offset(robj);
> -	drm_gem_object_put(gobj);
> -	return 0;
> -}
> -
>   int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data,
>   			  struct drm_file *filp)
>   {
>   	struct drm_radeon_gem_mmap *args = data;
>   
> -	return radeon_mode_dumb_mmap(filp, dev, args->handle, &args->addr_ptr);
> +	return drm_gem_dumb_map_offset(filp, dev, args->handle, &args->addr_ptr);
>   }
>   
>   int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-08  6:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-06 14:14 [PATCH 1/1] Refactor radeon driver to use drm_gem_create_map_offset() instead of its custom implementation for associating GEM object with a fake offset. Since, we already have a generic implementation, we don't need the custom function and it is better to standardize the code Dipam Turkar
2024-01-07 17:56 ` kernel test robot
2024-01-07 19:41 ` kernel test robot
2024-01-08  6:45 ` Christian König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox