xen/arm: smmuv1: Fixed stream matching register allocation
authorRahul Singh <rahul.singh@arm.com>
Fri, 25 Jun 2021 16:37:26 +0000 (17:37 +0100)
committerStefano Stabellini <sstabellini@kernel.org>
Fri, 25 Jun 2021 21:53:48 +0000 (14:53 -0700)
SMR allocation should be based on the number of supported stream
matching register for each SMMU device.

Issue introduced by commit 5e08586afbb90b2e2d56c175c07db77a4afa873c
when backported the patches from Linux to XEN to fix the stream match
conflict issue when two devices have the same stream-id.

Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Tested-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Rahul Singh <rahul.singh@arm.com>
xen/drivers/passthrough/arm/smmu.c

index 1a68c2ab3bacf0e9f2f2ded31b9bcceb59ade763..05c2d238b3ed334cb781ab416dd9876946e77f10 100644 (file)
@@ -149,6 +149,7 @@ typedef enum irqreturn irqreturn_t;
 #define kzalloc(size, flags)           _xzalloc(size, sizeof(void *))
 #define devm_kzalloc(dev, size, flags) _xzalloc(size, sizeof(void *))
 #define kmalloc_array(size, n, flags)  _xmalloc_array(size, sizeof(void *), n)
+#define kzalloc_array(size, n, flags)  _xzalloc_array(size, sizeof(void *), n)
 
 static void __iomem *devm_ioremap_resource(struct device *dev,
                                           struct resource *res)
@@ -2221,7 +2222,7 @@ static int arm_smmu_device_cfg_probe(struct arm_smmu_device *smmu)
                smmu->smr_mask_mask = smr >> SMR_MASK_SHIFT;
 
                /* Zero-initialised to mark as invalid */
-               smmu->smrs = devm_kzalloc(smmu->dev, sizeof(*smmu->smrs), GFP_KERNEL);
+               smmu->smrs = kzalloc_array(sizeof(*smmu->smrs), size, GFP_KERNEL);
                if (!smmu->smrs)
                        return -ENOMEM;