summaryrefslogtreecommitdiffstats
path: root/src/import/chips/p9/procedures/hwp/nest/p9_revert_sbe_mcs_setup.C
blob: 8c462498b972a3f7803a1e0e2275844e8f2a4020 (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: chips/p9/procedures/hwp/nest/p9_revert_sbe_mcs_setup.C $      */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* EKB Project                                                            */
/*                                                                        */
/* COPYRIGHT 2015                                                         */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
///
/// @file p9_revert_sbe_mcs_setup.C
/// @brief Revert MC configuration applied by SBE (FAPI2)

///
/// @author Joe McGill <jmcgill@us.ibm.com>
///

//
// *HWP HWP Owner: Joe McGill <jmcgill@us.ibm.com>
// *HWP FW Owner: Thi Tran <thi@us.ibm.com>
// *HWP Team: Nest
// *HWP Level: 2
// *HWP Consumed by: HB
//

//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include <p9_revert_sbe_mcs_setup.H>
#include <p9_mc_scom_addresses.H>
#include <p9_mc_scom_addresses_fld.H>


//------------------------------------------------------------------------------
// Function prototypes
//------------------------------------------------------------------------------

///
/// @brief Reset SBE applied hostboot dcbz MC configuration for one unit target
///
/// @param[in] i_target Reference to an MC target (MCS/MI)
/// @return FAPI2_RC_SUCCESS if success, else error code.
///
template<fapi2::TargetType T>
fapi2::ReturnCode revert_hb_dcbz_config(const fapi2::Target<T>& i_target);


//------------------------------------------------------------------------------
// Function definitions
//------------------------------------------------------------------------------


// specialization for MCS target type
template<>
fapi2::ReturnCode revert_hb_dcbz_config(const fapi2::Target<fapi2::TARGET_TYPE_MCS>& i_target)
{
    FAPI_DBG("Start");
    fapi2::buffer<uint64_t> l_mcfgp;
    fapi2::buffer<uint64_t> l_mcmode1;
    fapi2::buffer<uint64_t> l_mcfirmask;

    // MCFGP -- mark BAR invalid & reset grouping configuration fields
    FAPI_TRY(fapi2::getScom(i_target, MCS_MCFGP, l_mcfgp),
             "Error from getScom (MCS_MCFGP)");
    l_mcfgp.clearBit<MCS_MCFGP_VALID>();
    l_mcfgp.clearBit<MCS_MCFGP_MC_CHANNELS_PER_GROUP,
                     MCS_MCFGP_MC_CHANNELS_PER_GROUP_LEN>();
    l_mcfgp.clearBit<MCS_MCFGP_CHANNEL_0_GROUP_MEMBER_IDENTIFICATION,
                     MCS_MCFGP_CHANNEL_0_GROUP_MEMBER_IDENTIFICATION_LEN>();
    l_mcfgp.clearBit<MCS_MCFGP_GROUP_SIZE, MCS_MCFGP_GROUP_SIZE_LEN>();
    FAPI_TRY(fapi2::putScom(i_target, MCS_MCFGP, l_mcfgp),
             "Error from putScom (MCS_MCFGP)");

    // MCMODE1 -- enable speculation
    FAPI_TRY(fapi2::getScom(i_target, MCS_MCMODE1, l_mcmode1),
             "Error from getScom (MCS_MCMODE1)");
    l_mcmode1.clearBit<MCS_MCMODE1_DISABLE_ALL_SPEC_OPS>();
    l_mcmode1.clearBit<MCS_MCMODE1_DISABLE_SPEC_OP,
                       MCS_MCMODE1_DISABLE_SPEC_OP_LEN>();
    FAPI_TRY(fapi2::putScom(i_target, MCS_MCMODE1, l_mcmode1),
             "Error from putScom (MCS_MCMODE1)");

    // MCFIRMASK -- mask all errors
    l_mcfirmask.flush<1>();
    FAPI_TRY(fapi2::putScom(i_target, MCS_MCFIRMASK_OR, l_mcfirmask),
             "Error from putScom (MCS_MCFIRMASK_OR)");

fapi_try_exit:
    FAPI_DBG("End");
    return fapi2::current_err;
}


// specialization for MI target type
template<>
fapi2::ReturnCode revert_hb_dcbz_config(const fapi2::Target<fapi2::TARGET_TYPE_MI>& i_target)
{
    // TODO: implement for Cumulus (MI target)
    return fapi2::current_err;
}


// HWP entry point
fapi2::ReturnCode
p9_revert_sbe_mcs_setup(const fapi2::Target<fapi2::TARGET_TYPE_PROC_CHIP>& i_target)
{
    FAPI_INF("Start");

    auto l_mcs_chiplets = i_target.getChildren<fapi2::TARGET_TYPE_MCS>();

    if (l_mcs_chiplets.size())
    {
        for (auto l_target_mcs : l_mcs_chiplets)
        {
            FAPI_TRY(revert_hb_dcbz_config(l_target_mcs),
                     "Error from revert_hb_dcbz_config (MCS)");
        }
    }
    else
    {
        auto l_mi_chiplets = i_target.getChildren<fapi2::TARGET_TYPE_MI>();

        for (auto l_target_mi : l_mi_chiplets)
        {
            FAPI_TRY(revert_hb_dcbz_config(l_target_mi),
                     "Error from revert_hb_dcbz_config (MI)");
        }
    }

fapi_try_exit:
    FAPI_INF("End");
    return fapi2::current_err;
}
OpenPOWER on IntegriCloud