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