Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp619747pxf; Wed, 24 Mar 2021 11:42:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvMReQlssMZQKz6NxwLKdwOmbWNsYoJ93LzZ7AsDcsr6uHtg49xEznkCsio/ekcGgyYti4 X-Received: by 2002:a17:906:f88a:: with SMTP id lg10mr5420840ejb.39.1616611379278; Wed, 24 Mar 2021 11:42:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616611379; cv=none; d=google.com; s=arc-20160816; b=ta0ljp/QiyX7YMWSc7vfMQWHUGY/klsb2vQyCjR4Vo8WMpWckhsNlD5kwNZ3GWXGGv 3l1B3sp6z/B0AAk6Xc5gXcYhLToHvvhAfse10iMYa36C20iCLiN+SnY+2ozuVVcwS2OW ag6fTa0pf0hx/V6t1w53QLnrb0RKSp+1jNW8wbURGxNaMMp+GsMY/ykJoVB+mEg0WiR5 hu68dFXBAPex+Ie49vDF65QJ0ejIlOX8k5LxGMoOUv8m3eKq4LkadUF/XcOy1NWe7zaD gRJILstEC+p94CprR71rdniXxOLIb6K0oDsjOaPliPe6AUfe3YYUgV7GsNtfZwwcqArd mJoA== 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=oPS9h6DAeyWVDuOf36A1Gwfc/4UMf+DY5u2yaLOigdQ=; b=jBMfq0ri3UIjQRUSI0WghOGLx18aD2XY11zjRgsisOAR3C+aWSrb8FnSJUxalPJurv XHdo4oV+ce2apaU8Nb5FzuexPk3z9+Oz51yyvItaPRqO08UHN11sIYhaYdO08gNUCnDJ XSMp9dfKfQQR9SXIqoDofa2Nu+Jkl57xBNbnniZ2Pv+ihp7B8uy2wmaPCFyVqUVci92d oOfKV+fTocrSZHDhj1a9PSoZLjPi8jcE1GA9ggQLVc+KoUPGDVEG3D6Saj94xeuLabvc vSu+ogTsDWkB3Z2798O9Wnz30LD1Gxx5pYtDds8G42yvixSeRNR5H4AQjobfNs1iwwKf pCgQ== 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 q18si2249084ejr.593.2021.03.24.11.42.35; Wed, 24 Mar 2021 11:42:59 -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 S237814AbhCXSjO (ORCPT + 99 others); Wed, 24 Mar 2021 14:39:14 -0400 Received: from mga09.intel.com ([134.134.136.24]:17741 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237683AbhCXSio (ORCPT ); Wed, 24 Mar 2021 14:38:44 -0400 IronPort-SDR: w/uHEyc18RsnI5LtG6lsORwLIQfQ6PWtC8CRRP93AlFrU+r33C0r5xzukvnMM8PTQzO6g/oB6s 9JjkxjDQ1B4w== X-IronPort-AV: E=McAfee;i="6000,8403,9933"; a="190859559" X-IronPort-AV: E=Sophos;i="5.81,275,1610438400"; d="scan'208";a="190859559" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2021 11:38:43 -0700 IronPort-SDR: F/itdMtQS7fl9Z6XD8DS94bY5aX/lwDh697gBdpTgUQymsXWWUPd237H3p8BRiw7/1zq/2znXA /zPCypFN+UGQ== X-IronPort-AV: E=Sophos;i="5.81,275,1610438400"; d="scan'208";a="608203887" 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; 24 Mar 2021 11:38:41 -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 , Tomasz Jankowski , Savo Novakovic , Jianxun Zhang Subject: [PATCH v2 10/13] intel_gna: add interrupt handler Date: Wed, 24 Mar 2021 19:36:07 +0100 Message-Id: <20210324183610.4574-11-maciej.kwapulinski@linux.intel.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210324183610.4574-1-maciej.kwapulinski@linux.intel.com> References: <20210324183610.4574-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 From: Tomasz Jankowski 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 Tested-by: Savo Novakovic Co-developed-by: Jianxun Zhang Signed-off-by: Jianxun Zhang Co-developed-by: Maciej Kwapulinski Signed-off-by: Maciej Kwapulinski --- 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 #include #include @@ -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 #include -#include #include /* GNA MMIO registers */ -- 2.28.0