From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756629AbdJJWHR (ORCPT ); Tue, 10 Oct 2017 18:07:17 -0400 Received: from mga09.intel.com ([134.134.136.24]:5907 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753507AbdJJWHQ (ORCPT ); Tue, 10 Oct 2017 18:07:16 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,359,1503385200"; d="scan'208";a="145013637" Date: Tue, 10 Oct 2017 15:09:53 -0700 From: Jacob Pan To: Joerg Roedel Cc: iommu@lists.linux-foundation.org, LKML , David Woodhouse , Greg Kroah-Hartman , Rafael Wysocki , Jean-Philippe Brucker , "Liu, Yi L" , Lan Tianyu , "Tian, Kevin" , Raj Ashok , Alex Williamson , "Liu, Yi L" , Liu@8bytes.org, jacob.jun.pan@linux.intel.com Subject: Re: [PATCH v2 03/16] iommu: introduce iommu invalidate API function Message-ID: <20171010150953.4095a045@jacob-builder> In-Reply-To: <20171010133542.juag7cwbivlb56sl@8bytes.org> References: <1507244624-39189-1-git-send-email-jacob.jun.pan@linux.intel.com> <1507244624-39189-4-git-send-email-jacob.jun.pan@linux.intel.com> <20171010133542.juag7cwbivlb56sl@8bytes.org> 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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 10 Oct 2017 15:35:42 +0200 Joerg Roedel wrote: > On Thu, Oct 05, 2017 at 04:03:31PM -0700, Jacob Pan wrote: > > +int iommu_invalidate(struct iommu_domain *domain, > > + struct device *dev, struct tlb_invalidate_info > > *inv_info) > > This name is way too generic, it should at least be called > iommu_svm_invalidate() or something like that. With the name above it > is easily confused with the other TLB invalidation functions of the > IOMMU-API. > Good point. I was calling it iommu_passdown_invalidate() originally. The invalidation request comes from guest or user space instead of in-kernel unmap kind of calls. > > +enum iommu_inv_granularity { > > + IOMMU_INV_GRANU_GLOBAL, /* all TLBs > > invalidated */ > > Is that needed? We certainly don't want to give userspace/guests that > fine-grained control about IOMMU cache invalidations. > > In the end a guest issues flush-global command does not translate to a > flush-global on the host, but to separate flushes for the domains the > guest uses. > Right, guest should not go beyond its own domain. > > + IOMMU_INV_GRANU_DOMAIN, /* all TLBs > > associated with a domain */ > > + IOMMU_INV_GRANU_DEVICE, /* caching > > structure associated with a > > + * device ID > > What is the difference between a DOMAIN and a DEVICE flush? > Those are based on vt-d context cache flush granularity, domain selective flushes all context caches associated with a domain ID. Device selective flush flushes context caches of a source ID. But like you pointed out below, since context cache flush will come in as unbind call, there is no need to do passdown invalidate. I can remove that. Here I am trying to use all generic definitions, which is a superset of all vendor models. I am likely missing out some non-vt-d cases. > > + IOMMU_INV_GRANU_DOMAN_PAGE, /* address range with a > > domain */ > > + IOMMU_INV_GRANU_ALL_PASID, /* cache of a given > > PASID */ > > + IOMMU_INV_GRANU_PASID_SEL, /* only invalidate > > specified PASID */ + > > + IOMMU_INV_GRANU_NG_ALL_PASID, /* non-global within > > all PASIDs */ > > + IOMMU_INV_GRANU_NG_PASID, /* non-global within a > > PASIDs */ > > + IOMMU_INV_GRANU_PAGE_PASID, /* page-selective > > within a PASID */ > > + IOMMU_INV_NR_GRANU, > > +}; > > + > > +enum iommu_inv_type { > > + IOMMU_INV_TYPE_DTLB, /* device IOTLB */ > > + IOMMU_INV_TYPE_TLB, /* IOMMU paging structure cache > > */ > > + IOMMU_INV_TYPE_PASID, /* PASID cache */ > > + IOMMU_INV_TYPE_CONTEXT, /* device context entry > > cache */ > > Is that really needed? When the guest updates it context-entry > equivalent it translates to bind_pasid_table/unbind_pasid_table calls, > no? > Right no need to passdown context cache invalidation for VT-d. I just wasn't sure it is the same for all models. Again, trying to have a superset of generic fields. Thanks! Jacob