Skip to content

syncobj::fd_to_handle with import_sync_file = true is wrong #224

@YaLTeR

Description

@YaLTeR

DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE imports a fence fd into an existing syncobj handle which needs to be passed into handle. But the current function always passes handle: 0 on line 73 so it cannot work:

pub fn fd_to_handle(
fd: BorrowedFd<'_>,
syncobj_fd: BorrowedFd<'_>,
import_sync_file: bool,
) -> io::Result<drm_syncobj_handle> {
let mut args = drm_syncobj_handle {
handle: 0,
flags: if import_sync_file {
DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE
} else {
0
},
fd: syncobj_fd.as_raw_fd(),
pad: 0,
};
unsafe {
ioctl::syncobj::fd_to_handle(fd, &mut args)?;
}
Ok(args)
}

The API should have a separate function like:

pub fn syncobj_import_sync_file(
    fd: BorrowedFd<'_>,
    handle: u32,
    sync_file: BorrowedFd<'_>,
) -> io::Result<drm_syncobj_handle> {
    let mut args = drm_syncobj_handle {
        handle,
        flags: DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE,
        fd: sync_file.as_raw_fd(),
        pad: 0,
    };

    unsafe {
        ioctl::syncobj::fd_to_handle(fd, &mut args)?;
    }

    Ok(args)
}

(idk if the return value is any useful here)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions