Skip to content

Commit 8c9d137

Browse files
committed
idpf: avoid vport access in idpf_get_link_ksettings
jira LE-2522 Rebuild_History Non-Buildable kernel-5.14.0-503.29.1.el9_5 commit-author Pavan Kumar Linga <[email protected]> commit 81d2fb4 When the device control plane is removed or the platform running device control plane is rebooted, a reset is detected on the driver. On driver reset, it releases the resources and waits for the reset to complete. If the reset fails, it takes the error path and releases the vport lock. At this time if the monitoring tools tries to access link settings, it call traces for accessing released vport pointer. To avoid it, move link_speed_mbps to netdev_priv structure which removes the dependency on vport pointer and the vport lock in idpf_get_link_ksettings. Also use netif_carrier_ok() to check the link status and adjust the offsetof to use link_up instead of link_speed_mbps. Fixes: 02cbfba ("idpf: add ethtool callbacks") Cc: [email protected] # 6.7+ Reviewed-by: Tarun K Singh <[email protected]> Signed-off-by: Pavan Kumar Linga <[email protected]> Tested-by: Krishneil Singh <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> (cherry picked from commit 81d2fb4) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 9c0a7fd commit 8c9d137

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

drivers/net/ethernet/intel/idpf/idpf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ enum idpf_vport_state {
143143
* @adapter: Adapter back pointer
144144
* @vport: Vport back pointer
145145
* @vport_id: Vport identifier
146+
* @link_speed_mbps: Link speed in mbps
146147
* @vport_idx: Relative vport index
147148
* @state: See enum idpf_vport_state
148149
* @netstats: Packet and byte stats
@@ -152,6 +153,7 @@ struct idpf_netdev_priv {
152153
struct idpf_adapter *adapter;
153154
struct idpf_vport *vport;
154155
u32 vport_id;
156+
u32 link_speed_mbps;
155157
u16 vport_idx;
156158
enum idpf_vport_state state;
157159
struct rtnl_link_stats64 netstats;
@@ -290,7 +292,6 @@ struct idpf_port_stats {
290292
* @tx_itr_profile: TX profiles for Dynamic Interrupt Moderation
291293
* @port_stats: per port csum, header split, and other offload stats
292294
* @link_up: True if link is up
293-
* @link_speed_mbps: Link speed in mbps
294295
* @sw_marker_wq: workqueue for marker packets
295296
*/
296297
struct idpf_vport {
@@ -335,7 +336,6 @@ struct idpf_vport {
335336
struct idpf_port_stats port_stats;
336337

337338
bool link_up;
338-
u32 link_speed_mbps;
339339

340340
wait_queue_head_t sw_marker_wq;
341341
};

drivers/net/ethernet/intel/idpf/idpf_ethtool.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,24 +1319,19 @@ static void idpf_set_msglevel(struct net_device *netdev, u32 data)
13191319
static int idpf_get_link_ksettings(struct net_device *netdev,
13201320
struct ethtool_link_ksettings *cmd)
13211321
{
1322-
struct idpf_vport *vport;
1323-
1324-
idpf_vport_ctrl_lock(netdev);
1325-
vport = idpf_netdev_to_vport(netdev);
1322+
struct idpf_netdev_priv *np = netdev_priv(netdev);
13261323

13271324
ethtool_link_ksettings_zero_link_mode(cmd, supported);
13281325
cmd->base.autoneg = AUTONEG_DISABLE;
13291326
cmd->base.port = PORT_NONE;
1330-
if (vport->link_up) {
1327+
if (netif_carrier_ok(netdev)) {
13311328
cmd->base.duplex = DUPLEX_FULL;
1332-
cmd->base.speed = vport->link_speed_mbps;
1329+
cmd->base.speed = np->link_speed_mbps;
13331330
} else {
13341331
cmd->base.duplex = DUPLEX_UNKNOWN;
13351332
cmd->base.speed = SPEED_UNKNOWN;
13361333
}
13371334

1338-
idpf_vport_ctrl_unlock(netdev);
1339-
13401335
return 0;
13411336
}
13421337

drivers/net/ethernet/intel/idpf/idpf_lib.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,7 +1877,7 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport,
18771877
* mess with. Nothing below should use those variables from new_vport
18781878
* and should instead always refer to them in vport if they need to.
18791879
*/
1880-
memcpy(new_vport, vport, offsetof(struct idpf_vport, link_speed_mbps));
1880+
memcpy(new_vport, vport, offsetof(struct idpf_vport, link_up));
18811881

18821882
/* Adjust resource parameters prior to reallocating resources */
18831883
switch (reset_cause) {
@@ -1926,7 +1926,7 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport,
19261926
/* Same comment as above regarding avoiding copying the wait_queues and
19271927
* mutexes applies here. We do not want to mess with those if possible.
19281928
*/
1929-
memcpy(vport, new_vport, offsetof(struct idpf_vport, link_speed_mbps));
1929+
memcpy(vport, new_vport, offsetof(struct idpf_vport, link_up));
19301930

19311931
/* Since idpf_vport_queues_alloc was called with new_port, the queue
19321932
* back pointers are currently pointing to the local new_vport. Reset

drivers/net/ethernet/intel/idpf/idpf_virtchnl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static void idpf_handle_event_link(struct idpf_adapter *adapter,
139139
}
140140
np = netdev_priv(vport->netdev);
141141

142-
vport->link_speed_mbps = le32_to_cpu(v2e->link_speed);
142+
np->link_speed_mbps = le32_to_cpu(v2e->link_speed);
143143

144144
if (vport->link_up == v2e->link_status)
145145
return;

0 commit comments

Comments
 (0)