6 * Feature which performs Memory DQS training on each node with each node training
7 * its own memory through code running on a core in the associated processor.
8 * This way memory can be trained in parallel by more than one processor.
10 * This file contains the Deerhound specific parallel training function.
12 * @xrefitem bom "File Content Label" "Release Content"
14 * @e sub-project: (Mem/Feat/HCTRN)
15 * @e \$Revision: 6516 $ @e \$Date: 2008-06-24 06:06:40 -0500 (Tue, 24 Jun 2008) $
18 /*****************************************************************************
20 * Copyright (c) 2011, Advanced Micro Devices, Inc.
21 * All rights reserved.
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions are met:
25 * * Redistributions of source code must retain the above copyright
26 * notice, this list of conditions and the following disclaimer.
27 * * Redistributions in binary form must reproduce the above copyright
28 * notice, this list of conditions and the following disclaimer in the
29 * documentation and/or other materials provided with the distribution.
30 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
31 * its contributors may be used to endorse or promote products derived
32 * from this software without specific prior written permission.
34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
35 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
36 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
37 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
38 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
39 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
40 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
41 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
43 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
45 * ***************************************************************************
53 #include "AdvancedApi.h"
55 #include "OptionMemory.h"
60 #include "cpuRegisters.h"
61 #include "cpuServices.h"
62 #include "GeneralServices.h"
63 #include "cpuApicUtilities.h"
64 #include "mfParallelTraining.h"
65 #include "heapManager.h"
67 #define FILECODE PROC_MEM_NB_DA_MNPARTRAINDA_FILECODE
69 /*-----------------------------------------------------------------------------
72 *-----------------------------------------------------------------------------
77 MemConstructRemoteNBBlockDA (
78 IN OUT MEM_NB_BLOCK *NBPtr,
79 IN DIE_STRUCT *MCTPtr,
80 IN MEM_FEAT_BLOCK_NB *FeatPtr
83 /* -----------------------------------------------------------------------------*/
87 * This is the training function which set up the environment for remote
88 * training on the ap and launches the remote routine.
90 * @param[in,out] *NBPtr - Pointer to the MEM_NB_BLOCK
92 * @return TRUE - Launch training on AP successfully.
93 * @return FALSE - Fail to launch training on AP.
96 MemFParallelTrainingDA (
97 IN OUT MEM_NB_BLOCK *NBPtr
100 AMD_CONFIG_PARAMS *StdHeader;
102 REMOTE_TRAINING_ENV *EnvPtr;
103 AP_TASK TrainingTask;
114 ALLOCATE_HEAP_PARAMS AllocHeapParams;
116 StdHeader = &(NBPtr->MemPtr->StdHeader);
117 MCTPtr = NBPtr->MCTPtr;
118 Socket = MCTPtr->SocketId;
119 Module = MCTPtr->DieId;
122 // Allocate buffer for REMOTE_TRAINING_ENV
124 MctDataSize = MAX_DCTS_PER_NODE_DA * (
125 sizeof (DCT_STRUCT) + (
126 MAX_CHANNELS_PER_DCT_DA * (sizeof (CH_DEF_STRUCT) + sizeof (MEM_PS_BLOCK))
129 AllocHeapParams.RequestedBufferSize = MctDataSize + sizeof (REMOTE_TRAINING_ENV);
130 AllocHeapParams.BufferHandle = GENERATE_MEM_HANDLE (ALLOC_PAR_TRN_HANDLE, Socket, Module, 0);
131 AllocHeapParams.Persist = HEAP_LOCAL_CACHE;
132 if (HeapAllocateBuffer (&AllocHeapParams, StdHeader) == AGESA_SUCCESS) {
133 EnvPtr = (REMOTE_TRAINING_ENV *) AllocHeapParams.BufferPtr;
134 AllocHeapParams.BufferPtr += sizeof (REMOTE_TRAINING_ENV);
137 // Setup Remote training environment
139 LibAmdMemCopy (&(EnvPtr->StdHeader), StdHeader, sizeof (AMD_CONFIG_PARAMS), StdHeader);
140 LibAmdMemCopy (&(EnvPtr->DieStruct), MCTPtr, sizeof (DIE_STRUCT), StdHeader);
141 for (p = 0; p < MAX_PLATFORM_TYPES; p++) {
142 EnvPtr->GetPlatformCfg[p] = NBPtr->MemPtr->GetPlatformCfg[p];
144 EnvPtr->ErrorHandling = NBPtr->MemPtr->ErrorHandling;
145 EnvPtr->NBBlockCtor = MemConstructRemoteNBBlockDA;
146 EnvPtr->FeatPtr = NBPtr->FeatPtr;
147 EnvPtr->HoleBase = NBPtr->RefPtr->HoleBase;
148 EnvPtr->BottomIo = NBPtr->RefPtr->BottomIo;
149 EnvPtr->SysLimit = NBPtr->RefPtr->SysLimit;
150 EnvPtr->TableBasedAlterations = NBPtr->RefPtr->TableBasedAlterations;
151 EnvPtr->PlatformMemoryConfiguration = NBPtr->RefPtr->PlatformMemoryConfiguration;
153 LibAmdMemCopy (AllocHeapParams.BufferPtr, MCTPtr->DctData, MctDataSize, StdHeader);
156 // Get Socket, Core of the BSP
158 IdentifyCore (StdHeader, &BspSocket, &BspModule, &BspCore, &Status);
159 EnvPtr->BspSocket = ((UINT8)BspSocket & 0x000000FF);
160 EnvPtr->BspCore = ((UINT8)BspCore & 0x000000FF);
163 // Set up the remote task structure
165 TrainingTask.DataTransfer.DataPtr = EnvPtr;
166 TrainingTask.DataTransfer.DataSizeInDwords = (AllocHeapParams.RequestedBufferSize + 3) / 4;
167 TrainingTask.DataTransfer.DataTransferFlags = 0;
168 TrainingTask.ExeFlags = 0;
169 TrainingTask.FuncAddress.PfApTaskI = (PF_AP_TASK_I)MemFParallelTraining;
172 // Get Target AP Core
174 GetGivenModuleCoreRange (Socket, Module, &LowCore, &HighCore, StdHeader);
175 APCore = (UINT8) (LowCore & 0x000000FF);
178 // Launch Remote Training
180 ApUtilRunCodeOnSocketCore (Socket, APCore, &TrainingTask, StdHeader);
182 HeapDeallocateBuffer (AllocHeapParams.BufferHandle, StdHeader);
185 PutEventLog (AGESA_FATAL, MEM_ERROR_HEAP_ALLOCATE_FOR_REMOTE_TRAINING_ENV, NBPtr->Node, 0, 0, 0, StdHeader);
186 SetMemError (AGESA_FATAL, MCTPtr);
187 ASSERT(FALSE); // Could not allocated heap space for "REMOTE_TRAINING_ENV"
194 MemConstructRemoteNBBlockDA (
195 IN OUT MEM_NB_BLOCK *NBPtr,
196 IN DIE_STRUCT *MCTPtr,
197 IN MEM_FEAT_BLOCK_NB *FeatPtr
200 NBPtr->MCTPtr = MCTPtr;
201 NBPtr->PciAddr.AddressValue = MCTPtr->PciAddr.AddressValue;
203 MemNInitNBDataDA (NBPtr);
205 FeatPtr->InitCPG (NBPtr);
206 NBPtr->FeatPtr = FeatPtr;
208 MemNSwitchDCTNb (NBPtr, 0);