1*a9655020SBjoern A. Zeeb // SPDX-License-Identifier: BSD-3-Clause-Clear 2*a9655020SBjoern A. Zeeb /* 3*a9655020SBjoern A. Zeeb * Copyright (c) 2020 The Linux Foundation. All rights reserved. 4*a9655020SBjoern A. Zeeb * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. 5*a9655020SBjoern A. Zeeb */ 6*a9655020SBjoern A. Zeeb #include <linux/devcoredump.h> 7*a9655020SBjoern A. Zeeb #include "hif.h" 8*a9655020SBjoern A. Zeeb #include "coredump.h" 9*a9655020SBjoern A. Zeeb #include "debug.h" 10*a9655020SBjoern A. Zeeb 11*a9655020SBjoern A. Zeeb enum ath12k_coredump_get_dump_type(enum ath12k_qmi_target_mem type)12*a9655020SBjoern A. Zeebath12k_fw_crash_dump_type ath12k_coredump_get_dump_type(enum ath12k_qmi_target_mem type) 13*a9655020SBjoern A. Zeeb { 14*a9655020SBjoern A. Zeeb enum ath12k_fw_crash_dump_type dump_type; 15*a9655020SBjoern A. Zeeb 16*a9655020SBjoern A. Zeeb switch (type) { 17*a9655020SBjoern A. Zeeb case HOST_DDR_REGION_TYPE: 18*a9655020SBjoern A. Zeeb dump_type = FW_CRASH_DUMP_REMOTE_MEM_DATA; 19*a9655020SBjoern A. Zeeb break; 20*a9655020SBjoern A. Zeeb case M3_DUMP_REGION_TYPE: 21*a9655020SBjoern A. Zeeb dump_type = FW_CRASH_DUMP_M3_DUMP; 22*a9655020SBjoern A. Zeeb break; 23*a9655020SBjoern A. Zeeb case PAGEABLE_MEM_REGION_TYPE: 24*a9655020SBjoern A. Zeeb dump_type = FW_CRASH_DUMP_PAGEABLE_DATA; 25*a9655020SBjoern A. Zeeb break; 26*a9655020SBjoern A. Zeeb case BDF_MEM_REGION_TYPE: 27*a9655020SBjoern A. Zeeb case CALDB_MEM_REGION_TYPE: 28*a9655020SBjoern A. Zeeb dump_type = FW_CRASH_DUMP_NONE; 29*a9655020SBjoern A. Zeeb break; 30*a9655020SBjoern A. Zeeb case MLO_GLOBAL_MEM_REGION_TYPE: 31*a9655020SBjoern A. Zeeb dump_type = FW_CRASH_DUMP_MLO_GLOBAL_DATA; 32*a9655020SBjoern A. Zeeb break; 33*a9655020SBjoern A. Zeeb default: 34*a9655020SBjoern A. Zeeb dump_type = FW_CRASH_DUMP_TYPE_MAX; 35*a9655020SBjoern A. Zeeb break; 36*a9655020SBjoern A. Zeeb } 37*a9655020SBjoern A. Zeeb 38*a9655020SBjoern A. Zeeb return dump_type; 39*a9655020SBjoern A. Zeeb } 40*a9655020SBjoern A. Zeeb ath12k_coredump_upload(struct work_struct * work)41*a9655020SBjoern A. Zeebvoid ath12k_coredump_upload(struct work_struct *work) 42*a9655020SBjoern A. Zeeb { 43*a9655020SBjoern A. Zeeb struct ath12k_base *ab = container_of(work, struct ath12k_base, dump_work); 44*a9655020SBjoern A. Zeeb 45*a9655020SBjoern A. Zeeb ath12k_info(ab, "Uploading coredump\n"); 46*a9655020SBjoern A. Zeeb /* dev_coredumpv() takes ownership of the buffer */ 47*a9655020SBjoern A. Zeeb dev_coredumpv(ab->dev, ab->dump_data, ab->ath12k_coredump_len, GFP_KERNEL); 48*a9655020SBjoern A. Zeeb ab->dump_data = NULL; 49*a9655020SBjoern A. Zeeb } 50*a9655020SBjoern A. Zeeb ath12k_coredump_collect(struct ath12k_base * ab)51*a9655020SBjoern A. Zeebvoid ath12k_coredump_collect(struct ath12k_base *ab) 52*a9655020SBjoern A. Zeeb { 53*a9655020SBjoern A. Zeeb ath12k_hif_coredump_download(ab); 54*a9655020SBjoern A. Zeeb } 55