Pekka Paalanen
2009-Aug-18 13:23 UTC
[Nouveau] [PATCH 1/2] drm/nouveau: minor gem cleanups
Signed-off-by: Pekka Paalanen <pq at iki.fi> --- drivers/gpu/drm/nouveau/nouveau_gem.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 64e59fb..75cae79 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -595,7 +595,7 @@ nouveau_gem_ioctl_pushbuf_call(struct drm_device *dev, void *data, bo = u_memcpya(req->buffers, req->nr_buffers, sizeof(*bo)); if (IS_ERR(bo)) - return (unsigned long)bo; + return PTR_ERR(bo); mutex_lock(&dev->struct_mutex); @@ -622,7 +622,7 @@ nouveau_gem_ioctl_pushbuf_call(struct drm_device *dev, void *data, ret = -EINVAL; goto out; } - pbbo = gem->driver_private; + pbbo = nouveau_gem_object(gem); ret = ttm_bo_reserve(&pbbo->bo, false, false, true, chan->fence.sequence); @@ -669,7 +669,8 @@ nouveau_gem_ioctl_pushbuf_call(struct drm_device *dev, void *data, /* Apply any relocations that are required */ if (do_reloc) { - ret = ttm_bo_kmap(&pbbo->bo, 0, pbbo->bo.mem.num_pages, &pbbo->kmap); + ret = ttm_bo_kmap(&pbbo->bo, 0, pbbo->bo.mem.num_pages, + &pbbo->kmap); if (ret) { NV_ERROR(dev, "kmap pb: %d\n", ret); goto out; -- 1.6.3.3
Pekka Paalanen
2009-Aug-18 13:23 UTC
[Nouveau] [PATCH 2/2] drm/nouveau: fix bo access after CALL implementation
TTM buffer object's virtual cookie may be an iomem cookie or a kernel virtual address. These need to be handled separately. Signed-off-by: Pekka Paalanen <pq at iki.fi> --- drivers/gpu/drm/nouveau/nouveau_gem.c | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 75cae79..6b150fc 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -408,7 +408,7 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_channel *chan, int nr_bo, struct drm_nouveau_gem_pushbuf_bo *bo, int nr_relocs, uint64_t ptr_relocs, int nr_dwords, int first_dword, - uint32_t *pushbuf) + uint32_t *pushbuf, bool is_iomem) { struct drm_nouveau_gem_pushbuf_reloc *reloc = NULL; struct drm_device *dev = chan->dev; @@ -451,7 +451,11 @@ nouveau_gem_pushbuf_reloc_apply(struct nouveau_channel *chan, int nr_bo, data |= r->vor; } - pushbuf[r->reloc_index] = data; + if (is_iomem) + iowrite32_native(data, (void __force __iomem *) + &pushbuf[r->reloc_index]); + else + pushbuf[r->reloc_index] = data; } kfree(reloc); @@ -516,7 +520,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data, bo, req->nr_relocs, req->relocs, req->nr_dwords, 0, - pushbuf); + pushbuf, false); if (ret) goto out; } @@ -669,6 +673,8 @@ nouveau_gem_ioctl_pushbuf_call(struct drm_device *dev, void *data, /* Apply any relocations that are required */ if (do_reloc) { + void *pbvirt; + bool is_iomem; ret = ttm_bo_kmap(&pbbo->bo, 0, pbbo->bo.mem.num_pages, &pbbo->kmap); if (ret) { @@ -676,17 +682,18 @@ nouveau_gem_ioctl_pushbuf_call(struct drm_device *dev, void *data, goto out; } + pbvirt = ttm_kmap_obj_virtual(&pbbo->kmap, &is_iomem); ret = nouveau_gem_pushbuf_reloc_apply(chan, req->nr_buffers, bo, req->nr_relocs, req->relocs, req->nr_dwords, req->offset / 4, - pbbo->kmap.virtual); + pbvirt, is_iomem); if (!PUSHBUF_CAL) { - uint32_t *pushbuf = pbbo->kmap.virtual + req->offset; - - pushbuf[req->nr_dwords - 2] = req->suffix0; + nouveau_bo_wr32(pbbo, + req->offset / 4 + req->nr_dwords - 2, + req->suffix0); } ttm_bo_kunmap(&pbbo->kmap); -- 1.6.3.3
Seemingly Similar Threads
- [PATCH 2/3] drm/nouveau: slowpath for pushbuf ioctl
- [PATCH 1/2] libdrm/nouveau: new optimized libdrm pushbuffer ABI
- [PATCH 2/3] drm/nouveau: slowpath for pushbuf ioctl
- [PATCH 2/3] drm/nouveau: slowpath for pushbuf ioctl
- [PATCH] Fix null deref in nouveau_fence_emit due to deleted fence