From: Thomas Gleixner <tglx@linutronix.de>
To: Stanimir Varbanov <svarbanov@suse.de>,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rpi-kernel@lists.infradead.org, linux-pci@vger.kernel.org,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>
Cc: Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Jim Quinlan <jim2101024@gmail.com>,
Nicolas Saenz Julienne <nsaenz@kernel.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Lorenzo Pieralisi <lpieralisi@kernel.org>,
kw@linux.com, Philipp Zabel <p.zabel@pengutronix.de>,
Andrea della Porta <andrea.porta@suse.com>,
Phil Elwell <phil@raspberrypi.com>,
Jonathan Bell <jonathan@raspberrypi.com>,
Stanimir Varbanov <svarbanov@suse.de>
Subject: Re: [PATCH v4 03/10] irqchip: Add Broadcom bcm2712 MSI-X interrupt controller
Date: Mon, 28 Oct 2024 21:06:45 +0100 [thread overview]
Message-ID: <87ttcw0z6y.ffs@tglx> (raw)
In-Reply-To: <20241025124515.14066-4-svarbanov@suse.de>
On Fri, Oct 25 2024 at 15:45, Stanimir Varbanov wrote:
> Add an interrupt controller driver for MSI-X Interrupt Peripheral (MIP)
> hardware block found in bcm2712. The interrupt controller is used to
> handle MSI-X interrupts from peripherials behind PCIe endpoints like
> RP1 south bridge found in RPi5.
>
> There are two MIPs on bcm2712, the first has 64 consecutive SPIs
> assigned to 64 output vectors, and the second has 17 SPIs, but only
> 8 of them are consecutive starting at the 8th output vector.
This starts to converge nicely. Just a few remaining nitpicks.
> +static int mip_alloc_hwirq(struct mip_priv *mip, unsigned int nr_irqs,
> + unsigned int *hwirq)
> +{
> + int bit;
> +
> + spin_lock(&mip->lock);
> + bit = bitmap_find_free_region(mip->bitmap, mip->num_msis,
> + ilog2(nr_irqs));
> + spin_unlock(&mip->lock);
This should be
scoped_guard(spinlock, &mip->lock)
bit = bitmap_find_free_region(mip->bitmap, mip->num_msis, ilog2(nr_irqs));
> + if (bit < 0)
> + return bit;
> +
> + if (hwirq)
> + *hwirq = bit;
But what's the point of this conditional? The only call site hands in a
valid pointer, no?
> + return 0;
And therefore the whole thing can be simplified to:
static int mip_alloc_hwirq(struct mip_priv *mip, unsigned int nr_irqs)
{
guard(spinlock)(&mip_lock);
return bitmap_find_free_region(mip->bitmap, mip->num_msis, ilog2(nr_irqs));
}
and the callsite becomes:
irq = mip_alloc_hwirq(mip, nr_irqs);
if (irq < 0)
return irq;
Hmm?
> +}
> +
> +static void mip_free_hwirq(struct mip_priv *mip, unsigned int hwirq,
> + unsigned int nr_irqs)
> +{
> + spin_lock(&mip->lock);
guard(spinlock)(&mip->lock);
> + bitmap_release_region(mip->bitmap, hwirq, ilog2(nr_irqs));
> + spin_unlock(&mip->lock);
> +}
> + ret = irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, &fwspec);
> + if (ret) {
> + mip_free_hwirq(mip, irq, nr_irqs);
> + return ret;
goto err_free_hwirq; ?
> + }
> +
> + for (i = 0; i < nr_irqs; i++) {
> + irqd = irq_domain_get_irq_data(domain->parent, virq + i);
> + irqd->chip->irq_set_type(irqd, IRQ_TYPE_EDGE_RISING);
> +
> + ret = irq_domain_set_hwirq_and_chip(domain, virq + i, hwirq + i,
> + &mip_middle_irq_chip, mip);
> + if (ret)
> + goto err_free;
> +
> + irqd = irq_get_irq_data(virq + i);
> + irqd_set_single_target(irqd);
> + irqd_set_affinity_on_activate(irqd);
> + }
> +
> + return 0;
> +
> +err_free:
> + irq_domain_free_irqs_parent(domain, virq, nr_irqs);
> + mip_free_hwirq(mip, irq, nr_irqs);
> + return ret;
> +}
> +
> +static int __init mip_of_msi_init(struct device_node *node,
> + struct device_node *parent)
No line break required here.
> +{
> + struct platform_device *pdev;
> + struct mip_priv *mip;
> + int ret;
> +
> + pdev = of_find_device_by_node(node);
> + of_node_put(node);
> + if (!pdev)
> + return -EPROBE_DEFER;
> +
> + mip = kzalloc(sizeof(*mip), GFP_KERNEL);
> + if (!mip)
> + return -ENOMEM;
> +
> + spin_lock_init(&mip->lock);
> + mip->dev = &pdev->dev;
> +
> + ret = mip_parse_dt(mip, node);
> + if (ret)
> + goto err_priv;
> +
> + mip->base = of_iomap(node, 0);
> + if (!mip->base) {
> + ret = -ENXIO;
> + goto err_priv;
> + }
> +
> + mip->bitmap = bitmap_zalloc(mip->num_msis, GFP_KERNEL);
> + if (!mip->bitmap) {
> + ret = -ENOMEM;
> + goto err_base;
> + }
> +
> + /*
> + * All MSI-X masked in for the host, masked out for the
> + * VPU, and edge-triggered.
> + */
> + writel(0, mip->base + MIP_INT_MASKL_HOST);
> + writel(0, mip->base + MIP_INT_MASKH_HOST);
> + writel(~0, mip->base + MIP_INT_MASKL_VPU);
> + writel(~0, mip->base + MIP_INT_MASKH_VPU);
> + writel(~0, mip->base + MIP_INT_CFGL_HOST);
> + writel(~0, mip->base + MIP_INT_CFGH_HOST);
What undoes that in case mpi_init_domains() fails? Or is it harmless? I
really have no idea what masked in and masked out means here.
> + dev_dbg(&pdev->dev,
> + "MIP: MSI-X count: %u, base: %u, offset: %u, msg_addr: %llx\n",
Please move the string up. You have 100 characters width available.
> + mip->num_msis, mip->msi_base, mip->msi_offset, mip->msg_addr);
Thanks,
tglx
next prev parent reply other threads:[~2024-10-28 20:08 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 12:45 [PATCH v4 00/10] Add PCIe support for bcm2712 Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 01/10] dt-bindings: interrupt-controller: Add bcm2712 MSI-X DT bindings Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 02/10] dt-bindings: PCI: brcmstb: Update bindings for PCIe on bcm2712 Stanimir Varbanov
2024-10-25 21:55 ` Rob Herring
2024-10-25 12:45 ` [PATCH v4 03/10] irqchip: Add Broadcom bcm2712 MSI-X interrupt controller Stanimir Varbanov
2024-10-28 20:06 ` Thomas Gleixner [this message]
2024-11-01 13:15 ` Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 04/10] PCI: brcmstb: Reuse config structure Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 05/10] PCI: brcmstb: Expand inbound window size up to 64GB Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 06/10] PCI: brcmstb: Enable external MSI-X if available Stanimir Varbanov
2024-11-10 9:41 ` Stanimir Varbanov
2024-12-11 20:01 ` James Quinlan
2024-12-18 14:54 ` Stanimir Varbanov
2024-12-18 16:20 ` Jim Quinlan
2024-10-25 12:45 ` [PATCH v4 07/10] PCI: brcmstb: Add bcm2712 support Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 08/10] PCI: brcmstb: Adjust PHY PLL setup to use a 54MHz input refclk Stanimir Varbanov
2024-10-25 22:08 ` Florian Fainelli
2024-12-09 22:52 ` James Quinlan
2024-12-10 13:42 ` Stanimir Varbanov
2024-12-11 19:39 ` James Quinlan
2024-12-11 20:54 ` Jonathan Bell
2024-12-12 13:48 ` Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 09/10] arm64: dts: broadcom: bcm2712: Add PCIe DT nodes Stanimir Varbanov
2024-10-25 12:45 ` [PATCH v4 10/10] arm64: dts: broadcom: bcm2712-rpi-5-b: Enable " Stanimir Varbanov
2024-12-23 16:35 ` [PATCH v4 00/10] Add PCIe support for bcm2712 Olivier Benjamin
2025-01-21 15:01 ` Stanimir Varbanov
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=87ttcw0z6y.ffs@tglx \
--to=tglx@linutronix.de \
--cc=andrea.porta@suse.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bhelgaas@google.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=florian.fainelli@broadcom.com \
--cc=jim2101024@gmail.com \
--cc=jonathan@raspberrypi.com \
--cc=krzk+dt@kernel.org \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=lpieralisi@kernel.org \
--cc=nsaenz@kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=phil@raspberrypi.com \
--cc=robh@kernel.org \
--cc=svarbanov@suse.de \
/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.