blob: d0aa9bbc60da999a86c94f6425466dac36693339 [file] [log] [blame]
developer617abbd2024-04-23 14:50:01 +08001From 7582fc5bf2165b744eb41631f3892969ca6b510c Mon Sep 17 00:00:00 2001
2From: Rex Lu <rex.lu@mediatek.com>
3Date: Mon, 25 Dec 2023 15:17:49 +0800
4Subject: [PATCH 033/116] mtk: wifi: mt76: mt7996: Add mt7992 coredump support
5
61. Add mt7992 coredump support
72. fixed if new ic have not support coredump, it may cause crash when remove module
8
9CR-Id: WCNCR00259516
10Signed-off-by: Rex Lu <rex.lu@mediatek.com>
11Change-Id: I2ae5425aac6be8ff69a2c411e796be308b558b6b
12---
13 mt7996/coredump.c | 80 ++++++++++++++++++++++++++++++++++++++---------
14 mt7996/mt7996.h | 1 +
15 2 files changed, 67 insertions(+), 14 deletions(-)
16
17diff --git a/mt7996/coredump.c b/mt7996/coredump.c
18index a7f91b56d..d09bcd4bd 100644
19--- a/mt7996/coredump.c
20+++ b/mt7996/coredump.c
21@@ -67,6 +67,44 @@ static const struct mt7996_mem_region mt7996_wa_mem_regions[] = {
22 },
23 };
24
25+static const struct mt7996_mem_region mt7992_wm_mem_regions[] = {
26+ {
27+ .start = 0x00800000,
28+ .len = 0x0004bfff,
29+ .name = "ULM0",
30+ },
31+ {
32+ .start = 0x00900000,
33+ .len = 0x00035fff,
34+ .name = "ULM1",
35+ },
36+ {
37+ .start = 0x02200000,
38+ .len = 0x0003ffff,
39+ .name = "ULM2",
40+ },
41+ {
42+ .start = 0x00400000,
43+ .len = 0x00027fff,
44+ .name = "SRAM",
45+ },
46+ {
47+ .start = 0xe0000000,
48+ .len = 0x0015ffff,
49+ .name = "CRAM0",
50+ },
51+ {
52+ .start = 0xe0160000,
53+ .len = 0x00c7fff,
54+ .name = "CRAM1",
55+ },
56+ {
57+ .start = 0x7c050000,
58+ .len = 0x00007fff,
59+ .name = "CONN_INFRA",
60+ },
61+};
62+
63 const struct mt7996_mem_region*
64 mt7996_coredump_get_mem_layout(struct mt7996_dev *dev, u8 type, u32 *num)
65 {
66@@ -80,6 +118,14 @@ mt7996_coredump_get_mem_layout(struct mt7996_dev *dev, u8 type, u32 *num)
67
68 *num = ARRAY_SIZE(mt7996_wm_mem_regions);
69 return &mt7996_wm_mem_regions[0];
70+ case 0x7992:
71+ if (type == MT7996_RAM_TYPE_WA) {
72+ /* mt7992 wa memory regions is the same as mt7996 */
73+ *num = ARRAY_SIZE(mt7996_wa_mem_regions);
74+ return &mt7996_wa_mem_regions[0];
75+ }
76+ *num = ARRAY_SIZE(mt7992_wm_mem_regions);
77+ return &mt7992_wm_mem_regions[0];
78 default:
79 return NULL;
80 }
81@@ -115,7 +161,7 @@ struct mt7996_crash_data *mt7996_coredump_new(struct mt7996_dev *dev, u8 type)
82
83 lockdep_assert_held(&dev->dump_mutex);
84
85- if (!coredump_memdump)
86+ if (!coredump_memdump || !crash_data->supported)
87 return NULL;
88
89 guid_gen(&crash_data->guid);
90@@ -289,40 +335,46 @@ int mt7996_coredump_register(struct mt7996_dev *dev)
91 for (i = 0; i < MT7996_COREDUMP_MAX; i++) {
92 crash_data = vzalloc(sizeof(*dev->coredump.crash_data[i]));
93 if (!crash_data)
94- return -ENOMEM;
95+ goto nomem;
96
97 dev->coredump.crash_data[i] = crash_data;
98+ crash_data->supported = false;
99
100 if (coredump_memdump) {
101 crash_data->memdump_buf_len = mt7996_coredump_get_mem_size(dev, i);
102 if (!crash_data->memdump_buf_len)
103 /* no memory content */
104- return 0;
105+ continue;
106
107 crash_data->memdump_buf = vzalloc(crash_data->memdump_buf_len);
108- if (!crash_data->memdump_buf) {
109- vfree(crash_data);
110- return -ENOMEM;
111- }
112+ if (!crash_data->memdump_buf)
113+ goto nomem;
114+
115+ crash_data->supported = true;
116 }
117 }
118
119 return 0;
120+nomem:
121+ mt7996_coredump_unregister(dev);
122+ return -ENOMEM;
123 }
124
125 void mt7996_coredump_unregister(struct mt7996_dev *dev)
126 {
127 int i;
128+ struct mt7996_crash_data *crash_data;
129
130 for (i = 0; i < MT7996_COREDUMP_MAX; i++) {
131- if (dev->coredump.crash_data[i]->memdump_buf) {
132- vfree(dev->coredump.crash_data[i]->memdump_buf);
133- dev->coredump.crash_data[i]->memdump_buf = NULL;
134- dev->coredump.crash_data[i]->memdump_buf_len = 0;
135- }
136+ crash_data = dev->coredump.crash_data[i];
137+
138+ if (!crash_data)
139+ continue;
140+
141+ if (crash_data->memdump_buf)
142+ vfree(crash_data->memdump_buf);
143
144- vfree(dev->coredump.crash_data[i]);
145- dev->coredump.crash_data[i] = NULL;
146+ vfree(crash_data);
147 }
148 }
149
150diff --git a/mt7996/mt7996.h b/mt7996/mt7996.h
151index 623b782c9..97425a025 100644
152--- a/mt7996/mt7996.h
153+++ b/mt7996/mt7996.h
154@@ -229,6 +229,7 @@ struct mt7996_vif {
155 struct mt7996_crash_data {
156 guid_t guid;
157 struct timespec64 timestamp;
158+ bool supported;
159
160 u8 *memdump_buf;
161 size_t memdump_buf_len;
162--
1632.39.2
164