]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
enic: make enic_dev_enable/disable ref-counted
authorSatish Kharat <satishkh@cisco.com>
Wed, 1 Apr 2026 15:31:14 +0000 (08:31 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 3 Apr 2026 01:05:06 +0000 (18:05 -0700)
commit0266ecb59d5242a5d66261a671e42d53a1372f69
tree6cd7da2b62b8d222d6b7642e2d9196f18cd1802a
parent56a4d7a865860ac0e52e26a4c8d13de78e7a9707
enic: make enic_dev_enable/disable ref-counted

Both the data path (ndo_open/ndo_stop) and the upcoming admin channel
need to enable and disable the vNIC device independently. Without
reference counting, closing the admin channel while the netdev is up
would inadvertently disable the entire device.

Add an enable_count to struct enic, protected by the existing
devcmd_lock. enic_dev_enable() issues CMD_ENABLE_WAIT only on the
first caller (0 -> 1 transition), and enic_dev_disable() issues
CMD_DISABLE only when the last caller releases (1 -> 0 transition).

Also check the return value of enic_dev_enable() in enic_open() and
fail the open if the firmware enable command fails. Without this check,
a failed enable leaves enable_count at zero while the interface appears
up, which can cause a later admin channel enable/disable cycle to
incorrectly disable the hardware under the active data path.

Signed-off-by: Satish Kharat <satishkh@cisco.com>
Link: https://patch.msgid.link/20260401-enic-sriov-v2-prep-v4-4-d5834b2ef1b9@cisco.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/cisco/enic/enic.h
drivers/net/ethernet/cisco/enic/enic_dev.c
drivers/net/ethernet/cisco/enic/enic_main.c