[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] xen/arm: smmuv3: Advertise coherent table walk if supported


  • To: Michal Orzel <michal.orzel@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Ayan Kumar Halder <ayankuma@xxxxxxx>
  • Date: Mon, 15 May 2023 09:59:33 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mPLfuueglwoWf/gPGAQD/6AZ90RyjyMYCgwMF7EXa1k=; b=eKWNl/mYIjywH2vBXvCxueER1XBYG/tna9OnK1ytXJveEiGUss8AvM4CaTSyolv8eL3vTWHeImrPPqrI9d9vTJlmg0Q3wWhsFTSUOYLm7KYQsG/KpoxaY5O6Hi6KyO8NwhOtjI3rPE1RjArg7DX6m0HHMl3zPg59W+hvVyOvcoDArZ9X8xFII1CPD/dOVP/2w3Zyjg/8KqifVMbIuSMnGIm02eLVCrTAvhbD0z6JmHR9PxFIgUtS8RIo3k0hMC4067CSyTKzYjCHCpFVmHBLuFqe6PJQQ95dNgCOYcuKwP4NR3GfYFwSXXrfDInr1dCZNKk9a+HRArC2EO7GHMWe6Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bn3oFdHk/e0wMMmgEjnVBUyRO7MO9SszVsu+RZqaZBBPAsEBacUJuHqn6s8SYQAd3FZWPrLLc49iHezb5ZTnbnuSnzmCQt7LQNtlWPiCXLbET68uH80KfdlWayOO1OYJ87d2QMo4AEf2QBjGb85kjOBF+XEYmthX3uNVZu7PH20aB3LbLa39qqHoGSOhLnNT7Bhf6G6pUtWo22B/iLinsAsSOrhE0O/39i09MJDLvI+zsFYTWBatYtAure60c4R5ZZbT+HbS+Cf/WQ3of1bm0AIhgnzSX9cqBCEvmHJJseA5BMaXbz4Lby49K0i1Q97l7wcNvHfzrJQZCpBHrORCzA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 15 May 2023 08:59:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 15/05/2023 07:46, Michal Orzel wrote:
Hi Ayan,
Hi Michal,

On 12/05/2023 18:59, Ayan Kumar Halder wrote:
Hi Michal,

On 12/05/2023 15:35, Michal Orzel wrote:
At the moment, even in case of a SMMU being I/O coherent, we clean the
updated PT as a result of not advertising the coherency feature. SMMUv3
coherency feature means that page table walks, accesses to memory
structures and queues are I/O coherent (refer ARM IHI 0070 E.A, 3.15).

Follow the same steps that were done for SMMU v1,v2 driver by the commit:
080dcb781e1bc3bb22f55a9dfdecb830ccbabe88

The same restrictions apply, meaning that in order to advertise coherent
table walk platform feature, all the SMMU devices need to report coherency
feature. This is because the page tables (we are sharing them with CPU)
are populated before any device assignment and in case of a device being
behind non-coherent SMMU, we would have to scan the tables and clean
the cache.

It is to be noted that the SBSA/BSA (refer ARM DEN0094C 1.0C, section D)
requires that all SMMUv3 devices support I/O coherency.

Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
Reviewed-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
---
There are very few platforms out there with SMMUv3 but I have never seen
a SMMUv3 that is not I/O coherent.
---
   xen/drivers/passthrough/arm/smmu-v3.c | 24 +++++++++++++++++++++++-
   1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/passthrough/arm/smmu-v3.c 
b/xen/drivers/passthrough/arm/smmu-v3.c
index bf053cdb6d5c..2adaad0fa038 100644
--- a/xen/drivers/passthrough/arm/smmu-v3.c
+++ b/xen/drivers/passthrough/arm/smmu-v3.c
@@ -2526,6 +2526,15 @@ static const struct dt_device_match arm_smmu_of_match[] 
= {
   };
/* Start of Xen specific code. */
+
+/*
+ * Platform features. It indicates the list of features supported by all
+ * SMMUs. Actually we only care about coherent table walk, which in case of
+ * SMMUv3 is implied by the overall coherency feature (refer ARM IHI 0070 E.A,
+ * section 3.15 and SMMU_IDR0.COHACC bit description).
+ */
+static uint32_t platform_features = ARM_SMMU_FEAT_COHERENCY;
+
   static int __must_check arm_smmu_iotlb_flush_all(struct domain *d)
   {
        struct arm_smmu_xen_domain *xen_domain = dom_iommu(d)->arch.priv;
@@ -2708,8 +2717,12 @@ static int arm_smmu_iommu_xen_domain_init(struct domain 
*d)
        INIT_LIST_HEAD(&xen_domain->contexts);
dom_iommu(d)->arch.priv = xen_domain;
-       return 0;
+ /* Coherent walk can be enabled only when all SMMUs support it. */
+       if (platform_features & ARM_SMMU_FEAT_COHERENCY)
+               iommu_set_feature(d, IOMMU_FEAT_COHERENT_WALK);
+
+       return 0;
   }
All good till here.
   static void arm_smmu_iommu_xen_domain_teardown(struct domain *d)
@@ -2738,6 +2751,7 @@ static __init int arm_smmu_dt_init(struct dt_device_node 
*dev,
                                const void *data)
   {
        int rc;
+       const struct arm_smmu_device *smmu;
/*
         * Even if the device can't be initialized, we don't want to
@@ -2751,6 +2765,14 @@ static __init int arm_smmu_dt_init(struct dt_device_node 
*dev,
iommu_set_ops(&arm_smmu_iommu_ops); + /* Find the just added SMMU and retrieve its features. */
+       smmu = arm_smmu_get_by_dev(dt_to_dev(dev));
+
+       /* It would be a bug not to find the SMMU we just added. */
+       BUG_ON(!smmu);
+
+       platform_features &= smmu->features;
+
Can you explain this change in the commit message ?
I think it is already explained by saying that in order to advertise the 
*platform* feature, all
SMMUs need to report it. If at least one doesn't, the feature is disabled. This 
is exactly
what this line is doing. It is comparing platform features with a just probed 
SMMU features (arm_smmu_dt_init()
is called for each SMMU).
All good.

~Michal



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.