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

[PATCH] arm/smmu: Complete SMR masking support


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Wed, 4 Sep 2024 14:43:49 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=t4aDycOgF3J4oZvhTiXzfFnja/EfK1sdRKYoPfoj2U4=; b=YrSbk0axl30XNbPpiBqlR088PKa3lU+uKWTsyfc/xguunrVCzOpsHS6S22My4hpj4jx+yZVc0mQ5FZt4yxQuoFCXOyIAIc3tBDOyepC5SkRF6Hor8nUUhjA3Kkl0tMbGX5Y4DBnBKlF45wQ5NUkg2CthCwjVTpB5IAO7QFQaXjJRXnIzU33z3dCi0HKRxbQQTtQIMmJVCqwOeg02kEruyN0PAyHhyU6MjG/wqPrNXYEBHu6Smqx5f3p6sPbTtj6gwD908uGIELF1Xg5C969BNohvERUT/HhWjjoAGhAoEc9bKZ1PNLhqL4sC90YDJj+iWxtBEahbftRXb42W128JGQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Wo8b01x2zTcBEkMyP0hHU3QnoKcJjtu1GfxQ13dTca+4hHM0iZbeua5J0SsKDLnZUhevLmtDYSHtZI4o/MXlP63l0ZDeF1rgZb9PvO8XiOziprzko/aD8rgi+W+RxL4aaa8fJz3pmKK6OCRbHSZFndjkguNTca4A6Gtxb8xAsGziLexemlfVdClCVBj7TRSCcRSqGC5OtX4m3ocxtYyJXMMVKk7vhZLz/fkIsW0jYrAHrT7PJpqS1TZ/pWCevvx/NhF+5bxUsGVOiUGN+vDC8gEwfiAqiW1+OYvSMceoCwOeeg7nG3wreqxzEPWOAej0Vz2+WgaR25e6yjO1Q0erCw==
  • Cc: Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, "Rahul Singh" <rahul.singh@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Wed, 04 Sep 2024 12:44:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

SMR masking support allows deriving a mask either using a 2-cell iommu
specifier (per master) or stream-match-mask SMMU dt property (global
config). Even though the mask is stored in the fwid when adding a
device (in arm_smmu_dt_xlate_generic()), we still set it to 0 when
allocating SMEs (in arm_smmu_master_alloc_smes()). So at the end, we
always ignore the mask when programming SMRn registers. This leads to
SMMU failures. Fix it by completing the support.

A bit of history:
Linux support for SMR allocation was mainly done with:
588888a7399d ("iommu/arm-smmu: Intelligent SMR allocation")
021bb8420d44 ("iommu/arm-smmu: Wire up generic configuration support")

Taking the mask into account in arm_smmu_master_alloc_smes() was added
as part of the second commit, although quite hidden in the thicket of
other changes. We backported only the first patch with: 0435784cc75d
("xen/arm: smmuv1: Intelligent SMR allocation") but the changes to take
the mask into account were missed.

Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
---
 xen/drivers/passthrough/arm/smmu.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/xen/drivers/passthrough/arm/smmu.c 
b/xen/drivers/passthrough/arm/smmu.c
index f2cee82f553a..4c8a446754cc 100644
--- a/xen/drivers/passthrough/arm/smmu.c
+++ b/xen/drivers/passthrough/arm/smmu.c
@@ -1619,19 +1619,21 @@ static int arm_smmu_master_alloc_smes(struct device 
*dev)
        spin_lock(&smmu->stream_map_lock);
        /* Figure out a viable stream map entry allocation */
        for_each_cfg_sme(cfg, i, idx, fwspec->num_ids) {
+               uint16_t mask = (fwspec->ids[i] >> SMR_MASK_SHIFT) & 
SMR_MASK_MASK;
+
                if (idx != INVALID_SMENDX) {
                        ret = -EEXIST;
                        goto out_err;
                }
 
-               ret = arm_smmu_find_sme(smmu, fwspec->ids[i], 0);
+               ret = arm_smmu_find_sme(smmu, fwspec->ids[i], mask);
                if (ret < 0)
                        goto out_err;
 
                idx = ret;
                if (smrs && smmu->s2crs[idx].count == 0) {
                        smrs[idx].id = fwspec->ids[i];
-                       smrs[idx].mask = 0; /* We don't currently share SMRs */
+                       smrs[idx].mask = mask;
                        smrs[idx].valid = true;
                }
                smmu->s2crs[idx].count++;
-- 
2.25.1




 


Rackspace

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