xref: /netbsd-src/sys/external/bsd/drm2/dist/drm/amd/amdgpu/amdgpu_ih.h (revision 82d56013d7b633d116a93943de88e08335357a7c)
1 /*	$NetBSD: amdgpu_ih.h,v 1.3 2018/08/27 14:04:50 riastradh Exp $	*/
2 
3 /*
4  * Copyright 2014 Advanced Micro Devices, Inc.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22  * OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */
25 
26 #ifndef __AMDGPU_IH_H__
27 #define __AMDGPU_IH_H__
28 
29 struct amdgpu_device;
30 
31 /*
32  * R6xx+ IH ring
33  */
34 struct amdgpu_ih_ring {
35 	struct amdgpu_bo	*ring_obj;
36 #ifdef __NetBSD__
37 	bus_dma_segment_t	ring_seg;
38 	bus_dmamap_t		ring_map;
39 #endif
40 	volatile uint32_t	*ring;
41 	unsigned		rptr;
42 	unsigned		ring_size;
43 	uint64_t		gpu_addr;
44 	uint32_t		ptr_mask;
45 	atomic_t		lock;
46 	bool                    enabled;
47 	unsigned		wptr_offs;
48 	unsigned		rptr_offs;
49 	u32			doorbell_index;
50 	bool			use_doorbell;
51 	bool			use_bus_addr;
52 	dma_addr_t		rb_dma_addr; /* only used when use_bus_addr = true */
53 };
54 
55 struct amdgpu_iv_entry {
56 	unsigned src_id;
57 	unsigned src_data;
58 	unsigned ring_id;
59 	unsigned vm_id;
60 	unsigned pas_id;
61 	const uint32_t *iv_entry;
62 };
63 
64 int amdgpu_ih_ring_init(struct amdgpu_device *adev, unsigned ring_size,
65 			bool use_bus_addr);
66 void amdgpu_ih_ring_fini(struct amdgpu_device *adev);
67 int amdgpu_ih_process(struct amdgpu_device *adev);
68 
69 #endif
70