Module Name: src Committed By: martin Date: Mon Mar 26 11:19:39 UTC 2018
Modified Files: src/sys/arch/x86/x86 [netbsd-8]: intr.c Log Message: Pull up following revision(s) (requested by knakahara in ticket #658): sys/arch/x86/x86/intr.c: revision 1.124 Fix "intrctl list" causes panic while attaching MSI/MSI-X devices. When there are devices which is already pci_intr_alloc'ed, however is not established yet, "intrctl list" causes panic. E.g. # while true; do intrctl list > /dev/null ; done& # drvctl -d ixg0 && drvctl -r pci0 And add some KASSERTMSG to similar but not the same code. Pointed out by msaitoh@n.o. XXX pullup-8 To generate a diff of this commit: cvs rdiff -u -r1.101.2.3 -r1.101.2.4 src/sys/arch/x86/x86/intr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/x86/x86/intr.c diff -u src/sys/arch/x86/x86/intr.c:1.101.2.3 src/sys/arch/x86/x86/intr.c:1.101.2.4 --- src/sys/arch/x86/x86/intr.c:1.101.2.3 Fri Mar 16 13:17:56 2018 +++ src/sys/arch/x86/x86/intr.c Mon Mar 26 11:19:39 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: intr.c,v 1.101.2.3 2018/03/16 13:17:56 martin Exp $ */ +/* $NetBSD: intr.c,v 1.101.2.4 2018/03/26 11:19:39 martin Exp $ */ /*- * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -133,7 +133,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.101.2.3 2018/03/16 13:17:56 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.101.2.4 2018/03/26 11:19:39 martin Exp $"); #include "opt_intrdebug.h" #include "opt_multiprocessor.h" @@ -1839,6 +1839,9 @@ intr_get_affinity(struct intrsource *isp return; } + KASSERTMSG(isp->is_handlers != NULL, + "Don't get affinity for the device which is not established."); + ci = isp->is_handlers->ih_cpu; if (ci == NULL) { kcpuset_zero(cpuset); @@ -1891,6 +1894,9 @@ intr_set_affinity(struct intrsource *isp } ih = isp->is_handlers; + KASSERTMSG(ih != NULL, + "Don't set affinity for the device which is not established."); + oldci = ih->ih_cpu; if (newci == oldci) /* nothing to do */ return 0; @@ -1957,6 +1963,13 @@ intr_is_affinity_intrsource(struct intrs KASSERT(mutex_owned(&cpu_lock)); + /* + * The device is already pci_intr_alloc'ed, however it is not + * established yet. + */ + if (isp->is_handlers == NULL) + return false; + ci = isp->is_handlers->ih_cpu; KASSERT(ci != NULL);