From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH v4] xen/passthrough: Support a single iommu_domain per xen domain per SMMU Date: Tue, 31 Mar 2015 12:14:02 +0100 Message-ID: <1427800442.2115.76.camel@citrix.com> References: <1427230099-9115-1-git-send-email-robert.vanvossen@dornerworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Ycu7S-0007zX-Tu for xen-devel@lists.xenproject.org; Tue, 31 Mar 2015 11:14:07 +0000 In-Reply-To: <1427230099-9115-1-git-send-email-robert.vanvossen@dornerworks.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Robbie VanVossen Cc: julien.grall@citrix.com, xen-devel@lists.xenproject.org, edgar.iglesias@xilinx.com, Josh.Whitehead@dornerworks.com, Stefano.Stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org On Tue, 2015-03-24 at 16:48 -0400, Robbie VanVossen wrote: > If multiple devices are being passed through to the same domain and they > share a single SMMU, then they only require a single iommu_domain. > > In arm_smmu_assign_dev, before a new iommu_domain is created, the > xen_domain->contexts is checked for any iommu_domains that are already > assigned to device that uses the same SMMU as the current device. If one > is found, attach the device to that iommu_domain. If a new one isn't > found, create a new iommu_domain just like before. > > The arm_smmu_deassign_dev function assumes that there is a single > device per iommu_domain. This meant that when the first device was > deassigned, the iommu_domain was freed and when another device was > deassigned a crash occurred in xen. > > To fix this, a reference counter was added to the iommu_domain struct. > When an arm_smmu_xen_device references an iommu_domain, the > iommu_domains ref is incremented. When that reference is removed, the > iommu_domains ref is decremented. The iommu_domain will only be freed > when the ref is 0. > > Signed-off-by: Robbie VanVossen > Reviewed-by: Julien Grall I was expecting this to come back in a new version of Julien's passthrough series, but Julien prodded me to say that this patch didn't actually have any dependency/interaction with his passthrough series like I thought, so it can go in now. So Acked + applied, sorry for the delay.