DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/nfp: cancel delayed LSC work in port close logic
@ 2021-10-06  6:44 heinrich.kuhn
  2021-10-07 10:20 ` Ferruh Yigit
  0 siblings, 1 reply; 2+ messages in thread
From: heinrich.kuhn @ 2021-10-06  6:44 UTC (permalink / raw)
  To: dev; +Cc: Heinrich Kuhn, stable, Simon Horman

From: Heinrich Kuhn <heinrich.kuhn@corigine.com>

The link state change interrupt handler of the NFP PMD will delay the
actual LSC work for a short period to ensure the link is stable. If the
link of the port changes state and the port is closed immediately after
the link event then a segmentation fault will occur. This happens
because the delayed LSC work eventually triggers and this logic will try
to access private port data that had been released when the port was
closed.

Fixes: 6c53f87b3497 ("nfp: add link status interrupt")
Cc: stable@dpdk.org

Signed-off-by: Heinrich Kuhn <heinrich.kuhn@corigine.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
---
 drivers/net/nfp/nfp_common.c    | 2 +-
 drivers/net/nfp/nfp_common.h    | 1 +
 drivers/net/nfp/nfp_ethdev.c    | 5 +++++
 drivers/net/nfp/nfp_ethdev_vf.c | 6 ++++++
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/nfp/nfp_common.c b/drivers/net/nfp/nfp_common.c
index 1b4bc33593..4395a09c59 100644
--- a/drivers/net/nfp/nfp_common.c
+++ b/drivers/net/nfp/nfp_common.c
@@ -898,7 +898,7 @@ nfp_net_irq_unmask(struct rte_eth_dev *dev)
  *
  * @return  void
  */
-static void
+void
 nfp_net_dev_interrupt_delayed_handler(void *param)
 {
 	struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
diff --git a/drivers/net/nfp/nfp_common.h b/drivers/net/nfp/nfp_common.h
index 1fbf3d7cd6..3556c9cd17 100644
--- a/drivers/net/nfp/nfp_common.h
+++ b/drivers/net/nfp/nfp_common.h
@@ -376,6 +376,7 @@ void nfp_net_params_setup(struct nfp_net_hw *hw);
 void nfp_net_cfg_queue_setup(struct nfp_net_hw *hw);
 void nfp_eth_copy_mac(uint8_t *dst, const uint8_t *src);
 void nfp_net_dev_interrupt_handler(void *param);
+void nfp_net_dev_interrupt_delayed_handler(void *param);
 int nfp_net_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 int nfp_net_vlan_offload_set(struct rte_eth_dev *dev, int mask);
 int nfp_net_reta_update(struct rte_eth_dev *dev,
diff --git a/drivers/net/nfp/nfp_ethdev.c b/drivers/net/nfp/nfp_ethdev.c
index 6ba3c27f7f..1169ea77a8 100644
--- a/drivers/net/nfp/nfp_ethdev.c
+++ b/drivers/net/nfp/nfp_ethdev.c
@@ -22,6 +22,7 @@
 #include <rte_memzone.h>
 #include <rte_mempool.h>
 #include <rte_service_component.h>
+#include <rte_alarm.h>
 #include "eal_firmware.h"
 
 #include "nfpcore/nfp_cpp.h"
@@ -307,6 +308,10 @@ nfp_net_close(struct rte_eth_dev *dev)
 		nfp_net_reset_rx_queue(this_rx_q);
 	}
 
+	/* Cancel possible impending LSC work here before releasing the port*/
+	rte_eal_alarm_cancel(nfp_net_dev_interrupt_delayed_handler,
+			     (void *)dev);
+
 	/* Only free PF resources after all physical ports have been closed */
 	/* Mark this port as unused and free device priv resources*/
 	nn_cfg_writeb(hw, NFP_NET_CFG_LSC, 0xff);
diff --git a/drivers/net/nfp/nfp_ethdev_vf.c b/drivers/net/nfp/nfp_ethdev_vf.c
index b697b55865..62cb3536e0 100644
--- a/drivers/net/nfp/nfp_ethdev_vf.c
+++ b/drivers/net/nfp/nfp_ethdev_vf.c
@@ -13,6 +13,8 @@
  * Netronome vNIC  VF DPDK Poll-Mode Driver: Main entry point
  */
 
+#include <rte_alarm.h>
+
 #include "nfpcore/nfp_mip.h"
 #include "nfpcore/nfp_rtsym.h"
 
@@ -230,6 +232,10 @@ nfp_netvf_close(struct rte_eth_dev *dev)
 				     nfp_net_dev_interrupt_handler,
 				     (void *)dev);
 
+	/* Cancel possible impending LSC work here before releasing the port*/
+	rte_eal_alarm_cancel(nfp_net_dev_interrupt_delayed_handler,
+			     (void *)dev);
+
 	/*
 	 * The ixgbe PMD driver disables the pcie master on the
 	 * device. The i40e does not...
-- 
2.30.1 (Apple Git-130)


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] net/nfp: cancel delayed LSC work in port close logic
  2021-10-06  6:44 [dpdk-dev] [PATCH] net/nfp: cancel delayed LSC work in port close logic heinrich.kuhn
@ 2021-10-07 10:20 ` Ferruh Yigit
  0 siblings, 0 replies; 2+ messages in thread
From: Ferruh Yigit @ 2021-10-07 10:20 UTC (permalink / raw)
  To: heinrich.kuhn, dev; +Cc: stable, Simon Horman

On 10/6/2021 7:44 AM, heinrich.kuhn@corigine.com wrote:
> From: Heinrich Kuhn <heinrich.kuhn@corigine.com>
> 
> The link state change interrupt handler of the NFP PMD will delay the
> actual LSC work for a short period to ensure the link is stable. If the
> link of the port changes state and the port is closed immediately after
> the link event then a segmentation fault will occur. This happens
> because the delayed LSC work eventually triggers and this logic will try
> to access private port data that had been released when the port was
> closed.
> 
> Fixes: 6c53f87b3497 ("nfp: add link status interrupt")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Heinrich Kuhn <heinrich.kuhn@corigine.com>
> Signed-off-by: Simon Horman <simon.horman@corigine.com>

Applied to dpdk-next-net/main, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-07 10:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-06  6:44 [dpdk-dev] [PATCH] net/nfp: cancel delayed LSC work in port close logic heinrich.kuhn
2021-10-07 10:20 ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).