Index: sys/kern/subr_intr.c =================================================================== --- sys/kern/subr_intr.c +++ sys/kern/subr_intr.c @@ -696,8 +696,8 @@ mtx_assert(&pic_list_lock, MA_OWNED); - if (dev == NULL && xref == 0) - return (NULL); + KASSERT(dev != NULL || xref != -1, + ("pic_lookup_locked: Either the device or the xref must be valid")); /* Note that pic->pic_dev is never NULL on registered PIC. */ SLIST_FOREACH(pic, &pic_list, pic_next) { @@ -706,13 +706,17 @@ continue; if (dev == NULL) { + /* No dev, check the xref */ if (xref == pic->pic_xref) return (pic); - } else if (xref == 0 || pic->pic_xref == 0) { + } else if (xref == -1) { + /* No xref, check the dev */ if (dev == pic->pic_dev) return (pic); - } else if (xref == pic->pic_xref && dev == pic->pic_dev) - return (pic); + } else if (xref == pic->pic_xref && dev == pic->pic_dev) { + /* Have both, check both */ + return (pic); + } } return (NULL); } @@ -739,6 +743,8 @@ { struct intr_pic *pic; + KASSERT(xref != -1, ("%s: Invalid xref", __func__)); + mtx_lock(&pic_list_lock); pic = pic_lookup_locked(dev, xref, flags); if (pic != NULL) { @@ -768,6 +774,8 @@ { struct intr_pic *pic; + KASSERT(xref != -1, ("%s: Invalid xref", __func__)); + mtx_lock(&pic_list_lock); pic = pic_lookup_locked(dev, xref, flags); if (pic == NULL) { @@ -827,6 +835,7 @@ { struct intr_pic *pic; + KASSERT(xref != -1, ("%s: Invalid xref", __func__)); pic = pic_lookup(dev, xref, FLAG_PIC); if (pic == NULL) { device_printf(dev, "not registered\n"); @@ -876,7 +885,7 @@ #endif /* Find the parent PIC */ - parent_pic = pic_lookup(parent, 0, FLAG_PIC); + parent_pic = pic_lookup(parent, -1, FLAG_PIC); if (parent_pic == NULL) return (NULL); @@ -910,6 +919,7 @@ if (data == NULL) return (EINVAL); + KASSERT(xref != -1, ("%s: Invalid xref", __func__)); pic = pic_lookup(dev, xref, (data->type == INTR_MAP_DATA_MSI) ? FLAG_MSI : FLAG_PIC); if (pic == NULL) @@ -1281,6 +1291,7 @@ struct intr_map_data_msi *msi; int err, i; + KASSERT(xref != -1, ("%s: Invalid xref", __func__)); pic = pic_lookup(NULL, xref, FLAG_MSI); if (pic == NULL) return (ESRCH); @@ -1318,6 +1329,7 @@ struct intr_map_data_msi *msi; int i, err; + KASSERT(xref != -1, ("%s: Invalid xref", __func__)); pic = pic_lookup(NULL, xref, FLAG_MSI); if (pic == NULL) return (ESRCH); @@ -1357,6 +1369,7 @@ struct intr_map_data_msi *msi; int err; + KASSERT(xref != -1, ("%s: Invalid xref", __func__)); pic = pic_lookup(NULL, xref, FLAG_MSI); if (pic == NULL) return (ESRCH); @@ -1385,6 +1398,7 @@ struct intr_map_data_msi *msi; int err; + KASSERT(xref != -1, ("%s: Invalid xref", __func__)); pic = pic_lookup(NULL, xref, FLAG_MSI); if (pic == NULL) return (ESRCH); @@ -1418,6 +1432,7 @@ struct intr_pic *pic; int err; + KASSERT(xref != -1, ("%s: Invalid xref", __func__)); pic = pic_lookup(NULL, xref, FLAG_MSI); if (pic == NULL) return (ESRCH);