All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolai Buchwitz <nb@tipi-net.de>
To: Thomas Gleixner <tglx@kernel.org>
Cc: Radu Rendec <radu@rendec.net>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Florian Fainelli <florian.fainelli@broadcom.com>,
	Broadcom internal kernel review list
	<bcm-kernel-feedback-list@broadcom.com>,
	Stanimir Varbanov <svarbanov@suse.de>,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	Jonathan Bell <jonathan@raspberrypi.com>,
	Stefan Wahren <wahrenst@gmx.net>
Subject: Re: [PATCH 2/3] irqchip/bcm2712-mip: Support multiple MSI ranges
Date: Fri, 04 Dec 2026 21:16:17 +0100	[thread overview]
Message-ID: <237a3034c656b213b93c0b66f519d2a1@tipi-net.de> (raw)
In-Reply-To: <87cxrgn83r.ffs@fw13>

On 4.12.2026 20:44, Thomas Gleixner wrote:
> On Wed, Dec 02 2026 at 11:12, Nicolai Buchwitz wrote:
>>  /**
>>   * struct mip_priv - MSI-X interrupt controller data
>>   * @lock:	Used to protect bitmap alloc/free
>>   * @base:	Base address of MMIO area
>>   * @msg_addr:	PCIe MSI-X address
>> - * @msi_base:	MSI base
>> + * @parent_irqs:	GIC SPI numbers indexed by MIP message data
> 
> Please realign these entries so they are all tabular.
> 
>>   * @num_msis:	Count of MSIs
>>   * @msi_offset:	MSI offset
>>   * @bitmap:	A bitmap for hwirqs
> 
>> @@ -96,7 +97,7 @@ static int mip_middle_domain_alloc(struct irq_domain 
>> *domain, unsigned int virq,
>>  {
>>  	struct mip_priv *mip = domain->host_data;
>>  	struct irq_fwspec fwspec = {0};
>> -	unsigned int hwirq, i;
>> +	unsigned int hwirq, i, allocated = 0;
> 
> Reverse fir tree order. See
> 
>   https://docs.kernel.org/process/maintainer-tip.html
> 
>>  	struct irq_data *irqd;
>>  	int irq, ret;
>> 
>> @@ -104,21 +105,24 @@ static int mip_middle_domain_alloc(struct 
>> irq_domain *domain, unsigned int virq,
>>  	if (irq < 0)
>>  		return irq;
>> 
>> -	hwirq = irq + mip->msi_offset;
>> +	hwirq = irq;
>> 
>>  	fwspec.fwnode = domain->parent->fwnode;
>>  	fwspec.param_count = 3;
>>  	fwspec.param[0] = 0;
>> -	fwspec.param[1] = hwirq + mip->msi_base;
>>  	fwspec.param[2] = IRQ_TYPE_EDGE_RISING;
>> 
>> -	ret = irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, &fwspec);
>> -	if (ret)
>> -		goto err_free_hwirq;
>> -
>>  	for (i = 0; i < nr_irqs; i++) {
>> +		fwspec.param[1] = mip->parent_irqs[hwirq + i];
>> +		ret = irq_domain_alloc_irqs_parent(domain, virq + i, 1, &fwspec);
>> +		if (ret)
>> +			goto err_free;
>> +		allocated++;
>> +
>>  		irqd = irq_domain_get_irq_data(domain->parent, virq + i);
>> -		irqd->chip->irq_set_type(irqd, IRQ_TYPE_EDGE_RISING);
>> +		ret = irqd->chip->irq_set_type(irqd, IRQ_TYPE_EDGE_RISING);
>> +		if (ret)
>> +			goto err_free;
>> 
>>  		ret = irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq + i,
>>  						    &mip_middle_irq_chip, mip);
>> @@ -133,8 +137,8 @@ static int mip_middle_domain_alloc(struct 
>> irq_domain *domain, unsigned int virq,
>>  	return 0;
>> 
>>  err_free:
>> -	irq_domain_free_irqs_parent(domain, virq, nr_irqs);
>> -err_free_hwirq:
>> +	if (allocated)
>> +		irq_domain_free_irqs_parent(domain, virq, allocated);
>>  	mip_free_hwirq(mip, irq, nr_irqs);
>>  	return ret;
>>  }
>> @@ -152,7 +156,7 @@ static void mip_middle_domain_free(struct 
>> irq_domain *domain, unsigned int virq,
>>  	mip = irq_data_get_irq_chip_data(irqd);
>>  	hwirq = irqd_to_hwirq(irqd);
>>  	irq_domain_free_irqs_parent(domain, virq, nr_irqs);
>> -	mip_free_hwirq(mip, hwirq - mip->msi_offset, nr_irqs);
>> +	mip_free_hwirq(mip, hwirq, nr_irqs);
>>  }
>> 
>>  static const struct irq_domain_ops mip_middle_domain_ops = {
>> @@ -185,7 +189,7 @@ static int mip_init_domains(struct mip_priv *mip, 
>> struct device_node *np)
>>  		.fwnode		= of_fwnode_handle(np),
>>  		.ops		= &mip_middle_domain_ops,
>>  		.host_data	= mip,
>> -		.size		= mip->num_msis,
>> +		.size		= MIP_NUM_IRQS,
>>  		.parent		= mip->parent,
>>  		.dev		= mip->dev,
>>  	};
>> @@ -209,32 +213,59 @@ static int mip_init_domains(struct mip_priv 
>> *mip, struct device_node *np)
>>  static int mip_parse_dt(struct mip_priv *mip, struct device_node *np)
>>  {
>>  	struct of_phandle_args args;
>> +	struct irq_domain *parent;
>> +	u32 first, span, i, cells;
>>  	u64 size;
>> -	int ret;
>> +	int ret, count, range;
> 
> Please declare the variables which are only used in the for() loop in
> that scope and not here.
> 
>>  	ret = of_property_read_u32(np, "brcm,msi-offset", &mip->msi_offset);
>>  	if (ret)
>>  		mip->msi_offset = 0;
>> -
>> -	ret = of_parse_phandle_with_args(np, "msi-ranges", 
>> "#interrupt-cells",
>> -					 0, &args);
>> -	if (ret)
>> -		return ret;
>> -
>> -	ret = of_property_read_u32_index(np, "msi-ranges", args.args_count + 
>> 1,
>> -					 &mip->num_msis);
>> -	if (ret)
>> -		goto err_put;
>> +	if (mip->msi_offset >= MIP_NUM_IRQS)
>> +		return -EINVAL;
>> 
>>  	ret = of_property_read_reg(np, 1, &mip->msg_addr, &size);
>>  	if (ret)
>> -		goto err_put;
>> +		return ret;
>> 
>> -	mip->msi_base = args.args[1];
>> +	/* <&gic type spi flags span> per range */
>> +	count = of_property_count_u32_elems(np, "msi-ranges");
>> +	if (count <= 0 || count % 5)
>> +		return -EINVAL;
>> +	if (count > 5 && of_property_present(np, "brcm,msi-offset"))
>> +		return -EINVAL;
>> +
>> +	first = mip->msi_offset;
>> +	for (range = 0; range < count / 5; range++) {
> 
>   for (int range = 0; ....
> 
>> +		ret = of_parse_phandle_with_fixed_args(np, "msi-ranges", 4,
>> +						       range, &args);
>> +		if (ret)
>> +			return ret;
>> 
>> -	mip->parent = irq_find_host(args.np);
>> -	if (!mip->parent)
>> +		ret = of_property_read_u32(args.np, "#interrupt-cells", &cells);
>> +		if (ret)
>> +			goto err_put;
>>  		ret = -EINVAL;
>> +		span = args.args[3];
>> +		if (cells != 3 || args.args[0] != 0 ||
>> +		    args.args[2] != IRQ_TYPE_EDGE_RISING ||
>> +		    !span || span > MIP_NUM_IRQS - first)
>> +			goto err_put;
>> +
> 
> You have 100 characters. Please make it use of them
> 
> 
>> +		parent = irq_find_host(args.np);
>> +		if (!parent || (mip->parent && parent != mip->parent))
>> +			goto err_put;
>> +		mip->parent = parent;
>> +
>> +		/* The legacy offset shifts the SPI as well as the message data */
>> +		for (i = 0; i < span; i++)
>> +			mip->parent_irqs[first + i] = args.args[1] +
>> +						    mip->msi_offset + i;
> 
> See bracket rules in documentation.
> 
>> +		first += span;
>> +		of_node_put(args.np);
>> +	}
>> +	mip->num_msis = first - mip->msi_offset;
>> +	return 0;
>> 
>>  err_put:
>>  	of_node_put(args.np);
>> @@ -264,18 +295,20 @@ static int mip_msi_probe(struct platform_device 
>> *pdev, struct device_node *paren
>>  		goto err_priv;
>>  	}
>> 
>> -	mip->bitmap = bitmap_zalloc(mip->num_msis, GFP_KERNEL);
>> +	mip->bitmap = bitmap_alloc(MIP_NUM_IRQS, GFP_KERNEL);
>>  	if (!mip->bitmap) {
>>  		ret = -ENOMEM;
>>  		goto err_base;
>>  	}
>> +	bitmap_fill(mip->bitmap, MIP_NUM_IRQS);
>> +	bitmap_clear(mip->bitmap, mip->msi_offset, mip->num_msis);
> 
> That want's a comment.

Thanks, I will send a v2 with the style fixups + comment.

Regards
Nicolai

  reply	other threads:[~2026-12-04 20:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 10:12 [PATCH 0/3] irqchip/bcm2712-mip: Expose all 20 MIP1 outputs Nicolai Buchwitz
2026-12-02 10:12 ` [PATCH 1/3] dt-bindings: interrupt-controller: brcm,bcm2712-msix: Allow multiple ranges Nicolai Buchwitz
2026-12-02 10:12 ` [PATCH 2/3] irqchip/bcm2712-mip: Support multiple MSI ranges Nicolai Buchwitz
2026-12-04 19:44   ` Thomas Gleixner
2026-12-04 20:16     ` Nicolai Buchwitz [this message]
2026-12-02 10:12 ` [PATCH 3/3] arm64: dts: broadcom: bcm2712: Expose all 20 MIP1 outputs Nicolai Buchwitz

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=237a3034c656b213b93c0b66f519d2a1@tipi-net.de \
    --to=nb@tipi-net.de \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=florian.fainelli@broadcom.com \
    --cc=jonathan@raspberrypi.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=radu@rendec.net \
    --cc=robh@kernel.org \
    --cc=svarbanov@suse.de \
    --cc=tglx@kernel.org \
    --cc=wahrenst@gmx.net \
    /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.