Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mlx4: Delete custom device management logic

After the conversion to use the auxiliary bus, the custom device
management is not needed anymore and can be deleted.

Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Tested-by: Leon Romanovsky <leonro@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Acked-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Petr Pavlu and committed by
David S. Miller
c138cdb8 7d22b1cb

-166
-125
drivers/net/ethernet/mellanox/mlx4/intf.c
··· 38 38 39 39 #include "mlx4.h" 40 40 41 - struct mlx4_device_context { 42 - struct list_head list; 43 - struct list_head bond_list; 44 - struct mlx4_interface *intf; 45 - void *context; 46 - }; 47 - 48 - static LIST_HEAD(intf_list); 49 - static LIST_HEAD(dev_list); 50 41 static DEFINE_MUTEX(intf_mutex); 51 42 static DEFINE_IDA(mlx4_adev_ida); 52 43 ··· 147 156 auxiliary_device_uninit(adev); 148 157 } 149 158 150 - static void mlx4_add_device(struct mlx4_interface *intf, struct mlx4_priv *priv) 151 - { 152 - struct mlx4_device_context *dev_ctx; 153 - 154 - dev_ctx = kmalloc(sizeof(*dev_ctx), GFP_KERNEL); 155 - if (!dev_ctx) 156 - return; 157 - 158 - dev_ctx->intf = intf; 159 - dev_ctx->context = intf->add(&priv->dev); 160 - 161 - if (dev_ctx->context) { 162 - spin_lock_irq(&priv->ctx_lock); 163 - list_add_tail(&dev_ctx->list, &priv->ctx_list); 164 - spin_unlock_irq(&priv->ctx_lock); 165 - } else 166 - kfree(dev_ctx); 167 - 168 - } 169 - 170 - static void mlx4_remove_device(struct mlx4_interface *intf, struct mlx4_priv *priv) 171 - { 172 - struct mlx4_device_context *dev_ctx; 173 - 174 - list_for_each_entry(dev_ctx, &priv->ctx_list, list) 175 - if (dev_ctx->intf == intf) { 176 - spin_lock_irq(&priv->ctx_lock); 177 - list_del(&dev_ctx->list); 178 - spin_unlock_irq(&priv->ctx_lock); 179 - 180 - intf->remove(&priv->dev, dev_ctx->context); 181 - kfree(dev_ctx); 182 - return; 183 - } 184 - } 185 - 186 - int mlx4_register_interface(struct mlx4_interface *intf) 187 - { 188 - struct mlx4_priv *priv; 189 - 190 - if (!intf->add || !intf->remove) 191 - return -EINVAL; 192 - 193 - mutex_lock(&intf_mutex); 194 - 195 - list_add_tail(&intf->list, &intf_list); 196 - list_for_each_entry(priv, &dev_list, dev_list) { 197 - mlx4_add_device(intf, priv); 198 - } 199 - 200 - mutex_unlock(&intf_mutex); 201 - 202 - return 0; 203 - } 204 - EXPORT_SYMBOL_GPL(mlx4_register_interface); 205 - 206 - void mlx4_unregister_interface(struct mlx4_interface *intf) 207 - { 208 - struct mlx4_priv *priv; 209 - 210 - mutex_lock(&intf_mutex); 211 - 212 - list_for_each_entry(priv, &dev_list, dev_list) 213 - mlx4_remove_device(intf, priv); 214 - 215 - list_del(&intf->list); 216 - 217 - mutex_unlock(&intf_mutex); 218 - } 219 - EXPORT_SYMBOL_GPL(mlx4_unregister_interface); 220 - 221 159 int mlx4_register_auxiliary_driver(struct mlx4_adrv *madrv) 222 160 { 223 161 return auxiliary_driver_register(&madrv->adrv); ··· 162 242 int mlx4_do_bond(struct mlx4_dev *dev, bool enable) 163 243 { 164 244 struct mlx4_priv *priv = mlx4_priv(dev); 165 - struct mlx4_device_context *dev_ctx = NULL, *temp_dev_ctx; 166 - unsigned long flags; 167 245 int i, ret; 168 - LIST_HEAD(bond_list); 169 246 170 247 if (!(dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_PORT_REMAP)) 171 248 return -EOPNOTSUPP; ··· 182 265 return ret; 183 266 } 184 267 dev->flags &= ~MLX4_FLAG_BONDED; 185 - } 186 - 187 - spin_lock_irqsave(&priv->ctx_lock, flags); 188 - list_for_each_entry_safe(dev_ctx, temp_dev_ctx, &priv->ctx_list, list) { 189 - if (!(dev_ctx->intf->flags & MLX4_INTFF_BONDING)) 190 - continue; 191 - 192 - if (mlx4_is_mfunc(dev)) { 193 - mlx4_dbg(dev, 194 - "SRIOV, disabled HA mode for intf proto %d\n", 195 - dev_ctx->intf->protocol); 196 - continue; 197 - } 198 - 199 - list_add_tail(&dev_ctx->bond_list, &bond_list); 200 - list_del(&dev_ctx->list); 201 - } 202 - spin_unlock_irqrestore(&priv->ctx_lock, flags); 203 - 204 - list_for_each_entry(dev_ctx, &bond_list, bond_list) { 205 - dev_ctx->intf->remove(dev, dev_ctx->context); 206 - dev_ctx->context = dev_ctx->intf->add(dev); 207 - 208 - spin_lock_irqsave(&priv->ctx_lock, flags); 209 - list_add_tail(&dev_ctx->list, &priv->ctx_list); 210 - spin_unlock_irqrestore(&priv->ctx_lock, flags); 211 - 212 - mlx4_dbg(dev, "Interface for protocol %d restarted with bonded mode %s\n", 213 - dev_ctx->intf->protocol, enable ? 214 - "enabled" : "disabled"); 215 268 } 216 269 217 270 mutex_lock(&intf_mutex); ··· 334 447 335 448 int mlx4_register_device(struct mlx4_dev *dev) 336 449 { 337 - struct mlx4_priv *priv = mlx4_priv(dev); 338 - struct mlx4_interface *intf; 339 450 int ret; 340 451 341 452 mutex_lock(&intf_mutex); 342 453 343 454 dev->persist->interface_state |= MLX4_INTERFACE_STATE_UP; 344 - list_add_tail(&priv->dev_list, &dev_list); 345 - list_for_each_entry(intf, &intf_list, list) 346 - mlx4_add_device(intf, priv); 347 455 348 456 ret = rescan_drivers_locked(dev); 349 457 ··· 356 474 357 475 void mlx4_unregister_device(struct mlx4_dev *dev) 358 476 { 359 - struct mlx4_priv *priv = mlx4_priv(dev); 360 - struct mlx4_interface *intf; 361 - 362 477 if (!(dev->persist->interface_state & MLX4_INTERFACE_STATE_UP)) 363 478 return; 364 479 ··· 374 495 } 375 496 mutex_lock(&intf_mutex); 376 497 377 - list_for_each_entry(intf, &intf_list, list) 378 - mlx4_remove_device(intf, priv); 379 - 380 - list_del(&priv->dev_list); 381 498 dev->persist->interface_state &= ~MLX4_INTERFACE_STATE_UP; 382 499 383 500 rescan_drivers_locked(dev);
-28
drivers/net/ethernet/mellanox/mlx4/main.c
··· 42 42 #include <linux/slab.h> 43 43 #include <linux/io-mapping.h> 44 44 #include <linux/delay.h> 45 - #include <linux/kmod.h> 46 45 #include <linux/etherdevice.h> 47 46 #include <net/devlink.h> 48 47 ··· 1090 1091 return err; 1091 1092 } 1092 1093 1093 - static void mlx4_request_modules(struct mlx4_dev *dev) 1094 - { 1095 - int port; 1096 - int has_ib_port = false; 1097 - int has_eth_port = false; 1098 - #define EN_DRV_NAME "mlx4_en" 1099 - #define IB_DRV_NAME "mlx4_ib" 1100 - 1101 - for (port = 1; port <= dev->caps.num_ports; port++) { 1102 - if (dev->caps.port_type[port] == MLX4_PORT_TYPE_IB) 1103 - has_ib_port = true; 1104 - else if (dev->caps.port_type[port] == MLX4_PORT_TYPE_ETH) 1105 - has_eth_port = true; 1106 - } 1107 - 1108 - if (has_eth_port) 1109 - request_module_nowait(EN_DRV_NAME); 1110 - if (has_ib_port || (dev->caps.flags & MLX4_DEV_CAP_FLAG_IBOE)) 1111 - request_module_nowait(IB_DRV_NAME); 1112 - } 1113 - 1114 1094 /* 1115 1095 * Change the port configuration of the device. 1116 1096 * Every user of this function must hold the port mutex. ··· 1125 1147 mlx4_err(dev, "Failed to register device\n"); 1126 1148 goto out; 1127 1149 } 1128 - mlx4_request_modules(dev); 1129 1150 } 1130 1151 1131 1152 out: ··· 3403 3426 devl_assert_locked(devlink); 3404 3427 dev = &priv->dev; 3405 3428 3406 - INIT_LIST_HEAD(&priv->ctx_list); 3407 - spin_lock_init(&priv->ctx_lock); 3408 - 3409 3429 err = mlx4_adev_init(dev); 3410 3430 if (err) 3411 3431 return err; ··· 3705 3731 err = mlx4_register_device(dev); 3706 3732 if (err) 3707 3733 goto err_port; 3708 - 3709 - mlx4_request_modules(dev); 3710 3734 3711 3735 mlx4_sense_init(dev); 3712 3736 mlx4_start_sense(dev);
-3
drivers/net/ethernet/mellanox/mlx4/mlx4.h
··· 882 882 struct mlx4_priv { 883 883 struct mlx4_dev dev; 884 884 885 - struct list_head dev_list; 886 - struct list_head ctx_list; 887 - spinlock_t ctx_lock; 888 885 struct mlx4_adev **adev; 889 886 int adev_idx; 890 887 struct atomic_notifier_head event_nh;
-10
include/linux/mlx4/driver.h
··· 58 58 MLX4_INTFF_BONDING = 1 << 0 59 59 }; 60 60 61 - struct mlx4_interface { 62 - void * (*add) (struct mlx4_dev *dev); 63 - void (*remove)(struct mlx4_dev *dev, void *context); 64 - struct list_head list; 65 - enum mlx4_protocol protocol; 66 - int flags; 67 - }; 68 - 69 61 struct mlx4_adrv { 70 62 struct auxiliary_driver adrv; 71 63 enum mlx4_protocol protocol; 72 64 int flags; 73 65 }; 74 66 75 - int mlx4_register_interface(struct mlx4_interface *intf); 76 - void mlx4_unregister_interface(struct mlx4_interface *intf); 77 67 int mlx4_register_auxiliary_driver(struct mlx4_adrv *madrv); 78 68 void mlx4_unregister_auxiliary_driver(struct mlx4_adrv *madrv); 79 69