diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2014-02-10 02:24:06 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2014-02-10 02:24:06 +0000 |
commit | 7d1ccc14f35bd3d433c2ac78d564f8b35aac4355 (patch) | |
tree | 8719e90692606b761dca0066435f4afcef5bf733 | |
parent | 6780ac82cf3725731061bca667b56a2360d78c5e (diff) |
drm/ttm: Fix ttm_bo_move_memcpy
From Thomas Hellstrom
1fe70122dd9b926e84b14d1603202ae2ef2c5edd in ubuntu 3.8
da95c788ef0c645378ffccb7060a0df1a33aee38 in mainline linux
-rw-r--r-- | sys/dev/pci/drm/ttm/ttm_bo_util.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/sys/dev/pci/drm/ttm/ttm_bo_util.c b/sys/dev/pci/drm/ttm/ttm_bo_util.c index 44ec787e16d..34cbd214769 100644 --- a/sys/dev/pci/drm/ttm/ttm_bo_util.c +++ b/sys/dev/pci/drm/ttm/ttm_bo_util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ttm_bo_util.c,v 1.4 2014/02/10 02:15:25 jsg Exp $ */ +/* $OpenBSD: ttm_bo_util.c,v 1.5 2014/02/10 02:24:05 jsg Exp $ */ /************************************************************************** * * Copyright (c) 2007-2009 VMware, Inc., Palo Alto, CA., USA @@ -342,21 +342,25 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, if (ret) goto out; + /* + * Single TTM move. NOP. + */ if (old_iomap == NULL && new_iomap == NULL) goto out2; + + /* + * Move nonexistent data. NOP. + */ if (old_iomap == NULL && ttm == NULL) goto out2; - /* TTM might be null for moves within the same region. + /* + * TTM might be null for moves within the same region. */ if (ttm && ttm->state == tt_unpopulated) { ret = ttm->bdev->driver->ttm_tt_populate(ttm); - if (ret) { - /* if we fail here don't nuke the mm node - * as the bo still owns it */ - old_copy.mm_node = NULL; + if (ret) goto out1; - } } add = 0; @@ -382,11 +386,8 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, prot); } else ret = ttm_copy_io_page(new_iomap, old_iomap, page); - if (ret) { - /* failing here, means keep old copy as-is */ - old_copy.mm_node = NULL; + if (ret) goto out1; - } } DRM_MEMORYBARRIER(); out2: @@ -404,7 +405,12 @@ out1: ttm_mem_reg_iounmap(bdev, old_mem, new_iomap); out: ttm_mem_reg_iounmap(bdev, &old_copy, old_iomap); - ttm_bo_mem_put(bo, &old_copy); + + /* + * On error, keep the mm node! + */ + if (!ret) + ttm_bo_mem_put(bo, &old_copy); return ret; } EXPORT_SYMBOL(ttm_bo_move_memcpy); |