All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
To: raof-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Christopher James Halse Rogers
	<christopher.halse.rogers-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH 7/7 v2] drm/radeon: Refuse to migrate a prime BO to VRAM. (v2)
Date: Mon, 3 Apr 2017 10:24:18 +0200	[thread overview]
Message-ID: <4fe38f82-c9d5-c212-fa05-08c2b4684c4e@vodafone.de> (raw)
In-Reply-To: <20170403033523.22639-2-raof-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>

Am 03.04.2017 um 05:35 schrieb raof@ubuntu.com:
> From: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
>
> BOs shared via dma-buf, either imported or exported, cannot sensibly be migrated to VRAM
> without breaking the dma-buf sharing. Refuse userspace requests to migrate to VRAM,
> ensure such BOs are not migrated during command submission, and refuse to pin them
> to VRAM.
>
> v2: Don't pin BOs in GTT. Instead, refuse to migrate BOs to VRAM.
>
> Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>

Patches #4, #6 and this one (#7) are Reviewed-by: Christian König 
<christian.koenig@amd.com>.

> ---
>   drivers/gpu/drm/radeon/radeon_cs.c     | 10 ++++++++++
>   drivers/gpu/drm/radeon/radeon_gem.c    |  4 ++++
>   drivers/gpu/drm/radeon/radeon_object.c |  5 +++++
>   3 files changed, 19 insertions(+)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
> index a8442f7196d6..df6b58c08544 100644
> --- a/drivers/gpu/drm/radeon/radeon_cs.c
> +++ b/drivers/gpu/drm/radeon/radeon_cs.c
> @@ -164,6 +164,16 @@ static int radeon_cs_parser_relocs(struct radeon_cs_parser *p)
>   			p->relocs[i].allowed_domains = domain;
>   		}
>   
> +		/* Objects shared as dma-bufs cannot be moved to VRAM */
> +		if (p->relocs[i].robj->prime_shared_count) {
> +			p->relocs[i].allowed_domains &= ~RADEON_GEM_DOMAIN_VRAM;
> +			if (!p->relocs[i].allowed_domains) {
> +				DRM_ERROR("BO associated with dma-buf cannot "
> +					  "be moved to VRAM\n");
> +				return -EINVAL;
> +			}
> +		}
> +
>   		p->relocs[i].tv.bo = &p->relocs[i].robj->tbo;
>   		p->relocs[i].tv.shared = !r->write_domain;
>   
> diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
> index 96683f5b2b1b..067ea7d7658a 100644
> --- a/drivers/gpu/drm/radeon/radeon_gem.c
> +++ b/drivers/gpu/drm/radeon/radeon_gem.c
> @@ -120,6 +120,10 @@ static int radeon_gem_set_domain(struct drm_gem_object *gobj,
>   			return r;
>   		}
>   	}
> +	if (domain == RADEON_GEM_DOMAIN_VRAM && robj->prime_shared_count) {
> +		/* A BO that is associated with a dma-buf cannot be sensibly migrated to VRAM */
> +		return -EINVAL;
> +	}
>   	return 0;
>   }
>   
> diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
> index 74b276060c20..bec2ec056de4 100644
> --- a/drivers/gpu/drm/radeon/radeon_object.c
> +++ b/drivers/gpu/drm/radeon/radeon_object.c
> @@ -352,6 +352,11 @@ int radeon_bo_pin_restricted(struct radeon_bo *bo, u32 domain, u64 max_offset,
>   
>   		return 0;
>   	}
> +	if (bo->prime_shared_count && domain == RADEON_GEM_DOMAIN_VRAM) {
> +		/* A BO shared as a dma-buf cannot be sensibly migrated to VRAM */
> +		return -EINVAL;
> +	}
> +
>   	radeon_ttm_placement_from_domain(bo, domain);
>   	for (i = 0; i < bo->placement.num_placement; i++) {
>   		/* force to pin into visible video ram */


_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2017-04-03  8:24 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29  0:27 [PATCH] Fixes for interaction of imported dma-bufs and scanout raof
2017-03-29  0:27 ` [PATCH 1/6] drm/nouveau: Fail fb creation from imported dma-bufs raof
2017-03-29  8:47   ` Maarten Lankhorst
2017-03-29  0:27 ` [PATCH 2/6] drm/nouveau: Pin bos from imported dma-bufs to GTT raof
2017-03-29  8:45   ` Maarten Lankhorst
2017-04-03  5:56   ` [PATCH 2/6 v2] drm/nouveau: Pin bos from imported dma-bufs to GTT. (v2) raof
     [not found] ` <20170329002720.11445-1-raof-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2017-03-29  0:27   ` [PATCH 3/6] drm/amdgpu: Fail fb creation from imported dma-bufs raof-GeWIH/nMZzLQT0dZR+AlfA
     [not found]     ` <20170329002720.11445-4-raof-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2017-03-29  2:03       ` Michel Dänzer
     [not found]         ` <4a950f45-3ad5-2d63-c434-0474e8cfda37-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-03-29  3:41           ` Christopher James Halse Rogers
2017-03-29  4:02       ` [PATCH v2] drm/amdgpu: Fail fb creation from imported dma-bufs. (v2) raof-GeWIH/nMZzLQT0dZR+AlfA
     [not found]         ` <20170329040211.18844-1-raof-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2017-03-29  6:07           ` Michel Dänzer
     [not found]             ` <2b175dd8-abeb-b3e7-d783-355607a48fda-otUistvHUpPR7s880joybQ@public.gmane.org>
2017-03-29 21:51               ` Alex Deucher
2017-03-29  0:27   ` [PATCH 4/6] drm/amd/amdgpu: Pin bos from imported dma-bufs to GTT raof-GeWIH/nMZzLQT0dZR+AlfA
2017-03-29  1:57     ` Michel Dänzer
2017-03-29  7:14     ` Christian König
2017-03-29  9:07       ` Michel Dänzer
2017-03-29  9:11         ` Christian König
     [not found]     ` <20170329002720.11445-5-raof-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2017-04-03  3:31       ` [PATCH 4/6 (v2)] drm/amdgpu: Refuse to pin or change acceptable domains of prime BOs to VRAM. (v2) raof-GeWIH/nMZzLQT0dZR+AlfA
2017-03-29  0:27   ` [PATCH 5/6] drm/radeon: Fail fb creation from imported dma-bufs raof-GeWIH/nMZzLQT0dZR+AlfA
     [not found]     ` <20170329002720.11445-6-raof-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2017-03-29  4:00       ` [PATCH v2] " raof-GeWIH/nMZzLQT0dZR+AlfA
     [not found]         ` <20170329040054.18587-1-raof-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2017-03-29  7:18           ` Christian König
2017-03-29  0:27 ` [PATCH 6/6] drm/radeon: Pin bos from imported dma-bufs to GTT raof
     [not found]   ` <20170329002720.11445-7-raof-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2017-04-03  3:35     ` [PATCH 6/7] drm/radeon: Maintain prime import/export refcount for BOs raof-GeWIH/nMZzLQT0dZR+AlfA
     [not found]       ` <20170403033523.22639-1-raof-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2017-04-03  3:35         ` [PATCH 7/7 v2] drm/radeon: Refuse to migrate a prime BO to VRAM. (v2) raof-GeWIH/nMZzLQT0dZR+AlfA
     [not found]           ` <20170403033523.22639-2-raof-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2017-04-03  8:24             ` Christian König [this message]
2017-04-03 15:51               ` Alex Deucher
2017-04-03 16:00                 ` Christian König
     [not found]                   ` <c9417139-b930-040b-c186-e99b8ecc3474-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-04-04  8:03                     ` Christopher James Halse Rogers
     [not found]               ` <4fe38f82-c9d5-c212-fa05-08c2b4684c4e-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-04-04 15:08                 ` Alex Deucher

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=4fe38f82-c9d5-c212-fa05-08c2b4684c4e@vodafone.de \
    --to=deathsimple-antagkrnahcb1svskn2v4q@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=christopher.halse.rogers-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=raof-GeWIH/nMZzLQT0dZR+AlfA@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.