2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2020-02-03 17:50:53 +01:00
|
|
|
* Copyright (C) 2017-2020 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 09:11:08 +02:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-23 18:46:50 +01:00
|
|
|
#include "os_interface/linux/drm_gem_close_worker.h"
|
2020-02-22 22:50:57 +01:00
|
|
|
#include "opencl/source/command_stream/device_command_stream.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
#include "drm/i915_drm.h"
|
2018-03-12 15:06:33 +01:00
|
|
|
|
|
|
|
|
#include <vector>
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
class BufferObject;
|
|
|
|
|
class Drm;
|
2019-09-01 21:36:15 +02:00
|
|
|
class DrmAllocation;
|
2017-12-21 00:45:38 +01:00
|
|
|
class DrmMemoryManager;
|
|
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
|
class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily> {
|
|
|
|
|
protected:
|
|
|
|
|
typedef DeviceCommandStreamReceiver<GfxFamily> BaseClass;
|
2018-03-29 10:41:39 +02:00
|
|
|
using CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiver::getTagAddress;
|
2017-12-21 00:45:38 +01:00
|
|
|
using BaseClass::getScratchPatchAddress;
|
|
|
|
|
using BaseClass::makeNonResident;
|
|
|
|
|
using BaseClass::makeResident;
|
|
|
|
|
using BaseClass::mediaVfeStateDirty;
|
2018-11-26 14:04:52 +01:00
|
|
|
using BaseClass::osContext;
|
2017-12-21 00:45:38 +01:00
|
|
|
using BaseClass::requiredScratchSize;
|
|
|
|
|
|
|
|
|
|
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
|
2019-10-29 08:01:53 +01:00
|
|
|
DrmCommandStreamReceiver(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex,
|
2018-08-30 09:27:47 +02:00
|
|
|
gemCloseWorkerMode mode = gemCloseWorkerMode::gemCloseWorkerActive);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-11-24 14:50:41 +01:00
|
|
|
bool flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
|
2020-02-03 17:50:53 +01:00
|
|
|
void processResidency(const ResidencyContainer &allocationsForResidency, uint32_t handleId) override;
|
2017-12-21 00:45:38 +01:00
|
|
|
void makeNonResident(GraphicsAllocation &gfxAllocation) override;
|
2018-11-26 14:04:52 +01:00
|
|
|
bool waitForFlushStamp(FlushStamp &flushStampToWait) override;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-07-29 16:11:51 +02:00
|
|
|
DrmMemoryManager *getMemoryManager() const;
|
2019-11-06 18:14:30 +01:00
|
|
|
GmmPageTableMngr *createPageTableManager() override;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-09-17 11:06:35 +02:00
|
|
|
gemCloseWorkerMode peekGemCloseWorkerOperationMode() const {
|
2017-12-21 00:45:38 +01:00
|
|
|
return this->gemCloseWorkerOperationMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected:
|
2020-02-03 17:50:53 +01:00
|
|
|
void makeResidentBufferObjects(const DrmAllocation *drmAllocation, uint32_t handleId);
|
2017-12-21 00:45:38 +01:00
|
|
|
void makeResident(BufferObject *bo);
|
2019-09-23 16:30:31 +02:00
|
|
|
void flushInternal(const BatchBuffer &batchBuffer, const ResidencyContainer &allocationsForResidency);
|
|
|
|
|
void exec(const BatchBuffer &batchBuffer, uint32_t drmContextId);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
|
std::vector<BufferObject *> residency;
|
|
|
|
|
std::vector<drm_i915_gem_exec_object2> execObjectsStorage;
|
|
|
|
|
Drm *drm;
|
|
|
|
|
gemCloseWorkerMode gemCloseWorkerOperationMode;
|
|
|
|
|
};
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|