Skip to content

Commit 2c896b6

Browse files
committed
DrmGemCloseWorker now works on BufferObject instead of DrmAllocation.
Change-Id: I490edfc7532081eb31f700be70781c276dbc2916
1 parent bab9ad6 commit 2c896b6

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

runtime/os_interface/linux/drm_gem_close_worker.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Intel Corporation
2+
* Copyright (c) 2017 - 2018, Intel Corporation
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a
55
* copy of this software and associated documentation files (the "Software"),
@@ -54,7 +54,7 @@ DrmGemCloseWorker::~DrmGemCloseWorker() {
5454
closeThread();
5555
}
5656

57-
void DrmGemCloseWorker::push(DrmAllocation *bo) {
57+
void DrmGemCloseWorker::push(BufferObject *bo) {
5858
std::unique_lock<std::mutex> lock(closeWorkerMutex);
5959
workCount++;
6060
queue.push(bo);
@@ -74,19 +74,15 @@ bool DrmGemCloseWorker::isEmpty() {
7474
return workCount.load() == 0;
7575
}
7676

77-
inline void DrmGemCloseWorker::close(DrmAllocation *alloc) {
78-
auto bo = alloc->getBO();
79-
77+
inline void DrmGemCloseWorker::close(BufferObject *bo) {
8078
bo->wait(-1);
8179
memoryManager.unreference(bo);
8280
workCount--;
83-
84-
delete alloc;
8581
}
8682

8783
void DrmGemCloseWorker::worker() {
88-
DrmAllocation *workItem = nullptr;
89-
std::queue<DrmAllocation *> localQueue;
84+
BufferObject *workItem = nullptr;
85+
std::queue<BufferObject *> localQueue;
9086
std::unique_lock<std::mutex> lock(closeWorkerMutex);
9187
lock.unlock();
9288

runtime/os_interface/linux/drm_gem_close_worker.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
namespace OCLRT {
3434
class DrmMemoryManager;
35-
class DrmAllocation;
35+
class BufferObject;
3636

3737
enum gemCloseWorkerMode {
3838
gemCloseWorkerInactive,
@@ -47,20 +47,20 @@ class DrmGemCloseWorker {
4747
DrmGemCloseWorker(const DrmGemCloseWorker &) = delete;
4848
DrmGemCloseWorker &operator=(const DrmGemCloseWorker &) = delete;
4949

50-
void push(DrmAllocation *allocation);
50+
void push(BufferObject *allocation);
5151
void close(bool blocking);
5252

5353
bool isEmpty();
5454

5555
protected:
56-
void close(DrmAllocation *workItem);
56+
void close(BufferObject *workItem);
5757
void closeThread();
5858
void worker();
5959
bool active;
6060

6161
std::thread *thread;
6262

63-
std::queue<DrmAllocation *> queue;
63+
std::queue<BufferObject *> queue;
6464
std::atomic<uint32_t> workCount;
6565

6666
DrmMemoryManager &memoryManager;

unit_tests/os_interface/linux/drm_gem_close_worker_tests.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ TEST_F(DrmGemCloseWorkerTests, gemClose) {
112112

113113
auto worker = new DrmGemCloseWorker(*mm);
114114
auto bo = new BufferObjectWrapper(this->drmMock, 1);
115-
auto alloc = new DrmAllocationWrapper(bo);
116115

117-
worker->push(alloc);
116+
worker->push(bo);
118117

119118
delete worker;
120119
}
@@ -124,9 +123,8 @@ TEST_F(DrmGemCloseWorkerTests, gemCloseExit) {
124123

125124
auto worker = new DrmGemCloseWorker(*mm);
126125
auto bo = new BufferObjectWrapper(this->drmMock, 1);
127-
auto alloc = new DrmAllocationWrapper(bo);
128126

129-
worker->push(alloc);
127+
worker->push(bo);
130128

131129
//wait for worker to complete or deadCnt drops
132130
while (!worker->isEmpty() && (deadCnt-- > 0))
@@ -145,9 +143,8 @@ TEST_F(DrmGemCloseWorkerTests, close) {
145143

146144
auto worker = new DrmGemCloseWorker(*mm);
147145
auto bo = new BufferObjectWrapper(this->drmMock, 1);
148-
auto alloc = new DrmAllocationWrapper(bo);
149146

150-
worker->push(alloc);
147+
worker->push(bo);
151148
worker->close(false);
152149

153150
//wait for worker to complete or deadCnt drops
@@ -164,10 +161,9 @@ TEST_F(DrmGemCloseWorkerTests, givenAllocationWhenAskedForUnreferenceWithForceFl
164161

165162
auto worker = new DrmGemCloseWorker(*mm);
166163
auto bo = new BufferObjectWrapper(this->drmMock, 1);
167-
auto alloc = new DrmAllocationWrapper(bo);
168164

169165
bo->reference();
170-
worker->push(alloc);
166+
worker->push(bo);
171167

172168
auto r = mm->unreference(bo, true);
173169
EXPECT_EQ(1u, r);

0 commit comments

Comments
 (0)