fix: Make tlb flush os agnostic

Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
Lukasz Jobczyk
2023-06-29 12:53:36 +00:00
committed by Compute-Runtime-Automation
parent 3c4d921a80
commit c294ef48ce
18 changed files with 159 additions and 67 deletions

View File

@@ -105,8 +105,9 @@ class DirectSubmissionHw {
virtual bool allocateOsResources() = 0;
virtual bool submit(uint64_t gpuAddress, size_t size) = 0;
virtual bool handleResidency() = 0;
virtual void handleNewResourcesSubmission();
virtual size_t getSizeNewResourceHandler();
void handleNewResourcesSubmission();
bool isNewResourceHandleNeeded();
size_t getSizeNewResourceHandler();
virtual void handleStopRingBuffer(){};
virtual uint64_t switchRingBuffers();
virtual void handleSwitchRingBuffers() = 0;

View File

@@ -1000,11 +1000,28 @@ inline void DirectSubmissionHw<GfxFamily, Dispatcher>::setReturnAddress(void *re
template <typename GfxFamily, typename Dispatcher>
inline void DirectSubmissionHw<GfxFamily, Dispatcher>::handleNewResourcesSubmission() {
if (isNewResourceHandleNeeded()) {
auto tlbFlushCounter = this->osContext.peekTlbFlushCounter();
Dispatcher::dispatchTlbFlush(this->ringCommandStream, this->gpuVaForMiFlush, this->rootDeviceEnvironment);
this->osContext.setTlbFlushed(tlbFlushCounter);
}
}
template <typename GfxFamily, typename Dispatcher>
inline size_t DirectSubmissionHw<GfxFamily, Dispatcher>::getSizeNewResourceHandler() {
return 0u;
size_t DirectSubmissionHw<GfxFamily, Dispatcher>::getSizeNewResourceHandler() {
// Overestimate to avoid race
return Dispatcher::getSizeTlbFlush(this->rootDeviceEnvironment);
}
template <typename GfxFamily, typename Dispatcher>
bool DirectSubmissionHw<GfxFamily, Dispatcher>::isNewResourceHandleNeeded() {
auto newResourcesBound = this->osContext.isTlbFlushRequired();
if (DebugManager.flags.DirectSubmissionNewResourceTlbFlush.get() != -1) {
newResourcesBound = DebugManager.flags.DirectSubmissionNewResourceTlbFlush.get();
}
return newResourcesBound;
}
template <typename GfxFamily, typename Dispatcher>

View File

@@ -27,9 +27,6 @@ class DrmDirectSubmission : public DirectSubmissionHw<GfxFamily, Dispatcher> {
bool submit(uint64_t gpuAddress, size_t size) override;
bool handleResidency() override;
bool isNewResourceHandleNeeded();
void handleNewResourcesSubmission() override;
size_t getSizeNewResourceHandler() override;
void handleStopRingBuffer() override;
void handleSwitchRingBuffers() override;
uint64_t updateTagValue() override;

View File

@@ -189,35 +189,6 @@ bool DrmDirectSubmission<GfxFamily, Dispatcher>::handleResidency() {
return true;
}
template <typename GfxFamily, typename Dispatcher>
bool DrmDirectSubmission<GfxFamily, Dispatcher>::isNewResourceHandleNeeded() {
auto osContextLinux = static_cast<OsContextLinux *>(&this->osContext);
auto newResourcesBound = osContextLinux->isTlbFlushRequired();
if (DebugManager.flags.DirectSubmissionNewResourceTlbFlush.get() != -1) {
newResourcesBound = DebugManager.flags.DirectSubmissionNewResourceTlbFlush.get();
}
return newResourcesBound;
}
template <typename GfxFamily, typename Dispatcher>
void DrmDirectSubmission<GfxFamily, Dispatcher>::handleNewResourcesSubmission() {
if (isNewResourceHandleNeeded()) {
auto osContextLinux = static_cast<OsContextLinux *>(&this->osContext);
auto tlbFlushCounter = osContextLinux->peekTlbFlushCounter();
Dispatcher::dispatchTlbFlush(this->ringCommandStream, this->gpuVaForMiFlush, this->rootDeviceEnvironment);
osContextLinux->setTlbFlushed(tlbFlushCounter);
}
}
template <typename GfxFamily, typename Dispatcher>
size_t DrmDirectSubmission<GfxFamily, Dispatcher>::getSizeNewResourceHandler() {
// Overestimate to avoid race
return Dispatcher::getSizeTlbFlush(this->rootDeviceEnvironment);
}
template <typename GfxFamily, typename Dispatcher>
void DrmDirectSubmission<GfxFamily, Dispatcher>::handleStopRingBuffer() {
if (this->disableMonitorFence) {