Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1032016ybh; Thu, 16 Jul 2020 00:55:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5ly4lgvB8zg6HY9ipYc8KZYaLmhq+3ZcDAqRw5Fa9OhYrLPY+3SEpIfe1sJ4Y4y048+ay X-Received: by 2002:a17:906:a28b:: with SMTP id i11mr2513004ejz.524.1594886116089; Thu, 16 Jul 2020 00:55:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594886116; cv=none; d=google.com; s=arc-20160816; b=kAouZXptI4RgzrIvV7IBsM7EKoGYmXQIy/DYRhDBDEVnVUCxe0l1meq5dUqHff6fcQ RrsjHZxx92Wy/aSXwbWRa4ZRe0rFwxU2gJaD52gZOSfTYjm2rrNygZE16nrQvr8IVAKW PWIsftbZvnskKT+5AtjcSS/RGdO3ELIKx15ukTUJHKF0Grpe1qJKHT1rcxBaE25OSg3m a7fi50h6h7snU3zZnfDbONTOKXaF8DHCsGo42/ojU58nRk9lrTAZ5WFWLrou0hhxU6vh ZPsB3Z/Cvxht6yESwHXe8TV1lE9odtjAUvJhry0pCzD+SldAQNvMf7KPET9gAr8BRO/D kkBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=u05tKeUEsAaeYGPCQa0ls+uddt7PTxRvgt5ZWaTMPQo=; b=R9LyQ6PmFy9ATSMYG/smwiHCjCkMN5b/w9nP62dgjkniyl9PklThOmb4vV6SyrSzRU cm5BfyjriVtqQUgJp5M8TdR7hbP+mCrmYZAkw/5fNI/hgrOOLzhcbSx5mMjUC4RN91UV zFn4FQZMY1gRiKDVmvB5s9bJdlIFjdNw6S4ntpcn59TWbM/6zJ9SZz4rJbBvsGUbByYi +1RcGnjYxABuc+OXWRcTOY3CfGZ5icqd0eoH9+xs0G5LMn0CxCKx9U+YvinJJHx6M1c/ YoR+nkFp18ibY2hu+E/tUDRkjt1/g8Xt2ipI8PHWfCwD2yrJ9rxa7HPQ/a1ahQVsq4XV ZuBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UrLlztx0; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn13si2697589edb.186.2020.07.16.00.54.53; Thu, 16 Jul 2020 00:55:16 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UrLlztx0; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726599AbgGPHwY (ORCPT + 99 others); Thu, 16 Jul 2020 03:52:24 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:44798 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725867AbgGPHwY (ORCPT ); Thu, 16 Jul 2020 03:52:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594885942; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u05tKeUEsAaeYGPCQa0ls+uddt7PTxRvgt5ZWaTMPQo=; b=UrLlztx0U+FjvxZZB80rSUpbgEoucONh4bt/jpaqFKvHDouRWtf+HxClB4iM1JwDYPv5I8 ehoxGa4j8nnasR80FwBcCaAIRderKL6d7NkbFB3aOwRQ0LNZnFk6EnknV9gucnAY9bBNp4 uhQPuE7Hv6cL8wG4f4hs71IFpmm7QT4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-425-Xb-UOX7jPue6gqhzV6DN-Q-1; Thu, 16 Jul 2020 03:52:19 -0400 X-MC-Unique: Xb-UOX7jPue6gqhzV6DN-Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B41DBC746A; Thu, 16 Jul 2020 07:52:17 +0000 (UTC) Received: from [10.36.115.54] (ovpn-115-54.ams2.redhat.com [10.36.115.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CC70C1002391; Thu, 16 Jul 2020 07:52:15 +0000 (UTC) Subject: Re: [PATCH v4 3/7] iommu/vt-d: Fix PASID devTLB invalidation To: Jacob Pan , iommu@lists.linux-foundation.org, LKML , Lu Baolu , Joerg Roedel , David Woodhouse Cc: Yi Liu , "Tian, Kevin" , Raj Ashok References: <1594080774-33413-1-git-send-email-jacob.jun.pan@linux.intel.com> <1594080774-33413-4-git-send-email-jacob.jun.pan@linux.intel.com> From: Auger Eric Message-ID: Date: Thu, 16 Jul 2020 09:52:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <1594080774-33413-4-git-send-email-jacob.jun.pan@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacob, On 7/7/20 2:12 AM, Jacob Pan wrote: > 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") > Acked-by: Lu Baolu > Signed-off-by: Jacob Pan Reviewed-by: Eric Auger sent on v3. Thanks Eric > --- > 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, >