xref: /freebsd/sys/contrib/dev/athk/ath11k/coredump.c (revision c95ea407b322379bcb3c013a2dca9a18072c1df8)
1*c95ea407SBjoern A. Zeeb // SPDX-License-Identifier: BSD-3-Clause-Clear
2*c95ea407SBjoern A. Zeeb /*
3*c95ea407SBjoern A. Zeeb  * Copyright (c) 2020 The Linux Foundation. All rights reserved.
4*c95ea407SBjoern A. Zeeb  * Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved.
5*c95ea407SBjoern A. Zeeb  * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
6*c95ea407SBjoern A. Zeeb  */
7*c95ea407SBjoern A. Zeeb #include <linux/devcoredump.h>
8*c95ea407SBjoern A. Zeeb #include <linux/export.h>
9*c95ea407SBjoern A. Zeeb #include "hif.h"
10*c95ea407SBjoern A. Zeeb #include "coredump.h"
11*c95ea407SBjoern A. Zeeb #include "debug.h"
12*c95ea407SBjoern A. Zeeb 
13*c95ea407SBjoern A. Zeeb enum
ath11k_coredump_get_dump_type(int type)14*c95ea407SBjoern A. Zeeb ath11k_fw_crash_dump_type ath11k_coredump_get_dump_type(int type)
15*c95ea407SBjoern A. Zeeb {
16*c95ea407SBjoern A. Zeeb 	enum ath11k_fw_crash_dump_type dump_type;
17*c95ea407SBjoern A. Zeeb 
18*c95ea407SBjoern A. Zeeb 	switch (type) {
19*c95ea407SBjoern A. Zeeb 	case HOST_DDR_REGION_TYPE:
20*c95ea407SBjoern A. Zeeb 		dump_type = FW_CRASH_DUMP_REMOTE_MEM_DATA;
21*c95ea407SBjoern A. Zeeb 		break;
22*c95ea407SBjoern A. Zeeb 	case M3_DUMP_REGION_TYPE:
23*c95ea407SBjoern A. Zeeb 		dump_type = FW_CRASH_DUMP_M3_DUMP;
24*c95ea407SBjoern A. Zeeb 		break;
25*c95ea407SBjoern A. Zeeb 	case PAGEABLE_MEM_REGION_TYPE:
26*c95ea407SBjoern A. Zeeb 		dump_type = FW_CRASH_DUMP_PAGEABLE_DATA;
27*c95ea407SBjoern A. Zeeb 		break;
28*c95ea407SBjoern A. Zeeb 	case BDF_MEM_REGION_TYPE:
29*c95ea407SBjoern A. Zeeb 	case CALDB_MEM_REGION_TYPE:
30*c95ea407SBjoern A. Zeeb 		dump_type = FW_CRASH_DUMP_NONE;
31*c95ea407SBjoern A. Zeeb 		break;
32*c95ea407SBjoern A. Zeeb 	default:
33*c95ea407SBjoern A. Zeeb 		dump_type = FW_CRASH_DUMP_TYPE_MAX;
34*c95ea407SBjoern A. Zeeb 		break;
35*c95ea407SBjoern A. Zeeb 	}
36*c95ea407SBjoern A. Zeeb 
37*c95ea407SBjoern A. Zeeb 	return dump_type;
38*c95ea407SBjoern A. Zeeb }
39*c95ea407SBjoern A. Zeeb EXPORT_SYMBOL(ath11k_coredump_get_dump_type);
40*c95ea407SBjoern A. Zeeb 
ath11k_coredump_upload(struct work_struct * work)41*c95ea407SBjoern A. Zeeb void ath11k_coredump_upload(struct work_struct *work)
42*c95ea407SBjoern A. Zeeb {
43*c95ea407SBjoern A. Zeeb 	struct ath11k_base *ab = container_of(work, struct ath11k_base, dump_work);
44*c95ea407SBjoern A. Zeeb 
45*c95ea407SBjoern A. Zeeb 	ath11k_info(ab, "Uploading coredump\n");
46*c95ea407SBjoern A. Zeeb 	/* dev_coredumpv() takes ownership of the buffer */
47*c95ea407SBjoern A. Zeeb 	dev_coredumpv(ab->dev, ab->dump_data, ab->ath11k_coredump_len, GFP_KERNEL);
48*c95ea407SBjoern A. Zeeb 	ab->dump_data = NULL;
49*c95ea407SBjoern A. Zeeb }
50*c95ea407SBjoern A. Zeeb 
ath11k_coredump_collect(struct ath11k_base * ab)51*c95ea407SBjoern A. Zeeb void ath11k_coredump_collect(struct ath11k_base *ab)
52*c95ea407SBjoern A. Zeeb {
53*c95ea407SBjoern A. Zeeb 	ath11k_hif_coredump_download(ab);
54*c95ea407SBjoern A. Zeeb }
55