2018-11-08 13:05:46 +01:00
|
|
|
/*
|
2024-03-12 23:56:09 +00:00
|
|
|
* Copyright (C) 2018-2024 Intel Corporation
|
2018-11-08 13:05:46 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2019-09-01 21:36:15 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2023-05-23 16:06:03 +00:00
|
|
|
#include "shared/source/memory_manager/definitions/engine_limits.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/os_interface/os_context.h"
|
2018-11-08 13:05:46 +01:00
|
|
|
|
2023-05-23 16:06:03 +00:00
|
|
|
#include <array>
|
2022-08-30 12:02:01 +00:00
|
|
|
#include <atomic>
|
2019-07-11 14:29:45 +02:00
|
|
|
#include <vector>
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2018-11-08 13:05:46 +01:00
|
|
|
class Drm;
|
|
|
|
|
|
2019-02-27 11:17:17 +01:00
|
|
|
class OsContextLinux : public OsContext {
|
2018-11-08 13:05:46 +01:00
|
|
|
public:
|
2019-02-27 11:17:17 +01:00
|
|
|
OsContextLinux() = delete;
|
|
|
|
|
~OsContextLinux() override;
|
2022-11-16 19:31:25 +00:00
|
|
|
OsContextLinux(Drm &drm, uint32_t rootDeviceIndex, uint32_t contextId, const EngineDescriptor &engineDescriptor);
|
2019-02-27 11:17:17 +01:00
|
|
|
|
2018-11-26 14:04:52 +01:00
|
|
|
unsigned int getEngineFlag() const { return engineFlag; }
|
2022-06-28 17:10:24 +02:00
|
|
|
void setEngineFlag(unsigned int engineFlag) { this->engineFlag = engineFlag; }
|
2019-07-17 15:38:14 +02:00
|
|
|
const std::vector<uint32_t> &getDrmContextIds() const { return drmContextIds; }
|
2020-08-17 12:07:39 +02:00
|
|
|
const std::vector<uint32_t> &getDrmVmIds() const { return drmVmIds; }
|
2023-09-20 13:08:46 +00:00
|
|
|
bool isDirectSubmissionSupported() const override;
|
2020-07-02 11:49:46 +02:00
|
|
|
Drm &getDrm() const;
|
2024-05-10 10:32:33 +02:00
|
|
|
virtual void waitForPagingFence();
|
2022-11-16 19:31:25 +00:00
|
|
|
static OsContext *create(OSInterface *osInterface, uint32_t rootDeviceIndex, uint32_t contextId, const EngineDescriptor &engineDescriptor);
|
2021-12-16 02:13:00 +00:00
|
|
|
void reInitializeContext() override;
|
2023-01-10 17:20:07 +00:00
|
|
|
void setHangDetected() {
|
|
|
|
|
contextHangDetected = true;
|
|
|
|
|
}
|
|
|
|
|
bool isHangDetected() const {
|
|
|
|
|
return contextHangDetected;
|
|
|
|
|
}
|
2018-11-08 13:05:46 +01:00
|
|
|
|
2023-03-31 11:41:17 +00:00
|
|
|
uint64_t getOfflineDumpContextId(uint32_t deviceIndex) const override;
|
|
|
|
|
|
2023-05-23 16:06:03 +00:00
|
|
|
uint64_t getNextFenceVal(uint32_t deviceIndex) { return fenceVal[deviceIndex] + 1; }
|
|
|
|
|
void incFenceVal(uint32_t deviceIndex) { fenceVal[deviceIndex]++; }
|
|
|
|
|
uint64_t *getFenceAddr(uint32_t deviceIndex) { return &pagingFence[deviceIndex]; }
|
|
|
|
|
void waitForBind(uint32_t drmIterator);
|
|
|
|
|
|
2018-11-08 13:05:46 +01:00
|
|
|
protected:
|
2024-06-06 11:23:55 +00:00
|
|
|
bool initializeContext(bool allocateInterrupt) override;
|
2021-04-15 16:14:04 +00:00
|
|
|
|
2018-11-26 14:04:52 +01:00
|
|
|
unsigned int engineFlag = 0;
|
2019-07-11 14:29:45 +02:00
|
|
|
std::vector<uint32_t> drmContextIds;
|
2020-08-17 12:07:39 +02:00
|
|
|
std::vector<uint32_t> drmVmIds;
|
2023-05-23 16:06:03 +00:00
|
|
|
|
|
|
|
|
std::array<uint64_t, EngineLimits::maxHandleCount> pagingFence;
|
|
|
|
|
std::array<uint64_t, EngineLimits::maxHandleCount> fenceVal;
|
|
|
|
|
|
2018-11-08 13:05:46 +01:00
|
|
|
Drm &drm;
|
2023-01-10 17:20:07 +00:00
|
|
|
bool contextHangDetected = false;
|
2018-11-08 13:05:46 +01:00
|
|
|
};
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|