common/octeontx2: retry intr callback unregister
diff mbox series

Message ID 20200611072605.472-1-ndabilpuram@marvell.com
State Accepted, archived
Delegated to: Jerin Jacob
Headers show
Series
  • common/octeontx2: retry intr callback unregister
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/checkpatch success coding style OK

Commit Message

Nithin Dabilpuram June 11, 2020, 7:26 a.m. UTC
Interrupt callback unregister can fail with -EAGAIN
when interrupt handler is active in interrupt thread.
Hence retry before reporting a failure or proceeding further.

Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
---
 drivers/common/octeontx2/otx2_irq.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

Comments

Jerin Jacob June 26, 2020, 3:16 p.m. UTC | #1
On Thu, Jun 11, 2020 at 1:06 PM Nithin Dabilpuram
<ndabilpuram@marvell.com> wrote:
>
> Interrupt callback unregister can fail with -EAGAIN
> when interrupt handler is active in interrupt thread.
> Hence retry before reporting a failure or proceeding further.
>
> Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>

Acked-by: Jerin Jacob <jerinj@marvell.com>

Delegating to Thomas as it belongs to common/octeontx2.



> ---
>  drivers/common/octeontx2/otx2_irq.c | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/common/octeontx2/otx2_irq.c b/drivers/common/octeontx2/otx2_irq.c
> index fa3206a..c0137ff 100644
> --- a/drivers/common/octeontx2/otx2_irq.c
> +++ b/drivers/common/octeontx2/otx2_irq.c
> @@ -193,6 +193,8 @@ otx2_unregister_irq(struct rte_intr_handle *intr_handle,
>                     rte_intr_callback_fn cb, void *data, unsigned int vec)
>  {
>         struct rte_intr_handle tmp_handle;
> +       uint8_t retries = 5; /* 5 ms */
> +       int rc;
>
>         if (vec > intr_handle->max_intr) {
>                 otx2_err("Error unregistering MSI-X interrupts vec:%d > %d",
> @@ -205,8 +207,21 @@ otx2_unregister_irq(struct rte_intr_handle *intr_handle,
>         if (tmp_handle.fd == -1)
>                 return;
>
> -       /* Un-register callback func from eal lib */
> -       rte_intr_callback_unregister(&tmp_handle, cb, data);
> +       do {
> +               /* Un-register callback func from eal lib */
> +               rc = rte_intr_callback_unregister(&tmp_handle, cb, data);
> +               /* Retry only if -EAGAIN */
> +               if (rc != -EAGAIN)
> +                       break;
> +               rte_delay_ms(1);
> +               retries--;
> +       } while (retries);
> +
> +       if (rc < 0) {
> +               otx2_err("Error unregistering MSI-X intr vec %d cb, rc=%d",
> +                        vec, rc);
> +               return;
> +       }
>
>         otx2_base_dbg("Disable vector:0x%x for vfio (efds: %d, max:%d)",
>                         vec, intr_handle->nb_efd, intr_handle->max_intr);
> --
> 2.8.4
>
Jerin Jacob July 8, 2020, 11:38 a.m. UTC | #2
On Fri, Jun 26, 2020 at 8:46 PM Jerin Jacob <jerinjacobk@gmail.com> wrote:
>
> On Thu, Jun 11, 2020 at 1:06 PM Nithin Dabilpuram
> <ndabilpuram@marvell.com> wrote:
> >
> > Interrupt callback unregister can fail with -EAGAIN
> > when interrupt handler is active in interrupt thread.
> > Hence retry before reporting a failure or proceeding further.
> >
> > Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
>
> Acked-by: Jerin Jacob <jerinj@marvell.com>


 Applied to dpdk-next-net-mrvl/master. Thanks

Patch
diff mbox series

diff --git a/drivers/common/octeontx2/otx2_irq.c b/drivers/common/octeontx2/otx2_irq.c
index fa3206a..c0137ff 100644
--- a/drivers/common/octeontx2/otx2_irq.c
+++ b/drivers/common/octeontx2/otx2_irq.c
@@ -193,6 +193,8 @@  otx2_unregister_irq(struct rte_intr_handle *intr_handle,
 		    rte_intr_callback_fn cb, void *data, unsigned int vec)
 {
 	struct rte_intr_handle tmp_handle;
+	uint8_t retries = 5; /* 5 ms */
+	int rc;
 
 	if (vec > intr_handle->max_intr) {
 		otx2_err("Error unregistering MSI-X interrupts vec:%d > %d",
@@ -205,8 +207,21 @@  otx2_unregister_irq(struct rte_intr_handle *intr_handle,
 	if (tmp_handle.fd == -1)
 		return;
 
-	/* Un-register callback func from eal lib */
-	rte_intr_callback_unregister(&tmp_handle, cb, data);
+	do {
+		/* Un-register callback func from eal lib */
+		rc = rte_intr_callback_unregister(&tmp_handle, cb, data);
+		/* Retry only if -EAGAIN */
+		if (rc != -EAGAIN)
+			break;
+		rte_delay_ms(1);
+		retries--;
+	} while (retries);
+
+	if (rc < 0) {
+		otx2_err("Error unregistering MSI-X intr vec %d cb, rc=%d",
+			 vec, rc);
+		return;
+	}
 
 	otx2_base_dbg("Disable vector:0x%x for vfio (efds: %d, max:%d)",
 			vec, intr_handle->nb_efd, intr_handle->max_intr);