Mellanox, mlx5 fixes 2019-02-13
Subsystems (5)
Hi Dave,
This series introduces some fixes to mlx5 driver.
For more information please see tag log below.
Please pull and let me know if there is any problem.
For -stable v4.19:
('net/mlx5e: XDP, fix redirect resources availability check')
Thanks,
Saeed.
---
The following changes since commit 2fdeee2549231b1f989f011bb18191f5660d3745:
team: avoid complex list operations in team_nl_cmd_options_set() (2019-02-12 14:19:27 -0500)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2019-02-13
for you to fetch changes up to 407e17b1a69a51ba9a512a04342da56c1f931df4:
net/mlx5e: XDP, fix redirect resources availability check (2019-02-13 15:40:51 -0800)
----------------------------------------------------------------
mlx5-fixes-2019-02-13
----------------------------------------------------------------
Huy Nguyen (1):
net/mlx5: No command allowed when command interface is not ready
Maria Pasechnik (1):
net/mlx5e: Fix NULL pointer derefernce in set channels error flow
Saeed Mahameed (1):
net/mlx5e: XDP, fix redirect resources availability check
Tariq Toukan (1):
net/mlx5: Fix a compilation warning in events.c
drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 18 ++++++++++++++++++ drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 6 ++---- drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h | 17 +++++++++++++++++ drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 7 ++++--- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 2 ++ drivers/net/ethernet/mellanox/mlx5/core/events.c | 17 +++++++++-------- drivers/net/ethernet/mellanox/mlx5/core/health.c | 2 +- drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h | 1 + 9 files changed, 55 insertions(+), 16 deletions(-)
PATCH 1/4 net/mlx5e: Fix NULL pointer derefernce in set channels error flow
From: Maria Pasechnik <[email protected]>
New channels are applied to the priv channels only after they are successfully opened. Then, the indirection table should be built according to the new number of channels.
Currently, such build is preformed independently of whether the channels opening is successful, and is not reverted on failure.
The bug is caused due to removal of rss params from channels struct and moving it to priv struct. That change cause to independency between channels and rss params.
This causes a crash on a later point, when accessing rqn of a non existing channel.
This patch fixes it by moving the indirection table build right before switching the priv channels to new channels struct, after the new set of channels was successfully opened.
--- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +4 -3
@@ -354,9 +354,6 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv, new_channels.params = priv->channels.params; new_channels.params.num_channels = count; -if (!netif_is_rxfh_configured (priv->netdev)) -mlx5e_build_default_indir_rqt (priv->rss_params.indirection_rqt, -MLX5E_INDIR_RQT_SIZE , count);if (!test_bit (MLX5E_STATE_OPENED , &priv->state)) { priv->channels.params = new_channels.params;
@@ -372,6 +369,10 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,if (arfs_enabled)mlx5e_arfs_disable (priv); +if (!netif_is_rxfh_configured (priv->netdev)) +mlx5e_build_default_indir_rqt (priv->rss_params.indirection_rqt, +MLX5E_INDIR_RQT_SIZE , count); +/* Switch to new channels, set new parameters and close old ones */ mlx5e_switch_priv_channels (priv, &new_channels,NULL );
Signature · 1 line
2.20.1
PATCH 2/4 net/mlx5: No command allowed when command interface is not ready
In reply to Saeed MahameedFrom: Huy Nguyen <[email protected]>
When EEH is injected and PCI bus stalls, mlx5's pci error detect function is called to deactivate the command interface and tear down the device. The issue is that there can be a thread that already passed MLX5_DEVICE_STATE_INTERNAL_ERROR check, it will send the command and stuck in the wait_func.
Solution:
Add function mlx5_cmd_flush to disable command interface and clear all the pending commands. When device state is set to MLX5_DEVICE_STATE_INTERNAL_ERROR, call mlx5_cmd_flush to ensure all pending threads waiting for firmware commands completion are terminated.
--- drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 18 ++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/health.c | 2 +- .../ethernet/mellanox/mlx5/core/mlx5_core.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +18 -0
@@ -1583,6 +1583,24 @@ void mlx5_cmd_trigger_completions(struct mlx5_core_dev *dev)spin_unlock_irqrestore (&dev->cmd.alloc_lock, flags); } +void mlx5_cmd_flush (struct mlx5_core_dev *dev) +{ +struct mlx5_cmd *cmd = &dev->cmd; +int i; + +for (i =0 ; i < cmd->max_reg_cmds; i++) +while (down_trylock (&cmd->sem)) +mlx5_cmd_trigger_completions (dev); + +while (down_trylock (&cmd->pages_sem)) +mlx5_cmd_trigger_completions (dev); + +/* Unlock cmdif */ +up (&cmd->pages_sem); +for (i =0 ; i < cmd->max_reg_cmds; i++) +up (&cmd->sem); +} +static int status_to_err (u8 status) {return status ?-1 :0 ;/* TBD more meaningful codes */
drivers/net/ethernet/mellanox/mlx5/core/health.c +1 -1
@@ -103,7 +103,7 @@ void mlx5_enter_error_state(struct mlx5_core_dev *dev, bool force)mlx5_core_err (dev,"start\n" );if (pci_channel_offline (dev->pdev) ||in_fatal (dev) || force) { dev->state =MLX5_DEVICE_STATE_INTERNAL_ERROR ; -mlx5_cmd_trigger_completions (dev); +mlx5_cmd_flush (dev); }mlx5_notifier_call_chain (dev->priv.events,MLX5_DEV_EVENT_SYS_ERROR , (void *)1 );
drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +1 -0
@@ -126,6 +126,7 @@ u64 mlx5_read_internal_timer(struct mlx5_core_dev *dev, struct ptp_system_timestamp *sts);void mlx5_cmd_trigger_completions (struct mlx5_core_dev *dev); +void mlx5_cmd_flush (struct mlx5_core_dev *dev);int mlx5_cq_debugfs_init (struct mlx5_core_dev *dev);void mlx5_cq_debugfs_cleanup (struct mlx5_core_dev *dev);
Signature · 1 line
2.20.1
PATCH 3/4 net/mlx5: Fix a compilation warning in events.c
In reply to Saeed MahameedFrom: Tariq Toukan <[email protected]>
Eliminate the following compilation warning:
drivers/net/ethernet/mellanox/mlx5/core/events.c: warning: 'error_str' may be used uninitialized in this function [-Wuninitialized]: => 238:3
--- .../net/ethernet/mellanox/mlx5/core/events.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/events.c +9 -8
@@ -211,11 +211,10 @@ static int port_module(struct notifier_block *nb, unsigned long type, void *dataenum port_module_event_status_type module_status;enum port_module_event_error_type error_type;struct mlx5_eqe_port_module *module_event_eqe; -const char *status_str, *error_str; +const char *status_str;u8 module_num; module_event_eqe = &eqe->data.port_module; - module_num = module_event_eqe->module; module_status = module_event_eqe->module_status &PORT_MODULE_EVENT_MODULE_STATUS_MASK ; error_type = module_event_eqe->error_type &
@@ -223,25 +222,27 @@ static int port_module(struct notifier_block *nb, unsigned long type, void *dataif (module_status <MLX5_MODULE_STATUS_NUM ) events->pme_stats.status_counters[module_status]++; - status_str =mlx5_pme_status_to_string (module_status); -if (module_status ==MLX5_MODULE_STATUS_ERROR ) { +if (module_status ==MLX5_MODULE_STATUS_ERROR )if (error_type <MLX5_MODULE_EVENT_ERROR_NUM ) events->pme_stats.error_counters[error_type]++; - error_str =mlx5_pme_error_to_string (error_type); - }if (!printk_ratelimit ())return NOTIFY_OK ; -if (module_status ==MLX5_MODULE_STATUS_ERROR ) + module_num = module_event_eqe->module; + status_str =mlx5_pme_status_to_string (module_status); +if (module_status ==MLX5_MODULE_STATUS_ERROR ) { +const char *error_str =mlx5_pme_error_to_string (error_type); +mlx5_core_err (events->dev,"Port module event[error]: module %u, %s, %s\n" , module_num, status_str, error_str); -else + }else {mlx5_core_info (events->dev,"Port module event: module %u, %s\n" , module_num, status_str); + }return NOTIFY_OK ; }
Signature · 1 line
2.20.1
PATCH 4/4 net/mlx5e: XDP, fix redirect resources availability check
In reply to Saeed MahameedCurrently mlx5 driver creates xdp redirect hw queues unconditionally on netdevice open, This is great until someone starts redirecting XDP traffic via ndo_xdp_xmit on mlx5 device and changes the device configuration at the same time, this might cause crashes, since the other device's napi is not aware of the mlx5 state change (resources un-availability).
To fix this we must synchronize with other devices napi's on the system. Added a new flag under mlx5e_priv to determine XDP TX resources are available, set/clear it up when necessary and use synchronize_rcu() when the flag is turned off, so other napi's are in-sync with it, before we actually cleanup the hw resources.
The flag is tested prior to committing to transmit on mlx5e_xdp_xmit, and it is sufficient to determine if it safe to transmit or not. The other two internal flags (MLX5E_STATE_OPENED and MLX5E_SQ_STATE_ENABLED) become unnecessary. Thus, they are removed from data path.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + .../net/ethernet/mellanox/mlx5/core/en/xdp.c | 6 ++---- .../net/ethernet/mellanox/mlx5/core/en/xdp.h | 17 +++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/en_main.c | 2 ++ 4 files changed, 22 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -0
@@ -657,6 +657,7 @@ struct mlx5e_channel_stats {enum {MLX5E_STATE_OPENED ,MLX5E_STATE_DESTROYING , +MLX5E_STATE_XDP_TX_ENABLED , };struct mlx5e_rqt {
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c +2 -4
@@ -365,7 +365,8 @@ int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,int sq_num;int i; -if (unlikely (!test_bit (MLX5E_STATE_OPENED , &priv->state))) +/* this flag is sufficient, no need to test internal sq state */ +if (unlikely (!mlx5e_xdp_tx_is_enabled (priv)))return -ENETDOWN ;if (unlikely (flags & ~XDP_XMIT_FLAGS_MASK ))
@@ -378,9 +379,6 @@ int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames, sq = &priv->channels.c[sq_num]->xdpsq; -if (unlikely (!test_bit (MLX5E_SQ_STATE_ENABLED , &sq->state))) -return -ENETDOWN ; -for (i =0 ; i < n; i++) {struct xdp_frame *xdpf = frames[i];struct mlx5e_xdp_info xdpi;
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h +17 -0
@@ -50,6 +50,23 @@ void mlx5e_xdp_rx_poll_complete(struct mlx5e_rq *rq);int mlx5e_xdp_xmit (struct net_device *dev,int n,struct xdp_frame **frames,u32 flags); +static inline void mlx5e_xdp_tx_enable (struct mlx5e_priv *priv) +{ +set_bit (MLX5E_STATE_XDP_TX_ENABLED , &priv->state); +} + +static inline void mlx5e_xdp_tx_disable (struct mlx5e_priv *priv) +{ +clear_bit (MLX5E_STATE_XDP_TX_ENABLED , &priv->state); +/* let other device's napi(s) see our new state */ +synchronize_rcu (); +} + +static inline bool mlx5e_xdp_tx_is_enabled (struct mlx5e_priv *priv) +{ +return test_bit (MLX5E_STATE_XDP_TX_ENABLED , &priv->state); +} +static inline void mlx5e_xmit_xdp_doorbell (struct mlx5e_xdpsq *sq) {if (sq->doorbell_cseg) {
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +2 -0
@@ -2938,6 +2938,7 @@ void mlx5e_activate_priv_channels(struct mlx5e_priv *priv)mlx5e_build_tx2sq_maps (priv);mlx5e_activate_channels (&priv->channels); +mlx5e_xdp_tx_enable (priv);netif_tx_start_all_queues (priv->netdev);if (mlx5e_is_vport_rep (priv))
@@ -2959,6 +2960,7 @@ void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv)*/ netif_tx_stop_all_queues (priv->netdev);netif_tx_disable (priv->netdev); +mlx5e_xdp_tx_disable (priv);mlx5e_deactivate_channels (&priv->channels); }
Signature · 1 line
2.20.1
From: Saeed Mahameed <[email protected]>
Date: Wed, 13 Feb 2019 15:44:47 -0800
Quoted 4 lines
This series introduces some fixes to mlx5 driver.
For more information please see tag log below.Please pull and let me know if there is any problem.
Pulled.
Quoted 2 lines
For -stable v4.19:
('net/mlx5e: XDP, fix redirect resources availability check')
Queued up for -stable, thanks Saeed.