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

Commit 97a875cb authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Dave Airlie
Browse files

drm/ttm: remove no_wait_reserve, v3



All items on the lru list are always reservable, so this is a stupid
thing to keep. Not only that, it is used in a way which would
guarantee deadlocks if it were ever to be set to block on reserve.

This is a lot of churn, but mostly because of the removal of the
argument which can be nested arbitrarily deeply in many places.

No change of code in this patch except removal of the no_wait_reserve
argument, the previous patch removed the use of no_wait_reserve.

v2:
 - Warn if -EBUSY is returned on reservation, all objects on the list
   should be reservable. Adjusted patch slightly due to conflicts.
v3:
 - Focus on no_wait_reserve removal only.

Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: default avatarThomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent e7ab2019
Loading
Loading
Loading
Loading
+5 −5
Original line number Original line Diff line number Diff line
@@ -186,11 +186,11 @@ static void ast_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_reg *


static int ast_bo_move(struct ttm_buffer_object *bo,
static int ast_bo_move(struct ttm_buffer_object *bo,
		       bool evict, bool interruptible,
		       bool evict, bool interruptible,
		       bool no_wait_reserve, bool no_wait_gpu,
		       bool no_wait_gpu,
		       struct ttm_mem_reg *new_mem)
		       struct ttm_mem_reg *new_mem)
{
{
	int r;
	int r;
	r = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem);
	r = ttm_bo_move_memcpy(bo, evict, no_wait_gpu, new_mem);
	return r;
	return r;
}
}


@@ -383,7 +383,7 @@ int ast_bo_pin(struct ast_bo *bo, u32 pl_flag, u64 *gpu_addr)
	ast_ttm_placement(bo, pl_flag);
	ast_ttm_placement(bo, pl_flag);
	for (i = 0; i < bo->placement.num_placement; i++)
	for (i = 0; i < bo->placement.num_placement; i++)
		bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
		bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
	if (ret)
	if (ret)
		return ret;
		return ret;


@@ -406,7 +406,7 @@ int ast_bo_unpin(struct ast_bo *bo)


	for (i = 0; i < bo->placement.num_placement ; i++)
	for (i = 0; i < bo->placement.num_placement ; i++)
		bo->placements[i] &= ~TTM_PL_FLAG_NO_EVICT;
		bo->placements[i] &= ~TTM_PL_FLAG_NO_EVICT;
	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
	if (ret)
	if (ret)
		return ret;
		return ret;


@@ -431,7 +431,7 @@ int ast_bo_push_sysram(struct ast_bo *bo)
	for (i = 0; i < bo->placement.num_placement ; i++)
	for (i = 0; i < bo->placement.num_placement ; i++)
		bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
		bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;


	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
	if (ret) {
	if (ret) {
		DRM_ERROR("pushing to VRAM failed\n");
		DRM_ERROR("pushing to VRAM failed\n");
		return ret;
		return ret;
+5 −5
Original line number Original line Diff line number Diff line
@@ -186,11 +186,11 @@ static void cirrus_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_re


static int cirrus_bo_move(struct ttm_buffer_object *bo,
static int cirrus_bo_move(struct ttm_buffer_object *bo,
		       bool evict, bool interruptible,
		       bool evict, bool interruptible,
		       bool no_wait_reserve, bool no_wait_gpu,
		       bool no_wait_gpu,
		       struct ttm_mem_reg *new_mem)
		       struct ttm_mem_reg *new_mem)
{
{
	int r;
	int r;
	r = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem);
	r = ttm_bo_move_memcpy(bo, evict, no_wait_gpu, new_mem);
	return r;
	return r;
}
}


@@ -388,7 +388,7 @@ int cirrus_bo_pin(struct cirrus_bo *bo, u32 pl_flag, u64 *gpu_addr)
	cirrus_ttm_placement(bo, pl_flag);
	cirrus_ttm_placement(bo, pl_flag);
	for (i = 0; i < bo->placement.num_placement; i++)
	for (i = 0; i < bo->placement.num_placement; i++)
		bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
		bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
	if (ret)
	if (ret)
		return ret;
		return ret;


@@ -411,7 +411,7 @@ int cirrus_bo_unpin(struct cirrus_bo *bo)


	for (i = 0; i < bo->placement.num_placement ; i++)
	for (i = 0; i < bo->placement.num_placement ; i++)
		bo->placements[i] &= ~TTM_PL_FLAG_NO_EVICT;
		bo->placements[i] &= ~TTM_PL_FLAG_NO_EVICT;
	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
	if (ret)
	if (ret)
		return ret;
		return ret;


@@ -436,7 +436,7 @@ int cirrus_bo_push_sysram(struct cirrus_bo *bo)
	for (i = 0; i < bo->placement.num_placement ; i++)
	for (i = 0; i < bo->placement.num_placement ; i++)
		bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
		bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;


	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
	if (ret) {
	if (ret) {
		DRM_ERROR("pushing to VRAM failed\n");
		DRM_ERROR("pushing to VRAM failed\n");
		return ret;
		return ret;
+5 −5
Original line number Original line Diff line number Diff line
@@ -186,11 +186,11 @@ static void mgag200_ttm_io_mem_free(struct ttm_bo_device *bdev, struct ttm_mem_r


static int mgag200_bo_move(struct ttm_buffer_object *bo,
static int mgag200_bo_move(struct ttm_buffer_object *bo,
		       bool evict, bool interruptible,
		       bool evict, bool interruptible,
		       bool no_wait_reserve, bool no_wait_gpu,
		       bool no_wait_gpu,
		       struct ttm_mem_reg *new_mem)
		       struct ttm_mem_reg *new_mem)
{
{
	int r;
	int r;
	r = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem);
	r = ttm_bo_move_memcpy(bo, evict, no_wait_gpu, new_mem);
	return r;
	return r;
}
}


@@ -382,7 +382,7 @@ int mgag200_bo_pin(struct mgag200_bo *bo, u32 pl_flag, u64 *gpu_addr)
	mgag200_ttm_placement(bo, pl_flag);
	mgag200_ttm_placement(bo, pl_flag);
	for (i = 0; i < bo->placement.num_placement; i++)
	for (i = 0; i < bo->placement.num_placement; i++)
		bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
		bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
	if (ret)
	if (ret)
		return ret;
		return ret;


@@ -405,7 +405,7 @@ int mgag200_bo_unpin(struct mgag200_bo *bo)


	for (i = 0; i < bo->placement.num_placement ; i++)
	for (i = 0; i < bo->placement.num_placement ; i++)
		bo->placements[i] &= ~TTM_PL_FLAG_NO_EVICT;
		bo->placements[i] &= ~TTM_PL_FLAG_NO_EVICT;
	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
	if (ret)
	if (ret)
		return ret;
		return ret;


@@ -430,7 +430,7 @@ int mgag200_bo_push_sysram(struct mgag200_bo *bo)
	for (i = 0; i < bo->placement.num_placement ; i++)
	for (i = 0; i < bo->placement.num_placement ; i++)
		bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;
		bo->placements[i] |= TTM_PL_FLAG_NO_EVICT;


	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false, false);
	ret = ttm_bo_validate(&bo->bo, &bo->placement, false, false);
	if (ret) {
	if (ret) {
		DRM_ERROR("pushing to VRAM failed\n");
		DRM_ERROR("pushing to VRAM failed\n");
		return ret;
		return ret;
+26 −29
Original line number Original line Diff line number Diff line
@@ -315,7 +315,7 @@ nouveau_bo_pin(struct nouveau_bo *nvbo, uint32_t memtype)


	nouveau_bo_placement_set(nvbo, memtype, 0);
	nouveau_bo_placement_set(nvbo, memtype, 0);


	ret = nouveau_bo_validate(nvbo, false, false, false);
	ret = nouveau_bo_validate(nvbo, false, false);
	if (ret == 0) {
	if (ret == 0) {
		switch (bo->mem.mem_type) {
		switch (bo->mem.mem_type) {
		case TTM_PL_VRAM:
		case TTM_PL_VRAM:
@@ -351,7 +351,7 @@ nouveau_bo_unpin(struct nouveau_bo *nvbo)


	nouveau_bo_placement_set(nvbo, bo->mem.placement, 0);
	nouveau_bo_placement_set(nvbo, bo->mem.placement, 0);


	ret = nouveau_bo_validate(nvbo, false, false, false);
	ret = nouveau_bo_validate(nvbo, false, false);
	if (ret == 0) {
	if (ret == 0) {
		switch (bo->mem.mem_type) {
		switch (bo->mem.mem_type) {
		case TTM_PL_VRAM:
		case TTM_PL_VRAM:
@@ -392,12 +392,12 @@ nouveau_bo_unmap(struct nouveau_bo *nvbo)


int
int
nouveau_bo_validate(struct nouveau_bo *nvbo, bool interruptible,
nouveau_bo_validate(struct nouveau_bo *nvbo, bool interruptible,
		    bool no_wait_reserve, bool no_wait_gpu)
		    bool no_wait_gpu)
{
{
	int ret;
	int ret;


	ret = ttm_bo_validate(&nvbo->bo, &nvbo->placement, interruptible,
	ret = ttm_bo_validate(&nvbo->bo, &nvbo->placement,
			      no_wait_reserve, no_wait_gpu);
			      interruptible, no_wait_gpu);
	if (ret)
	if (ret)
		return ret;
		return ret;


@@ -556,8 +556,7 @@ nouveau_bo_evict_flags(struct ttm_buffer_object *bo, struct ttm_placement *pl)
static int
static int
nouveau_bo_move_accel_cleanup(struct nouveau_channel *chan,
nouveau_bo_move_accel_cleanup(struct nouveau_channel *chan,
			      struct nouveau_bo *nvbo, bool evict,
			      struct nouveau_bo *nvbo, bool evict,
			      bool no_wait_reserve, bool no_wait_gpu,
			      bool no_wait_gpu, struct ttm_mem_reg *new_mem)
			      struct ttm_mem_reg *new_mem)
{
{
	struct nouveau_fence *fence = NULL;
	struct nouveau_fence *fence = NULL;
	int ret;
	int ret;
@@ -567,7 +566,7 @@ nouveau_bo_move_accel_cleanup(struct nouveau_channel *chan,
		return ret;
		return ret;


	ret = ttm_bo_move_accel_cleanup(&nvbo->bo, fence, evict,
	ret = ttm_bo_move_accel_cleanup(&nvbo->bo, fence, evict,
					no_wait_reserve, no_wait_gpu, new_mem);
					no_wait_gpu, new_mem);
	nouveau_fence_unref(&fence);
	nouveau_fence_unref(&fence);
	return ret;
	return ret;
}
}
@@ -965,8 +964,7 @@ nouveau_vma_getmap(struct nouveau_channel *chan, struct nouveau_bo *nvbo,


static int
static int
nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
		     bool no_wait_reserve, bool no_wait_gpu,
		     bool no_wait_gpu, struct ttm_mem_reg *new_mem)
		     struct ttm_mem_reg *new_mem)
{
{
	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
	struct nouveau_channel *chan = chan = drm->channel;
	struct nouveau_channel *chan = chan = drm->channel;
@@ -995,7 +993,6 @@ nouveau_bo_move_m2mf(struct ttm_buffer_object *bo, int evict, bool intr,
	ret = drm->ttm.move(chan, bo, &bo->mem, new_mem);
	ret = drm->ttm.move(chan, bo, &bo->mem, new_mem);
	if (ret == 0) {
	if (ret == 0) {
		ret = nouveau_bo_move_accel_cleanup(chan, nvbo, evict,
		ret = nouveau_bo_move_accel_cleanup(chan, nvbo, evict,
						    no_wait_reserve,
						    no_wait_gpu, new_mem);
						    no_wait_gpu, new_mem);
	}
	}


@@ -1064,8 +1061,7 @@ nouveau_bo_move_init(struct nouveau_drm *drm)


static int
static int
nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
		      bool no_wait_reserve, bool no_wait_gpu,
		      bool no_wait_gpu, struct ttm_mem_reg *new_mem)
		      struct ttm_mem_reg *new_mem)
{
{
	u32 placement_memtype = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING;
	u32 placement_memtype = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING;
	struct ttm_placement placement;
	struct ttm_placement placement;
@@ -1078,7 +1074,7 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,


	tmp_mem = *new_mem;
	tmp_mem = *new_mem;
	tmp_mem.mm_node = NULL;
	tmp_mem.mm_node = NULL;
	ret = ttm_bo_mem_space(bo, &placement, &tmp_mem, intr, no_wait_reserve, no_wait_gpu);
	ret = ttm_bo_mem_space(bo, &placement, &tmp_mem, intr, no_wait_gpu);
	if (ret)
	if (ret)
		return ret;
		return ret;


@@ -1086,11 +1082,11 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,
	if (ret)
	if (ret)
		goto out;
		goto out;


	ret = nouveau_bo_move_m2mf(bo, true, intr, no_wait_reserve, no_wait_gpu, &tmp_mem);
	ret = nouveau_bo_move_m2mf(bo, true, intr, no_wait_gpu, &tmp_mem);
	if (ret)
	if (ret)
		goto out;
		goto out;


	ret = ttm_bo_move_ttm(bo, true, no_wait_reserve, no_wait_gpu, new_mem);
	ret = ttm_bo_move_ttm(bo, true, no_wait_gpu, new_mem);
out:
out:
	ttm_bo_mem_put(bo, &tmp_mem);
	ttm_bo_mem_put(bo, &tmp_mem);
	return ret;
	return ret;
@@ -1098,8 +1094,7 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool evict, bool intr,


static int
static int
nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,
		      bool no_wait_reserve, bool no_wait_gpu,
		      bool no_wait_gpu, struct ttm_mem_reg *new_mem)
		      struct ttm_mem_reg *new_mem)
{
{
	u32 placement_memtype = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING;
	u32 placement_memtype = TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING;
	struct ttm_placement placement;
	struct ttm_placement placement;
@@ -1112,15 +1107,15 @@ nouveau_bo_move_flips(struct ttm_buffer_object *bo, bool evict, bool intr,


	tmp_mem = *new_mem;
	tmp_mem = *new_mem;
	tmp_mem.mm_node = NULL;
	tmp_mem.mm_node = NULL;
	ret = ttm_bo_mem_space(bo, &placement, &tmp_mem, intr, no_wait_reserve, no_wait_gpu);
	ret = ttm_bo_mem_space(bo, &placement, &tmp_mem, intr, no_wait_gpu);
	if (ret)
	if (ret)
		return ret;
		return ret;


	ret = ttm_bo_move_ttm(bo, true, no_wait_reserve, no_wait_gpu, &tmp_mem);
	ret = ttm_bo_move_ttm(bo, true, no_wait_gpu, &tmp_mem);
	if (ret)
	if (ret)
		goto out;
		goto out;


	ret = nouveau_bo_move_m2mf(bo, true, intr, no_wait_reserve, no_wait_gpu, new_mem);
	ret = nouveau_bo_move_m2mf(bo, true, intr, no_wait_gpu, new_mem);
	if (ret)
	if (ret)
		goto out;
		goto out;


@@ -1195,8 +1190,7 @@ nouveau_bo_vm_cleanup(struct ttm_buffer_object *bo,


static int
static int
nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,
nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,
		bool no_wait_reserve, bool no_wait_gpu,
		bool no_wait_gpu, struct ttm_mem_reg *new_mem)
		struct ttm_mem_reg *new_mem)
{
{
	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
	struct nouveau_drm *drm = nouveau_bdev(bo->bdev);
	struct nouveau_bo *nvbo = nouveau_bo(bo);
	struct nouveau_bo *nvbo = nouveau_bo(bo);
@@ -1220,23 +1214,26 @@ nouveau_bo_move(struct ttm_buffer_object *bo, bool evict, bool intr,


	/* CPU copy if we have no accelerated method available */
	/* CPU copy if we have no accelerated method available */
	if (!drm->ttm.move) {
	if (!drm->ttm.move) {
		ret = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem);
		ret = ttm_bo_move_memcpy(bo, evict, no_wait_gpu, new_mem);
		goto out;
		goto out;
	}
	}


	/* Hardware assisted copy. */
	/* Hardware assisted copy. */
	if (new_mem->mem_type == TTM_PL_SYSTEM)
	if (new_mem->mem_type == TTM_PL_SYSTEM)
		ret = nouveau_bo_move_flipd(bo, evict, intr, no_wait_reserve, no_wait_gpu, new_mem);
		ret = nouveau_bo_move_flipd(bo, evict, intr,
					    no_wait_gpu, new_mem);
	else if (old_mem->mem_type == TTM_PL_SYSTEM)
	else if (old_mem->mem_type == TTM_PL_SYSTEM)
		ret = nouveau_bo_move_flips(bo, evict, intr, no_wait_reserve, no_wait_gpu, new_mem);
		ret = nouveau_bo_move_flips(bo, evict, intr,
					    no_wait_gpu, new_mem);
	else
	else
		ret = nouveau_bo_move_m2mf(bo, evict, intr, no_wait_reserve, no_wait_gpu, new_mem);
		ret = nouveau_bo_move_m2mf(bo, evict, intr,
					   no_wait_gpu, new_mem);


	if (!ret)
	if (!ret)
		goto out;
		goto out;


	/* Fallback to software copy. */
	/* Fallback to software copy. */
	ret = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, no_wait_gpu, new_mem);
	ret = ttm_bo_move_memcpy(bo, evict, no_wait_gpu, new_mem);


out:
out:
	if (nv_device(drm->device)->card_type < NV_50) {
	if (nv_device(drm->device)->card_type < NV_50) {
@@ -1343,7 +1340,7 @@ nouveau_ttm_fault_reserve_notify(struct ttm_buffer_object *bo)
	nvbo->placement.fpfn = 0;
	nvbo->placement.fpfn = 0;
	nvbo->placement.lpfn = mappable;
	nvbo->placement.lpfn = mappable;
	nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_VRAM, 0);
	nouveau_bo_placement_set(nvbo, TTM_PL_FLAG_VRAM, 0);
	return nouveau_bo_validate(nvbo, false, true, false);
	return nouveau_bo_validate(nvbo, false, false);
}
}


static int
static int
+1 −1
Original line number Original line Diff line number Diff line
@@ -76,7 +76,7 @@ u32 nouveau_bo_rd32(struct nouveau_bo *, unsigned index);
void nouveau_bo_wr32(struct nouveau_bo *, unsigned index, u32 val);
void nouveau_bo_wr32(struct nouveau_bo *, unsigned index, u32 val);
void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *);
void nouveau_bo_fence(struct nouveau_bo *, struct nouveau_fence *);
int  nouveau_bo_validate(struct nouveau_bo *, bool interruptible,
int  nouveau_bo_validate(struct nouveau_bo *, bool interruptible,
			 bool no_wait_reserve, bool no_wait_gpu);
			 bool no_wait_gpu);


struct nouveau_vma *
struct nouveau_vma *
nouveau_bo_vma_find(struct nouveau_bo *, struct nouveau_vm *);
nouveau_bo_vma_find(struct nouveau_bo *, struct nouveau_vm *);
Loading