[PATCH] vdpa: solidrun: Free IRQs after request failure

Xiong Weimin posted 1 patch 1 month, 4 weeks ago
There is a newer version of this series
drivers/vdpa/solidrun/snet_main.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
[PATCH] vdpa: solidrun: Free IRQs after request failure
Posted by Xiong Weimin 1 month, 4 weeks ago
Unwind any IRQs already requested by snet_request_irqs() before returning
an error so a later retry starts from a clean state.

Signed-off-by: Xiong Weimin <xiongweimin@kylinos.cn>
---
 drivers/vdpa/solidrun/snet_main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/vdpa/solidrun/snet_main.c b/drivers/vdpa/solidrun/snet_main.c
index 28d55315d..aa3ae3876 100644
--- a/drivers/vdpa/solidrun/snet_main.c
+++ b/drivers/vdpa/solidrun/snet_main.c
@@ -407,7 +407,7 @@ static int snet_request_irqs(struct pci_dev *pdev, struct snet *snet)
 			       snet->cfg_irq_name, snet);
 	if (ret) {
 		SNET_ERR(pdev, "Failed to request IRQ\n");
-		return ret;
+		goto err_free_irqs;
 	}
 	snet->cfg_irq = irq;
 
@@ -418,11 +418,15 @@ static int snet_request_irqs(struct pci_dev *pdev, struct snet *snet)
 				       snet->vqs[i]->irq_name, snet->vqs[i]);
 		if (ret) {
 			SNET_ERR(pdev, "Failed to request IRQ\n");
-			return ret;
+			goto err_free_irqs;
 		}
 		snet->vqs[i]->irq = irq;
 	}
 	return 0;
+
+err_free_irqs:
+	snet_free_irqs(snet);
+	return ret;
 }
 
 static void snet_set_status(struct vdpa_device *vdev, u8 status)
-- 
2.43.0
Re: [PATCH] vdpa: solidrun: Free IRQs after request failure
Posted by Michael S. Tsirkin 1 month, 4 weeks ago
On Tue, Aug 04, 2026 at 05:26:17PM +0800, Xiong Weimin wrote:
> Unwind any IRQs already requested by snet_request_irqs() before returning
> an error so a later retry starts from a clean state.
> 
> Signed-off-by: Xiong Weimin <xiongweimin@kylinos.cn>

Here too. Pls tell us what is wrong and how it is fixed. E.g.:

Currently .... This is a problem because ... We can not do .... because
... To address .... And then ....


> ---
>  drivers/vdpa/solidrun/snet_main.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/vdpa/solidrun/snet_main.c b/drivers/vdpa/solidrun/snet_main.c
> index 28d55315d..aa3ae3876 100644
> --- a/drivers/vdpa/solidrun/snet_main.c
> +++ b/drivers/vdpa/solidrun/snet_main.c
> @@ -407,7 +407,7 @@ static int snet_request_irqs(struct pci_dev *pdev, struct snet *snet)
>  			       snet->cfg_irq_name, snet);
>  	if (ret) {
>  		SNET_ERR(pdev, "Failed to request IRQ\n");
> -		return ret;
> +		goto err_free_irqs;
>  	}
>  	snet->cfg_irq = irq;
>  
> @@ -418,11 +418,15 @@ static int snet_request_irqs(struct pci_dev *pdev, struct snet *snet)
>  				       snet->vqs[i]->irq_name, snet->vqs[i]);
>  		if (ret) {
>  			SNET_ERR(pdev, "Failed to request IRQ\n");
> -			return ret;
> +			goto err_free_irqs;
>  		}
>  		snet->vqs[i]->irq = irq;
>  	}
>  	return 0;
> +
> +err_free_irqs:
> +	snet_free_irqs(snet);
> +	return ret;
>  }
>  
>  static void snet_set_status(struct vdpa_device *vdev, u8 status)
> -- 
> 2.43.0
Re: [PATCH] vdpa: solidrun: Free IRQs after request failure
Posted by Markus Elfring 1 month, 4 weeks ago
> Unwind any IRQs already requested by snet_request_irqs() before returning
> an error so a later retry starts from a clean state.

How good does a proposed snet_free_irqs(snet) call fit to previous devm_request_irq() calls?


I suggest to avoid duplicate exception handling code for affected cases.

Regards,
Markus
Re: [PATCH] vdpa: solidrun: Free IRQs after request failure
Posted by Xiong Weimin 1 month, 4 weeks ago
On Tue, Aug 04, 2026 at 06:54:24PM +0200, Markus Elfring wrote:
> How good does a proposed snet_free_irqs(snet) call fit to previous
> devm_request_irq() calls?
>
> I suggest to avoid duplicate exception handling code for affected cases.

The IRQs are requested and freed while the PCI device remains bound, for
example when DRIVER_OK is set and later reset. So the driver cannot rely
only on devres cleanup at device detach time; it already pairs
devm_request_irq() with devm_free_irq() in snet_free_irqs() for reset and
for the snet_write_conf() failure path.

That said, I agree that the error path can be made more precise. I will
send a v2 that keeps the config IRQ request failure as a direct return,
and only calls snet_free_irqs() after at least one IRQ was successfully
requested. I will also add the Fixes/Cc stable tags.

Thanks,
Xiong