|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] xen/passthrough: Support a single iommu_domain(context bank) per xen domain per SMMU
Hello Robert, Thank you for the patch. The commit title is too long (over 80 characters). On 19/03/2015 18:25, 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 occured 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 <robert.vanvossen@xxxxxxxxxxxxxxx> --- xen/drivers/passthrough/arm/smmu.c | 113 ++++++++++++++++++++++++++++-------- 1 file changed, 88 insertions(+), 25 deletions(-) diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c index a7a7da9..9b46054 100644 [..] I'd like to avoid modifying arm_smmu_attach_dev and arm_smmu_detach_dev as it's part of the Linux code. I think you can increment the reference counter in arm_smmu_assign_dev and arm_smmu_deassign_dev. That would avoid some possible race condition (see below). A general comment for coding style within this file. A line should not be more than 80 characters long. The insertion of a new iommu_domain is done after the device is attached, which is not protected by xen_domain->lock. Therefore it may be possible to end up with 2 iommu_domain on the same SMMU. The failure may be because we don't have any stream register available. So I don't think we should detach all the other devices within the same context.
if (!existing_ctx_fnd) {
[..]
There is a possible race with the previous function. arm_smmu_assign_dev still have time to increment domain->ref and we will free a domain with 1 device assigned. Overall, I think the 2 functions should be completely protected by the xen_domain->lock. Regards, -- Julien Grall _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |