All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@kernel.org>
To: Alexander Wilhelm <alexander.wilhelm@westermo.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC 1/2] irqchip/ls-scfg-msi: refactor allocation to bitmap_find_free_region()
Date: Mon, 20 Jul 2026 11:34:14 +0200	[thread overview]
Message-ID: <87ik6angx5.ffs@fw13> (raw)
In-Reply-To: <20260716-irqchip-ls-scfg-msi-add-multi-msi-support-v1-1-9795356d0ebc@westermo.com>

On Thu, Jul 16 2026 at 12:15, Alexander Wilhelm wrote:
> Replace the manual find_first_zero_bit()/__set_bit() pair with
> bitmap_find_free_region(), and __clear_bit() with bitmap_release_region().

Please don't enumerate WHAT the patch is doing. Explain context, problem
and solution in that order:

  https://docs.kernel.org/process/maintainer-tip.html#changelog

> @@ -141,28 +141,32 @@ static int ls_scfg_msi_domain_irq_alloc(struct irq_domain *domain,
>  {
>  	msi_alloc_info_t *info = args;
>  	struct ls_scfg_msi *msi_data = domain->host_data;
> -	int pos, err = 0;
> +	int order = get_count_order(nr_irqs);
> +	int pos, err;
> +	unsigned int i;

See the variable declaration chapter in the documentation above.

>  	WARN_ON(nr_irqs != 1);
>  
>  	spin_lock(&msi_data->lock);
> -	pos = find_first_zero_bit(msi_data->used, msi_data->irqs_num);
> -	if (pos < msi_data->irqs_num)
> -		__set_bit(pos, msi_data->used);
> -	else
> -		err = -ENOSPC;
> +	pos = bitmap_find_free_region(msi_data->used, msi_data->irqs_num,
> +				      order);
>  	spin_unlock(&msi_data->lock);

Please convert this to

	scoped_guard(spinlock, &msi_data->lock)
		pos = bitmap_find_free_region(msi_data->used, msi_data->irqs_num, order);

No line break required. You have 100 characters. 
  
> -	if (err)
> -		return err;
> +	if (pos < 0)
> +		return pos;
>  
>  	err = iommu_dma_prepare_msi(info->desc, msi_data->msiir_addr);
> -	if (err)
> +	if (err) {
> +		spin_lock(&msi_data->lock);
> +		bitmap_release_region(msi_data->used, pos, order);
> +		spin_unlock(&msi_data->lock);

scoped_guard() please

>  		return err;
> +	}
>  
> -	irq_domain_set_info(domain, virq, pos,
> -			    &ls_scfg_msi_parent_chip, msi_data,
> -			    handle_simple_irq, NULL, NULL);
> +	for (i = 0; i < nr_irqs; i++)
> +		irq_domain_set_info(domain, virq + i, pos + i,
> +				    &ls_scfg_msi_parent_chip, msi_data,
> +				    handle_simple_irq, NULL, NULL);
>  

Lacks brackets. See bracket rules in documentation.

>  	return 0;
>  }
> @@ -172,16 +176,18 @@ static void ls_scfg_msi_domain_irq_free(struct irq_domain *domain,
>  {
>  	struct irq_data *d = irq_domain_get_irq_data(domain, virq);
>  	struct ls_scfg_msi *msi_data = irq_data_get_irq_chip_data(d);
> +	int order = get_count_order(nr_irqs);
>  	int pos;
>  
>  	pos = d->hwirq;
> -	if (pos < 0 || pos >= msi_data->irqs_num) {
> -		pr_err("failed to teardown msi. Invalid hwirq %d\n", pos);
> +	if (pos < 0 || pos + nr_irqs > msi_data->irqs_num) {
> +		pr_err("failed to teardown msi. Invalid hwirq %d nr %u\n",
> +		       pos, nr_irqs);

No line break required.

>  		return;
>  	}
>  
>  	spin_lock(&msi_data->lock);
> -	__clear_bit(pos, msi_data->used);
> +	bitmap_release_region(msi_data->used, pos, order);
>  	spin_unlock(&msi_data->lock);
>  }

Thanks,

        tglx

  reply	other threads:[~2026-07-20  9:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16 10:14 [PATCH RFC 0/2] irqchip/ls-scfg-msi: add multi-MSI support Alexander Wilhelm
2026-07-16 10:15 ` [PATCH RFC 1/2] irqchip/ls-scfg-msi: refactor allocation to bitmap_find_free_region() Alexander Wilhelm
2026-07-20  9:34   ` Thomas Gleixner [this message]
2026-07-16 10:15 ` [PATCH RFC 2/2] irqchip/ls-scfg-msi: enable multi-MSI allocation Alexander Wilhelm
2026-07-20  9:41   ` Thomas Gleixner

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=87ik6angx5.ffs@fw13 \
    --to=tglx@kernel.org \
    --cc=alexander.wilhelm@westermo.com \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.