1 1.1 riastrad /* $NetBSD: amdgpu_sdma.h,v 1.2 2021/12/18 23:44:58 riastradh Exp $ */ 2 1.1 riastrad 3 1.1 riastrad /* 4 1.1 riastrad * Copyright 2018 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_SDMA_H__ 27 1.1 riastrad #define __AMDGPU_SDMA_H__ 28 1.1 riastrad 29 1.1 riastrad /* max number of IP instances */ 30 1.1 riastrad #define AMDGPU_MAX_SDMA_INSTANCES 8 31 1.1 riastrad 32 1.1 riastrad enum amdgpu_sdma_irq { 33 1.1 riastrad AMDGPU_SDMA_IRQ_INSTANCE0 = 0, 34 1.1 riastrad AMDGPU_SDMA_IRQ_INSTANCE1, 35 1.1 riastrad AMDGPU_SDMA_IRQ_INSTANCE2, 36 1.1 riastrad AMDGPU_SDMA_IRQ_INSTANCE3, 37 1.1 riastrad AMDGPU_SDMA_IRQ_INSTANCE4, 38 1.1 riastrad AMDGPU_SDMA_IRQ_INSTANCE5, 39 1.1 riastrad AMDGPU_SDMA_IRQ_INSTANCE6, 40 1.1 riastrad AMDGPU_SDMA_IRQ_INSTANCE7, 41 1.1 riastrad AMDGPU_SDMA_IRQ_LAST 42 1.1 riastrad }; 43 1.1 riastrad 44 1.1 riastrad struct amdgpu_sdma_instance { 45 1.1 riastrad /* SDMA firmware */ 46 1.1 riastrad const struct firmware *fw; 47 1.1 riastrad uint32_t fw_version; 48 1.1 riastrad uint32_t feature_version; 49 1.1 riastrad 50 1.1 riastrad struct amdgpu_ring ring; 51 1.1 riastrad struct amdgpu_ring page; 52 1.1 riastrad bool burst_nop; 53 1.1 riastrad }; 54 1.1 riastrad 55 1.1 riastrad struct amdgpu_sdma_ras_funcs { 56 1.1 riastrad int (*ras_late_init)(struct amdgpu_device *adev, 57 1.1 riastrad void *ras_ih_info); 58 1.1 riastrad void (*ras_fini)(struct amdgpu_device *adev); 59 1.1 riastrad int (*query_ras_error_count)(struct amdgpu_device *adev, 60 1.1 riastrad uint32_t instance, void *ras_error_status); 61 1.1 riastrad }; 62 1.1 riastrad 63 1.1 riastrad struct amdgpu_sdma { 64 1.1 riastrad struct amdgpu_sdma_instance instance[AMDGPU_MAX_SDMA_INSTANCES]; 65 1.1 riastrad struct drm_gpu_scheduler *sdma_sched[AMDGPU_MAX_SDMA_INSTANCES]; 66 1.1 riastrad uint32_t num_sdma_sched; 67 1.1 riastrad struct amdgpu_irq_src trap_irq; 68 1.1 riastrad struct amdgpu_irq_src illegal_inst_irq; 69 1.1 riastrad struct amdgpu_irq_src ecc_irq; 70 1.1 riastrad int num_instances; 71 1.1 riastrad uint32_t srbm_soft_reset; 72 1.1 riastrad bool has_page_queue; 73 1.1 riastrad struct ras_common_if *ras_if; 74 1.1 riastrad const struct amdgpu_sdma_ras_funcs *funcs; 75 1.1 riastrad }; 76 1.1 riastrad 77 1.1 riastrad /* 78 1.1 riastrad * Provided by hw blocks that can move/clear data. e.g., gfx or sdma 79 1.1 riastrad * But currently, we use sdma to move data. 80 1.1 riastrad */ 81 1.1 riastrad struct amdgpu_buffer_funcs { 82 1.1 riastrad /* maximum bytes in a single operation */ 83 1.1 riastrad uint32_t copy_max_bytes; 84 1.1 riastrad 85 1.1 riastrad /* number of dw to reserve per operation */ 86 1.1 riastrad unsigned copy_num_dw; 87 1.1 riastrad 88 1.1 riastrad /* used for buffer migration */ 89 1.1 riastrad void (*emit_copy_buffer)(struct amdgpu_ib *ib, 90 1.1 riastrad /* src addr in bytes */ 91 1.1 riastrad uint64_t src_offset, 92 1.1 riastrad /* dst addr in bytes */ 93 1.1 riastrad uint64_t dst_offset, 94 1.1 riastrad /* number of byte to transfer */ 95 1.1 riastrad uint32_t byte_count); 96 1.1 riastrad 97 1.1 riastrad /* maximum bytes in a single operation */ 98 1.1 riastrad uint32_t fill_max_bytes; 99 1.1 riastrad 100 1.1 riastrad /* number of dw to reserve per operation */ 101 1.1 riastrad unsigned fill_num_dw; 102 1.1 riastrad 103 1.1 riastrad /* used for buffer clearing */ 104 1.1 riastrad void (*emit_fill_buffer)(struct amdgpu_ib *ib, 105 1.1 riastrad /* value to write to memory */ 106 1.1 riastrad uint32_t src_data, 107 1.1 riastrad /* dst addr in bytes */ 108 1.1 riastrad uint64_t dst_offset, 109 1.1 riastrad /* number of byte to fill */ 110 1.1 riastrad uint32_t byte_count); 111 1.1 riastrad }; 112 1.1 riastrad 113 1.1 riastrad #define amdgpu_emit_copy_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_copy_buffer((ib), (s), (d), (b)) 114 1.1 riastrad #define amdgpu_emit_fill_buffer(adev, ib, s, d, b) (adev)->mman.buffer_funcs->emit_fill_buffer((ib), (s), (d), (b)) 115 1.1 riastrad 116 1.1 riastrad struct amdgpu_sdma_instance * 117 1.1 riastrad amdgpu_sdma_get_instance_from_ring(struct amdgpu_ring *ring); 118 1.1 riastrad int amdgpu_sdma_get_index_from_ring(struct amdgpu_ring *ring, uint32_t *index); 119 1.1 riastrad uint64_t amdgpu_sdma_get_csa_mc_addr(struct amdgpu_ring *ring, unsigned vmid); 120 1.1 riastrad int amdgpu_sdma_ras_late_init(struct amdgpu_device *adev, 121 1.1 riastrad void *ras_ih_info); 122 1.1 riastrad void amdgpu_sdma_ras_fini(struct amdgpu_device *adev); 123 1.1 riastrad int amdgpu_sdma_process_ras_data_cb(struct amdgpu_device *adev, 124 1.1 riastrad void *err_data, 125 1.1 riastrad struct amdgpu_iv_entry *entry); 126 1.1 riastrad int amdgpu_sdma_process_ecc_irq(struct amdgpu_device *adev, 127 1.1 riastrad struct amdgpu_irq_src *source, 128 1.1 riastrad struct amdgpu_iv_entry *entry); 129 1.1 riastrad #endif 130