2 * Copyright © 2011 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Daniel Vetter <daniel.vetter@ffwll.ch>
29 * Testcase: Unreferencing of active buffers
31 * Execs buffers and immediately unreferences them, hence the kernel active list
32 * will be the last one to hold a reference on them. Usually libdrm bo caching
33 * prevents that by keeping another reference.
44 #include "ioctl_wrappers.h"
46 #include "intel_bufmgr.h"
47 #include "intel_batchbuffer.h"
49 #include "intel_chipset.h"
51 static drm_intel_bufmgr *bufmgr;
52 struct intel_batchbuffer *batch;
53 static drm_intel_bo *load_bo;
59 igt_skip_on_simulation();
63 bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
65 /* don't enable buffer reuse!! */
66 //drm_intel_bufmgr_gem_enable_reuse(bufmgr);
68 batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
71 /* put some load onto the gpu to keep the light buffers active for long
73 for (i = 0; i < 1000; i++) {
74 load_bo = drm_intel_bo_alloc(bufmgr, "target bo", 1024*4096, 4096);
77 BLIT_COPY_BATCH_START(batch->devid, 0);
78 OUT_BATCH((3 << 24) | /* 32 bits */
79 (0xcc << 16) | /* copy ROP */
81 OUT_BATCH(0); /* dst x1,y1 */
82 OUT_BATCH((1024 << 16) | 512);
83 OUT_RELOC(load_bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
84 BLIT_RELOC_UDW(batch->devid);
85 OUT_BATCH((0 << 16) | 512); /* src x1, y1 */
87 OUT_RELOC(load_bo, I915_GEM_DOMAIN_RENDER, 0, 0);
88 BLIT_RELOC_UDW(batch->devid);
91 intel_batchbuffer_flush(batch);
93 drm_intel_bo_disable_reuse(load_bo);
94 drm_intel_bo_unreference(load_bo);
97 drm_intel_bufmgr_destroy(bufmgr);