mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Dipam Turkar <dipamt1729@gmail.com>, alexander.deucher@amd.com
Cc: Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
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.
Date: Mon, 8 Jan 2024 07:45:09 +0100	[thread overview]
Message-ID: <c82fbab0-1ba1-43cf-9f31-57d365b2baa2@amd.com> (raw)
In-Reply-To: <20240106141422.10734-1-dipamt1729@gmail.com>

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,


      parent reply	other threads:[~2024-01-08  6:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-06 14:14 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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c82fbab0-1ba1-43cf-9f31-57d365b2baa2@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=daniel@ffwll.ch \
    --cc=dipamt1729@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®