fcoe_link_speed_update() calls __ethtool_get_link_ksettings() on the
lport's netdev, which will soon take the dev's ops lock. Some notifier
callers already arrive with this lock held. Switch to
netif_get_link_ksettings() and adjust the explicit call sites to take
the netdev lock explicitly.
Within fcoe_device_notification() try to only query the link speed
from notifiers which announce link state change (UP / CHANGE),
DOWN / GOING_DOWN notifiers are slightly sketchy when it comes
to ops locking right now, and the code already special-cases
those by maintaining the local link_possible variable.
Also take the lock in bnx2fc_net_config(), even though I think
that bnx2fc call sites are largely irrelevant since it's not
an ops-locked driver.
Link: https://patch.msgid.link/20260603012840.2254293-11-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
#include "bnx2fc.h"
#include <linux/ethtool.h>
+#include <net/netdev_lock.h>
static struct list_head adapter_list;
static struct list_head if_list;
port->fcoe_pending_queue_active = 0;
timer_setup(&port->timer, fcoe_queue_timer, 0);
+ netdev_lock_ops(netdev);
fcoe_link_speed_update(lport);
+ netdev_unlock_ops(netdev);
if (!lport->vport) {
if (fcoe_get_wwn(netdev, &wwnn, NETDEV_FCOE_WWNN))
#include <scsi/scsicam.h>
#include <scsi/scsi_transport.h>
#include <scsi/scsi_transport_fc.h>
+#include <net/netdev_lock.h>
#include <net/rtnetlink.h>
#include <scsi/fc/fc_encaps.h>
port->fcoe_pending_queue_active = 0;
timer_setup(&port->timer, fcoe_queue_timer, 0);
+ netdev_lock_ops(netdev);
fcoe_link_speed_update(lport);
+ netdev_unlock_ops(netdev);
if (!lport->vport) {
if (fcoe_get_wwn(netdev, &wwnn, NETDEV_FCOE_WWNN))
break;
case NETDEV_UP:
case NETDEV_CHANGE:
+ fcoe_link_speed_update(lport);
break;
case NETDEV_CHANGEMTU:
if (netdev->fcoe_mtu)
"from netdev netlink\n", event);
}
- fcoe_link_speed_update(lport);
-
cdev = fcoe_ctlr_to_ctlr_dev(ctlr);
if (link_possible && !fcoe_link_ok(lport)) {
* fcoe_link_speed_update() - Update the supported and actual link speeds
* @lport: The local port to update speeds for
*
+ * Caller must hold the netdev's ops lock.
+ *
* Returns: 0 if the ethtool query was successful
* -1 if the ethtool query failed
*/
struct net_device *netdev = fcoe_get_netdev(lport);
struct ethtool_link_ksettings ecmd;
- if (!__ethtool_get_link_ksettings(netdev, &ecmd)) {
+ if (!netif_get_link_ksettings(netdev, &ecmd)) {
lport->link_supported_speeds &= ~(FC_PORTSPEED_1GBIT |
FC_PORTSPEED_10GBIT |
FC_PORTSPEED_20GBIT |