From patchwork Tue Jan 13 14:25:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 43003 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f197.google.com (mail-we0-f197.google.com [74.125.82.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C6A4E20DE8 for ; Tue, 13 Jan 2015 14:28:11 +0000 (UTC) Received: by mail-we0-f197.google.com with SMTP id w61sf1857306wes.0 for ; Tue, 13 Jan 2015 06:28:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=NwHWk+mlHSza/rSElXyDM/9bz/kzA0WvZbYI8deOhBA=; b=Ccdfptitn0g/32L5tUH4yQEvGMjNwZSN5I2tILeDS+6w06yqsooa4rN3ZZ+EGG8wLo wlOceyLQes3dw6yq3Gv8BGZbTYFZR3ZaefZRSMDt1J+6vOemiGVDm3d3MiC0SfbZ4EiI LUx6mIuvN6lgCA1YggK5FVwk9oOxmeNnXDWRnan/pppMn05LMKoPqBgoyXSURpWPtbcw Vd+IdZ+62CNdqj4C6Wwpze4n9jGer99AeCyaxGxrBcEXmLeUWQrxfrXe0egJEtmAhRX2 5eefVO4v/NWRCF2VkZRiV4bbPX6e78cpJMAh7CQs4CMjG1AgLK5jO/Kbh6rJwpYcBXUD uPaA== X-Gm-Message-State: ALoCoQk6SKIj0CRvxKmm6d27VOHlSerkANDSio8kDGtrQ6RJ7fuT4+WUNaou4pj0tRfDIqkB/HvL X-Received: by 10.112.99.37 with SMTP id en5mr323450lbb.17.1421159291020; Tue, 13 Jan 2015 06:28:11 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.202 with SMTP id ao10ls523lac.59.gmail; Tue, 13 Jan 2015 06:28:10 -0800 (PST) X-Received: by 10.112.12.65 with SMTP id w1mr42340558lbb.68.1421159290706; Tue, 13 Jan 2015 06:28:10 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id ms6si24420291lbb.52.2015.01.13.06.28.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Jan 2015 06:28:10 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id z11so2826091lbi.6 for ; Tue, 13 Jan 2015 06:28:10 -0800 (PST) X-Received: by 10.112.104.4 with SMTP id ga4mr42438748lbb.24.1421159290583; Tue, 13 Jan 2015 06:28:10 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp1398834lbb; Tue, 13 Jan 2015 06:28:09 -0800 (PST) X-Received: by 10.220.71.20 with SMTP id f20mr21666952vcj.36.1421159278421; Tue, 13 Jan 2015 06:27:58 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id ei10si1121341vdc.44.2015.01.13.06.27.57 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 13 Jan 2015 06:27:58 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YB2Qo-0001al-DE; Tue, 13 Jan 2015 14:26:54 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YB2Ql-0001TN-3z for xen-devel@lists.xenproject.org; Tue, 13 Jan 2015 14:26:51 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 6A/09-05632-A2B25B45; Tue, 13 Jan 2015 14:26:50 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-9.tower-31.messagelabs.com!1421159209!15535293!1 X-Originating-IP: [209.85.212.172] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.5; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12196 invoked from network); 13 Jan 2015 14:26:49 -0000 Received: from mail-wi0-f172.google.com (HELO mail-wi0-f172.google.com) (209.85.212.172) by server-9.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 13 Jan 2015 14:26:49 -0000 Received: by mail-wi0-f172.google.com with SMTP id n3so21609289wiv.5 for ; Tue, 13 Jan 2015 06:26:49 -0800 (PST) X-Received: by 10.194.61.231 with SMTP id t7mr1742924wjr.33.1421159209447; Tue, 13 Jan 2015 06:26:49 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id ni15sm14513482wic.18.2015.01.13.06.26.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Jan 2015 06:26:48 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 13 Jan 2015 14:25:26 +0000 Message-Id: <1421159133-31526-18-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1421159133-31526-1-git-send-email-julien.grall@linaro.org> References: <1421159133-31526-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com, Jan Beulich Subject: [Xen-devel] [PATCH v3 17/24] xen/passthrough: arm: release earlier the DT devices assigned to a guest X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: The toolstack may not have deassign every device used by a guest. Therefore we have to go through the device list and removing them before asking the IOMMU drivers to release memory for this domain. This can be done by moving the call to the release function when we relinquish the resources. The IOMMU part will be destroyed later when the domain is freed. Signed-off-by: Julien Grall Cc: Jan Beulich --- Changes in v3: - Patch added. Superseed the patch "xen/passthrough: call arch_iommu_domain_destroy before calling iommu teardown" in the previous patch series. --- xen/arch/arm/domain.c | 4 ++++ xen/drivers/passthrough/arm/iommu.c | 1 - xen/drivers/passthrough/device_tree.c | 5 ++++- xen/include/xen/iommu.h | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 6e56665..d85748a 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -772,6 +772,10 @@ int domain_relinquish_resources(struct domain *d) switch ( d->arch.relmem ) { case RELMEM_not_started: + ret = iommu_release_dt_devices(d); + if ( ret ) + return ret; + d->arch.relmem = RELMEM_xen; /* Falltrough */ diff --git a/xen/drivers/passthrough/arm/iommu.c b/xen/drivers/passthrough/arm/iommu.c index 5870aef..8223a39 100644 --- a/xen/drivers/passthrough/arm/iommu.c +++ b/xen/drivers/passthrough/arm/iommu.c @@ -66,7 +66,6 @@ int arch_iommu_domain_init(struct domain *d) void arch_iommu_domain_destroy(struct domain *d) { - iommu_dt_domain_destroy(d); } int arch_iommu_populate_page_table(struct domain *d) diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c index 88e496e..e7eb34f 100644 --- a/xen/drivers/passthrough/device_tree.c +++ b/xen/drivers/passthrough/device_tree.c @@ -97,7 +97,7 @@ int iommu_dt_domain_init(struct domain *d) return 0; } -void iommu_dt_domain_destroy(struct domain *d) +int iommu_release_dt_devices(struct domain *d) { struct hvm_iommu *hd = domain_hvm_iommu(d); struct dt_device_node *dev, *_dev; @@ -109,5 +109,8 @@ void iommu_dt_domain_destroy(struct domain *d) if ( rc ) dprintk(XENLOG_ERR, "Failed to deassign %s in domain %u\n", dt_node_full_name(dev), d->domain_id); + return rc; } + + return 0; } diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index c146ee4..d03df14 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -117,7 +117,7 @@ void iommu_read_msi_from_ire(struct msi_desc *msi_desc, struct msi_msg *msg); int iommu_assign_dt_device(struct domain *d, struct dt_device_node *dev); int iommu_deassign_dt_device(struct domain *d, struct dt_device_node *dev); int iommu_dt_domain_init(struct domain *d); -void iommu_dt_domain_destroy(struct domain *d); +int iommu_release_dt_devices(struct domain *d); #endif /* HAS_DEVICE_TREE */