forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
....@@ -1,36 +1,5 @@
1
-/*
2
- * drivers/net/ethernet/mellanox/mlxfw/mlxfw.c
3
- * Copyright (c) 2017 Mellanox Technologies. All rights reserved.
4
- * Copyright (c) 2017 Yotam Gigi <yotamg@mellanox.com>
5
- *
6
- * Redistribution and use in source and binary forms, with or without
7
- * modification, are permitted provided that the following conditions are met:
8
- *
9
- * 1. Redistributions of source code must retain the above copyright
10
- * notice, this list of conditions and the following disclaimer.
11
- * 2. Redistributions in binary form must reproduce the above copyright
12
- * notice, this list of conditions and the following disclaimer in the
13
- * documentation and/or other materials provided with the distribution.
14
- * 3. Neither the names of the copyright holders nor the names of its
15
- * contributors may be used to endorse or promote products derived from
16
- * this software without specific prior written permission.
17
- *
18
- * Alternatively, this software may be distributed under the terms of the
19
- * GNU General Public License ("GPL") version 2 as published by the Free
20
- * Software Foundation.
21
- *
22
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
- * POSSIBILITY OF SUCH DAMAGE.
33
- */
1
+// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2
+/* Copyright (c) 2017-2019 Mellanox Technologies. All rights reserved */
343
354 #define pr_fmt(fmt) "mlxfw: " fmt
365
....@@ -47,31 +16,74 @@
4716 (MLXFW_FSM_STATE_WAIT_TIMEOUT_MS / MLXFW_FSM_STATE_WAIT_CYCLE_MS)
4817 #define MLXFW_FSM_MAX_COMPONENT_SIZE (10 * (1 << 20))
4918
50
-static const char * const mlxfw_fsm_state_err_str[] = {
51
- [MLXFW_FSM_STATE_ERR_ERROR] =
52
- "general error",
53
- [MLXFW_FSM_STATE_ERR_REJECTED_DIGEST_ERR] =
54
- "component hash mismatch",
55
- [MLXFW_FSM_STATE_ERR_REJECTED_NOT_APPLICABLE] =
56
- "component not applicable",
57
- [MLXFW_FSM_STATE_ERR_REJECTED_UNKNOWN_KEY] =
58
- "unknown key",
59
- [MLXFW_FSM_STATE_ERR_REJECTED_AUTH_FAILED] =
60
- "authentication failed",
61
- [MLXFW_FSM_STATE_ERR_REJECTED_UNSIGNED] =
62
- "component was not signed",
63
- [MLXFW_FSM_STATE_ERR_REJECTED_KEY_NOT_APPLICABLE] =
64
- "key not applicable",
65
- [MLXFW_FSM_STATE_ERR_REJECTED_BAD_FORMAT] =
66
- "bad format",
67
- [MLXFW_FSM_STATE_ERR_BLOCKED_PENDING_RESET] =
68
- "pending reset",
69
- [MLXFW_FSM_STATE_ERR_MAX] =
70
- "unknown error"
19
+static const int mlxfw_fsm_state_errno[] = {
20
+ [MLXFW_FSM_STATE_ERR_ERROR] = -EIO,
21
+ [MLXFW_FSM_STATE_ERR_REJECTED_DIGEST_ERR] = -EBADMSG,
22
+ [MLXFW_FSM_STATE_ERR_REJECTED_NOT_APPLICABLE] = -ENOENT,
23
+ [MLXFW_FSM_STATE_ERR_REJECTED_UNKNOWN_KEY] = -ENOKEY,
24
+ [MLXFW_FSM_STATE_ERR_REJECTED_AUTH_FAILED] = -EACCES,
25
+ [MLXFW_FSM_STATE_ERR_REJECTED_UNSIGNED] = -EKEYREVOKED,
26
+ [MLXFW_FSM_STATE_ERR_REJECTED_KEY_NOT_APPLICABLE] = -EKEYREJECTED,
27
+ [MLXFW_FSM_STATE_ERR_REJECTED_BAD_FORMAT] = -ENOEXEC,
28
+ [MLXFW_FSM_STATE_ERR_BLOCKED_PENDING_RESET] = -EBUSY,
29
+ [MLXFW_FSM_STATE_ERR_MAX] = -EINVAL
30
+};
31
+
32
+#define MLXFW_ERR_PRFX "Firmware flash failed: "
33
+#define MLXFW_ERR_MSG(fwdev, extack, msg, err) do { \
34
+ mlxfw_err(fwdev, "%s, err (%d)\n", MLXFW_ERR_PRFX msg, err); \
35
+ NL_SET_ERR_MSG_MOD(extack, MLXFW_ERR_PRFX msg); \
36
+} while (0)
37
+
38
+static int mlxfw_fsm_state_err(struct mlxfw_dev *mlxfw_dev,
39
+ struct netlink_ext_ack *extack,
40
+ enum mlxfw_fsm_state_err err)
41
+{
42
+ enum mlxfw_fsm_state_err fsm_state_err;
43
+
44
+ fsm_state_err = min_t(enum mlxfw_fsm_state_err, err,
45
+ MLXFW_FSM_STATE_ERR_MAX);
46
+
47
+ switch (fsm_state_err) {
48
+ case MLXFW_FSM_STATE_ERR_ERROR:
49
+ MLXFW_ERR_MSG(mlxfw_dev, extack, "general error", err);
50
+ break;
51
+ case MLXFW_FSM_STATE_ERR_REJECTED_DIGEST_ERR:
52
+ MLXFW_ERR_MSG(mlxfw_dev, extack, "component hash mismatch", err);
53
+ break;
54
+ case MLXFW_FSM_STATE_ERR_REJECTED_NOT_APPLICABLE:
55
+ MLXFW_ERR_MSG(mlxfw_dev, extack, "component not applicable", err);
56
+ break;
57
+ case MLXFW_FSM_STATE_ERR_REJECTED_UNKNOWN_KEY:
58
+ MLXFW_ERR_MSG(mlxfw_dev, extack, "unknown key", err);
59
+ break;
60
+ case MLXFW_FSM_STATE_ERR_REJECTED_AUTH_FAILED:
61
+ MLXFW_ERR_MSG(mlxfw_dev, extack, "authentication failed", err);
62
+ break;
63
+ case MLXFW_FSM_STATE_ERR_REJECTED_UNSIGNED:
64
+ MLXFW_ERR_MSG(mlxfw_dev, extack, "component was not signed", err);
65
+ break;
66
+ case MLXFW_FSM_STATE_ERR_REJECTED_KEY_NOT_APPLICABLE:
67
+ MLXFW_ERR_MSG(mlxfw_dev, extack, "key not applicable", err);
68
+ break;
69
+ case MLXFW_FSM_STATE_ERR_REJECTED_BAD_FORMAT:
70
+ MLXFW_ERR_MSG(mlxfw_dev, extack, "bad format", err);
71
+ break;
72
+ case MLXFW_FSM_STATE_ERR_BLOCKED_PENDING_RESET:
73
+ MLXFW_ERR_MSG(mlxfw_dev, extack, "pending reset", err);
74
+ break;
75
+ case MLXFW_FSM_STATE_ERR_OK:
76
+ case MLXFW_FSM_STATE_ERR_MAX:
77
+ MLXFW_ERR_MSG(mlxfw_dev, extack, "unknown error", err);
78
+ break;
79
+ }
80
+
81
+ return mlxfw_fsm_state_errno[fsm_state_err];
7182 };
7283
7384 static int mlxfw_fsm_state_wait(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
74
- enum mlxfw_fsm_state fsm_state)
85
+ enum mlxfw_fsm_state fsm_state,
86
+ struct netlink_ext_ack *extack)
7587 {
7688 enum mlxfw_fsm_state_err fsm_state_err;
7789 enum mlxfw_fsm_state curr_fsm_state;
....@@ -82,19 +94,18 @@
8294 retry:
8395 err = mlxfw_dev->ops->fsm_query_state(mlxfw_dev, fwhandle,
8496 &curr_fsm_state, &fsm_state_err);
85
- if (err)
97
+ if (err) {
98
+ MLXFW_ERR_MSG(mlxfw_dev, extack, "FSM state query failed", err);
8699 return err;
87
-
88
- if (fsm_state_err != MLXFW_FSM_STATE_ERR_OK) {
89
- fsm_state_err = min_t(enum mlxfw_fsm_state_err,
90
- fsm_state_err, MLXFW_FSM_STATE_ERR_MAX);
91
- pr_err("Firmware flash failed: %s\n",
92
- mlxfw_fsm_state_err_str[fsm_state_err]);
93
- return -EINVAL;
94100 }
101
+
102
+ if (fsm_state_err != MLXFW_FSM_STATE_ERR_OK)
103
+ return mlxfw_fsm_state_err(mlxfw_dev, extack, fsm_state_err);
104
+
95105 if (curr_fsm_state != fsm_state) {
96106 if (--times == 0) {
97
- pr_err("Timeout reached on FSM state change");
107
+ MLXFW_ERR_MSG(mlxfw_dev, extack,
108
+ "Timeout reached on FSM state change", -ETIMEDOUT);
98109 return -ETIMEDOUT;
99110 }
100111 msleep(MLXFW_FSM_STATE_WAIT_CYCLE_MS);
....@@ -103,51 +114,155 @@
103114 return 0;
104115 }
105116
117
+static int
118
+mlxfw_fsm_reactivate_err(struct mlxfw_dev *mlxfw_dev,
119
+ struct netlink_ext_ack *extack, u8 err)
120
+{
121
+ enum mlxfw_fsm_reactivate_status status;
122
+
123
+#define MXFW_REACT_PRFX "Reactivate FSM: "
124
+#define MLXFW_REACT_ERR(msg, err) \
125
+ MLXFW_ERR_MSG(mlxfw_dev, extack, MXFW_REACT_PRFX msg, err)
126
+
127
+ status = min_t(enum mlxfw_fsm_reactivate_status, err,
128
+ MLXFW_FSM_REACTIVATE_STATUS_MAX);
129
+
130
+ switch (status) {
131
+ case MLXFW_FSM_REACTIVATE_STATUS_BUSY:
132
+ MLXFW_REACT_ERR("busy", err);
133
+ break;
134
+ case MLXFW_FSM_REACTIVATE_STATUS_PROHIBITED_FW_VER_ERR:
135
+ MLXFW_REACT_ERR("prohibited fw ver", err);
136
+ break;
137
+ case MLXFW_FSM_REACTIVATE_STATUS_FIRST_PAGE_COPY_FAILED:
138
+ MLXFW_REACT_ERR("first page copy failed", err);
139
+ break;
140
+ case MLXFW_FSM_REACTIVATE_STATUS_FIRST_PAGE_ERASE_FAILED:
141
+ MLXFW_REACT_ERR("first page erase failed", err);
142
+ break;
143
+ case MLXFW_FSM_REACTIVATE_STATUS_FIRST_PAGE_RESTORE_FAILED:
144
+ MLXFW_REACT_ERR("first page restore failed", err);
145
+ break;
146
+ case MLXFW_FSM_REACTIVATE_STATUS_CANDIDATE_FW_DEACTIVATION_FAILED:
147
+ MLXFW_REACT_ERR("candidate fw deactivation failed", err);
148
+ break;
149
+ case MLXFW_FSM_REACTIVATE_STATUS_ERR_DEVICE_RESET_REQUIRED:
150
+ MLXFW_REACT_ERR("device reset required", err);
151
+ break;
152
+ case MLXFW_FSM_REACTIVATE_STATUS_ERR_FW_PROGRAMMING_NEEDED:
153
+ MLXFW_REACT_ERR("fw programming needed", err);
154
+ break;
155
+ case MLXFW_FSM_REACTIVATE_STATUS_FW_ALREADY_ACTIVATED:
156
+ MLXFW_REACT_ERR("fw already activated", err);
157
+ break;
158
+ case MLXFW_FSM_REACTIVATE_STATUS_OK:
159
+ case MLXFW_FSM_REACTIVATE_STATUS_MAX:
160
+ MLXFW_REACT_ERR("unexpected error", err);
161
+ break;
162
+ }
163
+ return -EREMOTEIO;
164
+};
165
+
166
+static int mlxfw_fsm_reactivate(struct mlxfw_dev *mlxfw_dev,
167
+ struct netlink_ext_ack *extack,
168
+ bool *supported)
169
+{
170
+ u8 status;
171
+ int err;
172
+
173
+ if (!mlxfw_dev->ops->fsm_reactivate)
174
+ return 0;
175
+
176
+ err = mlxfw_dev->ops->fsm_reactivate(mlxfw_dev, &status);
177
+ if (err == -EOPNOTSUPP) {
178
+ *supported = false;
179
+ return 0;
180
+ }
181
+
182
+ if (err) {
183
+ MLXFW_ERR_MSG(mlxfw_dev, extack,
184
+ "Could not reactivate firmware flash", err);
185
+ return err;
186
+ }
187
+
188
+ if (status == MLXFW_FSM_REACTIVATE_STATUS_OK ||
189
+ status == MLXFW_FSM_REACTIVATE_STATUS_FW_ALREADY_ACTIVATED)
190
+ return 0;
191
+
192
+ return mlxfw_fsm_reactivate_err(mlxfw_dev, extack, status);
193
+}
194
+
195
+static void mlxfw_status_notify(struct mlxfw_dev *mlxfw_dev,
196
+ const char *msg, const char *comp_name,
197
+ u32 done_bytes, u32 total_bytes)
198
+{
199
+ devlink_flash_update_status_notify(mlxfw_dev->devlink, msg, comp_name,
200
+ done_bytes, total_bytes);
201
+}
202
+
106203 #define MLXFW_ALIGN_DOWN(x, align_bits) ((x) & ~((1 << (align_bits)) - 1))
107204 #define MLXFW_ALIGN_UP(x, align_bits) \
108205 MLXFW_ALIGN_DOWN((x) + ((1 << (align_bits)) - 1), (align_bits))
109206
110207 static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
111208 u32 fwhandle,
112
- struct mlxfw_mfa2_component *comp)
209
+ struct mlxfw_mfa2_component *comp,
210
+ bool reactivate_supp,
211
+ struct netlink_ext_ack *extack)
113212 {
114213 u16 comp_max_write_size;
115214 u8 comp_align_bits;
116215 u32 comp_max_size;
216
+ char comp_name[8];
117217 u16 block_size;
118218 u8 *block_ptr;
119219 u32 offset;
120220 int err;
121221
222
+ sprintf(comp_name, "%u", comp->index);
223
+
122224 err = mlxfw_dev->ops->component_query(mlxfw_dev, comp->index,
123225 &comp_max_size, &comp_align_bits,
124226 &comp_max_write_size);
125
- if (err)
227
+ if (err) {
228
+ MLXFW_ERR_MSG(mlxfw_dev, extack, "FSM component query failed", err);
126229 return err;
230
+ }
127231
128232 comp_max_size = min_t(u32, comp_max_size, MLXFW_FSM_MAX_COMPONENT_SIZE);
129233 if (comp->data_size > comp_max_size) {
130
- pr_err("Component %d is of size %d which is bigger than limit %d\n",
131
- comp->index, comp->data_size, comp_max_size);
234
+ MLXFW_ERR_MSG(mlxfw_dev, extack,
235
+ "Component size is bigger than limit", -EINVAL);
132236 return -EINVAL;
133237 }
134238
135239 comp_max_write_size = MLXFW_ALIGN_DOWN(comp_max_write_size,
136240 comp_align_bits);
137241
138
- pr_debug("Component update\n");
242
+ mlxfw_dbg(mlxfw_dev, "Component update\n");
243
+ mlxfw_status_notify(mlxfw_dev, "Updating component", comp_name, 0, 0);
139244 err = mlxfw_dev->ops->fsm_component_update(mlxfw_dev, fwhandle,
140245 comp->index,
141246 comp->data_size);
142
- if (err)
247
+ if (err) {
248
+ if (!reactivate_supp)
249
+ MLXFW_ERR_MSG(mlxfw_dev, extack,
250
+ "FSM component update failed, FW reactivate is not supported",
251
+ err);
252
+ else
253
+ MLXFW_ERR_MSG(mlxfw_dev, extack,
254
+ "FSM component update failed", err);
143255 return err;
256
+ }
144257
145258 err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
146
- MLXFW_FSM_STATE_DOWNLOAD);
259
+ MLXFW_FSM_STATE_DOWNLOAD, extack);
147260 if (err)
148261 goto err_out;
149262
150
- pr_debug("Component download\n");
263
+ mlxfw_dbg(mlxfw_dev, "Component download\n");
264
+ mlxfw_status_notify(mlxfw_dev, "Downloading component",
265
+ comp_name, 0, comp->data_size);
151266 for (offset = 0;
152267 offset < MLXFW_ALIGN_UP(comp->data_size, comp_align_bits);
153268 offset += comp_max_write_size) {
....@@ -157,17 +272,28 @@
157272 err = mlxfw_dev->ops->fsm_block_download(mlxfw_dev, fwhandle,
158273 block_ptr, block_size,
159274 offset);
160
- if (err)
275
+ if (err) {
276
+ MLXFW_ERR_MSG(mlxfw_dev, extack,
277
+ "Component download failed", err);
161278 goto err_out;
279
+ }
280
+ mlxfw_status_notify(mlxfw_dev, "Downloading component",
281
+ comp_name, offset + block_size,
282
+ comp->data_size);
162283 }
163284
164
- pr_debug("Component verify\n");
285
+ mlxfw_dbg(mlxfw_dev, "Component verify\n");
286
+ mlxfw_status_notify(mlxfw_dev, "Verifying component", comp_name, 0, 0);
165287 err = mlxfw_dev->ops->fsm_component_verify(mlxfw_dev, fwhandle,
166288 comp->index);
167
- if (err)
289
+ if (err) {
290
+ MLXFW_ERR_MSG(mlxfw_dev, extack,
291
+ "FSM component verify failed", err);
168292 goto err_out;
293
+ }
169294
170
- err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle, MLXFW_FSM_STATE_LOCKED);
295
+ err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
296
+ MLXFW_FSM_STATE_LOCKED, extack);
171297 if (err)
172298 goto err_out;
173299 return 0;
....@@ -178,7 +304,9 @@
178304 }
179305
180306 static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
181
- struct mlxfw_mfa2_file *mfa2_file)
307
+ struct mlxfw_mfa2_file *mfa2_file,
308
+ bool reactivate_supp,
309
+ struct netlink_ext_ack *extack)
182310 {
183311 u32 component_count;
184312 int err;
....@@ -188,7 +316,8 @@
188316 mlxfw_dev->psid_size,
189317 &component_count);
190318 if (err) {
191
- pr_err("Could not find device PSID in MFA2 file\n");
319
+ MLXFW_ERR_MSG(mlxfw_dev, extack,
320
+ "Could not find device PSID in MFA2 file", err);
192321 return err;
193322 }
194323
....@@ -197,11 +326,17 @@
197326
198327 comp = mlxfw_mfa2_file_component_get(mfa2_file, mlxfw_dev->psid,
199328 mlxfw_dev->psid_size, i);
200
- if (IS_ERR(comp))
201
- return PTR_ERR(comp);
329
+ if (IS_ERR(comp)) {
330
+ err = PTR_ERR(comp);
331
+ MLXFW_ERR_MSG(mlxfw_dev, extack,
332
+ "Failed to get MFA2 component", err);
333
+ return err;
334
+ }
202335
203
- pr_info("Flashing component type %d\n", comp->index);
204
- err = mlxfw_flash_component(mlxfw_dev, fwhandle, comp);
336
+ mlxfw_info(mlxfw_dev, "Flashing component type %d\n",
337
+ comp->index);
338
+ err = mlxfw_flash_component(mlxfw_dev, fwhandle, comp,
339
+ reactivate_supp, extack);
205340 mlxfw_mfa2_file_component_put(comp);
206341 if (err)
207342 return err;
....@@ -210,62 +345,91 @@
210345 }
211346
212347 int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
213
- const struct firmware *firmware)
348
+ const struct firmware *firmware,
349
+ struct netlink_ext_ack *extack)
214350 {
215351 struct mlxfw_mfa2_file *mfa2_file;
352
+ bool reactivate_supp = true;
216353 u32 fwhandle;
217354 int err;
218355
219356 if (!mlxfw_mfa2_check(firmware)) {
220
- pr_err("Firmware file is not MFA2\n");
357
+ MLXFW_ERR_MSG(mlxfw_dev, extack,
358
+ "Firmware file is not MFA2", -EINVAL);
221359 return -EINVAL;
222360 }
223361
224362 mfa2_file = mlxfw_mfa2_file_init(firmware);
225
- if (IS_ERR(mfa2_file))
226
- return PTR_ERR(mfa2_file);
363
+ if (IS_ERR(mfa2_file)) {
364
+ err = PTR_ERR(mfa2_file);
365
+ MLXFW_ERR_MSG(mlxfw_dev, extack,
366
+ "Failed to initialize MFA2 firmware file", err);
367
+ return err;
368
+ }
227369
228
- pr_info("Initialize firmware flash process\n");
370
+ mlxfw_info(mlxfw_dev, "Initialize firmware flash process\n");
371
+ devlink_flash_update_begin_notify(mlxfw_dev->devlink);
372
+ mlxfw_status_notify(mlxfw_dev, "Initializing firmware flash process",
373
+ NULL, 0, 0);
229374 err = mlxfw_dev->ops->fsm_lock(mlxfw_dev, &fwhandle);
230375 if (err) {
231
- pr_err("Could not lock the firmware FSM\n");
376
+ MLXFW_ERR_MSG(mlxfw_dev, extack,
377
+ "Could not lock the firmware FSM", err);
232378 goto err_fsm_lock;
233379 }
234380
235381 err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
236
- MLXFW_FSM_STATE_LOCKED);
382
+ MLXFW_FSM_STATE_LOCKED, extack);
237383 if (err)
238384 goto err_state_wait_idle_to_locked;
239385
240
- err = mlxfw_flash_components(mlxfw_dev, fwhandle, mfa2_file);
386
+ err = mlxfw_fsm_reactivate(mlxfw_dev, extack, &reactivate_supp);
387
+ if (err)
388
+ goto err_fsm_reactivate;
389
+
390
+ err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
391
+ MLXFW_FSM_STATE_LOCKED, extack);
392
+ if (err)
393
+ goto err_state_wait_reactivate_to_locked;
394
+
395
+ err = mlxfw_flash_components(mlxfw_dev, fwhandle, mfa2_file,
396
+ reactivate_supp, extack);
241397 if (err)
242398 goto err_flash_components;
243399
244
- pr_debug("Activate image\n");
400
+ mlxfw_dbg(mlxfw_dev, "Activate image\n");
401
+ mlxfw_status_notify(mlxfw_dev, "Activating image", NULL, 0, 0);
245402 err = mlxfw_dev->ops->fsm_activate(mlxfw_dev, fwhandle);
246403 if (err) {
247
- pr_err("Could not activate the downloaded image\n");
404
+ MLXFW_ERR_MSG(mlxfw_dev, extack,
405
+ "Could not activate the downloaded image", err);
248406 goto err_fsm_activate;
249407 }
250408
251
- err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle, MLXFW_FSM_STATE_LOCKED);
409
+ err = mlxfw_fsm_state_wait(mlxfw_dev, fwhandle,
410
+ MLXFW_FSM_STATE_LOCKED, extack);
252411 if (err)
253412 goto err_state_wait_activate_to_locked;
254413
255
- pr_debug("Handle release\n");
414
+ mlxfw_dbg(mlxfw_dev, "Handle release\n");
256415 mlxfw_dev->ops->fsm_release(mlxfw_dev, fwhandle);
257416
258
- pr_info("Firmware flash done.\n");
417
+ mlxfw_info(mlxfw_dev, "Firmware flash done\n");
418
+ mlxfw_status_notify(mlxfw_dev, "Firmware flash done", NULL, 0, 0);
259419 mlxfw_mfa2_file_fini(mfa2_file);
420
+ devlink_flash_update_end_notify(mlxfw_dev->devlink);
260421 return 0;
261422
262423 err_state_wait_activate_to_locked:
263424 err_fsm_activate:
264425 err_flash_components:
426
+err_state_wait_reactivate_to_locked:
427
+err_fsm_reactivate:
265428 err_state_wait_idle_to_locked:
266429 mlxfw_dev->ops->fsm_release(mlxfw_dev, fwhandle);
267430 err_fsm_lock:
268431 mlxfw_mfa2_file_fini(mfa2_file);
432
+ devlink_flash_update_end_notify(mlxfw_dev->devlink);
269433 return err;
270434 }
271435 EXPORT_SYMBOL(mlxfw_firmware_flash);