AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Monk Liu <Monk.Liu-5C7GfCeVMHo@public.gmane.org>,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Emily Deng <Emily.Deng-5C7GfCeVMHo@public.gmane.org>
Subject: Re: [PATCH 18/22] drm/amdgpu: Correct sdma_v4 get_wptr
Date: Mon, 26 Feb 2018 11:22:06 +0100	[thread overview]
Message-ID: <b9826bed-1b38-cbee-536a-1bd9d50dca6b@gmail.com> (raw)
In-Reply-To: <1519622300-8990-19-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>

Am 26.02.2018 um 06:18 schrieb Monk Liu:
> From: Emily Deng <Emily.Deng@amd.com>
>
> the original method will change the wptr value in wb.
>
> Change-Id: I984fabca35d9dcf1f5fa8ef7779b2afb7f7d7370
> Signed-off-by: Emily Deng <Emily.Deng@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> index 3d5385d..8c6e408 100644
> --- a/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c
> @@ -240,13 +240,14 @@ static uint64_t sdma_v4_0_ring_get_wptr(struct amdgpu_ring *ring)
>   	struct amdgpu_device *adev = ring->adev;
>   	u64 *wptr = NULL;
>   	uint64_t local_wptr = 0;
> -
> +	u64 tmp = 0;

Please keep an empty line between deceleration and code.

>   	if (ring->use_doorbell) {
>   		/* XXX check if swapping is necessary on BE */
>   		wptr = ((u64 *)&adev->wb.wb[ring->wptr_offs]);
>   		DRM_DEBUG("wptr/doorbell before shift == 0x%016llx\n", *wptr);
> -		*wptr = (*wptr) >> 2;
> -		DRM_DEBUG("wptr/doorbell after shift == 0x%016llx\n", *wptr);
> +		tmp = (*wptr) >> 2;
> +		DRM_DEBUG("wptr/doorbell after shift == 0x%016llx\n", tmp);
> +		return tmp;

Well I completely agree that this code is absolutely nonsense and could 
result in complete random hardware behavior.

But I think we need further cleanup than what you already did. How about 
the following instead?

> static uint64_t sdma_v4_0_ring_get_wptr(struct amdgpu_ring *ring)
> {
>         struct amdgpu_device *adev = ring->adev;
>         uint64_t wptr;
>
>         if (ring->use_doorbell) {
>                 /* XXX check if swapping is necessary on BE */
>                 wptr = READ_ONCE(*((u64 *)&adev->wb.wb[ring->wptr_offs]));
>                 DRM_DEBUG("wptr/doorbell == 0x%016llx\n", *wptr);
>         } else {
>                 int me = (ring == &adev->sdma.instance[0].ring) ? 0 : 1;
>                 u32 lowbit, highbit;
>
>                 lowbit = RREG32(sdma_v4_0_get_reg_offset(adev, me, 
> mmSDMA0_GFX_RB_WPTR));
>                 highbit = RREG32(sdma_v4_0_get_reg_offset(adev, me, 
> mmSDMA0_GFX_RB_WPTR_HI));
>
>                 DRM_DEBUG("wptr [%i]high== 0x%08x low==0x%08x\n",
>                                 me, highbit, lowbit);
>                 wptr = highbit;
>                 wptr = wptr << 32;
>                 wptr |= lowbit;
>         }
>
>         return wptr >> 2;
> }

Good catch,
Christian.

>   	} else {
>   		u32 lowbit, highbit;
>   		int me = (ring == &adev->sdma.instance[0].ring) ? 0 : 1;
> @@ -260,9 +261,8 @@ static uint64_t sdma_v4_0_ring_get_wptr(struct amdgpu_ring *ring)
>   		*wptr = highbit;
>   		*wptr = (*wptr) << 32;
>   		*wptr |= lowbit;
> +		return *wptr;
>   	}
> -
> -	return *wptr;
>   }
>   
>   /**

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

  parent reply	other threads:[~2018-02-26 10:22 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-26  5:17 [PATCH 00/22] *** bug fixing serials *** Monk Liu
     [not found] ` <1519622300-8990-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26  5:17   ` [PATCH 01/22] drm/amdgpu: fix&cleanups for wb_clear Monk Liu
     [not found]     ` <1519622300-8990-2-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 17:18       ` Alex Deucher
2018-02-26  5:18   ` [PATCH 02/22] drm/amdgpu: remove duplicated job_free_resources Monk Liu
     [not found]     ` <1519622300-8990-3-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26  9:51       ` Christian König
2018-02-26  5:18   ` [PATCH 03/22] drm/amdgpu: skip ECC for SRIOV in gmc late_init Monk Liu
     [not found]     ` <1519622300-8990-4-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 17:19       ` Alex Deucher
2018-02-26  5:18   ` [PATCH 04/22] drm/amdgpu: only flush hotplug work without DC Monk Liu
     [not found]     ` <1519622300-8990-5-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 17:19       ` Alex Deucher
2018-02-26  5:18   ` [PATCH 05/22] drm/amdgpu: cond_exec only for schedule with a job Monk Liu
     [not found]     ` <1519622300-8990-6-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26  9:53       ` Christian König
2018-02-26  5:18   ` [PATCH 06/22] drm/amdgpu: don't use MM idle_work for SRIOV Monk Liu
     [not found]     ` <1519622300-8990-7-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26  9:57       ` Christian König
2018-02-26  5:18   ` [PATCH 07/22] drm/amdgpu: fix fence_emit NULL pointer ref risk Monk Liu
     [not found]     ` <1519622300-8990-8-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26  9:58       ` Christian König
2018-02-26  5:18   ` [PATCH 08/22] drm/amdgpu: cleanups VCE/UVD ib test part Monk Liu
     [not found]     ` <1519622300-8990-9-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 10:06       ` Christian König
2018-02-26  5:18   ` [PATCH 09/22] drm/amdgpu: fix kmd reload bug on bare-metal Monk Liu
     [not found]     ` <1519622300-8990-10-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 10:08       ` Christian König
     [not found]         ` <a89aeb3e-1687-e7e6-bef4-9371ecb13a70-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-02-27  4:45           ` Liu, Monk
     [not found]             ` <BLUPR12MB044911AD4E7442812B7D589084C00-7LeqcoF/hwpTIQvHjXdJlwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-02-27  8:42               ` Christian König
     [not found]                 ` <1b9d2cbf-1ba5-1be6-11ef-4723e08e9699-5C7GfCeVMHo@public.gmane.org>
2018-02-27  9:09                   ` Liu, Monk
     [not found]                     ` <BLUPR12MB0449EE0E7CD1DAE5C60290C684C00-7LeqcoF/hwpTIQvHjXdJlwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-02-27  9:52                       ` Christian König
     [not found]                         ` <07b98381-cbea-7352-7cf3-d69020da6395-5C7GfCeVMHo@public.gmane.org>
2018-02-27 10:19                           ` Liu, Monk
     [not found]                             ` <BLUPR12MB0449F97B88BE9D312DD5479784C00-7LeqcoF/hwpTIQvHjXdJlwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-02-27 10:29                               ` Christian König
2018-02-26  5:18   ` [PATCH 10/22] drm/amdgpu: no need to count emitted for SRIOV Monk Liu
     [not found]     ` <1519622300-8990-11-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 10:09       ` Christian König
     [not found]         ` <994af188-1283-44ea-f868-73f4002a7cb3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-02-27  5:26           ` Liu, Monk
     [not found]             ` <BLUPR12MB04493445BAD30EA2B4F14A8184C00-7LeqcoF/hwpTIQvHjXdJlwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-02-27  8:47               ` Christian König
2018-02-26  5:18   ` [PATCH 11/22] drm/amdgpu: Remove the memory leak after unload amdgpu driver Monk Liu
     [not found]     ` <1519622300-8990-12-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 17:27       ` Alex Deucher
     [not found]         ` <CADnq5_M9z3T0ihL9cDVbgEjaKp0AM=Utvs_J-=q7szT2NXtvrQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-02-27  5:27           ` Liu, Monk
     [not found]             ` <BLUPR12MB0449DF1E4689A22636F01AB484C00-7LeqcoF/hwpTIQvHjXdJlwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-02-27  5:53               ` Liu, Monk
2018-02-27  5:52       ` Liu, Monk
2018-02-26  5:18   ` [PATCH 12/22] drm/amdgpu: send rel event first after init failed Monk Liu
     [not found]     ` <1519622300-8990-13-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 17:24       ` Alex Deucher
2018-02-26  5:18   ` [PATCH 13/22] drm/amdgpu: fix vce_ring test memleak Monk Liu
     [not found]     ` <1519622300-8990-14-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 10:10       ` Christian König
2018-02-26  5:18   ` [PATCH 14/22] drm/amdgpu: change gfx9 ib test to use WB Monk Liu
     [not found]     ` <1519622300-8990-15-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 17:30       ` Alex Deucher
2018-02-26  5:18   ` [PATCH 15/22] drm/amdgpu: move WB_FREE to correct place Monk Liu
     [not found]     ` <1519622300-8990-16-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 17:36       ` Alex Deucher
2018-02-26  5:18   ` [PATCH 16/22] drm/amdgpu: cleanup SA inti and fini Monk Liu
     [not found]     ` <1519622300-8990-17-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 10:12       ` Christian König
     [not found]         ` <51af9fc4-7827-9f40-da2b-0fd8753bc321-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-02-26 10:41           ` Liu, Monk
     [not found]             ` <SN1PR12MB04625A0F831F186440F4A81684C10-z7L1TMIYDg7VaWpRXmIMygdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-02-26 10:48               ` Liu, Monk
     [not found]                 ` <SN1PR12MB04620B6D208218E5EB23824284C10-z7L1TMIYDg7VaWpRXmIMygdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-02-26 11:29                   ` Christian König
2018-02-26  5:18   ` [PATCH 17/22] drm/amdgpu: disable GFX ring and disable PQ wptr in hw_fini Monk Liu
     [not found]     ` <1519622300-8990-18-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 17:39       ` Alex Deucher
     [not found]         ` <CADnq5_M1BkpZzNURswAh1fTpm1rZbspkZ4qq+g2pbdVjWyR2eQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-02-27  5:31           ` Liu, Monk
     [not found]             ` <BLUPR12MB044966DA7194FE030265D15D84C00-7LeqcoF/hwpTIQvHjXdJlwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-02-27 14:28               ` Deucher, Alexander
2018-02-26  5:18   ` [PATCH 18/22] drm/amdgpu: Correct sdma_v4 get_wptr Monk Liu
     [not found]     ` <1519622300-8990-19-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 10:22       ` Christian König [this message]
     [not found]         ` <b9826bed-1b38-cbee-536a-1bd9d50dca6b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2018-02-27  5:35           ` Liu, Monk
2018-02-26  5:18   ` [PATCH 19/22] drm/amdgpu: adjust timeout for ib_ring_tests Monk Liu
     [not found]     ` <1519622300-8990-20-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 15:55       ` Alex Deucher
2018-02-26  5:18   ` [PATCH 20/22] drm/amdgpu: increase gart size to 512MB Monk Liu
     [not found]     ` <1519622300-8990-21-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org>
2018-02-26 17:45       ` 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=b9826bed-1b38-cbee-536a-1bd9d50dca6b@gmail.com \
    --to=ckoenig.leichtzumerken-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=Emily.Deng-5C7GfCeVMHo@public.gmane.org \
    --cc=Monk.Liu-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=christian.koenig-5C7GfCeVMHo@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox