refactor: move product specific ioctl helper creation out of i915 specific code

Related-To: NEO-13527
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2024-12-18 09:45:58 +00:00
committed by Compute-Runtime-Automation
parent 58223ce8e1
commit f357ada604
6 changed files with 13 additions and 26 deletions

View File

@@ -1091,9 +1091,14 @@ bool Drm::completionFenceSupport() {
void Drm::setupIoctlHelper(const PRODUCT_FAMILY productFamily) {
if (!this->ioctlHelper) {
std::string prelimVersion = "";
getPrelimVersion(prelimVersion);
this->ioctlHelper = IoctlHelper::getI915Helper(productFamily, prelimVersion, *this);
auto productSpecificIoctlHelperCreator = ioctlHelperFactory[productFamily];
if (productSpecificIoctlHelperCreator) {
this->ioctlHelper = productSpecificIoctlHelperCreator.value()(*this);
} else {
std::string prelimVersion = "";
getPrelimVersion(prelimVersion);
this->ioctlHelper = IoctlHelper::getI915Helper(productFamily, prelimVersion, *this);
}
this->ioctlHelper->initialize();
}
}

View File

@@ -26,6 +26,7 @@
namespace NEO {
std::optional<std::function<std::unique_ptr<IoctlHelper>(Drm &drm)>> ioctlHelperFactory[IGFX_MAX_PRODUCT] = {};
void IoctlHelper::setExternalContext(ExternalCtx *ctx) {
externalCtx = ctx;
}

View File

@@ -446,4 +446,5 @@ class IoctlHelperPrelim20 : public IoctlHelperI915 {
uint64_t uuid = 0;
};
extern std::optional<std::function<std::unique_ptr<IoctlHelper>(Drm &drm)>> ioctlHelperFactory[IGFX_MAX_PRODUCT];
} // namespace NEO

View File

@@ -1,27 +1,17 @@
/*
* Copyright (C) 2021-2023 Intel Corporation
* Copyright (C) 2021-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/os_interface/linux/ioctl_helper.h"
#include <functional>
#include <string>
namespace NEO {
std::optional<std::function<std::unique_ptr<IoctlHelper>(Drm &drm)>> ioctlHelperFactory[IGFX_MAX_PRODUCT] = {};
std::unique_ptr<IoctlHelper> IoctlHelper::getI915Helper(const PRODUCT_FAMILY productFamily, const std::string &prelimVersion, Drm &drm) {
auto productSpecificIoctlHelperCreator = ioctlHelperFactory[productFamily];
if (productSpecificIoctlHelperCreator) {
return productSpecificIoctlHelperCreator.value()(drm);
}
if (prelimVersion == "") {
return std::make_unique<IoctlHelperUpstream>(drm);
}

View File

@@ -1,24 +1,17 @@
/*
* Copyright (C) 2022-2023 Intel Corporation
* Copyright (C) 2022-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/hw_info.h"
#include "shared/source/os_interface/linux/ioctl_helper.h"
#include <functional>
#include <memory>
namespace NEO {
std::optional<std::function<std::unique_ptr<IoctlHelper>(Drm &drm)>> ioctlHelperFactory[IGFX_MAX_PRODUCT] = {};
std::unique_ptr<IoctlHelper> IoctlHelper::getI915Helper(const PRODUCT_FAMILY productFamily, const std::string &prelimVersion, Drm &drm) {
auto productSpecificIoctlHelperCreator = ioctlHelperFactory[productFamily];
if (productSpecificIoctlHelperCreator) {
return productSpecificIoctlHelperCreator.value()(drm);
}
return std::make_unique<IoctlHelperUpstream>(drm);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 Intel Corporation
* Copyright (C) 2021-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -7,10 +7,7 @@
#include "shared/source/os_interface/linux/ioctl_helper.h"
#include <functional>
namespace NEO {
extern std::optional<std::function<std::unique_ptr<IoctlHelper>(Drm &drm)>> ioctlHelperFactory[IGFX_MAX_PRODUCT];
struct EnableProductIoctlHelperDg1 {
EnableProductIoctlHelperDg1() {