[Mesa-dev] [PATCH 00/11] Common pipe screen ref counting

Rob Herring robh at kernel.org
Thu Jun 23 23:57:59 UTC 2016


I needed to add screen ref counting to vc4 driver, so rather than yet
another copy of the same fd hashing and ref counting code, I implemented
it in the pipe-loader. AFAICT, the pipe-loader is the only place the
winsys create screen functions are called and seemed to be the best
location to put this. The tricky part is the destroy path and not
freeing the screen before reference counting. I think I found all the
callers of pipe_screen->destroy.

This version differs from the RFC in that the fd hashing and ref 
counting are opt-in as library functions and winsys implementations can 
do something different as amdgpu does. This makes the ref counting a bit 
more complicated to understand in that it happens in different places.

I'm testing on virgl, freedreno, and vc4. Testing on the other platforms 
would be great.

Rob

Rob Herring (11):
  gallium: move pipe_screen destroy into pipe-loader
  gallium: add common pipe_screen reference counting functions
  pipe-loader-drm: protect create_screen() and destroy() calls with
    mutex
  pipe-loader-drm: use pipe_screen_unreference to destroy screen
  nouveau: use common screen ref counting
  freedreno: use common screen ref counting
  amdgpu: use common screen ref counting
  radeon: use common screen ref counting
  vmwgfx: use common screen ref counting
  vc4: use common screen ref counting
  virgl: use common screen ref counting

 src/gallium/auxiliary/Makefile.sources             |   2 +
 src/gallium/auxiliary/pipe-loader/pipe_loader.h    |   1 +
 .../auxiliary/pipe-loader/pipe_loader_drm.c        |  30 ++++--
 src/gallium/auxiliary/pipe-loader/pipe_loader_sw.c |   6 ++
 src/gallium/auxiliary/util/u_screen.c              | 104 +++++++++++++++++++++
 src/gallium/auxiliary/util/u_screen.h              |  32 +++++++
 src/gallium/auxiliary/vl/vl_winsys_dri.c           |   1 -
 src/gallium/auxiliary/vl/vl_winsys_dri3.c          |   1 -
 src/gallium/auxiliary/vl/vl_winsys_drm.c           |   1 -
 src/gallium/drivers/freedreno/freedreno_screen.c   |   1 -
 src/gallium/drivers/freedreno/freedreno_screen.h   |  10 --
 src/gallium/drivers/nouveau/nouveau_screen.c       |   6 --
 src/gallium/drivers/nouveau/nouveau_screen.h       |   4 -
 src/gallium/drivers/nouveau/nv30/nv30_screen.c     |   3 -
 src/gallium/drivers/nouveau/nv50/nv50_screen.c     |   3 -
 src/gallium/drivers/nouveau/nvc0/nvc0_screen.c     |   3 -
 src/gallium/drivers/r300/r300_screen.c             |   3 -
 src/gallium/drivers/r600/r600_pipe.c               |   6 --
 src/gallium/drivers/radeon/radeon_winsys.h         |   8 --
 src/gallium/drivers/radeonsi/si_pipe.c             |   6 --
 src/gallium/include/pipe/p_screen.h                |   2 +
 src/gallium/state_trackers/clover/core/device.cpp  |   4 +-
 src/gallium/state_trackers/dri/dri_screen.c        |   3 -
 src/gallium/state_trackers/xa/xa_tracker.c         |   2 -
 src/gallium/tests/trivial/compute.c                |   1 -
 src/gallium/tests/trivial/quad-tex.c               |   1 -
 src/gallium/tests/trivial/tri.c                    |   1 -
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c      |  45 ++-------
 src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h      |   1 -
 .../winsys/freedreno/drm/freedreno_drm_winsys.c    |  94 ++-----------------
 .../winsys/nouveau/drm/nouveau_drm_winsys.c        |  89 ++----------------
 src/gallium/winsys/radeon/drm/radeon_drm_winsys.c  |  84 ++---------------
 src/gallium/winsys/svga/drm/vmw_screen.c           |  51 ++--------
 src/gallium/winsys/svga/drm/vmw_screen.h           |   6 --
 src/gallium/winsys/vc4/drm/vc4_drm_winsys.c        |   9 +-
 src/gallium/winsys/virgl/drm/virgl_drm_winsys.c    |  86 ++---------------
 36 files changed, 219 insertions(+), 491 deletions(-)
 create mode 100644 src/gallium/auxiliary/util/u_screen.c
 create mode 100644 src/gallium/auxiliary/util/u_screen.h

-- 
2.9.0



More information about the mesa-dev mailing list