Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp582915pxj; Thu, 13 May 2021 11:48:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuRXs2TmL5VfG71C+THTmi3AEFwjyUivIvGjC9Ay3+vczhj1xxzzlJ6WBRzKmZRU5784ya X-Received: by 2002:a4a:eb97:: with SMTP id d23mr17991581ooj.70.1620931734378; Thu, 13 May 2021 11:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620931734; cv=none; d=google.com; s=arc-20160816; b=dvawYF508HjFk9SrdyJ1y9Fb4PAmDTkiBLbZENKJ6gCybrUSeIqKmS5C8cQ1KRE+mV rnSrfEXu+Zoh0dl7rRVHaUj9v7iIztbJwK8Dm6p6bz+F8EGR45fjiyfUiHx9OuTy4+m/ VaOTIusOb70jE4dyVBghFK/cPFoN8MLGbxu1jicyKCXexu8JQm/BNaioaUw34/kAnD1A cum4Ga2EiV/r/DXYx6G1Vnhu9W0cZZQy9PJP6VE9DYCh9f+XVZClnDqwNK+c2A+npeA3 nhoWws5zWRnd3n6IU3VMQ4mVX5IWPGERYOoKesE0Xm7O2d0IXFBAKnbXTMFYbiqL4z1Y XZBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=3Nn6gFhV66aJrNn8d6VQpaxEI6JY/GdQAvkyzmA/ju0=; b=OPL5ALlpEt+Vwc6OAZqo0XCS2VIj3KgoS63qDVhuguLrifIxIgOv4x8o23nECXrqgW MoY93DAN4h+ZZbnr3blPWR9z1v1uiDpoAPyk4MH8SLlHQrOElwR0q0vOIum1y3cqy/9o bfbpeVEgtu9igvQOZnKb1KX9NjzleUzp2SWfKygUxUg1ZO2enrXJdPouTX4ysktLoRdW +hamuo7VRJa223QglIlbyU8iTxVs4Aj9rHl0FJmHmqNe1AwX0hB/kSsyaU1j4ByKQE6x NXbK3A3p9vQXdWlRMrGyxkO97Y2WjiCsv+k46HCY9esunC/1h9owDdHClemkk/OLPnRN FeHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v10si4148770otj.101.2021.05.13.11.48.41; Thu, 13 May 2021 11:48:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232990AbhEMLEr (ORCPT + 99 others); Thu, 13 May 2021 07:04:47 -0400 Received: from mga02.intel.com ([134.134.136.20]:45141 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233094AbhEMLD5 (ORCPT ); Thu, 13 May 2021 07:03:57 -0400 IronPort-SDR: C0nuCYHBhVjX7zskBkDf5wH5/2DQd/xIzlhBNKEfUxc2VgGspnpxWt+9s6LaC9jBBLeoGsnUDn Yfh3HtECeQ0Q== X-IronPort-AV: E=McAfee;i="6200,9189,9982"; a="187048334" X-IronPort-AV: E=Sophos;i="5.82,296,1613462400"; d="scan'208";a="187048334" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2021 04:01:21 -0700 IronPort-SDR: Vw08QTpV6MqMWLA0Ig8pif8+k6eHIkULFFy553hiUtW0hKWGELL1Juzx+UzUNr5zMYMafBncSk Q0dtV37XWVXA== X-IronPort-AV: E=Sophos;i="5.82,296,1613462400"; d="scan'208";a="625984162" Received: from gna-dev.igk.intel.com ([10.102.80.34]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 May 2021 04:01:18 -0700 From: Maciej Kwapulinski To: Greg Kroah-Hartman , Arnd Bergmann , Jonathan Corbet , Derek Kiernan , Dragan Cvetic , Andy Shevchenko Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Maciej Kwapulinski , Savo Novakovic , Tomasz Jankowski , Jianxun Zhang Subject: [PATCH v3 10/14] intel_gna: add interrupt handler Date: Thu, 13 May 2021 13:00:36 +0200 Message-Id: <20210513110040.2268-11-maciej.kwapulinski@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210513110040.2268-1-maciej.kwapulinski@linux.intel.com> References: <20210513110040.2268-1-maciej.kwapulinski@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Tested-by: Savo Novakovic Co-developed-by: Tomasz Jankowski Signed-off-by: Tomasz Jankowski Co-developed-by: Jianxun Zhang Signed-off-by: Jianxun Zhang --- 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 #include +#include #include #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