Skip to content

Commit 60ed551

Browse files
zhenggb72hzhou
authored andcommitted
mpl/ze: Fix bug in IPC handle creation
Drmfd (shareable IPC handle implementation) uses gem_hash to cache the GEM object handles. The gem_hash cache does not check mem_id, which may result in a false cache hit on the sender side.
1 parent f758a0d commit 60ed551

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/mpl/src/gpu/mpl_gpu_ze.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ static physical_device_state *physical_device_states = NULL;
115115

116116
typedef struct {
117117
const void *ptr;
118+
uint64_t mem_id;
118119
int dev_id;
119120
int handles[2];
120121
uint32_t nhandles;
@@ -2990,6 +2991,12 @@ int MPL_ze_ipc_handle_create(const void *ptr, MPL_gpu_device_attr * ptr_attr, in
29902991
MPL_ze_gem_hash_entry_t *entry = NULL;
29912992
HASH_FIND_PTR(gem_hash, &ptr, entry);
29922993

2994+
/* invalid entry */
2995+
if (entry && entry->mem_id != mem_id) {
2996+
MPL_ze_ipc_remove_cache_handle(ptr);
2997+
entry = NULL;
2998+
}
2999+
29933000
if (entry == NULL) {
29943001
int shared_dev_id = get_physical_device(local_dev_id);
29953002
for (int i = 0; i < nfds; i++) {
@@ -3010,6 +3017,7 @@ int MPL_ze_ipc_handle_create(const void *ptr, MPL_gpu_device_attr * ptr_attr, in
30103017
}
30113018

30123019
entry->ptr = ptr;
3020+
entry->mem_id = mem_id;
30133021
entry->dev_id = shared_dev_id;
30143022
for (int i = 0; i < nfds; i++)
30153023
entry->handles[i] = handles[i];

0 commit comments

Comments
 (0)