2024-01-06 14:15:08

by Dipam Turkar

[permalink] [raw]
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.

Signed-off-by: Dipam Turkar <[email protected]>
---
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



2024-01-07 17:56:48

by kernel test robot

[permalink] [raw]
Subject: 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.

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/[email protected]/config)
compiler: s390-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240108/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

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

2024-01-07 19:42:09

by kernel test robot

[permalink] [raw]
Subject: 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.

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/[email protected]/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/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

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

2024-01-08 06:45:27

by Christian König

[permalink] [raw]
Subject: 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.

Am 06.01.24 um 15:14 schrieb Dipam Turkar:
> Signed-off-by: Dipam Turkar <[email protected]>
> ---
> 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,