From: Thomas Gleixner <tglx@linutronix.de>
To: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Magnus Damm <magnus.damm@gmail.com>,
Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com>
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH 2/4] irqchip: add RZ/{T2H,N2H} Interrupt Controller (ICU) driver
Date: Sat, 22 Nov 2025 16:55:36 +0100 [thread overview]
Message-ID: <87see6hxjb.ffs@tglx> (raw)
In-Reply-To: <20251121111423.1379395-3-cosmin-gabriel.tanislav.xa@renesas.com>
On Fri, Nov 21 2025 at 13:14, Cosmin Tanislav wrote:
> +static inline int rzt2h_icu_irq_to_offset(struct irq_data *d, void __iomem **base,
> + unsigned int *offset)
> +{
> + struct rzt2h_icu_priv *priv = irq_data_to_priv(d);
> + unsigned int hwirq = irqd_to_hwirq(d);
> +
> + if (RZT2H_ICU_IRQ_IN_RANGE(hwirq, IRQ_NS)) {
> + *offset = hwirq - RZT2H_ICU_IRQ_NS_START;
> + *base = priv->base_ns;
> + } else if (RZT2H_ICU_IRQ_IN_RANGE(hwirq, IRQ_S) ||
> + /* SEI follows safety IRQs in registers and in IRQ numbers. */
> + RZT2H_ICU_IRQ_IN_RANGE(hwirq, SEI)) {
This nested commend in the condition is really unreadable.
> + *offset = hwirq - RZT2H_ICU_IRQ_S_START;
> + *base = priv->base_s;
> + } else {
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> +static int rzt2h_icu_irq_set_type(struct irq_data *d, unsigned int type)
> +{
> + struct rzt2h_icu_priv *priv = irq_data_to_priv(d);
> + unsigned int parent_type;
> + unsigned int offset;
Combine same data types into one line please.
> + void __iomem *base;
> + u32 val, md;
> + int ret;
> + guard(raw_spinlock)(&priv->lock);
> + val = readl_relaxed(base + RZT2H_ICU_PORTNF_MD);
> + val &= ~RZT2H_ICU_PORTNF_MDi_MASK(offset);
> + val |= RZT2H_ICU_PORTNF_MDi_PREP(offset, md);
> + writel_relaxed(val, base + RZT2H_ICU_PORTNF_MD);
> +
This looks wrong. guard() holds the lock across the set_parent()
call. If you really need that then this needs a comment explaining the
why. Otherwise use scoped_guard().
> + return irq_chip_set_type_parent(d, parent_type);
> +}
> +static const struct irq_chip rzt2h_icu_chip = {
> + .name = "rzt2h-icu",
> + .irq_mask = irq_chip_mask_parent,
> + .irq_unmask = irq_chip_unmask_parent,
> + .irq_eoi = irq_chip_eoi_parent,
> + .irq_set_type = rzt2h_icu_set_type,
> + .irq_set_wake = irq_chip_set_wake_parent,
> + .irq_set_affinity = irq_chip_set_affinity_parent,
> + .irq_retrigger = irq_chip_retrigger_hierarchy,
> + .irq_get_irqchip_state = irq_chip_get_parent_state,
> + .irq_set_irqchip_state = irq_chip_set_parent_state,
> + .flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_SET_TYPE_MASKED |
> + IRQCHIP_SKIP_SET_WAKE,
https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#struct-declarations-and-initializers
And please read and follow the rest of the documentation too.
> +};
> +
> +static int rzt2h_icu_alloc(struct irq_domain *domain, unsigned int virq,
> + unsigned int nr_irqs, void *arg)
> +{
> + struct rzt2h_icu_priv *priv = domain->host_data;
> + irq_hw_number_t hwirq;
> + unsigned int type;
> + int ret;
> +
> + ret = irq_domain_translate_twocell(domain, arg, &hwirq, &type);
> + if (ret)
> + return ret;
> +
> + ret = irq_domain_set_hwirq_and_chip(domain, virq, hwirq, &rzt2h_icu_chip,
> + NULL);
Get rid of the line breaks all over the place. You have 100 characters.
> + if (ret)
> + return ret;
> +
> + return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs,
> + &priv->fwspec[hwirq]);
> +}
> +static int rzt2h_icu_init(struct platform_device *pdev,
> + struct device_node *parent)
> +{
> + struct irq_domain *irq_domain, *parent_domain;
> + struct device_node *node = pdev->dev.of_node;
> + struct device *dev = &pdev->dev;
> + struct rzt2h_icu_priv *priv;
> + int ret;
> +
> + parent_domain = irq_find_host(parent);
> + if (!parent_domain)
> + return dev_err_probe(dev, -ENODEV, "cannot find parent domain\n");
> +
> + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + platform_set_drvdata(pdev, priv);
> +
> + priv->base_ns = devm_of_iomap(dev, dev->of_node, 0, NULL);
> + if (IS_ERR(priv->base_ns))
> + return PTR_ERR(priv->base_ns);
> +
> + priv->base_s = devm_of_iomap(dev, dev->of_node, 1, NULL);
> + if (IS_ERR(priv->base_s))
> + return PTR_ERR(priv->base_s);
> +
> + ret = rzt2h_icu_parse_interrupts(priv, node);
> + if (ret)
> + return dev_err_probe(dev, ret,
> + "cannot parse interrupts: %d\n", ret);
> +
> + ret = devm_pm_runtime_enable(dev);
> + if (ret)
> + return dev_err_probe(dev, ret,
> + "devm_pm_runtime_enable failed: %d\n", ret);
> +
> + ret = pm_runtime_resume_and_get(dev);
> + if (ret)
> + return dev_err_probe(dev, ret,
> + "pm_runtime_resume_and_get failed: %d\n", ret);
> +
> + raw_spin_lock_init(&priv->lock);
> +
> + irq_domain = irq_domain_create_hierarchy(parent_domain, 0, RZT2H_ICU_NUM_IRQ,
> + dev_fwnode(dev),
> + &rzt2h_icu_domain_ops, priv);
> + if (!irq_domain) {
> + pm_runtime_put(dev);
> + return -ENOMEM;
> + }
The mix of 'return $ERR' and 'return dev_err_probe()' is confusing at best.
Thanks,
tglx
next prev parent reply other threads:[~2025-11-22 15:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-21 11:14 [PATCH 0/4] Add ICU support for RZ/T2H and RZ/N2H Cosmin Tanislav
2025-11-21 11:14 ` [PATCH 1/4] dt-bindings: interrupt-controller: document RZ/{T2H,N2H} ICU Cosmin Tanislav
2025-11-23 13:23 ` Krzysztof Kozlowski
2025-11-24 16:25 ` Cosmin-Gabriel Tanislav
2025-11-27 7:19 ` Krzysztof Kozlowski
2025-11-27 14:44 ` Cosmin-Gabriel Tanislav
2025-11-21 11:14 ` [PATCH 2/4] irqchip: add RZ/{T2H,N2H} Interrupt Controller (ICU) driver Cosmin Tanislav
2025-11-22 15:55 ` Thomas Gleixner [this message]
2025-11-24 12:50 ` Cosmin-Gabriel Tanislav
2025-11-24 13:49 ` Thomas Gleixner
2025-11-24 15:28 ` Cosmin-Gabriel Tanislav
2025-11-24 19:01 ` Thomas Gleixner
2025-11-21 11:14 ` [PATCH 3/4] arm64: dts: renesas: r9a09g077: add ICU support Cosmin Tanislav
2025-11-21 11:14 ` [PATCH 4/4] arm64: dts: renesas: r9a09g087: " Cosmin Tanislav
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=87see6hxjb.ffs@tglx \
--to=tglx@linutronix.de \
--cc=conor+dt@kernel.org \
--cc=cosmin-gabriel.tanislav.xa@renesas.com \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=robh@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