cxgb4: Enhance driver to update FW, when FW is too old

t4_check_fw_version() can return several error codes (-EINVAL, -EBUSY,
-EAGAIN). The present code sets the adapter state to UNINIT only if its
an EFAULT. In all the error cases set the adapter to uninitialized state.

In t4_check_fw_version() if call to t4_get_fw_version() fails, repeat the
operation a few times before returning failure.

Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Hariprasad Shenai 2015-10-08 10:08:23 +05:30 committed by David S. Miller
parent ff936a04e5
commit 21d11bd6f0
2 changed files with 6 additions and 2 deletions

View file

@ -3698,7 +3698,7 @@ static int adap_init0(struct adapter *adap)
t4_get_tp_version(adap, &adap->params.tp_vers); t4_get_tp_version(adap, &adap->params.tp_vers);
ret = t4_check_fw_version(adap); ret = t4_check_fw_version(adap);
/* If firmware is too old (not supported by driver) force an update. */ /* If firmware is too old (not supported by driver) force an update. */
if (ret == -EFAULT) if (ret)
state = DEV_STATE_UNINIT; state = DEV_STATE_UNINIT;
if ((adap->flags & MASTER_PF) && state != DEV_STATE_INIT) { if ((adap->flags & MASTER_PF) && state != DEV_STATE_INIT) {
struct fw_info *fw_info; struct fw_info *fw_info;

View file

@ -2981,11 +2981,15 @@ int t4_get_exprom_version(struct adapter *adap, u32 *vers)
*/ */
int t4_check_fw_version(struct adapter *adap) int t4_check_fw_version(struct adapter *adap)
{ {
int ret, major, minor, micro; int i, ret, major, minor, micro;
int exp_major, exp_minor, exp_micro; int exp_major, exp_minor, exp_micro;
unsigned int chip_version = CHELSIO_CHIP_VERSION(adap->params.chip); unsigned int chip_version = CHELSIO_CHIP_VERSION(adap->params.chip);
ret = t4_get_fw_version(adap, &adap->params.fw_vers); ret = t4_get_fw_version(adap, &adap->params.fw_vers);
/* Try multiple times before returning error */
for (i = 0; (ret == -EBUSY || ret == -EAGAIN) && i < 3; i++)
ret = t4_get_fw_version(adap, &adap->params.fw_vers);
if (ret) if (ret)
return ret; return ret;