Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3658793ybg; Mon, 28 Oct 2019 16:46:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzXZe+nJNA5lFQu4mSbh3mJxvUZxVAR2GMf1sQYkWBF2JkipczzmYzg0EO5j6ZqreCRsHV4 X-Received: by 2002:a17:906:f1d0:: with SMTP id gx16mr509607ejb.62.1572306360248; Mon, 28 Oct 2019 16:46:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572306360; cv=none; d=google.com; s=arc-20160816; b=Ji3Jw0KJL4Mx72qGgya8X9vRXFFHUs8YTDu7Xw+N2BHUj6gPL+ZA3iF4CRRd/07ekO VKBt0FnBhjL7UnsCjj9GL57BVuzm6kcaliKod3loPhDUzJg1GP7Wtpi3kfvPTHk8EUw1 5DwIrKqE2gN/Pmn7ZxAqU8ibuWtFxmEl0stYa11pkddBDkEtWGXOuIW3RgKAvA72lCHf AvCrp8rQsTNgYe7diRRQloh2c5NjSws8SEiJ74YJGZw1g26+57cPJnjPRZlvpFaU5VzU aIluon76pi5q7eAy1QKOyyQ8XAM4R8IU50i94EPdvyjvcT0FEzwMxKC9s/H8TI0Ods99 nMXg== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=CtVcRBYCRAmdMA9WANApdfd9G9yzIzyykZkcaoEwkes=; b=fTBuRH2aY0cr0tWoUJ6TnJbPfQCkwOmJWd5pPUIMZEPGQKn2eXBCXrttC7yWcgky9l XgyNFY96t6QFBghgr18bn28F4C2VMehRKRNG/+ueyiBMQ2X6UvnyX8CUrq2IW89WMANz gHDH+d91qqxug0pd2KtwoZU1TY365UaQwjHCM4H5mZojrWLXpKcxwYYMtxL+sspgtWUC WVSETdxIBjyJYn7eZ3qujHRZAuxiBKvt2aj7Xx0zPJh1jB3b5bDySJCvr1NkhPLg8nEG tFkgCZ6Cq2t16jvAo6AB5gyCnYzPlBzRHjrZMKoBq/m8rcxApQjsv7EcjeRAEKAuAKRK OeDQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s28si5904448edc.98.2019.10.28.16.45.37; Mon, 28 Oct 2019 16:46:00 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729212AbfJ1WhR (ORCPT + 99 others); Mon, 28 Oct 2019 18:37:17 -0400 Received: from mga14.intel.com ([192.55.52.115]:30465 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728648AbfJ1WhR (ORCPT ); Mon, 28 Oct 2019 18:37:17 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Oct 2019 15:37:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,241,1569308400"; d="scan'208";a="203399122" Received: from jacob-builder.jf.intel.com (HELO jacob-builder) ([10.7.199.155]) by orsmga006.jf.intel.com with ESMTP; 28 Oct 2019 15:37:16 -0700 Date: Mon, 28 Oct 2019 15:41:40 -0700 From: Jacob Pan To: "Tian, Kevin" Cc: "iommu@lists.linux-foundation.org" , LKML , Joerg Roedel , "David Woodhouse" , Alex Williamson , Jean-Philippe Brucker , "Liu, Yi L" , "Raj, Ashok" , Christoph Hellwig , Lu Baolu , Jonathan Cameron , Eric Auger , jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v7 06/11] iommu/vt-d: Avoid duplicated code for PASID setup Message-ID: <20191028154140.313a1fe9@jacob-builder> In-Reply-To: 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> Organization: OTC X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 25 Oct 2019 06:42:54 +0000 "Tian, Kevin" wrote: > > From: Jacob Pan [mailto:jacob.jun.pan@linux.intel.com] > > Sent: Friday, October 25, 2019 3:55 AM > > > > After each setup for PASID entry, related translation caches must be > > flushed. > > We can combine duplicated code into one function which is less error > > prone. > > > > Signed-off-by: Jacob Pan > > similarly, it doesn't need to be in this series. Technically true, it is in this series so that we can use the combined function. > > > --- > > drivers/iommu/intel-pasid.c | 48 > > +++++++++++++++++--------------------------- - > > 1 file changed, 18 insertions(+), 30 deletions(-) > > > > 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, > > devtlb_invalidation_with_pasid(iommu, dev, pasid); > > } > > > > +static void pasid_flush_caches(struct intel_iommu *iommu, > > + struct pasid_entry *pte, > > + int pasid, u16 did) > > +{ > > + if (!ecap_coherent(iommu->ecap)) > > + clflush_cache_range(pte, sizeof(*pte)); > > + > > + if (cap_caching_mode(iommu->cap)) { > > + pasid_cache_invalidation_with_pasid(iommu, did, > > pasid); > > + iotlb_invalidation_with_pasid(iommu, did, pasid); > > + } else { > > + iommu_flush_write_buffer(iommu); > > + } > > +} > > + > > /* > > * 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, > > /* Setup Present and PASID Granular Transfer Type: */ > > pasid_set_translation_type(pte, 1); > > pasid_set_present(pte); > > - > > - if (!ecap_coherent(iommu->ecap)) > > - clflush_cache_range(pte, sizeof(*pte)); > > - > > - if (cap_caching_mode(iommu->cap)) { > > - pasid_cache_invalidation_with_pasid(iommu, did, > > pasid); > > - iotlb_invalidation_with_pasid(iommu, did, pasid); > > - } else { > > - iommu_flush_write_buffer(iommu); > > - } > > + pasid_flush_caches(iommu, pte, pasid, did); > > > > return 0; > > } > > @@ -603,16 +609,7 @@ int intel_pasid_setup_second_level(struct > > intel_iommu *iommu, > > */ > > pasid_set_sre(pte); > > pasid_set_present(pte); > > - > > - if (!ecap_coherent(iommu->ecap)) > > - clflush_cache_range(pte, sizeof(*pte)); > > - > > - if (cap_caching_mode(iommu->cap)) { > > - pasid_cache_invalidation_with_pasid(iommu, did, > > pasid); > > - iotlb_invalidation_with_pasid(iommu, did, pasid); > > - } else { > > - iommu_flush_write_buffer(iommu); > > - } > > + pasid_flush_caches(iommu, pte, pasid, did); > > > > return 0; > > } > > @@ -646,16 +643,7 @@ int intel_pasid_setup_pass_through(struct > > intel_iommu *iommu, > > */ > > pasid_set_sre(pte); > > pasid_set_present(pte); > > - > > - if (!ecap_coherent(iommu->ecap)) > > - clflush_cache_range(pte, sizeof(*pte)); > > - > > - if (cap_caching_mode(iommu->cap)) { > > - pasid_cache_invalidation_with_pasid(iommu, did, > > pasid); > > - iotlb_invalidation_with_pasid(iommu, did, pasid); > > - } else { > > - iommu_flush_write_buffer(iommu); > > - } > > + pasid_flush_caches(iommu, pte, pasid, did); > > > > return 0; > > } > > -- > > 2.7.4 > [Jacob Pan]