On Fri, Aug 22, 2025 at 09:52:25PM +0200, Andrew Lunn wrote: > > 'Update firmware operation' will take long time, maybe more than > > 10s. If user use 'ethtool -f' to update firmware, and ^C before done? > > If ^C before mucse_write_mbx, return as soon as possible. If after mucse_write_mbx, > > wait until fw true response. > > And what happens if the firmware writing is interrupted? Could you end > up with a brick? This is actually one of the operations i would not > expect to be able to ^C. > > You might also want consider devlink flash. > > https://www.kernel.org/doc/html/latest/networking/devlink/devlink-flash.html > > It replaces the older ethtool-flash mechanism, and doesn’t require > taking any networking locks in the kernel to perform the flash > update. > > I assume this is meaning ethtool take RTNL, and while that is held, no > other network configuration can be performed on any interface. devlink > has its own lock so avoids this. > > Andrew > ethtool or devlink both call mbx(mucse_mbx_fw_post_req) to do the true update to firmware. FW not end up with a brick, it has fault tolerance itself. But that's not the point. The original question is about 'wait_event_timeout', I add some comment link this in v6: Wait fw response without interruptible. static int mucse_mbx_fw_post_req(struct mucse_hw *hw, struct mbx_fw_cmd_req *req, struct mbx_req_cookie *cookie) { int len = le16_to_cpu(req->datalen); int err; cookie->errcode = 0; cookie->done = 0; init_waitqueue_head(&cookie->wait); err = mutex_lock_interruptible(&hw->mbx.lock); if (err) return err; err = mucse_write_mbx_pf(hw, (u32 *)req, len); if (err) goto out; /* if write succeeds, we must wait for firmware response or * timeout to avoid using the already freed cookie->wait */ err = wait_event_timeout(cookie->wait, cookie->done == 1, cookie->timeout_jiffies); if (!err) err = -ETIMEDOUT; else err = 0; if (!err && cookie->errcode) err = cookie->errcode; out: mutex_unlock(&hw->mbx.lock); return err; }