2020-01-16 00:02:47 +08:00
|
|
|
/*
|
2022-01-07 22:53:31 +08:00
|
|
|
* Copyright (C) 2020-2022 Intel Corporation
|
2020-01-16 00:02:47 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/linear_stream.h"
|
|
|
|
#include "shared/source/helpers/completion_stamp.h"
|
2020-04-02 17:28:38 +08:00
|
|
|
#include "shared/source/helpers/constants.h"
|
2022-05-18 03:04:23 +08:00
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2020-01-16 00:02:47 +08:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
|
|
|
#pragma pack(1)
|
|
|
|
struct RingSemaphoreData {
|
|
|
|
uint32_t QueueWorkCount;
|
2021-09-28 07:27:46 +08:00
|
|
|
uint8_t ReservedCacheline0[60];
|
2020-08-07 16:57:53 +08:00
|
|
|
uint32_t tagAllocation;
|
2021-09-28 07:27:46 +08:00
|
|
|
uint8_t ReservedCacheline1[60];
|
2020-08-18 19:54:23 +08:00
|
|
|
uint32_t DiagnosticModeCounter;
|
|
|
|
uint32_t Reserved0Uint32;
|
2021-09-28 07:27:46 +08:00
|
|
|
uint64_t Reserved1Uint64;
|
|
|
|
uint8_t ReservedCacheline2[48];
|
|
|
|
uint64_t miFlushSpace;
|
|
|
|
uint8_t ReservedCacheline3[56];
|
2020-01-16 00:02:47 +08:00
|
|
|
};
|
2021-09-28 07:27:46 +08:00
|
|
|
static_assert((64u * 4) == sizeof(RingSemaphoreData), "Invalid size for RingSemaphoreData");
|
2020-01-16 00:02:47 +08:00
|
|
|
#pragma pack()
|
|
|
|
|
|
|
|
using DirectSubmissionAllocations = StackVec<GraphicsAllocation *, 8>;
|
|
|
|
|
|
|
|
struct TagData {
|
|
|
|
uint64_t tagAddress = 0ull;
|
|
|
|
uint64_t tagValue = 0ull;
|
|
|
|
};
|
|
|
|
|
2022-04-06 19:32:56 +08:00
|
|
|
enum class DirectSubmissionSfenceMode : int32_t {
|
|
|
|
Disabled = 0,
|
|
|
|
BeforeSemaphoreOnly = 1,
|
|
|
|
BeforeAndAfterSemaphore = 2
|
|
|
|
};
|
|
|
|
|
2020-09-22 23:49:06 +08:00
|
|
|
namespace UllsDefaults {
|
2021-04-14 22:40:23 +08:00
|
|
|
constexpr bool defaultDisableCacheFlush = true;
|
2020-09-22 23:49:06 +08:00
|
|
|
constexpr bool defaultDisableMonitorFence = false;
|
|
|
|
} // namespace UllsDefaults
|
|
|
|
|
2020-01-16 00:02:47 +08:00
|
|
|
struct BatchBuffer;
|
2020-03-27 23:32:07 +08:00
|
|
|
class DirectSubmissionDiagnosticsCollector;
|
2020-01-16 00:02:47 +08:00
|
|
|
class FlushStampTracker;
|
|
|
|
class GraphicsAllocation;
|
2022-06-23 17:44:45 +08:00
|
|
|
class LogicalStateHelper;
|
2020-01-16 00:02:47 +08:00
|
|
|
struct HardwareInfo;
|
|
|
|
class OsContext;
|
2022-04-20 21:55:31 +08:00
|
|
|
class MemoryOperationsHandler;
|
|
|
|
|
|
|
|
struct DirectSubmissionInputParams : NonCopyableClass {
|
|
|
|
DirectSubmissionInputParams(const CommandStreamReceiver &commandStreamReceiver);
|
|
|
|
OsContext &osContext;
|
|
|
|
const RootDeviceEnvironment &rootDeviceEnvironment;
|
2022-06-23 17:44:45 +08:00
|
|
|
LogicalStateHelper *logicalStateHelper = nullptr;
|
2022-04-20 21:55:31 +08:00
|
|
|
MemoryManager *memoryManager = nullptr;
|
|
|
|
const GraphicsAllocation *globalFenceAllocation = nullptr;
|
|
|
|
GraphicsAllocation *workPartitionAllocation = nullptr;
|
2022-04-21 01:32:39 +08:00
|
|
|
GraphicsAllocation *completionFenceAllocation = nullptr;
|
2022-04-20 21:55:31 +08:00
|
|
|
const uint32_t rootDeviceIndex;
|
|
|
|
};
|
2020-01-16 00:02:47 +08:00
|
|
|
|
2020-03-27 03:13:10 +08:00
|
|
|
template <typename GfxFamily, typename Dispatcher>
|
2020-01-16 00:02:47 +08:00
|
|
|
class DirectSubmissionHw {
|
|
|
|
public:
|
2022-04-20 21:55:31 +08:00
|
|
|
DirectSubmissionHw(const DirectSubmissionInputParams &inputParams);
|
2020-01-16 00:02:47 +08:00
|
|
|
|
|
|
|
virtual ~DirectSubmissionHw();
|
|
|
|
|
2021-12-23 03:28:02 +08:00
|
|
|
bool initialize(bool submitOnInit, bool useNotify);
|
2020-01-16 00:02:47 +08:00
|
|
|
|
2021-12-06 06:32:20 +08:00
|
|
|
MOCKABLE_VIRTUAL bool stopRingBuffer();
|
2020-01-16 00:02:47 +08:00
|
|
|
|
|
|
|
bool startRingBuffer();
|
|
|
|
|
2022-01-07 22:53:31 +08:00
|
|
|
MOCKABLE_VIRTUAL bool dispatchCommandBuffer(BatchBuffer &batchBuffer, FlushStampTracker &flushStamp);
|
2020-01-16 00:02:47 +08:00
|
|
|
|
2022-04-20 21:55:31 +08:00
|
|
|
static std::unique_ptr<DirectSubmissionHw<GfxFamily, Dispatcher>> create(const DirectSubmissionInputParams &inputParams);
|
2020-07-17 17:28:59 +08:00
|
|
|
|
2022-04-26 21:29:31 +08:00
|
|
|
virtual uint32_t *getCompletionValuePointer() { return nullptr; }
|
|
|
|
|
2020-01-16 00:02:47 +08:00
|
|
|
protected:
|
|
|
|
static constexpr size_t prefetchSize = 8 * MemoryConstants::cacheLineSize;
|
2020-03-27 23:32:07 +08:00
|
|
|
static constexpr size_t prefetchNoops = prefetchSize / sizeof(uint32_t);
|
2020-01-16 00:02:47 +08:00
|
|
|
bool allocateResources();
|
2021-12-06 06:32:20 +08:00
|
|
|
MOCKABLE_VIRTUAL void deallocateResources();
|
2020-07-17 17:28:59 +08:00
|
|
|
MOCKABLE_VIRTUAL bool makeResourcesResident(DirectSubmissionAllocations &allocations);
|
|
|
|
virtual bool allocateOsResources() = 0;
|
2020-01-16 00:02:47 +08:00
|
|
|
virtual bool submit(uint64_t gpuAddress, size_t size) = 0;
|
|
|
|
virtual bool handleResidency() = 0;
|
2021-04-14 22:40:23 +08:00
|
|
|
virtual void handleNewResourcesSubmission();
|
|
|
|
virtual size_t getSizeNewResourceHandler();
|
2021-08-25 23:19:44 +08:00
|
|
|
virtual void handleStopRingBuffer(){};
|
2020-07-17 17:28:59 +08:00
|
|
|
virtual uint64_t switchRingBuffers();
|
|
|
|
virtual void handleSwitchRingBuffers() = 0;
|
2020-01-16 00:02:47 +08:00
|
|
|
GraphicsAllocation *switchRingBuffersAllocations();
|
|
|
|
virtual uint64_t updateTagValue() = 0;
|
|
|
|
virtual void getTagAddressValue(TagData &tagData) = 0;
|
2022-11-09 22:43:02 +08:00
|
|
|
void unblockGpu();
|
2020-01-16 00:02:47 +08:00
|
|
|
|
|
|
|
void cpuCachelineFlush(void *ptr, size_t size);
|
|
|
|
|
2020-03-27 23:32:07 +08:00
|
|
|
void dispatchSemaphoreSection(uint32_t value);
|
2020-01-16 00:02:47 +08:00
|
|
|
size_t getSizeSemaphoreSection();
|
|
|
|
|
|
|
|
void dispatchStartSection(uint64_t gpuStartAddress);
|
|
|
|
size_t getSizeStartSection();
|
|
|
|
|
|
|
|
void dispatchSwitchRingBufferSection(uint64_t nextBufferGpuAddress);
|
|
|
|
size_t getSizeSwitchRingBufferSection();
|
|
|
|
|
2022-11-17 01:24:04 +08:00
|
|
|
void dispatchTaskStoreSection(uint64_t taskStartSectionVa);
|
|
|
|
MOCKABLE_VIRTUAL void preinitializeTaskStoreSection();
|
|
|
|
|
2020-01-16 00:02:47 +08:00
|
|
|
void setReturnAddress(void *returnCmd, uint64_t returnAddress);
|
|
|
|
|
2020-03-18 21:14:04 +08:00
|
|
|
void *dispatchWorkloadSection(BatchBuffer &batchBuffer);
|
2020-01-16 00:02:47 +08:00
|
|
|
size_t getSizeDispatch();
|
|
|
|
|
2020-08-18 17:27:44 +08:00
|
|
|
void dispatchPrefetchMitigation();
|
|
|
|
size_t getSizePrefetchMitigation();
|
|
|
|
|
|
|
|
void dispatchDisablePrefetcher(bool disable);
|
|
|
|
size_t getSizeDisablePrefetcher();
|
|
|
|
|
2020-01-16 00:02:47 +08:00
|
|
|
size_t getSizeEnd();
|
|
|
|
|
|
|
|
uint64_t getCommandBufferPositionGpuAddress(void *position);
|
|
|
|
|
2021-11-18 03:51:43 +08:00
|
|
|
void dispatchPartitionRegisterConfiguration();
|
|
|
|
size_t getSizePartitionRegisterConfigurationSection();
|
|
|
|
|
2022-04-06 22:41:45 +08:00
|
|
|
void dispatchSystemMemoryFenceAddress();
|
|
|
|
size_t getSizeSystemMemoryFenceAddress();
|
|
|
|
|
2020-03-27 23:32:07 +08:00
|
|
|
void createDiagnostic();
|
|
|
|
void initDiagnostic(bool &submitOnInit);
|
|
|
|
MOCKABLE_VIRTUAL void performDiagnosticMode();
|
2020-05-19 00:48:43 +08:00
|
|
|
void dispatchDiagnosticModeSection();
|
|
|
|
size_t getDiagnosticModeSection();
|
2021-11-30 22:41:26 +08:00
|
|
|
void setPostSyncOffset();
|
2020-03-27 23:32:07 +08:00
|
|
|
|
2022-06-01 18:05:07 +08:00
|
|
|
virtual bool isCompleted(uint32_t ringBufferIndex) = 0;
|
|
|
|
|
|
|
|
struct RingBufferUse {
|
|
|
|
RingBufferUse() = default;
|
|
|
|
RingBufferUse(FlushStamp completionFence, GraphicsAllocation *ringBuffer) : completionFence(completionFence), ringBuffer(ringBuffer){};
|
|
|
|
|
|
|
|
constexpr static uint32_t initialRingBufferCount = 2u;
|
|
|
|
|
|
|
|
FlushStamp completionFence = 0ull;
|
|
|
|
GraphicsAllocation *ringBuffer = nullptr;
|
2020-01-16 00:02:47 +08:00
|
|
|
};
|
2022-06-01 18:05:07 +08:00
|
|
|
std::vector<RingBufferUse> ringBuffers;
|
2022-11-17 01:24:04 +08:00
|
|
|
std::unique_ptr<uint8_t[]> preinitializedTaskStoreSection;
|
2022-06-01 18:05:07 +08:00
|
|
|
uint32_t currentRingBuffer = 0u;
|
|
|
|
uint32_t previousRingBuffer = 0u;
|
|
|
|
uint32_t maxRingBufferCount = std::numeric_limits<uint32_t>::max();
|
2020-03-23 17:14:50 +08:00
|
|
|
|
2020-01-16 00:02:47 +08:00
|
|
|
LinearStream ringCommandStream;
|
2020-03-27 23:32:07 +08:00
|
|
|
std::unique_ptr<DirectSubmissionDiagnosticsCollector> diagnostic;
|
2020-01-16 00:02:47 +08:00
|
|
|
|
2020-03-23 17:14:50 +08:00
|
|
|
uint64_t semaphoreGpuVa = 0u;
|
2021-07-29 14:40:42 +08:00
|
|
|
uint64_t gpuVaForMiFlush = 0u;
|
2022-07-05 18:25:16 +08:00
|
|
|
uint64_t gpuVaForAdditionalSynchronizationWA = 0u;
|
2020-03-23 17:14:50 +08:00
|
|
|
|
|
|
|
OsContext &osContext;
|
2022-04-20 21:55:31 +08:00
|
|
|
const uint32_t rootDeviceIndex;
|
|
|
|
MemoryManager *memoryManager = nullptr;
|
2022-06-23 17:44:45 +08:00
|
|
|
LogicalStateHelper *logicalStateHelper = nullptr;
|
2022-04-20 21:55:31 +08:00
|
|
|
MemoryOperationsHandler *memoryOperationHandler = nullptr;
|
2020-03-23 17:14:50 +08:00
|
|
|
const HardwareInfo *hwInfo = nullptr;
|
2022-04-07 21:03:01 +08:00
|
|
|
const GraphicsAllocation *globalFenceAllocation = nullptr;
|
2022-04-21 01:32:39 +08:00
|
|
|
GraphicsAllocation *completionFenceAllocation = nullptr;
|
2020-01-16 00:02:47 +08:00
|
|
|
GraphicsAllocation *semaphores = nullptr;
|
2021-10-13 05:28:34 +08:00
|
|
|
GraphicsAllocation *workPartitionAllocation = nullptr;
|
2022-11-17 01:24:04 +08:00
|
|
|
GraphicsAllocation *deferredTasksListAllocation = nullptr;
|
2020-01-16 00:02:47 +08:00
|
|
|
void *semaphorePtr = nullptr;
|
|
|
|
volatile RingSemaphoreData *semaphoreData = nullptr;
|
2020-03-27 23:32:07 +08:00
|
|
|
volatile void *workloadModeOneStoreAddress = nullptr;
|
2020-03-23 17:14:50 +08:00
|
|
|
|
2020-01-16 00:02:47 +08:00
|
|
|
uint32_t currentQueueWorkCount = 1u;
|
2020-03-23 17:14:50 +08:00
|
|
|
uint32_t workloadMode = 0;
|
2020-03-27 23:32:07 +08:00
|
|
|
uint32_t workloadModeOneExpectedValue = 0u;
|
2021-09-28 07:27:46 +08:00
|
|
|
uint32_t activeTiles = 1u;
|
2021-11-30 22:41:26 +08:00
|
|
|
uint32_t postSyncOffset = 0u;
|
2022-04-06 19:32:56 +08:00
|
|
|
DirectSubmissionSfenceMode sfenceMode = DirectSubmissionSfenceMode::BeforeAndAfterSemaphore;
|
2022-03-29 19:51:44 +08:00
|
|
|
volatile uint32_t reserved = 0u;
|
2020-03-27 23:32:07 +08:00
|
|
|
|
2020-01-16 00:02:47 +08:00
|
|
|
bool ringStart = false;
|
2020-10-06 20:14:36 +08:00
|
|
|
bool disableCpuCacheFlush = true;
|
2020-03-23 17:14:50 +08:00
|
|
|
bool disableCacheFlush = false;
|
|
|
|
bool disableMonitorFence = false;
|
2021-09-28 07:27:46 +08:00
|
|
|
bool partitionedMode = false;
|
2021-10-26 19:53:01 +08:00
|
|
|
bool partitionConfigSet = true;
|
2021-12-23 03:28:02 +08:00
|
|
|
bool useNotifyForPostSync = false;
|
2022-04-06 22:41:45 +08:00
|
|
|
bool miMemFenceRequired = false;
|
|
|
|
bool systemMemoryFenceAddressSet = false;
|
2022-07-05 18:25:16 +08:00
|
|
|
bool completionFenceSupported = false;
|
2022-08-10 19:52:06 +08:00
|
|
|
bool isDisablePrefetcherRequired = false;
|
2022-10-12 02:47:13 +08:00
|
|
|
bool dcFlushRequired = false;
|
2022-11-17 01:24:04 +08:00
|
|
|
bool relaxedOrderingEnabled = false;
|
|
|
|
bool relaxedOrderingInitialized = false;
|
2020-01-16 00:02:47 +08:00
|
|
|
};
|
|
|
|
} // namespace NEO
|