Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: libwx: fix firmware mailbox abnormal return

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: 1efa9bfe58c5 ("net: libwx: Implement interaction with firmware")
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
Link: https://patch.msgid.link/20250103081013.1995939-1-jiawenwu@trustnetic.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Jiawen Wu and committed by
Jakub Kicinski
8ce4f287 a4faa15d

+11 -13
+11 -13
drivers/net/ethernet/wangxun/libwx/wx_hw.c
··· 334 334 status = read_poll_timeout(rd32, hicr, hicr & WX_MNG_MBOX_CTL_FWRDY, 1000, 335 335 timeout * 1000, false, wx, WX_MNG_MBOX_CTL); 336 336 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 + 337 344 /* Check command completion */ 338 345 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"); 352 347 wx_dbg(wx, "write value:\n"); 353 348 for (i = 0; i < dword_len; i++) 354 349 wx_dbg(wx, "%x ", buffer[i]); 355 350 wx_dbg(wx, "read value:\n"); 356 351 for (i = 0; i < dword_len; i++) 357 352 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; 358 356 } 359 357 360 358 if (!return_data)