[2/3] eal: fix remove incorrect event_cb
diff mbox series

Message ID a2a8a6832e6621e578c6f779221d00cbd620b3b6.1591186247.git.wangyunjian@huawei.com
State New
Delegated to: David Marchand
Headers show
Series
  • fixes for device event
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

wangyunjian June 3, 2020, 12:55 p.m. UTC
From: Yunjian Wang <wangyunjian@huawei.com>

When the device_name is NULL, it will remove the event_cb directly.
We need to compare the 'cb_fn' and 'cb_arg' at the same time.

Fixes: a753e53d517b ("eal: add device event monitor framework")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 lib/librte_eal/common/eal_common_dev.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Jeff Guo June 12, 2020, 5:56 a.m. UTC | #1
hi, yunjian

On 6/3/2020 8:55 PM, wangyunjian wrote:
> From: Yunjian Wang <wangyunjian@huawei.com>
>
> When the device_name is NULL, it will remove the event_cb directly.
> We need to compare the 'cb_fn' and 'cb_arg' at the same time.
>
> Fixes: a753e53d517b ("eal: add device event monitor framework")
> Cc: stable@dpdk.org
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>   lib/librte_eal/common/eal_common_dev.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
> index 4cfdb80..6b465bc 100644
> --- a/lib/librte_eal/common/eal_common_dev.c
> +++ b/lib/librte_eal/common/eal_common_dev.c
> @@ -516,7 +516,12 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name)
>   				    event_cb->cb_arg != cb_arg))
>   					continue;
>   			}
> -		} else if (device_name != NULL) {
> +		} else if (device_name == NULL && event_cb->dev_name == NULL) {
> +			if (event_cb->cb_fn != cb_fn ||
> +			    (cb_arg != (void *)-1 &&
> +			    event_cb->cb_arg != cb_arg))
> +				continue;
> +		} else {


If we expect flush all event_cb when device_name is NULL, why we should 
check the cb_fn and cb_arg?


>   			continue;
>   		}
>
wangyunjian June 30, 2020, 11:29 a.m. UTC | #2
> -----Original Message-----
> From: Jeff Guo [mailto:jia.guo@intel.com]
> Sent: Friday, June 12, 2020 1:56 PM
> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> Cc: Lilijun (Jerry) <jerry.lilijun@huawei.com>; xudingke
> <xudingke@huawei.com>; stable@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH 2/3] eal: fix remove incorrect event_cb
> 
> hi, yunjian
> 
> On 6/3/2020 8:55 PM, wangyunjian wrote:
> > From: Yunjian Wang <wangyunjian@huawei.com>
> >
> > When the device_name is NULL, it will remove the event_cb directly.
> > We need to compare the 'cb_fn' and 'cb_arg' at the same time.
> >
> > Fixes: a753e53d517b ("eal: add device event monitor framework")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > ---
> >   lib/librte_eal/common/eal_common_dev.c | 7 ++++++-
> >   1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/librte_eal/common/eal_common_dev.c
> > b/lib/librte_eal/common/eal_common_dev.c
> > index 4cfdb80..6b465bc 100644
> > --- a/lib/librte_eal/common/eal_common_dev.c
> > +++ b/lib/librte_eal/common/eal_common_dev.c
> > @@ -516,7 +516,12 @@ static int cmp_dev_name(const struct rte_device
> *dev, const void *_name)
> >   				    event_cb->cb_arg != cb_arg))
> >   					continue;
> >   			}
> > -		} else if (device_name != NULL) {
> > +		} else if (device_name == NULL && event_cb->dev_name == NULL) {
> > +			if (event_cb->cb_fn != cb_fn ||
> > +			    (cb_arg != (void *)-1 &&
> > +			    event_cb->cb_arg != cb_arg))
> > +				continue;
> > +		} else {
> 
> 
> If we expect flush all event_cb when device_name is NULL, why we should
> check the cb_fn and cb_arg?

Oh, sorry! My mistake, I am wrong to think that this function is used like
rte_intr_callback_register()/rte_intr_callback_unregister().

Please discard it.

Thanks,
Yunjian
> 
> 
> >   			continue;
> >   		}
> >

Patch
diff mbox series

diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index 4cfdb80..6b465bc 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -516,7 +516,12 @@  static int cmp_dev_name(const struct rte_device *dev, const void *_name)
 				    event_cb->cb_arg != cb_arg))
 					continue;
 			}
-		} else if (device_name != NULL) {
+		} else if (device_name == NULL && event_cb->dev_name == NULL) {
+			if (event_cb->cb_fn != cb_fn ||
+			    (cb_arg != (void *)-1 &&
+			    event_cb->cb_arg != cb_arg))
+				continue;
+		} else {
 			continue;
 		}