1*88dfc9a3SLikun Gao 
2*88dfc9a3SLikun Gao /*
3*88dfc9a3SLikun Gao  * Copyright 2014 Advanced Micro Devices, Inc.
4*88dfc9a3SLikun Gao  * Copyright 2008 Red Hat Inc.
5*88dfc9a3SLikun Gao  * Copyright 2009 Jerome Glisse.
6*88dfc9a3SLikun Gao  *
7*88dfc9a3SLikun Gao  * Permission is hereby granted, free of charge, to any person obtaining a
8*88dfc9a3SLikun Gao  * copy of this software and associated documentation files (the "Software"),
9*88dfc9a3SLikun Gao  * to deal in the Software without restriction, including without limitation
10*88dfc9a3SLikun Gao  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11*88dfc9a3SLikun Gao  * and/or sell copies of the Software, and to permit persons to whom the
12*88dfc9a3SLikun Gao  * Software is furnished to do so, subject to the following conditions:
13*88dfc9a3SLikun Gao  *
14*88dfc9a3SLikun Gao  * The above copyright notice and this permission notice shall be included in
15*88dfc9a3SLikun Gao  * all copies or substantial portions of the Software.
16*88dfc9a3SLikun Gao  *
17*88dfc9a3SLikun Gao  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18*88dfc9a3SLikun Gao  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19*88dfc9a3SLikun Gao  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20*88dfc9a3SLikun Gao  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
21*88dfc9a3SLikun Gao  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22*88dfc9a3SLikun Gao  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23*88dfc9a3SLikun Gao  * OTHER DEALINGS IN THE SOFTWARE.
24*88dfc9a3SLikun Gao  *
25*88dfc9a3SLikun Gao  */
26*88dfc9a3SLikun Gao 
27*88dfc9a3SLikun Gao #include "amdgpu.h"
28*88dfc9a3SLikun Gao #include "amdgpu_gfx.h"
29*88dfc9a3SLikun Gao #include "amdgpu_rlc.h"
30*88dfc9a3SLikun Gao 
31*88dfc9a3SLikun Gao /**
32*88dfc9a3SLikun Gao  * amdgpu_gfx_rlc_fini - Free BO which used for RLC
33*88dfc9a3SLikun Gao  *
34*88dfc9a3SLikun Gao  * @adev: amdgpu_device pointer
35*88dfc9a3SLikun Gao  *
36*88dfc9a3SLikun Gao  * Free three BO which is used for rlc_save_restore_block, rlc_clear_state_block
37*88dfc9a3SLikun Gao  * and rlc_jump_table_block.
38*88dfc9a3SLikun Gao  */
39*88dfc9a3SLikun Gao void amdgpu_gfx_rlc_fini(struct amdgpu_device *adev)
40*88dfc9a3SLikun Gao {
41*88dfc9a3SLikun Gao 	/* save restore block */
42*88dfc9a3SLikun Gao 	if (adev->gfx.rlc.save_restore_obj) {
43*88dfc9a3SLikun Gao 		amdgpu_bo_free_kernel(&adev->gfx.rlc.save_restore_obj,
44*88dfc9a3SLikun Gao 				      &adev->gfx.rlc.save_restore_gpu_addr,
45*88dfc9a3SLikun Gao 				      (void **)&adev->gfx.rlc.sr_ptr);
46*88dfc9a3SLikun Gao 	}
47*88dfc9a3SLikun Gao 
48*88dfc9a3SLikun Gao 	/* clear state block */
49*88dfc9a3SLikun Gao 	amdgpu_bo_free_kernel(&adev->gfx.rlc.clear_state_obj,
50*88dfc9a3SLikun Gao 			      &adev->gfx.rlc.clear_state_gpu_addr,
51*88dfc9a3SLikun Gao 			      (void **)&adev->gfx.rlc.cs_ptr);
52*88dfc9a3SLikun Gao 
53*88dfc9a3SLikun Gao 	/* jump table block */
54*88dfc9a3SLikun Gao 	amdgpu_bo_free_kernel(&adev->gfx.rlc.cp_table_obj,
55*88dfc9a3SLikun Gao 			      &adev->gfx.rlc.cp_table_gpu_addr,
56*88dfc9a3SLikun Gao 			      (void **)&adev->gfx.rlc.cp_table_ptr);
57*88dfc9a3SLikun Gao }
58