All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/4] bnxt: Fix a segfault encountered during KNI exit
@ 2016-09-29 17:03 Ajit Khaparde
  2016-09-29 17:41 ` Ferruh Yigit
  0 siblings, 1 reply; 5+ messages in thread
From: Ajit Khaparde @ 2016-09-29 17:03 UTC (permalink / raw)
  To: dev

The bnxt PMD is running into a segfault when exiting out of KNI
in the dev_uninit/close path. This patch fixes that.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt.h        |  1 +
 drivers/net/bnxt/bnxt_ethdev.c | 34 ++++++++++++++++++++++------------
 2 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index c77ecef..07b4cf2 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -175,6 +175,7 @@ struct bnxt {
 	struct bnxt_pf_info		pf;
 	struct bnxt_vf_info		vf;
 	uint8_t			port_partition_type;
+	uint8_t			dev_stopped;
 };
 
 #endif
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index bd1ffc0..1e3519b 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -428,6 +428,7 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev)
 	struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
 	int rc;
 
+	bp->dev_stopped = 0;
 	rc = bnxt_hwrm_func_reset(bp);
 	if (rc) {
 		RTE_LOG(ERR, PMD, "hwrm chip reset failure rc: %x\n", rc);
@@ -471,10 +472,27 @@ static int bnxt_dev_set_link_down_op(struct rte_eth_dev *eth_dev)
 	return 0;
 }
 
+/* Unload the driver, release resources */
+static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
+{
+	struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
+
+	if (bp->eth_dev->data->dev_started) {
+		/* TBD: STOP HW queues DMA */
+		eth_dev->data->dev_link.link_status = 0;
+	}
+	bnxt_set_hwrm_link_config(bp, false);
+	bnxt_shutdown_nic(bp);
+	bp->dev_stopped = 1;
+}
+
 static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
 {
 	struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
 
+	if (bp->dev_stopped == 0)
+		bnxt_dev_stop_op(eth_dev);
+
 	bnxt_free_tx_mbufs(bp);
 	bnxt_free_rx_mbufs(bp);
 	bnxt_free_mem(bp);
@@ -488,18 +506,6 @@ static void bnxt_dev_close_op(struct rte_eth_dev *eth_dev)
 	}
 }
 
-/* Unload the driver, release resources */
-static void bnxt_dev_stop_op(struct rte_eth_dev *eth_dev)
-{
-	struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private;
-
-	if (bp->eth_dev->data->dev_started) {
-		/* TBD: STOP HW queues DMA */
-		eth_dev->data->dev_link.link_status = 0;
-	}
-	bnxt_shutdown_nic(bp);
-}
-
 static void bnxt_mac_addr_remove_op(struct rte_eth_dev *eth_dev,
 				    uint32_t index)
 {
@@ -1078,6 +1084,8 @@ bnxt_dev_init(struct rte_eth_dev *eth_dev)
 		eth_dev->pci_dev->mem_resource[0].phys_addr,
 		eth_dev->pci_dev->mem_resource[0].addr);
 
+	bp->dev_stopped = 0;
+
 	return 0;
 
 error_free:
@@ -1101,6 +1109,8 @@ bnxt_dev_uninit(struct rte_eth_dev *eth_dev) {
 	}
 	rc = bnxt_hwrm_func_driver_unregister(bp, 0);
 	bnxt_free_hwrm_resources(bp);
+	if (bp->dev_stopped == 0)
+		bnxt_dev_close_op(eth_dev);
 	eth_dev->dev_ops = NULL;
 	eth_dev->rx_pkt_burst = NULL;
 	eth_dev->tx_pkt_burst = NULL;
-- 
2.4.3

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

* Re: [PATCH 2/4] bnxt: Fix a segfault encountered during KNI exit
  2016-09-29 17:03 [PATCH 2/4] bnxt: Fix a segfault encountered during KNI exit Ajit Khaparde
@ 2016-09-29 17:41 ` Ferruh Yigit
  2016-09-29 19:06   ` Ajit Khaparde
  0 siblings, 1 reply; 5+ messages in thread
From: Ferruh Yigit @ 2016-09-29 17:41 UTC (permalink / raw)
  To: Ajit Khaparde, dev

On 9/29/2016 6:03 PM, Ajit Khaparde wrote:
> The bnxt PMD is running into a segfault when exiting out of KNI

KNI?

> in the dev_uninit/close path. This patch fixes that.
> 
> Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
...

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

* Re: [PATCH 2/4] bnxt: Fix a segfault encountered during KNI exit
  2016-09-29 17:41 ` Ferruh Yigit
@ 2016-09-29 19:06   ` Ajit Khaparde
  2016-10-10 15:24     ` Ferruh Yigit
  0 siblings, 1 reply; 5+ messages in thread
From: Ajit Khaparde @ 2016-09-29 19:06 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev

On Thu, Sep 29, 2016 at 12:41 PM, Ferruh Yigit <ferruh.yigit@intel.com>
wrote:

> On 9/29/2016 6:03 PM, Ajit Khaparde wrote:
> > The bnxt PMD is running into a segfault when exiting out of KNI
>
> KNI?
>
examples/kni

​On closing the kni app, I am seeing a segfault.​ because of improper
cleanup of resources
in the dev_uninit path.

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

* Re: [PATCH 2/4] bnxt: Fix a segfault encountered during KNI exit
  2016-09-29 19:06   ` Ajit Khaparde
@ 2016-10-10 15:24     ` Ferruh Yigit
  2016-10-10 18:41       ` Ajit Khaparde
  0 siblings, 1 reply; 5+ messages in thread
From: Ferruh Yigit @ 2016-10-10 15:24 UTC (permalink / raw)
  To: Ajit Khaparde; +Cc: dev

On 9/29/2016 8:06 PM, Ajit Khaparde wrote:
> On Thu, Sep 29, 2016 at 12:41 PM, Ferruh Yigit <ferruh.yigit@intel.com
> <mailto:ferruh.yigit@intel.com>>wrote:
> 
>     On 9/29/2016 6:03 PM, Ajit Khaparde wrote:
>     > The bnxt PMD is running into a segfault when exiting out of KNI
> 
>     KNI?
> 
> examples/kni
> 
> ​On closing the kni app, I am seeing a segfault.​ because of improper
> cleanup of resources
> in the dev_uninit path.

So this is mainly related to driver exit, KNI app is just a way to
reproduce it.

Are you OK with following update in commit log:

"
net/bnxt: fix a segfault encountered during PMD exit

This patch fixes segfault encountered during dev_uninit/close routine.
KNI sample app can be used to reproduce the issue.
"

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

* Re: [PATCH 2/4] bnxt: Fix a segfault encountered during KNI exit
  2016-10-10 15:24     ` Ferruh Yigit
@ 2016-10-10 18:41       ` Ajit Khaparde
  0 siblings, 0 replies; 5+ messages in thread
From: Ajit Khaparde @ 2016-10-10 18:41 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev

On Mon, Oct 10, 2016 at 10:24 AM, Ferruh Yigit <ferruh.yigit@intel.com>
wrote:

> On 9/29/2016 8:06 PM, Ajit Khaparde wrote:
> > On Thu, Sep 29, 2016 at 12:41 PM, Ferruh Yigit <ferruh.yigit@intel.com
> > <mailto:ferruh.yigit@intel.com>>wrote:
> >
> >     On 9/29/2016 6:03 PM, Ajit Khaparde wrote:
> >     > The bnxt PMD is running into a segfault when exiting out of KNI
> >
> >     KNI?
> >
> > examples/kni
> >
> > ​On closing the kni app, I am seeing a segfault.​ because of improper
> > cleanup of resources
> > in the dev_uninit path.
>
> So this is mainly related to driver exit, KNI app is just a way to
> reproduce it.
>
> Are you OK with following update in commit log:
>
> "
> net/bnxt: fix a segfault encountered during PMD exit
>
> This patch fixes segfault encountered during dev_uninit/close routine.
> KNI sample app can be used to reproduce the issue.
> "
>
​I am OK with this Ferruh.

Thanks​

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

end of thread, other threads:[~2016-10-10 18:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-29 17:03 [PATCH 2/4] bnxt: Fix a segfault encountered during KNI exit Ajit Khaparde
2016-09-29 17:41 ` Ferruh Yigit
2016-09-29 19:06   ` Ajit Khaparde
2016-10-10 15:24     ` Ferruh Yigit
2016-10-10 18:41       ` Ajit Khaparde

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.