lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210513110040.2268-11-maciej.kwapulinski@linux.intel.com>
Date:   Thu, 13 May 2021 13:00:36 +0200
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>,
        Savo Novakovic <savox.novakovic@...el.com>,
        Tomasz Jankowski <tomasz1.jankowski@...el.com>,
        Jianxun Zhang <jianxun.zhang@...ux.intel.com>
Subject: [PATCH v3 10/14] intel_gna: add interrupt handler

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: Maciej Kwapulinski <maciej.kwapulinski@...ux.intel.com>
Tested-by: Savo Novakovic <savox.novakovic@...el.com>
Co-developed-by: Tomasz Jankowski <tomasz1.jankowski@...el.com>
Signed-off-by: Tomasz Jankowski <tomasz1.jankowski@...el.com>
Co-developed-by: Jianxun Zhang <jianxun.zhang@...ux.intel.com>
Signed-off-by: Jianxun Zhang <jianxun.zhang@...ux.intel.com>
---
 drivers/misc/intel/gna/device.c | 20 ++++++++++++++++++-
 drivers/misc/intel/gna/device.h |  2 +-
 drivers/misc/intel/gna/pci.c    | 35 ++++++++++++++++++++++++++++++++-
 3 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/intel/gna/device.c b/drivers/misc/intel/gna/device.c
index ca988d3ec408..75d8e1675485 100644
--- a/drivers/misc/intel/gna/device.c
+++ b/drivers/misc/intel/gna/device.c
@@ -3,6 +3,7 @@
 
 #include <linux/device.h>
 #include <linux/dma-mapping.h>
+#include <linux/interrupt.h>
 #include <linux/module.h>
 
 #include "device.h"
@@ -23,6 +24,16 @@ static void gna_devm_idr_destroy(void *data)
 	idr_destroy(idr);
 }
 
+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;
+}
+
 static void gna_devm_destroy_workqueue(void *data)
 {
 	struct workqueue_struct *request_wq = data;
@@ -51,7 +62,7 @@ static int gna_devm_create_singlethread_workqueue(struct gna_private *gna_priv)
 	return ret;
 }
 
-int gna_probe(struct device *parent, struct gna_dev_info *dev_info, void __iomem *iobase)
+int gna_probe(struct device *parent, struct gna_dev_info *dev_info, void __iomem *iobase, int irq)
 {
 	static atomic_t dev_last_idx = ATOMIC_INIT(-1);
 	struct gna_private *gna_priv;
@@ -124,6 +135,13 @@ int gna_probe(struct device *parent, struct gna_dev_info *dev_info, void __iomem
 	if (ret)
 		return ret;
 
+	ret = devm_request_irq(parent, irq, gna_interrupt,
+			IRQF_SHARED, dev_misc_name, gna_priv);
+	if (ret) {
+		dev_err(parent, "could not register for interrupt\n");
+		return ret;
+	}
+
 	return 0;
 }
 
diff --git a/drivers/misc/intel/gna/device.h b/drivers/misc/intel/gna/device.h
index 65856d08729f..d3c86d649b5c 100644
--- a/drivers/misc/intel/gna/device.h
+++ b/drivers/misc/intel/gna/device.h
@@ -70,7 +70,7 @@ struct gna_private {
 	struct mutex memidr_lock;
 };
 
-int gna_probe(struct device *parent, struct gna_dev_info *dev_info, void __iomem *iobase);
+int gna_probe(struct device *parent, struct gna_dev_info *dev_info, void __iomem *iobase, int irq);
 
 static inline u32 gna_reg_read(struct gna_private *gna_priv, u32 reg)
 {
diff --git a/drivers/misc/intel/gna/pci.c b/drivers/misc/intel/gna/pci.c
index 525e9de9d577..a31f0142a4f2 100644
--- a/drivers/misc/intel/gna/pci.c
+++ b/drivers/misc/intel/gna/pci.c
@@ -69,10 +69,33 @@ static const struct pci_device_id gna_pci_ids[] = {
 	{ }
 };
 
+static void gna_pcim_free_irq_vectors(void *data)
+{
+	struct pci_dev *pcidev = data;
+
+	pci_free_irq_vectors(pcidev);
+}
+
+static int gna_pcim_alloc_irq_vectors(struct pci_dev *pcidev)
+{
+	int ret;
+
+	ret = pci_alloc_irq_vectors(pcidev, 1, 1, PCI_IRQ_ALL_TYPES);
+	if (ret < 0)
+		return ret;
+
+	ret = devm_add_action(&pcidev->dev, gna_pcim_free_irq_vectors, pcidev);
+	if (ret)
+		gna_pcim_free_irq_vectors(pcidev);
+
+	return ret;
+}
+
 int gna_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *pci_id)
 {
 	struct gna_dev_info *dev_info;
 	void __iomem *iobase;
+	int irq;
 	int ret;
 
 	ret = pcim_enable_device(pcidev);
@@ -91,9 +114,19 @@ int gna_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *pci_id)
 
 	pci_set_master(pcidev);
 
+	ret = gna_pcim_alloc_irq_vectors(pcidev);
+	if (ret < 0)
+		return ret;
+
+	irq = pci_irq_vector(pcidev, 0);
+	if (unlikely(irq < 0)) {
+		dev_err(&pcidev->dev, "could not get irq number\n");
+		return -EIO;
+	}
+
 	dev_info = (struct gna_dev_info *)pci_id->driver_data;
 
-	ret = gna_probe(&pcidev->dev, dev_info, iobase);
+	ret = gna_probe(&pcidev->dev, dev_info, iobase, irq);
 	if (ret) {
 		dev_err(&pcidev->dev, "could not initialize device\n");
 		return ret;
-- 
2.28.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ