2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2022-01-07 22:53:31 +08:00
|
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-03-03 18:59:49 +08:00
|
|
|
#include "shared/source/command_stream/device_command_stream.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/os_interface/linux/drm_gem_close_worker.h"
|
2022-05-11 23:06:01 +08:00
|
|
|
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
2018-03-12 22:06:33 +08:00
|
|
|
|
|
|
|
#include <vector>
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
class BufferObject;
|
|
|
|
class Drm;
|
2019-09-02 03:36:15 +08:00
|
|
|
class DrmAllocation;
|
2017-12-21 07:45:38 +08:00
|
|
|
class DrmMemoryManager;
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
|
|
|
|
protected:
|
2021-06-17 19:55:28 +08:00
|
|
|
using BaseClass = DeviceCommandStreamReceiver<GfxFamily>;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
using BaseClass::getScratchPatchAddress;
|
|
|
|
using BaseClass::makeNonResident;
|
|
|
|
using BaseClass::makeResident;
|
|
|
|
using BaseClass::mediaVfeStateDirty;
|
2018-11-26 21:04:52 +08:00
|
|
|
using BaseClass::osContext;
|
2017-12-21 07:45:38 +08:00
|
|
|
using BaseClass::requiredScratchSize;
|
2021-06-17 19:55:28 +08:00
|
|
|
using CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiver::getTagAddress;
|
|
|
|
using CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiver::getTagAllocation;
|
2021-08-09 17:52:54 +08:00
|
|
|
using CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiver::latestSentTaskCount;
|
2021-06-17 19:55:28 +08:00
|
|
|
using CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiver::taskCount;
|
|
|
|
using CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiver::useNotifyEnableForPostSync;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
// When drm is null default implementation is used. In this case DrmCommandStreamReceiver is responsible to free drm.
|
|
|
|
// When drm is passed, DCSR will not free it at destruction
|
2020-10-29 22:33:35 +08:00
|
|
|
DrmCommandStreamReceiver(ExecutionEnvironment &executionEnvironment,
|
|
|
|
uint32_t rootDeviceIndex,
|
|
|
|
const DeviceBitfield deviceBitfield,
|
2018-08-30 15:27:47 +08:00
|
|
|
gemCloseWorkerMode mode = gemCloseWorkerMode::gemCloseWorkerActive);
|
2022-05-10 01:40:30 +08:00
|
|
|
~DrmCommandStreamReceiver() override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2022-01-07 22:53:31 +08:00
|
|
|
SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
|
2022-11-15 18:04:19 +08:00
|
|
|
SubmissionStatus processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override;
|
2017-12-21 07:45:38 +08:00
|
|
|
void makeNonResident(GraphicsAllocation &gfxAllocation) override;
|
2021-09-17 21:05:26 +08:00
|
|
|
bool waitForFlushStamp(FlushStamp &flushStampToWait) override;
|
2021-06-15 19:31:12 +08:00
|
|
|
bool isKmdWaitModeActive() override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-07-29 22:11:51 +08:00
|
|
|
DrmMemoryManager *getMemoryManager() const;
|
2019-11-07 01:14:30 +08:00
|
|
|
GmmPageTableMngr *createPageTableManager() override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-09-17 17:06:35 +08:00
|
|
|
gemCloseWorkerMode peekGemCloseWorkerOperationMode() const {
|
2017-12-21 07:45:38 +08:00
|
|
|
return this->gemCloseWorkerOperationMode;
|
|
|
|
}
|
|
|
|
|
2020-09-05 07:18:12 +08:00
|
|
|
void initializeDefaultsForInternalEngine() override {
|
|
|
|
gemCloseWorkerOperationMode = gemCloseWorkerMode::gemCloseWorkerInactive;
|
|
|
|
}
|
|
|
|
|
2022-11-15 19:21:56 +08:00
|
|
|
SubmissionStatus printBOsForSubmit(ResidencyContainer &allocationsForResidency, GraphicsAllocation &cmdBufferAllocation);
|
2021-02-19 23:23:35 +08:00
|
|
|
|
2021-09-29 23:59:41 +08:00
|
|
|
using CommandStreamReceiver::pageTableManager;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
protected:
|
2022-09-13 22:26:03 +08:00
|
|
|
MOCKABLE_VIRTUAL SubmissionStatus flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency);
|
2022-01-21 02:13:07 +08:00
|
|
|
MOCKABLE_VIRTUAL int exec(const BatchBuffer &batchBuffer, uint32_t vmHandleId, uint32_t drmContextId, uint32_t index);
|
2021-09-17 21:05:26 +08:00
|
|
|
MOCKABLE_VIRTUAL int waitUserFence(uint32_t waitValue);
|
2022-03-29 19:51:44 +08:00
|
|
|
MOCKABLE_VIRTUAL void readBackAllocation(void *source);
|
2021-06-18 09:11:36 +08:00
|
|
|
bool isUserFenceWaitActive();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-05-06 18:37:15 +08:00
|
|
|
std::vector<BufferObject *> residency;
|
2022-05-11 23:06:01 +08:00
|
|
|
std::vector<ExecObject> execObjectsStorage;
|
2017-12-21 07:45:38 +08:00
|
|
|
Drm *drm;
|
|
|
|
gemCloseWorkerMode gemCloseWorkerOperationMode;
|
2021-06-04 20:23:20 +08:00
|
|
|
|
2022-03-29 19:51:44 +08:00
|
|
|
volatile uint32_t reserved = 0;
|
2021-06-18 09:11:36 +08:00
|
|
|
int32_t kmdWaitTimeout = -1;
|
|
|
|
|
2021-08-12 00:13:08 +08:00
|
|
|
bool useUserFenceWait = true;
|
2021-09-09 17:58:46 +08:00
|
|
|
bool useContextForUserFenceWait = false;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|