From 345150ca3e11237247a69769f072115fa73a124b Mon Sep 17 00:00:00 2001 From: kettenis Date: Wed, 27 Jul 2022 20:26:17 +0000 Subject: [PATCH] Support "empty" phandles in interrups-extended properties. This is needed to support the device tree binding for the "apple,admac" controller. ok visa@, patrick@ --- sys/arch/arm64/arm64/intr.c | 9 ++++++++- sys/arch/armv7/armv7/intr.c | 9 ++++++++- sys/arch/powerpc64/powerpc64/intr.c | 9 ++++++++- sys/arch/riscv64/riscv64/intr.c | 9 ++++++++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/sys/arch/arm64/arm64/intr.c b/sys/arch/arm64/arm64/intr.c index e3e8d46d552..886ce8776f9 100644 --- a/sys/arch/arm64/arm64/intr.c +++ b/sys/arch/arm64/arm64/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.24 2022/01/02 01:01:04 jsg Exp $ */ +/* $OpenBSD: intr.c,v 1.25 2022/07/27 20:26:17 kettenis Exp $ */ /* * Copyright (c) 2011 Dale Rahn * @@ -377,6 +377,13 @@ arm_intr_establish_fdt_idx_cpu(int node, int idx, int level, struct cpu_info *ci if (extended) { phandle = cell[0]; + /* Handle "empty" phandle reference. */ + if (phandle == 0) { + cell++; + ncells--; + continue; + } + LIST_FOREACH(ic, &interrupt_controllers, ic_list) { if (ic->ic_phandle == phandle) break; diff --git a/sys/arch/armv7/armv7/intr.c b/sys/arch/armv7/armv7/intr.c index c0816da3d83..96bf04bbf4b 100644 --- a/sys/arch/armv7/armv7/intr.c +++ b/sys/arch/armv7/armv7/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.20 2022/01/02 01:01:04 jsg Exp $ */ +/* $OpenBSD: intr.c,v 1.21 2022/07/27 20:26:17 kettenis Exp $ */ /* * Copyright (c) 2011 Dale Rahn * @@ -366,6 +366,13 @@ arm_intr_establish_fdt_idx_cpu(int node, int idx, int level, struct cpu_info *ci if (extended) { phandle = cell[0]; + /* Handle "empty" phandle reference. */ + if (phandle == 0) { + cell++; + ncells--; + continue; + } + LIST_FOREACH(ic, &interrupt_controllers, ic_list) { if (ic->ic_phandle == phandle) break; diff --git a/sys/arch/powerpc64/powerpc64/intr.c b/sys/arch/powerpc64/powerpc64/intr.c index d2658a8176c..ebcf4ef7ba8 100644 --- a/sys/arch/powerpc64/powerpc64/intr.c +++ b/sys/arch/powerpc64/powerpc64/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.9 2020/09/26 17:56:54 kettenis Exp $ */ +/* $OpenBSD: intr.c,v 1.10 2022/07/27 20:26:17 kettenis Exp $ */ /* * Copyright (c) 2020 Mark Kettenis @@ -281,6 +281,13 @@ fdt_intr_establish_idx_cpu(int node, int idx, int level, struct cpu_info *ci, if (extended) { phandle = cell[0]; + /* Handle "empty" phandle reference. */ + if (phandle == 0) { + cell++; + ncells--; + continue; + } + LIST_FOREACH(ic, &interrupt_controllers, ic_list) { if (ic->ic_phandle == phandle) break; diff --git a/sys/arch/riscv64/riscv64/intr.c b/sys/arch/riscv64/riscv64/intr.c index 9fbba867cc2..a5263e70099 100644 --- a/sys/arch/riscv64/riscv64/intr.c +++ b/sys/arch/riscv64/riscv64/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.9 2022/01/02 01:01:04 jsg Exp $ */ +/* $OpenBSD: intr.c,v 1.10 2022/07/27 20:26:17 kettenis Exp $ */ /* * Copyright (c) 2011 Dale Rahn @@ -359,6 +359,13 @@ riscv_intr_establish_fdt_idx_cpu(int node, int idx, int level, if (extended) { phandle = cell[0]; + /* Handle "empty" phandle reference. */ + if (phandle == 0) { + cell++; + ncells--; + continue; + } + LIST_FOREACH(ic, &interrupt_controllers, ic_list) { if (ic->ic_phandle == phandle) break; -- 2.20.1