Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp179316pxb; Thu, 12 Aug 2021 13:44:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkbsN8gmeDxjRrRym1p+lmWaeb/zmJt3OMNTwBG5OIzDhZNUUet834Su8WScbtMs5RGLO6 X-Received: by 2002:a5d:9e19:: with SMTP id h25mr4466264ioh.25.1628801092273; Thu, 12 Aug 2021 13:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628801092; cv=none; d=google.com; s=arc-20160816; b=zjI/v8qj2w4+gZO1+LA6sD2kl7Z1uOzEt74CCWjSWcOEr30DDS1dhVNx0LxlJJ+OOi blhkdHN/VtEDzJt/I7Udz+MvNXKimF58e+WGOv0mBaQu7e9+uy7d+KMG1pJqpUfqALTr TM1UwAe1AijeNEZu1Ne74Xcu7CpqJ5DmJ049Oj1PULjYH+YxE4Gl7/LUtr8iXHilLmBZ yDnUF0E5DAzBYfefJps5Du090c6P+16ZQ6lm7tcjZnvwfODLvvmXKCbpveCPrj1vfD4j GJ/1Vycbw4I7cbu4XjQ5YT0tnbutISI8k9drbbcc5K7NYuQmIZ5Jzgu6bU1LElTXwfZu Iflg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=3FD06vaodGDCqtnpN2sUvvxROHPUtwLVX+dR/mWd7sU=; b=d/Eqw33NUOapHjvgnGkRkekDv2Em899TOYnjWsAB9NAzFOjA3VRPdnnlaIDfmyWli/ VurDE5MhuLwrvMASN0UAauLr8/NCGS3el08nTwyYs9+xmuI6IjNFyuXI9QCfKmqH8ORa sAKH4bw/24AY5pGcr9kF5P5qnjUa/a6iC1WsLF5pI2MWPTG1rp8yhuZVVnrJHthJMpMA mfNHSmXSZDKkR/cHWESUC/a75+P1k5Li2tlRN3j5WUmvNdbwOg4ra0XkSwsOUa0HYvyy d8BB3SzUjv+0dcpp/mUgL3ZJstnsDe6ycexOgmBj/DBjhcAcAP2B20hMq4MOvtw4L0Fx dJJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 p6si4655364ilo.37.2021.08.12.13.44.40; Thu, 12 Aug 2021 13:44:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-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 S237015AbhHLUWZ (ORCPT + 99 others); Thu, 12 Aug 2021 16:22:25 -0400 Received: from mga03.intel.com ([134.134.136.65]:4146 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237087AbhHLUWY (ORCPT ); Thu, 12 Aug 2021 16:22:24 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10074"; a="215474026" X-IronPort-AV: E=Sophos;i="5.84,316,1620716400"; d="scan'208";a="215474026" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2021 13:21:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,316,1620716400"; d="scan'208";a="517608600" Received: from silpixa00400314.ir.intel.com (HELO silpixa00400314.ger.corp.intel.com) ([10.237.222.51]) by FMSMGA003.fm.intel.com with ESMTP; 12 Aug 2021 13:21:49 -0700 From: Giovanni Cabiddu To: herbert@gondor.apana.org.au Cc: linux-crypto@vger.kernel.org, qat-linux@intel.com, Marco Chiappero , Giovanni Cabiddu , Fiona Trahe Subject: [PATCH 07/20] crypto: qat - prevent spurious MSI interrupt in PF Date: Thu, 12 Aug 2021 21:21:16 +0100 Message-Id: <20210812202129.18831-8-giovanni.cabiddu@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210812202129.18831-1-giovanni.cabiddu@intel.com> References: <20210812202129.18831-1-giovanni.cabiddu@intel.com> MIME-Version: 1.0 Organization: Intel Research and Development Ireland Ltd - Co. Reg. #308263 - Collinstown Industrial Park, Leixlip, County Kildare - Ireland Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Marco Chiappero There is a chance that the PFVF handler, adf_vf2pf_req_hndl(), runs twice for the same request when multiple interrupts come simultaneously from different VFs. Since the source VF is identified by a positional bit set in the ERRSOU registers and that is not cleared until the bottom half completes, new top halves from other VFs may reschedule a second bottom half for previous interrupts. This patch solves the problem in the ISR handler by not considering sources with already disabled interrupts (and processing pending), as set in the ERRMSK registers. Also, move some definitions where actually needed. Signed-off-by: Marco Chiappero Co-developed-by: Giovanni Cabiddu Signed-off-by: Giovanni Cabiddu Reviewed-by: Fiona Trahe --- .../crypto/qat/qat_common/adf_accel_devices.h | 2 -- drivers/crypto/qat/qat_common/adf_isr.c | 25 +++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/qat/qat_common/adf_accel_devices.h b/drivers/crypto/qat/qat_common/adf_accel_devices.h index ac435b44f1d2..2ee11b4763cd 100644 --- a/drivers/crypto/qat/qat_common/adf_accel_devices.h +++ b/drivers/crypto/qat/qat_common/adf_accel_devices.h @@ -18,8 +18,6 @@ #define ADF_4XXX_DEVICE_NAME "4xxx" #define ADF_4XXX_PCI_DEVICE_ID 0x4940 #define ADF_4XXXIOV_PCI_DEVICE_ID 0x4941 -#define ADF_ERRSOU3 (0x3A000 + 0x0C) -#define ADF_ERRSOU5 (0x3A000 + 0xD8) #define ADF_DEVICE_FUSECTL_OFFSET 0x40 #define ADF_DEVICE_LEGFUSE_OFFSET 0x4C #define ADF_DEVICE_FUSECTL_MASK 0x80000000 diff --git a/drivers/crypto/qat/qat_common/adf_isr.c b/drivers/crypto/qat/qat_common/adf_isr.c index daab02011717..a25b7845c9d3 100644 --- a/drivers/crypto/qat/qat_common/adf_isr.c +++ b/drivers/crypto/qat/qat_common/adf_isr.c @@ -16,6 +16,12 @@ #include "adf_transport_internal.h" #define ADF_MAX_NUM_VFS 32 +#define ADF_ERRSOU3 (0x3A000 + 0x0C) +#define ADF_ERRSOU5 (0x3A000 + 0xD8) +#define ADF_ERRMSK3 (0x3A000 + 0x1C) +#define ADF_ERRMSK5 (0x3A000 + 0xDC) +#define ADF_ERR_REG_VF2PF_L(vf_src) (((vf_src) & 0x01FFFE00) >> 9) +#define ADF_ERR_REG_VF2PF_U(vf_src) (((vf_src) & 0x0000FFFF) << 16) static int adf_enable_msix(struct adf_accel_dev *accel_dev) { @@ -73,14 +79,23 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr) struct adf_hw_device_data *hw_data = accel_dev->hw_device; struct adf_bar *pmisc = &GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)]; - void __iomem *pmisc_bar_addr = pmisc->virt_addr; + void __iomem *pmisc_addr = pmisc->virt_addr; + u32 errsou3, errsou5, errmsk3, errmsk5; unsigned long vf_mask; /* Get the interrupt sources triggered by VFs */ - vf_mask = ((ADF_CSR_RD(pmisc_bar_addr, ADF_ERRSOU5) & - 0x0000FFFF) << 16) | - ((ADF_CSR_RD(pmisc_bar_addr, ADF_ERRSOU3) & - 0x01FFFE00) >> 9); + errsou3 = ADF_CSR_RD(pmisc_addr, ADF_ERRSOU3); + errsou5 = ADF_CSR_RD(pmisc_addr, ADF_ERRSOU5); + vf_mask = ADF_ERR_REG_VF2PF_L(errsou3); + vf_mask |= ADF_ERR_REG_VF2PF_U(errsou5); + + /* To avoid adding duplicate entries to work queue, clear + * vf_int_mask_sets bits that are already masked in ERRMSK register. + */ + errmsk3 = ADF_CSR_RD(pmisc_addr, ADF_ERRMSK3); + errmsk5 = ADF_CSR_RD(pmisc_addr, ADF_ERRMSK5); + vf_mask &= ~ADF_ERR_REG_VF2PF_L(errmsk3); + vf_mask &= ~ADF_ERR_REG_VF2PF_U(errmsk5); if (vf_mask) { struct adf_accel_vf_info *vf_info; -- 2.31.1