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