Commit 3530bdc3 authored by Thomas Hellstrom's avatar Thomas Hellstrom

drm/vmwgfx: Add MOB management

Implement MOB setup, binding and unbinding, but don't hook up to
TTM yet.
Signed-off-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: default avatarBrian Paul <brianp@vmware.com>
Reviewed-by: default avatarZack Rusin <zackr@vmware.com>
parent 716a2fd6
...@@ -6,6 +6,6 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \ ...@@ -6,6 +6,6 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \
vmwgfx_fifo.o vmwgfx_irq.o vmwgfx_ldu.o vmwgfx_ttm_glue.o \ vmwgfx_fifo.o vmwgfx_irq.o vmwgfx_ldu.o vmwgfx_ttm_glue.o \
vmwgfx_overlay.o vmwgfx_marker.o vmwgfx_gmrid_manager.o \ vmwgfx_overlay.o vmwgfx_marker.o vmwgfx_gmrid_manager.o \
vmwgfx_fence.o vmwgfx_dmabuf.o vmwgfx_scrn.o vmwgfx_context.o \ vmwgfx_fence.o vmwgfx_dmabuf.o vmwgfx_scrn.o vmwgfx_context.o \
vmwgfx_surface.o vmwgfx_prime.o vmwgfx_surface.o vmwgfx_prime.o vmwgfx_mob.o
obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o
...@@ -40,6 +40,10 @@ static uint32_t vram_ne_placement_flags = TTM_PL_FLAG_VRAM | ...@@ -40,6 +40,10 @@ static uint32_t vram_ne_placement_flags = TTM_PL_FLAG_VRAM |
static uint32_t sys_placement_flags = TTM_PL_FLAG_SYSTEM | static uint32_t sys_placement_flags = TTM_PL_FLAG_SYSTEM |
TTM_PL_FLAG_CACHED; TTM_PL_FLAG_CACHED;
static uint32_t sys_ne_placement_flags = TTM_PL_FLAG_SYSTEM |
TTM_PL_FLAG_CACHED |
TTM_PL_FLAG_NO_EVICT;
static uint32_t gmr_placement_flags = VMW_PL_FLAG_GMR | static uint32_t gmr_placement_flags = VMW_PL_FLAG_GMR |
TTM_PL_FLAG_CACHED; TTM_PL_FLAG_CACHED;
...@@ -116,6 +120,15 @@ struct ttm_placement vmw_sys_placement = { ...@@ -116,6 +120,15 @@ struct ttm_placement vmw_sys_placement = {
.busy_placement = &sys_placement_flags .busy_placement = &sys_placement_flags
}; };
struct ttm_placement vmw_sys_ne_placement = {
.fpfn = 0,
.lpfn = 0,
.num_placement = 1,
.placement = &sys_ne_placement_flags,
.num_busy_placement = 1,
.busy_placement = &sys_ne_placement_flags
};
static uint32_t evictable_placement_flags[] = { static uint32_t evictable_placement_flags[] = {
TTM_PL_FLAG_SYSTEM | TTM_PL_FLAG_CACHED, TTM_PL_FLAG_SYSTEM | TTM_PL_FLAG_CACHED,
TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED,
......
...@@ -327,6 +327,14 @@ static int vmw_request_device(struct vmw_private *dev_priv) ...@@ -327,6 +327,14 @@ static int vmw_request_device(struct vmw_private *dev_priv)
return ret; return ret;
} }
vmw_fence_fifo_up(dev_priv->fman); vmw_fence_fifo_up(dev_priv->fman);
if (dev_priv->has_mob) {
ret = vmw_otables_setup(dev_priv);
if (unlikely(ret != 0)) {
DRM_ERROR("Unable to initialize "
"guest Memory OBjects.\n");
goto out_no_mob;
}
}
ret = vmw_dummy_query_bo_create(dev_priv); ret = vmw_dummy_query_bo_create(dev_priv);
if (unlikely(ret != 0)) if (unlikely(ret != 0))
goto out_no_query_bo; goto out_no_query_bo;
...@@ -335,6 +343,9 @@ static int vmw_request_device(struct vmw_private *dev_priv) ...@@ -335,6 +343,9 @@ static int vmw_request_device(struct vmw_private *dev_priv)
return 0; return 0;
out_no_query_bo: out_no_query_bo:
if (dev_priv->has_mob)
vmw_otables_takedown(dev_priv);
out_no_mob:
vmw_fence_fifo_down(dev_priv->fman); vmw_fence_fifo_down(dev_priv->fman);
vmw_fifo_release(dev_priv, &dev_priv->fifo); vmw_fifo_release(dev_priv, &dev_priv->fifo);
return ret; return ret;
...@@ -350,10 +361,13 @@ static void vmw_release_device(struct vmw_private *dev_priv) ...@@ -350,10 +361,13 @@ static void vmw_release_device(struct vmw_private *dev_priv)
BUG_ON(dev_priv->pinned_bo != NULL); BUG_ON(dev_priv->pinned_bo != NULL);
ttm_bo_unref(&dev_priv->dummy_query_bo); ttm_bo_unref(&dev_priv->dummy_query_bo);
if (dev_priv->has_mob)
vmw_otables_takedown(dev_priv);
vmw_fence_fifo_down(dev_priv->fman); vmw_fence_fifo_down(dev_priv->fman);
vmw_fifo_release(dev_priv, &dev_priv->fifo); vmw_fifo_release(dev_priv, &dev_priv->fifo);
} }
/** /**
* Increase the 3d resource refcount. * Increase the 3d resource refcount.
* If the count was prevously zero, initialize the fifo, switching to svga * If the count was prevously zero, initialize the fifo, switching to svga
...@@ -690,6 +704,9 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) ...@@ -690,6 +704,9 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
dev_priv->has_gmr = false; dev_priv->has_gmr = false;
} }
if (dev_priv->capabilities & SVGA_CAP_GBOBJECTS)
dev_priv->has_mob = true;
dev_priv->mmio_mtrr = arch_phys_wc_add(dev_priv->mmio_start, dev_priv->mmio_mtrr = arch_phys_wc_add(dev_priv->mmio_start,
dev_priv->mmio_size); dev_priv->mmio_size);
......
...@@ -51,6 +51,16 @@ ...@@ -51,6 +51,16 @@
#define VMWGFX_MAX_DISPLAYS 16 #define VMWGFX_MAX_DISPLAYS 16
#define VMWGFX_CMD_BOUNCE_INIT_SIZE 32768 #define VMWGFX_CMD_BOUNCE_INIT_SIZE 32768
/*
* Perhaps we should have sysfs entries for these.
*/
#define VMWGFX_NUM_GB_CONTEXT 256
#define VMWGFX_NUM_GB_SHADER 20000
#define VMWGFX_NUM_GB_SURFACE 32768
#define VMWGFX_NUM_MOB (VMWGFX_NUM_GB_CONTEXT +\
VMWGFX_NUM_GB_SHADER +\
VMWGFX_NUM_GB_SURFACE)
#define VMW_PL_GMR TTM_PL_PRIV0 #define VMW_PL_GMR TTM_PL_PRIV0
#define VMW_PL_FLAG_GMR TTM_PL_FLAG_PRIV0 #define VMW_PL_FLAG_GMR TTM_PL_FLAG_PRIV0
...@@ -295,6 +305,7 @@ struct vmw_private { ...@@ -295,6 +305,7 @@ struct vmw_private {
uint32_t max_gmr_pages; uint32_t max_gmr_pages;
uint32_t memory_size; uint32_t memory_size;
bool has_gmr; bool has_gmr;
bool has_mob;
struct mutex hw_mutex; struct mutex hw_mutex;
/* /*
...@@ -415,6 +426,12 @@ struct vmw_private { ...@@ -415,6 +426,12 @@ struct vmw_private {
* DMA mapping stuff. * DMA mapping stuff.
*/ */
enum vmw_dma_map_mode map_mode; enum vmw_dma_map_mode map_mode;
/*
* Guest Backed stuff
*/
struct ttm_buffer_object *otable_bo;
struct vmw_otable *otables;
}; };
static inline struct vmw_surface *vmw_res_to_srf(struct vmw_resource *res) static inline struct vmw_surface *vmw_res_to_srf(struct vmw_resource *res)
...@@ -622,6 +639,7 @@ extern struct ttm_placement vmw_vram_sys_placement; ...@@ -622,6 +639,7 @@ extern struct ttm_placement vmw_vram_sys_placement;
extern struct ttm_placement vmw_vram_gmr_placement; extern struct ttm_placement vmw_vram_gmr_placement;
extern struct ttm_placement vmw_vram_gmr_ne_placement; extern struct ttm_placement vmw_vram_gmr_ne_placement;
extern struct ttm_placement vmw_sys_placement; extern struct ttm_placement vmw_sys_placement;
extern struct ttm_placement vmw_sys_ne_placement;
extern struct ttm_placement vmw_evictable_placement; extern struct ttm_placement vmw_evictable_placement;
extern struct ttm_placement vmw_srf_placement; extern struct ttm_placement vmw_srf_placement;
extern struct ttm_bo_driver vmw_bo_driver; extern struct ttm_bo_driver vmw_bo_driver;
...@@ -832,6 +850,19 @@ extern int vmw_prime_handle_to_fd(struct drm_device *dev, ...@@ -832,6 +850,19 @@ extern int vmw_prime_handle_to_fd(struct drm_device *dev,
uint32_t handle, uint32_t flags, uint32_t handle, uint32_t flags,
int *prime_fd); int *prime_fd);
/*
* MemoryOBject management - vmwgfx_mob.c
*/
struct vmw_mob;
extern int vmw_mob_bind(struct vmw_private *dev_priv, struct vmw_mob *mob,
struct page **data_pages, unsigned long num_data_pages,
int32_t mob_id);
extern void vmw_mob_unbind(struct vmw_private *dev_priv,
struct vmw_mob *mob);
extern void vmw_mob_destroy(struct vmw_mob *mob);
extern struct vmw_mob *vmw_mob_create(unsigned long data_pages);
extern int vmw_otables_setup(struct vmw_private *dev_priv);
extern void vmw_otables_takedown(struct vmw_private *dev_priv);
/** /**
* Inline helper functions * Inline helper functions
......
This diff is collapsed.
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