net/sfc/base: check NVRAM locking by partition ID
Tracking which partition is locked avoids being overly conservative when EFX_NVRAM_xxx maps to more than one partition (depnding on the current port number). Signed-off-by: Andy Moreton <amoreton@solarflare.com> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
This commit is contained in:
parent
90f8fc7b9d
commit
f4332a5f48
@ -461,6 +461,10 @@ typedef struct efx_mcdi_s {
|
||||
#endif /* EFSYS_OPT_MCDI */
|
||||
|
||||
#if EFSYS_OPT_NVRAM
|
||||
|
||||
/* Invalid partition ID for en_nvram_partn_locked field of efx_nc_t */
|
||||
#define EFX_NVRAM_PARTN_INVALID (0xffffffffu)
|
||||
|
||||
typedef struct efx_nvram_ops_s {
|
||||
#if EFSYS_OPT_DIAG
|
||||
efx_rc_t (*envo_test)(efx_nic_t *);
|
||||
@ -648,7 +652,7 @@ struct efx_nic_s {
|
||||
efx_mcdi_t en_mcdi;
|
||||
#endif /* EFSYS_OPT_MCDI */
|
||||
#if EFSYS_OPT_NVRAM
|
||||
efx_nvram_type_t en_nvram_locked;
|
||||
uint32_t en_nvram_partn_locked;
|
||||
const efx_nvram_ops_t *en_envop;
|
||||
#endif /* EFSYS_OPT_NVRAM */
|
||||
#if EFSYS_OPT_VPD
|
||||
|
@ -112,6 +112,8 @@ efx_nvram_init(
|
||||
enp->en_envop = envop;
|
||||
enp->en_mod_flags |= EFX_MOD_NVRAM;
|
||||
|
||||
enp->en_nvram_partn_locked = EFX_NVRAM_PARTN_INVALID;
|
||||
|
||||
return (0);
|
||||
|
||||
fail1:
|
||||
@ -227,15 +229,15 @@ efx_nvram_rw_start(
|
||||
EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES);
|
||||
EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID);
|
||||
|
||||
EFSYS_ASSERT3U(enp->en_nvram_locked, ==, EFX_NVRAM_INVALID);
|
||||
|
||||
if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
|
||||
goto fail1;
|
||||
|
||||
EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, EFX_NVRAM_PARTN_INVALID);
|
||||
|
||||
if ((rc = envop->envo_partn_rw_start(enp, partn, chunk_sizep)) != 0)
|
||||
goto fail2;
|
||||
|
||||
enp->en_nvram_locked = type;
|
||||
enp->en_nvram_partn_locked = partn;
|
||||
|
||||
return (0);
|
||||
|
||||
@ -265,11 +267,11 @@ efx_nvram_read_chunk(
|
||||
EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES);
|
||||
EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID);
|
||||
|
||||
EFSYS_ASSERT3U(enp->en_nvram_locked, ==, type);
|
||||
|
||||
if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
|
||||
goto fail1;
|
||||
|
||||
EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, partn);
|
||||
|
||||
if ((rc = envop->envo_partn_read(enp, partn, offset, data, size)) != 0)
|
||||
goto fail2;
|
||||
|
||||
@ -300,11 +302,11 @@ efx_nvram_erase(
|
||||
EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES);
|
||||
EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID);
|
||||
|
||||
EFSYS_ASSERT3U(enp->en_nvram_locked, ==, type);
|
||||
|
||||
if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
|
||||
goto fail1;
|
||||
|
||||
EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, partn);
|
||||
|
||||
if ((rc = envop->envo_partn_size(enp, partn, &size)) != 0)
|
||||
goto fail2;
|
||||
|
||||
@ -341,11 +343,11 @@ efx_nvram_write_chunk(
|
||||
EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES);
|
||||
EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID);
|
||||
|
||||
EFSYS_ASSERT3U(enp->en_nvram_locked, ==, type);
|
||||
|
||||
if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
|
||||
goto fail1;
|
||||
|
||||
EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, partn);
|
||||
|
||||
if ((rc = envop->envo_partn_write(enp, partn, offset, data, size)) != 0)
|
||||
goto fail2;
|
||||
|
||||
@ -376,15 +378,15 @@ efx_nvram_rw_finish(
|
||||
EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES);
|
||||
EFSYS_ASSERT3U(type, !=, EFX_NVRAM_INVALID);
|
||||
|
||||
EFSYS_ASSERT3U(enp->en_nvram_locked, ==, type);
|
||||
|
||||
if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
|
||||
goto fail1;
|
||||
|
||||
EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, partn);
|
||||
|
||||
if ((rc = envop->envo_partn_rw_finish(enp, partn, &verify_result)) != 0)
|
||||
goto fail2;
|
||||
|
||||
enp->en_nvram_locked = EFX_NVRAM_INVALID;
|
||||
enp->en_nvram_partn_locked = EFX_NVRAM_PARTN_INVALID;
|
||||
|
||||
if (verify_resultp != NULL)
|
||||
*verify_resultp = verify_result;
|
||||
@ -393,7 +395,7 @@ efx_nvram_rw_finish(
|
||||
|
||||
fail2:
|
||||
EFSYS_PROBE(fail2);
|
||||
enp->en_nvram_locked = EFX_NVRAM_INVALID;
|
||||
enp->en_nvram_partn_locked = EFX_NVRAM_PARTN_INVALID;
|
||||
|
||||
fail1:
|
||||
EFSYS_PROBE1(fail1, efx_rc_t, rc);
|
||||
@ -421,16 +423,16 @@ efx_nvram_set_version(
|
||||
|
||||
EFSYS_ASSERT3U(type, <, EFX_NVRAM_NTYPES);
|
||||
|
||||
/*
|
||||
* The Siena implementation of envo_set_version() will attempt to
|
||||
* acquire the NVRAM_UPDATE lock for the DYNAMIC_CONFIG sector.
|
||||
* Therefore, you can't have already acquired the NVRAM_UPDATE lock.
|
||||
*/
|
||||
EFSYS_ASSERT3U(enp->en_nvram_locked, ==, EFX_NVRAM_INVALID);
|
||||
|
||||
if ((rc = envop->envo_type_to_partn(enp, type, &partn)) != 0)
|
||||
goto fail1;
|
||||
|
||||
/*
|
||||
* The Siena implementation of envo_set_version() will attempt to
|
||||
* acquire the NVRAM_UPDATE lock for the DYNAMIC_CONFIG partition.
|
||||
* Therefore, you can't have already acquired the NVRAM_UPDATE lock.
|
||||
*/
|
||||
EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, EFX_NVRAM_PARTN_INVALID);
|
||||
|
||||
if ((rc = envop->envo_partn_set_version(enp, partn, version)) != 0)
|
||||
goto fail2;
|
||||
|
||||
@ -490,7 +492,7 @@ efx_nvram_fini(
|
||||
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
|
||||
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_NVRAM);
|
||||
|
||||
EFSYS_ASSERT3U(enp->en_nvram_locked, ==, EFX_NVRAM_INVALID);
|
||||
EFSYS_ASSERT3U(enp->en_nvram_partn_locked, ==, EFX_NVRAM_PARTN_INVALID);
|
||||
|
||||
enp->en_envop = NULL;
|
||||
enp->en_mod_flags &= ~EFX_MOD_NVRAM;
|
||||
|
Loading…
x
Reference in New Issue
Block a user