[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210324183610.4574-11-maciej.kwapulinski@linux.intel.com>
Date: Wed, 24 Mar 2021 19:36:07 +0100
From: Maciej Kwapulinski <maciej.kwapulinski@...ux.intel.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Arnd Bergmann <arnd@...db.de>,
Jonathan Corbet <corbet@....net>,
Derek Kiernan <derek.kiernan@...inx.com>,
Dragan Cvetic <dragan.cvetic@...inx.com>,
Andy Shevchenko <andy.shevchenko@...il.com>
Cc: linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
Maciej Kwapulinski <maciej.kwapulinski@...ux.intel.com>,
Tomasz Jankowski <tomasz1.jankowski@...el.com>,
Savo Novakovic <savox.novakovic@...el.com>,
Jianxun Zhang <jianxun.zhang@...ux.intel.com>
Subject: [PATCH v2 10/13] intel_gna: add interrupt handler
From: Tomasz Jankowski <tomasz1.jankowski@...el.com>
An interrupt is generated by the hardware when a scoring job is
done. The interrupt handler wakes up the work queue to resume
the processing on the current request.
Signed-off-by: Tomasz Jankowski <tomasz1.jankowski@...el.com>
Tested-by: Savo Novakovic <savox.novakovic@...el.com>
Co-developed-by: Jianxun Zhang <jianxun.zhang@...ux.intel.com>
Signed-off-by: Jianxun Zhang <jianxun.zhang@...ux.intel.com>
Co-developed-by: Maciej Kwapulinski <maciej.kwapulinski@...ux.intel.com>
Signed-off-by: Maciej Kwapulinski <maciej.kwapulinski@...ux.intel.com>
---
drivers/misc/intel/gna/gna_device.c | 45 ++++++++++++++++++++++++++++-
drivers/misc/intel/gna/gna_device.h | 2 ++
drivers/misc/intel/gna/gna_hw.h | 1 -
3 files changed, 46 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/intel/gna/gna_device.c b/drivers/misc/intel/gna/gna_device.c
index 47f238677bc9..67917106a262 100644
--- a/drivers/misc/intel/gna/gna_device.c
+++ b/drivers/misc/intel/gna/gna_device.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
// Copyright(c) 2017-2021 Intel Corporation
+#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/pci.h>
@@ -153,6 +154,16 @@ static void gna_dev_deinit(struct gna_private *gna_priv)
gna_mmu_free(gna_priv);
}
+static irqreturn_t gna_interrupt(int irq, void *priv)
+{
+ struct gna_private *gna_priv;
+
+ gna_priv = (struct gna_private *)priv;
+ gna_priv->dev_busy = false;
+ wake_up(&gna_priv->dev_busy_waitq);
+ return IRQ_HANDLED;
+}
+
int gna_probe(struct pci_dev *pcidev, const struct pci_device_id *pci_id)
{
struct gna_private *gna_priv;
@@ -201,14 +212,42 @@ int gna_probe(struct pci_dev *pcidev, const struct pci_device_id *pci_id)
pci_set_master(pcidev);
+ ret = pci_alloc_irq_vectors(pcidev, 1, 1, PCI_IRQ_ALL_TYPES);
+ if (ret < 0)
+ return ret;
+
+ gna_priv->irq = pci_irq_vector(pcidev, 0);
+ if (unlikely(gna_priv->irq < 0)) {
+ dev_err(&pcidev->dev, "could not obtain irq number\n");
+ ret = -EIO;
+ goto err_free_irq_vector;
+ }
+
+ ret = request_irq(gna_priv->irq, gna_interrupt,
+ IRQF_SHARED, GNA_DV_NAME, gna_priv);
+
+ if (ret) {
+ dev_err(&pcidev->dev, "could not register for interrupt\n");
+ goto err_free_irq_vector;
+ }
+
+ dev_dbg(&pcidev->dev, "irq num %d\n", gna_priv->irq);
+
ret = gna_dev_init(gna_priv, pcidev, pci_id);
if (ret) {
dev_err(&pcidev->dev, "could not initialize %s device\n", GNA_DV_NAME);
- return ret;
+ goto err_free_irq;
}
return 0;
+
+err_free_irq:
+ free_irq(gna_priv->irq, gna_priv);
+err_free_irq_vector:
+ pci_free_irq_vectors(pcidev);
+
+ return ret;
}
void gna_remove(struct pci_dev *pcidev)
@@ -217,5 +256,9 @@ void gna_remove(struct pci_dev *pcidev)
gna_priv = pci_get_drvdata(pcidev);
+ free_irq(gna_priv->irq, gna_priv);
+
gna_dev_deinit(gna_priv);
+
+ pci_free_irq_vectors(pcidev);
}
diff --git a/drivers/misc/intel/gna/gna_device.h b/drivers/misc/intel/gna/gna_device.h
index 23eae806f96d..7ba25f6f8492 100644
--- a/drivers/misc/intel/gna/gna_device.h
+++ b/drivers/misc/intel/gna/gna_device.h
@@ -43,6 +43,8 @@ struct gna_private {
/* pdev->dev */
struct device *parent;
+ int irq;
+ /* hardware status set by interrupt handler */
u32 hw_status;
/* device related resources */
diff --git a/drivers/misc/intel/gna/gna_hw.h b/drivers/misc/intel/gna/gna_hw.h
index dd682f95094e..904e551f4f17 100644
--- a/drivers/misc/intel/gna/gna_hw.h
+++ b/drivers/misc/intel/gna/gna_hw.h
@@ -6,7 +6,6 @@
#include <linux/bits.h>
#include <linux/bitfield.h>
-#include <linux/interrupt.h>
#include <linux/io.h>
/* GNA MMIO registers */
--
2.28.0
Powered by blists - more mailing lists