summaryrefslogtreecommitdiffstats
path: root/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
diff options
context:
space:
mode:
authorloos <loos@FreeBSD.org>2014-12-27 13:52:33 +0000
committerloos <loos@FreeBSD.org>2014-12-27 13:52:33 +0000
commit01e07ac8e2e9bfe04fff21f727b7cc626f13c56d (patch)
tree1b9ab2377d3c341447c81143e087151036dfce4e /sys/arm/broadcom/bcm2835/bcm2835_mbox.c
parent5a1ebb207fc82dca3d5fcba0747b0cf9a18d51c1 (diff)
downloadFreeBSD-src-01e07ac8e2e9bfe04fff21f727b7cc626f13c56d.zip
FreeBSD-src-01e07ac8e2e9bfe04fff21f727b7cc626f13c56d.tar.gz
On interrupt handler, save the actual data read from mbox. The previous
macro wasn't needed and was being used with swapped arguments which always give the same result (0) defeating the overflow check. On initialization, do not use bcm_mbox_intr() to read the pending messages, with the new semaphore based implementation this will lead to semaphore being incremented on the channels that contain pending data and will make the first read for that channel return stale data. This fixes the hang that happens on boot while initializing the cpufreq on Raspberry Pi.
Diffstat (limited to 'sys/arm/broadcom/bcm2835/bcm2835_mbox.c')
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_mbox.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
index 4c647fdd..224a0d5 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
@@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$");
mtx_unlock(&(sc)->lock); \
} while(0)
+#undef DEBUG
#ifdef DEBUG
#define dprintf(fmt, args...) printf(fmt, ##args)
#else
@@ -116,7 +117,7 @@ bcm_mbox_intr(void *arg)
continue;
}
dprintf("bcm_mbox_intr: chan %d, data %08x\n", chan, data);
- sc->msg[chan] = MBOX_MSG(data, 0xf);
+ sc->msg[chan] = msg;
sema_post(&sc->sema[chan]);
}
}
@@ -174,7 +175,8 @@ bcm_mbox_attach(device_t dev)
}
/* Read all pending messages */
- bcm_mbox_intr(sc);
+ while ((mbox_read_4(sc, REG_STATUS) & STATUS_EMPTY) == 0)
+ (void)mbox_read_4(sc, REG_READ);
mbox_write_4(sc, REG_CONFIG, CONFIG_DATA_IRQ);
OpenPOWER on IntegriCloud