1 /* 2 * Copyright © 2016 Broadcom 3 * 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: 10 * 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 13 * Software. 14 * 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 21 * IN THE SOFTWARE. 22 */ 23 24 #include "igt.h" 25 #include <assert.h> 26 #include <unistd.h> 27 #include <stdlib.h> 28 #include <stdio.h> 29 #include <string.h> 30 #include <fcntl.h> 31 #include <inttypes.h> 32 #include <errno.h> 33 #include <sys/stat.h> 34 #include <sys/ioctl.h> 35 #include "vc4_drm.h" 36 #include "vc4_packet.h" 37 38 igt_main 39 { 40 int fd; 41 42 igt_fixture 43 fd = drm_open_driver(DRIVER_VC4); 44 45 igt_subtest("bad-color-write") { 46 uint32_t size = 4096; 47 /* A single row will be a page. */ 48 uint32_t width = 1024; 49 uint32_t height = size / (width * 4); 50 uint32_t handle = 0xd0d0d0d0; /* Don't actually make a BO */ 51 struct drm_vc4_submit_cl submit = { 52 .color_write = { 53 .hindex = 0, 54 .bits = VC4_SET_FIELD(VC4_RENDER_CONFIG_FORMAT_RGBA8888, 55 VC4_RENDER_CONFIG_FORMAT), 56 }, 57 58 .color_read = { .hindex = ~0 }, 59 .zs_read = { .hindex = ~0 }, 60 .zs_write = { .hindex = ~0 }, 61 .msaa_color_write = { .hindex = ~0 }, 62 .msaa_zs_write = { .hindex = ~0 }, 63 64 .bo_handles = (uint64_t)(uintptr_t)&handle, 65 .bo_handle_count = 1, 66 .width = width, 67 .height = height, 68 .max_x_tile = ALIGN(width, 64) / 64 - 1, 69 .max_y_tile = ALIGN(height, 64) / 64 - 1, 70 .clear_color = { 0xcccccccc, 0xcccccccc }, 71 .flags = VC4_SUBMIT_CL_USE_CLEAR_COLOR, 72 }; 73 74 igt_assert_eq_u32(width * height * 4, size); 75 76 do_ioctl_err(fd, DRM_IOCTL_VC4_SUBMIT_CL, &submit, EINVAL); 77 } 78 79 igt_fixture 80 close(fd); 81 } 82