From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from huawei.com (szxga02-in.huawei.com [45.249.212.188]) by dpdk.org (Postfix) with ESMTP id 7AEAA4C6C; Fri, 10 May 2019 13:37:42 +0200 (CEST) Received: from DGGEMM403-HUB.china.huawei.com (unknown [172.30.72.55]) by Forcepoint Email with ESMTP id 6E109FC0FDB00B6E0884; Fri, 10 May 2019 19:37:40 +0800 (CST) Received: from DGGEMM533-MBX.china.huawei.com ([169.254.5.117]) by DGGEMM403-HUB.china.huawei.com ([10.3.20.211]) with mapi id 14.03.0415.000; Fri, 10 May 2019 19:37:32 +0800 From: wangyunjian To: "Zhao1, Wei" , "dev@dpdk.org" CC: "i.maximets@samsung.com" , xudingke , "stable@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] net/ixgbe: fix cancel link handler when port is being removed Thread-Index: AQHVBt6BPglikvqlH0CrlaGqW0YVf6ZkNZiQ Date: Fri, 10 May 2019 11:37:32 +0000 Message-ID: <34EFBCA9F01B0748BEB6B629CE643AE60CAE5747@DGGEMM533-MBX.china.huawei.com> References: <1557319898-9588-1-git-send-email-wangyunjian@huawei.com> In-Reply-To: Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.177.24.66] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH] net/ixgbe: fix cancel link handler when port is being removed X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 May 2019 11:37:44 -0000 > -----Original Message----- > From: Zhao1, Wei [mailto:wei.zhao1@intel.com] > Sent: Friday, May 10, 2019 11:14 AM > To: wangyunjian ; dev@dpdk.org > Cc: i.maximets@samsung.com; xudingke ; > stable@dpdk.org > Subject: RE: [dpdk-dev] [PATCH] net/ixgbe: fix cancel link handler when p= ort > is being removed >=20 > Hi, wangyunjian >=20 > May I ask some more info about it? > Sure, we may this handler in ixgbe_dev_link_update_share (), but we have > "rte_eal_alarm_cancel(ixgbe_dev_setup_link_alarm_handler, dev)" > in function ixgbe_dev_stop() and ixgbevf_dev_stop() to cancel this handl= er. > If you want to remove dev, you will call ixgbe_dev_stop() first, RIGHT? > Maybe there is an accidental situation that some interrupt like LSC trigg= er > ixgbe_dev_link_update() to set setup_link_alarm_handler just after dev st= op? > Then we need to cancel it in eth_ixgbe_dev_uninit(). > Is you issue the same as above or other? Yes, it is as above. It is easy to reproduce through fault injection. As f= ollow: diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_eth= dev.c index 975fa47..a1e93c0 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -4055,7 +4055,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused = struct rte_eth_dev *dev, if (link_up =3D=3D 0) { if (ixgbe_get_media_type(hw) =3D=3D ixgbe_media_type_fiber)= { intr->flags |=3D IXGBE_FLAG_NEED_LINK_CONFIG; - rte_eal_alarm_set(10, + rte_eal_alarm_set(500 * 1000, ixgbe_dev_setup_link_alarm_handler, dev); } return rte_eth_linkstatus_set(dev, &link); >=20 >=20 > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of wangyunjian > > Sent: Wednesday, May 8, 2019 8:52 PM > > To: dev@dpdk.org > > Cc: i.maximets@samsung.com; xudingke@huawei.com; Yunjian Wang > > ; stable@dpdk.org > > Subject: [dpdk-dev] [PATCH] net/ixgbe: fix cancel link handler when > > port is being removed > > > > From: Yunjian Wang > > > > The nic's interrupt source has some active handler, which maybe call > > ixgbe_dev_link_update() to set link handler. We should cancel the link > > handler before remove dev to prevent executing the link handler. > > It triggers segfault. > > > > Fixes: 0408f47ba4d6 ("net/ixgbe: fix busy polling while fiber link > > update") > > Cc: stable@dpdk.org > > > > Signed-off-by: Yunjian Wang > > --- > > drivers/net/ixgbe/ixgbe_ethdev.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c > > b/drivers/net/ixgbe/ixgbe_ethdev.c > > index 975fa47..2470c89 100644 > > --- a/drivers/net/ixgbe/ixgbe_ethdev.c > > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c > > @@ -1344,6 +1344,9 @@ struct rte_ixgbe_xstats_name_off { > > /* cancel the delay handler before remove dev */ > > rte_eal_alarm_cancel(ixgbe_dev_interrupt_delayed_handler, > eth_dev); > > > > + /* cancel the link handler before remove dev */ > > + rte_eal_alarm_cancel(ixgbe_dev_setup_link_alarm_handler, > eth_dev); > > + > > /* uninitialize PF if max_vfs not zero */ > > ixgbe_pf_host_uninit(eth_dev); > > > > -- > > 1.8.3.1 > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 93359A0096 for ; Fri, 10 May 2019 13:37:47 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5E8E156A1; Fri, 10 May 2019 13:37:45 +0200 (CEST) Received: from huawei.com (szxga02-in.huawei.com [45.249.212.188]) by dpdk.org (Postfix) with ESMTP id 7AEAA4C6C; Fri, 10 May 2019 13:37:42 +0200 (CEST) Received: from DGGEMM403-HUB.china.huawei.com (unknown [172.30.72.55]) by Forcepoint Email with ESMTP id 6E109FC0FDB00B6E0884; Fri, 10 May 2019 19:37:40 +0800 (CST) Received: from DGGEMM533-MBX.china.huawei.com ([169.254.5.117]) by DGGEMM403-HUB.china.huawei.com ([10.3.20.211]) with mapi id 14.03.0415.000; Fri, 10 May 2019 19:37:32 +0800 From: wangyunjian To: "Zhao1, Wei" , "dev@dpdk.org" CC: "i.maximets@samsung.com" , xudingke , "stable@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] net/ixgbe: fix cancel link handler when port is being removed Thread-Index: AQHVBt6BPglikvqlH0CrlaGqW0YVf6ZkNZiQ Date: Fri, 10 May 2019 11:37:32 +0000 Message-ID: <34EFBCA9F01B0748BEB6B629CE643AE60CAE5747@DGGEMM533-MBX.china.huawei.com> References: <1557319898-9588-1-git-send-email-wangyunjian@huawei.com> In-Reply-To: Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.177.24.66] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected Subject: Re: [dpdk-dev] [PATCH] net/ixgbe: fix cancel link handler when port is being removed X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190510113732.R8izUrRCaE7iRx7D59Z23Qt5qP2WGm7kdTRpamF8-UU@z> > -----Original Message----- > From: Zhao1, Wei [mailto:wei.zhao1@intel.com] > Sent: Friday, May 10, 2019 11:14 AM > To: wangyunjian ; dev@dpdk.org > Cc: i.maximets@samsung.com; xudingke ; > stable@dpdk.org > Subject: RE: [dpdk-dev] [PATCH] net/ixgbe: fix cancel link handler when p= ort > is being removed >=20 > Hi, wangyunjian >=20 > May I ask some more info about it? > Sure, we may this handler in ixgbe_dev_link_update_share (), but we have > "rte_eal_alarm_cancel(ixgbe_dev_setup_link_alarm_handler, dev)" > in function ixgbe_dev_stop() and ixgbevf_dev_stop() to cancel this handl= er. > If you want to remove dev, you will call ixgbe_dev_stop() first, RIGHT? > Maybe there is an accidental situation that some interrupt like LSC trigg= er > ixgbe_dev_link_update() to set setup_link_alarm_handler just after dev st= op? > Then we need to cancel it in eth_ixgbe_dev_uninit(). > Is you issue the same as above or other? Yes, it is as above. It is easy to reproduce through fault injection. As f= ollow: diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_eth= dev.c index 975fa47..a1e93c0 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -4055,7 +4055,7 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused = struct rte_eth_dev *dev, if (link_up =3D=3D 0) { if (ixgbe_get_media_type(hw) =3D=3D ixgbe_media_type_fiber)= { intr->flags |=3D IXGBE_FLAG_NEED_LINK_CONFIG; - rte_eal_alarm_set(10, + rte_eal_alarm_set(500 * 1000, ixgbe_dev_setup_link_alarm_handler, dev); } return rte_eth_linkstatus_set(dev, &link); >=20 >=20 > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of wangyunjian > > Sent: Wednesday, May 8, 2019 8:52 PM > > To: dev@dpdk.org > > Cc: i.maximets@samsung.com; xudingke@huawei.com; Yunjian Wang > > ; stable@dpdk.org > > Subject: [dpdk-dev] [PATCH] net/ixgbe: fix cancel link handler when > > port is being removed > > > > From: Yunjian Wang > > > > The nic's interrupt source has some active handler, which maybe call > > ixgbe_dev_link_update() to set link handler. We should cancel the link > > handler before remove dev to prevent executing the link handler. > > It triggers segfault. > > > > Fixes: 0408f47ba4d6 ("net/ixgbe: fix busy polling while fiber link > > update") > > Cc: stable@dpdk.org > > > > Signed-off-by: Yunjian Wang > > --- > > drivers/net/ixgbe/ixgbe_ethdev.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c > > b/drivers/net/ixgbe/ixgbe_ethdev.c > > index 975fa47..2470c89 100644 > > --- a/drivers/net/ixgbe/ixgbe_ethdev.c > > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c > > @@ -1344,6 +1344,9 @@ struct rte_ixgbe_xstats_name_off { > > /* cancel the delay handler before remove dev */ > > rte_eal_alarm_cancel(ixgbe_dev_interrupt_delayed_handler, > eth_dev); > > > > + /* cancel the link handler before remove dev */ > > + rte_eal_alarm_cancel(ixgbe_dev_setup_link_alarm_handler, > eth_dev); > > + > > /* uninitialize PF if max_vfs not zero */ > > ixgbe_pf_host_uninit(eth_dev); > > > > -- > > 1.8.3.1 > >