2 * Copyright © 2009 Corbin Simpson <MostAwesomeDude@gmail.com>
3 * Copyright © 2009 Joakim Sindholt <opensource@zhasha.com>
4 * Copyright © 2011 Marek Olšák <maraeo@gmail.com>
5 * Copyright © 2015 Advanced Micro Devices, Inc.
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sub license, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
20 * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23 * USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * The above copyright notice and this permission notice (including the
26 * next paragraph) shall be included in all copies or substantial portions
31 * Marek Olšák <maraeo@gmail.com>
34 #include "amdgpu_cs.h"
35 #include "amdgpu_public.h"
37 #include "util/u_hash_table.h"
38 #include <amdgpu_drm.h>
42 #include "amd/common/amdgpu_id.h"
43 #include "amd/common/sid.h"
44 #include "amd/common/gfx9d.h"
46 #define CIK_TILE_MODE_COLOR_2D 14
48 #define CIK__GB_TILE_MODE__PIPE_CONFIG(x) (((x) >> 6) & 0x1f)
49 #define CIK__PIPE_CONFIG__ADDR_SURF_P2 0
50 #define CIK__PIPE_CONFIG__ADDR_SURF_P4_8x16 4
51 #define CIK__PIPE_CONFIG__ADDR_SURF_P4_16x16 5
52 #define CIK__PIPE_CONFIG__ADDR_SURF_P4_16x32 6
53 #define CIK__PIPE_CONFIG__ADDR_SURF_P4_32x32 7
54 #define CIK__PIPE_CONFIG__ADDR_SURF_P8_16x16_8x16 8
55 #define CIK__PIPE_CONFIG__ADDR_SURF_P8_16x32_8x16 9
56 #define CIK__PIPE_CONFIG__ADDR_SURF_P8_32x32_8x16 10
57 #define CIK__PIPE_CONFIG__ADDR_SURF_P8_16x32_16x16 11
58 #define CIK__PIPE_CONFIG__ADDR_SURF_P8_32x32_16x16 12
59 #define CIK__PIPE_CONFIG__ADDR_SURF_P8_32x32_16x32 13
60 #define CIK__PIPE_CONFIG__ADDR_SURF_P8_32x64_32x32 14
61 #define CIK__PIPE_CONFIG__ADDR_SURF_P16_32X32_8X16 16
62 #define CIK__PIPE_CONFIG__ADDR_SURF_P16_32X32_16X16 17
64 static struct util_hash_table
*dev_tab
= NULL
;
65 static mtx_t dev_tab_mutex
= _MTX_INITIALIZER_NP
;
67 static unsigned cik_get_num_tile_pipes(struct amdgpu_gpu_info
*info
)
69 unsigned mode2d
= info
->gb_tile_mode
[CIK_TILE_MODE_COLOR_2D
];
71 switch (CIK__GB_TILE_MODE__PIPE_CONFIG(mode2d
)) {
72 case CIK__PIPE_CONFIG__ADDR_SURF_P2
:
74 case CIK__PIPE_CONFIG__ADDR_SURF_P4_8x16
:
75 case CIK__PIPE_CONFIG__ADDR_SURF_P4_16x16
:
76 case CIK__PIPE_CONFIG__ADDR_SURF_P4_16x32
:
77 case CIK__PIPE_CONFIG__ADDR_SURF_P4_32x32
:
79 case CIK__PIPE_CONFIG__ADDR_SURF_P8_16x16_8x16
:
80 case CIK__PIPE_CONFIG__ADDR_SURF_P8_16x32_8x16
:
81 case CIK__PIPE_CONFIG__ADDR_SURF_P8_32x32_8x16
:
82 case CIK__PIPE_CONFIG__ADDR_SURF_P8_16x32_16x16
:
83 case CIK__PIPE_CONFIG__ADDR_SURF_P8_32x32_16x16
:
84 case CIK__PIPE_CONFIG__ADDR_SURF_P8_32x32_16x32
:
85 case CIK__PIPE_CONFIG__ADDR_SURF_P8_32x64_32x32
:
87 case CIK__PIPE_CONFIG__ADDR_SURF_P16_32X32_8X16
:
88 case CIK__PIPE_CONFIG__ADDR_SURF_P16_32X32_16X16
:
91 fprintf(stderr
, "Invalid CIK pipe configuration, assuming P2\n");
92 assert(!"this should never occur");
97 /* Helper function to do the ioctls needed for setup and init. */
98 static bool do_winsys_init(struct amdgpu_winsys
*ws
, int fd
)
100 struct amdgpu_buffer_size_alignments alignment_info
= {};
101 struct amdgpu_heap_info vram
, vram_vis
, gtt
;
102 struct drm_amdgpu_info_hw_ip dma
= {}, uvd
= {}, vce
= {};
103 uint32_t vce_version
= 0, vce_feature
= 0, uvd_version
= 0, uvd_feature
= 0;
104 uint32_t unused_feature
;
106 drmDevicePtr devinfo
;
109 r
= drmGetDevice2(fd
, 0, &devinfo
);
111 fprintf(stderr
, "amdgpu: drmGetDevice2 failed.\n");
114 ws
->info
.pci_domain
= devinfo
->businfo
.pci
->domain
;
115 ws
->info
.pci_bus
= devinfo
->businfo
.pci
->bus
;
116 ws
->info
.pci_dev
= devinfo
->businfo
.pci
->dev
;
117 ws
->info
.pci_func
= devinfo
->businfo
.pci
->func
;
118 drmFreeDevice(&devinfo
);
120 /* Query hardware and driver information. */
121 r
= amdgpu_query_gpu_info(ws
->dev
, &ws
->amdinfo
);
123 fprintf(stderr
, "amdgpu: amdgpu_query_gpu_info failed.\n");
127 r
= amdgpu_query_buffer_size_alignment(ws
->dev
, &alignment_info
);
129 fprintf(stderr
, "amdgpu: amdgpu_query_buffer_size_alignment failed.\n");
133 r
= amdgpu_query_heap_info(ws
->dev
, AMDGPU_GEM_DOMAIN_VRAM
, 0, &vram
);
135 fprintf(stderr
, "amdgpu: amdgpu_query_heap_info(vram) failed.\n");
139 r
= amdgpu_query_heap_info(ws
->dev
, AMDGPU_GEM_DOMAIN_VRAM
,
140 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED
,
143 fprintf(stderr
, "amdgpu: amdgpu_query_heap_info(vram_vis) failed.\n");
147 r
= amdgpu_query_heap_info(ws
->dev
, AMDGPU_GEM_DOMAIN_GTT
, 0, >t
);
149 fprintf(stderr
, "amdgpu: amdgpu_query_heap_info(gtt) failed.\n");
153 r
= amdgpu_query_hw_ip_info(ws
->dev
, AMDGPU_HW_IP_DMA
, 0, &dma
);
155 fprintf(stderr
, "amdgpu: amdgpu_query_hw_ip_info(dma) failed.\n");
159 r
= amdgpu_query_hw_ip_info(ws
->dev
, AMDGPU_HW_IP_UVD
, 0, &uvd
);
161 fprintf(stderr
, "amdgpu: amdgpu_query_hw_ip_info(uvd) failed.\n");
165 r
= amdgpu_query_firmware_version(ws
->dev
, AMDGPU_INFO_FW_GFX_ME
, 0, 0,
166 &ws
->info
.me_fw_version
, &unused_feature
);
168 fprintf(stderr
, "amdgpu: amdgpu_query_firmware_version(me) failed.\n");
172 r
= amdgpu_query_firmware_version(ws
->dev
, AMDGPU_INFO_FW_GFX_PFP
, 0, 0,
173 &ws
->info
.pfp_fw_version
, &unused_feature
);
175 fprintf(stderr
, "amdgpu: amdgpu_query_firmware_version(pfp) failed.\n");
179 r
= amdgpu_query_firmware_version(ws
->dev
, AMDGPU_INFO_FW_GFX_CE
, 0, 0,
180 &ws
->info
.ce_fw_version
, &unused_feature
);
182 fprintf(stderr
, "amdgpu: amdgpu_query_firmware_version(ce) failed.\n");
186 r
= amdgpu_query_firmware_version(ws
->dev
, AMDGPU_INFO_FW_UVD
, 0, 0,
187 &uvd_version
, &uvd_feature
);
189 fprintf(stderr
, "amdgpu: amdgpu_query_firmware_version(uvd) failed.\n");
193 r
= amdgpu_query_hw_ip_info(ws
->dev
, AMDGPU_HW_IP_VCE
, 0, &vce
);
195 fprintf(stderr
, "amdgpu: amdgpu_query_hw_ip_info(vce) failed.\n");
199 r
= amdgpu_query_firmware_version(ws
->dev
, AMDGPU_INFO_FW_VCE
, 0, 0,
200 &vce_version
, &vce_feature
);
202 fprintf(stderr
, "amdgpu: amdgpu_query_firmware_version(vce) failed.\n");
206 /* Set chip identification. */
207 ws
->info
.pci_id
= ws
->amdinfo
.asic_id
; /* TODO: is this correct? */
208 ws
->info
.vce_harvest_config
= ws
->amdinfo
.vce_harvest_config
;
210 switch (ws
->info
.pci_id
) {
211 #define CHIPSET(pci_id, name, cfamily) case pci_id: ws->info.family = CHIP_##cfamily; break;
212 #include "pci_ids/radeonsi_pci_ids.h"
216 fprintf(stderr
, "amdgpu: Invalid PCI ID.\n");
220 if (ws
->info
.family
>= CHIP_VEGA10
)
221 ws
->info
.chip_class
= GFX9
;
222 else if (ws
->info
.family
>= CHIP_TONGA
)
223 ws
->info
.chip_class
= VI
;
224 else if (ws
->info
.family
>= CHIP_BONAIRE
)
225 ws
->info
.chip_class
= CIK
;
226 else if (ws
->info
.family
>= CHIP_TAHITI
)
227 ws
->info
.chip_class
= SI
;
229 fprintf(stderr
, "amdgpu: Unknown family.\n");
233 /* LLVM 5.0 is required for GFX9. */
234 if (ws
->info
.chip_class
>= GFX9
&& HAVE_LLVM
< 0x0500) {
235 fprintf(stderr
, "amdgpu: LLVM 5.0 is required, got LLVM %i.%i\n",
236 HAVE_LLVM
>> 8, HAVE_LLVM
& 255);
240 ws
->addrlib
= amdgpu_addr_create(ws
->info
.family
, &ws
->amdinfo
);
242 fprintf(stderr
, "amdgpu: Cannot create addrlib.\n");
246 /* Set which chips have dedicated VRAM. */
247 ws
->info
.has_dedicated_vram
=
248 !(ws
->amdinfo
.ids_flags
& AMDGPU_IDS_FLAGS_FUSION
);
250 /* Set hardware information. */
251 ws
->info
.gart_size
= gtt
.heap_size
;
252 ws
->info
.vram_size
= vram
.heap_size
;
253 ws
->info
.vram_vis_size
= vram_vis
.heap_size
;
254 /* The kernel can split large buffers in VRAM but not in GTT, so large
255 * allocations can fail or cause buffer movement failures in the kernel.
257 ws
->info
.max_alloc_size
= MIN2(ws
->info
.vram_size
* 0.9, ws
->info
.gart_size
* 0.7);
258 /* convert the shader clock from KHz to MHz */
259 ws
->info
.max_shader_clock
= ws
->amdinfo
.max_engine_clk
/ 1000;
260 ws
->info
.max_se
= ws
->amdinfo
.num_shader_engines
;
261 ws
->info
.max_sh_per_se
= ws
->amdinfo
.num_shader_arrays_per_engine
;
262 ws
->info
.has_uvd
= uvd
.available_rings
!= 0;
263 ws
->info
.uvd_fw_version
=
264 uvd
.available_rings
? uvd_version
: 0;
265 ws
->info
.vce_fw_version
=
266 vce
.available_rings
? vce_version
: 0;
267 ws
->info
.has_userptr
= true;
268 ws
->info
.num_render_backends
= ws
->amdinfo
.rb_pipes
;
269 ws
->info
.clock_crystal_freq
= ws
->amdinfo
.gpu_counter_freq
;
270 ws
->info
.tcc_cache_line_size
= 64; /* TC L2 line size on GCN */
271 if (ws
->info
.chip_class
== GFX9
) {
272 ws
->info
.num_tile_pipes
= 1 << G_0098F8_NUM_PIPES(ws
->amdinfo
.gb_addr_cfg
);
273 ws
->info
.pipe_interleave_bytes
=
274 256 << G_0098F8_PIPE_INTERLEAVE_SIZE_GFX9(ws
->amdinfo
.gb_addr_cfg
);
276 ws
->info
.num_tile_pipes
= cik_get_num_tile_pipes(&ws
->amdinfo
);
277 ws
->info
.pipe_interleave_bytes
=
278 256 << G_0098F8_PIPE_INTERLEAVE_SIZE_GFX6(ws
->amdinfo
.gb_addr_cfg
);
280 ws
->info
.has_virtual_memory
= true;
281 ws
->info
.has_sdma
= dma
.available_rings
!= 0;
283 /* Get the number of good compute units. */
284 ws
->info
.num_good_compute_units
= 0;
285 for (i
= 0; i
< ws
->info
.max_se
; i
++)
286 for (j
= 0; j
< ws
->info
.max_sh_per_se
; j
++)
287 ws
->info
.num_good_compute_units
+=
288 util_bitcount(ws
->amdinfo
.cu_bitmap
[i
][j
]);
290 memcpy(ws
->info
.si_tile_mode_array
, ws
->amdinfo
.gb_tile_mode
,
291 sizeof(ws
->amdinfo
.gb_tile_mode
));
292 ws
->info
.enabled_rb_mask
= ws
->amdinfo
.enabled_rb_pipes_mask
;
294 memcpy(ws
->info
.cik_macrotile_mode_array
, ws
->amdinfo
.gb_macro_tile_mode
,
295 sizeof(ws
->amdinfo
.gb_macro_tile_mode
));
297 ws
->info
.gart_page_size
= alignment_info
.size_remote
;
299 if (ws
->info
.chip_class
== SI
)
300 ws
->info
.gfx_ib_pad_with_type2
= TRUE
;
302 ws
->check_vm
= strstr(debug_get_option("R600_DEBUG", ""), "check_vm") != NULL
;
308 AddrDestroy(ws
->addrlib
);
309 amdgpu_device_deinitialize(ws
->dev
);
314 static void do_winsys_deinit(struct amdgpu_winsys
*ws
)
316 AddrDestroy(ws
->addrlib
);
317 amdgpu_device_deinitialize(ws
->dev
);
320 static void amdgpu_winsys_destroy(struct radeon_winsys
*rws
)
322 struct amdgpu_winsys
*ws
= (struct amdgpu_winsys
*)rws
;
324 if (util_queue_is_initialized(&ws
->cs_queue
))
325 util_queue_destroy(&ws
->cs_queue
);
327 mtx_destroy(&ws
->bo_fence_lock
);
328 pb_slabs_deinit(&ws
->bo_slabs
);
329 pb_cache_deinit(&ws
->bo_cache
);
330 mtx_destroy(&ws
->global_bo_list_lock
);
331 do_winsys_deinit(ws
);
335 static void amdgpu_winsys_query_info(struct radeon_winsys
*rws
,
336 struct radeon_info
*info
)
338 *info
= ((struct amdgpu_winsys
*)rws
)->info
;
341 static bool amdgpu_cs_request_feature(struct radeon_winsys_cs
*rcs
,
342 enum radeon_feature_id fid
,
348 static uint64_t amdgpu_query_value(struct radeon_winsys
*rws
,
349 enum radeon_value_id value
)
351 struct amdgpu_winsys
*ws
= (struct amdgpu_winsys
*)rws
;
352 struct amdgpu_heap_info heap
;
356 case RADEON_REQUESTED_VRAM_MEMORY
:
357 return ws
->allocated_vram
;
358 case RADEON_REQUESTED_GTT_MEMORY
:
359 return ws
->allocated_gtt
;
360 case RADEON_MAPPED_VRAM
:
361 return ws
->mapped_vram
;
362 case RADEON_MAPPED_GTT
:
363 return ws
->mapped_gtt
;
364 case RADEON_BUFFER_WAIT_TIME_NS
:
365 return ws
->buffer_wait_time
;
366 case RADEON_NUM_MAPPED_BUFFERS
:
367 return ws
->num_mapped_buffers
;
368 case RADEON_TIMESTAMP
:
369 amdgpu_query_info(ws
->dev
, AMDGPU_INFO_TIMESTAMP
, 8, &retval
);
371 case RADEON_NUM_GFX_IBS
:
372 return ws
->num_gfx_IBs
;
373 case RADEON_NUM_SDMA_IBS
:
374 return ws
->num_sdma_IBs
;
375 case RADEON_NUM_BYTES_MOVED
:
376 amdgpu_query_info(ws
->dev
, AMDGPU_INFO_NUM_BYTES_MOVED
, 8, &retval
);
378 case RADEON_NUM_EVICTIONS
:
379 amdgpu_query_info(ws
->dev
, AMDGPU_INFO_NUM_EVICTIONS
, 8, &retval
);
381 case RADEON_VRAM_USAGE
:
382 amdgpu_query_heap_info(ws
->dev
, AMDGPU_GEM_DOMAIN_VRAM
, 0, &heap
);
383 return heap
.heap_usage
;
384 case RADEON_VRAM_VIS_USAGE
:
385 amdgpu_query_heap_info(ws
->dev
, AMDGPU_GEM_DOMAIN_VRAM
,
386 AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED
, &heap
);
387 return heap
.heap_usage
;
388 case RADEON_GTT_USAGE
:
389 amdgpu_query_heap_info(ws
->dev
, AMDGPU_GEM_DOMAIN_GTT
, 0, &heap
);
390 return heap
.heap_usage
;
391 case RADEON_GPU_TEMPERATURE
:
392 amdgpu_query_sensor_info(ws
->dev
, AMDGPU_INFO_SENSOR_GPU_TEMP
, 4, &retval
);
394 case RADEON_CURRENT_SCLK
:
395 amdgpu_query_sensor_info(ws
->dev
, AMDGPU_INFO_SENSOR_GFX_SCLK
, 4, &retval
);
397 case RADEON_CURRENT_MCLK
:
398 amdgpu_query_sensor_info(ws
->dev
, AMDGPU_INFO_SENSOR_GFX_MCLK
, 4, &retval
);
400 case RADEON_GPU_RESET_COUNTER
:
403 case RADEON_CS_THREAD_TIME
:
404 return util_queue_get_thread_time_nano(&ws
->cs_queue
, 0);
409 static bool amdgpu_read_registers(struct radeon_winsys
*rws
,
411 unsigned num_registers
, uint32_t *out
)
413 struct amdgpu_winsys
*ws
= (struct amdgpu_winsys
*)rws
;
415 return amdgpu_read_mm_registers(ws
->dev
, reg_offset
/ 4, num_registers
,
416 0xffffffff, 0, out
) == 0;
419 static unsigned hash_dev(void *key
)
421 #if defined(PIPE_ARCH_X86_64)
422 return pointer_to_intptr(key
) ^ (pointer_to_intptr(key
) >> 32);
424 return pointer_to_intptr(key
);
428 static int compare_dev(void *key1
, void *key2
)
433 static bool amdgpu_winsys_unref(struct radeon_winsys
*rws
)
435 struct amdgpu_winsys
*ws
= (struct amdgpu_winsys
*)rws
;
438 /* When the reference counter drops to zero, remove the device pointer
440 * This must happen while the mutex is locked, so that
441 * amdgpu_winsys_create in another thread doesn't get the winsys
442 * from the table when the counter drops to 0. */
443 mtx_lock(&dev_tab_mutex
);
445 destroy
= pipe_reference(&ws
->reference
, NULL
);
446 if (destroy
&& dev_tab
)
447 util_hash_table_remove(dev_tab
, ws
->dev
);
449 mtx_unlock(&dev_tab_mutex
);
453 PUBLIC
struct radeon_winsys
*
454 amdgpu_winsys_create(int fd
, radeon_screen_create_t screen_create
)
456 struct amdgpu_winsys
*ws
;
457 drmVersionPtr version
= drmGetVersion(fd
);
458 amdgpu_device_handle dev
;
459 uint32_t drm_major
, drm_minor
, r
;
461 /* The DRM driver version of amdgpu is 3.x.x. */
462 if (version
->version_major
!= 3) {
463 drmFreeVersion(version
);
466 drmFreeVersion(version
);
468 /* Look up the winsys from the dev table. */
469 mtx_lock(&dev_tab_mutex
);
471 dev_tab
= util_hash_table_create(hash_dev
, compare_dev
);
473 /* Initialize the amdgpu device. This should always return the same pointer
474 * for the same fd. */
475 r
= amdgpu_device_initialize(fd
, &drm_major
, &drm_minor
, &dev
);
477 mtx_unlock(&dev_tab_mutex
);
478 fprintf(stderr
, "amdgpu: amdgpu_device_initialize failed.\n");
482 /* Lookup a winsys if we have already created one for this device. */
483 ws
= util_hash_table_get(dev_tab
, dev
);
485 pipe_reference(NULL
, &ws
->reference
);
486 mtx_unlock(&dev_tab_mutex
);
490 /* Create a new winsys. */
491 ws
= CALLOC_STRUCT(amdgpu_winsys
);
496 ws
->info
.drm_major
= drm_major
;
497 ws
->info
.drm_minor
= drm_minor
;
499 if (!do_winsys_init(ws
, fd
))
502 /* Create managers. */
503 pb_cache_init(&ws
->bo_cache
, 500000, ws
->check_vm
? 1.0f
: 2.0f
, 0,
504 (ws
->info
.vram_size
+ ws
->info
.gart_size
) / 8,
505 amdgpu_bo_destroy
, amdgpu_bo_can_reclaim
);
507 if (!pb_slabs_init(&ws
->bo_slabs
,
508 AMDGPU_SLAB_MIN_SIZE_LOG2
, AMDGPU_SLAB_MAX_SIZE_LOG2
,
509 12, /* number of heaps (domain/flags combinations) */
511 amdgpu_bo_can_reclaim_slab
,
512 amdgpu_bo_slab_alloc
,
513 amdgpu_bo_slab_free
))
516 ws
->info
.min_alloc_size
= 1 << AMDGPU_SLAB_MIN_SIZE_LOG2
;
519 pipe_reference_init(&ws
->reference
, 1);
522 ws
->base
.unref
= amdgpu_winsys_unref
;
523 ws
->base
.destroy
= amdgpu_winsys_destroy
;
524 ws
->base
.query_info
= amdgpu_winsys_query_info
;
525 ws
->base
.cs_request_feature
= amdgpu_cs_request_feature
;
526 ws
->base
.query_value
= amdgpu_query_value
;
527 ws
->base
.read_registers
= amdgpu_read_registers
;
529 amdgpu_bo_init_functions(ws
);
530 amdgpu_cs_init_functions(ws
);
531 amdgpu_surface_init_functions(ws
);
533 LIST_INITHEAD(&ws
->global_bo_list
);
534 (void) mtx_init(&ws
->global_bo_list_lock
, mtx_plain
);
535 (void) mtx_init(&ws
->bo_fence_lock
, mtx_plain
);
537 if (!util_queue_init(&ws
->cs_queue
, "amdgpu_cs", 8, 1)) {
538 amdgpu_winsys_destroy(&ws
->base
);
539 mtx_unlock(&dev_tab_mutex
);
543 /* Create the screen at the end. The winsys must be initialized
546 * Alternatively, we could create the screen based on "ws->gen"
547 * and link all drivers into one binary blob. */
548 ws
->base
.screen
= screen_create(&ws
->base
);
549 if (!ws
->base
.screen
) {
550 amdgpu_winsys_destroy(&ws
->base
);
551 mtx_unlock(&dev_tab_mutex
);
555 util_hash_table_set(dev_tab
, dev
, ws
);
557 /* We must unlock the mutex once the winsys is fully initialized, so that
558 * other threads attempting to create the winsys from the same fd will
559 * get a fully initialized winsys and not just half-way initialized. */
560 mtx_unlock(&dev_tab_mutex
);
565 pb_cache_deinit(&ws
->bo_cache
);
566 do_winsys_deinit(ws
);
570 mtx_unlock(&dev_tab_mutex
);