mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 22:43:00 +08:00
fix: update properly bindInfo in GemCreate on xe kmd
Related-To: NEO-8325 Signed-off-by: Cencelewska, Katarzyna <katarzyna.cencelewska@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
0dd40b8616
commit
df961b3dc0
@@ -435,6 +435,12 @@ bool IoctlHelperXe::getTopologyDataAndMap(const HardwareInfo &hwInfo, DrmQueryTo
|
||||
return true;
|
||||
}
|
||||
|
||||
void IoctlHelperXe::updateBindInfo(uint32_t handle, uint64_t userPtr, uint64_t size) {
|
||||
std::unique_lock<std::mutex> lock(xeLock);
|
||||
BindInfo b = {handle, userPtr, 0, size};
|
||||
bindInfo.push_back(b);
|
||||
}
|
||||
|
||||
int IoctlHelperXe::createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks) {
|
||||
struct drm_xe_gem_create create = {};
|
||||
uint32_t regionsSize = static_cast<uint32_t>(memClassInstances.size());
|
||||
@@ -462,13 +468,7 @@ int IoctlHelperXe::createGemExt(const MemRegionsVec &memClassInstances, size_t a
|
||||
xeLog(" -> IoctlHelperXe::%s [%d,%d] vmid=0x%x s=0x%lx f=0x%x h=0x%x r=%d\n", __FUNCTION__,
|
||||
mem.memoryClass, mem.memoryInstance,
|
||||
create.vm_id, create.size, create.flags, handle, ret);
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(xeLock);
|
||||
BindInfo b = {create.handle, 0, 0, create.size};
|
||||
bindInfo.push_back(b);
|
||||
}
|
||||
|
||||
updateBindInfo(create.handle, 0u, create.size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -496,6 +496,7 @@ uint32_t IoctlHelperXe::createGem(uint64_t size, uint32_t memoryBanks) {
|
||||
create.flags = static_cast<uint32_t>(memoryInstances.to_ulong());
|
||||
[[maybe_unused]] auto ret = ioctl(DrmIoctl::GemCreate, &create);
|
||||
DEBUG_BREAK_IF(ret != 0);
|
||||
updateBindInfo(create.handle, 0u, create.size);
|
||||
return create.handle;
|
||||
}
|
||||
|
||||
@@ -984,11 +985,7 @@ int IoctlHelperXe::ioctl(DrmIoctl request, void *arg) {
|
||||
case DrmIoctl::GemUserptr: {
|
||||
GemUserPtr *d = static_cast<GemUserPtr *>(arg);
|
||||
d->handle = userPtrHandle++ | XE_USERPTR_FAKE_FLAG;
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(xeLock);
|
||||
BindInfo b = {d->handle, d->userPtr, 0, d->userSize};
|
||||
bindInfo.push_back(b);
|
||||
}
|
||||
updateBindInfo(d->handle, d->userPtr, d->userSize);
|
||||
ret = 0;
|
||||
xeLog(" -> IoctlHelperXe::ioctl GemUserptrGemUserptr p=0x%llx s=0x%llx f=0x%x h=0x%x r=%d\n", d->userPtr,
|
||||
d->userSize, d->flags, d->handle, ret);
|
||||
|
||||
@@ -111,7 +111,6 @@ class IoctlHelperXe : public IoctlHelper {
|
||||
uint32_t xeSyncObjCreate(uint32_t flags);
|
||||
bool xeSyncObjWait(uint32_t *handles, uint32_t count, uint64_t absTimeoutNsec, uint32_t flags, uint32_t *firstSignaled);
|
||||
void xeSyncObjDestroy(uint32_t handle);
|
||||
|
||||
int xeGetQuery(Query *data);
|
||||
struct drm_xe_engine_class_instance *xeFindMatchingEngine(uint16_t engineClass, uint16_t engineInstance);
|
||||
|
||||
@@ -123,6 +122,7 @@ class IoctlHelperXe : public IoctlHelper {
|
||||
int xeWaitUserFence(uint64_t mask, uint16_t op, uint64_t addr, uint64_t value, int64_t timeout);
|
||||
int xeVmBind(const VmBindParams &vmBindParams, bool bindOp);
|
||||
void xeShowBindTable();
|
||||
void updateBindInfo(uint32_t handle, uint64_t userPtr, uint64_t size);
|
||||
|
||||
struct UserFenceExtension {
|
||||
static constexpr uint32_t tagValue = 0x123987;
|
||||
|
||||
@@ -65,7 +65,7 @@ TEST(IoctlHelperXeTest, whenChangingBufferBindingThenWaitIsNeededAlways) {
|
||||
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGemCreateExtWithRegionsThenDummyValueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
|
||||
ASSERT_NE(nullptr, xeIoctlHelper);
|
||||
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
@@ -77,13 +77,16 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGemCreateExtWithRegionsThen
|
||||
|
||||
uint32_t handle = 0u;
|
||||
uint32_t numOfChunks = 0;
|
||||
|
||||
EXPECT_TRUE(xeIoctlHelper->bindInfo.empty());
|
||||
EXPECT_NE(0, xeIoctlHelper->createGemExt(memRegions, 0u, handle, 0, {}, -1, false, numOfChunks));
|
||||
EXPECT_FALSE(xeIoctlHelper->bindInfo.empty());
|
||||
}
|
||||
|
||||
TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGemCreateExtWithRegionsAndVmIdThenDummyValueIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
|
||||
ASSERT_NE(nullptr, xeIoctlHelper);
|
||||
|
||||
std::vector<MemoryRegion> regionInfo(2);
|
||||
@@ -95,8 +98,11 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallingGemCreateExtWithRegionsAndV
|
||||
|
||||
uint32_t handle = 0u;
|
||||
uint32_t numOfChunks = 0;
|
||||
|
||||
GemVmControl test = {};
|
||||
EXPECT_TRUE(xeIoctlHelper->bindInfo.empty());
|
||||
EXPECT_NE(0, xeIoctlHelper->createGemExt(memRegions, 0u, handle, 0, test.vmId, -1, false, numOfChunks));
|
||||
EXPECT_FALSE(xeIoctlHelper->bindInfo.empty());
|
||||
}
|
||||
|
||||
inline constexpr int testValueVmId = 0x5764;
|
||||
@@ -329,7 +335,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateAndNoLocalMemoryThenP
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
|
||||
drm.memoryInfo.reset(xeIoctlHelper->createMemoryInfo().release());
|
||||
ASSERT_NE(nullptr, xeIoctlHelper);
|
||||
|
||||
@@ -337,8 +343,10 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateAndNoLocalMemoryThenP
|
||||
uint32_t memoryBanks = 3u;
|
||||
|
||||
EXPECT_EQ(0, drm.ioctlCnt.gemCreate);
|
||||
EXPECT_TRUE(xeIoctlHelper->bindInfo.empty());
|
||||
uint32_t handle = xeIoctlHelper->createGem(size, memoryBanks);
|
||||
EXPECT_EQ(1, drm.ioctlCnt.gemCreate);
|
||||
EXPECT_FALSE(xeIoctlHelper->bindInfo.empty());
|
||||
|
||||
EXPECT_EQ(size, drm.createParamsSize);
|
||||
EXPECT_EQ(1u, drm.createParamsFlags);
|
||||
@@ -354,7 +362,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateWhenMemoryBanksZeroTh
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
|
||||
drm.memoryInfo.reset(xeIoctlHelper->createMemoryInfo().release());
|
||||
ASSERT_NE(nullptr, xeIoctlHelper);
|
||||
|
||||
@@ -362,8 +370,10 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateWhenMemoryBanksZeroTh
|
||||
uint32_t memoryBanks = 0u;
|
||||
|
||||
EXPECT_EQ(0, drm.ioctlCnt.gemCreate);
|
||||
EXPECT_TRUE(xeIoctlHelper->bindInfo.empty());
|
||||
uint32_t handle = xeIoctlHelper->createGem(size, memoryBanks);
|
||||
EXPECT_EQ(1, drm.ioctlCnt.gemCreate);
|
||||
EXPECT_FALSE(xeIoctlHelper->bindInfo.empty());
|
||||
|
||||
EXPECT_EQ(size, drm.createParamsSize);
|
||||
EXPECT_EQ(1u, drm.createParamsFlags);
|
||||
@@ -379,7 +389,7 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateAndLocalMemoryThenPro
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmMockXe drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
auto xeIoctlHelper = std::make_unique<IoctlHelperXe>(drm);
|
||||
auto xeIoctlHelper = std::make_unique<MockIoctlHelperXe>(drm);
|
||||
drm.memoryInfo.reset(xeIoctlHelper->createMemoryInfo().release());
|
||||
ASSERT_NE(nullptr, xeIoctlHelper);
|
||||
|
||||
@@ -387,8 +397,10 @@ TEST(IoctlHelperXeTest, givenIoctlHelperXeWhenCallGemCreateAndLocalMemoryThenPro
|
||||
uint32_t memoryBanks = 3u;
|
||||
|
||||
EXPECT_EQ(0, drm.ioctlCnt.gemCreate);
|
||||
EXPECT_TRUE(xeIoctlHelper->bindInfo.empty());
|
||||
uint32_t handle = xeIoctlHelper->createGem(size, memoryBanks);
|
||||
EXPECT_EQ(1, drm.ioctlCnt.gemCreate);
|
||||
EXPECT_FALSE(xeIoctlHelper->bindInfo.empty());
|
||||
|
||||
EXPECT_EQ(size, drm.createParamsSize);
|
||||
EXPECT_EQ(6u, drm.createParamsFlags);
|
||||
|
||||
Reference in New Issue
Block a user