1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright (C) 2019 Collabora, Ltd. 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21bf215546Sopenharmony_ci * SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#ifndef __MDG_QUIRKS_H 25bf215546Sopenharmony_ci#define __MDG_QUIRKS_H 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci/* Model-specific quirks requiring compiler workarounds/etc. Quirks 28bf215546Sopenharmony_ci * may be errata requiring a workaround, or features. We're trying to be 29bf215546Sopenharmony_ci * quirk-positive here; quirky is the best! */ 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci/* Typed loads are broken on this Midgard GPU due to issue #10607 and #10632 and 32bf215546Sopenharmony_ci * should use software unpacks instead. 33bf215546Sopenharmony_ci */ 34bf215546Sopenharmony_ci#define MIDGARD_BROKEN_BLEND_LOADS (1 << 0) 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ci/* Whether output texture registers (normally r28/r29) overlap with work 37bf215546Sopenharmony_ci * registers r0/r1 and input texture registers (also normally r28/r29) overlap 38bf215546Sopenharmony_ci * with load/store registers r26/r27. This constrains register allocation 39bf215546Sopenharmony_ci * considerably but is a space-saving measure on small Midgards. It's worth 40bf215546Sopenharmony_ci * noting if you try to access r28/r29, it may still work, but you'll mess up 41bf215546Sopenharmony_ci * the interference. Corresponds to BASE_HW_FEATURE_INTERPIPE_REG_ALIASING in 42bf215546Sopenharmony_ci * kbase. */ 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_ci#define MIDGARD_INTERPIPE_REG_ALIASING (1 << 1) 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_ci/* Whether we should use old-style blend opcodes */ 47bf215546Sopenharmony_ci 48bf215546Sopenharmony_ci#define MIDGARD_OLD_BLEND (1 << 2) 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ci/* Errata causing the LOD clamps and bias in the sampler descriptor to be 51bf215546Sopenharmony_ci * ignored. This errata affects the command stream but uses a compiler 52bf215546Sopenharmony_ci * workaround (applying the clamps/bias manually in the shader. Corresponds in 53bf215546Sopenharmony_ci * BASE_HW_ISSUE_10471 in kbase, described as "TEXGRD doesn't honor Sampler 54bf215546Sopenharmony_ci * Descriptor LOD clamps nor bias". (I'm assuming TEXGRD is what we call 55bf215546Sopenharmony_ci * textureLod) */ 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_ci#define MIDGARD_BROKEN_LOD (1 << 3) 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_ci/* Don't use upper ALU tags for writeout (if you do, you'll get a 60bf215546Sopenharmony_ci * INSTR_INVALID_ENC). It's not clear to me what these tags are for. */ 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ci#define MIDGARD_NO_UPPER_ALU (1 << 4) 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci/* Whether (texture) out-of-order execution support is missing on early 65bf215546Sopenharmony_ci * Midgards. For these just set the OoO bits to 0. */ 66bf215546Sopenharmony_ci 67bf215546Sopenharmony_ci#define MIDGARD_NO_OOO (1 << 5) 68bf215546Sopenharmony_ci 69bf215546Sopenharmony_cistatic inline unsigned 70bf215546Sopenharmony_cimidgard_get_quirks(unsigned gpu_id) 71bf215546Sopenharmony_ci{ 72bf215546Sopenharmony_ci switch (gpu_id) { 73bf215546Sopenharmony_ci case 0x600: 74bf215546Sopenharmony_ci case 0x620: 75bf215546Sopenharmony_ci return MIDGARD_OLD_BLEND | 76bf215546Sopenharmony_ci MIDGARD_BROKEN_BLEND_LOADS | 77bf215546Sopenharmony_ci MIDGARD_BROKEN_LOD | 78bf215546Sopenharmony_ci MIDGARD_NO_UPPER_ALU | 79bf215546Sopenharmony_ci MIDGARD_NO_OOO; 80bf215546Sopenharmony_ci 81bf215546Sopenharmony_ci case 0x720: 82bf215546Sopenharmony_ci return MIDGARD_INTERPIPE_REG_ALIASING | 83bf215546Sopenharmony_ci MIDGARD_OLD_BLEND | 84bf215546Sopenharmony_ci MIDGARD_BROKEN_LOD | 85bf215546Sopenharmony_ci MIDGARD_NO_UPPER_ALU | 86bf215546Sopenharmony_ci MIDGARD_NO_OOO; 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_ci case 0x820: 89bf215546Sopenharmony_ci case 0x830: 90bf215546Sopenharmony_ci return MIDGARD_INTERPIPE_REG_ALIASING; 91bf215546Sopenharmony_ci 92bf215546Sopenharmony_ci case 0x750: 93bf215546Sopenharmony_ci return MIDGARD_NO_UPPER_ALU; 94bf215546Sopenharmony_ci 95bf215546Sopenharmony_ci case 0x860: 96bf215546Sopenharmony_ci case 0x880: 97bf215546Sopenharmony_ci return 0; 98bf215546Sopenharmony_ci 99bf215546Sopenharmony_ci default: 100bf215546Sopenharmony_ci unreachable("Invalid Midgard GPU ID"); 101bf215546Sopenharmony_ci } 102bf215546Sopenharmony_ci} 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_ci#endif 105