mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Nikola Pajkovsky <npajkovsky@suse.cz>, <linux-kernel@vger.kernel.org>
Cc: Alex Deucher <alexander.deucher@amd.com>,
	David Airlie <airlied@linux.ie>, <amd-gfx@lists.freedesktop.org>,
	<dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] drm/amd/amdgpu: get rid of else branch
Date: Thu, 4 May 2017 15:14:36 +0200	[thread overview]
Message-ID: <6e2bf24d-ece1-7afa-2b33-fecd0eea7550@amd.com> (raw)
In-Reply-To: <5a3557799269f0c74694a10a5ee6a6427e2a4290.1493902309.git.npajkovsky@suse.cz>

Am 04.05.2017 um 14:52 schrieb Nikola Pajkovsky:
> else branch is pointless if it's right at the end of function and use
> unlikely() on err path.
>
> Signed-off-by: Nikola Pajkovsky <npajkovsky@suse.cz>

Reviewed-by: Christian König <christian.koenig@amd.com>

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu.h | 45 +++++++++++++++++++------------------
>   1 file changed, 23 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index c1b913541739..8ab250d4761a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -1594,30 +1594,31 @@ static inline void amdgpu_ring_write_multiple(struct amdgpu_ring *ring, void *sr
>   	unsigned occupied, chunk1, chunk2;
>   	void *dst;
>   
> -	if (ring->count_dw < count_dw) {
> +	if (unlikely(ring->count_dw < count_dw)) {
>   		DRM_ERROR("amdgpu: writing more dwords to the ring than expected!\n");
> -	} else {
> -		occupied = ring->wptr & ring->ptr_mask;
> -		dst = (void *)&ring->ring[occupied];
> -		chunk1 = ring->ptr_mask + 1 - occupied;
> -		chunk1 = (chunk1 >= count_dw) ? count_dw: chunk1;
> -		chunk2 = count_dw - chunk1;
> -		chunk1 <<= 2;
> -		chunk2 <<= 2;
> -
> -		if (chunk1)
> -			memcpy(dst, src, chunk1);
> -
> -		if (chunk2) {
> -			src += chunk1;
> -			dst = (void *)ring->ring;
> -			memcpy(dst, src, chunk2);
> -		}
> -
> -		ring->wptr += count_dw;
> -		ring->wptr &= ring->ptr_mask;
> -		ring->count_dw -= count_dw;
> +		return;
>   	}
> +
> +	occupied = ring->wptr & ring->ptr_mask;
> +	dst = (void *)&ring->ring[occupied];
> +	chunk1 = ring->ptr_mask + 1 - occupied;
> +	chunk1 = (chunk1 >= count_dw) ? count_dw: chunk1;
> +	chunk2 = count_dw - chunk1;
> +	chunk1 <<= 2;
> +	chunk2 <<= 2;
> +
> +	if (chunk1)
> +		memcpy(dst, src, chunk1);
> +
> +	if (chunk2) {
> +		src += chunk1;
> +		dst = (void *)ring->ring;
> +		memcpy(dst, src, chunk2);
> +	}
> +
> +	ring->wptr += count_dw;
> +	ring->wptr &= ring->ptr_mask;
> +	ring->count_dw -= count_dw;
>   }
>   
>   static inline struct amdgpu_sdma_instance *

  reply	other threads:[~2017-05-04 13:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-04 12:52 Nikola Pajkovsky
2017-05-04 13:14 ` Christian König [this message]
2017-05-04 16:41   ` 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=6e2bf24d-ece1-7afa-2b33-fecd0eea7550@amd.com \
    --to=christian.koenig@amd.com \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=npajkovsky@suse.cz \
    /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

Powered by JetHome