From: =?UTF-8?Q?Christian_K=c3=b6nig?= Subject: Re: [PATCH] drm/amdgpu: Fix amdgpu_vm_alloc_pts failed Date: Tue, 23 Oct 2018 11:01:08 +0200 Message-ID: <62aee584-d4b1-dd9b-234e-8ca7d7a23a29@gmail.com> References: <1540265370-23923-1-git-send-email-Rex.Zhu@amd.com> <7b50f2a1-791e-8eab-6777-e7fff572565c@amd.com> Reply-To: christian.koenig-5C7GfCeVMHo@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1513739454==" Return-path: In-Reply-To: Content-Language: en-US List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Sender: "amd-gfx" To: "Zhu, Rex" , "Zhang, Jerry" , "amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org" , "Deucher, Alexander" , "Koenig, Christian" This is a multi-part message in MIME format. --===============1513739454== Content-Type: multipart/alternative; boundary="------------403058BA37F1A64BE60C5AD4" Content-Language: en-US This is a multi-part message in MIME format. --------------403058BA37F1A64BE60C5AD4 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Hi guys, yeah the root PD doesn't necessarily have a power of two entries. But what exactly was the problem with the original code? Why does 0xffffffff doesn't work? The only possible explanation I can see is that somebody tried to use an address which is above max_pfn, or how did that trigger? Thanks, Christian. Am 23.10.18 um 07:42 schrieb Zhu, Rex: > > No, if the vm size is small, there may only on root pd entry. > > we need to make sure the mask >= 0; > > > Maybe this change revert Christian's commit: > > > commit 72af632549b97ead9251bb155f08fefd1fb6f5c3 > Author: Christian König > Date:   Sat Sep 15 10:02:13 2018 +0200 > >     drm/amdgpu: add amdgpu_vm_entries_mask v2 > >     We can't get the mask for the root directory from the number of > entries. > >     So add a new function to avoid that problem. > > > Best Regards > > Rex > > > > ------------------------------------------------------------------------ > *From:* amd-gfx on behalf of > Zhang, Jerry(Junwei) > *Sent:* Tuesday, October 23, 2018 1:12 PM > *To:* Zhu, Rex; amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; Deucher, Alexander; > Koenig, Christian > *Subject:* Re: [PATCH] drm/amdgpu: Fix amdgpu_vm_alloc_pts failed > On 10/23/2018 11:29 AM, Rex Zhu wrote: > > when the VA address located in the last PD entries, > > the alloc_pts will faile. > > > > Use the right PD mask instand of hardcode, suggested > > by jerry.zhang. > > > > Signed-off-by: Rex Zhu > > Thanks to verify that. > Feel free to add > Reviewed-by: Junwei Zhang > > Also like to get to know some background about these two functions from > Christian. > Perhaps we may make it more simple, e.g. merging them together. > > Regards, > Jerry > > > --- > >   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 ++++- > >   1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > > index 054633b..3939013 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > > @@ -202,8 +202,11 @@ static unsigned amdgpu_vm_num_entries(struct > amdgpu_device *adev, > >   static uint32_t amdgpu_vm_entries_mask(struct amdgpu_device *adev, > >                                       unsigned int level) > >   { > > +     unsigned shift = amdgpu_vm_level_shift(adev, > > + adev->vm_manager.root_level); > > + > >        if (level <= adev->vm_manager.root_level) > > -             return 0xffffffff; > > +             return (round_up(adev->vm_manager.max_pfn, 1 << shift) > >> shift) - 1; > >        else if (level != AMDGPU_VM_PTB) > >                return 0x1ff; > >        else > > _______________________________________________ > amd-gfx mailing list > amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx > amd-gfx Info Page - freedesktop.org > > lists.freedesktop.org > To see the collection of prior postings to the list, visit the amd-gfx > Archives.. Using amd-gfx: To post a message to all the list members, > send email to amd-gfx-PD4FTy7X32lNgt0PjOBp9xlNPtJONSTn@public.gmane.org You can subscribe to the > list, or change your existing subscription, in the sections below. > > > > _______________________________________________ > amd-gfx mailing list > amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx --------------403058BA37F1A64BE60C5AD4 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 8bit
Hi guys,

yeah the root PD doesn't necessarily have a power of two entries.

But what exactly was the problem with the original code? Why does 0xffffffff doesn't work?

The only possible explanation I can see is that somebody tried to use an address which is above max_pfn, or how did that trigger?

Thanks,
Christian.

Am 23.10.18 um 07:42 schrieb Zhu, Rex:

No, if the vm size is small, there may only on root pd entry.

we need to make sure the mask >= 0;


Maybe this change revert Christian's commit:


commit 72af632549b97ead9251bb155f08fefd1fb6f5c3
Author: Christian König <christian.koenig-5C7GfCeVMHo@public.gmane.org>
Date:   Sat Sep 15 10:02:13 2018 +0200

    drm/amdgpu: add amdgpu_vm_entries_mask v2
    
    We can't get the mask for the root directory from the number of entries.
    
    So add a new function to avoid that problem.


Best Regards

Rex




From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Zhang, Jerry(Junwei) <Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>
Sent: Tuesday, October 23, 2018 1:12 PM
To: Zhu, Rex; amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org; Deucher, Alexander; Koenig, Christian
Subject: Re: [PATCH] drm/amdgpu: Fix amdgpu_vm_alloc_pts failed
 
On 10/23/2018 11:29 AM, Rex Zhu wrote:
> when the VA address located in the last PD entries,
> the alloc_pts will faile.
>
> Use the right PD mask instand of hardcode, suggested
> by jerry.zhang.
>
> Signed-off-by: Rex Zhu <Rex.Zhu-5C7GfCeVMHo@public.gmane.org>

Thanks to verify that.
Feel free to add
Reviewed-by: Junwei Zhang <Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>

Also like to get to know some background about these two functions from
Christian.
Perhaps we may make it more simple, e.g. merging them together.

Regards,
Jerry

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 054633b..3939013 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -202,8 +202,11 @@ static unsigned amdgpu_vm_num_entries(struct amdgpu_device *adev,
>   static uint32_t amdgpu_vm_entries_mask(struct amdgpu_device *adev,
>                                       unsigned int level)
>   {
> +     unsigned shift = amdgpu_vm_level_shift(adev,
> +                                            adev->vm_manager.root_level);
> +
>        if (level <= adev->vm_manager.root_level)
> -             return 0xffffffff;
> +             return (round_up(adev->vm_manager.max_pfn, 1 << shift) >> shift) - 1;
>        else if (level != AMDGPU_VM_PTB)
>                return 0x1ff;
>        else

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


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

--------------403058BA37F1A64BE60C5AD4-- --===============1513739454== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KYW1kLWdmeCBt YWlsaW5nIGxpc3QKYW1kLWdmeEBsaXN0cy5mcmVlZGVza3RvcC5vcmcKaHR0cHM6Ly9saXN0cy5m cmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9hbWQtZ2Z4Cg== --===============1513739454==--