Commit f13b3263 authored by Francisco Jerez's avatar Francisco Jerez Committed by Ben Skeggs

drm/nouveau: Expose some BO usage flags to userspace.

This will be needed for Z compression and to take smarter placement
decisions.
Signed-off-by: default avatarFrancisco Jerez <currojerez@riseup.net>
Acked-by: default avatarBen Skeggs <bskeggs@redhat.com>
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 1397b42b
...@@ -144,7 +144,8 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan, ...@@ -144,7 +144,8 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan,
nvbo->tile_mode = tile_mode; nvbo->tile_mode = tile_mode;
nvbo->tile_flags = tile_flags; nvbo->tile_flags = tile_flags;
nouveau_bo_fixup_align(dev, tile_mode, tile_flags, &align, &size); nouveau_bo_fixup_align(dev, tile_mode, nouveau_bo_tile_layout(nvbo),
&align, &size);
align >>= PAGE_SHIFT; align >>= PAGE_SHIFT;
nouveau_bo_placement_set(nvbo, flags, 0); nouveau_bo_placement_set(nvbo, flags, 0);
...@@ -525,7 +526,8 @@ nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo, ...@@ -525,7 +526,8 @@ nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
stride = 16 * 4; stride = 16 * 4;
height = amount / stride; height = amount / stride;
if (new_mem->mem_type == TTM_PL_VRAM && nvbo->tile_flags) { if (new_mem->mem_type == TTM_PL_VRAM &&
nouveau_bo_tile_layout(nvbo)) {
ret = RING_SPACE(chan, 8); ret = RING_SPACE(chan, 8);
if (ret) if (ret)
return ret; return ret;
...@@ -546,7 +548,8 @@ nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo, ...@@ -546,7 +548,8 @@ nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
BEGIN_RING(chan, NvSubM2MF, 0x0200, 1); BEGIN_RING(chan, NvSubM2MF, 0x0200, 1);
OUT_RING (chan, 1); OUT_RING (chan, 1);
} }
if (old_mem->mem_type == TTM_PL_VRAM && nvbo->tile_flags) { if (old_mem->mem_type == TTM_PL_VRAM &&
nouveau_bo_tile_layout(nvbo)) {
ret = RING_SPACE(chan, 8); ret = RING_SPACE(chan, 8);
if (ret) if (ret)
return ret; return ret;
...@@ -753,7 +756,8 @@ nouveau_bo_vm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem, ...@@ -753,7 +756,8 @@ nouveau_bo_vm_bind(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem,
if (dev_priv->card_type == NV_50) { if (dev_priv->card_type == NV_50) {
ret = nv50_mem_vm_bind_linear(dev, ret = nv50_mem_vm_bind_linear(dev,
offset + dev_priv->vm_vram_base, offset + dev_priv->vm_vram_base,
new_mem->size, nvbo->tile_flags, new_mem->size,
nouveau_bo_tile_layout(nvbo),
offset); offset);
if (ret) if (ret)
return ret; return ret;
...@@ -894,7 +898,8 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo) ...@@ -894,7 +898,8 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
* nothing to do here. * nothing to do here.
*/ */
if (bo->mem.mem_type != TTM_PL_VRAM) { if (bo->mem.mem_type != TTM_PL_VRAM) {
if (dev_priv->card_type < NV_50 || !nvbo->tile_flags) if (dev_priv->card_type < NV_50 ||
!nouveau_bo_tile_layout(nvbo))
return 0; return 0;
} }
......
...@@ -100,6 +100,9 @@ struct nouveau_bo { ...@@ -100,6 +100,9 @@ struct nouveau_bo {
int pin_refcnt; int pin_refcnt;
}; };
#define nouveau_bo_tile_layout(nvbo) \
((nvbo)->tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK)
static inline struct nouveau_bo * static inline struct nouveau_bo *
nouveau_bo(struct ttm_buffer_object *bo) nouveau_bo(struct ttm_buffer_object *bo)
{ {
......
...@@ -107,8 +107,12 @@ nouveau_gem_info(struct drm_gem_object *gem, struct drm_nouveau_gem_info *rep) ...@@ -107,8 +107,12 @@ nouveau_gem_info(struct drm_gem_object *gem, struct drm_nouveau_gem_info *rep)
} }
static bool static bool
nouveau_gem_tile_flags_valid(struct drm_device *dev, uint32_t tile_flags) { nouveau_gem_tile_flags_valid(struct drm_device *dev, uint32_t tile_flags)
switch (tile_flags) { {
struct drm_nouveau_private *dev_priv = dev->dev_private;
if (dev_priv->card_type >= NV_50) {
switch (tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK) {
case 0x0000: case 0x0000:
case 0x1800: case 0x1800:
case 0x2800: case 0x2800:
...@@ -117,13 +121,15 @@ nouveau_gem_tile_flags_valid(struct drm_device *dev, uint32_t tile_flags) { ...@@ -117,13 +121,15 @@ nouveau_gem_tile_flags_valid(struct drm_device *dev, uint32_t tile_flags) {
case 0x7400: case 0x7400:
case 0x7a00: case 0x7a00:
case 0xe000: case 0xe000:
break; return true;
default:
NV_ERROR(dev, "bad page flags: 0x%08x\n", tile_flags);
return false;
} }
} else {
if (!(tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK))
return true; return true;
}
NV_ERROR(dev, "bad page flags: 0x%08x\n", tile_flags);
return false;
} }
int int
......
...@@ -1041,6 +1041,9 @@ int nouveau_ioctl_getparam(struct drm_device *dev, void *data, ...@@ -1041,6 +1041,9 @@ int nouveau_ioctl_getparam(struct drm_device *dev, void *data,
case NOUVEAU_GETPARAM_PTIMER_TIME: case NOUVEAU_GETPARAM_PTIMER_TIME:
getparam->value = dev_priv->engine.timer.read(dev); getparam->value = dev_priv->engine.timer.read(dev);
break; break;
case NOUVEAU_GETPARAM_HAS_BO_USAGE:
getparam->value = 1;
break;
case NOUVEAU_GETPARAM_GRAPH_UNITS: case NOUVEAU_GETPARAM_GRAPH_UNITS:
/* NV40 and NV50 versions are quite different, but register /* NV40 and NV50 versions are quite different, but register
* address is the same. User is supposed to know the card * address is the same. User is supposed to know the card
......
...@@ -546,7 +546,7 @@ nv50_crtc_do_mode_set_base(struct drm_crtc *crtc, ...@@ -546,7 +546,7 @@ nv50_crtc_do_mode_set_base(struct drm_crtc *crtc,
} }
nv_crtc->fb.offset = fb->nvbo->bo.offset - dev_priv->vm_vram_base; nv_crtc->fb.offset = fb->nvbo->bo.offset - dev_priv->vm_vram_base;
nv_crtc->fb.tile_flags = fb->nvbo->tile_flags; nv_crtc->fb.tile_flags = nouveau_bo_tile_layout(fb->nvbo);
nv_crtc->fb.cpp = drm_fb->bits_per_pixel / 8; nv_crtc->fb.cpp = drm_fb->bits_per_pixel / 8;
if (!nv_crtc->fb.blanked && dev_priv->chipset != 0x50) { if (!nv_crtc->fb.blanked && dev_priv->chipset != 0x50) {
ret = RING_SPACE(evo, 2); ret = RING_SPACE(evo, 2);
...@@ -578,7 +578,7 @@ nv50_crtc_do_mode_set_base(struct drm_crtc *crtc, ...@@ -578,7 +578,7 @@ nv50_crtc_do_mode_set_base(struct drm_crtc *crtc,
fb->nvbo->tile_mode); fb->nvbo->tile_mode);
} }
if (dev_priv->chipset == 0x50) if (dev_priv->chipset == 0x50)
OUT_RING(evo, (fb->nvbo->tile_flags << 8) | format); OUT_RING(evo, (nv_crtc->fb.tile_flags << 8) | format);
else else
OUT_RING(evo, format); OUT_RING(evo, format);
......
...@@ -80,6 +80,7 @@ struct drm_nouveau_gpuobj_free { ...@@ -80,6 +80,7 @@ struct drm_nouveau_gpuobj_free {
#define NOUVEAU_GETPARAM_VM_VRAM_BASE 12 #define NOUVEAU_GETPARAM_VM_VRAM_BASE 12
#define NOUVEAU_GETPARAM_GRAPH_UNITS 13 #define NOUVEAU_GETPARAM_GRAPH_UNITS 13
#define NOUVEAU_GETPARAM_PTIMER_TIME 14 #define NOUVEAU_GETPARAM_PTIMER_TIME 14
#define NOUVEAU_GETPARAM_HAS_BO_USAGE 15
struct drm_nouveau_getparam { struct drm_nouveau_getparam {
uint64_t param; uint64_t param;
uint64_t value; uint64_t value;
...@@ -95,6 +96,12 @@ struct drm_nouveau_setparam { ...@@ -95,6 +96,12 @@ struct drm_nouveau_setparam {
#define NOUVEAU_GEM_DOMAIN_GART (1 << 2) #define NOUVEAU_GEM_DOMAIN_GART (1 << 2)
#define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3) #define NOUVEAU_GEM_DOMAIN_MAPPABLE (1 << 3)
#define NOUVEAU_GEM_TILE_LAYOUT_MASK 0x0000ff00
#define NOUVEAU_GEM_TILE_16BPP 0x00000001
#define NOUVEAU_GEM_TILE_32BPP 0x00000002
#define NOUVEAU_GEM_TILE_ZETA 0x00000004
#define NOUVEAU_GEM_TILE_NONCONTIG 0x00000008
struct drm_nouveau_gem_info { struct drm_nouveau_gem_info {
uint32_t handle; uint32_t handle;
uint32_t domain; uint32_t domain;
......
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