diff mbox series

[RFC,v2,04/25] idpf: prevent deadlock with irdma get link settings

Message ID 20240824031924.421-5-tatyana.e.nikolova@intel.com (mailing list archive)
State RFC
Headers show
Series Add RDMA support for Intel IPU E2000 (GEN3) | expand

Commit Message

Nikolova, Tatyana E Aug. 24, 2024, 3:19 a.m. UTC
From: Joshua Hay <joshua.a.hay@intel.com>

When the rdma core deinitializes (reset or remove), it is calling
get_link_ksettings. Add logic to get link settings to avoid even taking
the lock during a reset or remove, since we will not care what the link
settings are in that state anyways.

Signed-off-by: Joshua Hay <joshua.a.hay@intel.com>
Signed-off-by: Tatyana Nikolova <tatyana.e.nikolova@intel.com>
---
 drivers/net/ethernet/intel/idpf/idpf_ethtool.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/idpf/idpf_ethtool.c b/drivers/net/ethernet/intel/idpf/idpf_ethtool.c
index 3806ddd3ce4a..d287a5537167 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_ethtool.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_ethtool.c
@@ -1296,20 +1296,25 @@  static void idpf_set_msglevel(struct net_device *netdev, u32 data)
 static int idpf_get_link_ksettings(struct net_device *netdev,
 				   struct ethtool_link_ksettings *cmd)
 {
+	struct idpf_adapter *adapter = idpf_netdev_to_adapter(netdev);
 	struct idpf_vport *vport;
 
-	idpf_vport_ctrl_lock(netdev);
-	vport = idpf_netdev_to_vport(netdev);
-
 	ethtool_link_ksettings_zero_link_mode(cmd, supported);
 	cmd->base.autoneg = AUTONEG_DISABLE;
 	cmd->base.port = PORT_NONE;
+	cmd->base.duplex = DUPLEX_UNKNOWN;
+	cmd->base.speed = SPEED_UNKNOWN;
+
+	if (idpf_is_reset_in_prog(adapter) ||
+	    test_bit(IDPF_REMOVE_IN_PROG, adapter->flags))
+		return 0;
+
+	idpf_vport_ctrl_lock(netdev);
+	vport = idpf_netdev_to_vport(netdev);
+
 	if (vport->link_up) {
 		cmd->base.duplex = DUPLEX_FULL;
 		cmd->base.speed = vport->link_speed_mbps;
-	} else {
-		cmd->base.duplex = DUPLEX_UNKNOWN;
-		cmd->base.speed = SPEED_UNKNOWN;
 	}
 
 	idpf_vport_ctrl_unlock(netdev);