|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
| 2 | +// |
| 3 | +// Copyright(c) 2021-2024 Intel Corporation. All rights reserved. |
| 4 | +// |
| 5 | +// Authors: Cezary Rojewski <[email protected]> |
| 6 | +// Amadeusz Slawinski <[email protected]> |
| 7 | +// |
| 8 | + |
| 9 | +#include <linux/slab.h> |
| 10 | +#include "avs.h" |
| 11 | +#include "messages.h" |
| 12 | + |
| 13 | +#ifdef CONFIG_DEBUG_FS |
| 14 | +int avs_icl_enable_logs(struct avs_dev *adev, enum avs_log_enable enable, u32 aging_period, |
| 15 | + u32 fifo_full_period, unsigned long resource_mask, u32 *priorities) |
| 16 | +{ |
| 17 | + struct avs_icl_log_state_info *info; |
| 18 | + u32 size, num_libs = adev->fw_cfg.max_libs_count; |
| 19 | + int i, ret; |
| 20 | + |
| 21 | + if (fls_long(resource_mask) > num_libs) |
| 22 | + return -EINVAL; |
| 23 | + size = struct_size(info, logs_priorities_mask, num_libs); |
| 24 | + info = kzalloc(size, GFP_KERNEL); |
| 25 | + if (!info) |
| 26 | + return -ENOMEM; |
| 27 | + |
| 28 | + info->aging_timer_period = aging_period; |
| 29 | + info->fifo_full_timer_period = fifo_full_period; |
| 30 | + info->enable = enable; |
| 31 | + if (enable) |
| 32 | + for_each_set_bit(i, &resource_mask, num_libs) |
| 33 | + info->logs_priorities_mask[i] = *priorities++; |
| 34 | + |
| 35 | + ret = avs_ipc_set_enable_logs(adev, (u8 *)info, size); |
| 36 | + kfree(info); |
| 37 | + if (ret) |
| 38 | + return AVS_IPC_RET(ret); |
| 39 | + |
| 40 | + return 0; |
| 41 | +} |
| 42 | +#endif |
| 43 | + |
| 44 | +union avs_icl_memwnd2_slot_type { |
| 45 | + u32 val; |
| 46 | + struct { |
| 47 | + u32 resource_id:8; |
| 48 | + u32 type:24; |
| 49 | + }; |
| 50 | +} __packed; |
| 51 | + |
| 52 | +struct avs_icl_memwnd2_desc { |
| 53 | + u32 resource_id; |
| 54 | + union avs_icl_memwnd2_slot_type slot_id; |
| 55 | + u32 vma; |
| 56 | +} __packed; |
| 57 | + |
| 58 | +#define AVS_ICL_MEMWND2_SLOTS_COUNT 15 |
| 59 | + |
| 60 | +struct avs_icl_memwnd2 { |
| 61 | + union { |
| 62 | + struct avs_icl_memwnd2_desc slot_desc[AVS_ICL_MEMWND2_SLOTS_COUNT]; |
| 63 | + u8 rsvd[PAGE_SIZE]; |
| 64 | + }; |
| 65 | + u8 slot_array[AVS_ICL_MEMWND2_SLOTS_COUNT][PAGE_SIZE]; |
| 66 | +} __packed; |
| 67 | + |
| 68 | +#define AVS_ICL_SLOT_UNUSED \ |
| 69 | + ((union avs_icl_memwnd2_slot_type) { 0x00000000U }) |
| 70 | +#define AVS_ICL_SLOT_CRITICAL_LOG \ |
| 71 | + ((union avs_icl_memwnd2_slot_type) { 0x54524300U }) |
| 72 | +#define AVS_ICL_SLOT_DEBUG_LOG \ |
| 73 | + ((union avs_icl_memwnd2_slot_type) { 0x474f4c00U }) |
| 74 | +#define AVS_ICL_SLOT_GDB_STUB \ |
| 75 | + ((union avs_icl_memwnd2_slot_type) { 0x42444700U }) |
| 76 | +#define AVS_ICL_SLOT_BROKEN \ |
| 77 | + ((union avs_icl_memwnd2_slot_type) { 0x44414544U }) |
| 78 | + |
| 79 | +static int avs_icl_slot_offset(struct avs_dev *adev, union avs_icl_memwnd2_slot_type slot_type) |
| 80 | +{ |
| 81 | + struct avs_icl_memwnd2_desc desc[AVS_ICL_MEMWND2_SLOTS_COUNT]; |
| 82 | + int i; |
| 83 | + |
| 84 | + memcpy_fromio(&desc, avs_sram_addr(adev, AVS_DEBUG_WINDOW), sizeof(desc)); |
| 85 | + |
| 86 | + for (i = 0; i < AVS_ICL_MEMWND2_SLOTS_COUNT; i++) |
| 87 | + if (desc[i].slot_id.val == slot_type.val) |
| 88 | + return offsetof(struct avs_icl_memwnd2, slot_array) + |
| 89 | + avs_skl_log_buffer_offset(adev, i); |
| 90 | + return -ENXIO; |
| 91 | +} |
| 92 | + |
| 93 | +int avs_icl_log_buffer_offset(struct avs_dev *adev, u32 core) |
| 94 | +{ |
| 95 | + union avs_icl_memwnd2_slot_type slot_type = AVS_ICL_SLOT_DEBUG_LOG; |
| 96 | + int ret; |
| 97 | + |
| 98 | + slot_type.resource_id = core; |
| 99 | + ret = avs_icl_slot_offset(adev, slot_type); |
| 100 | + if (ret < 0) |
| 101 | + dev_dbg(adev->dev, "No slot offset found for: %x\n", |
| 102 | + slot_type.val); |
| 103 | + |
| 104 | + return ret; |
| 105 | +} |
| 106 | + |
| 107 | +bool avs_icl_d0ix_toggle(struct avs_dev *adev, struct avs_ipc_msg *tx, bool wake) |
| 108 | +{ |
| 109 | + /* Payload-less IPCs do not take part in d0ix toggling. */ |
| 110 | + return tx->size; |
| 111 | +} |
| 112 | + |
| 113 | +int avs_icl_set_d0ix(struct avs_dev *adev, bool enable) |
| 114 | +{ |
| 115 | + int ret; |
| 116 | + |
| 117 | + ret = avs_ipc_set_d0ix(adev, enable, false); |
| 118 | + return AVS_IPC_RET(ret); |
| 119 | +} |
| 120 | + |
| 121 | +const struct avs_dsp_ops avs_icl_dsp_ops = { |
| 122 | + .power = avs_dsp_core_power, |
| 123 | + .reset = avs_dsp_core_reset, |
| 124 | + .stall = avs_dsp_core_stall, |
| 125 | + .irq_handler = avs_irq_handler, |
| 126 | + .irq_thread = avs_cnl_irq_thread, |
| 127 | + .int_control = avs_dsp_interrupt_control, |
| 128 | + .load_basefw = avs_hda_load_basefw, |
| 129 | + .load_lib = avs_hda_load_library, |
| 130 | + .transfer_mods = avs_hda_transfer_modules, |
| 131 | + .log_buffer_offset = avs_icl_log_buffer_offset, |
| 132 | + .log_buffer_status = avs_apl_log_buffer_status, |
| 133 | + .coredump = avs_apl_coredump, |
| 134 | + .d0ix_toggle = avs_icl_d0ix_toggle, |
| 135 | + .set_d0ix = avs_icl_set_d0ix, |
| 136 | + AVS_SET_ENABLE_LOGS_OP(icl) |
| 137 | +}; |
0 commit comments