From patchwork Fri Jan 30 18:49:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 44048 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 1B74F20CA8 for ; Fri, 30 Jan 2015 18:51:50 +0000 (UTC) Received: by mail-wi0-f200.google.com with SMTP id fb4sf3379169wid.3 for ; Fri, 30 Jan 2015 10:51:49 -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=D1HzHyFo2nYGRgfqMYm8toG1WB2y+HLFiZTQGQ0B7Tg=; b=GJW8KT9yuwk5j0aE0BXW0mUbDy063BRfTc4t3daMwSoMy0OpeU2BT0ESJdgf7+q7Nw Z3EoXDx2yh7QFGBxVuhRwjbSpuddgxoRbecx3VLB7XWqcT5VBkfxZ+GFXs7Y4BwQ/qdV rCohQegLbE0teXC48s5cWOzM4mW8iRzZp+7AKCRuJ99NO81baH8Dmx/lPMP9Y2iQApAM 1BTQsi3+Rc+j5ovRGEn6uZzA8rO1OL3sYxyVneFe6YJgbCfgyjwqDCKCaxGsj6nGFG/2 bqE7jn6vOdgzf4L6sVGoRSJfQgP8/+BOLzpRllEveZczowbmJJKp91ZkXlNXBt9qGp2d poWw== X-Gm-Message-State: ALoCoQkJKL2bMgZlK1y374nxTjsnJqLX5LhahrxNeB5Qb8bjN9i9ZqARooawb0xkBNeDto+ET/C8 X-Received: by 10.180.105.129 with SMTP id gm1mr19517wib.3.1422643909421; Fri, 30 Jan 2015 10:51:49 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.6 with SMTP id x6ls471832lag.70.gmail; Fri, 30 Jan 2015 10:51:49 -0800 (PST) X-Received: by 10.152.30.6 with SMTP id o6mr8167623lah.64.1422643909191; Fri, 30 Jan 2015 10:51:49 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id es2si10709917lbb.114.2015.01.30.10.51.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 30 Jan 2015 10:51:49 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id hs14so25212879lab.9 for ; Fri, 30 Jan 2015 10:51:49 -0800 (PST) X-Received: by 10.152.245.44 with SMTP id xl12mr7934140lac.81.1422643909076; Fri, 30 Jan 2015 10:51:49 -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 h5csp377646lbj; Fri, 30 Jan 2015 10:51:48 -0800 (PST) X-Received: by 10.220.166.77 with SMTP id l13mr4012812vcy.26.1422643907254; Fri, 30 Jan 2015 10:51:47 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id di5si5285821vdc.71.2015.01.30.10.51.46 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 30 Jan 2015 10:51:47 -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 1YHGe6-0007Il-Ui; Fri, 30 Jan 2015 18:50:22 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YHGe4-0007GA-Qy for xen-devel@lists.xenproject.org; Fri, 30 Jan 2015 18:50:21 +0000 Received: from [193.109.254.147] by server-14.bemta-14.messagelabs.com id 4F/07-02753-B62DBC45; Fri, 30 Jan 2015 18:50:19 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-13.tower-27.messagelabs.com!1422643819!11884492!1 X-Originating-IP: [74.125.82.178] 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 22725 invoked from network); 30 Jan 2015 18:50:19 -0000 Received: from mail-we0-f178.google.com (HELO mail-we0-f178.google.com) (74.125.82.178) by server-13.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 30 Jan 2015 18:50:19 -0000 Received: by mail-we0-f178.google.com with SMTP id k48so28751352wev.9 for ; Fri, 30 Jan 2015 10:50:18 -0800 (PST) X-Received: by 10.180.198.209 with SMTP id je17mr183109wic.17.1422643818872; Fri, 30 Jan 2015 10:50:18 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id n1sm169040wib.11.2015.01.30.10.50.17 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Jan 2015 10:50:18 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Fri, 30 Jan 2015 18:49:28 +0000 Message-Id: <1422643768-23614-14-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1422643768-23614-1-git-send-email-julien.grall@linaro.org> References: <1422643768-23614-1-git-send-email-julien.grall@linaro.org> Cc: stefano.stabellini@citrix.com, Julien Grall , tim@xen.org, ian.campbell@citrix.com Subject: [Xen-devel] [PATCH v3 13/13] 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.50 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 v3: - Patch added --- xen/drivers/passthrough/arm/smmu.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c index 373eee8..f4c7e49 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -577,6 +577,13 @@ struct arm_smmu_domain { spinlock_t lock; }; +/* + * Xen: Platform features. It indicates the list of features support by all the + * SMMUs. + * Actually we only care about coherent table walk. + */ +static u32 platform_features = ARM_SMMU_FEAT_COHERENT_WALK; + /* Xen: Dummy iommu_domain */ struct iommu_domain { @@ -2810,6 +2817,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; } @@ -2885,6 +2899,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 @@ -2896,6 +2911,16 @@ static __init int arm_smmu_dt_init(struct dt_device_node *dev, if ( !rc ) iommu_set_ops(&arm_smmu_iommu_ops); + /* + * The last added SMMU is the first element of arm_smmu_devices. + * It's not necessary to take the lock because only the boot CPU is + * initialized the SMMU devices. + */ + smmu = list_entry(arm_smmu_devices.next, typeof(*smmu), list); + ASSERT(smmu != NULL); + + platform_features &= smmu->features; + return rc; }