Skip to content

Commit 0a7ed9f

Browse files
feature: Add ioctl helpers for primary contexts
Related-To: NEO-12952 Signed-off-by: Slawomir Milczarek <[email protected]>
1 parent 7c34687 commit 0a7ed9f

File tree

6 files changed

+18
-7
lines changed

6 files changed

+18
-7
lines changed

shared/source/os_interface/linux/xe/ioctl_helper_xe.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ int IoctlHelperXe::createDrmContext(Drm &drm, OsContextLinux &osContext, uint32_
13191319
std::array<drm_xe_ext_set_property, maxContextSetProperties> extProperties{};
13201320
uint32_t extPropertyIndex{0U};
13211321
setOptionalContextProperties(drm, &extProperties, extPropertyIndex);
1322-
setContextProperties(osContext, &extProperties, extPropertyIndex);
1322+
setContextProperties(osContext, deviceIndex, &extProperties, extPropertyIndex);
13231323

13241324
drm_xe_exec_queue_create create{};
13251325
create.width = 1;
@@ -1653,7 +1653,7 @@ void IoctlHelperXe::setOptionalContextProperties(Drm &drm, void *extProperties,
16531653
}
16541654
}
16551655

1656-
void IoctlHelperXe::setContextProperties(const OsContextLinux &osContext, void *extProperties, uint32_t &extIndexInOut) {
1656+
void IoctlHelperXe::setContextProperties(const OsContextLinux &osContext, uint32_t deviceIndex, void *extProperties, uint32_t &extIndexInOut) {
16571657

16581658
auto &ext = *reinterpret_cast<std::array<drm_xe_ext_set_property, maxContextSetProperties> *>(extProperties);
16591659

shared/source/os_interface/linux/xe/ioctl_helper_xe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class IoctlHelperXe : public IoctlHelper {
167167

168168
uint16_t getDefaultEngineClass(const aub_stream::EngineType &defaultEngineType);
169169
void setOptionalContextProperties(Drm &drm, void *extProperties, uint32_t &extIndexInOut);
170-
virtual void setContextProperties(const OsContextLinux &osContext, void *extProperties, uint32_t &extIndexInOut);
170+
virtual void setContextProperties(const OsContextLinux &osContext, uint32_t deviceIndex, void *extProperties, uint32_t &extIndexInOut);
171171
virtual void applyContextFlags(void *execQueueCreate, bool allocateInterrupt){};
172172

173173
struct GtIpVersion {

shared/source/os_interface/linux/xe/ioctl_helper_xe_prelim.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@
99

1010
namespace NEO {
1111

12-
void IoctlHelperXePrelim::setContextProperties(const OsContextLinux &osContext, void *extProperties, uint32_t &extIndexInOut) {
13-
IoctlHelperXe::setContextProperties(osContext, extProperties, extIndexInOut);
12+
bool IoctlHelperXePrelim::isPrimaryContext(const OsContextLinux &osContext, uint32_t deviceIndex) {
13+
return false;
14+
}
15+
16+
uint32_t IoctlHelperXePrelim::getPrimaryContextId(const OsContextLinux &osContext, uint32_t deviceIndex, size_t contextIndex) {
17+
return static_cast<uint32_t>(-1);
18+
}
19+
20+
void IoctlHelperXePrelim::setContextProperties(const OsContextLinux &osContext, uint32_t deviceIndex, void *extProperties, uint32_t &extIndexInOut) {
21+
IoctlHelperXe::setContextProperties(osContext, deviceIndex, extProperties, extIndexInOut);
1422
}
1523

1624
bool IoctlHelperXePrelim::getFdFromVmExport(uint32_t vmId, uint32_t flags, int32_t *fd) {

shared/source/os_interface/linux/xe/ioctl_helper_xe_prelim.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class IoctlHelperXePrelim : public IoctlHelperXe {
2020
std::string getIoctlString(DrmIoctl ioctlRequest) const override;
2121

2222
protected:
23-
void setContextProperties(const OsContextLinux &osContext, void *extProperties, uint32_t &extIndexInOut) override;
23+
virtual bool isPrimaryContext(const OsContextLinux &osContext, uint32_t deviceIndex);
24+
virtual uint32_t getPrimaryContextId(const OsContextLinux &osContext, uint32_t deviceIndex, size_t contextIndex);
25+
void setContextProperties(const OsContextLinux &osContext, uint32_t deviceIndex, void *extProperties, uint32_t &extIndexInOut) override;
2426
};
2527

2628
} // namespace NEO

shared/test/common/os_interface/linux/xe/mock_drm_xe.inl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ inline constexpr int testValueMapOff = 0x7788;
1010
inline constexpr int testValuePrime = 0x4321;
1111
inline constexpr uint32_t testValueGemCreate = 0x8273;
1212
struct DrmMockXe : public DrmMockCustom {
13+
using Drm::engineInfo;
1314

1415
static std::unique_ptr<DrmMockXe> create(RootDeviceEnvironment &rootDeviceEnvironment);
1516

shared/test/unit_test/os_interface/linux/xe/ioctl_helper_xe_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2098,7 +2098,7 @@ TEST_F(IoctlHelperXeTest, givenLowPriorityContextWhenSettingPropertiesThenCorrec
20982098
OsContextLinux osContext(*drm, 0, 5u, EngineDescriptorHelper::getDefaultDescriptor({aub_stream::ENGINE_CCS, EngineUsage::lowPriority}));
20992099
std::array<drm_xe_ext_set_property, MockIoctlHelperXe::maxContextSetProperties> extProperties{};
21002100
uint32_t extIndex = 1;
2101-
xeIoctlHelper->setContextProperties(osContext, &extProperties, extIndex);
2101+
xeIoctlHelper->setContextProperties(osContext, 0, &extProperties, extIndex);
21022102

21032103
EXPECT_EQ(reinterpret_cast<uint64_t>(&extProperties[1]), extProperties[0].base.next_extension);
21042104
EXPECT_EQ(0u, extProperties[1].base.next_extension);

0 commit comments

Comments
 (0)