Skip to content

Commit db3cd50

Browse files
Jiawen Wugregkh
authored andcommitted
net: libwx: fix firmware mailbox abnormal return
[ Upstream commit 8ce4f28 ] The existing SW-FW interaction flow on the driver is wrong. Follow this wrong flow, driver would never return error if there is a unknown command. Since firmware writes back 'firmware ready' and 'unknown command' in the mailbox message if there is an unknown command sent by driver. So reading 'firmware ready' does not timeout. Then driver would mistakenly believe that the interaction has completed successfully. It tends to happen with the use of custom firmware. Move the check for 'unknown command' out of the poll timeout for 'firmware ready'. And adjust the debug log so that mailbox messages are always printed when commands timeout. Fixes: 1efa9bf ("net: libwx: Implement interaction with firmware") Signed-off-by: Jiawen Wu <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 6fde663 commit db3cd50

File tree

1 file changed

+11
-13
lines changed
  • drivers/net/ethernet/wangxun/libwx

1 file changed

+11
-13
lines changed

drivers/net/ethernet/wangxun/libwx/wx_hw.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -334,27 +334,25 @@ int wx_host_interface_command(struct wx *wx, u32 *buffer,
334334
status = read_poll_timeout(rd32, hicr, hicr & WX_MNG_MBOX_CTL_FWRDY, 1000,
335335
timeout * 1000, false, wx, WX_MNG_MBOX_CTL);
336336

337+
buf[0] = rd32(wx, WX_MNG_MBOX);
338+
if ((buf[0] & 0xff0000) >> 16 == 0x80) {
339+
wx_err(wx, "Unknown FW command: 0x%x\n", buffer[0] & 0xff);
340+
status = -EINVAL;
341+
goto rel_out;
342+
}
343+
337344
/* Check command completion */
338345
if (status) {
339-
wx_dbg(wx, "Command has failed with no status valid.\n");
340-
341-
buf[0] = rd32(wx, WX_MNG_MBOX);
342-
if ((buffer[0] & 0xff) != (~buf[0] >> 24)) {
343-
status = -EINVAL;
344-
goto rel_out;
345-
}
346-
if ((buf[0] & 0xff0000) >> 16 == 0x80) {
347-
wx_dbg(wx, "It's unknown cmd.\n");
348-
status = -EINVAL;
349-
goto rel_out;
350-
}
351-
346+
wx_err(wx, "Command has failed with no status valid.\n");
352347
wx_dbg(wx, "write value:\n");
353348
for (i = 0; i < dword_len; i++)
354349
wx_dbg(wx, "%x ", buffer[i]);
355350
wx_dbg(wx, "read value:\n");
356351
for (i = 0; i < dword_len; i++)
357352
wx_dbg(wx, "%x ", buf[i]);
353+
wx_dbg(wx, "\ncheck: %x %x\n", buffer[0] & 0xff, ~buf[0] >> 24);
354+
355+
goto rel_out;
358356
}
359357

360358
if (!return_data)

0 commit comments

Comments
 (0)