svn commit: r297614 - head/sys/kern

Svatopluk Kraus skra at FreeBSD.org
Wed Apr 6 12:48:46 UTC 2016


Author: skra
Date: Wed Apr  6 12:48:45 2016
New Revision: 297614
URL: https://svnweb.freebsd.org/changeset/base/297614

Log:
  Fix PIC lookup by device and xref. There was not taken into account
  the situation that someone has a pointer to device but not its xref.
  This situation is regular now, after r297539.

Modified:
  head/sys/kern/subr_intr.c

Modified: head/sys/kern/subr_intr.c
==============================================================================
--- head/sys/kern/subr_intr.c	Wed Apr  6 11:11:31 2016	(r297613)
+++ head/sys/kern/subr_intr.c	Wed Apr  6 12:48:45 2016	(r297614)
@@ -766,11 +766,19 @@ pic_lookup_locked(device_t dev, intptr_t
 
 	mtx_assert(&pic_list_lock, MA_OWNED);
 
+	if (dev == NULL && xref == 0)
+		return (NULL);
+
+	/* Note that pic->pic_dev is never NULL on registered PIC. */
 	SLIST_FOREACH(pic, &pic_list, pic_next) {
-		if (pic->pic_xref != xref)
-			continue;
-		if (pic->pic_xref != 0 || pic->pic_dev == dev)
-			return (pic);
+		if (dev == NULL) {
+			if (xref == pic->pic_xref)
+				return (pic);
+		} else if (xref == 0 || pic->pic_xref == 0) {
+			if (dev == pic->pic_dev)
+				return (pic);
+		} else if (xref == pic->pic_xref && dev == pic->pic_dev)
+				return (pic);
 	}
 	return (NULL);
 }
@@ -840,14 +848,14 @@ intr_pic_register(device_t dev, intptr_t
 {
 	struct intr_pic *pic;
 
+	if (dev == NULL)
+		return (EINVAL);
 	pic = pic_create(dev, xref);
 	if (pic == NULL)
 		return (ENOMEM);
-	if (pic->pic_dev != dev)
-		return (EINVAL);	/* XXX it could be many things. */
 
-	debugf("PIC %p registered for %s <xref %x>\n", pic,
-	    device_get_nameunit(dev), xref);
+	debugf("PIC %p registered for %s <dev %p, xref %x>\n", pic,
+	    device_get_nameunit(dev), dev, xref);
 	return (0);
 }
 


More information about the svn-src-all mailing list