mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yang Yingliang <yangyingliang@huawei.com>
To: <linux-kernel@vger.kernel.org>
Cc: <ogabbay@kernel.org>
Subject: [PATCH -next] habanalabs/gaudi2: fix free irq in error path in gaudi2_enable_msix()
Date: Thu, 25 Aug 2022 21:31:23 +0800	[thread overview]
Message-ID: <20220825133123.1874337-1-yangyingliang@huawei.com> (raw)

Add two variables to store completion irq and event queue irq. And add
a new lable to free event queue irq in error path in gaudi2_enable_msix().

Fixes: d7bb1ac89b2f ("habanalabs: add gaudi2 asic-specific code")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/misc/habanalabs/gaudi2/gaudi2.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/misc/habanalabs/gaudi2/gaudi2.c b/drivers/misc/habanalabs/gaudi2/gaudi2.c
index 98336a1a84b0..54eca19b270b 100644
--- a/drivers/misc/habanalabs/gaudi2/gaudi2.c
+++ b/drivers/misc/habanalabs/gaudi2/gaudi2.c
@@ -3518,6 +3518,7 @@ static int gaudi2_enable_msix(struct hl_device *hdev)
 	struct asic_fixed_properties *prop = &hdev->asic_prop;
 	struct gaudi2_device *gaudi2 = hdev->asic_specific;
 	int rc, irq, i, j, user_irq_init_cnt;
+	int completion_irq, event_queue_irq;
 	irq_handler_t irq_handler;
 	struct hl_cq *cq;
 
@@ -3532,17 +3533,19 @@ static int gaudi2_enable_msix(struct hl_device *hdev)
 		return rc;
 	}
 
-	irq = pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_COMPLETION);
+	completion_irq = pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_COMPLETION);
 	cq = &hdev->completion_queue[GAUDI2_RESERVED_CQ_CS_COMPLETION];
-	rc = request_irq(irq, hl_irq_handler_cq, 0, gaudi2_irq_name(GAUDI2_IRQ_NUM_COMPLETION), cq);
+	rc = request_irq(completion_irq, hl_irq_handler_cq, 0,
+			 gaudi2_irq_name(GAUDI2_IRQ_NUM_COMPLETION), cq);
 	if (rc) {
 		dev_err(hdev->dev, "Failed to request IRQ %d", irq);
 		goto free_irq_vectors;
 	}
 
-	irq = pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_EVENT_QUEUE);
-	rc = request_irq(irq, hl_irq_handler_eq, 0, gaudi2_irq_name(GAUDI2_IRQ_NUM_EVENT_QUEUE),
-			&hdev->event_queue);
+	event_queue_irq = pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_EVENT_QUEUE);
+	rc = request_irq(event_queue_irq, hl_irq_handler_eq, 0,
+			 gaudi2_irq_name(GAUDI2_IRQ_NUM_EVENT_QUEUE),
+			 &hdev->event_queue);
 	if (rc) {
 		dev_err(hdev->dev, "Failed to request IRQ %d", irq);
 		goto free_completion_irq;
@@ -3551,7 +3554,7 @@ static int gaudi2_enable_msix(struct hl_device *hdev)
 	rc = gaudi2_dec_enable_msix(hdev);
 	if (rc) {
 		dev_err(hdev->dev, "Failed to enable decoder IRQ");
-		goto free_completion_irq;
+		goto free_event_queue_irq;
 	}
 
 	for (i = GAUDI2_IRQ_NUM_USER_FIRST, j = prop->user_dec_intr_count, user_irq_init_cnt = 0;
@@ -3582,9 +3585,11 @@ static int gaudi2_enable_msix(struct hl_device *hdev)
 
 	gaudi2_dec_disable_msix(hdev, GAUDI2_IRQ_NUM_SHARED_DEC1_ABNRM + 1);
 
+free_event_queue_irq:
+	free_irq(event_queue_irq, &hdev->event_queue);
+
 free_completion_irq:
-	irq = pci_irq_vector(hdev->pdev, GAUDI2_IRQ_NUM_COMPLETION);
-	free_irq(irq, cq);
+	free_irq(completion_irq, cq);
 
 free_irq_vectors:
 	pci_free_irq_vectors(hdev->pdev);
-- 
2.25.1


             reply	other threads:[~2022-08-25 13:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-25 13:31 Yang Yingliang [this message]
2022-08-29 10:14 ` Oded Gabbay
2022-09-13  2:23   ` Yang Yingliang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220825133123.1874337-1-yangyingliang@huawei.com \
    --to=yangyingliang@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ogabbay@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®