Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-30 Thread Xi Ruoyao
On 2021-03-30 15:24 +0200, Christian König wrote: > Am 30.03.21 um 15:23 schrieb Dan Horák: > > On Tue, 30 Mar 2021 21:09:12 +0800 > > Xi Ruoyao wrote: > > > > > On 2021-03-30 21:02 +0800, Xi Ruoyao wrote: > > > > On 2021-03-30 14:55 +0200, Christian König wrote: > > > > > I rather see this as a

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-30 Thread Xi Ruoyao
On 2021-03-30 03:40 +0800, Xi Ruoyao wrote: > On 2021-03-29 21:36 +0200, Christian König wrote: > > Am 29.03.21 um 21:27 schrieb Xi Ruoyao: > > > Hi Christian, > > > > > > I don't think there is any constraint implemented to ensure `num_entries % > > > AMDGPU_GPU_PAGES_IN_CPU_PAGE == 0`.  For exam

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-30 Thread Dan Horák
On Tue, 30 Mar 2021 14:55:01 +0200 Christian König wrote: > Am 30.03.21 um 14:04 schrieb Xi Ruoyao: > > On 2021-03-30 03:40 +0800, Xi Ruoyao wrote: > >> On 2021-03-29 21:36 +0200, Christian König wrote: > >>> Am 29.03.21 um 21:27 schrieb Xi Ruoyao: > Hi Christian, > > I don't think

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-30 Thread Dan Horák
On Tue, 30 Mar 2021 21:09:12 +0800 Xi Ruoyao wrote: > On 2021-03-30 21:02 +0800, Xi Ruoyao wrote: > > On 2021-03-30 14:55 +0200, Christian König wrote: > > > > > > I rather see this as a kernel bug. Can you test if this code fragment > > > fixes your issue: > > > > > > diff --git a/drivers/gpu

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-30 Thread Xi Ruoyao
On 2021-03-30 21:02 +0800, Xi Ruoyao wrote: > On 2021-03-30 14:55 +0200, Christian König wrote: > > > > I rather see this as a kernel bug. Can you test if this code fragment > > fixes your issue: > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c > > b/drivers/gpu/drm/amd/amdgpu/amdgp

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-30 Thread Xi Ruoyao
On 2021-03-30 14:55 +0200, Christian König wrote: > Am 30.03.21 um 14:04 schrieb Xi Ruoyao: > > On 2021-03-30 03:40 +0800, Xi Ruoyao wrote: > > > On 2021-03-29 21:36 +0200, Christian König wrote: > > > > Am 29.03.21 um 21:27 schrieb Xi Ruoyao: > > > > > Hi Christian, > > > > > > > > > > I don't th

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-30 Thread Christian König
Am 30.03.21 um 15:23 schrieb Dan Horák: On Tue, 30 Mar 2021 21:09:12 +0800 Xi Ruoyao wrote: On 2021-03-30 21:02 +0800, Xi Ruoyao wrote: On 2021-03-30 14:55 +0200, Christian König wrote: I rather see this as a kernel bug. Can you test if this code fragment fixes your issue: diff --git a/dr

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-30 Thread Christian König
Am 30.03.21 um 15:00 schrieb Dan Horák: On Tue, 30 Mar 2021 14:55:01 +0200 Christian König wrote: Am 30.03.21 um 14:04 schrieb Xi Ruoyao: On 2021-03-30 03:40 +0800, Xi Ruoyao wrote: On 2021-03-29 21:36 +0200, Christian König wrote: Am 29.03.21 um 21:27 schrieb Xi Ruoyao: Hi Christian, I d

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-30 Thread Christian König
Am 30.03.21 um 14:04 schrieb Xi Ruoyao: On 2021-03-30 03:40 +0800, Xi Ruoyao wrote: On 2021-03-29 21:36 +0200, Christian König wrote: Am 29.03.21 um 21:27 schrieb Xi Ruoyao: Hi Christian, I don't think there is any constraint implemented to ensure `num_entries % AMDGPU_GPU_PAGES_IN_CPU_PAGE =

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-29 Thread Xi Ruoyao
Hi Christian, I don't think there is any constraint implemented to ensure `num_entries % AMDGPU_GPU_PAGES_IN_CPU_PAGE == 0`. For example, in `amdgpu_vm_bo_map()`: /* validate the parameters */ if (saddr & AMDGPU_GPU_PAGE_MASK || offset & AMDGPU_GPU_PAGE_MASK || size =

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-29 Thread Xi Ruoyao
On 2021-03-29 20:04 +0200, Christian König wrote: > Am 29.03.21 um 19:53 schrieb Xℹ Ruoyao: > > If the initial value of `num_entires` (calculated at line 1654) is not > > an integral multiple of `AMDGPU_GPU_PAGES_IN_CPU_PAGE`, in line 1681 a > > value greater than the initial value will be assigned

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-29 Thread Xi Ruoyao
On 2021-03-29 20:10 +0200, Christian König wrote: > You need to identify the root cause of this, most likely start or last > are not a multiple of AMDGPU_GPU_PAGES_IN_CPU_PAGE. I printk'ed the value of start & last, they are all a multiple of 4 (AMDGPU_GPU_PAGES_IN_CPU_PAGE). However... `num_ent

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-29 Thread Xi Ruoyao
On 2021-03-29 21:36 +0200, Christian König wrote: > Am 29.03.21 um 21:27 schrieb Xi Ruoyao: > > Hi Christian, > > > > I don't think there is any constraint implemented to ensure `num_entries % > > AMDGPU_GPU_PAGES_IN_CPU_PAGE == 0`.  For example, in `amdgpu_vm_bo_map()`: > > > > /* valid

[PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-29 Thread Xℹ Ruoyao
If the initial value of `num_entires` (calculated at line 1654) is not an integral multiple of `AMDGPU_GPU_PAGES_IN_CPU_PAGE`, in line 1681 a value greater than the initial value will be assigned to it. That causes `start > last + 1` after line 1708. Then in the next iteration an underflow happen

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-29 Thread Xi Ruoyao
On 2021-03-30 02:21 +0800, Xi Ruoyao wrote: > On 2021-03-29 20:10 +0200, Christian König wrote: > > You need to identify the root cause of this, most likely start or last > > are not a multiple of AMDGPU_GPU_PAGES_IN_CPU_PAGE. > > I printk'ed the value of start & last, they are all a multiple of

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-29 Thread Christian König
Am 29.03.21 um 21:27 schrieb Xi Ruoyao: Hi Christian, I don't think there is any constraint implemented to ensure `num_entries % AMDGPU_GPU_PAGES_IN_CPU_PAGE == 0`. For example, in `amdgpu_vm_bo_map()`: /* validate the parameters */ if (saddr & AMDGPU_GPU_PAGE_MASK || offset

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-29 Thread Christian König
Am 29.03.21 um 20:08 schrieb Xi Ruoyao: On 2021-03-29 20:04 +0200, Christian König wrote: Am 29.03.21 um 19:53 schrieb Xℹ Ruoyao: If the initial value of `num_entires` (calculated at line 1654) is not an integral multiple of `AMDGPU_GPU_PAGES_IN_CPU_PAGE`, in line 1681 a value greater than the

Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems

2021-03-29 Thread Christian König
Am 29.03.21 um 19:53 schrieb Xℹ Ruoyao: If the initial value of `num_entires` (calculated at line 1654) is not an integral multiple of `AMDGPU_GPU_PAGES_IN_CPU_PAGE`, in line 1681 a value greater than the initial value will be assigned to it. That causes `start > last + 1` after line 1708. Then