All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>,
	DRI Development <dri-devel@lists.freedesktop.org>
Cc: linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org,
	linux-rdma@vger.kernel.org, amd-gfx@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org,
	Chris Wilson <chris@chris-wilson.co.uk>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH] drm/amdgpu/dc: Stop dma_resv_lock inversion in commit_tail
Date: Tue, 28 Jul 2020 08:56:37 +0200	[thread overview]
Message-ID: <d4e687e9-cf0b-384f-5982-849d0fa11147@amd.com> (raw)
In-Reply-To: <20200727213017.852589-1-daniel.vetter@ffwll.ch>

Am 27.07.20 um 23:30 schrieb Daniel Vetter:
> Trying to grab dma_resv_lock while in commit_tail before we've done
> all the code that leads to the eventual signalling of the vblank event
> (which can be a dma_fence) is deadlock-y. Don't do that.
>
> Here the solution is easy because just grabbing locks to read
> something races anyway. We don't need to bother, READ_ONCE is
> equivalent. And avoids the locking issue.
>
> v2: Also take into account tmz_surface boolean, plus just delete the
> old code.
>
> Cc: linux-media@vger.kernel.org
> Cc: linaro-mm-sig@lists.linaro.org
> Cc: linux-rdma@vger.kernel.org
> Cc: amd-gfx@lists.freedesktop.org
> Cc: intel-gfx@lists.freedesktop.org
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Christian König <christian.koenig@amd.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
> DC-folks, I think this split out patch from my series here
>
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fdri-devel%2F20200707201229.472834-1-daniel.vetter%40ffwll.ch%2F&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7C8a4f5736682a4b5c943e08d832747ab1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637314823145521840&amp;sdata=qd7Nrox62Lr%2FXWbJJFVskg9RYL4%2FoRVCFjR6rUDMA5E%3D&amp;reserved=0
>
> should be ready for review/merging. I fixed it up a bit so that it's not
> just a gross hack :-)
>
> Cheers, Daniel
>
>
> ---
>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 ++++++-------------
>   1 file changed, 6 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 21ec64fe5527..a20b62b1f2ef 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -6959,20 +6959,13 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
>   			DRM_ERROR("Waiting for fences timed out!");
>   
>   		/*
> -		 * TODO This might fail and hence better not used, wait
> -		 * explicitly on fences instead
> -		 * and in general should be called for
> -		 * blocking commit to as per framework helpers
> +		 * We cannot reserve buffers here, which means the normal flag
> +		 * access functions don't work. Paper over this with READ_ONCE,
> +		 * but maybe the flags are invariant enough that not even that
> +		 * would be needed.
>   		 */
> -		r = amdgpu_bo_reserve(abo, true);
> -		if (unlikely(r != 0))
> -			DRM_ERROR("failed to reserve buffer before flip\n");
> -
> -		amdgpu_bo_get_tiling_flags(abo, &tiling_flags);
> -
> -		tmz_surface = amdgpu_bo_encrypted(abo);
> -
> -		amdgpu_bo_unreserve(abo);
> +		tiling_flags = READ_ONCE(abo->tiling_flags);
> +		tmz_surface = READ_ONCE(abo->flags) & AMDGPU_GEM_CREATE_ENCRYPTED;

Yeah, the abo->flags are mostly fixed after creation, especially the 
encrypted flag can't change or we corrupt page table tables. So that 
should work fine.

Anybody who picks this up feel free to add an Reviewed-by: Christian 
König <christian.koenig@amd.com>.

Regards,
Christian.

>   
>   		fill_dc_plane_info_and_addr(
>   			dm->adev, new_plane_state, tiling_flags,


WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <christian.koenig@amd.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>,
	DRI Development <dri-devel@lists.freedesktop.org>
Cc: linux-rdma@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	amd-gfx@lists.freedesktop.org,
	Chris Wilson <chris@chris-wilson.co.uk>,
	linaro-mm-sig@lists.linaro.org,
	Daniel Vetter <daniel.vetter@intel.com>,
	linux-media@vger.kernel.org
Subject: Re: [PATCH] drm/amdgpu/dc: Stop dma_resv_lock inversion in commit_tail
Date: Tue, 28 Jul 2020 08:56:37 +0200	[thread overview]
Message-ID: <d4e687e9-cf0b-384f-5982-849d0fa11147@amd.com> (raw)
In-Reply-To: <20200727213017.852589-1-daniel.vetter@ffwll.ch>

Am 27.07.20 um 23:30 schrieb Daniel Vetter:
> Trying to grab dma_resv_lock while in commit_tail before we've done
> all the code that leads to the eventual signalling of the vblank event
> (which can be a dma_fence) is deadlock-y. Don't do that.
>
> Here the solution is easy because just grabbing locks to read
> something races anyway. We don't need to bother, READ_ONCE is
> equivalent. And avoids the locking issue.
>
> v2: Also take into account tmz_surface boolean, plus just delete the
> old code.
>
> Cc: linux-media@vger.kernel.org
> Cc: linaro-mm-sig@lists.linaro.org
> Cc: linux-rdma@vger.kernel.org
> Cc: amd-gfx@lists.freedesktop.org
> Cc: intel-gfx@lists.freedesktop.org
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Christian König <christian.koenig@amd.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
> DC-folks, I think this split out patch from my series here
>
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fdri-devel%2F20200707201229.472834-1-daniel.vetter%40ffwll.ch%2F&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7C8a4f5736682a4b5c943e08d832747ab1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637314823145521840&amp;sdata=qd7Nrox62Lr%2FXWbJJFVskg9RYL4%2FoRVCFjR6rUDMA5E%3D&amp;reserved=0
>
> should be ready for review/merging. I fixed it up a bit so that it's not
> just a gross hack :-)
>
> Cheers, Daniel
>
>
> ---
>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 ++++++-------------
>   1 file changed, 6 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 21ec64fe5527..a20b62b1f2ef 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -6959,20 +6959,13 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
>   			DRM_ERROR("Waiting for fences timed out!");
>   
>   		/*
> -		 * TODO This might fail and hence better not used, wait
> -		 * explicitly on fences instead
> -		 * and in general should be called for
> -		 * blocking commit to as per framework helpers
> +		 * We cannot reserve buffers here, which means the normal flag
> +		 * access functions don't work. Paper over this with READ_ONCE,
> +		 * but maybe the flags are invariant enough that not even that
> +		 * would be needed.
>   		 */
> -		r = amdgpu_bo_reserve(abo, true);
> -		if (unlikely(r != 0))
> -			DRM_ERROR("failed to reserve buffer before flip\n");
> -
> -		amdgpu_bo_get_tiling_flags(abo, &tiling_flags);
> -
> -		tmz_surface = amdgpu_bo_encrypted(abo);
> -
> -		amdgpu_bo_unreserve(abo);
> +		tiling_flags = READ_ONCE(abo->tiling_flags);
> +		tmz_surface = READ_ONCE(abo->flags) & AMDGPU_GEM_CREATE_ENCRYPTED;

Yeah, the abo->flags are mostly fixed after creation, especially the 
encrypted flag can't change or we corrupt page table tables. So that 
should work fine.

Anybody who picks this up feel free to add an Reviewed-by: Christian 
König <christian.koenig@amd.com>.

Regards,
Christian.

>   
>   		fill_dc_plane_info_and_addr(
>   			dm->adev, new_plane_state, tiling_flags,

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <christian.koenig@amd.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>,
	DRI Development <dri-devel@lists.freedesktop.org>
Cc: linux-rdma@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	amd-gfx@lists.freedesktop.org,
	Chris Wilson <chris@chris-wilson.co.uk>,
	linaro-mm-sig@lists.linaro.org,
	Daniel Vetter <daniel.vetter@intel.com>,
	linux-media@vger.kernel.org
Subject: Re: [Intel-gfx] [PATCH] drm/amdgpu/dc: Stop dma_resv_lock inversion in commit_tail
Date: Tue, 28 Jul 2020 08:56:37 +0200	[thread overview]
Message-ID: <d4e687e9-cf0b-384f-5982-849d0fa11147@amd.com> (raw)
In-Reply-To: <20200727213017.852589-1-daniel.vetter@ffwll.ch>

Am 27.07.20 um 23:30 schrieb Daniel Vetter:
> Trying to grab dma_resv_lock while in commit_tail before we've done
> all the code that leads to the eventual signalling of the vblank event
> (which can be a dma_fence) is deadlock-y. Don't do that.
>
> Here the solution is easy because just grabbing locks to read
> something races anyway. We don't need to bother, READ_ONCE is
> equivalent. And avoids the locking issue.
>
> v2: Also take into account tmz_surface boolean, plus just delete the
> old code.
>
> Cc: linux-media@vger.kernel.org
> Cc: linaro-mm-sig@lists.linaro.org
> Cc: linux-rdma@vger.kernel.org
> Cc: amd-gfx@lists.freedesktop.org
> Cc: intel-gfx@lists.freedesktop.org
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Christian König <christian.koenig@amd.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
> DC-folks, I think this split out patch from my series here
>
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fdri-devel%2F20200707201229.472834-1-daniel.vetter%40ffwll.ch%2F&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7C8a4f5736682a4b5c943e08d832747ab1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637314823145521840&amp;sdata=qd7Nrox62Lr%2FXWbJJFVskg9RYL4%2FoRVCFjR6rUDMA5E%3D&amp;reserved=0
>
> should be ready for review/merging. I fixed it up a bit so that it's not
> just a gross hack :-)
>
> Cheers, Daniel
>
>
> ---
>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 ++++++-------------
>   1 file changed, 6 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 21ec64fe5527..a20b62b1f2ef 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -6959,20 +6959,13 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
>   			DRM_ERROR("Waiting for fences timed out!");
>   
>   		/*
> -		 * TODO This might fail and hence better not used, wait
> -		 * explicitly on fences instead
> -		 * and in general should be called for
> -		 * blocking commit to as per framework helpers
> +		 * We cannot reserve buffers here, which means the normal flag
> +		 * access functions don't work. Paper over this with READ_ONCE,
> +		 * but maybe the flags are invariant enough that not even that
> +		 * would be needed.
>   		 */
> -		r = amdgpu_bo_reserve(abo, true);
> -		if (unlikely(r != 0))
> -			DRM_ERROR("failed to reserve buffer before flip\n");
> -
> -		amdgpu_bo_get_tiling_flags(abo, &tiling_flags);
> -
> -		tmz_surface = amdgpu_bo_encrypted(abo);
> -
> -		amdgpu_bo_unreserve(abo);
> +		tiling_flags = READ_ONCE(abo->tiling_flags);
> +		tmz_surface = READ_ONCE(abo->flags) & AMDGPU_GEM_CREATE_ENCRYPTED;

Yeah, the abo->flags are mostly fixed after creation, especially the 
encrypted flag can't change or we corrupt page table tables. So that 
should work fine.

Anybody who picks this up feel free to add an Reviewed-by: Christian 
König <christian.koenig@amd.com>.

Regards,
Christian.

>   
>   		fill_dc_plane_info_and_addr(
>   			dm->adev, new_plane_state, tiling_flags,

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

WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <christian.koenig@amd.com>
To: Daniel Vetter <daniel.vetter@ffwll.ch>,
	DRI Development <dri-devel@lists.freedesktop.org>
Cc: linux-rdma@vger.kernel.org, intel-gfx@lists.freedesktop.org,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	amd-gfx@lists.freedesktop.org,
	Chris Wilson <chris@chris-wilson.co.uk>,
	linaro-mm-sig@lists.linaro.org,
	Daniel Vetter <daniel.vetter@intel.com>,
	linux-media@vger.kernel.org
Subject: Re: [PATCH] drm/amdgpu/dc: Stop dma_resv_lock inversion in commit_tail
Date: Tue, 28 Jul 2020 08:56:37 +0200	[thread overview]
Message-ID: <d4e687e9-cf0b-384f-5982-849d0fa11147@amd.com> (raw)
In-Reply-To: <20200727213017.852589-1-daniel.vetter@ffwll.ch>

Am 27.07.20 um 23:30 schrieb Daniel Vetter:
> Trying to grab dma_resv_lock while in commit_tail before we've done
> all the code that leads to the eventual signalling of the vblank event
> (which can be a dma_fence) is deadlock-y. Don't do that.
>
> Here the solution is easy because just grabbing locks to read
> something races anyway. We don't need to bother, READ_ONCE is
> equivalent. And avoids the locking issue.
>
> v2: Also take into account tmz_surface boolean, plus just delete the
> old code.
>
> Cc: linux-media@vger.kernel.org
> Cc: linaro-mm-sig@lists.linaro.org
> Cc: linux-rdma@vger.kernel.org
> Cc: amd-gfx@lists.freedesktop.org
> Cc: intel-gfx@lists.freedesktop.org
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Christian König <christian.koenig@amd.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
> DC-folks, I think this split out patch from my series here
>
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fdri-devel%2F20200707201229.472834-1-daniel.vetter%40ffwll.ch%2F&amp;data=02%7C01%7Cchristian.koenig%40amd.com%7C8a4f5736682a4b5c943e08d832747ab1%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637314823145521840&amp;sdata=qd7Nrox62Lr%2FXWbJJFVskg9RYL4%2FoRVCFjR6rUDMA5E%3D&amp;reserved=0
>
> should be ready for review/merging. I fixed it up a bit so that it's not
> just a gross hack :-)
>
> Cheers, Daniel
>
>
> ---
>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 ++++++-------------
>   1 file changed, 6 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 21ec64fe5527..a20b62b1f2ef 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -6959,20 +6959,13 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
>   			DRM_ERROR("Waiting for fences timed out!");
>   
>   		/*
> -		 * TODO This might fail and hence better not used, wait
> -		 * explicitly on fences instead
> -		 * and in general should be called for
> -		 * blocking commit to as per framework helpers
> +		 * We cannot reserve buffers here, which means the normal flag
> +		 * access functions don't work. Paper over this with READ_ONCE,
> +		 * but maybe the flags are invariant enough that not even that
> +		 * would be needed.
>   		 */
> -		r = amdgpu_bo_reserve(abo, true);
> -		if (unlikely(r != 0))
> -			DRM_ERROR("failed to reserve buffer before flip\n");
> -
> -		amdgpu_bo_get_tiling_flags(abo, &tiling_flags);
> -
> -		tmz_surface = amdgpu_bo_encrypted(abo);
> -
> -		amdgpu_bo_unreserve(abo);
> +		tiling_flags = READ_ONCE(abo->tiling_flags);
> +		tmz_surface = READ_ONCE(abo->flags) & AMDGPU_GEM_CREATE_ENCRYPTED;

Yeah, the abo->flags are mostly fixed after creation, especially the 
encrypted flag can't change or we corrupt page table tables. So that 
should work fine.

Anybody who picks this up feel free to add an Reviewed-by: Christian 
König <christian.koenig@amd.com>.

Regards,
Christian.

>   
>   		fill_dc_plane_info_and_addr(
>   			dm->adev, new_plane_state, tiling_flags,

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

  parent reply	other threads:[~2020-07-28  6:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27 21:30 [PATCH] drm/amdgpu/dc: Stop dma_resv_lock inversion in commit_tail Daniel Vetter
2020-07-27 21:30 ` Daniel Vetter
2020-07-27 21:30 ` [Intel-gfx] " Daniel Vetter
2020-07-27 21:30 ` Daniel Vetter
2020-07-27 21:40 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for " Patchwork
2020-07-27 21:40 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2020-07-27 22:01 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2020-07-27 23:24 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2020-07-28  6:56 ` Christian König [this message]
2020-07-28  6:56   ` [PATCH] " Christian König
2020-07-28  6:56   ` [Intel-gfx] " Christian König
2020-07-28  6:56   ` Christian König
2020-07-29 22:10   ` Alex Deucher
2020-07-29 22:10     ` Alex Deucher
2020-07-29 22:10     ` [Intel-gfx] " Alex Deucher
2020-07-29 22:10     ` 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=d4e687e9-cf0b-384f-5982-849d0fa11147@amd.com \
    --to=christian.koenig@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    /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.