Re: [RFC PATCH v3 35/37] kvx: Add IPI driver

Krzysztof Kozlowski
2024-07-22T12:39:25Z

On 22/07/2024 11:41, ysionneau@kalrayinc.com wrote:
> From: Yann Sionneau <ysionneau@kalrayinc.com>
>
> The Inter-Processor Interrupt Controller (IPI) provides a fast
> synchronization mechanism to the software. It exposes eight independent
> sets of registers that can be used to notify each processor in the cluster.
>
> Co-developed-by: Clement Leger <clement@clement-leger.fr>
> Signed-off-by: Clement Leger <clement@clement-leger.fr>
> Co-developed-by: Guillaume Thouvenin <thouveng@gmail.com>
> Signed-off-by: Guillaume Thouvenin <thouveng@gmail.com>
> Co-developed-by: Julian Vetter <jvetter@kalrayinc.com>
> Signed-off-by: Julian Vetter <jvetter@kalrayinc.com>
> Co-developed-by: Luc Michel <luc@lmichel.fr>
> Signed-off-by: Luc Michel <luc@lmichel.fr>
> Signed-off-by: Jules Maselbas <jmaselbas@zdiv.net>
> Signed-off-by: Yann Sionneau <ysionneau@kalrayinc.com>

...

> +
> +int __init kvx_ipi_ctrl_init(struct device_node *node,
> + struct device_node *parent)
> +{
> + int ret;
> + unsigned int ipi_irq;
> + void __iomem *ipi_base;
> +
> + BUG_ON(!node);

Fix your code instead.

> +
> + ipi_base = of_iomap(node, 0);
> + BUG_ON(!ipi_base);

No, handle it by returning.

> +
> + kvx_ipi_controller.regs = ipi_base;
> +
> + /* Init mask for interrupts to PE0 -> PE15 */
> + writel(KVX_IPI_CPU_MASK, kvx_ipi_controller.regs + IPI_MASK_OFFSET);
> +
> + ipi_irq = irq_of_parse_and_map(node, 0);
> + if (!ipi_irq) {
> + pr_err("Failed to parse irq: %d\n", ipi_irq);
> + return -EINVAL;
> + }
> +
> + ret = request_percpu_irq(ipi_irq, ipi_irq_handler,
> + "kvx_ipi", &kvx_ipi_controller);
> + if (ret) {
> + pr_err("can't register interrupt %d (%d)\n",
> + ipi_irq, ret);
> + return ret;
> + }
> + kvx_ipi_controller.ipi_irq = ipi_irq;
> +
> + ret = cpuhp_setup_state(CPUHP_AP_IRQ_KVX_STARTING,
> + "kvx/ipi:online",
> + kvx_ipi_starting_cpu,
> + kvx_ipi_dying_cpu);
> + if (ret < 0) {
> + pr_err("Failed to setup hotplug state");
> + return ret;
> + }
> +
> + set_smp_cross_call(kvx_ipi_send);
> + pr_info("controller probed\n");

Drop this simple probe successes. This is not the way to trace system
bootup. Keep only reasonable amount, not every driver printing that its
initcall started.

Best regards,
Krzysztof