net: libwx: fix firmware mailbox abnormal return
authorJiawen Wu <jiawenwu@trustnetic.com>
Fri, 3 Jan 2025 08:10:13 +0000 (16:10 +0800)
committerJakub Kicinski <kuba@kernel.org>
Sun, 5 Jan 2025 01:42:15 +0000 (17:42 -0800)
commit8ce4f287524c74a118b0af1eebd4b24a8efca57a
tree302418d1621c82c636105eaf31d9387350861b52
parenta4faa15d28f4afb0a7d6213894175e612f825cd6
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>
drivers/net/ethernet/wangxun/libwx/wx_hw.c