From c02c5f37a3d9905dc845fb049f3e1db5dc7e9335 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Fri, 15 Sep 2023 12:51:39 +0200 Subject: [PATCH 25/64] fixup! panfrost: Abstract some kernel driver operations --- src/panfrost/lib/kmod/panfrost_kmod.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/panfrost/lib/kmod/panfrost_kmod.c b/src/panfrost/lib/kmod/panfrost_kmod.c index a653d513513..a1590ca5050 100644 --- a/src/panfrost/lib/kmod/panfrost_kmod.c +++ b/src/panfrost/lib/kmod/panfrost_kmod.c @@ -181,7 +181,10 @@ panfrost_kmod_bo_import(struct pan_kmod_dev *dev, int fd) if (ret) goto err_free_bo; - struct drm_panfrost_get_bo_offset get_bo_offset = {}; + struct drm_panfrost_get_bo_offset get_bo_offset = { + .handle = handle, + 0 + }; ret = drmIoctl(dev->fd, DRM_IOCTL_PANFROST_GET_BO_OFFSET, &get_bo_offset); if (ret) goto err_close_handle; @@ -222,10 +225,16 @@ panfrost_kmod_bo_export(struct pan_kmod_bo *bo) static off_t panfrost_kmod_bo_get_mmap_offset(struct pan_kmod_bo *bo) { - struct panfrost_kmod_bo *panfrost_bo = - container_of(bo, struct panfrost_kmod_bo, base); + struct drm_panfrost_mmap_bo mmap_bo = { + .handle = bo->handle + }; + int ret = drmIoctl(bo->dev->fd, DRM_IOCTL_PANFROST_MMAP_BO, &mmap_bo); + if (ret) { + fprintf(stderr, "DRM_IOCTL_PANFROST_MMAP_BO failed: %m\n"); + assert(0); + } - return panfrost_bo->offset; + return mmap_bo.offset; } static bool -- 2.42.0