Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F167725531
D58871.id184137.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D58871.id184137.diff
View Options
diff --git a/sys/dev/apple_bce/apple_bce_mailbox.c b/sys/dev/apple_bce/apple_bce_mailbox.c
--- a/sys/dev/apple_bce/apple_bce_mailbox.c
+++ b/sys/dev/apple_bce/apple_bce_mailbox.c
@@ -7,6 +7,7 @@
*/
#include <sys/param.h>
+#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/sema.h>
@@ -62,20 +63,41 @@
return (0);
}
- /* Wait for interrupt-driven reply */
- if (sema_timedwait(&mb->mb_cmpl, hz * timeout_ms / 1000) != 0) {
- /* Timeout -- reset to idle */
- atomic_store_int(&mb->status, 0);
- return (ETIMEDOUT);
- }
-
- if (atomic_load_int(&mb->status) != 2) {
- atomic_store_int(&mb->status, 0);
- return (ETIMEDOUT);
+ if (cold) {
+ /*
+ * During early boot, timer-backed sleeps are not available.
+ * Poll the hardware directly, but account for an installed
+ * interrupt handler consuming the reply first.
+ */
+ unsigned int waited = 0;
+
+ while (waited < timeout_ms * 1000) {
+ if (atomic_load_int(&mb->status) == 2)
+ break;
+ (void)bce_mailbox_handle_interrupt(mb);
+ if (atomic_load_int(&mb->status) == 2)
+ break;
+ DELAY(100);
+ waited += 100;
+ }
+ if (atomic_load_int(&mb->status) != 2) {
+ atomic_store_int(&mb->status, 0);
+ return (ETIMEDOUT);
+ }
+ } else {
+ /* Wait for interrupt-driven reply */
+ if (sema_timedwait(&mb->mb_cmpl,
+ hz * timeout_ms / 1000) != 0) {
+ atomic_store_int(&mb->status, 0);
+ return (ETIMEDOUT);
+ }
+ if (atomic_load_int(&mb->status) != 2) {
+ atomic_store_int(&mb->status, 0);
+ return (ETIMEDOUT);
+ }
}
- if (recv != NULL)
- *recv = mb->mb_result;
+ *recv = mb->mb_result;
atomic_store_int(&mb->status, 0);
return (0);
@@ -106,7 +128,9 @@
if (atomic_load_int(&mb->status) == 1) {
atomic_store_int(&mb->status, 2);
- sema_post(&mb->mb_cmpl);
+ /* A cold sender polls status and must not leave a token. */
+ if (!cold)
+ sema_post(&mb->mb_cmpl);
}
return (0);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Aug 25, 1:27 AM (18 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36861647
Default Alt Text
D58871.id184137.diff (1 KB)
Attached To
Mode
D58871: apple_bce: fix cold boot panic in mailbox send
Attached
Detach File
Event Timeline
Log In to Comment