Skip to content

Commit

Permalink
Merge branch 'for-airlied-next' of git://people.freedesktop.org/~mlan…
Browse files Browse the repository at this point in the history
…khorst/linux into drm-next

fixups for nouveau and fencing

* 'for-airlied-next' of git://people.freedesktop.org/~mlankhorst/linux:
  drm/nouveau: export reservation_object from dmabuf to ttm
  drm/ttm: add reservation_object as argument to ttm_bo_init
  drm: Pass dma-buf as argument to gem_prime_import_sg_table
  drm/nouveau: assign fence_chan->name correctly
  drm/nouveau: specify if interruptible wait is desired in nouveau_fence_sync
  drm/nouveau: bump driver patchlevel to 1.2.1
  • Loading branch information
Dave Airlie committed Oct 1, 2014
2 parents c5939a7 + bb6178b commit 7a42e83
Show file tree
Hide file tree
Showing 36 changed files with 126 additions and 63 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/ast/ast_ttm.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ int ast_bo_create(struct drm_device *dev, int size, int align,
ret = ttm_bo_init(&ast->ttm.bdev, &astbo->bo, size,
ttm_bo_type_device, &astbo->placement,
align >> PAGE_SHIFT, false, NULL, acc_size,
NULL, ast_bo_ttm_destroy);
NULL, NULL, ast_bo_ttm_destroy);
if (ret)
return ret;

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/bochs/bochs_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ static int bochs_bo_create(struct drm_device *dev, int size, int align,
ret = ttm_bo_init(&bochs->ttm.bdev, &bochsbo->bo, size,
ttm_bo_type_device, &bochsbo->placement,
align >> PAGE_SHIFT, false, NULL, acc_size,
NULL, bochs_bo_ttm_destroy);
NULL, NULL, bochs_bo_ttm_destroy);
if (ret)
return ret;

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/cirrus/cirrus_ttm.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ int cirrus_bo_create(struct drm_device *dev, int size, int align,
ret = ttm_bo_init(&cirrus->ttm.bdev, &cirrusbo->bo, size,
ttm_bo_type_device, &cirrusbo->placement,
align >> PAGE_SHIFT, false, NULL, acc_size,
NULL, cirrus_bo_ttm_destroy);
NULL, NULL, cirrus_bo_ttm_destroy);
if (ret)
return ret;

Expand Down
7 changes: 4 additions & 3 deletions drivers/gpu/drm/drm_gem_cma_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ struct sg_table *drm_gem_cma_prime_get_sg_table(struct drm_gem_object *obj)
EXPORT_SYMBOL_GPL(drm_gem_cma_prime_get_sg_table);

struct drm_gem_object *
drm_gem_cma_prime_import_sg_table(struct drm_device *dev, size_t size,
drm_gem_cma_prime_import_sg_table(struct drm_device *dev,
struct dma_buf_attachment *attach,
struct sg_table *sgt)
{
struct drm_gem_cma_object *cma_obj;
Expand All @@ -325,14 +326,14 @@ drm_gem_cma_prime_import_sg_table(struct drm_device *dev, size_t size,
return ERR_PTR(-EINVAL);

/* Create a CMA GEM buffer. */
cma_obj = __drm_gem_cma_create(dev, size);
cma_obj = __drm_gem_cma_create(dev, attach->dmabuf->size);
if (IS_ERR(cma_obj))
return ERR_CAST(cma_obj);

cma_obj->paddr = sg_dma_address(sgt->sgl);
cma_obj->sgt = sgt;

DRM_DEBUG_PRIME("dma_addr = %pad, size = %zu\n", &cma_obj->paddr, size);
DRM_DEBUG_PRIME("dma_addr = %pad, size = %zu\n", &cma_obj->paddr, attach->dmabuf->size);

return &cma_obj->base;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/drm_prime.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ struct drm_gem_object *drm_gem_prime_import(struct drm_device *dev,
goto fail_detach;
}

obj = dev->driver->gem_prime_import_sg_table(dev, dma_buf->size, sgt);
obj = dev->driver->gem_prime_import_sg_table(dev, attach, sgt);
if (IS_ERR(obj)) {
ret = PTR_ERR(obj);
goto fail_unmap;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/mgag200/mgag200_ttm.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ int mgag200_bo_create(struct drm_device *dev, int size, int align,
ret = ttm_bo_init(&mdev->ttm.bdev, &mgabo->bo, size,
ttm_bo_type_device, &mgabo->placement,
align >> PAGE_SHIFT, false, NULL, acc_size,
NULL, mgag200_bo_ttm_destroy);
NULL, NULL, mgag200_bo_ttm_destroy);
if (ret)
return ret;

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/msm/msm_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj);
void *msm_gem_prime_vmap(struct drm_gem_object *obj);
void msm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
struct drm_gem_object *msm_gem_prime_import_sg_table(struct drm_device *dev,
size_t size, struct sg_table *sg);
struct dma_buf_attachment *attach, struct sg_table *sg);
int msm_gem_prime_pin(struct drm_gem_object *obj);
void msm_gem_prime_unpin(struct drm_gem_object *obj);
void *msm_gem_vaddr_locked(struct drm_gem_object *obj);
Expand Down
5 changes: 3 additions & 2 deletions drivers/gpu/drm/msm/msm_gem_prime.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "msm_drv.h"
#include "msm_gem.h"

#include <linux/dma-buf.h>

struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj)
{
Expand All @@ -37,9 +38,9 @@ void msm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
}

struct drm_gem_object *msm_gem_prime_import_sg_table(struct drm_device *dev,
size_t size, struct sg_table *sg)
struct dma_buf_attachment *attach, struct sg_table *sg)
{
return msm_gem_import(dev, size, sg);
return msm_gem_import(dev, attach->dmabuf->size, sg);
}

int msm_gem_prime_pin(struct drm_gem_object *obj)
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/nouveau/dispnv04/crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ nv04_crtc_create(struct drm_device *dev, int crtc_num)
drm_mode_crtc_set_gamma_size(&nv_crtc->base, 256);

ret = nouveau_bo_new(dev, 64*64*4, 0x100, TTM_PL_FLAG_VRAM,
0, 0x0000, NULL, &nv_crtc->cursor.nvbo);
0, 0x0000, NULL, NULL, &nv_crtc->cursor.nvbo);
if (!ret) {
ret = nouveau_bo_pin(nv_crtc->cursor.nvbo, TTM_PL_FLAG_VRAM);
if (!ret) {
Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/nouveau/nouveau_bo.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ nouveau_bo_fixup_align(struct nouveau_bo *nvbo, u32 flags,
int
nouveau_bo_new(struct drm_device *dev, int size, int align,
uint32_t flags, uint32_t tile_mode, uint32_t tile_flags,
struct sg_table *sg,
struct sg_table *sg, struct reservation_object *robj,
struct nouveau_bo **pnvbo)
{
struct nouveau_drm *drm = nouveau_drm(dev);
Expand Down Expand Up @@ -230,7 +230,7 @@ nouveau_bo_new(struct drm_device *dev, int size, int align,
ret = ttm_bo_init(&drm->ttm.bdev, &nvbo->bo, size,
type, &nvbo->placement,
align >> PAGE_SHIFT, false, NULL, acc_size, sg,
nouveau_bo_del_ttm);
robj, nouveau_bo_del_ttm);
if (ret) {
/* ttm will call nouveau_bo_del_ttm if it fails.. */
return ret;
Expand Down Expand Up @@ -970,7 +970,7 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
}

mutex_lock_nested(&cli->mutex, SINGLE_DEPTH_NESTING);
ret = nouveau_fence_sync(nouveau_bo(bo), chan, true);
ret = nouveau_fence_sync(nouveau_bo(bo), chan, true, intr);
if (ret == 0) {
ret = drm->ttm.move(chan, bo, &bo->mem, new_mem);
if (ret == 0) {
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/nouveau/nouveau_bo.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ extern struct ttm_bo_driver nouveau_bo_driver;
void nouveau_bo_move_init(struct nouveau_drm *);
int nouveau_bo_new(struct drm_device *, int size, int align, u32 flags,
u32 tile_mode, u32 tile_flags, struct sg_table *sg,
struct reservation_object *robj,
struct nouveau_bo **);
int nouveau_bo_pin(struct nouveau_bo *, u32 flags);
int nouveau_bo_unpin(struct nouveau_bo *);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/nouveau/nouveau_chan.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ nouveau_channel_prep(struct nouveau_drm *drm, struct nvif_device *device,
if (nouveau_vram_pushbuf)
target = TTM_PL_FLAG_VRAM;

ret = nouveau_bo_new(drm->dev, size, 0, target, 0, 0, NULL,
ret = nouveau_bo_new(drm->dev, size, 0, target, 0, 0, NULL, NULL,
&chan->push.buffer);
if (ret == 0) {
ret = nouveau_bo_pin(chan->push.buffer, target);
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/nouveau/nouveau_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ nouveau_page_flip_emit(struct nouveau_channel *chan,
spin_unlock_irqrestore(&dev->event_lock, flags);

/* Synchronize with the old framebuffer */
ret = nouveau_fence_sync(old_bo, chan, false);
ret = nouveau_fence_sync(old_bo, chan, false, false);
if (ret)
goto fail;

Expand Down Expand Up @@ -722,7 +722,7 @@ nouveau_crtc_page_flip(struct drm_crtc *crtc, struct drm_framebuffer *fb,
goto fail_unpin;

/* synchronise rendering channel with the kernel's channel */
ret = nouveau_fence_sync(new_bo, chan, false);
ret = nouveau_fence_sync(new_bo, chan, false, true);
if (ret) {
ttm_bo_unreserve(&new_bo->bo);
goto fail_unpin;
Expand Down
4 changes: 3 additions & 1 deletion drivers/gpu/drm/nouveau/nouveau_drm.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#define DRIVER_MAJOR 1
#define DRIVER_MINOR 2
#define DRIVER_PATCHLEVEL 0
#define DRIVER_PATCHLEVEL 1

/*
* 1.1.1:
Expand All @@ -26,6 +26,8 @@
* 1.2.0:
* - object api exposed to userspace
* - fermi,kepler,maxwell zbc
* 1.2.1:
* - allow concurrent access to bo's mapped read/write.
*/

#include <nvif/client.h>
Expand Down
53 changes: 43 additions & 10 deletions drivers/gpu/drm/nouveau/nouveau_fence.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ nouveau_fence_context_del(struct nouveau_fence_chan *fctx)
spin_unlock_irq(&fctx->lock);
}

static void
nouveau_fence_context_put(struct kref *fence_ref)
{
kfree(container_of(fence_ref, struct nouveau_fence_chan, fence_ref));
}

void
nouveau_fence_context_free(struct nouveau_fence_chan *fctx)
{
kref_put(&fctx->fence_ref, nouveau_fence_context_put);
}

static void
nouveau_fence_update(struct nouveau_channel *chan, struct nouveau_fence_chan *fctx)
{
Expand Down Expand Up @@ -141,13 +153,22 @@ void
nouveau_fence_context_new(struct nouveau_channel *chan, struct nouveau_fence_chan *fctx)
{
struct nouveau_fence_priv *priv = (void*)chan->drm->fence;
struct nouveau_cli *cli = (void *)nvif_client(chan->object);
int ret;

INIT_LIST_HEAD(&fctx->flip);
INIT_LIST_HEAD(&fctx->pending);
spin_lock_init(&fctx->lock);
fctx->context = priv->context_base + chan->chid;

if (chan == chan->drm->cechan)
strcpy(fctx->name, "copy engine channel");
else if (chan == chan->drm->channel)
strcpy(fctx->name, "generic kernel channel");
else
strcpy(fctx->name, nvkm_client(&cli->base)->name);

kref_init(&fctx->fence_ref);
if (!priv->uevent)
return;

Expand Down Expand Up @@ -195,8 +216,12 @@ nouveau_fence_work(struct fence *fence,

work = kmalloc(sizeof(*work), GFP_KERNEL);
if (!work) {
/*
* this might not be a nouveau fence any more,
* so force a lazy wait here
*/
WARN_ON(nouveau_fence_wait((struct nouveau_fence *)fence,
false, false));
true, false));
goto err;
}

Expand Down Expand Up @@ -226,12 +251,11 @@ nouveau_fence_emit(struct nouveau_fence *fence, struct nouveau_channel *chan)

if (priv->uevent)
fence_init(&fence->base, &nouveau_fence_ops_uevent,
&fctx->lock,
priv->context_base + chan->chid, ++fctx->sequence);
&fctx->lock, fctx->context, ++fctx->sequence);
else
fence_init(&fence->base, &nouveau_fence_ops_legacy,
&fctx->lock,
priv->context_base + chan->chid, ++fctx->sequence);
&fctx->lock, fctx->context, ++fctx->sequence);
kref_get(&fctx->fence_ref);

trace_fence_emit(&fence->base);
ret = fctx->emit(fence);
Expand Down Expand Up @@ -342,7 +366,7 @@ nouveau_fence_wait(struct nouveau_fence *fence, bool lazy, bool intr)
}

int
nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool exclusive)
nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool exclusive, bool intr)
{
struct nouveau_fence_chan *fctx = chan->fence;
struct fence *fence;
Expand All @@ -369,7 +393,7 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e
prev = f->channel;

if (!prev || (prev != chan && (ret = fctx->sync(f, prev, chan))))
ret = fence_wait(fence, true);
ret = fence_wait(fence, intr);

return ret;
}
Expand All @@ -387,8 +411,8 @@ nouveau_fence_sync(struct nouveau_bo *nvbo, struct nouveau_channel *chan, bool e
if (f)
prev = f->channel;

if (!prev || (ret = fctx->sync(f, prev, chan)))
ret = fence_wait(fence, true);
if (!prev || (prev != chan && (ret = fctx->sync(f, prev, chan))))
ret = fence_wait(fence, intr);

if (ret)
break;
Expand Down Expand Up @@ -482,13 +506,22 @@ static bool nouveau_fence_no_signaling(struct fence *f)
return true;
}

static void nouveau_fence_release(struct fence *f)
{
struct nouveau_fence *fence = from_fence(f);
struct nouveau_fence_chan *fctx = nouveau_fctx(fence);

kref_put(&fctx->fence_ref, nouveau_fence_context_put);
fence_free(&fence->base);
}

static const struct fence_ops nouveau_fence_ops_legacy = {
.get_driver_name = nouveau_fence_get_get_driver_name,
.get_timeline_name = nouveau_fence_get_timeline_name,
.enable_signaling = nouveau_fence_no_signaling,
.signaled = nouveau_fence_is_signaled,
.wait = nouveau_fence_wait_legacy,
.release = NULL
.release = nouveau_fence_release
};

static bool nouveau_fence_enable_signaling(struct fence *f)
Expand Down
7 changes: 5 additions & 2 deletions drivers/gpu/drm/nouveau/nouveau_fence.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ int nouveau_fence_emit(struct nouveau_fence *, struct nouveau_channel *);
bool nouveau_fence_done(struct nouveau_fence *);
void nouveau_fence_work(struct fence *, void (*)(void *), void *);
int nouveau_fence_wait(struct nouveau_fence *, bool lazy, bool intr);
int nouveau_fence_sync(struct nouveau_bo *, struct nouveau_channel *, bool exclusive);
int nouveau_fence_sync(struct nouveau_bo *, struct nouveau_channel *, bool exclusive, bool intr);

struct nouveau_fence_chan {
spinlock_t lock;
struct kref fence_ref;

struct list_head pending;
struct list_head flip;

Expand All @@ -42,7 +44,7 @@ struct nouveau_fence_chan {

u32 sequence;
u32 context;
char name[24];
char name[32];

struct nvif_notify notify;
int notify_ref;
Expand All @@ -63,6 +65,7 @@ struct nouveau_fence_priv {

void nouveau_fence_context_new(struct nouveau_channel *, struct nouveau_fence_chan *);
void nouveau_fence_context_del(struct nouveau_fence_chan *);
void nouveau_fence_context_free(struct nouveau_fence_chan *);

int nv04_fence_create(struct nouveau_drm *);
int nv04_fence_mthd(struct nouveau_channel *, u32, u32, u32);
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/nouveau/nouveau_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ nouveau_gem_new(struct drm_device *dev, int size, int align, uint32_t domain,
flags |= TTM_PL_FLAG_SYSTEM;

ret = nouveau_bo_new(dev, size, align, flags, tile_mode,
tile_flags, NULL, pnvbo);
tile_flags, NULL, NULL, pnvbo);
if (ret)
return ret;
nvbo = *pnvbo;
Expand Down Expand Up @@ -459,7 +459,7 @@ validate_list(struct nouveau_channel *chan, struct nouveau_cli *cli,
return ret;
}

ret = nouveau_fence_sync(nvbo, chan, !!b->write_domains);
ret = nouveau_fence_sync(nvbo, chan, !!b->write_domains, true);
if (unlikely(ret)) {
if (ret != -ERESTARTSYS)
NV_PRINTK(error, cli, "fail post-validate sync\n");
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/nouveau/nouveau_gem.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct reservation_object *nouveau_gem_prime_res_obj(struct drm_gem_object *);
extern void nouveau_gem_prime_unpin(struct drm_gem_object *);
extern struct sg_table *nouveau_gem_prime_get_sg_table(struct drm_gem_object *);
extern struct drm_gem_object *nouveau_gem_prime_import_sg_table(
struct drm_device *, size_t size, struct sg_table *);
struct drm_device *, struct dma_buf_attachment *, struct sg_table *);
extern void *nouveau_gem_prime_vmap(struct drm_gem_object *);
extern void nouveau_gem_prime_vunmap(struct drm_gem_object *, void *);

Expand Down
Loading

0 comments on commit 7a42e83

Please sign in to comment.