radeonsi/video: Avoid stream handle duplicates in PID namespace
Add current time when generating the stream handle initial value. When running inside PID namespace there can be multiple processes in the system that will share the same PID and with current code this could result in the same stream handle being used at the same time from different processes. This can easily happen with Flatpak when running two instances of the same application - both processes will have the same PID and we will use the same stream handles. For older UVDs kernel will reject the CS if we use duplicated handles. Cc: mesa-stable Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12575 Reviewed-by: Ruijing Dong <ruijing.dong@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33374>
This commit is contained in:
@@ -21,15 +21,12 @@
|
||||
unsigned si_vid_alloc_stream_handle()
|
||||
{
|
||||
static unsigned counter = 0;
|
||||
unsigned stream_handle = 0;
|
||||
unsigned pid = getpid();
|
||||
int i;
|
||||
static unsigned handle_base = 0;
|
||||
|
||||
for (i = 0; i < 32; ++i)
|
||||
stream_handle |= ((pid >> i) & 1) << (31 - i);
|
||||
if (!handle_base)
|
||||
handle_base = util_bitreverse(getpid() ^ os_time_get());
|
||||
|
||||
stream_handle ^= ++counter;
|
||||
return stream_handle;
|
||||
return handle_base ^ ++counter;
|
||||
}
|
||||
|
||||
/* create a buffer in the winsys */
|
||||
|
||||
Reference in New Issue
Block a user