Skip to content

Commit 95d4ac7

Browse files
Capability to insert WA MMIO for BCS dispatch
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
1 parent 1ef5161 commit 95d4ac7

File tree

7 files changed

+69
-1
lines changed

7 files changed

+69
-1
lines changed

shared/source/command_stream/command_stream_receiver_hw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
189189
std::unique_ptr<DirectSubmissionHw<GfxFamily, BlitterDispatcher<GfxFamily>>> blitterDirectSubmission;
190190

191191
size_t cmdStreamStart = 0;
192+
uint32_t latestSentBcsWaValue = std::numeric_limits<uint32_t>::max();
192193
};
193194

194195
} // namespace NEO

shared/source/command_stream/command_stream_receiver_hw_base.inl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,8 @@ std::optional<uint32_t> CommandStreamReceiverHw<GfxFamily>::flushBcsTask(const B
10751075
TimestampPacketHelper::programCsrDependenciesForTimestampPacketContainer<GfxFamily>(commandStream, blitProperties.csrDependencies);
10761076
TimestampPacketHelper::programCsrDependenciesForForTaskCountContainer<GfxFamily>(commandStream, blitProperties.csrDependencies);
10771077

1078+
BlitCommandsHelper<GfxFamily>::encodeWa(commandStream, blitProperties, latestSentBcsWaValue);
1079+
10781080
if (blitProperties.outputTimestampPacket && profilingEnabled) {
10791081
BlitCommandsHelper<GfxFamily>::encodeProfilingStartMmios(commandStream, *blitProperties.outputTimestampPacket);
10801082
}

shared/source/debug_settings/debug_variables_base.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ DECLARE_DEBUG_VARIABLE(int32_t, EnableDrmCompletionFence, -1, "Enables DRM compl
398398
DECLARE_DEBUG_VARIABLE(int32_t, UseDrmCompletionFenceForAllAllocations, -1, "Uses DRM completion fence for all allocations, -1:default (disabled), 0:disable, 1:enable")
399399
DECLARE_DEBUG_VARIABLE(int32_t, EnableChipsetUniqueUUID, -1, "Enables retrieving chipset unique UUID using telemetry, -1:default (disabled), 0:disable, 1:enable")
400400
DECLARE_DEBUG_VARIABLE(int32_t, EnableFlushTaskSubmission, -1, "Driver uses csr flushTask for immediate commandlist submissions, -1:default (enabled), 0:disabled, 1:enabled")
401+
DECLARE_DEBUG_VARIABLE(int32_t, EnableBcsSwControlWa, -1, "Enable BCS WA via BCSSWCONTROL MMIO. -1: default, 0: disabled, 1: if src in system mem, 2: if dst in system mem, 3: if src and dst in system mem, 4: always")
401402

402403
/*EXPERIMENTAL TOGGLES*/
403404
DECLARE_DEBUG_VARIABLE(int32_t, ExperimentalSetWalkerPartitionCount, 0, "Experimental implementation: Set number of COMPUTE_WALKERs for a given Partition Type, 0 - do not set the feature.")

shared/source/helpers/blit_commands_helper.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,5 +178,8 @@ struct BlitCommandsHelper {
178178
static void encodeProfilingStartMmios(LinearStream &cmdStream, const TagNodeBase &timestampPacketNode);
179179
static void encodeProfilingEndMmios(LinearStream &cmdStream, const TagNodeBase &timestampPacketNode);
180180
static size_t getProfilingMmioCmdsSize();
181+
182+
static void encodeWa(LinearStream &cmdStream, const BlitProperties &blitProperties, uint32_t &latestSentBcsWaValue);
183+
static size_t getWaCmdsSize(const BlitPropertiesContainer &blitPropertiesContainer);
181184
};
182185
} // namespace NEO

shared/source/helpers/blit_commands_helper_base.inl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ size_t BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(const BlitPropert
142142
size += BlitCommandsHelper<GfxFamily>::estimateBlitCommandSize(blitProperties.copySize, blitProperties.csrDependencies, updateTimestampPacket,
143143
profilingEnabled, isImage, rootDeviceEnvironment);
144144
}
145+
size += BlitCommandsHelper<GfxFamily>::getWaCmdsSize(blitPropertiesContainer);
145146
size += 2 * MemorySynchronizationCommands<GfxFamily>::getSizeForAdditonalSynchronization(*rootDeviceEnvironment.getHardwareInfo());
146147
size += EncodeMiFlushDW<GfxFamily>::getMiFlushDwCmdSizeForDataWrite();
147148
size += blitterDirectSubmission ? sizeof(typename GfxFamily::MI_BATCH_BUFFER_START) : sizeof(typename GfxFamily::MI_BATCH_BUFFER_END);
@@ -509,4 +510,13 @@ size_t BlitCommandsHelper<GfxFamily>::getProfilingMmioCmdsSize() {
509510

510511
template <typename GfxFamily>
511512
void BlitCommandsHelper<GfxFamily>::appendBaseAddressOffset(const BlitProperties &blitProperties, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd, const uint32_t originalSliceIndex, const bool isSource) {}
513+
514+
template <typename GfxFamily>
515+
void BlitCommandsHelper<GfxFamily>::encodeWa(LinearStream &cmdStream, const BlitProperties &blitProperties, uint32_t &latestSentBcsWaValue) {
516+
}
517+
518+
template <typename GfxFamily>
519+
size_t BlitCommandsHelper<GfxFamily>::getWaCmdsSize(const BlitPropertiesContainer &blitPropertiesContainer) {
520+
return 0;
521+
}
512522
} // namespace NEO

shared/source/xe_hpc_core/command_stream_receiver_hw_xe_hpc_core.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,56 @@ template <>
205205
template <>
206206
void BlitCommandsHelper<Family>::appendColorDepth(const BlitProperties &blitProperites, typename Family::XY_COPY_BLT &blitCmd) {}
207207

208+
template <>
209+
void BlitCommandsHelper<Family>::encodeWa(LinearStream &cmdStream, const BlitProperties &blitProperties, uint32_t &latestSentBcsWaValue) {
210+
using MI_LOAD_REGISTER_IMM = typename Family::MI_LOAD_REGISTER_IMM;
211+
212+
if (DebugManager.flags.EnableBcsSwControlWa.get() <= 0) {
213+
return;
214+
}
215+
216+
constexpr int32_t srcInSystemMemOnly = 1;
217+
constexpr int32_t dstInSystemMemOnly = 2;
218+
constexpr int32_t enableAlways = 4;
219+
constexpr uint32_t waEnabledMMioValue = 0x40004;
220+
constexpr uint32_t waDisabledMMioValue = 0x40000;
221+
222+
const bool applyForSrc = (DebugManager.flags.EnableBcsSwControlWa.get() & srcInSystemMemOnly);
223+
const bool applyForDst = (DebugManager.flags.EnableBcsSwControlWa.get() & dstInSystemMemOnly);
224+
const bool applyAlways = (DebugManager.flags.EnableBcsSwControlWa.get() == enableAlways);
225+
226+
const bool enableWa = (!blitProperties.srcAllocation->isAllocatedInLocalMemoryPool() && applyForSrc) ||
227+
(!blitProperties.dstAllocation->isAllocatedInLocalMemoryPool() && applyForDst) ||
228+
applyAlways;
229+
230+
uint32_t newValue = enableWa ? waEnabledMMioValue : waDisabledMMioValue;
231+
232+
if (newValue == latestSentBcsWaValue) {
233+
return;
234+
}
235+
236+
latestSentBcsWaValue = newValue;
237+
238+
MI_LOAD_REGISTER_IMM cmd = Family::cmdInitLoadRegisterImm;
239+
cmd.setRegisterOffset(0x22200);
240+
cmd.setDataDword(newValue);
241+
cmd.setMmioRemapEnable(true);
242+
243+
auto lri = cmdStream.getSpaceForCmd<MI_LOAD_REGISTER_IMM>();
244+
*lri = cmd;
245+
}
246+
247+
template <>
248+
size_t BlitCommandsHelper<Family>::getWaCmdsSize(const BlitPropertiesContainer &blitPropertiesContainer) {
249+
using MI_LOAD_REGISTER_IMM = typename Family::MI_LOAD_REGISTER_IMM;
250+
251+
if (DebugManager.flags.EnableBcsSwControlWa.get() <= 0) {
252+
return 0;
253+
}
254+
255+
return (blitPropertiesContainer.size() * sizeof(MI_LOAD_REGISTER_IMM));
256+
}
257+
208258
template class CommandStreamReceiverHw<Family>;
209259
template struct BlitCommandsHelper<Family>;
210260
template void BlitCommandsHelper<Family>::appendBlitCommandsForBuffer<typename Family::XY_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment);

shared/test/common/test_files/igdrcl.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,4 +431,5 @@ ForceUncachedGmmUsageType = 0
431431
OverrideDeviceName = unk
432432
EnablePrivateBO = 0
433433
ExperimentalEnableDeviceAllocationCache = 0
434-
OverrideL1CachePolicyInSurfaceStateAndStateless = -1
434+
OverrideL1CachePolicyInSurfaceStateAndStateless = -1
435+
EnableBcsSwControlWa = -1

0 commit comments

Comments
 (0)