All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michel Dänzer" <michel-otUistvHUpPR7s880joybQ@public.gmane.org>
To: Chunming Zhou <david1.zhou-5C7GfCeVMHo@public.gmane.org>
Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH] drm/amdgpu: enable bo priority setting from user space
Date: Thu, 7 Mar 2019 10:55:20 +0100	[thread overview]
Message-ID: <a8803c5e-d911-992e-2b67-13ed6ca29ccf@daenzer.net> (raw)
In-Reply-To: <20190307091528.22788-1-david1.zhou-5C7GfCeVMHo@public.gmane.org>

On 2019-03-07 10:15 a.m., Chunming Zhou wrote:
> Signed-off-by: Chunming Zhou <david1.zhou@amd.com>

Please provide corresponding UMD patches showing how this is to be used.


> @@ -229,6 +231,14 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
>  	if (args->in.domains & ~AMDGPU_GEM_DOMAIN_MASK)
>  		return -EINVAL;
>  
> +	/* check priority */
> +	if (args->in.priority == 0) {

Did you verify that this is 0 with old userspace compiled against struct
drm_amdgpu_gem_create_in without the priority field?


> +		/* default is normal */
> +		args->in.priority = TTM_BO_PRIORITY_NORMAL;
> +	} else if (args->in.priority > TTM_MAX_BO_PRIORITY) {
> +		args->in.priority = TTM_MAX_BO_PRIORITY;
> +		DRM_ERROR("priority specified from user space is over MAX priority\n");

This must be DRM_DEBUG, or buggy/malicious userspace can spam dmesg.


> @@ -252,6 +262,7 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
>  
>  	r = amdgpu_gem_object_create(adev, size, args->in.alignment,
>  				     (u32)(0xffffffff & args->in.domains),
> +				     args->in.priority - 1,
>  				     flags, ttm_bo_type_device, resv, &gobj);

It might be less confusing to subtract 1 after checking against
TTM_MAX_BO_PRIORITY instead of here. Still kind of confusing though. How
about this instead:

Make the priority field of struct drm_amdgpu_gem_create_in signed. In
amdgpu_gem_create_ioctl, clamp the priority to the supported range:

	args->in.priority += TTM_BO_PRIORITY_NORMAL;
	args->in.priority = max(args->in.priority, 0);
	args->in.priority = min(args->in.priority,
				TTM_BO_PRIORITY_NORMAL - 1);

This way userspace doesn't need to do a weird mapping of the priority
values (where 0 and 2 have the same meaning), and the range of supported
priorities could at least theoretically be extended without breaking
userspace.


> @@ -304,6 +315,7 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,
>  
>  	/* create a gem object to contain this object in */
>  	r = amdgpu_gem_object_create(adev, args->size, 0, AMDGPU_GEM_DOMAIN_CPU,
> +				     TTM_BO_PRIORITY_NORMAL,
>  				     0, ttm_bo_type_device, NULL, &gobj);

Should the userptr ioctl also allow setting the priority?


> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index fd9c4beeaaa4..c85304e03021 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -494,8 +494,9 @@ static int amdgpu_bo_do_create(struct amdgpu_device *adev,
>  
>  	bo->tbo.bdev = &adev->mman.bdev;
>  	amdgpu_bo_placement_from_domain(bo, bp->domain);
> +	bo->tbo.priority = bp->priority;
>  	if (bp->type == ttm_bo_type_kernel)
> -		bo->tbo.priority = 1;
> +		bo->tbo.priority = TTM_BO_PRIORITY_VERYHIGH;

	if (bp->type == ttm_bo_type_kernel)
		bo->tbo.priority = TTM_BO_PRIORITY_VERYHIGH;
	else
		bo->tbo.priority = bp->priority;

would be clearer I think.


-- 
Earthling Michel Dänzer               |              https://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2019-03-07  9:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-07  9:15 [PATCH] drm/amdgpu: enable bo priority setting from user space Chunming Zhou
     [not found] ` <20190307091528.22788-1-david1.zhou-5C7GfCeVMHo@public.gmane.org>
2019-03-07  9:55   ` Michel Dänzer [this message]
     [not found]     ` <a8803c5e-d911-992e-2b67-13ed6ca29ccf-otUistvHUpPR7s880joybQ@public.gmane.org>
2019-03-07 10:48       ` zhoucm1
     [not found]         ` <1d4f0b7d-f726-3cad-13c3-36e670f35baf-5C7GfCeVMHo@public.gmane.org>
2019-03-07 11:33           ` Michel Dänzer
2019-03-07 11:36   ` Christian König
     [not found]     ` <a1efec4e-0cb9-f92f-2688-ecfd4ed7ad12-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2019-03-07 13:09       ` Zhou, David(ChunMing)
     [not found]         ` <-o8xodt-v7ma50s620vm-x3ufrzt16m3ru4l9qc4l8rct-ppumfj-lgzfos2xnj696p97zq-q88klx-1xor439yr648-3s2lfc-pglvz8-9du7dn8goc66-3zd1sv-cy6o2qkurchc-gpwxlg-c9iov0a657ue.1551963984191-2ueSQiBKiTY7tOexoI0I+QC/G2K4zDHf@public.gmane.org>
2019-03-07 13:15           ` [PATCH] " Koenig, Christian
     [not found]             ` <b2fed38f-bcc1-07df-625c-fa912022bdd4-5C7GfCeVMHo@public.gmane.org>
2019-03-07 13:31               ` Zhou, David(ChunMing)

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=a8803c5e-d911-992e-2b67-13ed6ca29ccf@daenzer.net \
    --to=michel-otuistvhuppr7s880joybq@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=david1.zhou-5C7GfCeVMHo@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.