-
Notifications
You must be signed in to change notification settings - Fork 8
/
p9_pgpe_thread_process_requests.c
1450 lines (1278 loc) · 58.6 KB
/
p9_pgpe_thread_process_requests.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
128
129
130
131
132
133
134
135
136
137
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: import/chips/p9/procedures/ppe_closed/pgpe/pstate_gpe/p9_pgpe_thread_process_requests.c $ */
/* */
/* OpenPOWER HCODE Project */
/* */
/* COPYRIGHT 2016,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
#include "p9_pgpe.h"
#include "gpehw_common.h"
#include "p9_pgpe_pstate.h"
#include "pstate_pgpe_occ_api.h"
#include "wof_sgpe_pgpe_api.h"
#include "ipc_api.h"
#include "ipc_async_cmd.h"
#include "p9_pgpe_header.h"
#include "p9_pgpe_optrace.h"
#include "p9_pgpe_gppb.h"
//
//External Global Data
//
extern TraceData_t G_pgpe_optrace_data;
extern PgpePstateRecord G_pgpe_pstate_record;
extern PgpeHeader_t* G_pgpe_header_data;
extern GlobalPstateParmBlock* G_gppb;
//
//Local Function Prototypes
//
inline void p9_pgpe_process_sgpe_updt_active_cores() __attribute__((always_inline));
inline void p9_pgpe_process_sgpe_updt_active_quads() __attribute__((always_inline));
inline void p9_pgpe_process_start_stop() __attribute__((always_inline));
inline void p9_pgpe_process_clip_updt() __attribute__((always_inline));
inline void p9_pgpe_process_wof_ctrl() __attribute__((always_inline));
inline void p9_pgpe_process_wof_vfrt() __attribute__((always_inline));
inline void p9_pgpe_process_set_pmcr_req() __attribute__((always_inline));
inline void p9_pgpe_process_registration() __attribute__((always_inline));
inline void p9_pgpe_process_ack_sgpe_ctrl_stop_updt() __attribute__((always_inline));
inline void p9_pgpe_process_ack_sgpe_suspend_stop() __attribute__((always_inline));
//
//Process Request Thread
//
//This thread processes IPC request from SGPE and OCC, registration msg(type4),
//PMCR requests(type1), and IPC acks from SGPE. When any of interrupts associated
//with these require happen, the interrupt handler takes a note of the request, and
//posts semaphore.
//
void p9_pgpe_thread_process_requests(void* arg)
{
PK_TRACE_DBG("PTH:Started");
uint32_t restore_irq;
PkMachineContext ctx;
//IPC Init
p9_pgpe_ipc_init();
#if EPM_P9_TUNING
asm volatile ("tw 0, 31, 0");
#endif
// Set OCC Scratch2[PGPE_ACTIVE], so that external world knows that PGPE is UP
// 00 - WOF Phase1(Vratio Fixed,Fratio Fixed)
// 01 - WOF Phase2(Vratio Active Cores, Fratio Fixed)
// 10 - WOF Phase3(Vratio Full, Fratio Fixed)
// 11 - WOF Phase4(Vratio Full, Fratio Full)
// Currently, only Phase 1 and 2 are supported.
if ((G_pgpe_header_data->g_pgpe_flags & PGPE_FLAG_ENABLE_VRATIO) ||
(G_pgpe_header_data->g_pgpe_flags & PGPE_FLAG_VRATIO_MODIFIER) ||
(G_pgpe_header_data->g_pgpe_flags & PGPE_FLAG_ENABLE_FRATIO))
{
out32(G_OCB_OCCFLG_OR, BIT32(29));
}
PK_TRACE_DBG("PTH:Inited");
while(1)
{
//pend on semaphore
PK_TRACE_INF("PTH:Pend");
pk_semaphore_pend(&(G_pgpe_pstate_record.sem_process_req), PK_WAIT_FOREVER);
wrteei(1);
//Enter Sub-Critical Section. Timer Interrupts are enabled
pk_irq_sub_critical_enter(&ctx);
G_pgpe_pstate_record.semProcessPosted = 0;
restore_irq = 1;
PK_TRACE_DBG("PTH: Process Task");
//Go through IPC Pending Table
if (G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_WOF_CTRL].pending_processing)
{
//During processo_wof_ctrl, it's pending_ack bit is cleared
p9_pgpe_process_wof_ctrl();
}
if (G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_SGPE_ACTIVE_CORES_UPDT].pending_processing == 1)
{
p9_pgpe_process_sgpe_updt_active_cores();
//If we have pending_ack for active cores, then don't open up IPC yet. It will be opened
//up after actuation
if(G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_SGPE_ACTIVE_CORES_UPDT].pending_ack == 1)
{
restore_irq = 0;
}
}
if (G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_SGPE_ACTIVE_QUADS_UPDT].pending_processing == 1)
{
//During process_spge_updt_active_quads, it's pending_ack bit may be cleared
p9_pgpe_process_sgpe_updt_active_quads();
}
if ((G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_PSTATE_START_STOP].pending_processing == 1) &&
(G_pgpe_pstate_record.pendingActiveQuadUpdtDone != 1))
{
//During process_start_stop, it's pending_ack bit is cleared
p9_pgpe_process_start_stop();
}
if (G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_CLIP_UPDT].pending_processing == 1)
{
p9_pgpe_process_clip_updt();
//If we have pending_ack for clip_updt cores, then don't open up IPC yet. It will be opened
//up after actuation
if(G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_CLIP_UPDT].pending_ack == 1)
{
restore_irq = 0;
}
}
if (G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_WOF_VFRT].pending_processing == 1)
{
p9_pgpe_process_wof_vfrt();
//If we have pending_ack for wof_vfrt, then don't open up IPC yet. It will be opened
//up after actuation
if(G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_WOF_VFRT].pending_ack == 1)
{
restore_irq = 0;
}
}
if (G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_SET_PMCR_REQ].pending_processing == 1)
{
//During process_start_stop, it's pending_ack bit is cleared
p9_pgpe_process_set_pmcr_req();
}
if (G_pgpe_pstate_record.ipcPendTbl[IPC_ACK_CTRL_STOP_UPDT].pending_processing)
{
p9_pgpe_process_ack_sgpe_ctrl_stop_updt();
}
if (G_pgpe_pstate_record.ipcPendTbl[IPC_ACK_SUSPEND_STOP].pending_processing)
{
p9_pgpe_process_ack_sgpe_suspend_stop();
}
if (G_pgpe_pstate_record.pendQuadsRegisterProcess != 0)
{
p9_pgpe_process_registration();
}
//Restore IPC IRQ if no pending acks. Otherwise, actuate thread will
//eventually restore IPC interrupt. Also, make sure that IPC IRQ did post semphore. We
//can have the case where type4 posted for processing the registration message. In that case,
//no need to call pk_irq_vec_restore as type4 handler calls it. Clear semprocessSrc, and exit
//sub-critical section
if ((G_pgpe_pstate_record.semProcessSrc & SEM_PROCESS_SRC_IPI2_IRQ) && restore_irq == 1)
{
PK_TRACE_DBG("PTH: IRQ Restore");
G_pgpe_pstate_record.semProcessSrc = 0;
pk_irq_sub_critical_exit(&ctx);
pk_irq_vec_restore(&ctx);
}
else
{
G_pgpe_pstate_record.semProcessSrc = 0;
pk_irq_sub_critical_exit(&ctx);
}
}
}
//
// p9_pgpe_process_sgpe_updt_active_cores
//
// Process Update Active Cores IPC sent from SGPE
//
// ACTION:
// 1) Do nothing(error ack), if WOF is disabled
// and active core update action is set to error.
// 2) Update active_cores list and ack right away, if WOF is disabled
// and active core update action is set to ack only.
// 3) Update active cores list, calculate wof clips, and new target pstate,
// if WOF is enabled. If core is entrying stop, then ack is sent right away.
// Otherwise, ack is sent after acutation
// ACK:
// 1) IPC_SGPE_PGPE_RC_SUCCESS - If WOF is disabled and active core update action i
// is ACTIVE_CORE_UPDATE_ACTION_ERROR. Or, WOF is enabled
// 2) SGPE_PGPE_RC_WOF_DISABLED - If WOF is disabled and active core update action i
// is ACTIVE_CORE_UPDATE_ACTION_ERROR
//
inline void p9_pgpe_process_sgpe_updt_active_cores()
{
PK_TRACE_DBG("PTH: Core Updt Entry");
uint32_t c, ack_now = 0, bad_rc = 0;
ipc_async_cmd_t* async_cmd = (ipc_async_cmd_t*)G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_SGPE_ACTIVE_CORES_UPDT].cmd;
ipcmsg_s2p_update_active_cores_t* args = (ipcmsg_s2p_update_active_cores_t*)async_cmd->cmd_data;
G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_SGPE_ACTIVE_CORES_UPDT].pending_processing = 0;
if(G_pgpe_pstate_record.wofStatus != WOF_ENABLED)
{
ack_now = 1;
if (G_pgpe_pstate_record.activeCoreUpdtAction == ACTIVE_CORE_UPDATE_ACTION_ERROR)
{
G_pgpe_optrace_data.word[0] = PGPE_OP_CORES_ACTIVE_IN_WOF_DISABLED;
p9_pgpe_optrace(UNEXPECTED_ERROR);
bad_rc = 1;
PK_TRACE_DBG("PTH: Core Updt(WOF_Disabled) Error");
}
else
{
if (args->fields.update_type == UPDATE_ACTIVE_CORES_TYPE_ENTRY)
{
G_pgpe_pstate_record.activeCores &= ~(args->fields.active_cores << 8);
}
else
{
G_pgpe_pstate_record.activeCores |= (args->fields.active_cores << 8);
}
args->fields.return_active_cores = G_pgpe_pstate_record.activeCores >> 8;
PK_TRACE_INF("PTH: Core Updt(WOF_Disabled) Ack Only numActiveCores=0x%x,activeCores=0x%x",
G_pgpe_pstate_record.numActiveCores, G_pgpe_pstate_record.activeCores);
}
}
else
{
//If WOF_ENABLED=1, and pstatesStatus == ACITVE, then process active cores update
//Otherwise, pstatesStatus == SAFE_MODE_PENDING, and requests will be ACKed
//after actuating to Psafe
if(G_pgpe_pstate_record.pstatesStatus == PSTATE_ACTIVE)
{
//Store separately as shared SRAM location is split
PK_TRACE_INF("PTH: Core Updt type=%u(0/1=EN/EX) reqCores=0x%x", args->fields.update_type, args->fields.active_cores);
//If ENTRY type then send ACK to SGPE immediately
//Otherwise, wait to ACK until WOF Clip has been applied(from actuate_pstate thread)
if (args->fields.update_type == UPDATE_ACTIVE_CORES_TYPE_ENTRY)
{
G_pgpe_pstate_record.activeCores &= ~(args->fields.active_cores << 8);
args->fields.return_active_cores = G_pgpe_pstate_record.activeCores >> 8;
ack_now = 1;
}
else
{
G_pgpe_pstate_record.activeCores |= (args->fields.active_cores << 8);
}
//Update Shared Memory Region
G_pgpe_pstate_record.pQuadState0->fields.active_cores = (G_pgpe_pstate_record.activeCores >> 16);
G_pgpe_pstate_record.pQuadState1->fields.active_cores = (G_pgpe_pstate_record.activeCores & 0x0000FF00);
PK_TRACE_DBG("PTH: quadPS2=0x%08x%08x,activeCores=0x%x", G_pgpe_pstate_record.pQuadState0->value >> 32,
G_pgpe_pstate_record.pQuadState0->value, G_pgpe_pstate_record.pQuadState0->fields.active_cores );
PK_TRACE_DBG("PTH: quadPS1=0x%08x%08x,activeCores=0x%x", G_pgpe_pstate_record.pQuadState1->value >> 32,
G_pgpe_pstate_record.pQuadState1->value, G_pgpe_pstate_record.pQuadState1->fields.active_cores);
//Calculate number of active cores
G_pgpe_pstate_record.numActiveCores = 0;
for (c = 0; c < MAX_CORES; c++)
{
if (G_pgpe_pstate_record.activeCores & CORE_MASK(c))
{
G_pgpe_pstate_record.numActiveCores++;
}
}
PK_TRACE_INF("PTH: numActiveCores=0x%x,activeCores=0x%x", G_pgpe_pstate_record.numActiveCores,
G_pgpe_pstate_record.activeCores);
//OP_TRACE(Do before auction and wof calculation)
G_pgpe_optrace_data.word[0] = (G_pgpe_pstate_record.activeQuads << 24) |
((args->fields.update_type == UPDATE_ACTIVE_CORES_TYPE_ENTRY) ? 0x2000000 : 0x1000000) |
(G_pgpe_pstate_record.activeCores >> 8);
p9_pgpe_optrace(PRC_CORES_ACTV);
//Do auction and wof calculation
p9_pgpe_pstate_do_auction();
p9_pgpe_pstate_calc_wof();
}
}
if (ack_now == 1)
{
G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_SGPE_ACTIVE_CORES_UPDT].pending_ack = 0;
ipc_send_rsp(G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_SGPE_ACTIVE_CORES_UPDT].cmd, IPC_RC_SUCCESS);
PK_TRACE_DBG("PTH: Core Entry ACK back to SGPE");
p9_pgpe_optrace(ACK_CORES_ACTV);
//We set the return code after sending the ipc response. This is because
//SGPE is polling on the return code and will move on as soon as it is set.
//To prevent any race condition, we set the return code afterwards.
if (bad_rc == 1)
{
args->fields.return_code = SGPE_PGPE_RC_WOF_DISABLED;
PGPE_OPTIONAL_TRACE_AND_PANIC(PGPE_SGPE_IPC_ACK_BAD_RC);
}
else
{
args->fields.return_code = IPC_SGPE_PGPE_RC_SUCCESS;
}
}
PK_TRACE_DBG("PTH: Core Updt Exit");
}
//
// p9_pgpe_process_sgpe_updt_active_quads
//
// Process Update Active Quads IPC sent from SGPE
//
// ACTION: Update Active Quads IPC is processed according to it's type. There are
// 4 types: Quad Entry Notify, Quad Entry Done, Quad Exit Notify, and
// Quad Entry Notify.
//
// ACK RETURN CODE:
// 1) IPC_SGPE_PGPE_RC_SUCCESS - If WOF is enabled, then Quad Exit Notify processing is
// delayed until a WOF VFRT is received from OCC. Otherwise, an ACK is sent
// always at the end of this function.
//
inline void p9_pgpe_process_sgpe_updt_active_quads()
{
PK_TRACE_DBG("QX: Quad Updt Start");
uint32_t ack_now = 1;
uint32_t SS;
uint32_t quads_requested;
ipc_async_cmd_t* async_cmd = (ipc_async_cmd_t*)G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_SGPE_ACTIVE_QUADS_UPDT].cmd;
ipcmsg_s2p_update_active_quads_t* args = (ipcmsg_s2p_update_active_quads_t*)async_cmd->cmd_data;
G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_SGPE_ACTIVE_QUADS_UPDT].pending_processing = 0;
if(args->fields.update_type == UPDATE_ACTIVE_QUADS_TYPE_ENTRY) //entry
{
SS = (args->fields.entry_type == UPDATE_ACTIVE_QUADS_ENTRY_TYPE_NOTIFY) ? 0x2 : 0x3;
}
else //exit
{
SS = 0x1;
}
//ENTRY
quads_requested = (args->fields.requested_quads << 2);
if (args->fields.update_type == UPDATE_ACTIVE_QUADS_TYPE_ENTRY)
{
if (args->fields.entry_type == UPDATE_ACTIVE_QUADS_ENTRY_TYPE_NOTIFY)
{
p9_pgpe_pstate_process_quad_entry_notify(quads_requested);
}
else
{
p9_pgpe_pstate_process_quad_entry_done(quads_requested);
}
args->fields.return_active_quads =
((G_pgpe_pstate_record.pReqActQuads->fields.requested_active_quads & (~(quads_requested))) >> 2);
args->fields.return_code = IPC_SGPE_PGPE_RC_SUCCESS;
}
//EXIT
else
{
//Update Shared Memory Region
G_pgpe_pstate_record.pReqActQuads->fields.requested_active_quads |= (quads_requested);
if (args->fields.exit_type == UPDATE_ACTIVE_QUADS_EXIT_TYPE_NOTIFY)
{
//WOF Enabled
//If WOF_ENABLED=1, and pstatesStatus == ACITVE, then request for WOF_VFRT
//Otherwise, we don't as SAFE_MODE or PM_COMPLEX_SUSPEND or STOP is pending
if(G_pgpe_pstate_record.wofStatus == WOF_ENABLED && G_pgpe_pstate_record.pstatesStatus == PSTATE_ACTIVE)
{
PK_TRACE_INF("PTH: OCCLFG[30] set");
out32(G_OCB_OCCFLG_OR, BIT32(REQUESTED_ACTIVE_QUAD_UPDATE));//Set OCCFLG[REQUESTED_ACTIVE_QUAD_UPDATE]
ack_now = 0;
}
else
{
p9_pgpe_pstate_process_quad_exit_notify(quads_requested);
args->fields.return_active_quads = G_pgpe_pstate_record.pReqActQuads->fields.requested_active_quads >>
2; //activeQuads isn't updated until registration, so we OR with requested quads.
args->fields.return_code = IPC_SGPE_PGPE_RC_SUCCESS;
}
}
else
{
p9_pgpe_pstate_process_quad_exit_done();
args->fields.return_active_quads = G_pgpe_pstate_record.pReqActQuads->fields.requested_active_quads >>
2; //activeQuads isn't updated until registration, so we OR with requested quads.
args->fields.return_code = IPC_SGPE_PGPE_RC_SUCCESS;
}
}
PK_TRACE_INF("QU: type=0x%x(EN=0,EX=1), req=0x%x,active=0x%x,ret=0x%x", args->fields.update_type,
args->fields.requested_quads, G_pgpe_pstate_record.activeQuads, args->fields.return_active_quads);
G_pgpe_optrace_data.word[0] = (args->fields.requested_quads << 26) |
(SS << 24) |
(G_pgpe_pstate_record.activeCores >> 8);
p9_pgpe_optrace(PRC_QUAD_ACTV);
if (ack_now == 1)
{
G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_SGPE_ACTIVE_QUADS_UPDT].pending_ack = 0;
ipc_send_rsp(G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_SGPE_ACTIVE_QUADS_UPDT].cmd, IPC_RC_SUCCESS);
p9_pgpe_optrace(ACK_QUAD_ACTV);
}
PK_TRACE_DBG("QX: Quad Updt End");
}
//
// p9_pgpe_process_start_stop
//
// Process PSTATE_START_STOP IPC from OCC
//
// ACTION:
// 1) Start Pstates and Set Onwer - If ACTION is START and PstatesStatus is INIT or STOPPED
// 2) Change PMCR Owner - If ACTION is START and PstatesStatus is ACTIVE
// 3) Stop Pstates - If ACTION is STOP and PstatesStatus is ACTIVE
// 4) Do nothing - If ACTION is STOP and PstatesStatus is STOPPED or INIT
//
// ACK RETURN CODE:
// 1) PGPE_RC_SUCCESS
// a) If PGPE_FLAG_OCC_IPC_IMMEDIATE_MODE is set in PGPE_FLAGS.
// b) If PstateStatus is NOT one of these PSTATE_PM_SUSPEND_PENDING or
// PSTATE_PM_SUSPENDED or PSTATE_SAFE_MODE_PENDING or PSTATE_SAFE_MODE.
// 2) PGPE_RC_PM_COMPLEX_SUSPEND_SAFE_MODE
// a) If PstateStatus is one of these PSTATE_PM_SUSPEND_PENDING or
// PSTATE_PM_SUSPENDED or PSTATE_SAFE_MODE_PENDING or PSTATE_SAFE_MODE.
//
inline void p9_pgpe_process_start_stop()
{
PK_TRACE_DBG("PTH: Start/Stop Entry");
uint32_t ack_now = 1, bad_rc = 0;
ipc_async_cmd_t* async_cmd = (ipc_async_cmd_t*)G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_PSTATE_START_STOP].cmd;
ipcmsg_start_stop_t* args = (ipcmsg_start_stop_t*)async_cmd->cmd_data;
if(G_pgpe_header_data->g_pgpe_flags & PGPE_FLAG_OCC_IPC_IMMEDIATE_MODE)
{
PK_TRACE_DBG("START_STOP: Imm");
args->msg_cb.rc = PGPE_RC_SUCCESS;
G_pgpe_optrace_data.word[0] = (args->pmcr_owner << 25 ) |
(PSTATE_START << 24) |
(G_pgpe_pstate_record.psCurr.fields.glb << 16) |
(in32(G_OCB_QCSR) >> 16);
p9_pgpe_optrace(PRC_START_STOP);
}
else if(G_pgpe_pstate_record.pstatesStatus & (PSTATE_PM_SUSPEND_PENDING | PSTATE_PM_SUSPENDED |
PSTATE_SAFE_MODE_PENDING | PSTATE_SAFE_MODE))
{
PK_TRACE_DBG("START_STOP: PM_SUSP/Safe");
args->msg_cb.rc = PGPE_RC_PM_COMPLEX_SUSPEND_SAFE_MODE;
if(G_pgpe_pstate_record.pstatesStatus & (PSTATE_SAFE_MODE_PENDING | PSTATE_SAFE_MODE))
{
if (args->action == PGPE_ACTION_PSTATE_START)
{
G_pgpe_optrace_data.word[0] = PGPE_OP_PSTATE_START_IN_SAFE_MODE;
}
else
{
G_pgpe_optrace_data.word[0] = PGPE_OP_PSTATE_STOP_IN_SAFE_MODE;
}
}
else
{
if (args->action == PGPE_ACTION_PSTATE_START)
{
G_pgpe_optrace_data.word[0] = PGPE_OP_PSTATE_START_IN_PM_SUSP;
}
else
{
G_pgpe_optrace_data.word[0] = PGPE_OP_PSTATE_STOP_IN_PM_SUSP;
}
}
p9_pgpe_optrace(UNEXPECTED_ERROR);
bad_rc = 1;
}
else
{
//If Start
if (args->action == PGPE_ACTION_PSTATE_START)
{
if ((args->pmcr_owner == PMCR_OWNER_HOST) ||
(args->pmcr_owner == PMCR_OWNER_OCC) ||
(args->pmcr_owner == PMCR_OWNER_CHAR))
{
if(G_pgpe_pstate_record.pstatesStatus & (PSTATE_INIT | PSTATE_STOPPED))
{
p9_pgpe_pstate_start(PSTATE_START_OCC_IPC);
args->msg_cb.rc = PGPE_RC_SUCCESS;
pk_semaphore_post(&G_pgpe_pstate_record.sem_actuate);
}
else if (G_pgpe_pstate_record.pstatesStatus == PSTATE_ACTIVE)
{
p9_pgpe_pstate_set_pmcr_owner(args->pmcr_owner);
args->msg_cb.rc = PGPE_RC_SUCCESS;
}
G_pgpe_optrace_data.word[0] = (args->pmcr_owner << 25 ) |
(PSTATE_START << 24) |
(G_pgpe_pstate_record.psCurr.fields.glb << 16) |
(in32(G_OCB_QCSR) >> 16);
p9_pgpe_optrace(PRC_START_STOP);
}
else
{
args->msg_cb.rc = PGPE_RC_INVALID_PMCR_OWNER;
p9_pgpe_optrace(UNEXPECTED_ERROR);
bad_rc = 1;
}
}
else
{
if(G_pgpe_pstate_record.pstatesStatus & (PSTATE_INIT | PSTATE_STOPPED))
{
PK_TRACE_DBG("START_STOP: Already Stopped");
args->msg_cb.rc = PGPE_RC_SUCCESS;
G_pgpe_optrace_data.word[0] = PGPE_OP_PSTATE_STOP_IN_PSTATE_STOPPED;
p9_pgpe_optrace(UNEXPECTED_ERROR);
bad_rc = 1;
}
else if (G_pgpe_pstate_record.pstatesStatus == PSTATE_ACTIVE)
{
p9_pgpe_pstate_stop();
args->msg_cb.rc = PGPE_RC_SUCCESS;
G_pgpe_optrace_data.word[0] = (G_pgpe_pstate_record.psCurr.fields.glb << 16) |
(in32(G_OCB_QCSR) >> 16);
p9_pgpe_optrace(PRC_START_STOP);
}
}
}
if (ack_now == 1)
{
ipc_send_rsp(G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_PSTATE_START_STOP].cmd, IPC_RC_SUCCESS);
G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_PSTATE_START_STOP].pending_ack = 0;
G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_PSTATE_START_STOP].pending_processing = 0;
p9_pgpe_optrace(ACK_START_STOP);
if (bad_rc == 1)
{
PGPE_OPTIONAL_TRACE_AND_PANIC(PGPE_OCC_IPC_ACK_BAD_RC);
}
}
PK_TRACE_DBG("PTH: Start/Stop End");
}
//
//p9_pgpe_process_clip_updt
//
// Process CLIP_UPDATE IPC from OCC
//
// ACTION:
// 1) Ack back only - If PGPE_FLAG_OCC_IPC_IMMEDIATE_MODE is set in PGPE_FLAGS.
// 2) Ack back with error - If PstateStatus is NOT one of these
// PSTATE_PM_SUSPEND_PENDING or PSTATE_PM_SUSPENDED or PSTATE_SAFE_MODE_PENDING
// or PSTATE_SAFE_MODE.
// 3) Update Clips and Calculate New Pstart Target - If PstateStatus is NOT
// one of these PSTATE_PM_SUSPEND_PENDING or PSTATE_PM_SUSPENDED or
// PSTATE_SAFE_MODE_PENDING or PSTATE_SAFE_MODE.
//
// ACK RETURN CODE:
// 1) PGPE_RC_SUCCESS
// a) If PGPE_FLAG_OCC_IPC_IMMEDIATE_MODE is set in PGPE_FLAGS.
// b) If PstateStatus is NOT one of these PSTATE_PM_SUSPEND_PENDING or
// PSTATE_PM_SUSPENDED or PSTATE_SAFE_MODE_PENDING or PSTATE_SAFE_MODE.
// Ack is sent right away if Pstates aren't active. Or, after system
// has been actuated within the bounds of the clips
// 2) PGPE_RC_PM_COMPLEX_SUSPEND_SAFE_MODE
// a) If PstateStatus is one of these PSTATE_PM_SUSPEND_PENDING or
// PSTATE_PM_SUSPENDED or PSTATE_SAFE_MODE_PENDING or PSTATE_SAFE_MODE.
//
inline void p9_pgpe_process_clip_updt()
{
PK_TRACE_DBG("PTH: Clip Updt Entry");
uint32_t q, ack_now = 1, bad_rc = 0;
ipc_async_cmd_t* async_cmd = (ipc_async_cmd_t*)G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_CLIP_UPDT].cmd;
ipcmsg_clip_update_t* args = (ipcmsg_clip_update_t*)async_cmd->cmd_data;
G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_CLIP_UPDT].pending_processing = 0;
if(G_pgpe_header_data->g_pgpe_flags & PGPE_FLAG_OCC_IPC_IMMEDIATE_MODE)
{
PK_TRACE_DBG("PTH: Clip Updt Imme");
args->msg_cb.rc = PGPE_RC_SUCCESS;
G_pgpe_optrace_data.word[0] = (G_pgpe_pstate_record.psClipMax[0] << 24) |
(G_pgpe_pstate_record.psClipMax[1] << 16) |
(G_pgpe_pstate_record.psClipMax[2] << 8) |
(G_pgpe_pstate_record.psClipMax[3]);
G_pgpe_optrace_data.word[1] = (G_pgpe_pstate_record.psClipMax[4] << 24) |
(G_pgpe_pstate_record.psClipMax[5] << 16) |
(G_pgpe_pstate_record.psClipMin[0] << 8) |
(G_pgpe_pstate_record.psClipMin[1]);
G_pgpe_optrace_data.word[2] = (G_pgpe_pstate_record.psClipMin[2] << 24) |
(G_pgpe_pstate_record.psClipMin[3] << 16) |
(G_pgpe_pstate_record.psClipMin[4] << 8) |
(G_pgpe_pstate_record.psClipMin[5]);
p9_pgpe_optrace(PRC_CLIP_UPDT);
}
else if (G_pgpe_pstate_record.pstatesStatus & (PSTATE_PM_SUSPENDED |
PSTATE_PM_SUSPEND_PENDING |
PSTATE_SAFE_MODE_PENDING |
PSTATE_SAFE_MODE))
{
PK_TRACE_DBG("PTH: Clip Updt PMSUSP/Safe");
args->msg_cb.rc = PGPE_RC_PM_COMPLEX_SUSPEND_SAFE_MODE;
if(G_pgpe_pstate_record.pstatesStatus & (PSTATE_SAFE_MODE_PENDING |
PSTATE_SAFE_MODE))
{
G_pgpe_optrace_data.word[0] = PGPE_OP_CLIP_UPDT_IN_SAFE_MODE;
}
else
{
G_pgpe_optrace_data.word[0] = PGPE_OP_CLIP_UPDT_IN_PM_SUSP;
}
p9_pgpe_optrace(UNEXPECTED_ERROR);
bad_rc = 1;
}
else
{
//IPC from 405 treats clip_min as Pstate for min frequency(higher numbered)
//and clip_max as Pstate for max frequency(lower numbered). However, PGPE
//Hcode stores them with reverse interpretation.
for (q = 0; q < MAX_QUADS; q++)
{
if (G_pgpe_pstate_record.psClipMax[q] != args->ps_val_clip_min[q])
{
G_pgpe_pstate_record.psClipMax[q] = args->ps_val_clip_min[q];
G_pgpe_pstate_record.pendingPminClipBcast = 1;
}
//We can't have max freq/voltage to be below safePstate, so just halt PGPE
if(args->ps_val_clip_max[q] > G_pgpe_pstate_record.safePstate)
{
PGPE_TRACE_AND_PANIC(PGPE_PMAX_RCV_GREATER_THAN_PSAFE);
}
if (G_pgpe_pstate_record.psClipMin[q] != args->ps_val_clip_max[q])
{
G_pgpe_pstate_record.psClipMin[q] = args->ps_val_clip_max[q];
G_pgpe_pstate_record.pendingPmaxClipBcast = 1;
}
}
G_pgpe_optrace_data.word[0] = (G_pgpe_pstate_record.psClipMax[0] << 24) |
(G_pgpe_pstate_record.psClipMax[1] << 16) |
(G_pgpe_pstate_record.psClipMax[2] << 8) |
(G_pgpe_pstate_record.psClipMax[3]);
G_pgpe_optrace_data.word[1] = (G_pgpe_pstate_record.psClipMax[4] << 24) |
(G_pgpe_pstate_record.psClipMax[5] << 16) |
(G_pgpe_pstate_record.psClipMin[0] << 8) |
(G_pgpe_pstate_record.psClipMin[1]);
G_pgpe_optrace_data.word[2] = (G_pgpe_pstate_record.psClipMin[2] << 24) |
(G_pgpe_pstate_record.psClipMin[3] << 16) |
(G_pgpe_pstate_record.psClipMin[4] << 8) |
(G_pgpe_pstate_record.psClipMin[5]);
p9_pgpe_optrace(PRC_CLIP_UPDT);
p9_pgpe_pstate_apply_clips(&G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_CLIP_UPDT]);
//If CLIP_UPDT before Pstate Start, then ack now. Otherwise, ACK
//after actuation
if (G_pgpe_pstate_record.pstatesStatus & (PSTATE_INIT | PSTATE_STOPPED))
{
args->msg_cb.rc = PGPE_RC_SUCCESS;
}
else
{
ack_now = 0;
}
}
//Clips ACKed in error cases or if Pstates are not active yet
if (ack_now == 1)
{
G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_CLIP_UPDT].pending_ack = 0;
ipc_send_rsp(G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_CLIP_UPDT].cmd, IPC_RC_SUCCESS);
p9_pgpe_optrace(ACK_CLIP_UPDT);
if (bad_rc == 1)
{
PGPE_OPTIONAL_TRACE_AND_PANIC(PGPE_OCC_IPC_ACK_BAD_RC);
}
}
PK_TRACE_DBG("PTH: Clip Upd Exit");
}
//
// p9_pgpe_process_wof_ctrl
//
// Process WOF_CTRL IPC from OCC
//
// ACTION:
// 1) Ack back only -
// a) If PGPE_FLAG_OCC_IPC_IMMEDIATE_MODE is set in PGPE_FLAGS.
// b) If WOF_CTRL(Enable) when WOF is already enabled
// c) If WOF_CTRL(Disable) when WOF is already disabled
// 2) Ack with error -
// a) If PstatesStatus is one of these PSTATE_INIT, PSTATE_STOPPED,
// PSTATE_PM_SUSPENDED, PSTATE_PM_SUSPEND_PENDING,
// PSTATE_SAFE_MODE_PENDING, PSTATE_SAFE_MODE
// b) If NULL VFRT pointer is sent
// 3) Enable WOF - If WOF_CTRL(Enable), WOF is disabled and PstatesStatus is ACTIVE
// 3) Disable WOF - If WOF_CTRL(Enable), WOF is enabled and PstatesStatus is ACTIVE
//
// ACK RETURN CODE:
// 1) PGPE_RC_PSTATES_NOT_STARTED - If PstatesStatus is one of
// these PSTATE_INIT or PSTATE_STOPPED.
// 2) PGPE_RC_PM_COMPLEX_SUSPEND_SAFE_MODE - If PstatesStatus is one of these
// PSTATE_PM_SUSPENDED, PSTATE_PM_SUSPEND_PENDING,
// PSTATE_SAFE_MODE_PENDING, PSTATE_SAFE_MODE
// 4) PGPE_RC_SUCCESS -
// a) If PGPE_FLAG_OCC_IPC_IMMEDIATE_MODE is set in PGPE_FLAGS.
// b) If WOF_CTRL(Enable) when WOF is already enabled
// c) If WOF_CTRL(Disable) when WOF is already disabled
//
inline void p9_pgpe_process_wof_ctrl()
{
PK_TRACE_DBG("PTH: WOF Ctrl Enter");
uint32_t ack_now = 1, bad_rc = 0;
ipc_async_cmd_t* async_cmd = (ipc_async_cmd_t*)G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_WOF_CTRL].cmd;
ipcmsg_wof_control_t* args = (ipcmsg_wof_control_t*)async_cmd->cmd_data;
G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_WOF_CTRL].pending_processing = 0;
if((G_pgpe_header_data->g_pgpe_flags & PGPE_FLAG_OCC_IPC_IMMEDIATE_MODE) ||
(G_pgpe_header_data->g_pgpe_flags & PGPE_FLAG_WOF_IPC_IMMEDIATE_MODE))
{
PK_TRACE_DBG("PTH: WOF Ctrl Imme");
args->msg_cb.rc = PGPE_RC_SUCCESS;
G_pgpe_optrace_data.word[0] = (G_pgpe_pstate_record.activeQuads << 24) |
(args->action << 16) |
(in32(G_OCB_QCSR) >> 16);
p9_pgpe_optrace(PRC_WOF_CTRL);
}
else if (G_pgpe_pstate_record.pstatesStatus & ( PSTATE_PM_SUSPENDED | PSTATE_PM_SUSPEND_PENDING |
PSTATE_SAFE_MODE_PENDING | PSTATE_SAFE_MODE))
{
PK_TRACE_DBG("PTH: WOF Ctrl PMSUSP/Safe");
args->msg_cb.rc = PGPE_RC_PM_COMPLEX_SUSPEND_SAFE_MODE;
if(G_pgpe_pstate_record.pstatesStatus & (PSTATE_SAFE_MODE_PENDING | PSTATE_SAFE_MODE))
{
G_pgpe_optrace_data.word[0] = PGPE_OP_WOF_CTRL_IN_SAFE_MODE;
}
else
{
G_pgpe_optrace_data.word[0] = PGPE_OP_WOF_CTRL_IN_PM_SUSP;
}
p9_pgpe_optrace(UNEXPECTED_ERROR);
bad_rc = 1;
}
else if(G_pgpe_pstate_record.pstatesStatus & (PSTATE_INIT | PSTATE_STOPPED))
{
PK_TRACE_DBG("PTH: WOF Ctrl PSStop/Init");
args->msg_cb.rc = PGPE_RC_PSTATES_NOT_STARTED;
G_pgpe_optrace_data.word[0] = PGPE_OP_WOF_CTRL_IN_PSTATE_STOPPED;
p9_pgpe_optrace(UNEXPECTED_ERROR);
bad_rc = 1;
}
else
{
//If WOF ON
if (args->action == PGPE_ACTION_WOF_ON)
{
if(G_pgpe_pstate_record.wofStatus == WOF_DISABLED)
{
PK_TRACE_INF("PTH: WOF Ctrl=ON,WOF_Enabled=0");
p9_pgpe_pstate_wof_ctrl(PGPE_ACTION_WOF_ON);
ack_now = 0; //For WOF_ENABLE, we ACK after WOF_CLIP has been honored(actuate thread)
G_pgpe_optrace_data.word[0] = (G_pgpe_pstate_record.activeQuads << 24) |
(args->action << 16) |
(in32(G_OCB_QCSR) >> 16);
p9_pgpe_optrace(PRC_WOF_CTRL);
}
else
{
args->msg_cb.rc = PGPE_RC_SUCCESS;
PK_TRACE_INF("PTH: WOF Ctrl=ON,WOF_Enabled=1");
G_pgpe_optrace_data.word[0] = PGPE_OP_WOF_CTRL_ENABLE_WHEN_ENABLED;
p9_pgpe_optrace(UNEXPECTED_ERROR);
bad_rc = 1;
}
}
else if (args->action == PGPE_ACTION_WOF_OFF)
{
if(G_pgpe_pstate_record.wofStatus == WOF_ENABLED)
{
PK_TRACE_INF("PTH: WOF Ctrl=OFF,WOF_Enabled=1");
//Disable WOF, and we ACK to OCC below
p9_pgpe_pstate_wof_ctrl(PGPE_ACTION_WOF_OFF);
G_pgpe_optrace_data.word[0] = (G_pgpe_pstate_record.activeQuads << 24) |
(args->action << 16) |
(in32(G_OCB_QCSR) >> 16);
p9_pgpe_optrace(PRC_WOF_CTRL);
args->msg_cb.rc = PGPE_RC_SUCCESS;
}
else
{
args->msg_cb.rc = PGPE_RC_SUCCESS;
PK_TRACE_INF("PTH: WOF Ctrl=OFF,WOF_Enabled=0");
G_pgpe_optrace_data.word[0] = PGPE_OP_WOF_CTRL_DISABLE_WHEN_DISABLED;
p9_pgpe_optrace(UNEXPECTED_ERROR);
bad_rc = 1;
}
}
}
if (ack_now == 1)
{
G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_WOF_CTRL].pending_ack = 0;
ipc_send_rsp(G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_WOF_CTRL].cmd, IPC_RC_SUCCESS);
p9_pgpe_optrace(ACK_WOF_CTRL);
if (bad_rc == 1)
{
PGPE_OPTIONAL_TRACE_AND_PANIC(PGPE_OCC_IPC_ACK_BAD_RC);
}
}
PK_TRACE_DBG("PTH: WOF Ctrl Exit");
}
//
// p9_pgpe_process_wof_vfrt
//
// ACTION:
// 1) Ack back only - If PGPE_FLAG_OCC_IPC_IMMEDIATE_MODE is set in PGPE_FLAGS.
// 2) Ack with error -
// a) If PstatesStatus is one of these PSTATE_INIT, PSTATE_STOPPED,
// PSTATE_PM_SUSPENDED, PSTATE_PM_SUSPEND_PENDING,
// PSTATE_SAFE_MODE_PENDING, PSTATE_SAFE_MODE
// b) If NULL VFRT pointer is sent
// 3) Update VFRT pointer, and if wof is enabled then
// calculate wof clips, and generate new targets. Ack is sent right away
// if WOF is enabled. Otherwise, ack is sent after actuation
//
// ACK RETURN CODE:
// 1) PGPE_RC_PSTATES_NOT_STARTED - If PstatesStatus is one of
// these PSTATE_INIT or PSTATE_STOPPED.
// 2) PGPE_RC_PM_COMPLEX_SUSPEND_SAFE_MODE - If PstatesStatus is one of these
// PSTATE_PM_SUSPENDED, PSTATE_PM_SUSPEND_PENDING,
// PSTATE_SAFE_MODE_PENDING, PSTATE_SAFE_MODE
// 3) PGPE_RC_NULL_VFRT_POINTER - If NULL VFRT pointer is sent.
// 4) PGPE_RC_SUCCESS -
// a) If Pstate Status is ACTIVE and VFRT pointer is not NULL.
// b) If PGPE_FLAG_OCC_IPC_IMMEDIATE_MODE is set in PGPE_FLAGS.
//
inline void p9_pgpe_process_wof_vfrt()
{
PK_TRACE_DBG("PTH: WOF VFRT Enter");
uint32_t ack_now = 1, bad_rc = 0;
ipc_async_cmd_t* async_cmd = (ipc_async_cmd_t*)G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_WOF_VFRT].cmd;
ipcmsg_wof_vfrt_t* args = (ipcmsg_wof_vfrt_t*)async_cmd->cmd_data;
G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_WOF_VFRT].pending_processing = 0;
if((G_pgpe_header_data->g_pgpe_flags & PGPE_FLAG_OCC_IPC_IMMEDIATE_MODE) ||
(G_pgpe_header_data->g_pgpe_flags & PGPE_FLAG_WOF_IPC_IMMEDIATE_MODE))
{
PK_TRACE_DBG("PTH: WOF VFRT Imme");
args->msg_cb.rc = PGPE_RC_SUCCESS;
G_pgpe_optrace_data.word[0] = 0;
G_pgpe_optrace_data.word[1] = 0;
p9_pgpe_optrace(PRC_WOF_VFRT);
}
else if (G_pgpe_pstate_record.pstatesStatus & (PSTATE_PM_SUSPENDED | PSTATE_PM_SUSPEND_PENDING |
PSTATE_SAFE_MODE_PENDING | PSTATE_SAFE_MODE))
{
PK_TRACE_DBG("PTH: WOF VFRT PMSUSP/Safe");
args->msg_cb.rc = PGPE_RC_PM_COMPLEX_SUSPEND_SAFE_MODE;
if(G_pgpe_pstate_record.pstatesStatus & (PSTATE_SAFE_MODE_PENDING | PSTATE_SAFE_MODE))
{
G_pgpe_optrace_data.word[0] = PGPE_OP_WOF_VFRT_IN_SAFE_MODE;
}
else
{
G_pgpe_optrace_data.word[0] = PGPE_OP_WOF_VFRT_IN_PM_SUSP;
}
p9_pgpe_optrace(UNEXPECTED_ERROR);
bad_rc = 1;
}
else if(G_pgpe_pstate_record.pstatesStatus & (PSTATE_STOPPED | PSTATE_INIT))
{
PK_TRACE_DBG("PTH: WOF VFRT PSStop/Init");
args->msg_cb.rc = PGPE_RC_PSTATES_NOT_STARTED;
G_pgpe_optrace_data.word[0] = PGPE_OP_WOF_VFRT_IN_PSTATE_STOPPED;
p9_pgpe_optrace(UNEXPECTED_ERROR);
bad_rc = 1;
}
else
{
if(args->homer_vfrt_ptr == NULL)
{
PK_TRACE_ERR("PTH: NULL VFRT Ptr");
bad_rc = 1;
args->msg_cb.rc = PGPE_RC_NULL_VFRT_POINTER;
}
//Update VFRT pointer
G_pgpe_pstate_record.pVFRT = args->homer_vfrt_ptr;
PK_TRACE_INF("PTH: VFRT Table 0x%x", (uint32_t)G_pgpe_pstate_record.pVFRT);
PK_TRACE_INF("Mgc=0x%x, ver=%d, vdnid=%x,VddQAId=%x", G_pgpe_pstate_record.pVFRT->vfrtHeader.magic_number,
G_pgpe_pstate_record.pVFRT->vfrtHeader.type_version,
G_pgpe_pstate_record.pVFRT->vfrtHeader.res_vdnId,
G_pgpe_pstate_record.pVFRT->vfrtHeader.VddId_QAId);
G_pgpe_optrace_data.word[0] = ((G_pgpe_pstate_record.pVFRT->vfrtHeader.magic_number << 16) |
G_pgpe_pstate_record.pVFRT->vfrtHeader.reserved);
G_pgpe_optrace_data.word[1] = ((G_pgpe_pstate_record.pVFRT->vfrtHeader.type_version << 24) |
(G_pgpe_pstate_record.pVFRT->vfrtHeader.res_vdnId << 16) |
(G_pgpe_pstate_record.pVFRT->vfrtHeader.VddId_QAId << 8) |
G_pgpe_pstate_record.pVFRT->vfrtHeader.rsvd_QAId);
p9_pgpe_optrace(PRC_WOF_VFRT);
if(G_pgpe_pstate_record.wofStatus == WOF_ENABLED)
{
p9_pgpe_pstate_calc_wof();
ack_now = 0;
}
else
{
args->msg_cb.rc = PGPE_RC_SUCCESS;
}
}
if (ack_now == 1)
{
G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_WOF_VFRT].pending_ack = 0;
ipc_send_rsp(G_pgpe_pstate_record.ipcPendTbl[IPC_PEND_WOF_VFRT].cmd, IPC_RC_SUCCESS);
p9_pgpe_optrace(ACK_WOF_VFRT);
if (bad_rc == 1)