Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@kernel.org>
To: Ghennadi Procopciuc via B4 Relay
	<devnull+ghennadi.procopciuc.oss.nxp.com@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Rob Herring <robh@kernel.org>, Frank Li <Frank.Li@nxp.com>,
	Conor Dooley <conor+dt@kernel.org>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>,
	imx@lists.linux.dev, devicetree@vger.kernel.org,
	NXP S32 Linux Team <s32@nxp.com>,
	linux-kernel@vger.kernel.org, Fabio Estevam <festevam@gmail.com>,
	Radu Rendec <radu@rendec.net>,
	linux-arm-kernel@lists.infradead.org, echanude@redhat.com,
	clizzi@redhat.com, aruizrui@redhat.com,
	ghennadi.procopciuc@oss.nxp.com, eballetb@redhat.com
Subject: Re: [PATCH 2/6] irqchip: Add NXP S32N79 MRU MSI controller driver
Date: Fri, 04 Dec 2026 20:26:05 +0100	[thread overview]
Message-ID: <87fqwcn8z6.ffs@fw13> (raw)
In-Reply-To: <20261204-b4-s32n79-mru-msi-v1-2-e66f9b0dfa79@oss.nxp.com>

On Fri, Dec 04 2026 at 14:56, Ghennadi Procopciuc via wrote:
> +
> +struct mru_msi;
> +
> +struct mru {
> +	struct mru_msi *priv;
> +	void __iomem *base;
> +	phys_addr_t addr;
> +	unsigned int index;
> +	int irq;
> +};
> +
> +struct mru_msi {
> +	struct irq_domain *domain;
> +	unsigned long *chans_bitmap;
> +	struct device *dev;
> +	struct mru *mrus;
> +	unsigned int nmrus;
> +	unsigned int nchans;
> +};

Please read and follow:

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

Especially struct definitions and bracket rules. Also you have 100
characters so please get rid of pointless line breaks.

> +/*
> + * The chained handler clears the status of the channel before it dispatches
> + * the vector. The vector can run later on another CPU, and by then the next
> + * message must be able to raise the SPI again. The flow handler of the device
> + * domain still needs an irq_ack() to call.
> + */
> +static void mru_msi_irq_ack(struct irq_data *d)
> +{
> +}

It's amazing how much comment an empty callback needs. The two lines of
code doing the ACK in the callback wouldn't need any and would actually
do it in the right context :)

> +static void mru_msi_compose_msg(struct irq_data *d, struct msi_msg *msg)
> +{
> +	struct mru_msi *priv = irq_data_get_irq_chip_data(d);
> +
> +	msi_msg_set_addr(irq_data_get_msi_desc(d), msg,
> +			 mru_mailbox_phys(priv, d->hwirq));
> +	msg->data = 0;
> +}
> +
> +static const struct irq_chip mru_msi_parent_chip = {
> +	.name			= "MRU",
> +	.irq_ack		= mru_msi_irq_ack,
> +	.irq_compose_msi_msg	= mru_msi_compose_msg,
> +#ifdef CONFIG_SMP
> +	.irq_set_affinity	= irq_chip_redirect_set_affinity,
> +#endif
> +};

As there are no mask/unmask callbacks, this relies fully on the device
MSI implementation to provide them. MSI-X must provide masking, but MSI
does not, which can be a real pain as you have no way to prevent an
interrupt storm from a malfunctioning device.

Aside of that usually the on-SOC registers are faster to access than the
PCI registers for masking. MSI_FLAG_PCI_MSI_MASK_PARENT makes this work
so that only on startup/shutdown the masking happens at the PCI device
level, but run-time mask/unmask goes to the parent domain chip.

Just a hint. I personally don't care about debugging an interrupt storm
on your SoC :)

> +static void mru_msi_irq_handler(struct irq_desc *desc)
> +{
> +	struct mru *mru = irq_desc_get_handler_data(desc);
> +	struct irq_chip *chip = irq_desc_get_chip(desc);
> +	struct mru_msi *priv = mru->priv;
> +	unsigned int chan, pos;
> +
> +	chained_irq_enter(chip, desc);

guard_chained_irq()

> +	for (chan = 0; chan < MRU_CHANS_PER_MRU; chan++) {
> +		void __iomem *mbstat = mru->base + chan * MRU_CH_STRIDE +
> +				       MRU_CH_MBSTAT;
> +
> +		if (!(readl(mbstat) & MRU_MBSTAT_MBS0))
> +			continue;
> +
> +		writel(MRU_MBSTAT_MBS0, mbstat);
> +
> +		pos = mru_mru2pos(priv, mru->index, chan);
> +		if (!generic_handle_demux_domain_irq(priv->domain, pos))
> +			dev_err_ratelimited(priv->dev,
> +					    "unexpected message on MRU%u channel %u\n",
> +					    mru->index, chan);

That message is nice, but that happens when an interrupt is not
mapped. But what masks the interrupt channel?

Thanks,

        tglx

  parent reply	other threads:[~2026-12-04 19:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 12:56 [PATCH 0/6] irqchip: Add NXP S32N79 MRU MSI controller Ghennadi Procopciuc via B4 Relay
2026-12-04 12:56 ` [PATCH 1/6] dt-bindings: interrupt-controller: " Ghennadi Procopciuc via B4 Relay
2026-12-04 13:21   ` sashiko-bot
2026-12-04 12:56 ` [PATCH 2/6] irqchip: Add NXP S32N79 MRU MSI controller driver Ghennadi Procopciuc via B4 Relay
2026-12-04 13:56   ` sashiko-bot
2026-12-04 17:51   ` Frank Li
2026-12-04 19:26   ` Thomas Gleixner [this message]
2026-12-04 12:56 ` [PATCH 3/6] MAINTAINERS: Add entry for " Ghennadi Procopciuc via B4 Relay
2026-12-04 12:56 ` [PATCH 4/6] arm64: dts: s32n79: add MRU MSI controller node Ghennadi Procopciuc via B4 Relay
2026-12-04 14:04   ` sashiko-bot
2026-12-04 12:56 ` [PATCH 5/6] arm64: dts: s32n79-rdb: enable the MRU MSI controller Ghennadi Procopciuc via B4 Relay
2026-12-04 12:56 ` [PATCH 6/6] arm64: dts: s32n79: route the NETC IEP18 MSIs to the MRU Ghennadi Procopciuc via B4 Relay

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=87fqwcn8z6.ffs@fw13 \
    --to=tglx@kernel.org \
    --cc=Frank.Li@nxp.com \
    --cc=aruizrui@redhat.com \
    --cc=clizzi@redhat.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=devnull+ghennadi.procopciuc.oss.nxp.com@kernel.org \
    --cc=eballetb@redhat.com \
    --cc=echanude@redhat.com \
    --cc=festevam@gmail.com \
    --cc=ghennadi.procopciuc@oss.nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=radu@rendec.net \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=s32@nxp.com \
    /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