From: Thomas Gleixner <tglx@kernel.org>
To: Tianyang Zhang <zhangtianyang@loongson.cn>,
chenhuacai@kernel.org, kernel@xen0n.name, corbet@lwn.net,
alexs@kernel.org, si.yanteng@linux.dev, jiaxun.yang@flygoat.com,
maobibo@loongson.cn
Cc: loongarch@lists.linux.dev, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org,
Tianyang Zhang <zhangtianyang@loongson.cn>,
Liupu Wang <wangliupu@loongson.cn>
Subject: Re: [PATCH v9 4/4] irqchip/irq-loongarch-ir:Add Redirect irqchip support
Date: Fri, 30 Jan 2026 09:54:20 +0100 [thread overview]
Message-ID: <87zf5vlbur.ffs@tglx> (raw)
In-Reply-To: <20260130025941.2140582-5-zhangtianyang@loongson.cn>
On Fri, Jan 30 2026 at 10:59, Tianyang Zhang wrote:
> +// SPDX-License-Identifier: GPL-2.0
GPL-2.0-only please
> +/*
> + * Copyright (C) 2020 Loongson Technologies, Inc.
This was written 6 years ago already?
> + */
> +
> +#include <linux/cpuhotplug.h>
> +#include <linux/init.h>
> +#include <linux/interrupt.h>
> +#include <linux/kernel.h>
> +#include <linux/irq.h>
> +#include <linux/irqchip.h>
> +#include <linux/irqchip/irq-msi-lib.h>
> +#include <linux/irqdomain.h>
> +#include <linux/spinlock.h>
> +#include <linux/msi.h>
Includes should be alphabetically ordered.
> +#define REDIRECT_REG(reg, node) \
> + ((void __iomem *)(IO_BASE | redirect_reg_base | (u64)(node) << NODE_ADDRSPACE_SHIFT | (reg)))
> +
> +static inline void redirect_write_reg64(u32 node, u64 val, u32 reg)
> +{
> + void __iomem *reg_addr = REDIRECT_REG(reg, node);
> +
> + return writeq(val, reg_addr);
Bogus return and you can simplify this to
writeq(val, REDIRECT_REG(reg, node));
No?
> +}
> +
> +static inline void redirect_write_reg32(u32 node, u32 val, u32 reg)
> +{
> + void __iomem *reg_addr = REDIRECT_REG(reg, node);
> +
> + return writel(val, reg_addr);
Ditto
> +}
> +
> +static inline u32 redirect_read_reg32(u32 node, u32 reg)
> +{
> + void __iomem *reg_addr = REDIRECT_REG(reg, node);
> +
> + return readl(reg_addr);
Condense to single line as well
> +static void irde_invalid_entry(struct redirect_item *item)
This should be named irde_invalidate_entry() as that's what the function
is about. irq_invalid_entry() reads more like a function which check for
an invalid entry.
> +{
> + struct irde_inv_cmd cmd;
> + u64 raddr = 0;
> +
> + cmd.cmd_info = 0;
> + cmd.index.type = INVALID_INDEX;
> + cmd.index.need_notice = 1;
> + cmd.index.index = item->index;
> + cmd.notice_addr = (u64)(__pa(&raddr));
> +
> + invalid_enqueue(item, &cmd);
> +
> + /*
> + * CPU needs to wait here for cmd to complete, and it determines this
The CPU
> + * by checking whether invalid queue has already written a valid value
whether the invalidation queue
> + * to cmd.notice_addr.
> + */
> +static int redirect_table_alloc(int node, u32 nr_irqs)
> +{
> + struct redirect_table *ird_table = &irde_descs[node].ird_table;
> + unsigned int index, order;
> +
> + if (nr_irqs > 1) {
> + nr_irqs = __roundup_pow_of_two(nr_irqs);
> + order = ilog2(nr_irqs);
> + }
> +
> + guard(raw_spinlock_irqsave)(&ird_table->lock);
> +
> + index = bitmap_find_free_region(ird_table->bitmap,
> + IRD_ENTRIES, order);
Get rid of this pointless line break. You have 100 characters and the
above even fits into 80
> + if (index < 0) {
> + pr_err("No redirect entry to use\n");
> + return -ENOMEM;
> + }
> +static int redirect_domain_alloc(struct irq_domain *domain, unsigned int virq,
> + unsigned int nr_irqs, void *arg)
> +{
> + msi_alloc_info_t *info = arg;
> + int ret, i, node, index;
> +
> + node = dev_to_node(info->desc->dev);
> +
> + ret = irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, arg);
> + if (ret < 0)
> + return ret;
> +
> + index = redirect_table_alloc(node, nr_irqs);
> + if (index < 0) {
> + pr_err("Alloc redirect table entry failed\n");
> + return -ENOMEM;
> + }
> +
> + for (i = 0; i < nr_irqs; i++) {
> + struct irq_data *irq_data = irq_domain_get_irq_data(domain, virq + i);
> + struct redirect_item *item;
> +
> + item = kzalloc(sizeof(*item), GFP_KERNEL);
> + if (!item) {
> + pr_err("Alloc redirect descriptor failed\n");
> + goto out_free_resources;
> + }
> + item->irde = &irde_descs[node];
> +
> + /*
> + * Only bits 47:6 of the GPID are passed to the controller,
> + * 64-byte alignment must be guarantee and make kzalloc can
> + * align to the respective size.
-ENOPARSE
> + */
> +static const struct irq_domain_ops redirect_domain_ops = {
> + .alloc = redirect_domain_alloc,
> + .free = redirect_domain_free,
> + .select = msi_lib_irq_domain_select,
> +};
> +static void __redirect_irde_fini(struct irde_desc *irde)
This schoolbook _fini() naming is just lame and nondescriptive. Please
use descriptive function names which make it clear what this is about,
e.g. redirect_free_irde() or something like that.
Also this should be __init, no?
> +{
> + struct redirect_table *ird_table = &irde_descs->ird_table;
> + struct redirect_queue *inv_queue = &irde_descs->inv_queue;
> +static inline void redirect_irde_fini(int node)
> +{
> + __redirect_irde_fini(&irde_descs[node]);
This indirection is really pointless. Just move the '&irde_descs[node]' to
the only caller.
> +int __init redirect_acpi_init(struct irq_domain *parent)
> +{
> + struct fwnode_handle *fwnode;
> + int ret = -EINVAL, node;
> +
> + fwnode = irq_domain_alloc_named_fwnode("redirect");
> + if (!fwnode) {
> + pr_err("Unable to alloc redirect domain handle\n");
> + goto fail;
> + }
> +
> + redirect_domain = irq_domain_create_hierarchy(parent, 0, IRD_ENTRIES, fwnode,
> + &redirect_domain_ops, irde_descs);
> + if (!redirect_domain) {
> + pr_err("Unable to alloc redirect domain\n");
> + goto out_free_fwnode;
> + }
> +
> +
stray newline
> + for_each_node_mask(node, node_possible_map) {
> + ret = redirect_irde_init(node);
> + if (ret)
> + goto out_clear_irde;
> + }
> +
> + ret = acpi_cascade_irqdomain_init();
> + if (ret < 0) {
> + pr_err("Failed to cascade IRQ domain, ret=%d\n", ret);
> + goto out_clear_irde;
> + }
> +
> + pr_info("loongarch irq redirect modules init succeeded\n");
You really want to have:
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
at the top of the file, so that all printk()s in this file are properly
prefixed.
Thanks,
tglx
next prev parent reply other threads:[~2026-01-30 8:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-30 2:59 [PATCH v9 0/4] Loongarch irq-redirect support Tianyang Zhang
2026-01-30 2:59 ` [PATCH v9 1/4] Docs/LoongArch: Add Advanced Extended-Redirect IRQ model description Tianyang Zhang
2026-01-30 2:59 ` [PATCH v9 2/4] irqchip/irq-loongson.h:irq-loongson.h preparation for Redirect irqchip Tianyang Zhang
2026-01-30 8:14 ` Thomas Gleixner
2026-01-30 2:59 ` [PATCH v9 3/4] irqchip/loongarch-avec.c:return IRQ_SET_MASK_OK_DONE when keep affinity Tianyang Zhang
2026-01-30 8:20 ` Thomas Gleixner
2026-01-30 9:05 ` Tianyang Zhang
2026-01-30 2:59 ` [PATCH v9 4/4] irqchip/irq-loongarch-ir:Add Redirect irqchip support Tianyang Zhang
2026-01-30 8:33 ` kernel test robot
2026-01-30 8:54 ` Thomas Gleixner [this message]
2026-02-02 1:00 ` Tianyang Zhang
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=87zf5vlbur.ffs@tglx \
--to=tglx@kernel.org \
--cc=alexs@kernel.org \
--cc=chenhuacai@kernel.org \
--cc=corbet@lwn.net \
--cc=jiaxun.yang@flygoat.com \
--cc=kernel@xen0n.name \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=maobibo@loongson.cn \
--cc=si.yanteng@linux.dev \
--cc=wangliupu@loongson.cn \
--cc=zhangtianyang@loongson.cn \
/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