Commit aa843e7
authored
cpu_seq: Fix a variety of hilarious bugs in sequencer IRQ handling (#2390)
Depends on #2392
There are several things wrong with the current handling of sequencer
FPGA interrupts (on Cosmo) and PMBus alerts in the Gimlet sequencer. To
wit:
1. On Cosmo, the `cosmo_seq_server` task does not handle the `NIC_MAPO`
interrupt from the sequencer FPGA. When the NIC MAPOs, we should be
transitioning from A0+HP back to A0, rather than just ignoring the
NIC MAPO event. Presently, ignoring NIC MAPOs result in an improper
thermal shutdown (see #2384), as the `thermal` task continues to poll
the NIC's temperature sensor despite it no longer being powered, and
extrapolates a worst-case temperature trend in the face of I2C NACKs
from the temperature sensor, which eventually result in a thermal
shutdown. This isn't great.
2. Both the Cosmo sequencer FPGA interrupt and the Gimlet
V<sub>core</sub> VRM PMBus alert handling are implemented using the
STM32 external interrupt (EXTI) peripheral, which only supports
edge-triggered interrupts (not level-triggered). On Cosmo, where the
FPGA IRQ line can be triggered by multiple bits in the FPGA's
Interrupt Flags Register (IFR) being set, this means that we can miss
interrupts in a situation where one IFR bit is set and then, *after*
Hubris reads the IFR, a second IFR bit is *also* set while the
`FPGA1_TO_SP_IRQ_L` line remains asserted. In this case, any bits
which are set after the initial IFR read are completely missed by
Hubris.
Sadly, it turns out that this is often what happens in the event of a
voltage sag on `V12_SYS_A2` similar to mfg-quality#140. If the
voltage dips enough to both trigger the RAA229620A's V<sub>in</sub>
undervolt warning **and** enough to MAPO the T6, the T6 MAPO tends to
occur while we are in the interrupt handler but after the initial IFR
read, so the NIC MAPO interrupt tends to be missed. Cool.
3. Our code that attempts to clear PMBus faults in the RAA229620As (on
Cosmo)/RAA229618 (on Gimlet)...doesn't due that (see #2389), due to
multiple _hilarious_ bugs:
- We are currently sending the PMBus `CLEAR_FAULTS` command without a
PMBus page (rail) associated with it. It turns out that this does
_not_ actually result in clearing faults on all pages. Instead, it
results in, uh, nothing happening.
Quoth the PMBus standard:
> Commands to clear a bit are gated by the PAGE command. The
> CLEAR_FAULTS can be made to clear all faults on all pages by
> setting the page command to FFh.
>
> --- _PMBus Power System Mgt Protocol Specification – Part II –
> Revision 1.3.1_; §10.3 (p. 44)
So, sending the command without a page doesn't actually do
anything. That's great.
- The second thing that stops this from working is _technically_ our
fault but is due to a decision on the part of the vendor which is
both profoundly bone-headed and somewhat poorly documented (as is
traditional). As @nathanaelhuffman discovered, the RAA229620A
documentation for the `VIN_UV_FAULT_RESPONSE` register, states the
following:
> Configures the input undervoltage fault response. **For a fault
> to be considered cleared, the input voltage must rise by 1/16th
> of the UV fault threshold value.**
>
> --- _R16DS0309EU0100 Rev.1.00_ §11.36 "VIN_OV_FAULT_RESPONSE" (p.
> 57) (emphasis mine)
When we configure the undervoltage warning, [we set the threshold
to 11.75V][1]. If you remember fractions from...elementary
school?[^1] you may have already realized that 1/16 * 11.75V =
0.734375V. This means that for the VRM to clear the fault, the
input voltage must reach 12.484375V (since 11.75V + 0.734375V =
12.484375V).
Yes, that is *almost half a volt above the nominal voltage for the
12V rail*. It isn't supposed to do that! It's supposed to be 12V!!
So, even if a voltage sag has ended and the input voltage to the
VRM has returned to 12V, the fault will not clear because the
voltage has not increased by the requisite 1/16th of the undervolt
threshold. Isn't that wonderful?
5. There was also a FPGA bug in which the `NIC_MAPO` bit did not
actually get unset as expected.
This branch unwinds the entire Litany of Sadness and Pain described
above, by doing the following things:
- Integrating with @nathanaelhuffman's changes in
oxidecomputer/quartz#467, which fixes the bug with clearing the
`IFR[NIC_MAPO]` bit, and also changes all the IFR flags to be
write-1-to-clear. Now, we can clear them properly in the Cosmo
sequencer's routine for handling FPGA IRQs. This required #2392 as the
new FPGA register map wouldn't build without it.
- Actually making the NIC MAPO interrupt transition the system state
from A0+HP to A0, which (in conjunction with #2391) fixes #2384.
- Changing the code for clearing RAA22960A and RAA229618 PMBus faults to
do paged writes rather than unpaged writes, fixing #2389.
- Changing the V<sub>in</sub> undervolt warning threshold from 11.75V to
11V, so that the fault actually clears when the input voltage returns
to normal.
- On Cosmo, changing the code for handling the EXTI notification to
continue reading the FPGA IFR register and clearing any set interrupt
bits until the IRQ line is actually deasserted in a loop, to
compensate for the possibility of additional bits being set whilst we
are already handling an interrupt but after we have read the IFR.
This does not apply to the PMBus alerts from the RAA229620As, as they
are set in the IFR as long as the corresponding PMBus alert line to
the FPGA is asserted, and cannot be cleared by writing back a 1 to the
IFR. Instead, we mask them out by setting the corresponding bits in
the FPGA Interrupt Enable Register (IER), so that they can remain
asserted without the FPGA continuing to assert the IRQ.
- Masking out the RAA229620A PMBus alerts _half-solves_ the problem, but
it doesn't reset the IER when the PMBus fault actually does clear, so
we wouldn't be notified of a _subsequent_ fault condition. Thus, we
must also set a flag that tells the sequencer task to continue trying
to clear faults in the VRM(s) that asserted the PMBus alert
periodically until the fault actually goes away. If it does, we then
re-enable IRQs for the corresponding `PMALERT_L` pin(s).
- A slightly simpler version of that also had to happen on Gimlet. It's
simpler because Gimlet only monitors a single RAA229618.
Whew okay yeah, I think that's everything. This was a whole thing.
Fixes #2384
Fixes #2389
[1]:
https://github.com/oxidecomputer/hubris/blob/939c48a1ff8e3ab059d8813f6a58b82fdaccc562/drv/cosmo-seq-server/src/vcore.rs#L85-L91
[^1]: Or middle school? When do children learn fractions?1 parent 49bc625 commit aa843e7
12 files changed
Lines changed: 1202 additions & 145 deletions
File tree
- drv
- cosmo-seq-server/src
- cpu-seq-api/src
- gimlet-seq-server/src
- i2c-devices/src
- spartan7-loader/cosmo-seq
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | | - | |
| 34 | + | |
33 | 35 | | |
34 | | - | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
52 | | - | |
53 | 54 | | |
54 | 55 | | |
55 | | - | |
| 56 | + | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
67 | 72 | | |
68 | 73 | | |
69 | 74 | | |
| |||
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
78 | | - | |
79 | | - | |
80 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
81 | 128 | | |
82 | 129 | | |
83 | 130 | | |
84 | 131 | | |
85 | 132 | | |
86 | | - | |
| 133 | + | |
87 | 134 | | |
88 | 135 | | |
89 | 136 | | |
90 | 137 | | |
91 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
92 | 166 | | |
93 | 167 | | |
94 | 168 | | |
| |||
108 | 182 | | |
109 | 183 | | |
110 | 184 | | |
| 185 | + | |
111 | 186 | | |
112 | 187 | | |
113 | 188 | | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
114 | 193 | | |
115 | 194 | | |
116 | 195 | | |
117 | 196 | | |
118 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
119 | 202 | | |
120 | 203 | | |
121 | 204 | | |
| |||
128 | 211 | | |
129 | 212 | | |
130 | 213 | | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
135 | 218 | | |
136 | 219 | | |
137 | 220 | | |
| |||
141 | 224 | | |
142 | 225 | | |
143 | 226 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
149 | 232 | | |
| 233 | + | |
150 | 234 | | |
151 | | - | |
152 | | - | |
153 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
154 | 242 | | |
| 243 | + | |
155 | 244 | | |
156 | 245 | | |
157 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
158 | 251 | | |
159 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
160 | 265 | | |
161 | 266 | | |
162 | 267 | | |
163 | | - | |
164 | | - | |
| 268 | + | |
| 269 | + | |
165 | 270 | | |
166 | 271 | | |
167 | 272 | | |
168 | 273 | | |
169 | 274 | | |
170 | | - | |
| 275 | + | |
171 | 276 | | |
172 | 277 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
180 | 289 | | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
188 | 300 | | |
189 | | - | |
| 301 | + | |
190 | 302 | | |
191 | 303 | | |
192 | 304 | | |
| |||
214 | 326 | | |
215 | 327 | | |
216 | 328 | | |
217 | | - | |
| 329 | + | |
218 | 330 | | |
219 | 331 | | |
220 | 332 | | |
| |||
231 | 343 | | |
232 | 344 | | |
233 | 345 | | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | 346 | | |
253 | 347 | | |
254 | 348 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
727 | 728 | | |
728 | 729 | | |
729 | 730 | | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
730 | 735 | | |
731 | 736 | | |
732 | 737 | | |
| |||
1163 | 1168 | | |
1164 | 1169 | | |
1165 | 1170 | | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
1166 | 1174 | | |
1167 | 1175 | | |
1168 | 1176 | | |
1169 | 1177 | | |
| 1178 | + | |
1170 | 1179 | | |
1171 | 1180 | | |
1172 | 1181 | | |
| |||
0 commit comments