@@ -17,7 +17,6 @@ use drv_i2c_api::ResponseCode;
17
17
use drv_i2c_devices:: raa229620a:: { self , Raa229620A } ;
18
18
use ringbuf:: * ;
19
19
use serde:: Serialize ;
20
- use task_packrat_api:: { self , Packrat } ;
21
20
use userlib:: { sys_get_timer, units, TaskId } ;
22
21
23
22
pub ( super ) struct VCore {
@@ -162,18 +161,31 @@ impl VCore {
162
161
Ok ( ( ) )
163
162
}
164
163
165
- pub fn handle_pmbus_alert ( & self , mut rails : Rails , now : u64 ) {
164
+ pub fn handle_pmbus_alert (
165
+ & self ,
166
+ mut rails : Rails ,
167
+ now : u64 ,
168
+ ereport_buf : & mut [ u8 ] ,
169
+ ) {
166
170
ringbuf_entry ! ( Trace :: PmbusAlert {
167
171
timestamp: now,
168
172
rails,
169
173
} ) ;
170
174
171
- let cpu0_state =
172
- self . record_pmbus_status ( now, Rail :: VddcrCpu0 , rails. vddcr_cpu0 ) ;
175
+ let cpu0_state = self . record_pmbus_status (
176
+ now,
177
+ Rail :: VddcrCpu0 ,
178
+ rails. vddcr_cpu0 ,
179
+ ereport_buf,
180
+ ) ;
173
181
rails. vddcr_cpu0 |= cpu0_state. faulted ;
174
182
175
- let cpu1_state =
176
- self . record_pmbus_status ( now, Rail :: VddcrCpu1 , rails. vddcr_cpu1 ) ;
183
+ let cpu1_state = self . record_pmbus_status (
184
+ now,
185
+ Rail :: VddcrCpu1 ,
186
+ rails. vddcr_cpu1 ,
187
+ ereport_buf,
188
+ ) ;
177
189
rails. vddcr_cpu1 |= cpu1_state. faulted ;
178
190
179
191
if cpu0_state. input_fault || cpu1_state. input_fault {
@@ -246,6 +258,7 @@ impl VCore {
246
258
now : u64 ,
247
259
rail : Rail ,
248
260
alerted : bool ,
261
+ ereport_buf : & mut [ u8 ] ,
249
262
) -> RegulatorState {
250
263
use pmbus:: commands:: raa229620a:: STATUS_WORD ;
251
264
@@ -372,7 +385,18 @@ impl VCore {
372
385
status,
373
386
pwr_good : power_good,
374
387
} ;
375
- deliver_ereport ( rail, & self . packrat , & ereport) ;
388
+ match self . packrat . serialize_ereport ( & ereport, ereport_buf) {
389
+ Ok ( len) => ringbuf_entry ! ( Trace :: EreportSent ( rail, len) ) ,
390
+ Err ( task_packrat_api:: EreportSerializeError :: Packrat {
391
+ len,
392
+ err,
393
+ } ) => {
394
+ ringbuf_entry ! ( Trace :: EreportLost ( rail, len, err) )
395
+ }
396
+ Err ( task_packrat_api:: EreportSerializeError :: Serialize ( _) ) => {
397
+ ringbuf_entry ! ( Trace :: EreportTooBig ( rail) )
398
+ }
399
+ }
376
400
377
401
RegulatorState {
378
402
faulted,
@@ -432,25 +456,3 @@ fn retry_i2c_txn<T>(
432
456
}
433
457
}
434
458
}
435
-
436
- // This is in its own function so that the ereport buffer is only on the stack
437
- // while we're using it, and not for the entireity of `record_pmbus_status`,
438
- // which calls into a bunch of other functions. This may reduce our stack depth
439
- // a bit.
440
- #[ inline( never) ]
441
- fn deliver_ereport (
442
- rail : Rail ,
443
- packrat : & Packrat ,
444
- data : & impl serde:: Serialize ,
445
- ) {
446
- let mut ereport_buf = [ 0u8 ; 256 ] ;
447
- match packrat. serialize_ereport ( data, & mut ereport_buf[ ..] ) {
448
- Ok ( len) => ringbuf_entry ! ( Trace :: EreportSent ( rail, len) ) ,
449
- Err ( task_packrat_api:: EreportSerializeError :: Packrat { len, err } ) => {
450
- ringbuf_entry ! ( Trace :: EreportLost ( rail, len, err) )
451
- }
452
- Err ( task_packrat_api:: EreportSerializeError :: Serialize ( _) ) => {
453
- ringbuf_entry ! ( Trace :: EreportTooBig ( rail) )
454
- }
455
- }
456
- }
0 commit comments