From patchwork Wed Feb 25 18:53:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 45105 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f200.google.com (mail-wi0-f200.google.com [209.85.212.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4586420502 for ; Wed, 25 Feb 2015 18:55:49 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id r20sf4929243wiv.3 for ; Wed, 25 Feb 2015 10:55:48 -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=3Eo3gwZUit4rVDxC472zVYBSvVK+e5fjrgBCfFDV/Tg=; b=aFDa+y5NeWvLGLS5LwCd698/WGn6PKLDaQQ0s39JKAKgSm2Az021DE8TZ1nxxMn0N4 vhUlDtrUIyZJe5+y0R56/WfDwtj/kMhcwNFsLSkANPB5SqOcEnyfVcAnF0u+V8RgrQDy adEFl11o91gKcEhNoruvlo48UB8C8sQqPsKgyvZraEXzUVrW7nLkhrynDT5wQasH4Ca+ oYS+wvd9UcP7xTJp8gZMV/qwYNyMn2pitSrdg/Z7Z6o4BU6ZpLwc8LKAVGyGbCj4rW3Q 7WgyB+ihgTRjl4WiYBAv46R/HukcPYgEyQ4qyP0dxAJnvFNqQjBw5Qo3rQbFZDP9o+pp BrKg== X-Gm-Message-State: ALoCoQlUzcTByY5wwRhwpBy7sn5esGGV8o3gs8e37Wx9KnH/sR0sFWzak6A5ePOFhiAH+1KXwK5y X-Received: by 10.194.161.194 with SMTP id xu2mr725795wjb.1.1424890548596; Wed, 25 Feb 2015 10:55:48 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.104 with SMTP id r8ls246037lar.48.gmail; Wed, 25 Feb 2015 10:55:47 -0800 (PST) X-Received: by 10.152.87.50 with SMTP id u18mr4191557laz.82.1424890547132; Wed, 25 Feb 2015 10:55:47 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id i7si23542844laf.49.2015.02.25.10.55.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Feb 2015 10:55:47 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by labgd6 with SMTP id gd6so6007209lab.7 for ; Wed, 25 Feb 2015 10:55:47 -0800 (PST) X-Received: by 10.152.116.18 with SMTP id js18mr4213051lab.106.1424890547032; Wed, 25 Feb 2015 10:55:47 -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.35.133 with SMTP id h5csp2819975lbj; Wed, 25 Feb 2015 10:55:46 -0800 (PST) X-Received: by 10.52.146.39 with SMTP id sz7mr5180639vdb.73.1424890545181; Wed, 25 Feb 2015 10:55:45 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id d6si6197999vda.74.2015.02.25.10.55.44 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 25 Feb 2015 10:55:45 -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 1YQh5f-0005uq-5t; Wed, 25 Feb 2015 18:53:47 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YQh5c-0005t9-Nz for xen-devel@lists.xenproject.org; Wed, 25 Feb 2015 18:53:44 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 57/8A-02991-83A1EE45; Wed, 25 Feb 2015 18:53:44 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-12.tower-31.messagelabs.com!1424890423!10930622!1 X-Originating-IP: [74.125.82.46] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4452 invoked from network); 25 Feb 2015 18:53:43 -0000 Received: from mail-wg0-f46.google.com (HELO mail-wg0-f46.google.com) (74.125.82.46) by server-12.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 25 Feb 2015 18:53:43 -0000 Received: by wggy19 with SMTP id y19so5516185wgg.13 for ; Wed, 25 Feb 2015 10:53:43 -0800 (PST) X-Received: by 10.194.77.230 with SMTP id v6mr9174172wjw.25.1424890423256; Wed, 25 Feb 2015 10:53:43 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id kr5sm61071839wjc.1.2015.02.25.10.53.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Feb 2015 10:53:42 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Wed, 25 Feb 2015 18:53:00 +0000 Message-Id: <1424890381-4225-8-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1424890381-4225-1-git-send-email-julien.grall@linaro.org> References: <1424890381-4225-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, manish.jaggi@caviumnetworks.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH v4 7/8] xen/iommu: smmu: Advertise when the SMMU support coherent table walk 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.215.51 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: When SMMU doesn't support coherent table walk, Xen may need to clean updated PT (see commit 4c5f4cb "xen/arm: p2m: Clean cache PT when the IOMMU doesn't support coherent walk"). If one SMMU of the platform doesn't support coherent table walk, the feature is disabled for the whole platform. This is because device is assigned to a domain after the page table are populated. This could impact performance on domain which doesn't use device passthrough. But, as the spec strongly recommends the support of this feature for maintstream platform, I expect server will always have SMMUs supporting coherent table walk. If not, we may need to enable this feature per-domain. Signed-off-by: Julien Grall --- I've just noticed that the support on the previous driver (i.e in Xen 4.5) may incorrectly expose this feature when all the SMMUs is not supporting coherent table walk. I'm not sure, if I should send a patch for it. Also I didn't squash this patch into "xen/iommu: smmu: Add Xen specific code to be able to use the driver" to help for review and to catch possible error in this patch. Changes in v4: - Browse the list to retrieve the last SMMU added. - Take the spinlock Changes in v3: - Patch added --- xen/drivers/passthrough/arm/smmu.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c index d01a26a..b478463 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -2531,6 +2531,13 @@ MODULE_LICENSE("GPL v2"); /* Xen only supports stage-2 translation, so force the value to 2. */ static int force_stage = 2; +/* + * Platform features. It indicates the list of features supported by all the + * SMMUs. + * Actually we only care about coherent table walk. + */ +static u32 platform_features = ARM_SMMU_FEAT_COHERENT_WALK; + static void arm_smmu_iotlb_flush_all(struct domain *d) { struct arm_smmu_xen_domain *smmu_domain = domain_hvm_iommu(d)->arch.priv; @@ -2668,6 +2675,13 @@ static int arm_smmu_iommu_domain_init(struct domain *d) domain_hvm_iommu(d)->arch.priv = xen_domain; + /* + * The feature coherent walk can be enabled only when all SMMUs + * support it. + */ + if (platform_features & ARM_SMMU_FEAT_COHERENT_WALK) + iommu_set_feature(d, IOMMU_FEAT_COHERENT_WALK); + return 0; } @@ -2742,6 +2756,7 @@ static __init int arm_smmu_dt_init(struct dt_device_node *dev, const void *data) { int rc; + struct arm_smmu_device *smmu; /* * Even if the device can't be initialized, we don't want to @@ -2755,6 +2770,20 @@ static __init int arm_smmu_dt_init(struct dt_device_node *dev, iommu_set_ops(&arm_smmu_iommu_ops); + /* Find the last SMMU added and retrieve its features. */ + spin_lock(&arm_smmu_devices_lock); + list_for_each_entry(smmu, &arm_smmu_devices, list) { + if (smmu->dev == &dev->dev) + goto found; + } + + BUG(); + +found: + platform_features &= smmu->features; + + spin_unlock(&arm_smmu_devices_lock); + return 0; }