panfrost: Fix leak of render node fd

Transfer ownership of the render node fd to the panfrost_device (minor
change to panvk), and then close the file descriptor for the render node
bound to the panfrost_device when destroying the panfrost_device. Of all
the users of panfrost_open_device, panvk is the only one that correctly
closed the fd before. Accordingly, this fixes an fd leak in the Gallium
driver (and performance counter utilities).

This fix still applies to the Gallium driver when renderonly is in use--
although renderonly closes its own fd, the fd is _duplicated_ in
panfrost_drm_winsys.c, so renderonly and panfrost must _both_ close
their respective fd to fix the leak.

This fixes a crash when running dEQP-EGL for more than two hours.
dEQP-EGL creates a new screen for every test case and then immediately
destroys it. If destroying a screen leaks the fd, this causes the number
of open file descriptors to increase monotonically until the process
ends. This will eventually hit the system limit for number of open files
and abort the process.

This bug was identified while attempting to run the OpenGL ES
conformance tests via cts-runner, and then confirmed with `lsof`. With
the fix, the number of file descriptors reported by `lsof | wc -l` is
now constant while running dEQP-EGL as expected.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Cc: mesa-stable
171 jobs for fix-fd-leak
Status Name Job ID Coverage
  Container
manual debian/arm_build #12727338
aarch64 manual
manual debian/x86_build-base #12727336
manual
manual debian/x86_test-base #12727337
manual
manual fedora/x86_build #12727339
manual
manual windows_build_vs2019 #12727340
windows shell 1809 mesa manual
 
  Container 2
created debian/android_build #12727345
created debian/i386_build #12727342
created debian/ppc64el_build #12727343
created debian/s390x_build #12727344
created debian/x86_build #12727341
created debian/x86_test-gl #12727346
created debian/x86_test-vk #12727347
created kernel+rootfs_amd64 #12727348
created kernel+rootfs_arm64 #12727349
aarch64
created kernel+rootfs_armhf #12727350
aarch64
 
  Build X86 64
created debian-clang #12727357
created debian-clover #12727358
created debian-clover-testing #12727353
created debian-gallium #12727354
created debian-release #12727355
created debian-testing #12727351
created debian-testing-asan #12727352
created debian-vulkan #12727359
created fedora-release #12727356
 
  Build Misc
created debian-android #12727361
created debian-arm64 #12727363
aarch64
created debian-arm64-asan #12727364
aarch64
created debian-arm64-build-test #12727365
aarch64
created debian-armhf #12727362
aarch64
created debian/arm_test #12727360
created debian-i386 #12727367
created debian-mingw32-x86_64 #12727370
created debian-ppc64el #12727369
created debian-s390x #12727368
kvm
created windows-vs2019 #12727366
windows docker 1809 mesa
 
  Amd
created radeonsi-stoney-gles2:amd64 #12727379
mesa-ci-x86-64-lava-hp-11A-G6-EE-grunt
created radeonsi-stoney-gles31:amd64 1/2 #12727382
mesa-ci-x86-64-lava-hp-11A-G6-EE-grunt
created radeonsi-stoney-gles31:amd64 2/2 #12727383
mesa-ci-x86-64-lava-hp-11A-G6-EE-grunt
created radeonsi-stoney-gles3:amd64 1/2 #12727380
mesa-ci-x86-64-lava-hp-11A-G6-EE-grunt
created radeonsi-stoney-gles3:amd64 2/2 #12727381
mesa-ci-x86-64-lava-hp-11A-G6-EE-grunt
created radeonsi-stoney-piglit-gl:amd64 #12727385
mesa-ci-x86-64-lava-hp-11A-G6-EE-grunt
created radeonsi-stoney-traces:amd64 #12727384
mesa-ci-x86-64-lava-hp-11A-G6-EE-grunt
created radv-fossils #12727378
created radv-navy_flounder-traces #12727372
amdgpu:codename:NAVY_FLOUNDER manual
created radv-navy_flounder-vkd3d-proton #12727371
amdgpu:codename:NAVY_FLOUNDER manual
created radv_polaris10_vkcts #12727374
polaris10 manual
created radv-raven-traces #12727373
amdgpu:codename:RAVEN manual
created radv_stoney_vkcts:amd64 1/3 #12727375
mesa-ci-x86-64-lava-hp-11A-G6-EE-grunt
created radv_stoney_vkcts:amd64 2/3 #12727376
mesa-ci-x86-64-lava-hp-11A-G6-EE-grunt
created radv_stoney_vkcts:amd64 3/3 #12727377
mesa-ci-x86-64-lava-hp-11A-G6-EE-grunt
 
  Intel
created i915-g33-deqp #12727386
anholt-g33 manual
created i915-g33-piglit #12727387
anholt-g33 manual
created i915-g33-traces #12727388
anholt-g33 manual
created iris-apl-egl #12727393
mesa-ci-x86-64-lava-asus-C523NA-A20057-coral
created iris-apl-gl #12727392
mesa-ci-x86-64-lava-asus-C523NA-A20057-coral manual
created iris-apl-gles2 #12727389
mesa-ci-x86-64-lava-asus-C523NA-A20057-coral
created iris-apl-gles3 #12727390
mesa-ci-x86-64-lava-asus-C523NA-A20057-coral
created iris-apl-gles31 #12727391
mesa-ci-x86-64-lava-asus-C523NA-A20057-coral
created iris-apl-traces #12727399
mesa-ci-x86-64-lava-asus-C523NA-A20057-coral
created iris-glk-egl #12727398
mesa-ci-x86-64-lava-hp-x360-12b-n4000-octopus manual
created iris-glk-gl #12727397
mesa-ci-x86-64-lava-hp-x360-12b-n4000-octopus manual
created iris-glk-gles2 #12727394
mesa-ci-x86-64-lava-hp-x360-12b-n4000-octopus manual
created iris-glk-gles3 #12727395
mesa-ci-x86-64-lava-hp-x360-12b-n4000-octopus manual
created iris-glk-gles31 #12727396
mesa-ci-x86-64-lava-hp-x360-12b-n4000-octopus manual
created iris-glk-traces #12727400
mesa-ci-x86-64-lava-hp-x360-12b-n4000-octopus manual
created iris-kbl-traces #12727401
mesa-ci-x86-64-lava-hp-x360-14-G1-sona manual
 
  Arm
created panfrost-g52-gles31:arm64 #12727411
mesa-ci-x86-64-lava-meson-g12b-a311d-khadas-vim3
created panfrost-g52-gles3:arm64 1/2 #12727409
mesa-ci-x86-64-lava-meson-g12b-a311d-khadas-vim3
created panfrost-g52-gles3:arm64 2/2 #12727410
mesa-ci-x86-64-lava-meson-g12b-a311d-khadas-vim3
created panfrost-t720-gles2:arm64 #12727402
mesa-ci-x86-64-lava-sun50i-h6-pine-h64
created panfrost-t760-gles2:armhf #12727403
mesa-ci-x86-64-lava-rk3288-veyron-jaq
created panfrost-t760-traces:armhf #12727404
mesa-ci-x86-64-lava-rk3288-veyron-jaq
created panfrost-t860-gles31:arm64 #12727407
mesa-ci-x86-64-lava-rk3399-gru-kevin
created panfrost-t860-gles3:arm64 1/2 #12727405
mesa-ci-x86-64-lava-rk3399-gru-kevin
created panfrost-t860-gles3:arm64 2/2 #12727406
mesa-ci-x86-64-lava-rk3399-gru-kevin
created panfrost-t860-traces:arm64 #12727408
mesa-ci-x86-64-lava-rk3399-gru-kevin
 
  Broadcom
created v3d-rpi4-egl:armhf #12727434
igalia-rpi4
created v3d-rpi4-gles2:armhf #12727430
igalia-rpi4
created v3d-rpi4-gles31:armhf 1/2 #12727424
igalia-rpi4
created v3d-rpi4-gles31:armhf 2/2 #12727425
igalia-rpi4
created v3d-rpi4-gles3:armhf 1/4 #12727426
igalia-rpi4
created v3d-rpi4-gles3:armhf 2/4 #12727427
igalia-rpi4
created v3d-rpi4-gles3:armhf 3/4 #12727428
igalia-rpi4
created v3d-rpi4-gles3:armhf 4/4 #12727429
igalia-rpi4
created v3d-rpi4-khr-gles2:armhf #12727433
igalia-rpi4
created v3d-rpi4-khr-gles31:armhf #12727431
igalia-rpi4
created v3d-rpi4-khr-gles3:armhf #12727432
igalia-rpi4
created v3d-rpi4-piglit:armhf 1/3 #12727435
igalia-rpi4
created v3d-rpi4-piglit:armhf 2/3 #12727436
igalia-rpi4
created v3d-rpi4-piglit:armhf 3/3 #12727437
igalia-rpi4
created v3dv-rpi4-vk:arm64 1/6 #12727438
igalia-rpi4
created v3dv-rpi4-vk:arm64 2/6 #12727439
igalia-rpi4
created v3dv-rpi4-vk:arm64 3/6 #12727440
igalia-rpi4
created v3dv-rpi4-vk:arm64 4/6 #12727441
igalia-rpi4
created v3dv-rpi4-vk:arm64 5/6 #12727442
igalia-rpi4
created v3dv-rpi4-vk:arm64 6/6 #12727443
igalia-rpi4
created vc4-rpi3-egl:armhf #12727417
igalia-rpi3
created vc4-rpi3-gles2:armhf 1/4 #12727412
igalia-rpi3
created vc4-rpi3-gles2:armhf 2/4 #12727413
igalia-rpi3
created vc4-rpi3-gles2:armhf 3/4 #12727414
igalia-rpi3
created vc4-rpi3-gles2:armhf 4/4 #12727415
igalia-rpi3
created vc4-rpi3-khr-gles2:armhf #12727416
igalia-rpi3
created vc4-rpi3-piglit-quick_gl:armhf 1/4 #12727418
igalia-rpi3 manual
created vc4-rpi3-piglit-quick_gl:armhf 2/4 #12727419
igalia-rpi3 manual
created vc4-rpi3-piglit-quick_gl:armhf 3/4 #12727420
igalia-rpi3 manual
created vc4-rpi3-piglit-quick_gl:armhf 4/4 #12727421
igalia-rpi3 manual
created vc4-rpi3-piglit-quick_shader:armhf 1/2 #12727422
igalia-rpi3 manual
created vc4-rpi3-piglit-quick_shader:armhf 2/2 #12727423
igalia-rpi3 manual
 
  Freedreno
created a306_gles2 #12727444
google-freedreno-db410c
created a306_gles3 1/3 #12727445
google-freedreno-db410c
created a306_gles3 2/3 #12727446
google-freedreno-db410c
created a306_gles3 3/3 #12727447
google-freedreno-db410c
created a306_gles3_options #12727448
google-freedreno-db410c
created a306-traces #12727449
google-freedreno-db410c
created a530_gles2 #12727450
google-freedreno-db820c
created a530_gles31 1/2 #12727453
google-freedreno-db820c
created a530_gles3 1/2 #12727451
google-freedreno-db820c
created a530_gles31 2/2 #12727454
google-freedreno-db820c
created a530_gles3 2/2 #12727452
google-freedreno-db820c
created a530_piglit_gl #12727455
google-freedreno-db820c manual
created a530_piglit_shader 1/2 #12727456
google-freedreno-db820c
created a530_piglit_shader 2/2 #12727457
google-freedreno-db820c
created a530-traces #12727458
google-freedreno-db820c
created a630_egl #12727463
google-freedreno-cheza
created a630_gl #12727462
google-freedreno-cheza
created a630_gles2 #12727459
google-freedreno-cheza
created a630_gles3 #12727461
google-freedreno-cheza
created a630_gles31 #12727460
google-freedreno-cheza
created a630_gles_asan #12727465
google-freedreno-cheza manual
created a630_gles_others #12727464
google-freedreno-cheza
created a630_piglit #12727472
google-freedreno-cheza
created a630-traces #12727473
google-freedreno-cheza
created a630_vk 1/2 #12727466
google-freedreno-cheza
created a630_vk 2/2 #12727467
google-freedreno-cheza
created a630_vk_asan #12727470
google-freedreno-cheza manual
created a630_vk_full 1/2 #12727468
google-freedreno-cheza manual
created a630_vk_full 2/2 #12727469
google-freedreno-cheza manual
created a630_vk_sysmem #12727471
google-freedreno-cheza
 
  Software Renderer
created lavapipe-nir-stress #12727487
created lavapipe-vk #12727486
created llvmpipe-deqp 1/2 #12727479
created llvmpipe-deqp 2/2 #12727480
created llvmpipe-egl #12727481
created llvmpipe-piglit-cl #12727474
created llvmpipe-piglit-glslparser #12727476
created llvmpipe-piglit-quick_gl #12727475
created llvmpipe-piglit-quick_shader #12727477
created llvmpipe-traces #12727478
created softpipe-asan-gles31 #12727484
created softpipe-deqp 1/2 #12727482
created softpipe-deqp 2/2 #12727483
created softpipe-piglit-quick #12727485
 
  Layered Backends
created test-d3d12-windows #12727505
windows docker 1809 mesa
created virgl-on-gl 1/6 #12727488
kvm
created virgl-on-gl 2/6 #12727489
kvm
created virgl-on-gl 3/6 #12727490
kvm
created virgl-on-gl 4/6 #12727491
kvm
created virgl-on-gl 5/6 #12727492
kvm
created virgl-on-gl 6/6 #12727493
kvm
created virgl-on-gles 1/6 #12727494
kvm manual
created virgl-on-gles 2/6 #12727495
kvm manual
created virgl-on-gles 3/6 #12727496
kvm manual
created virgl-on-gles 4/6 #12727497
kvm manual
created virgl-on-gles 5/6 #12727498
kvm manual
created virgl-on-gles 6/6 #12727499
kvm manual
created virgl-traces #12727500
kvm
created zink-lvp-deqp 1/2 #12727503
created zink-lvp-deqp 2/2 #12727504
created zink-piglit-no_timelines #12727502
created zink-piglit-timelines #12727501
 
  Deploy
manual test-docs #12727506
manual