nvk/winsys: store device ptr into bo instead of ptr
authorDave Airlie <airlied@redhat.com>
Mon, 31 Oct 2022 00:28:18 +0000 (10:28 +1000)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:32:03 +0000 (21:32 +0000)
This will be needed later.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>

src/nouveau/winsys/nouveau_bo.c
src/nouveau/winsys/nouveau_bo.h

index 1ee2bfe..3684a5d 100644 (file)
@@ -77,7 +77,7 @@ nouveau_ws_bo_new_tiled(struct nouveau_ws_device *dev,
    bo->offset = req.info.offset;
    bo->handle = req.info.handle;
    bo->map_handle = req.info.map_handle;
-   bo->fd = dev->fd;
+   bo->dev = dev;
    bo->flags = flags;
    bo->refcnt = 1;
 
@@ -90,7 +90,7 @@ nouveau_ws_bo_destroy(struct nouveau_ws_bo *bo)
    if (--bo->refcnt)
       return;
 
-   drmCloseBufferHandle(bo->fd, bo->handle);
+   drmCloseBufferHandle(bo->dev->fd, bo->handle);
    FREE(bo);
 }
 
@@ -104,7 +104,7 @@ nouveau_ws_bo_map(struct nouveau_ws_bo *bo, enum nouveau_ws_bo_map_flags flags)
    if (flags & NOUVEAU_WS_BO_WR)
       prot |= PROT_WRITE;
 
-   void *res = mmap64(NULL, bo->size, prot, MAP_SHARED, bo->fd, bo->map_handle);
+   void *res = mmap64(NULL, bo->size, prot, MAP_SHARED, bo->dev->fd, bo->map_handle);
    if (res == MAP_FAILED)
       return NULL;
 
@@ -120,11 +120,11 @@ nouveau_ws_bo_wait(struct nouveau_ws_bo *bo, enum nouveau_ws_bo_map_flags flags)
    if (flags & NOUVEAU_WS_BO_WR)
       req.flags |= NOUVEAU_GEM_CPU_PREP_WRITE;
 
-   return !drmCommandWrite(bo->fd, DRM_NOUVEAU_GEM_CPU_PREP, &req, sizeof(req));
+   return !drmCommandWrite(bo->dev->fd, DRM_NOUVEAU_GEM_CPU_PREP, &req, sizeof(req));
 }
 
 int
 nouveau_ws_bo_dma_buf(struct nouveau_ws_bo *bo, int *fd)
 {
-   return drmPrimeHandleToFD(bo->fd, bo->handle, DRM_CLOEXEC, fd);
+   return drmPrimeHandleToFD(bo->dev->fd, bo->handle, DRM_CLOEXEC, fd);
 }
index 53670ce..bb355f3 100644 (file)
@@ -35,7 +35,7 @@ struct nouveau_ws_bo {
    uint64_t size;
    uint64_t offset;
    uint64_t map_handle;
-   int fd;
+   struct nouveau_ws_device *dev;
    uint32_t handle;
    enum nouveau_ws_bo_flags flags;
    atomic_uint_fast32_t refcnt;