mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2024-11-23 18:24:13 +08:00
winsys/radeon: wrap fd access with util function
no functional changes Acked-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30224>
This commit is contained in:
parent
ec2451fcb3
commit
216ff9591b
@ -1090,7 +1090,7 @@ static struct pb_buffer_lean *radeon_winsys_bo_from_ptr(struct radeon_winsys *rw
|
||||
RADEON_GEM_USERPTR_REGISTER |
|
||||
RADEON_GEM_USERPTR_VALIDATE;
|
||||
|
||||
if (drmCommandWriteRead(ws->fd, DRM_RADEON_GEM_USERPTR,
|
||||
if (drmCommandWriteRead(radeon_drm_winsys_fd(ws), DRM_RADEON_GEM_USERPTR,
|
||||
&args, sizeof(args))) {
|
||||
FREE(bo);
|
||||
return NULL;
|
||||
@ -1129,7 +1129,7 @@ static struct pb_buffer_lean *radeon_winsys_bo_from_ptr(struct radeon_winsys *rw
|
||||
RADEON_VM_PAGE_WRITEABLE |
|
||||
RADEON_VM_PAGE_SNOOPED;
|
||||
va.offset = bo->va;
|
||||
r = drmCommandWriteRead(ws->fd, DRM_RADEON_GEM_VA, &va, sizeof(va));
|
||||
r = drmCommandWriteRead(radeon_drm_winsys_fd(ws), DRM_RADEON_GEM_VA, &va, sizeof(va));
|
||||
if (r && va.operation == RADEON_VA_RESULT_ERROR) {
|
||||
fprintf(stderr, "radeon: Failed to assign virtual address space\n");
|
||||
radeon_bo_destroy(NULL, &bo->base);
|
||||
@ -1205,7 +1205,7 @@ static struct pb_buffer_lean *radeon_winsys_bo_from_handle(struct radeon_winsys
|
||||
memset(&open_arg, 0, sizeof(open_arg));
|
||||
/* Open the BO. */
|
||||
open_arg.name = whandle->handle;
|
||||
if (drmIoctl(ws->fd, DRM_IOCTL_GEM_OPEN, &open_arg)) {
|
||||
if (drmIoctl(radeon_drm_winsys_fd(ws), DRM_IOCTL_GEM_OPEN, &open_arg)) {
|
||||
FREE(bo);
|
||||
goto fail;
|
||||
}
|
||||
@ -1259,7 +1259,7 @@ done:
|
||||
RADEON_VM_PAGE_WRITEABLE |
|
||||
RADEON_VM_PAGE_SNOOPED;
|
||||
va.offset = bo->va;
|
||||
r = drmCommandWriteRead(ws->fd, DRM_RADEON_GEM_VA, &va, sizeof(va));
|
||||
r = drmCommandWriteRead(radeon_drm_winsys_fd(ws), DRM_RADEON_GEM_VA, &va, sizeof(va));
|
||||
if (r && va.operation == RADEON_VA_RESULT_ERROR) {
|
||||
fprintf(stderr, "radeon: Failed to assign virtual address space\n");
|
||||
radeon_bo_destroy(NULL, &bo->base);
|
||||
@ -1314,7 +1314,7 @@ static bool radeon_winsys_bo_get_handle(struct radeon_winsys *rws,
|
||||
if (!bo->flink_name) {
|
||||
flink.handle = bo->handle;
|
||||
|
||||
if (ioctl(ws->fd, DRM_IOCTL_GEM_FLINK, &flink)) {
|
||||
if (ioctl(radeon_drm_winsys_fd(ws), DRM_IOCTL_GEM_FLINK, &flink)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1328,7 +1328,7 @@ static bool radeon_winsys_bo_get_handle(struct radeon_winsys *rws,
|
||||
} else if (whandle->type == WINSYS_HANDLE_TYPE_KMS) {
|
||||
whandle->handle = bo->handle;
|
||||
} else if (whandle->type == WINSYS_HANDLE_TYPE_FD) {
|
||||
if (drmPrimeHandleToFD(ws->fd, bo->handle, DRM_CLOEXEC, (int*)&whandle->handle))
|
||||
if (drmPrimeHandleToFD(radeon_drm_winsys_fd(ws), bo->handle, DRM_CLOEXEC, (int*)&whandle->handle))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ static bool radeon_set_fd_access(struct radeon_drm_cs *applier,
|
||||
/* Pass through the request to the kernel. */
|
||||
info.value = (unsigned long)&value;
|
||||
info.request = request;
|
||||
if (drmCommandWriteRead(applier->ws->fd, DRM_RADEON_INFO,
|
||||
if (drmCommandWriteRead(radeon_drm_winsys_fd(applier->ws), DRM_RADEON_INFO,
|
||||
&info, sizeof(info)) != 0) {
|
||||
mtx_unlock(&*mutex);
|
||||
return false;
|
||||
@ -94,7 +94,7 @@ static bool radeon_get_drm_value(struct radeon_drm_winsys *ws, unsigned request,
|
||||
info.value = (unsigned long)out;
|
||||
info.request = request;
|
||||
|
||||
retval = drmCommandWriteRead(ws->fd, DRM_RADEON_INFO, &info, sizeof(info));
|
||||
retval = drmCommandWriteRead(radeon_drm_winsys_fd(ws), DRM_RADEON_INFO, &info, sizeof(info));
|
||||
if (retval) {
|
||||
if (errname) {
|
||||
fprintf(stderr, "radeon: Failed to get %s, error number %d\n",
|
||||
@ -328,12 +328,12 @@ static bool do_winsys_init(struct radeon_drm_winsys *ws)
|
||||
* aren't set.
|
||||
*/
|
||||
ws->info.has_userptr =
|
||||
drmCommandWriteRead(ws->fd, DRM_RADEON_GEM_USERPTR,
|
||||
drmCommandWriteRead(radeon_drm_winsys_fd(ws), DRM_RADEON_GEM_USERPTR,
|
||||
&args, sizeof(args)) == -EACCES;
|
||||
}
|
||||
|
||||
/* Get GEM info. */
|
||||
retval = drmCommandWriteRead(ws->fd, DRM_RADEON_GEM_INFO,
|
||||
retval = drmCommandWriteRead(radeon_drm_winsys_fd(ws), DRM_RADEON_GEM_INFO,
|
||||
&gem_info, sizeof(gem_info));
|
||||
if (retval) {
|
||||
fprintf(stderr, "radeon: Failed to get MM info, error number %d\n",
|
||||
@ -855,7 +855,7 @@ radeon_drm_winsys_get_fd(struct radeon_winsys *ws)
|
||||
{
|
||||
struct radeon_drm_winsys *rws = (struct radeon_drm_winsys*)ws;
|
||||
|
||||
return rws->fd;
|
||||
return radeon_drm_winsys_fd(rws);
|
||||
}
|
||||
|
||||
PUBLIC struct radeon_winsys *
|
||||
@ -915,7 +915,7 @@ radeon_drm_winsys_create(int fd, const struct pipe_screen_config *config,
|
||||
}
|
||||
|
||||
if (ws->gen >= DRV_R600) {
|
||||
ws->surf_man = radeon_surface_manager_new(ws->fd);
|
||||
ws->surf_man = radeon_surface_manager_new(radeon_drm_winsys_fd(ws));
|
||||
if (!ws->surf_man)
|
||||
goto fail_slab;
|
||||
}
|
||||
|
@ -90,6 +90,12 @@ static inline struct radeon_drm_winsys *radeon_drm_winsys(struct radeon_winsys *
|
||||
return (struct radeon_drm_winsys*)base;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static int
|
||||
radeon_drm_winsys_fd(const struct radeon_drm_winsys *ws)
|
||||
{
|
||||
return ws->fd;
|
||||
}
|
||||
|
||||
uint32_t radeon_drm_get_gpu_reset_counter(struct radeon_drm_winsys *ws);
|
||||
void radeon_surface_init_functions(struct radeon_drm_winsys *ws);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user