> Date: Fri, 18 Nov 2022 14:36:18 +0100
> From: Jan Stary <[email protected]>
>
> On Nov 18 12:51:32, [email protected] wrote:
> > > Date: Fri, 18 Nov 2022 12:19:46 +0100
> > > From: Jan Stary <[email protected]>
> > >
> > > On Nov 17 14:44:59, [email protected] wrote:
> > > > This is a freshly installed current/arm64 on a MAcBook Air,
> > > > model 2337 (M1, 2020); full dmesg below.
> > >
> > > Upgrading the co-existing macOS to 12.6.1
> > > seems to have brken the working bsd installation.
> > > The booting bsd kernel gets to
> > >
> > > [...]
> > > exuart0 at simplebus0
> > > exuart1 at simplebus0
> > > aplspmi0 at simplebus0
> > > aplpmu0 at aplspmi0 sid 0xf
> > > aplsmc0 at simplebus0
> > >
> > > and moves no further. Same with booting bsd.rd,
> > > same with booting the latest one from snapshots (off a USB stick).
> > >
> > > Can the macOS upgrade be related? Is this known?
> > > The macOS upgrade also switched the default boot to macOS
> > > (while after the bsd install, the avahi boot went to bsd by default).
> >
> > Possible. In principle the OpenBSD install comes with its own set of
> > Apple firmwares. But the SMC firmware (like the NVMe firmware) is
> > stored in some sort of ROM and therefore "global". The macOS upgrade
> > might have updated the SMC in a way that is incompatible with the
> > aplsmc(4) driver.
>
> Thanks for the insight.
> Is there something I can do to debug it?
> Also, the line that normally follows is
>
> aplsart0 at simplebus0
>
> and some time ago there was a warning at this list
> not to upgrade to macOS 13 specifically related to aplsart
> - could it be that's in fact what's broken now (as opposed to SMC)?
>
> Jan
Here is a diff that changes the rtkit code to not spin forever. That
might get you going again. You'll need to boot a kernel with this
diff from a USB stick or something like that.
Cheers,
Mark
Index: arch/arm64/dev/aplmbox.c
===================================================================
RCS file: /cvs/src/sys/arch/arm64/dev/aplmbox.c,v
retrieving revision 1.3
diff -u -p -r1.3 aplmbox.c
--- arch/arm64/dev/aplmbox.c 9 Nov 2022 19:18:11 -0000 1.3
+++ arch/arm64/dev/aplmbox.c 18 Nov 2022 16:12:35 -0000
@@ -187,7 +187,7 @@ aplmbox_recv(void *cookie, void *data, s
ctrl = HREAD4(sc, MBOX_I2A_CTRL);
if (ctrl & MBOX_I2A_CTRL_EMPTY)
- return EAGAIN;
+ return EWOULDBLOCK;
msg->data0 = HREAD8(sc, MBOX_I2A_RECV0);
msg->data1 = HREAD8(sc, MBOX_I2A_RECV1);
Index: arch/arm64/dev/rtkit.c
===================================================================
RCS file: /cvs/src/sys/arch/arm64/dev/rtkit.c,v
retrieving revision 1.9
diff -u -p -r1.9 rtkit.c
--- arch/arm64/dev/rtkit.c 11 Nov 2022 11:45:10 -0000 1.9
+++ arch/arm64/dev/rtkit.c 18 Nov 2022 16:12:35 -0000
@@ -99,16 +99,7 @@ struct rtkit_state {
int
rtkit_recv(struct mbox_channel *mc, struct aplmbox_msg *msg)
{
- int error, timo;
-
- for (timo = 0; timo < 10000; timo++) {
- error = mbox_recv(mc, msg, sizeof(*msg));
- if (error == 0)
- break;
- delay(10);
- }
-
- return error;
+ return mbox_recv(mc, msg, sizeof(*msg));
}
int
@@ -468,36 +459,18 @@ rtkit_init(int node, const char *name, i
int
rtkit_boot(struct rtkit_state *state)
{
- struct mbox_channel *mc = state->mc;
- int error;
-
/* Wake up! */
- error = rtkit_send(mc, RTKIT_EP_MGMT, RTKIT_MGMT_IOP_PWR_STATE,
- RTKIT_MGMT_PWR_STATE_ON);
- if (error)
- return error;
-
- while (state->iop_pwrstate != RTKIT_MGMT_PWR_STATE_ON)
- rtkit_poll(state);
-
- return 0;
+ return rtkit_set_iop_pwrstate(state, RTKIT_MGMT_PWR_STATE_ON);
}
void
rtkit_shutdown(struct rtkit_state *state)
{
- struct mbox_channel *mc = state->mc;
struct rtkit *rk = state->rk;
int i;
- if (state->ap_pwrstate != RTKIT_MGMT_PWR_STATE_QUIESCED)
- rtkit_set_ap_pwrstate(state, RTKIT_MGMT_PWR_STATE_QUIESCED);
-
- rtkit_send(mc, RTKIT_EP_MGMT, RTKIT_MGMT_IOP_PWR_STATE,
- RTKIT_MGMT_PWR_STATE_SLEEP);
-
- while (state->iop_pwrstate != RTKIT_MGMT_PWR_STATE_SLEEP)
- rtkit_poll(state);
+ rtkit_set_ap_pwrstate(state, RTKIT_MGMT_PWR_STATE_QUIESCED);
+ rtkit_set_iop_pwrstate(state, RTKIT_MGMT_PWR_STATE_SLEEP);
KASSERT(state->iop_pwrstate == RTKIT_MGMT_PWR_STATE_SLEEP);
KASSERT(state->ap_pwrstate == RTKIT_MGMT_PWR_STATE_QUIESCED);
@@ -521,7 +494,7 @@ int
rtkit_set_ap_pwrstate(struct rtkit_state *state, uint16_t pwrstate)
{
struct mbox_channel *mc = state->mc;
- int error;
+ int error, timo;
if (state->ap_pwrstate == pwrstate)
return 0;
@@ -531,10 +504,48 @@ rtkit_set_ap_pwrstate(struct rtkit_state
if (error)
return error;
- while (state->ap_pwrstate != pwrstate)
- rtkit_poll(state);
+ for (timo = 0; timo < 100000; timo++) {
+ error = rtkit_poll(state);
+ if (error == EWOULDBLOCK) {
+ delay(10);
+ continue;
+ }
- return 0;
+ KASSERT(error == 0);
+ if (state->ap_pwrstate == pwrstate)
+ break;
+ }
+
+ return error;
+}
+
+int
+rtkit_set_iop_pwrstate(struct rtkit_state *state, uint16_t pwrstate)
+{
+ struct mbox_channel *mc = state->mc;
+ int error, timo;
+
+ if (state->iop_pwrstate == pwrstate)
+ return 0;
+
+ error = rtkit_send(mc, RTKIT_EP_MGMT, RTKIT_MGMT_IOP_PWR_STATE,
+ pwrstate);
+ if (error)
+ return error;
+
+ for (timo = 0; timo < 100000; timo++) {
+ error = rtkit_poll(state);
+ if (error == EWOULDBLOCK) {
+ delay(10);
+ continue;
+ }
+
+ KASSERT(error == 0);
+ if (state->iop_pwrstate == pwrstate)
+ break;
+ }
+
+ return error;
}
int
Index: arch/arm64/dev/rtkit.h
===================================================================
RCS file: /cvs/src/sys/arch/arm64/dev/rtkit.h,v
retrieving revision 1.8
diff -u -p -r1.8 rtkit.h
--- arch/arm64/dev/rtkit.h 11 Nov 2022 11:45:10 -0000 1.8
+++ arch/arm64/dev/rtkit.h 18 Nov 2022 16:12:35 -0000
@@ -19,6 +19,7 @@ struct rtkit_state *rtkit_init(int, cons
int rtkit_boot(struct rtkit_state *);
void rtkit_shutdown(struct rtkit_state *);
int rtkit_set_ap_pwrstate(struct rtkit_state *, uint16_t);
+int rtkit_set_iop_pwrstate(struct rtkit_state *, uint16_t);
int rtkit_poll(struct rtkit_state *);
int rtkit_start_endpoint(struct rtkit_state *, uint32_t,
void (*)(void *, uint64_t), void *);