summaryrefslogtreecommitdiffstats
path: root/src/usr/diag/prdf/common/plat/pegasus/prdfCenMbaTdCtlr_rt.C
blob: a2bc9ca83577bf6767500d3381e00c8aaf77c1f7 (plain)
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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/diag/prdf/common/plat/pegasus/prdfCenMbaTdCtlr_rt.C $ */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2016,2018                        */
/* [+] 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 <prdfCenMbaTdCtlr_rt.H>

// Framework includes
#include <iipconst.h>
#include <prdfGlobal.H>
#include <prdfTrace.H>
#include <prdfExtensibleChip.H>
#include <prdfPlatServices.H>
#include <UtilHash.H>
#include <prdfRegisterCache.H>

#ifndef __HOSTBOOT_RUNTIME
  #include <prdfSdcFileControl.H>
#endif

// Pegasus includes
#include <prdfCenAddress.H>
#include <prdfCenDqBitmap.H>
#include <prdfCenMbaDataBundle.H>
#include <prdfCenMbaExtraSig.H>
#include <prdfCalloutUtil.H>
#include <prdfCenMemUtils.H>
#include <prdfCenMbaThresholds.H>
#include <prdfCenMbaDynMemDealloc_rt.H>

using namespace TARGETING;

namespace PRDF
{

using namespace CalloutUtil;
using namespace PlatServices;
using namespace MemUtils;

//------------------------------------------------------------------------------
//                            Class Variables
//------------------------------------------------------------------------------

CenMbaTdCtlr::FUNCS CenMbaTdCtlr::cv_cmdCompleteFuncs[] =
{
    &CenMbaTdCtlr::analyzeCmdComplete,      // NO_OP
    &CenMbaTdCtlr::analyzeVcmPhase1,        // VCM_PHASE_1
    &CenMbaTdCtlr::analyzeVcmPhase2,        // VCM_PHASE_2
    &CenMbaTdCtlr::analyzeDsdPhase1,        // DSD_PHASE_1
    NULL,                                   // DSD_PHASE_2
    &CenMbaTdCtlr::analyzeTpsPhase1,        // TPS_PHASE_1
    NULL,                                   // TPS_PHASE_2
};

//------------------------------------------------------------------------------
//                            Private Functions
//------------------------------------------------------------------------------

int32_t CenMbaTdCtlr::analyzeDsdPhase1( STEP_CODE_DATA_STRUCT & io_sc,
                                        const CenAddr & i_stopAddr,
                                        const CenAddr & i_endAddr )
{
    #define PRDF_FUNC "[CenMbaTdCtlr::analyzeDsdPhase1] "

    int32_t o_rc = SUCCESS;

    do
    {
        if ( DSD_PHASE_1 != iv_tdState )
        {
            PRDF_ERR( PRDF_FUNC "Invalid state machine configuration" );
            o_rc = FAIL; break;
        }

        // Add the mark to the callout list.
        CalloutUtil::calloutMark( iv_mbaTrgt, iv_rank, iv_mark, io_sc );

        // Check for any ECC errors that occurred during the procedure.
        uint16_t eccErrorMask = NO_ERROR;
        o_rc = checkEccErrors( eccErrorMask, io_sc );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "checkEccErrors() failed" );
            break;
        }

        if ( eccErrorMask & UE )
        {
            o_rc = handleUe_Td( io_sc, i_stopAddr );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "handleUe_Td() failed" );
                break;
            }

            // Abort the procedure.
            iv_tdState = NO_OP;
            break;
        }

        if ( eccErrorMask & RETRY_CTE )
        {
            o_rc = handleRceEte_Td( io_sc );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "handleRceEte_Td() failed" );
                break;
            }
        }

        if ( i_endAddr == i_stopAddr )
        {
            // At this point, the procedure has not been aborted due to an error
            // like a memory UE so consider the spare successful.
            setTdSignature( io_sc, PRDFSIG_DsdDramSpared );

            // Remove chip mark from hardware.
            iv_mark.clearCM();

            // There is small time window where hardware places a chip mark
            // immediately after it is removed, but before the HWP procedure can
            // query the FIR registers. In this case, we will simply allow the
            // write to be 'blocked' and handle the new chip mark in a separate
            // attention.
            bool allowWriteBlocked = true;
            bool blocked; // Currently ignored.
            o_rc = mssSetMarkStore( iv_mbaTrgt, iv_rank, iv_mark, blocked,
                                    allowWriteBlocked );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "mssSetMarkStore() failed" );
                break;
            }

            // Always reset the state machine after DSD Phase 1 is complete.
            iv_tdState = NO_OP;
        }
        else
        {
            // Restart the scrub on the next address.
            o_rc = resumeScrub( io_sc, eccErrorMask );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "resumeScrub() failed" );
                break;
            }
        }

    } while(0);

    // If this TD procedure was completed or aborted, execute TD complete
    // sequence.
    if ( (iv_tdState == NO_OP) && (SUCCESS == o_rc) )
    {
        o_rc = handleTdComplete( io_sc );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "handleTdComplete() failed" );
        }
    }

    return o_rc;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

int32_t CenMbaTdCtlr::analyzeTpsPhase1( STEP_CODE_DATA_STRUCT & io_sc,
                                        const CenAddr & i_stopAddr,
                                        const CenAddr & i_endAddr )
{
    #define PRDF_FUNC "[CenMbaTdCtlr::analyzeTpsPhase1] "

    int32_t o_rc = SUCCESS;

    do
    {
        if ( TPS_PHASE_1 != iv_tdState )
        {
            PRDF_ERR( PRDF_FUNC "Invalid state machine configuration" );
            o_rc = FAIL; break;
        }

        // Get the current marks in hardware (initialize iv_mark).
        o_rc = mssGetMarkStore( iv_mbaTrgt, iv_rank, iv_mark );
        if ( SUCCESS != o_rc )
        {
           PRDF_ERR( PRDF_FUNC "mssGetMarkStore() failed." );
           break;
        }

        const bool reachedEndAddr = ( i_stopAddr == i_endAddr );

        // Check for any ECC errors that occurred during the procedure.
        uint16_t eccErrorMask = NO_ERROR;
        o_rc = checkEccErrors( eccErrorMask, io_sc );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "checkEccErrors() failed" );
            break;
        }

        // The order of the following checks is important. Each call to handle
        // an error will set the PRD signature and override the previous
        // signature. We want the highest priority error signature (memory UEs)
        // to be displayed so these checks should be ordered from lowest to
        // highest priority.

        if ( eccErrorMask & MPE )
        {
            // Only error that will not potentially produce a predictive error,
            // so lowest priority.

            o_rc = handleMpe_Tps( io_sc );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "handleMpe_Tps() failed" );
                break;
            }

            // Abort this procedure and the do the VCM procedure.
            iv_tdState = NO_OP;
            break;
        }

        // The hardware thresholds are intentionally set to the max value for
        // stop on error conditions in the middle of the scrub. Therefore, we
        // must check the per symbol counters for threshold regardless of any
        // CTE attentions if the scrub has reached the end of the rank.
        // Otherwise, check the per symbol counters only of a CTE attention is
        // raised somewhere in the middle of the scrub.
        bool ceTypeTh = iv_tpsRankData.checkCeTypeTh(iv_rank);
        if ( ( reachedEndAddr                              ) ||
             ( !ceTypeTh &&  (eccErrorMask & HARD_CTE )    ) ||
             (  ceTypeTh && ((eccErrorMask & SOFT_CTE ) ||
                             (eccErrorMask & INTER_CTE) ||
                             (eccErrorMask & HARD_CTE ))   ) )
        {
            o_rc = handleCeEte_Tps( io_sc );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "handleCeEte_Tps() failed" );
                break;
            }
        }

        if ( eccErrorMask & RETRY_CTE )
        {
            o_rc = handleRceEte_Td( io_sc );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "handleRceEte_Td() failed" );
                break;
            }
        }

        if ( eccErrorMask & UE )
        {
            o_rc = handleUe_Td( io_sc, i_stopAddr, false ); // No TPS request.
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "handleUe_Td() failed" );
                break;
            }
        }

        // If the command had reached the end of the rank, handle any false
        // alarm conditions, if needed, and continue on to the next TD
        // procedure. Otherwise, resume the scrub starting on the next address.
        if ( reachedEndAddr )
        {
            // Handle false alarm conditions, if needed.
            if ( iv_tpsFalseAlarm )
            {
                o_rc = handleTpsFalseAlarm( io_sc );
                if ( SUCCESS != o_rc )
                {
                    PRDF_ERR( PRDF_FUNC "handleTpsFalseAlarm() failed" );
                    break;
                }
            }

            // This procedure is done. Reset the state machine and go onto the
            // next TD procedure.
            iv_tdState = NO_OP;
            break;
        }

        // Restart the scrub on the next address.
        o_rc = resumeScrub( io_sc, eccErrorMask );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "resumeScrub() failed" );
            break;
        }

    } while(0);

    // Callout the rank if no other callouts have been made.
    if ( 0 == io_sc.service_data->getMruListSize() )
    {
        MemoryMru memmru( iv_mbaTrgt, iv_rank,
                          MemoryMruData::CALLOUT_RANK );
        io_sc.service_data->SetCallout( memmru );
    }

    // If this TD procedure was aborted, execute TD complete sequence.
    if ( (iv_tdState == NO_OP) && (SUCCESS == o_rc) )
    {
        o_rc = handleTdComplete( io_sc );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "handleTdComplete() failed" );
        }
    }

    return o_rc;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

int32_t CenMbaTdCtlr::startTpsPhase1( STEP_CODE_DATA_STRUCT & io_sc )
{
    // Initially true, until hardware error is found.
    iv_tpsFalseAlarm = true;

    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    // moved to TpsEvent class
    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    return SUCCESS;
}

//------------------------------------------------------------------------------

int32_t CenMbaTdCtlr::handleUe_Td( STEP_CODE_DATA_STRUCT & io_sc,
                                   const CenAddr & i_stopAddr,
                                   bool i_addTpsRequest )
{
    #define PRDF_FUNC "[CenMbaTdCtlr::handleUe_Td] "

    int32_t o_rc = SUCCESS;

    setTdSignature( io_sc, PRDFSIG_MaintUE );

    // Clear TPS false alarm flag.
    iv_tpsFalseAlarm = false;

    // Callout the rank
    MemoryMru memmru ( iv_mbaTrgt, iv_rank, MemoryMruData::CALLOUT_RANK );
    io_sc.service_data->SetCallout( memmru );

    // Make error log predictive
    io_sc.service_data->setServiceCall();

    do
    {
        // Add entry to UE table.
        if ( (TPS_PHASE_1 != iv_tdState) )
        {
            CenMbaDataBundle * mbadb = getMbaDataBundle( iv_mbaChip );
            mbadb->iv_ueTable.addEntry( UE_TABLE::SCRUB_UE, i_stopAddr );

            // Send lmb gard message to PHYP.
            o_rc =  DEALLOC::lmbGard( iv_mbaChip, i_stopAddr, false );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "lmbGard() failed" );
                break;
            }
        }

        if ( i_addTpsRequest )
        {
            // Add a TPS request to the queue and ban any future TPS requests.
            o_rc = addTdQueueEntryTPS( i_stopAddr.getRank(), io_sc, true );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "addTdQueueEntryTPS() failed" );
                break;
            }
        }

    } while (0);

    return o_rc;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

int32_t CenMbaTdCtlr::handleRceEte_Td( STEP_CODE_DATA_STRUCT & io_sc )
{
    #define PRDF_FUNC "[CenMbaTdCtlr::handleRceEte_Td] "

    int32_t o_rc = SUCCESS;

    setTdSignature( io_sc, PRDFSIG_MaintRETRY_CTE );

    // Clear TPS false alarm flag.
    iv_tpsFalseAlarm = false;

    // Callout the rank
    MemoryMru memmru ( iv_mbaTrgt, iv_rank, MemoryMruData::CALLOUT_RANK );
    io_sc.service_data->SetCallout( memmru );

    // Make error log predictive
    io_sc.service_data->setServiceCall();

    return o_rc;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

int32_t CenMbaTdCtlr::handleMpe_Tps( STEP_CODE_DATA_STRUCT & io_sc )
{
    #define PRDF_FUNC "[CenMbaTdCtlr::handleMpe_Tps] "

    int32_t o_rc = SUCCESS;

    setTdSignature( io_sc, PRDFSIG_MaintMPE );

    // Clear TPS false alarm flag.
    iv_tpsFalseAlarm = false;

    do
    {
        // Callout the mark.
        CalloutUtil::calloutMark( iv_mbaTrgt, iv_rank, iv_mark, io_sc );

        // Add a VCM request to the queue.
        o_rc = addTdQueueEntryVCM( iv_rank );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "addTdQueueEntryVCM() failed" );
            break;
        }

        // Clear the scrub attention. This is needed later if we need to write
        // markstore for a symbol mark.
        const char * fir_str = (0 == iv_mbaPos) ? "MBSECCFIR_0_AND"
                                                : "MBSECCFIR_1_AND";

        SCAN_COMM_REGISTER_CLASS * fir = iv_membChip->getRegister( fir_str );

        fir->ClearBit( 20 + iv_rank.getMaster() ); // scrub

        o_rc = fir->Write();
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "Write() failed on %s", fir_str );
            break;
        }

    } while(0);

    return o_rc;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

int32_t CenMbaTdCtlr::handleCeEte_Tps( STEP_CODE_DATA_STRUCT & io_sc )
{
    #define PRDF_FUNC "[CenMbaTdCtlr::handleCeEte_Tps] "

    int32_t o_rc = SUCCESS;

    do
    {
        if ( TPS_PHASE_1 != iv_tdState )
        {
            PRDF_ERR( PRDF_FUNC "Invalid state machine configuration" );
            o_rc = FAIL; break;
        }

        // Get the current threshold.
        uint16_t thr = 0;
        o_rc = getTpsCeThr( thr );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "getTpsCeThr() failed." );
            break;
        }

        // Get all symbols that have a count greater than or equal to the target
        // threshold.
        MaintSymbols symData; CenSymbol targetCM;
        o_rc = collectCeStats( iv_mbaChip, iv_rank, symData, targetCM, thr );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "collectCeStats() failed." );
            break;
        }

        // Check for false alarms.
        if ( symData.empty() ) break; // nothing else to do

        // There is valid data so clear the false alarm flag.
        iv_tpsFalseAlarm = false;

        // Callout all DIMMS with symbol count that reached threshold.
        CalloutUtil::calloutSymbolData( iv_mbaTrgt, iv_rank, symData, io_sc );

        // Check if DRAM repairs are disabled.
        if ( areDramRepairsDisabled() )
        {
            io_sc.service_data->setServiceCall();
            break; // nothing else to do
        }

        // Add all symbols to the VPD.
        CenDqBitmap bitmap;
        o_rc = getBadDqBitmap( iv_mbaTrgt, iv_rank, bitmap );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "getBadDqBitmap() failed" );
            break;
        }

        for ( MaintSymbols::iterator it = symData.begin();
              it != symData.end(); it++ )
        {
            bitmap.setSymbol( it->symbol );
        }

        o_rc = setBadDqBitmap( iv_mbaTrgt, iv_rank, bitmap );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "setBadDqBitmap() failed" );
            break;
        }

        // Check if the chip mark is available.
        bool cmPlaced = false;
        if ( !iv_mark.getCM().isValid() )
        {
            if ( targetCM.isValid() )
            {
                // Use the DRAM with the highest total count.
                iv_mark.setCM( targetCM );
                o_rc = tpsChipMark( io_sc );
                if ( SUCCESS != o_rc )
                {
                    PRDF_ERR( PRDF_FUNC "tpsChipMark() failed." );
                    break;
                }

                cmPlaced = true;
            }
            // If the symbol mark has been used then use the chip mark.
            else if ( !iv_x4Dimm && iv_mark.getSM().isValid() )
            {
                for ( MaintSymbols::iterator it = symData.end();
                      it-- != symData.begin(); )
                {
                    if ( !(it->symbol == iv_mark.getSM()) )
                    {
                        iv_mark.setCM( it->symbol );
                        o_rc = tpsChipMark( io_sc );
                        if ( SUCCESS != o_rc )
                        {
                            PRDF_ERR( PRDF_FUNC "tpsChipMark() failed." );
                            break;
                        }

                        cmPlaced = true;
                        break;
                    }
                }
                if ( SUCCESS != o_rc ) break;
            }
        }

        // Check if the symbol mark is available. Note that symbol marks are not
        // available in x4 mode. Also, we only want to place a symbol mark if we
        // did not just place a chip mark above. The reason for this is because
        // having a chip mark and symbol mark at the same time increases the
        // chance of UEs. We will want to wait until the chip mark we placed
        // above is verified< and possibily steered, before placing the symbol
        // mark.
        if ( !cmPlaced && !iv_x4Dimm && !iv_mark.getSM().isValid() )
        {
            // Use the symbol with the highest count.
            iv_mark.setSM( symData.back().symbol );
            o_rc = tpsSymbolMark( io_sc );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "tpsSymbolMark() failed." );
                break;
            }
        }

        // We know with a degree of confidence that any chip mark placed in this
        // function will be verified. Therefore, we can do a early check here
        // and make a predictive callout if the chip mark and all available
        // spares have been used. This is useful because the targeted
        // diagnostics procedure will take much longer to complete due to a
        // hardware issue. By making the predictive callout now, we will send a
        // Dynamic Memory Deallocation message to PHYP sooner so that they can
        // attempt to get off the memory instead of waiting for the callout
        // after the VCM procedure.

        if ( iv_mark.getCM().isValid() )
        {
            bool available;
            o_rc = checkForAvailableSpares( iv_mark.getCM().getPortSlct(),
                                            available );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "checkForAvailableSpares() failed" );
                break;
            }

            if ( !available )
            {
                // Spares have been used. Callout the mark. Make the error log
                // predictive.
                CalloutUtil::calloutMark( iv_mbaTrgt, iv_rank, iv_mark, io_sc );
                setTdSignature( io_sc, PRDFSIG_TpsCmAndSpare );
                io_sc.service_data->setServiceCall();
            }
        }

    } while(0);

    return o_rc;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

int32_t CenMbaTdCtlr::handleTpsFalseAlarm( STEP_CODE_DATA_STRUCT & io_sc )
{
    #define PRDF_FUNC "[CenMbaTdCtlr::handleTpsFalseAlarm] "

    int32_t o_rc = SUCCESS;

    setTdSignature( io_sc, PRDFSIG_TpsFalseAlarm );

    do
    {
        if ( TPS_PHASE_1 != iv_tdState )
        {
            PRDF_ERR( PRDF_FUNC "Invalid state machine configuration" );
            o_rc = FAIL; break;
        }

        // Callout all DIMMs that have reached threshold.
        //   Centaur DIMMS: Any non-zero count, threshold on 1.
        //   IS DIMMS:      Allow 1, threshold on 2 (because of limited spares).
        uint8_t thr = isMembufOnDimm<TYPE_MBA>(iv_mbaTrgt) ? 1 : 2;
        MaintSymbols symData; CenSymbol junk;
        o_rc = collectCeStats( iv_mbaChip, iv_rank, symData, junk, thr );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "collectCeStats() failed." );
            break;
        }

        if ( symData.empty() )
        {
            // There is no data so callout the rank.
            MemoryMru memmru (iv_mbaTrgt, iv_rank, MemoryMruData::CALLOUT_RANK);
            io_sc.service_data->SetCallout( memmru );
        }
        else
        {
            CalloutUtil::calloutSymbolData(iv_mbaTrgt, iv_rank, symData, io_sc);
        }

        // In manufacturing, this error log will be predictive.
        if ( areDramRepairsDisabled() )
        {
            io_sc.service_data->setServiceCall();
            break; // nothing else to do
        }

        // Increase the false alarm counter. Continue only if false alarm
        // threshold is exceeded.
        if ( !iv_tpsRankData.incFalseAlarm(iv_rank, io_sc) ) break;

        setTdSignature( io_sc, PRDFSIG_TpsFalseAlarmExceeded );

        // If there are no symbols in the list, exit quietly.
        if ( symData.empty() ) break;

        // Use the symbol with the highest count to place a symbol or chip mark,
        // if possible. Note that we only want to use one repair for this false
        // alarm to avoid using up all the repairs for 'weak' errors.
        CenSymbol highestSymbol = symData.back().symbol;

        // Check if the symbol mark is available. Note that symbol marks are not
        // available in x4 mode.
        if ( !iv_x4Dimm && !iv_mark.getSM().isValid() )
        {
            iv_mark.setSM( highestSymbol );
            o_rc = tpsSymbolMark( io_sc );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "tpsSymbolMark() failed." );
                break;
            }

            // Add this symbol to the VPD.
            CenDqBitmap bitmap;
            o_rc = getBadDqBitmap( iv_mbaTrgt, iv_rank, bitmap );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "getBadDqBitmap() failed" );
                break;
            }

            bitmap.setSymbol( highestSymbol );

            o_rc = setBadDqBitmap( iv_mbaTrgt, iv_rank, bitmap );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "setBadDqBitmap() failed" );
                break;
            }
        }
        // Check if the chip mark is available.
        else if ( !iv_mark.getCM().isValid() )
        {
            iv_mark.setCM( highestSymbol );
            o_rc = tpsChipMark( io_sc );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "tpsChipMark() failed" );
                break;
            }
        }
        else
        {
            // The spares have been used. Make the error log predictive.
            setTdSignature( io_sc, PRDFSIG_TpsMarksUnavail );
            io_sc.service_data->setServiceCall();
        }

    } while(0);

    return o_rc;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

int32_t CenMbaTdCtlr::getTpsCeThr( uint16_t & o_thr )
{
    #define PRDF_FUNC "[CenMbaTdCtlr::getTpsCeThr] "

    int32_t o_rc = SUCCESS;

    do
    {
        if ( TPS_PHASE_1 != iv_tdState )
        {
            PRDF_ERR( PRDF_FUNC "Invalid state machine configuration" );
            o_rc = FAIL;
            break;
        }

        if ( !iv_tpsRankData.checkCeTypeTh(iv_rank) )
        {
            o_thr = mfgMode() ? 1 : 48;
        }
        else
        {
            o_thr = getScrubCeThreshold( iv_mbaChip, iv_rank );
        }

    } while( 0 );

    return o_rc;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

int32_t CenMbaTdCtlr::tpsChipMark( STEP_CODE_DATA_STRUCT & io_sc )
{
    #define PRDF_FUNC "[CenMbaTdCtlr::tpsChipMark] "

    int32_t o_rc = SUCCESS;

    setTdSignature( io_sc, PRDFSIG_TpsChipMark );

    do
    {
        if ( TPS_PHASE_1 != iv_tdState )
        {
            PRDF_ERR( PRDF_FUNC "Invalid state machine configuration" );
            o_rc = FAIL; break;
        }

        // Write the chip mark to markstore.
        bool allowWriteBlocked = true;
        bool blocked;
        o_rc = mssSetMarkStore( iv_mbaTrgt, iv_rank, iv_mark, blocked,
                                allowWriteBlocked );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "mssSetMarkStore() failed" );
            break;
        }

        if ( blocked )
        {
            // Continue on with the rest of the TPS procedure as if nothing
            // failed. We will find the new chip mark on a subsequent attention.
            // The chances are that hardware had placed a chip mark on the same
            // DRAM that we tried to write, so for now, ignore these failing
            // symbols.
        }
        else
        {
            // Add a VCM request to the queue.
            o_rc = addTdQueueEntryVCM( iv_rank );
            if ( SUCCESS != o_rc )
            {
                PRDF_ERR( PRDF_FUNC "addTdQueueEntryVCM() failed" );
                break;
            }
        }

    } while (0);

    return o_rc;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

int32_t CenMbaTdCtlr::tpsSymbolMark( STEP_CODE_DATA_STRUCT & io_sc )
{
    #define PRDF_FUNC "[CenMbaTdCtlr::tpsSymbolMark] "

    int32_t o_rc = SUCCESS;

    setTdSignature( io_sc, PRDFSIG_TpsSymbolMark );

    do
    {
        if ( TPS_PHASE_1 != iv_tdState )
        {
            PRDF_ERR( PRDF_FUNC "Invalid state machine configuration" );
            o_rc = FAIL; break;
        }

        // Write the symbol mark to markstore.
        bool allowWriteBlocked = true;
        bool blocked = false;
        o_rc = mssSetMarkStore( iv_mbaTrgt, iv_rank, iv_mark, blocked,
                                allowWriteBlocked );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "mssSetMarkStore() failed." );
            o_rc = FAIL; break;
        }

        if ( !blocked ) break; // Write was successful, no need to continue.

        // Hardware placed a new chip mark. Add a VCM request to the queue.
        o_rc = addTdQueueEntryVCM( iv_rank );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "addTdQueueEntryVCM() failed" );
            break;
        }

        // Clear the fetch attention before attempting the rewrite.
        const char * reg_str = (0 == iv_mbaPos) ? "MBSECCFIR_0_AND"
                                                : "MBSECCFIR_1_AND";
        SCAN_COMM_REGISTER_CLASS * firand = iv_membChip->getRegister( reg_str );
        firand->setAllBits();
        firand->ClearBit( 0 + iv_rank.getMaster() ); // fetch
        o_rc = firand->Write();
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "Write() failed on %s", reg_str );
            break;
        }

        // Rewrite markstore. Do not allow this write to be blocked. If it is
        // blocked there is a code bug. Note that iv_mark was updated with the
        // hardware placed chip mark in the previous call to mssSetMarkStore().
        o_rc = mssSetMarkStore( iv_mbaTrgt, iv_rank, iv_mark, blocked );
        if ( SUCCESS != o_rc )
        {
           PRDF_ERR( PRDF_FUNC "mssSetMarkStore() failed on retry." );
           break;
        }

    } while( 0 );

    return o_rc;

    #undef PRDF_FUNC
}

//------------------------------------------------------------------------------

int32_t CenMbaTdCtlr::checkForAvailableSpares( uint8_t i_ps, bool & o_avail )
{
    #define PRDF_FUNC "[CenMbaTdCtlr::checkForAvailableSpares] "

    int32_t o_rc = SUCCESS;

    o_avail = false;

    do
    {
        // First, make sure the spares are supported and have not been
        // intentially made unavailable by the manufacturer via the VPD.

        CenDqBitmap bitmap;
        o_rc = getBadDqBitmap( iv_mbaTrgt, iv_rank, bitmap );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "getBadDqBitmap() failed" );
            break;
        }

        bool dramSparePossible = false;
        bool eccSparePossible  = false;
        o_rc = bitmap.isSpareAvailable( i_ps, dramSparePossible,
                                        eccSparePossible );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "isDramSpareAvailable() failed" );
            break;
        }

        // Second, query hardware for the any available spares.

        CenSymbol sp0, sp1, ecc;
        o_rc = mssGetSteerMux( iv_mbaTrgt, iv_rank, sp0, sp1, ecc );
        if ( SUCCESS != o_rc )
        {
            PRDF_ERR( PRDF_FUNC "mssGetSteerMux() failed" );
            break;
        }

        if ( ( dramSparePossible &&
               (0 == i_ps ? !sp0.isValid() : !sp1.isValid()) ) ||
             ( eccSparePossible && !ecc.isValid() ) )
        {
           o_avail = true;
        }

    } while(0);

    return o_rc;

    #undef PRDF_FUNC
}

} // end namespace PRDF
OpenPOWER on IntegriCloud