Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -144,7 +144,8 @@ nouveau_bo_new(struct drm_device *dev, struct nouveau_channel *chan,
	nvbo->tile_mode = tile_mode;
	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;

	nouveau_bo_placement_set(nvbo, flags, 0);
@@ -525,7 +526,8 @@ nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
		stride  = 16 * 4;
		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);
			if (ret)
				return ret;
@@ -546,7 +548,8 @@ nv50_bo_move_m2mf(struct nouveau_channel *chan, struct ttm_buffer_object *bo,
			BEGIN_RING(chan, NvSubM2MF, 0x0200, 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);
			if (ret)
				return ret;
@@ -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) {
		ret = nv50_mem_vm_bind_linear(dev,
					      offset + dev_priv->vm_vram_base,
					      new_mem->size, nvbo->tile_flags,
					      new_mem->size,
					      nouveau_bo_tile_layout(nvbo),
					      offset);
		if (ret)
			return ret;
@@ -894,7 +898,8 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
	 * nothing to do here.
	 */
	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;
	}

+3 −0
Original line number Diff line number Diff line
@@ -100,6 +100,9 @@ struct nouveau_bo {
	int pin_refcnt;
};

#define nouveau_bo_tile_layout(nvbo)				\
	((nvbo)->tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK)

static inline struct nouveau_bo *
nouveau_bo(struct ttm_buffer_object *bo)
{
+21 −15
Original line number Diff line number Diff line
@@ -107,8 +107,12 @@ nouveau_gem_info(struct drm_gem_object *gem, struct drm_nouveau_gem_info *rep)
}

static bool
nouveau_gem_tile_flags_valid(struct drm_device *dev, uint32_t tile_flags) {
	switch (tile_flags) {
nouveau_gem_tile_flags_valid(struct drm_device *dev, uint32_t 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 0x1800:
		case 0x2800:
@@ -117,15 +121,17 @@ nouveau_gem_tile_flags_valid(struct drm_device *dev, uint32_t tile_flags) {
		case 0x7400:
		case 0x7a00:
		case 0xe000:
		break;
	default:
		NV_ERROR(dev, "bad page flags: 0x%08x\n", tile_flags);
		return false;
			return true;
		}

	} else {
		if (!(tile_flags & NOUVEAU_GEM_TILE_LAYOUT_MASK))
			return true;
	}

	NV_ERROR(dev, "bad page flags: 0x%08x\n", tile_flags);
	return false;
}

int
nouveau_gem_ioctl_new(struct drm_device *dev, void *data,
		      struct drm_file *file_priv)
+3 −0
Original line number Diff line number Diff line
@@ -1041,6 +1041,9 @@ int nouveau_ioctl_getparam(struct drm_device *dev, void *data,
	case NOUVEAU_GETPARAM_PTIMER_TIME:
		getparam->value = dev_priv->engine.timer.read(dev);
		break;
	case NOUVEAU_GETPARAM_HAS_BO_USAGE:
		getparam->value = 1;
		break;
	case NOUVEAU_GETPARAM_GRAPH_UNITS:
		/* NV40 and NV50 versions are quite different, but register
		 * address is the same. User is supposed to know the card
+2 −2
Original line number Diff line number Diff line
@@ -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.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;
	if (!nv_crtc->fb.blanked && dev_priv->chipset != 0x50) {
		ret = RING_SPACE(evo, 2);
@@ -578,7 +578,7 @@ nv50_crtc_do_mode_set_base(struct drm_crtc *crtc,
				  fb->nvbo->tile_mode);
	}
	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
		OUT_RING(evo, format);

Loading