[PATCH] xen/arm: smmuv1: Switch from kzalloc_array(..) to devm_kcalloc(..)

Rahul Singh posted 1 patch 2 years, 9 months ago
Test gitlab-ci failed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/2c611dec5f1dbd6040d7a37d2d72ad2fc66e113f.1625568432.git.rahul.singh@arm.com
xen/drivers/passthrough/arm/smmu.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[PATCH] xen/arm: smmuv1: Switch from kzalloc_array(..) to devm_kcalloc(..)
Posted by Rahul Singh 2 years, 9 months ago
Switch from kzalloc_array(..) to devm_kcalloc(..) when allocating the
SMR to make code coherent.

Signed-off-by: Rahul Singh <rahul.singh@arm.com>
---
 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 da2cd457d7..658c40433c 100644
--- a/xen/drivers/passthrough/arm/smmu.c
+++ b/xen/drivers/passthrough/arm/smmu.c
@@ -149,7 +149,8 @@ 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)
+#define devm_kcalloc(dev, n, size, flags)			\
+	_xzalloc_array(size, sizeof(void *), n)
 
 static void __iomem *devm_ioremap_resource(struct device *dev,
 					   struct resource *res)
@@ -2222,7 +2223,8 @@ 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 = kzalloc_array(sizeof(*smmu->smrs), size, GFP_KERNEL);
+		smmu->smrs = devm_kcalloc(smmu->dev, size, sizeof(*smmu->smrs),
+								GFP_KERNEL);
 		if (!smmu->smrs)
 			return -ENOMEM;
 
-- 
2.17.1


Re: [PATCH] xen/arm: smmuv1: Switch from kzalloc_array(..) to devm_kcalloc(..)
Posted by Bertrand Marquis 2 years, 9 months ago
Hi Rahul,

> On 6 Jul 2021, at 11:53, Rahul Singh <Rahul.Singh@arm.com> wrote:
> 
> Switch from kzalloc_array(..) to devm_kcalloc(..) when allocating the
> SMR to make code coherent.
> 
> Signed-off-by: Rahul Singh <rahul.singh@arm.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>

Cheers
Bertrand

> ---
> 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 da2cd457d7..658c40433c 100644
> --- a/xen/drivers/passthrough/arm/smmu.c
> +++ b/xen/drivers/passthrough/arm/smmu.c
> @@ -149,7 +149,8 @@ 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)
> +#define devm_kcalloc(dev, n, size, flags)			\
> +	_xzalloc_array(size, sizeof(void *), n)
> 
> static void __iomem *devm_ioremap_resource(struct device *dev,
> 					   struct resource *res)
> @@ -2222,7 +2223,8 @@ 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 = kzalloc_array(sizeof(*smmu->smrs), size, GFP_KERNEL);
> +		smmu->smrs = devm_kcalloc(smmu->dev, size, sizeof(*smmu->smrs),
> +								GFP_KERNEL);
> 		if (!smmu->smrs)
> 			return -ENOMEM;
> 
> -- 
> 2.17.1
> 


Re: [PATCH] xen/arm: smmuv1: Switch from kzalloc_array(..) to devm_kcalloc(..)
Posted by Julien Grall 2 years, 9 months ago
Hi Rahul,

On 06/07/2021 11:53, Rahul Singh wrote:
> Switch from kzalloc_array(..) to devm_kcalloc(..) when allocating the
> SMR to make code coherent.
> 
> Signed-off-by: Rahul Singh <rahul.singh@arm.com>

Acked-by: Julien Grall <jgrall@amazon.com>

Cheers,

-- 
Julien Grall

Re: [PATCH] xen/arm: smmuv1: Switch from kzalloc_array(..) to devm_kcalloc(..)
Posted by Julien Grall 2 years, 9 months ago

On 07/07/2021 14:07, Julien Grall wrote:
> Hi Rahul,
> 
> On 06/07/2021 11:53, Rahul Singh wrote:
>> Switch from kzalloc_array(..) to devm_kcalloc(..) when allocating the
>> SMR to make code coherent.
>>
>> Signed-off-by: Rahul Singh <rahul.singh@arm.com>
> 
> Acked-by: Julien Grall <jgrall@amazon.com>

And committed.

Cheers,

-- 
Julien Grall