On Fri, Aug 22, 2025 at 04:43:16PM +0200, Andrew Lunn wrote:
> > +/**
> > + * mucse_mbx_get_capability - Get hw abilities from fw
> > + * @hw: pointer to the HW structure
> > + *
> > + * mucse_mbx_get_capability tries to get capabities from
> > + * hw. Many retrys will do if it is failed.
> > + *
> > + * @return: 0 on success, negative on failure
> > + **/
> > +int mucse_mbx_get_capability(struct mucse_hw *hw)
> > +{
> > + struct hw_abilities ability = {};
> > + int try_cnt = 3;
> > + int err = -EIO;
> > +
> > + while (try_cnt--) {
> > + err = mucse_fw_get_capability(hw, &ability);
> > + if (err)
> > + continue;
> > + hw->pfvfnum = le16_to_cpu(ability.pfnum) & GENMASK_U16(7, 0);
> > + return 0;
> > + }
> > + return err;
> > +}
>
> Please could you add an explanation why it would fail? Is this to do
> with getting the driver and firmware in sync? Maybe you should make
> this explicit, add a function mucse_mbx_sync() with a comment that
> this is used once during probe to synchronise communication with the
> firmware. You can then remove this loop here.
It is just get some fw capability(or info such as fw version).
It is failed maybe:
1. -EIO: return by mucse_obtain_mbx_lock_pf. The function tries to get
pf-fw lock(in chip register, not driver), failed when fw hold the lock.
2. -ETIMEDOUT: return by mucse_poll_for_xx. Failed when timeout.
3. -ETIMEDOUT: return by mucse_fw_send_cmd_wait. Failed when wait
response timeout.
4. -EIO: return by mucse_fw_send_cmd_wait. Failed when error_code in
response.
5. err return by mutex_lock_interruptible.
>
> I would also differentiate between different error codes. It is
> pointless to try again with ENOMEM, EINVAL, etc. These are real errors
> which should be reported. However TIMEDOUT might makes sense to
> retry.
>
> Andrew
>
Yes, I didn't differentiate between different error codes. But it cost
~0 to ask firmware again. And error will be reported after 'try_cnt' times
retry to the function caller.
Maybe can simply handle error codes link this?
Thanks for your feedback.