mlx5: Fix driver version location

Driver description should be set by core and not by the Ethernet driver.

Approved by:    hselasky (mentor)
MFC after:      1 week
Sponsored by:   Mellanox Technologies
This commit is contained in:
Slava Shwartsman 2018-12-05 13:47:10 +00:00
parent 721a1a6a69
commit 31c3f64819
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=341567
4 changed files with 25 additions and 15 deletions

View File

@ -199,6 +199,7 @@ linux_pci_detach(device_t dev)
spin_lock(&pci_lock);
list_del(&pdev->links);
spin_unlock(&pci_lock);
device_set_desc(dev, NULL);
put_device(&pdev->dev);
return (0);

View File

@ -44,6 +44,8 @@
#include "mlx5_core.h"
#include "fs_core.h"
static const char mlx5_version[] = "Mellanox Core driver "
DRIVER_VERSION " (" DRIVER_RELDATE ")";
MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>");
MODULE_DESCRIPTION("Mellanox Connect-IB, ConnectX-4 core driver");
MODULE_LICENSE("Dual BSD/GPL");
@ -1220,6 +1222,9 @@ static int init_one(struct pci_dev *pdev,
dev->pdev = pdev;
dev->event = mlx5_core_event;
/* Set desc */
device_set_desc(bsddev, mlx5_version);
sysctl_ctx_init(&dev->sysctl_ctx);
SYSCTL_ADD_INT(&dev->sysctl_ctx,
SYSCTL_CHILDREN(device_get_sysctl_tree(bsddev)),

View File

@ -34,8 +34,8 @@
#define ETH_DRIVER_VERSION "3.4.2"
#endif
char mlx5e_version[] = "Mellanox Ethernet driver"
" (" ETH_DRIVER_VERSION ")";
static const char mlx5e_version[] = "mlx5en: Mellanox Ethernet driver "
ETH_DRIVER_VERSION " (" DRIVER_RELDATE ")\n";
static int mlx5e_get_wqe_sz(struct mlx5e_priv *priv, u32 *wqe_sz, u32 *nsegs);
@ -3687,9 +3687,6 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
/* set default MTU */
mlx5e_set_dev_port_mtu(ifp, ifp->if_mtu);
/* Set desc */
device_set_desc(mdev->pdev->dev.bsddev, mlx5e_version);
/* Set default media status */
priv->media_status_last = IFM_AVALID;
priv->media_active_last = IFM_ETHER | IFM_AUTO |
@ -3805,13 +3802,6 @@ mlx5e_destroy_ifp(struct mlx5_core_dev *mdev, void *vpriv)
/* don't allow more IOCTLs */
priv->gone = 1;
/*
* Clear the device description to avoid use after free,
* because the bsddev is not destroyed when this module is
* unloaded:
*/
device_set_desc(mdev->pdev->dev.bsddev, NULL);
/* XXX wait a bit to allow IOCTL handlers to complete */
pause("W", hz);
@ -3897,6 +3887,14 @@ mlx5e_cleanup(void)
mlx5_unregister_interface(&mlx5e_interface);
}
static void
mlx5e_show_version(void __unused *arg)
{
printf("%s", mlx5e_version);
}
SYSINIT(mlx5e_show_version, SI_SUB_DRIVERS, SI_ORDER_ANY, mlx5e_show_version, NULL);
module_init_order(mlx5e_init, SI_ORDER_THIRD);
module_exit_order(mlx5e_cleanup, SI_ORDER_THIRD);

View File

@ -50,7 +50,7 @@
#include <dev/mlx5/fs.h>
#include "mlx5_ib.h"
#define DRIVER_NAME "mlx5_ib"
#define DRIVER_NAME "mlx5ib"
#ifndef DRIVER_VERSION
#define DRIVER_VERSION "3.4.2"
#endif
@ -2963,8 +2963,6 @@ static void *mlx5_ib_add(struct mlx5_core_dev *mdev)
if ((ll == IB_LINK_LAYER_ETHERNET) && !MLX5_CAP_GEN(mdev, roce))
return NULL;
printk_once(KERN_INFO "%s", mlx5_version);
dev = (struct mlx5_ib_dev *)ib_alloc_device(sizeof(*dev));
if (!dev)
return NULL;
@ -3259,5 +3257,13 @@ static void __exit mlx5_ib_cleanup(void)
mlx5_ib_odp_cleanup();
}
static void
mlx5_ib_show_version(void __unused *arg)
{
printf("%s", mlx5_version);
}
SYSINIT(mlx5_ib_show_version, SI_SUB_DRIVERS, SI_ORDER_ANY, mlx5_ib_show_version, NULL);
module_init_order(mlx5_ib_init, SI_ORDER_THIRD);
module_exit_order(mlx5_ib_cleanup, SI_ORDER_THIRD);