Commit 2298e804 authored by Maarten Lankhorst's avatar Maarten Lankhorst

drm/vmwgfx: rework to new fence interface, v2

Use the new fence interface on vmwgfx too.
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@canonical.com>

---
Changes since v1:
Fix a sleeping function called from invalid context in enable_signaling.
parent c060a4e1
...@@ -703,6 +703,7 @@ extern void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes); ...@@ -703,6 +703,7 @@ extern void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes);
extern void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes); extern void vmw_fifo_commit(struct vmw_private *dev_priv, uint32_t bytes);
extern int vmw_fifo_send_fence(struct vmw_private *dev_priv, extern int vmw_fifo_send_fence(struct vmw_private *dev_priv,
uint32_t *seqno); uint32_t *seqno);
extern void vmw_fifo_ping_host_locked(struct vmw_private *, uint32_t reason);
extern void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason); extern void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason);
extern bool vmw_fifo_have_3d(struct vmw_private *dev_priv); extern bool vmw_fifo_have_3d(struct vmw_private *dev_priv);
extern bool vmw_fifo_have_pitchlock(struct vmw_private *dev_priv); extern bool vmw_fifo_have_pitchlock(struct vmw_private *dev_priv);
......
...@@ -2389,7 +2389,7 @@ vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv, ...@@ -2389,7 +2389,7 @@ vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv,
BUG_ON(fence == NULL); BUG_ON(fence == NULL);
fence_rep.handle = fence_handle; fence_rep.handle = fence_handle;
fence_rep.seqno = fence->seqno; fence_rep.seqno = fence->base.seqno;
vmw_update_seqno(dev_priv, &dev_priv->fifo); vmw_update_seqno(dev_priv, &dev_priv->fifo);
fence_rep.passed_seqno = dev_priv->last_read_seqno; fence_rep.passed_seqno = dev_priv->last_read_seqno;
} }
......
This diff is collapsed.
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#ifndef _VMWGFX_FENCE_H_ #ifndef _VMWGFX_FENCE_H_
#include <linux/fence.h>
#define VMW_FENCE_WAIT_TIMEOUT (5*HZ) #define VMW_FENCE_WAIT_TIMEOUT (5*HZ)
struct vmw_private; struct vmw_private;
...@@ -50,15 +52,11 @@ struct vmw_fence_action { ...@@ -50,15 +52,11 @@ struct vmw_fence_action {
}; };
struct vmw_fence_obj { struct vmw_fence_obj {
struct kref kref; struct fence base;
u32 seqno;
struct vmw_fence_manager *fman;
struct list_head head; struct list_head head;
uint32_t signaled;
struct list_head seq_passed_actions; struct list_head seq_passed_actions;
void (*destroy)(struct vmw_fence_obj *fence); void (*destroy)(struct vmw_fence_obj *fence);
wait_queue_head_t queue;
}; };
extern struct vmw_fence_manager * extern struct vmw_fence_manager *
...@@ -66,10 +64,23 @@ vmw_fence_manager_init(struct vmw_private *dev_priv); ...@@ -66,10 +64,23 @@ vmw_fence_manager_init(struct vmw_private *dev_priv);
extern void vmw_fence_manager_takedown(struct vmw_fence_manager *fman); extern void vmw_fence_manager_takedown(struct vmw_fence_manager *fman);
extern void vmw_fence_obj_unreference(struct vmw_fence_obj **fence_p); static inline void
vmw_fence_obj_unreference(struct vmw_fence_obj **fence_p)
extern struct vmw_fence_obj * {
vmw_fence_obj_reference(struct vmw_fence_obj *fence); struct vmw_fence_obj *fence = *fence_p;
*fence_p = NULL;
if (fence)
fence_put(&fence->base);
}
static inline struct vmw_fence_obj *
vmw_fence_obj_reference(struct vmw_fence_obj *fence)
{
if (fence)
fence_get(&fence->base);
return fence;
}
extern void vmw_fences_update(struct vmw_fence_manager *fman); extern void vmw_fences_update(struct vmw_fence_manager *fman);
......
...@@ -160,16 +160,21 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo) ...@@ -160,16 +160,21 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
return vmw_fifo_send_fence(dev_priv, &dummy); return vmw_fifo_send_fence(dev_priv, &dummy);
} }
void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason) void vmw_fifo_ping_host_locked(struct vmw_private *dev_priv, uint32_t reason)
{ {
__le32 __iomem *fifo_mem = dev_priv->mmio_virt; __le32 __iomem *fifo_mem = dev_priv->mmio_virt;
mutex_lock(&dev_priv->hw_mutex);
if (unlikely(ioread32(fifo_mem + SVGA_FIFO_BUSY) == 0)) { if (unlikely(ioread32(fifo_mem + SVGA_FIFO_BUSY) == 0)) {
iowrite32(1, fifo_mem + SVGA_FIFO_BUSY); iowrite32(1, fifo_mem + SVGA_FIFO_BUSY);
vmw_write(dev_priv, SVGA_REG_SYNC, reason); vmw_write(dev_priv, SVGA_REG_SYNC, reason);
} }
}
void vmw_fifo_ping_host(struct vmw_private *dev_priv, uint32_t reason)
{
mutex_lock(&dev_priv->hw_mutex);
vmw_fifo_ping_host_locked(dev_priv, reason);
mutex_unlock(&dev_priv->hw_mutex); mutex_unlock(&dev_priv->hw_mutex);
} }
......
...@@ -1420,21 +1420,20 @@ void vmw_fence_single_bo(struct ttm_buffer_object *bo, ...@@ -1420,21 +1420,20 @@ void vmw_fence_single_bo(struct ttm_buffer_object *bo,
struct vmw_fence_obj *fence) struct vmw_fence_obj *fence)
{ {
struct ttm_bo_device *bdev = bo->bdev; struct ttm_bo_device *bdev = bo->bdev;
struct ttm_bo_driver *driver = bdev->driver;
struct vmw_fence_obj *old_fence_obj; struct vmw_fence_obj *old_fence_obj;
struct vmw_private *dev_priv = struct vmw_private *dev_priv =
container_of(bdev, struct vmw_private, bdev); container_of(bdev, struct vmw_private, bdev);
if (fence == NULL) if (fence == NULL) {
vmw_execbuf_fence_commands(NULL, dev_priv, &fence, NULL); vmw_execbuf_fence_commands(NULL, dev_priv, &fence, NULL);
else } else
driver->sync_obj_ref(fence); vmw_fence_obj_reference(fence);
reservation_object_add_excl_fence(bo->resv, &fence->base);
old_fence_obj = bo->sync_obj; old_fence_obj = bo->sync_obj;
bo->sync_obj = fence; bo->sync_obj = fence;
if (old_fence_obj) if (old_fence_obj)
vmw_fence_obj_unreference(&old_fence_obj); vmw_fence_obj_unreference(&old_fence_obj);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment