Skip to content

Commit f357ada

Browse files
refactor: move product specific ioctl helper creation out of i915 specific code
Related-To: NEO-13527 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 58223ce commit f357ada

File tree

6 files changed

+13
-26
lines changed

6 files changed

+13
-26
lines changed

shared/source/os_interface/linux/drm_neo.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,9 +1091,14 @@ bool Drm::completionFenceSupport() {
10911091

10921092
void Drm::setupIoctlHelper(const PRODUCT_FAMILY productFamily) {
10931093
if (!this->ioctlHelper) {
1094-
std::string prelimVersion = "";
1095-
getPrelimVersion(prelimVersion);
1096-
this->ioctlHelper = IoctlHelper::getI915Helper(productFamily, prelimVersion, *this);
1094+
auto productSpecificIoctlHelperCreator = ioctlHelperFactory[productFamily];
1095+
if (productSpecificIoctlHelperCreator) {
1096+
this->ioctlHelper = productSpecificIoctlHelperCreator.value()(*this);
1097+
} else {
1098+
std::string prelimVersion = "";
1099+
getPrelimVersion(prelimVersion);
1100+
this->ioctlHelper = IoctlHelper::getI915Helper(productFamily, prelimVersion, *this);
1101+
}
10971102
this->ioctlHelper->initialize();
10981103
}
10991104
}

shared/source/os_interface/linux/ioctl_helper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
namespace NEO {
2828

29+
std::optional<std::function<std::unique_ptr<IoctlHelper>(Drm &drm)>> ioctlHelperFactory[IGFX_MAX_PRODUCT] = {};
2930
void IoctlHelper::setExternalContext(ExternalCtx *ctx) {
3031
externalCtx = ctx;
3132
}

shared/source/os_interface/linux/ioctl_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,4 +446,5 @@ class IoctlHelperPrelim20 : public IoctlHelperI915 {
446446
uint64_t uuid = 0;
447447
};
448448

449+
extern std::optional<std::function<std::unique_ptr<IoctlHelper>(Drm &drm)>> ioctlHelperFactory[IGFX_MAX_PRODUCT];
449450
} // namespace NEO

shared/source/os_interface/linux/ioctl_helper_getter.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
11
/*
2-
* Copyright (C) 2021-2023 Intel Corporation
2+
* Copyright (C) 2021-2024 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

8-
#include "shared/source/execution_environment/root_device_environment.h"
9-
#include "shared/source/helpers/hw_info.h"
10-
#include "shared/source/os_interface/linux/drm_neo.h"
118
#include "shared/source/os_interface/linux/ioctl_helper.h"
129

13-
#include <functional>
1410
#include <string>
1511

1612
namespace NEO {
1713

18-
std::optional<std::function<std::unique_ptr<IoctlHelper>(Drm &drm)>> ioctlHelperFactory[IGFX_MAX_PRODUCT] = {};
19-
2014
std::unique_ptr<IoctlHelper> IoctlHelper::getI915Helper(const PRODUCT_FAMILY productFamily, const std::string &prelimVersion, Drm &drm) {
21-
auto productSpecificIoctlHelperCreator = ioctlHelperFactory[productFamily];
22-
if (productSpecificIoctlHelperCreator) {
23-
return productSpecificIoctlHelperCreator.value()(drm);
24-
}
2515
if (prelimVersion == "") {
2616
return std::make_unique<IoctlHelperUpstream>(drm);
2717
}

shared/source/os_interface/linux/ioctl_helper_getter_upstream.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
/*
2-
* Copyright (C) 2022-2023 Intel Corporation
2+
* Copyright (C) 2022-2024 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

8-
#include "shared/source/helpers/hw_info.h"
98
#include "shared/source/os_interface/linux/ioctl_helper.h"
109

11-
#include <functional>
1210
#include <memory>
1311

1412
namespace NEO {
15-
std::optional<std::function<std::unique_ptr<IoctlHelper>(Drm &drm)>> ioctlHelperFactory[IGFX_MAX_PRODUCT] = {};
1613

1714
std::unique_ptr<IoctlHelper> IoctlHelper::getI915Helper(const PRODUCT_FAMILY productFamily, const std::string &prelimVersion, Drm &drm) {
18-
auto productSpecificIoctlHelperCreator = ioctlHelperFactory[productFamily];
19-
if (productSpecificIoctlHelperCreator) {
20-
return productSpecificIoctlHelperCreator.value()(drm);
21-
}
2215
return std::make_unique<IoctlHelperUpstream>(drm);
2316
}
2417

shared/source/os_interface/linux/local/dg1/enable_ioctl_helper_dg1.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
/*
2-
* Copyright (C) 2021-2022 Intel Corporation
2+
* Copyright (C) 2021-2024 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
66
*/
77

88
#include "shared/source/os_interface/linux/ioctl_helper.h"
99

10-
#include <functional>
11-
1210
namespace NEO {
13-
extern std::optional<std::function<std::unique_ptr<IoctlHelper>(Drm &drm)>> ioctlHelperFactory[IGFX_MAX_PRODUCT];
1411

1512
struct EnableProductIoctlHelperDg1 {
1613
EnableProductIoctlHelperDg1() {

0 commit comments

Comments
 (0)