Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146627815
D8616.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D8616.diff
View Options
Index: sys/dev/gpio/gpiobus.c
===================================================================
--- sys/dev/gpio/gpiobus.c
+++ sys/dev/gpio/gpiobus.c
@@ -96,7 +96,8 @@
gpio_data->gpio_pin_flags = pin->flags;
gpio_data->gpio_intr_mode = intr_mode;
- irq = intr_map_irq(pin->dev, 0, (struct intr_map_data *)gpio_data);
+ irq = intr_map_irq(pin->dev, XREF_NONE,
+ (struct intr_map_data *)gpio_data);
res = bus_alloc_resource(consumer_dev, SYS_RES_IRQ, rid, irq, irq, 1,
alloc_flags);
if (res == NULL) {
Index: sys/kern/subr_intr.c
===================================================================
--- sys/kern/subr_intr.c
+++ sys/kern/subr_intr.c
@@ -104,6 +104,7 @@
/* Interrupt controller definition. */
struct intr_pic {
SLIST_ENTRY(intr_pic) pic_next;
+#define XREF_INVALID -1
intptr_t pic_xref; /* hardware identification */
device_t pic_dev;
/* Only one of FLAG_PIC or FLAG_MSI may be set */
@@ -697,8 +698,10 @@
mtx_assert(&pic_list_lock, MA_OWNED);
- if (dev == NULL && xref == 0)
- return (NULL);
+ KASSERT(dev != NULL || xref != XREF_INVALID,
+ ("pic_lookup_locked: Either the device or the xref must be valid"));
+ KASSERT(dev != NULL || xref != XREF_NONE,
+ ("pic_lookup_locked: A device is required when there is no xref"));
/* Note that pic->pic_dev is never NULL on registered PIC. */
SLIST_FOREACH(pic, &pic_list, pic_next) {
@@ -706,14 +709,18 @@
(flags & FLAG_TYPE_MASK))
continue;
- if (dev == NULL) {
+ if (dev == NULL && xref != XREF_NONE) {
+ /* No dev, check the xref */
if (xref == pic->pic_xref)
return (pic);
- } else if (xref == 0 || pic->pic_xref == 0) {
+ } else if (xref == XREF_INVALID) {
+ /* 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);
}
@@ -740,6 +747,8 @@
{
struct intr_pic *pic;
+ KASSERT(xref != XREF_INVALID, ("%s: Invalid xref", __func__));
+
mtx_lock(&pic_list_lock);
pic = pic_lookup_locked(dev, xref, flags);
if (pic != NULL) {
@@ -769,6 +778,8 @@
{
struct intr_pic *pic;
+ KASSERT(xref != XREF_INVALID, ("%s: Invalid xref", __func__));
+
mtx_lock(&pic_list_lock);
pic = pic_lookup_locked(dev, xref, flags);
if (pic == NULL) {
@@ -828,6 +839,7 @@
{
struct intr_pic *pic;
+ KASSERT(xref != XREF_INVALID, ("%s: Invalid xref", __func__));
pic = pic_lookup(dev, xref, FLAG_PIC);
if (pic == NULL) {
device_printf(dev, "not registered\n");
@@ -877,7 +889,7 @@
#endif
/* Find the parent PIC */
- parent_pic = pic_lookup(parent, 0, FLAG_PIC);
+ parent_pic = pic_lookup(parent, XREF_INVALID, FLAG_PIC);
if (parent_pic == NULL)
return (NULL);
@@ -911,6 +923,7 @@
if (data == NULL)
return (EINVAL);
+ KASSERT(xref != XREF_INVALID, ("%s: Invalid xref", __func__));
pic = pic_lookup(dev, xref,
(data->type == INTR_MAP_DATA_MSI) ? FLAG_MSI : FLAG_PIC);
if (pic == NULL)
@@ -1290,6 +1303,7 @@
struct intr_map_data_msi *msi;
int err, i;
+ KASSERT(xref != XREF_INVALID, ("%s: Invalid xref", __func__));
pic = pic_lookup(NULL, xref, FLAG_MSI);
if (pic == NULL)
return (ESRCH);
@@ -1327,6 +1341,7 @@
struct intr_map_data_msi *msi;
int i, err;
+ KASSERT(xref != XREF_INVALID, ("%s: Invalid xref", __func__));
pic = pic_lookup(NULL, xref, FLAG_MSI);
if (pic == NULL)
return (ESRCH);
@@ -1366,6 +1381,7 @@
struct intr_map_data_msi *msi;
int err;
+ KASSERT(xref != XREF_INVALID, ("%s: Invalid xref", __func__));
pic = pic_lookup(NULL, xref, FLAG_MSI);
if (pic == NULL)
return (ESRCH);
@@ -1394,6 +1410,7 @@
struct intr_map_data_msi *msi;
int err;
+ KASSERT(xref != XREF_INVALID, ("%s: Invalid xref", __func__));
pic = pic_lookup(NULL, xref, FLAG_MSI);
if (pic == NULL)
return (ESRCH);
@@ -1427,6 +1444,7 @@
struct intr_pic *pic;
int err;
+ KASSERT(xref != XREF_INVALID, ("%s: Invalid xref", __func__));
pic = pic_lookup(NULL, xref, FLAG_MSI);
if (pic == NULL)
return (ESRCH);
Index: sys/sys/intr.h
===================================================================
--- sys/sys/intr.h
+++ sys/sys/intr.h
@@ -106,6 +106,8 @@
int intr_isrc_dispatch(struct intr_irqsrc *, struct trapframe *);
u_int intr_irq_next_cpu(u_int current_cpu, cpuset_t *cpumask);
+/* The device has no xref */
+#define XREF_NONE -2
struct intr_pic *intr_pic_register(device_t, intptr_t);
int intr_pic_deregister(device_t, intptr_t);
int intr_pic_claim_root(device_t, intptr_t, intr_irq_filter_t *, void *, u_int);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 5, 5:53 AM (14 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29273686
Default Alt Text
D8616.diff (4 KB)
Attached To
Mode
D8616: Rework the logic for finding the pic object.
Attached
Detach File
Event Timeline
Log In to Comment