Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp321007ybc; Tue, 12 Nov 2019 01:58:12 -0800 (PST) X-Google-Smtp-Source: APXvYqx0j3fkEvm/mOTnzwc1pYJroY5icyrhnTMd3gtjVRDWdcOXt+BzXCMRUm+mzEKtBzmc4ILU X-Received: by 2002:a17:906:3f8a:: with SMTP id b10mr6390257ejj.315.1573552692761; Tue, 12 Nov 2019 01:58:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573552692; cv=none; d=google.com; s=arc-20160816; b=wgEMnb+TnrEk4AcsHSJ50P4FJoCs4Z461fPB6gsyJMM2/v1Pp/k/8eOJHvZvCQHLhP TrmqNCWXGN9pj0o126jN+0E2t5eLL9Y6K7D0zU1s6whGwRjxEIiaSsVNrLZlIjpEktrH 8VbJp34UhMrEDdJBGXJofUKN3uhuJB7hrEmHvSZHRQGcr8YjZta7kgffGECJSGH7Hxqc AzZRVKsDCc9Ijrsyz0zGOZniA5sEubtOwkMgTvAFtTKlpehtgZBGAxumLmFveuHfwvpO bb65ytgowlgZ0bp33aSo6pUs1sy6/pXC/c9eNTKSiouh+gJDAvN0UjZB8R1KYpzIYrfx lInA== 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:references:cc:to:subject:from:dkim-signature; bh=AdBHFyhioxfCvrwsJAry/REnsYtBUierHYY+S1ZJ0LQ=; b=OJH0LoV9eKr4t111qAIHnT2cBamEEWAFCDpCpsH/bm+YyFxhtHnJmLTkNIKGbvDCc/ l5MzfXo76JaBvOXWTvSskLJF31SQzQ8EjBehJJftsbB7SJYMNQm/E4oDHNI7R7MHlbqy Q9HkzPRCGRV9XZEMPrCBIpDGIUEuAC43+ae6JlD2k9vjxE0xeElOtSE4VITy5IjKZopG gdsZHUE34LlXs+SJKwZkaeHzD1A+8Oks0vI8LRCcmZVyhiojn8DQeOnomdI0ibJAUrXt 75DLRaztUv77xZWXzOtIb2Rrci8XtzelfYSRd9hEpSnkb5R1ZRp8JVTxlsh7j2NrpEJg t/8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hKnWSFjv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id g19si107844edb.280.2019.11.12.01.57.48; Tue, 12 Nov 2019 01:58:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hKnWSFjv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727104AbfKLJzD (ORCPT + 99 others); Tue, 12 Nov 2019 04:55:03 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:35783 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726008AbfKLJzD (ORCPT ); Tue, 12 Nov 2019 04:55:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573552502; 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=AdBHFyhioxfCvrwsJAry/REnsYtBUierHYY+S1ZJ0LQ=; b=hKnWSFjvFfwUKEK3kqcI+JI4VUA9duvYB4BV1ZHDPXA3bdqZ9S8RaWVseLw72QJRSESHpA 8hedksMnD8C7OpkpCeYyb8c9baRP/KFje1iut0MuNFAjdH5S2uqrt2tKQMV7cjUdtNOODD AQgaBjKNaEShebVf+F6Ot+KAFezfTuU= 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-343-lS6wqL5ROSi5zE9pjn3Wyg-1; Tue, 12 Nov 2019 04:55:01 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A36B91800D63; Tue, 12 Nov 2019 09:54:59 +0000 (UTC) Received: from [10.36.116.54] (ovpn-116-54.ams2.redhat.com [10.36.116.54]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B35E061F58; Tue, 12 Nov 2019 09:54:53 +0000 (UTC) From: Auger Eric Subject: Re: [PATCH v7 06/11] iommu/vt-d: Avoid duplicated code for PASID setup To: Jacob Pan , iommu@lists.linux-foundation.org, LKML , Joerg Roedel , David Woodhouse , Alex Williamson , Jean-Philippe Brucker Cc: Yi Liu , "Tian, Kevin" , Raj Ashok , Christoph Hellwig , Lu Baolu , Jonathan Cameron References: <1571946904-86776-1-git-send-email-jacob.jun.pan@linux.intel.com> <1571946904-86776-7-git-send-email-jacob.jun.pan@linux.intel.com> Message-ID: <552c55f3-a8d6-10aa-5dbc-5b2c45ad90d0@redhat.com> Date: Tue, 12 Nov 2019 10:54:52 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <1571946904-86776-7-git-send-email-jacob.jun.pan@linux.intel.com> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: lS6wqL5ROSi5zE9pjn3Wyg-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacob, On 10/24/19 9:54 PM, Jacob Pan wrote: > After each setup for PASID entry, related translation caches must be flus= hed. > We can combine duplicated code into one function which is less error pron= e. >=20 > Signed-off-by: Jacob Pan > --- > drivers/iommu/intel-pasid.c | 48 +++++++++++++++++----------------------= ------ > 1 file changed, 18 insertions(+), 30 deletions(-) >=20 > diff --git a/drivers/iommu/intel-pasid.c b/drivers/iommu/intel-pasid.c > index e79d680fe300..ffbd416ed3b8 100644 > --- a/drivers/iommu/intel-pasid.c > +++ b/drivers/iommu/intel-pasid.c > @@ -485,6 +485,21 @@ void intel_pasid_tear_down_entry(struct intel_iommu = *iommu, > =09=09devtlb_invalidation_with_pasid(iommu, dev, pasid); > } > =20 > +static void pasid_flush_caches(struct intel_iommu *iommu, > +=09=09=09=09struct pasid_entry *pte, > +=09=09=09=09int pasid, u16 did) > +{ > +=09if (!ecap_coherent(iommu->ecap)) > +=09=09clflush_cache_range(pte, sizeof(*pte)); > + > +=09if (cap_caching_mode(iommu->cap)) { > +=09=09pasid_cache_invalidation_with_pasid(iommu, did, pasid); > +=09=09iotlb_invalidation_with_pasid(iommu, did, pasid); > +=09} else { > +=09=09iommu_flush_write_buffer(iommu); > +=09} > +} > + > /* > * Set up the scalable mode pasid table entry for first only > * translation type. > @@ -530,16 +545,7 @@ int intel_pasid_setup_first_level(struct intel_iommu= *iommu, > =09/* Setup Present and PASID Granular Transfer Type: */ > =09pasid_set_translation_type(pte, 1); > =09pasid_set_present(pte); > - > -=09if (!ecap_coherent(iommu->ecap)) > -=09=09clflush_cache_range(pte, sizeof(*pte)); > - > -=09if (cap_caching_mode(iommu->cap)) { > -=09=09pasid_cache_invalidation_with_pasid(iommu, did, pasid); > -=09=09iotlb_invalidation_with_pasid(iommu, did, pasid); > -=09} else { > -=09=09iommu_flush_write_buffer(iommu); > -=09} > +=09pasid_flush_caches(iommu, pte, pasid, did); > =20 > =09return 0; > } > @@ -603,16 +609,7 @@ int intel_pasid_setup_second_level(struct intel_iomm= u *iommu, > =09 */ > =09pasid_set_sre(pte); > =09pasid_set_present(pte); > - > -=09if (!ecap_coherent(iommu->ecap)) > -=09=09clflush_cache_range(pte, sizeof(*pte)); > - > -=09if (cap_caching_mode(iommu->cap)) { > -=09=09pasid_cache_invalidation_with_pasid(iommu, did, pasid); > -=09=09iotlb_invalidation_with_pasid(iommu, did, pasid); > -=09} else { > -=09=09iommu_flush_write_buffer(iommu); > -=09} > +=09pasid_flush_caches(iommu, pte, pasid, did); > =20 > =09return 0; > } > @@ -646,16 +643,7 @@ int intel_pasid_setup_pass_through(struct intel_iomm= u *iommu, > =09 */ > =09pasid_set_sre(pte); > =09pasid_set_present(pte); > - > -=09if (!ecap_coherent(iommu->ecap)) > -=09=09clflush_cache_range(pte, sizeof(*pte)); > - > -=09if (cap_caching_mode(iommu->cap)) { > -=09=09pasid_cache_invalidation_with_pasid(iommu, did, pasid); > -=09=09iotlb_invalidation_with_pasid(iommu, did, pasid); > -=09} else { > -=09=09iommu_flush_write_buffer(iommu); > -=09} > +=09pasid_flush_caches(iommu, pte, pasid, did); > =20 > =09return 0; > } >=20 Reviewed-by: Eric Auger Thanks Eric