Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp720506ybt; Wed, 1 Jul 2020 08:29:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0l9s30yYZKnSgb02Hf5wtDyUl1vUxXZGH1He6AyCoW2nukTjiaCMQ2ahM5JWhXG58xlXL X-Received: by 2002:a05:6402:1b0e:: with SMTP id by14mr28769688edb.266.1593617346711; Wed, 01 Jul 2020 08:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593617346; cv=none; d=google.com; s=arc-20160816; b=JLeZai8yPQUzOeIONelIy55IZzzEQ6sA2cO0uicBs00So+BQJUnvXMpotZTeZL2oRV CtmIFHg315c8rgf+YOCTBVvNBM521iEn9ZKyjln+7p7HTlQwJ2lqtAQaE9HoVTnLSDJm cMDNbpkKf4eMQXyvY4RJ0IZaNx/3cFTCMZ1oHOou5QHmHuo/Mk6dm/cQzIRo8N/klMzF bGv0T+t6HfdQSZUhrr8g6LP3k5mYGbCrdi65RvdzAuQFvzzInXlsFJtbdXBxjsxF6dFX jU9MQKe58nDCPLS25VvpwGHRez+4EQ8isvN+p+l9dcYKigmEXqezEEe1tYb+Swj2M/Iv thNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=tEqa2RnAROSsLSrdtuyjLx3mE4RxSIF7npG2Mg9dnhA=; b=GDZv9zVlMNiHXvVfm90+cdeTNURN2fdcaRuoOBaZreSIKjiqBoao6RoEYbgee/+GDB uDChLoeYuZV3zXXfv9k4vHQmb/9zmQzGTyuwJenmRVTi4A7qPS2J59O/CHITL1m1cu1E keKb0hbrsLwFxogkLem9pzC/Gck67Wb42lYbIrJh2xX9k4HWo02NNw3aQXnoy5gs3ee2 L5euZyfMZ6m7+CcJgzDJzzQdiADNKyMMUWMFcQh9qcTSmHIzo1YHhsxNcJFFsuyg/1xT KXE0epWRJicu0DO6Gu0L/S9gcpe48ola9ytfNoOOdQSnRGzSVcJONBWNAIgqjzh61geA I+mw== 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 dm9si5339224ejc.624.2020.07.01.08.28.43; Wed, 01 Jul 2020 08:29:06 -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 S1731870AbgGAP1s (ORCPT + 99 others); Wed, 1 Jul 2020 11:27:48 -0400 Received: from mga17.intel.com ([192.55.52.151]:54837 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732004AbgGAP1Z (ORCPT ); Wed, 1 Jul 2020 11:27:25 -0400 IronPort-SDR: 1lKOYQEx6jjlc7iAAJFMMwz/Q99Q7cNox9+cUXWwZe6PsSgian1z0C2o6o0O60pcVGMn2dJ+io lUFLthEI61DQ== X-IronPort-AV: E=McAfee;i="6000,8403,9668"; a="126699717" X-IronPort-AV: E=Sophos;i="5.75,300,1589266800"; d="scan'208";a="126699717" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2020 08:27:22 -0700 IronPort-SDR: u9h00Dj0YFmtIgKW1YoQHXAnJsnfhOsoXn8xVha87V1+qfbpWl7YNx/mN8KRBgu0o4amTw1zLf ywszPxoX+Lew== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,300,1589266800"; d="scan'208";a="295591646" Received: from jacob-builder.jf.intel.com ([10.7.199.155]) by orsmga002.jf.intel.com with ESMTP; 01 Jul 2020 08:27:22 -0700 From: Jacob Pan To: iommu@lists.linux-foundation.org, LKML , "Lu Baolu" , Joerg Roedel , David Woodhouse Cc: Yi Liu , "Tian, Kevin" , Raj Ashok , Eric Auger , Jacob Pan Subject: [PATCH v3 3/7] iommu/vt-d: Fix PASID devTLB invalidation Date: Wed, 1 Jul 2020 08:33:52 -0700 Message-Id: <1593617636-79385-4-git-send-email-jacob.jun.pan@linux.intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593617636-79385-1-git-send-email-jacob.jun.pan@linux.intel.com> References: <1593617636-79385-1-git-send-email-jacob.jun.pan@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org DevTLB flush can be used for both DMA request with and without PASIDs. The former uses PASID#0 (RID2PASID), latter uses non-zero PASID for SVA usage. This patch adds a check for PASID value such that devTLB flush with PASID is used for SVA case. This is more efficient in that multiple PASIDs can be used by a single device, when tearing down a PASID entry we shall flush only the devTLB specific to a PASID. Fixes: 6f7db75e1c46 ("iommu/vt-d: Add second level page table") Signed-off-by: Jacob Pan --- drivers/iommu/intel/pasid.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index c81f0f17c6ba..fa0154cce537 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -486,7 +486,16 @@ devtlb_invalidation_with_pasid(struct intel_iommu *iommu, qdep = info->ats_qdep; pfsid = info->pfsid; - qi_flush_dev_iotlb(iommu, sid, pfsid, qdep, 0, 64 - VTD_PAGE_SHIFT); + /* + * When PASID 0 is used, it indicates RID2PASID(DMA request w/o PASID), + * devTLB flush w/o PASID should be used. For non-zero PASID under + * SVA usage, device could do DMA with multiple PASIDs. It is more + * efficient to flush devTLB specific to the PASID. + */ + if (pasid == PASID_RID2PASID) + qi_flush_dev_iotlb(iommu, sid, pfsid, qdep, 0, 64 - VTD_PAGE_SHIFT); + else + qi_flush_dev_iotlb_pasid(iommu, sid, pfsid, pasid, qdep, 0, 64 - VTD_PAGE_SHIFT); } void intel_pasid_tear_down_entry(struct intel_iommu *iommu, struct device *dev, -- 2.7.4