]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
idpf: avoid vport access in idpf_get_link_ksettings
authorPavan Kumar Linga <pavan.kumar.linga@intel.com>
Fri, 25 Oct 2024 18:38:42 +0000 (11:38 -0700)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Mon, 4 Nov 2024 21:09:33 +0000 (13:09 -0800)
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: 02cbfba1add5 ("idpf: add ethtool callbacks")
Cc: stable@vger.kernel.org # 6.7+
Reviewed-by: Tarun K Singh <tarun.k.singh@intel.com>
Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
Tested-by: Krishneil Singh <krishneil.k.singh@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/idpf/idpf.h
drivers/net/ethernet/intel/idpf/idpf_ethtool.c
drivers/net/ethernet/intel/idpf/idpf_lib.c
drivers/net/ethernet/intel/idpf/idpf_virtchnl.c

index 2c31ad87587a4a61e0edd47601a26649f6b0851c..66544faab710aa9ebc7e9cca48702fedd699cfe8 100644 (file)
@@ -141,6 +141,7 @@ enum idpf_vport_state {
  * @adapter: Adapter back pointer
  * @vport: Vport back pointer
  * @vport_id: Vport identifier
+ * @link_speed_mbps: Link speed in mbps
  * @vport_idx: Relative vport index
  * @state: See enum idpf_vport_state
  * @netstats: Packet and byte stats
@@ -150,6 +151,7 @@ struct idpf_netdev_priv {
        struct idpf_adapter *adapter;
        struct idpf_vport *vport;
        u32 vport_id;
+       u32 link_speed_mbps;
        u16 vport_idx;
        enum idpf_vport_state state;
        struct rtnl_link_stats64 netstats;
@@ -287,7 +289,6 @@ struct idpf_port_stats {
  * @tx_itr_profile: TX profiles for Dynamic Interrupt Moderation
  * @port_stats: per port csum, header split, and other offload stats
  * @link_up: True if link is up
- * @link_speed_mbps: Link speed in mbps
  * @sw_marker_wq: workqueue for marker packets
  */
 struct idpf_vport {
@@ -331,7 +332,6 @@ struct idpf_vport {
        struct idpf_port_stats port_stats;
 
        bool link_up;
-       u32 link_speed_mbps;
 
        wait_queue_head_t sw_marker_wq;
 };
index 3806ddd3ce4ab95a4d52dbabaad34957c775d935..59b1a1a099967f96230b5f5739dec80ad965a7cb 100644 (file)
@@ -1296,24 +1296,19 @@ 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_vport *vport;
-
-       idpf_vport_ctrl_lock(netdev);
-       vport = idpf_netdev_to_vport(netdev);
+       struct idpf_netdev_priv *np = netdev_priv(netdev);
 
        ethtool_link_ksettings_zero_link_mode(cmd, supported);
        cmd->base.autoneg = AUTONEG_DISABLE;
        cmd->base.port = PORT_NONE;
-       if (vport->link_up) {
+       if (netif_carrier_ok(netdev)) {
                cmd->base.duplex = DUPLEX_FULL;
-               cmd->base.speed = vport->link_speed_mbps;
+               cmd->base.speed = np->link_speed_mbps;
        } else {
                cmd->base.duplex = DUPLEX_UNKNOWN;
                cmd->base.speed = SPEED_UNKNOWN;
        }
 
-       idpf_vport_ctrl_unlock(netdev);
-
        return 0;
 }
 
index 4f20343e49a98039a5ca3b3c862fd44c05548bfc..c3848e10e7dbef76a33b24429ced32d3488d8059 100644 (file)
@@ -1860,7 +1860,7 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport,
         * mess with. Nothing below should use those variables from new_vport
         * and should instead always refer to them in vport if they need to.
         */
-       memcpy(new_vport, vport, offsetof(struct idpf_vport, link_speed_mbps));
+       memcpy(new_vport, vport, offsetof(struct idpf_vport, link_up));
 
        /* Adjust resource parameters prior to reallocating resources */
        switch (reset_cause) {
@@ -1906,7 +1906,7 @@ int idpf_initiate_soft_reset(struct idpf_vport *vport,
        /* Same comment as above regarding avoiding copying the wait_queues and
         * mutexes applies here. We do not want to mess with those if possible.
         */
-       memcpy(vport, new_vport, offsetof(struct idpf_vport, link_speed_mbps));
+       memcpy(vport, new_vport, offsetof(struct idpf_vport, link_up));
 
        if (reset_cause == IDPF_SR_Q_CHANGE)
                idpf_vport_alloc_vec_indexes(vport);
index 15c00a01f1c0b988e349e196fa3d9a25cbcf78d5..ce217e274506db57710609f57b2735be95cb1823 100644 (file)
@@ -141,7 +141,7 @@ static void idpf_handle_event_link(struct idpf_adapter *adapter,
        }
        np = netdev_priv(vport->netdev);
 
-       vport->link_speed_mbps = le32_to_cpu(v2e->link_speed);
+       np->link_speed_mbps = le32_to_cpu(v2e->link_speed);
 
        if (vport->link_up == v2e->link_status)
                return;