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

From: Krzysztof Kozlowski
Date: Mon Jul 22 2024 - 08:39:34 EST


On 22/07/2024 11:41, ysionneau@xxxxxxxxxxxxx wrote:
> From: Yann Sionneau <ysionneau@xxxxxxxxxxxxx>
>
> 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@xxxxxxxxxxxxxxxx>
> Signed-off-by: Clement Leger <clement@xxxxxxxxxxxxxxxx>
> Co-developed-by: Guillaume Thouvenin <thouveng@xxxxxxxxx>
> Signed-off-by: Guillaume Thouvenin <thouveng@xxxxxxxxx>
> Co-developed-by: Julian Vetter <jvetter@xxxxxxxxxxxxx>
> Signed-off-by: Julian Vetter <jvetter@xxxxxxxxxxxxx>
> Co-developed-by: Luc Michel <luc@xxxxxxxxxx>
> Signed-off-by: Luc Michel <luc@xxxxxxxxxx>
> Signed-off-by: Jules Maselbas <jmaselbas@xxxxxxxx>
> Signed-off-by: Yann Sionneau <ysionneau@xxxxxxxxxxxxx>

...

> +
> +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