Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp179314pxb; Thu, 12 Aug 2021 13:44:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSeTXsPWApOkggeumbHl5nMrgSmg7y/HFDeDlk26uSkLLFAgoel8WBwevFIxj6R60JMFWM X-Received: by 2002:a05:6e02:12b3:: with SMTP id f19mr345705ilr.234.1628801092270; 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=jcc63PtX4G12XCWjXtjbR+CiVcefpjzlgFBfLjTDF4cuezSwp04K+bx1aKL3+pJYev WBHCbrrGbMlyHgJ9AgJ1zP3WD/49QVWtceJZLiubUfE7Fbke21KPqUTiY9nOWdPn2Drg vPYxvg4wAdHUC/qaJu06tmpsZDqIDd9BbgQz+ywpQXdV8PJ6TbMZX5MQT2b2Bcl0KZBb 4WerMbcEQmAZei7pcGDIst+rBc7IfvNytad9bno6zowbmeVDw7kSwJ0YtxExASjaMRsR afUCCVqMyuGSly2V+E1MNFy6HskEcla3RfgBd24GKXXP1JZWbWoZpJt6l1Ey3RB7t+vZ njRg== 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=nK/Zuj3ip2BLkuwinTpdXiovC+bEtiA7F/0tD+aCatU=; b=gDs3yQNf6tfnjt5m5Dpfg6E34nUg31dA+Y4/0+y6n9xxV/fjuEQCtFVA+CW3Yy1l4n T4ODkWtvu/+49Qzfz/LIu8MeJXsbchdVFKc5lGSIS6D94eg32AICuzgQyX2e6JW/u3X3 awPSRrvqGkLG2QGUFx7jyUOFuDXdciRBTywCKM98uNNiwrMzBQmbHsqAtL4EPIegBkp2 beMQ9L/ZqRYOPgCjyujMnhn84EskNlZRLaUw/Bf0julnK1tI0sIDtPVp1MwfnkvfkSJN tQjdEtdJeUCLgycRTufu+7qnnAslKU8z9pnet3FVs3DoeaZ/nM730FBttoBmC1aMAt1i 9b4g== 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 c10si5093635iow.93.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 S236584AbhHLUWZ (ORCPT + 99 others); Thu, 12 Aug 2021 16:22:25 -0400 Received: from mga03.intel.com ([134.134.136.65]:4154 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236956AbhHLUWW (ORCPT ); Thu, 12 Aug 2021 16:22:22 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10074"; a="215474021" X-IronPort-AV: E=Sophos;i="5.84,316,1620716400"; d="scan'208";a="215474021" 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:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,316,1620716400"; d="scan'208";a="517608591" 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:47 -0700 From: Giovanni Cabiddu To: herbert@gondor.apana.org.au Cc: linux-crypto@vger.kernel.org, qat-linux@intel.com, Giovanni Cabiddu , Marco Chiappero , Fiona Trahe Subject: [PATCH 06/20] crypto: qat - prevent spurious MSI interrupt in VF Date: Thu, 12 Aug 2021 21:21:15 +0100 Message-Id: <20210812202129.18831-7-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 QAT GEN2 devices suffer from a defect where the MSI interrupt can be sent multiple times. If the second (spurious) interrupt is handled before the bottom half handler runs, then the extra interrupt is effectively ignored because the bottom half is only scheduled once. However, if the top half runs again after the bottom half runs, this will appear as a spurious PF to VF interrupt. This can be avoided by checking the interrupt mask register in addition to the interrupt source register in the interrupt handler. This patch is based on earlier work done by Conor McLoughlin. Signed-off-by: Giovanni Cabiddu Co-developed-by: Marco Chiappero Signed-off-by: Marco Chiappero Reviewed-by: Fiona Trahe --- drivers/crypto/qat/qat_common/adf_vf_isr.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/qat/qat_common/adf_vf_isr.c b/drivers/crypto/qat/qat_common/adf_vf_isr.c index 3e4f64d248f9..4359ca633ea9 100644 --- a/drivers/crypto/qat/qat_common/adf_vf_isr.c +++ b/drivers/crypto/qat/qat_common/adf_vf_isr.c @@ -18,6 +18,7 @@ #include "adf_pf2vf_msg.h" #define ADF_VINTSOU_OFFSET 0x204 +#define ADF_VINTMSK_OFFSET 0x208 #define ADF_VINTSOU_BUN BIT(0) #define ADF_VINTSOU_PF2VF BIT(1) @@ -161,11 +162,20 @@ static irqreturn_t adf_isr(int irq, void *privdata) &GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)]; void __iomem *pmisc_bar_addr = pmisc->virt_addr; bool handled = false; - u32 v_int; + u32 v_int, v_mask; /* Read VF INT source CSR to determine the source of VF interrupt */ v_int = ADF_CSR_RD(pmisc_bar_addr, ADF_VINTSOU_OFFSET); + /* Read VF INT mask CSR to determine which sources are masked */ + v_mask = ADF_CSR_RD(pmisc_bar_addr, ADF_VINTMSK_OFFSET); + + /* + * Recompute v_int ignoring sources that are masked. This is to + * avoid rescheduling the tasklet for interrupts already handled + */ + v_int &= ~v_mask; + /* Check for PF2VF interrupt */ if (v_int & ADF_VINTSOU_PF2VF) { /* Disable PF to VF interrupt */ -- 2.31.1