<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Both patches are:</p>
<p style="margin-top:0;margin-bottom:0">Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Sharma, Deepak<br>
<b>Sent:</b> Friday, May 25, 2018 8:19:26 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org; Deucher, Alexander; michel@daenzer.net; Koenig, Christian<br>
<b>Subject:</b> Re: drm/amdgpu: Add helper function to get buffer domain</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">If look fine , please give rb for this and <br>
<a href="https://patchwork.freedesktop.org/patch/224850/">https://patchwork.freedesktop.org/patch/224850/</a><br>
<br>
Thanks,<br>
Deepak<br>
<br>
On 05/25/2018 05:12 PM, Deepak Sharma wrote:<br>
> Move logic of getting supported domain to a helper<br>
> function<br>
> <br>
> Signed-off-by: Deepak Sharma <Deepak.Sharma@amd.com><br>
> ---<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 10 +++-------<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 17 ++++++++++++-----<br>
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 3 ++-<br>
> 3 files changed, 17 insertions(+), 13 deletions(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c<br>
> index 63758db5e2ea..556406a44da3 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c<br>
> @@ -750,19 +750,15 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv,<br>
> struct amdgpu_device *adev = dev->dev_private;<br>
> struct drm_gem_object *gobj;<br>
> uint32_t handle;<br>
> - u32 domain = amdgpu_display_supported_domains(adev);<br>
> + u32 domain;<br>
> int r;<br>
> <br>
> args->pitch = amdgpu_align_pitch(adev, args->width,<br>
> DIV_ROUND_UP(args->bpp, 8), 0);<br>
> args->size = (u64)args->pitch * args->height;<br>
> args->size = ALIGN(args->size, PAGE_SIZE);<br>
> - if (domain == (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT)) {<br>
> - domain = AMDGPU_GEM_DOMAIN_VRAM;<br>
> - if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)<br>
> - domain = AMDGPU_GEM_DOMAIN_GTT;<br>
> - }<br>
> -<br>
> + domain = amdgpu_bo_get_preferred_pin_domain(adev,<br>
> + amdgpu_display_supported_domains(adev));<br>
> r = amdgpu_gem_object_create(adev, args->size, 0, domain,<br>
> AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,<br>
> false, NULL, &gobj);<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c<br>
> index 6a9e46ae7f0a..5e4e1bd90383 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c<br>
> @@ -703,11 +703,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,<br>
> /* This assumes only APU display buffers are pinned with (VRAM|GTT).<br>
> * See function amdgpu_display_supported_domains()<br>
> */<br>
> - if (domain == (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT)) {<br>
> - domain = AMDGPU_GEM_DOMAIN_VRAM;<br>
> - if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)<br>
> - domain = AMDGPU_GEM_DOMAIN_GTT;<br>
> - }<br>
> + domain = amdgpu_bo_get_preferred_pin_domain(adev, domain);<br>
> <br>
> if (bo->pin_count) {<br>
> uint32_t mem_type = bo->tbo.mem.mem_type;<br>
> @@ -1066,3 +1062,14 @@ u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo)<br>
> <br>
> return bo->tbo.offset;<br>
> }<br>
> +<br>
> +uint32_t amdgpu_bo_get_preferred_pin_domain(struct amdgpu_device *adev,<br>
> + uint32_t domain)<br>
> +{<br>
> + if (domain == (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT)) {<br>
> + domain = AMDGPU_GEM_DOMAIN_VRAM;<br>
> + if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)<br>
> + domain = AMDGPU_GEM_DOMAIN_GTT;<br>
> + }<br>
> + return domain;<br>
> +}<br>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h<br>
> index 540e03fa159f..731748033878 100644<br>
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h<br>
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.h<br>
> @@ -289,7 +289,8 @@ int amdgpu_bo_restore_from_shadow(struct amdgpu_device *adev,<br>
> struct reservation_object *resv,<br>
> struct dma_fence **fence,<br>
> bool direct);<br>
> -<br>
> +uint32_t amdgpu_bo_get_preferred_pin_domain(struct amdgpu_device *adev,<br>
> + uint32_t domain);<br>
> <br>
> /*<br>
> * sub allocation<br>
> <br>
</div>
</span></font></div>
</body>
</html>