drm/amdgpu: drop multiple bo_unreserve() calls in amdgpu_gem_op_ioctl()
Subsystems (2)
PATCH 1/2 drm/amdgpu: drop multiple bo_unreserve() calls in amdgpu_gem_op_ioctl()
Move amdgpu_bo_unreserve() outside of the switch. While we are at it, add a missing break in the default case.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2 -5
@@ -660,7 +660,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, info.alignment = robj->tbo.mem.page_alignment <<PAGE_SHIFT ; info.domains = robj->prefered_domains; info.domain_flags = robj->flags; -amdgpu_bo_unreserve (robj);if (copy_to_user (out, &info,sizeof (info))) r = -EFAULT ;break ;
@@ -668,7 +667,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,case AMDGPU_GEM_OP_SET_PLACEMENT :if (amdgpu_ttm_tt_get_usermm (robj->tbo.ttm)) { r = -EPERM ; -amdgpu_bo_unreserve (robj);break ; } robj->prefered_domains = args->value & (AMDGPU_GEM_DOMAIN_VRAM |
@@ -677,14 +675,13 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, robj->allowed_domains = robj->prefered_domains;if (robj->allowed_domains ==AMDGPU_GEM_DOMAIN_VRAM ) robj->allowed_domains |=AMDGPU_GEM_DOMAIN_GTT ; - -amdgpu_bo_unreserve (robj);break ;default : -amdgpu_bo_unreserve (robj); r = -EINVAL ; +break ; } +amdgpu_bo_unreserve (robj); out:drm_gem_object_unreference_unlocked (gobj);return r;
Signature · 6 lines
2.11.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170209222824.3267-1-samuel.pitoiset-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
PATCH 2/2 drm/amdgpu: use amdgpu_gem_va_check() in amdgpu_gem_va_update_vm()
This removes code duplication.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1 -7
@@ -506,13 +506,7 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,list_for_each_entry (entry, list, head) {struct amdgpu_bo *bo = container_of(entry->bo, struct amdgpu_bo, tbo); - -/* if anything is swapped out don't swap it in here, -just abort and wait for the next CS */ -if (!amdgpu_bo_gpu_accessible (bo)) - goto error; - -if (bo->shadow && !amdgpu_bo_gpu_accessible (bo->shadow)) +if (amdgpu_gem_va_check (NULL , bo)) goto error; }
Signature · 6 lines
2.11.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170209222824.3267-2-samuel.pitoiset-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
zhoucm1
Reviewed-by Chunming ZhouRe: [PATCH 2/2] drm/amdgpu: use amdgpu_gem_va_check() in amdgpu_gem_va_update_vm()
Quoted 3 lines · Samuel Pitoiset
This removes code duplication.
Signed-off-by Samuel Pitoiset <[email protected]>
Thanks,
David Zhou
Quoted 13 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-1@@ -506,13 +506,7 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,list_for_each_entry (entry, list, head) {struct amdgpu_bo *bo = container_of(entry->bo, struct amdgpu_bo, tbo); -
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, · line 512
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-6-/* if anything is swapped out don't swap it in here, -just abort and wait for the next CS */ -if (!amdgpu_bo_gpu_accessible (bo)) - goto error; - -if (bo->shadow && !amdgpu_bo_gpu_accessible (bo->shadow)) +if (amdgpu_gem_va_check (NULL , bo)) goto error; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
Reviewed-byRe: [PATCH 2/2] drm/amdgpu: use amdgpu_gem_va_check() in amdgpu_gem_va_update_vm()
In reply to a message not in the archiveAm 09.02.2017 um 23:28 schrieb Samuel Pitoiset:
Quoted 3 lines
This removes code duplication.
Signed-off-by Samuel Pitoiset <[email protected]>
Quoted 13 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-1@@ -506,13 +506,7 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,list_for_each_entry (entry, list, head) {struct amdgpu_bo *bo = container_of(entry->bo, struct amdgpu_bo, tbo); -
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, · line 512
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-6-/* if anything is swapped out don't swap it in here, -just abort and wait for the next CS */ -if (!amdgpu_bo_gpu_accessible (bo)) - goto error; - -if (bo->shadow && !amdgpu_bo_gpu_accessible (bo->shadow)) +if (amdgpu_gem_va_check (NULL , bo)) goto error; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
AppliedRe: [PATCH 2/2] drm/amdgpu: use amdgpu_gem_va_check() in amdgpu_gem_va_update_vm()
In reply to a message not in the archiveQuoted 3 lines · Samuel Pitoiset
This removes code duplication.
Signed-off-by Samuel Pitoiset <[email protected]>
Applied. thanks!
Alex
Quoted 26 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-8@@ -506,13 +506,7 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev,list_for_each_entry (entry, list, head) {struct amdgpu_bo *bo = container_of(entry->bo, struct amdgpu_bo, tbo); - -/* if anything is swapped out don't swap it in here, -just abort and wait for the next CS */ -if (!amdgpu_bo_gpu_accessible (bo)) - goto error; - -if (bo->shadow && !amdgpu_bo_gpu_accessible (bo->shadow)) +if (amdgpu_gem_va_check (NULL , bo)) goto error; } --2.11.1
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
zhoucm1
NAKQuoted 13 lines · Samuel Pitoiset
Move
amdgpu_bo_unreserve()outside of the switch. While we are at it, add a missing break in the default case.Signed-off-by Samuel Pitoiset <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, · line 664
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-1@@ -660,7 +660,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, info.alignment = robj->tbo.mem.page_alignment <<PAGE_SHIFT ; info.domains = robj->prefered_domains; info.domain_flags = robj->flags; -amdgpu_bo_unreserve (robj);if (copy_to_user (out, &info,sizeof (info))) r = -EFAULT ;
NAK, your this change will break our previous deadlock fix for ww_mutex and mm->mmap_sem if I remember correctly.
Regards,
David Zhou
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-3break ;@@ -668,7 +667,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,case AMDGPU_GEM_OP_SET_PLACEMENT :if (amdgpu_ttm_tt_get_usermm (robj->tbo.ttm)) { r = -EPERM ; -amdgpu_bo_unreserve (robj);break ; } robj->prefered_domains = args->value & (AMDGPU_GEM_DOMAIN_VRAM |@@ -677,14 +675,13 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, robj->allowed_domains = robj->prefered_domains;if (robj->allowed_domains ==AMDGPU_GEM_DOMAIN_VRAM ) robj->allowed_domains |=AMDGPU_GEM_DOMAIN_GTT ; - -amdgpu_bo_unreserve (robj);break ;
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, · line 687
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-1default : -amdgpu_bo_unreserve (robj); r = -EINVAL ; +break ; } +amdgpu_bo_unreserve (robj); out:drm_gem_object_unreference_unlocked (gobj);return r;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · On 02/10/2017 03:55 AM, zhoucm1 wrote:
Quoted 8 lines · Samuel Pitoiset
Move
amdgpu_bo_unreserve()outside of the switch. While we are at it, add a missing break in the default case.Signed-off-by Samuel Pitoiset <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev, · line 665
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-1@@ -660,7 +660,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, info.alignment = robj->tbo.mem.page_alignment << PAGE_SHIFT; info.domains = robj->prefered_domains; info.domain_flags = robj->flags; -amdgpu_bo_unreserve (robj);if (copy_to_user (out, &info,sizeof (info))) r = -EFAULT ;NAK, your this change will break our previous deadlock fix for
ww_mutexandmm->mmap_semif I remember correctly.
Mmh, really? Can you pinpoint the commit? I don't see anything obvious in the history about that.
Thanks.
Quoted 23 lines
Regards,
David ZhouQuoted 20 lines
break;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-1@@ -668,7 +667,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, case AMDGPU_GEM_OP_SET_PLACEMENT: if (amdgpu_ttm_tt_get_usermm(robj->tbo.ttm)) { r = -EPERM; -amdgpu_bo_unreserve (robj);break ; }robj->prefered_domains = args->value &(
AMDGPU_GEM_DOMAIN_VRAM|drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-2@@ -677,14 +675,13 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, robj->allowed_domains = robj->prefered_domains;if (robj->allowed_domains ==AMDGPU_GEM_DOMAIN_VRAM ) robj->allowed_domains |=AMDGPU_GEM_DOMAIN_GTT ; - -amdgpu_bo_unreserve (robj);break ;default :
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, · line 687
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-1-amdgpu_bo_unreserve (robj); r = -EINVAL ; +break ; } +amdgpu_bo_unreserve (robj); out:drm_gem_object_unreference_unlocked (gobj);return r;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 0c47615f-6e93-eea1-418c-f846a0c1d3ae-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Am 10.02.2017 um 11:11 schrieb Samuel Pitoiset:
Quoted 30 lines · On 02/10/2017 03:55 AM, zhoucm1 wrote:
Quoted 11 lines · Samuel Pitoiset
Quoted 8 lines
Move
amdgpu_bo_unreserve()outside of the switch. While we are at it, add a missing break in the default case.Signed-off-by Samuel Pitoiset <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev, · line 665
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-1@@ -660,7 +660,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, info.alignment = robj->tbo.mem.page_alignment << PAGE_SHIFT; info.domains = robj->prefered_domains; info.domain_flags = robj->flags; -amdgpu_bo_unreserve (robj);if (copy_to_user (out, &info,sizeof (info))) r = -EFAULT ;NAK, your this change will break our previous deadlock fix for
ww_mutexandmm->mmap_semif I remember correctly.
Quoted 1 line
Mmh, really? Can you pinpoint the commit? I don't see anything obvious in the history about that.
David is right here. Not sure when we fixed that, but in general calling copy_to/from_user while a BO is reserved is illegal.
Otherwise somebody could send the kernel a memory mapped BO as address and the copy_to/from_user would just deadlock because it tries to reserve a BO while another (or the same) BO is already reserved in the call path.
Regards,
Christian.
Quoted 35 lines
Thanks.
Quoted 23 lines
Regards,
David ZhouQuoted 20 lines
break;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-1@@ -668,7 +667,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, case AMDGPU_GEM_OP_SET_PLACEMENT: if (amdgpu_ttm_tt_get_usermm(robj->tbo.ttm)) { r = -EPERM; -amdgpu_bo_unreserve (robj);break ; }robj->prefered_domains = args->value &(
AMDGPU_GEM_DOMAIN_VRAM|drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-2@@ -677,14 +675,13 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, robj->allowed_domains = robj->prefered_domains;if (robj->allowed_domains ==AMDGPU_GEM_DOMAIN_VRAM ) robj->allowed_domains |=AMDGPU_GEM_DOMAIN_GTT ; - -amdgpu_bo_unreserve (robj);break ;default :Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, · line 687
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-1-amdgpu_bo_unreserve (robj); r = -EINVAL ; +break ; } +amdgpu_bo_unreserve (robj); out:drm_gem_object_unreference_unlocked (gobj);return r;
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): f297f821-678a-392a-2786-0307dc7a54ad-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Quoted 34 lines · Christian König
Am 10.02.2017 um 11:11 schrieb Samuel Pitoiset:
Quoted 30 lines · On 02/10/2017 03:55 AM, zhoucm1 wrote:
Quoted 11 lines · Samuel Pitoiset
Quoted 8 lines
Move
amdgpu_bo_unreserve()outside of the switch. While we are at it, add a missing break in the default case.Signed-off-by Samuel Pitoiset <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev, · line 665
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-1@@ -660,7 +660,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, info.alignment = robj->tbo.mem.page_alignment << PAGE_SHIFT; info.domains = robj->prefered_domains; info.domain_flags = robj->flags; -amdgpu_bo_unreserve (robj);if (copy_to_user (out, &info,sizeof (info))) r = -EFAULT ;NAK, your this change will break our previous deadlock fix for
ww_mutexandmm->mmap_semif I remember correctly.Quoted 2 lines
Mmh, really? Can you pinpoint the commit? I don't see anything obvious in the history about that.
Quoted 7 lines
David is right here. Not sure when we fixed that, but in general calling copy_to/from_user while a BO is reserved is illegal.
Otherwise somebody could send the kernel a memory mapped BO as address and the copy_to/from_user would just deadlock because it tries to reserve a BO while another (or the same) BO is already reserved in the call path.
Okay, makes more sense.
Thanks for the review. My goal is not to introduce new regressions but I didn't know that.
Maybe this should be explained in the code? Just a thought.
Quoted 45 lines
Regards,
Christian.Quoted 39 lines
Thanks.
Quoted 23 lines
Regards,
David ZhouQuoted 20 lines
break;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-1@@ -668,7 +667,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, case AMDGPU_GEM_OP_SET_PLACEMENT: if (amdgpu_ttm_tt_get_usermm(robj->tbo.ttm)) { r = -EPERM; -amdgpu_bo_unreserve (robj);break ; }robj->prefered_domains = args->value &(
AMDGPU_GEM_DOMAIN_VRAM|drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-2@@ -677,14 +675,13 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, robj->allowed_domains = robj->prefered_domains;if (robj->allowed_domains ==AMDGPU_GEM_DOMAIN_VRAM ) robj->allowed_domains |=AMDGPU_GEM_DOMAIN_GTT ; - -amdgpu_bo_unreserve (robj);break ;default :Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev,
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-1-amdgpu_bo_unreserve (robj); r = -EINVAL ; +break ; } +amdgpu_bo_unreserve (robj); out:drm_gem_object_unreference_unlocked (gobj);return r;_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): fcf33caf-41c4-5344-ede7-9be1cecf813c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Am 10.02.2017 um 11:22 schrieb Samuel Pitoiset:
Quoted 46 lines · Christian König
Quoted 35 lines
Am 10.02.2017 um 11:11 schrieb Samuel Pitoiset:
Quoted 31 lines · On 02/10/2017 03:55 AM, zhoucm1 wrote:
Quoted 11 lines · Samuel Pitoiset
Quoted 8 lines
Move
amdgpu_bo_unreserve()outside of the switch. While we are at it, add a missing break in the default case.Signed-off-by Samuel Pitoiset <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)Quoted 16 lines
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-1@@ -660,7 +660,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, info.alignment = robj->tbo.mem.page_alignment <<PAGE_SHIFT ; info.domains = robj->prefered_domains; info.domain_flags = robj->flags; -amdgpu_bo_unreserve (robj);if (copy_to_user (out, &info,sizeof (info)))Quoted 1 line
r = -EFAULT;NAK, your this change will break our previous deadlock fix for
ww_mutexandmm->mmap_semif I remember correctly.Quoted 2 lines
Mmh, really? Can you pinpoint the commit? I don't see anything obvious in the history about that.
Quoted 7 lines
David is right here. Not sure when we fixed that, but in general calling copy_to/from_user while a BO is reserved is illegal.
Otherwise somebody could send the kernel a memory mapped BO as address and the copy_to/from_user would just deadlock because it tries to reserve a BO while another (or the same) BO is already reserved in the call path.
Quoted 5 lines
Okay, makes more sense.
Thanks for the review. My goal is not to introduce new regressions but I didn't know that.
Maybe this should be explained in the code? Just a thought.
We do have a comment in the TTM mapping code I think.
But copy_to/from_user and BO reservation is just so common that we would need to add the same comment on a whole bunch of different places and that doesn't make to much sense.
But in this particular case a comment might make sense because I think somebody proposed the same patch before. Ah! Enlightenment, that also explains why you can't find it in the history. We just rejected the same patch multiple times now :)
Regards,
Christian.
Quoted 46 lines
Quoted 46 lines
Regards,
Christian.Quoted 39 lines
Thanks.
Quoted 23 lines
Regards,
David ZhouQuoted 20 lines
break;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-1@@ -668,7 +667,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, case AMDGPU_GEM_OP_SET_PLACEMENT: if (amdgpu_ttm_tt_get_usermm(robj->tbo.ttm)) { r = -EPERM; -amdgpu_bo_unreserve (robj);break ; }robj->prefered_domains = args->value &(
AMDGPU_GEM_DOMAIN_VRAM|drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-2@@ -677,14 +675,13 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, robj->allowed_domains = robj->prefered_domains;if (robj->allowed_domains ==AMDGPU_GEM_DOMAIN_VRAM ) robj->allowed_domains |=AMDGPU_GEM_DOMAIN_GTT ; - -amdgpu_bo_unreserve (robj);break ;default :Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev,
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-1-amdgpu_bo_unreserve (robj); r = -EINVAL ; +break ; } +amdgpu_bo_unreserve (robj); out:drm_gem_object_unreference_unlocked (gobj);return r;_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 185ea16c-7062-f137-2234-a19f845062a6-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Quoted 57 lines · Christian König
Am 10.02.2017 um 11:22 schrieb Samuel Pitoiset:
Quoted 47 lines · Christian König
Quoted 36 lines
Am 10.02.2017 um 11:11 schrieb Samuel Pitoiset:
Quoted 32 lines · On 02/10/2017 03:55 AM, zhoucm1 wrote:
Quoted 20 lines · Samuel Pitoiset
Quoted 17 lines
Move
amdgpu_bo_unreserve()outside of the switch. While we are at it, add a missing break in the default case.Signed-off-by Samuel Pitoiset <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-0@@ -660,7 +660,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, info.alignment = robj->tbo.mem.page_alignment <<PAGE_SHIFT ;Quoted 8 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-1info.domains = robj->prefered_domains; info.domain_flags = robj->flags; -amdgpu_bo_unreserve (robj);if (copy_to_user (out, &info,sizeof (info)))r = -EFAULT;NAK, your this change will break our previous deadlock fix for
ww_mutex
andmm->mmap_semif I remember correctly.Quoted 2 lines
Mmh, really? Can you pinpoint the commit? I don't see anything obvious in the history about that.
Quoted 7 lines
David is right here. Not sure when we fixed that, but in general calling copy_to/from_user while a BO is reserved is illegal.
Otherwise somebody could send the kernel a memory mapped BO as address and the copy_to/from_user would just deadlock because it tries to reserve a BO while another (or the same) BO is already reserved in the call path.
Quoted 6 lines
Okay, makes more sense.
Thanks for the review. My goal is not to introduce new regressions but I didn't know that.
Maybe this should be explained in the code? Just a thought.
We do have a comment in the TTM mapping code I think.
Quoted 8 lines
But copy_to/from_user and BO reservation is just so common that we would need to add the same comment on a whole bunch of different places and that doesn't make to much sense.
But in this particular case a comment might make sense because I think somebody proposed the same patch before. Ah! Enlightenment, that also explains why you can't find it in the history. We just rejected the same patch multiple times now :)
Yeah, I bet someone else will submit the same patch in few weeks/months without a comment explaining why we shouldn't change it. :)
Quoted 56 lines
Regards,
Christian.Quoted 50 lines
Quoted 46 lines
Regards,
Christian.Quoted 39 lines
Thanks.
Quoted 23 lines
Regards,
David ZhouQuoted 20 lines
break;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-1@@ -668,7 +667,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, case AMDGPU_GEM_OP_SET_PLACEMENT: if (amdgpu_ttm_tt_get_usermm(robj->tbo.ttm)) { r = -EPERM; -amdgpu_bo_unreserve (robj);break ; }robj->prefered_domains = args->value &(
AMDGPU_GEM_DOMAIN_VRAM|drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-2@@ -677,14 +675,13 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, robj->allowed_domains = robj->prefered_domains;if (robj->allowed_domains ==AMDGPU_GEM_DOMAIN_VRAM ) robj->allowed_domains |=AMDGPU_GEM_DOMAIN_GTT ; - -amdgpu_bo_unreserve (robj);break ;default :Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev,
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-1-amdgpu_bo_unreserve (robj); r = -EINVAL ; +break ; } +amdgpu_bo_unreserve (robj); out:drm_gem_object_unreference_unlocked (gobj);return r;_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
NAKNAK, we need to drop the reservation before calling copy_to_user().
Otherwise you run into a double locking error when copy_to_user() is trying to copy to the BO in question.
Regards,
Christian.
Am 09.02.2017 um 23:28 schrieb Samuel Pitoiset:
Quoted 35 lines
Move
amdgpu_bo_unreserve()outside of the switch. While we are at it, add a missing break in the default case.Signed-off-by Samuel Pitoiset <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-4@@ -660,7 +660,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, info.alignment = robj->tbo.mem.page_alignment <<PAGE_SHIFT ; info.domains = robj->prefered_domains; info.domain_flags = robj->flags; -amdgpu_bo_unreserve (robj);if (copy_to_user (out, &info,sizeof (info))) r = -EFAULT ;break ;@@ -668,7 +667,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data,case AMDGPU_GEM_OP_SET_PLACEMENT :if (amdgpu_ttm_tt_get_usermm (robj->tbo.ttm)) { r = -EPERM ; -amdgpu_bo_unreserve (robj);break ; } robj->prefered_domains = args->value & (AMDGPU_GEM_DOMAIN_VRAM |@@ -677,14 +675,13 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, robj->allowed_domains = robj->prefered_domains;if (robj->allowed_domains ==AMDGPU_GEM_DOMAIN_VRAM ) robj->allowed_domains |=AMDGPU_GEM_DOMAIN_GTT ; - -amdgpu_bo_unreserve (robj);break ;
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, · line 687
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +2
-1default : -amdgpu_bo_unreserve (robj); r = -EINVAL ; +break ; } +amdgpu_bo_unreserve (robj); out:drm_gem_object_unreference_unlocked (gobj);return r;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 35f1c55d-5ade-ffd0-6c9f-95fc891e1d77-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Quoted 4 lines · Christian König
NAK, we need to drop the reservation before calling
copy_to_user().Otherwise you run into a double locking error when
copy_to_user()is trying to copy to the BO in question.
Okay, I trust you but this seems tricky. copy_to_user() doesn't even take the BO as parameter, how can this happen?
Quoted 46 lines
Regards,
Christian.Am 09.02.2017 um 23:28 schrieb Samuel Pitoiset:
Quoted 41 lines
Move
amdgpu_bo_unreserve()outside of the switch. While we are at it, add a missing break in the default case.Signed-off-by Samuel Pitoiset <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-1@@ -660,7 +660,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, info.alignment = robj->tbo.mem.page_alignment << PAGE_SHIFT; info.domains = robj->prefered_domains; info.domain_flags = robj->flags; -amdgpu_bo_unreserve (robj);if (copy_to_user (out, &info,sizeof (info))) r = -EFAULT ;break;drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-1@@ -668,7 +667,6 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, case AMDGPU_GEM_OP_SET_PLACEMENT: if (amdgpu_ttm_tt_get_usermm(robj->tbo.ttm)) { r = -EPERM; -amdgpu_bo_unreserve (robj);break ; }robj->prefered_domains = args->value &(
AMDGPU_GEM_DOMAIN_VRAM|drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +0
-2@@ -677,14 +675,13 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev,void *data, robj->allowed_domains = robj->prefered_domains;if (robj->allowed_domains ==AMDGPU_GEM_DOMAIN_VRAM ) robj->allowed_domains |=AMDGPU_GEM_DOMAIN_GTT ; - -amdgpu_bo_unreserve (robj);break ;default :
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, · line 687
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +1
-1-amdgpu_bo_unreserve (robj); r = -EINVAL ; +break ; } +amdgpu_bo_unreserve (robj); out:drm_gem_object_unreference_unlocked (gobj);return r;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx