mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lu Baolu <baolu.lu@linux.intel.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	dwmw2@infradead.org, joro@8bytes.org, will@kernel.org
Cc: baolu.lu@linux.intel.com, iommu@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] iommu/vt-d: Use bitmap_zalloc() when applicable
Date: Sat, 18 Dec 2021 13:56:09 +0800	[thread overview]
Message-ID: <73bdc4a3-6028-2ab5-f9a6-dbad15effad4@linux.intel.com> (raw)
In-Reply-To: <367914663187b8fe043e31b352cd6ad836088f0a.1639778255.git.christophe.jaillet@wanadoo.fr>

On 2021/12/18 5:58, Christophe JAILLET wrote:
> 'ommu->domain_ids' is a bitmap. So use 'bitmap_zalloc()' to simplify
> code and improve the semantic, instead of hand writing it.
> 
> Also change the corresponding 'kfree()' into 'bitmap_free()' to keep
> consistency.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>   drivers/iommu/intel/iommu.c | 9 ++++-----
>   1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index b6a8f3282411..4acc97765209 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -1878,17 +1878,16 @@ static void iommu_disable_translation(struct intel_iommu *iommu)
>   
>   static int iommu_init_domains(struct intel_iommu *iommu)
>   {
> -	u32 ndomains, nlongs;
> +	u32 ndomains;
>   	size_t size;
>   
>   	ndomains = cap_ndoms(iommu->cap);
>   	pr_debug("%s: Number of Domains supported <%d>\n",
>   		 iommu->name, ndomains);
> -	nlongs = BITS_TO_LONGS(ndomains);
>   
>   	spin_lock_init(&iommu->lock);
>   
> -	iommu->domain_ids = kcalloc(nlongs, sizeof(unsigned long), GFP_KERNEL);
> +	iommu->domain_ids = bitmap_zalloc(ndomains, GFP_KERNEL);
>   	if (!iommu->domain_ids)
>   		return -ENOMEM;
>   
> @@ -1903,7 +1902,7 @@ static int iommu_init_domains(struct intel_iommu *iommu)
>   	if (!iommu->domains || !iommu->domains[0]) {
>   		pr_err("%s: Allocating domain array failed\n",
>   		       iommu->name);
> -		kfree(iommu->domain_ids);
> +		bitmap_free(iommu->domain_ids);
>   		kfree(iommu->domains);
>   		iommu->domain_ids = NULL;
>   		iommu->domains    = NULL;
> @@ -1964,7 +1963,7 @@ static void free_dmar_iommu(struct intel_iommu *iommu)
>   		for (i = 0; i < elems; i++)
>   			kfree(iommu->domains[i]);
>   		kfree(iommu->domains);
> -		kfree(iommu->domain_ids);
> +		bitmap_free(iommu->domain_ids);
>   		iommu->domains = NULL;
>   		iommu->domain_ids = NULL;
>   	}

This patch has been merged to Joerg's tree through

https://lore.kernel.org/linux-iommu/20211217083817.1745419-2-baolu.lu@linux.intel.com/

Are there any extra changes in this one?

Best regards,
baolu

  reply	other threads:[~2021-12-18  5:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-17 21:58 Christophe JAILLET
2021-12-18  5:56 ` Lu Baolu [this message]
2021-12-18  6:55   ` Christophe JAILLET
  -- strict thread matches above, loose matches on Subject: below --
2021-10-23 19:49 Christophe JAILLET

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=73bdc4a3-6028-2ab5-f9a6-dbad15effad4@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®