Maarten Maathuis
2009-Dec-24 18:33 UTC
[Nouveau] [PATCH] nouveau: when nouveau_bo_map fails you expect it to not be mapped
- This includes unmapping on failure to sync for cpu access. - Double mapping will also be punished, so that people fix their code. --- nouveau/nouveau_bo.c | 23 ++++++++++++++++------- 1 files changed, 16 insertions(+), 7 deletions(-) diff --git a/nouveau/nouveau_bo.c b/nouveau/nouveau_bo.c index 10cc8a6..9a7c368 100644 --- a/nouveau/nouveau_bo.c +++ b/nouveau/nouveau_bo.c @@ -415,22 +415,28 @@ nouveau_bo_map_range(struct nouveau_bo *bo, uint32_t delta, uint32_t size, uint32_t flags) { struct nouveau_bo_priv *nvbo = nouveau_bo(bo); - int ret; + int ret = 0; - if (!nvbo || bo->map) + if (!nvbo) return -EINVAL; + /* People should not double map, let's make sure they will notice. */ + if (bo->map) { + ret = -EINVAL; + goto out; + } + if (!nouveau_bo_allocated(nvbo)) { if (nvbo->flags & (NOUVEAU_BO_VRAM | NOUVEAU_BO_GART)) { ret = nouveau_bo_kalloc(nvbo, NULL); if (ret) - return ret; + goto out; } if (!nouveau_bo_allocated(nvbo)) { ret = nouveau_bo_ualloc(nvbo); if (ret) - return ret; + goto out; } } @@ -439,19 +445,22 @@ nouveau_bo_map_range(struct nouveau_bo *bo, uint32_t delta, uint32_t size, } else { ret = nouveau_bo_kmap(nvbo); if (ret) - return ret; + goto out; if (!(flags & NOUVEAU_BO_NOSYNC)) { ret = nouveau_bo_wait(bo, (flags & NOUVEAU_BO_WR), (flags & NOUVEAU_BO_NOWAIT), 0); if (ret) - return ret; + goto out; } bo->map = (char *)nvbo->map + delta; } - return 0; +out: + if (ret) + nouveau_bo_unmap(bo); + return ret; } void -- 1.6.6.rc4
Dave Airlie
2009-Dec-25 10:43 UTC
[Nouveau] [PATCH] nouveau: when nouveau_bo_map fails you expect it to not be mapped
On Fri, Dec 25, 2009 at 4:33 AM, Maarten Maathuis <madman2003 at gmail.com> wrote:> - This includes unmapping on failure to sync for cpu access. > - Double mapping will also be punished, so that people fix their code.Not sure that'll work too well for sw fallbacks, you can same src/dst pixmap or same texture/colorbuffer and the mapping code should just work. Dave.
Seemingly Similar Threads
- [PATCH] libdrm/nouveau: Support nested bo mapping
- [Bug 24092] New: X with nouveau hangs in nouveau_bo_map_range when doing anything
- [Bug 48454] New: Xorg hang and have to kill X from ssh
- [PATCH 1/2] nv50: don't emit reloc markers after a referenced vtxbuf is mapped
- NV30 (FX 5200 Ultra) OUT_RINGp and initial four GEM objects are mapped to the GART instead of System RAM - is that proper?