1 1.1 riastrad /* $NetBSD: amdgpu_ih.h,v 1.4 2021/12/18 23:44:58 riastradh Exp $ */ 2 1.1 riastrad 3 1.1 riastrad /* 4 1.1 riastrad * Copyright 2014 Advanced Micro Devices, Inc. 5 1.1 riastrad * 6 1.1 riastrad * Permission is hereby granted, free of charge, to any person obtaining a 7 1.1 riastrad * copy of this software and associated documentation files (the "Software"), 8 1.1 riastrad * to deal in the Software without restriction, including without limitation 9 1.1 riastrad * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 1.1 riastrad * and/or sell copies of the Software, and to permit persons to whom the 11 1.1 riastrad * Software is furnished to do so, subject to the following conditions: 12 1.1 riastrad * 13 1.1 riastrad * The above copyright notice and this permission notice shall be included in 14 1.1 riastrad * all copies or substantial portions of the Software. 15 1.1 riastrad * 16 1.1 riastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 1.1 riastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 1.1 riastrad * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 1.1 riastrad * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 1.1 riastrad * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 1.1 riastrad * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 1.1 riastrad * OTHER DEALINGS IN THE SOFTWARE. 23 1.1 riastrad * 24 1.1 riastrad */ 25 1.1 riastrad 26 1.1 riastrad #ifndef __AMDGPU_IH_H__ 27 1.1 riastrad #define __AMDGPU_IH_H__ 28 1.1 riastrad 29 1.4 riastrad /* Maximum number of IVs processed at once */ 30 1.4 riastrad #define AMDGPU_IH_MAX_NUM_IVS 32 31 1.4 riastrad 32 1.1 riastrad struct amdgpu_device; 33 1.4 riastrad struct amdgpu_iv_entry; 34 1.1 riastrad 35 1.1 riastrad /* 36 1.1 riastrad * R6xx+ IH ring 37 1.1 riastrad */ 38 1.1 riastrad struct amdgpu_ih_ring { 39 1.4 riastrad unsigned ring_size; 40 1.4 riastrad uint32_t ptr_mask; 41 1.4 riastrad u32 doorbell_index; 42 1.4 riastrad bool use_doorbell; 43 1.4 riastrad bool use_bus_addr; 44 1.4 riastrad 45 1.1 riastrad struct amdgpu_bo *ring_obj; 46 1.3 riastrad #ifdef __NetBSD__ 47 1.3 riastrad bus_dma_segment_t ring_seg; 48 1.3 riastrad bus_dmamap_t ring_map; 49 1.3 riastrad #endif 50 1.1 riastrad volatile uint32_t *ring; 51 1.4 riastrad uint64_t gpu_addr; 52 1.4 riastrad 53 1.4 riastrad uint64_t wptr_addr; 54 1.4 riastrad volatile uint32_t *wptr_cpu; 55 1.4 riastrad 56 1.4 riastrad uint64_t rptr_addr; 57 1.4 riastrad volatile uint32_t *rptr_cpu; 58 1.4 riastrad 59 1.4 riastrad bool enabled; 60 1.1 riastrad unsigned rptr; 61 1.1 riastrad atomic_t lock; 62 1.1 riastrad }; 63 1.1 riastrad 64 1.4 riastrad /* provided by the ih block */ 65 1.4 riastrad struct amdgpu_ih_funcs { 66 1.4 riastrad /* ring read/write ptr handling, called from interrupt context */ 67 1.4 riastrad u32 (*get_wptr)(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih); 68 1.4 riastrad void (*decode_iv)(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih, 69 1.4 riastrad struct amdgpu_iv_entry *entry); 70 1.4 riastrad void (*set_rptr)(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih); 71 1.1 riastrad }; 72 1.1 riastrad 73 1.4 riastrad #define amdgpu_ih_get_wptr(adev, ih) (adev)->irq.ih_funcs->get_wptr((adev), (ih)) 74 1.4 riastrad #define amdgpu_ih_decode_iv(adev, iv) \ 75 1.4 riastrad (adev)->irq.ih_funcs->decode_iv((adev), (ih), (iv)) 76 1.4 riastrad #define amdgpu_ih_set_rptr(adev, ih) (adev)->irq.ih_funcs->set_rptr((adev), (ih)) 77 1.4 riastrad 78 1.4 riastrad int amdgpu_ih_ring_init(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih, 79 1.4 riastrad unsigned ring_size, bool use_bus_addr); 80 1.4 riastrad void amdgpu_ih_ring_fini(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih); 81 1.4 riastrad int amdgpu_ih_process(struct amdgpu_device *adev, struct amdgpu_ih_ring *ih); 82 1.1 riastrad 83 1.1 riastrad #endif 84