dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Sinclair Yeh <syeh@vmware.com>
To: "Christian König" <christian.koenig@amd.com>
Cc: David Airlie <airlied@linux.ie>, Roger He <Hongbo.He@amd.com>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Subject: Re: [PATCH] drm/ttm: use swap macro in ttm_bo_handle_move_mem
Date: Fri, 13 Jul 2018 09:01:28 -0700	[thread overview]
Message-ID: <20180713160127.GA14777@vmware.com> (raw)
In-Reply-To: <56e7e63d-f66f-194d-4f0b-3fb9642e7ff9@amd.com>

On Fri, Jul 13, 2018 at 08:41:37AM +0200, Christian König wrote:
> Am 13.07.2018 um 04:37 schrieb Sinclair Yeh:
> >On Mon, Jul 09, 2018 at 10:24:47AM -0500, Gustavo A. R. Silva wrote:
> >>Make use of the swap macro and remove unnecessary variable *tmp_mem*.
> >>This makes the code easier to read and maintain. Also, reduces the
> >>stack usage.
> >>
> >>This code was detected with the help of Coccinelle.
> >>
> >>Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> >>---
> >>  drivers/gpu/drm/ttm/ttm_bo.c | 7 ++-----
> >>  1 file changed, 2 insertions(+), 5 deletions(-)
> >>
> >>diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> >>index 5d8688e52..5142dcb 100644
> >>--- a/drivers/gpu/drm/ttm/ttm_bo.c
> >>+++ b/drivers/gpu/drm/ttm/ttm_bo.c
> >>@@ -287,12 +287,9 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
> >>  	if (ret) {
> >>  		if (bdev->driver->move_notify) {
> >>-			struct ttm_mem_reg tmp_mem = *mem;
> >>-			*mem = bo->mem;
> >>-			bo->mem = tmp_mem;
> >>+			swap(*mem, bo->mem);
> >>  			bdev->driver->move_notify(bo, false, mem);
> >>-			bo->mem = *mem;
> >>-			*mem = tmp_mem;
> >>+			swap(*mem, bo->mem);
> >This code assumes bo->mem is the same as tmp_mem after the call to
> >move_notify. Is this always true?
> 
> Actually the old code assumed that. Using the swap macro now fixed that
> little unclean implementation.

Ok, thanks for the clarification.  This looks good to me.

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

      reply	other threads:[~2018-07-13 16:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-09 15:24 [PATCH] drm/ttm: use swap macro in ttm_bo_handle_move_mem Gustavo A. R. Silva
2018-07-13  2:37 ` Sinclair Yeh
2018-07-13  6:41   ` Christian König
2018-07-13 16:01     ` Sinclair Yeh [this message]

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=20180713160127.GA14777@vmware.com \
    --to=syeh@vmware.com \
    --cc=Hongbo.He@amd.com \
    --cc=airlied@linux.ie \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gustavo@embeddedor.com \
    --cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).