[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20180713160127.GA14777@vmware.com>
Date: Fri, 13 Jul 2018 09:01:28 -0700
From: Sinclair Yeh <syeh@...are.com>
To: Christian König <christian.koenig@....com>
Cc: "Gustavo A. R. Silva" <gustavo@...eddedor.com>,
Roger He <Hongbo.He@....com>, David Airlie <airlied@...ux.ie>,
linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org
Subject: Re: [PATCH] drm/ttm: use swap macro in ttm_bo_handle_move_mem
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@...eddedor.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.
Powered by blists - more mailing lists