18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/* (C) COPYRIGHT 2014-2018 ARM Limited. All rights reserved. */
38c2ecf20Sopenharmony_ci/* Copyright 2019 Linaro, Ltd., Rob Herring <robh@kernel.org> */
48c2ecf20Sopenharmony_ci#ifndef __PANFROST_ISSUES_H__
58c2ecf20Sopenharmony_ci#define __PANFROST_ISSUES_H__
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <linux/bitops.h>
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include "panfrost_device.h"
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci/*
128c2ecf20Sopenharmony_ci * This is not a complete list of issues, but only the ones the driver needs
138c2ecf20Sopenharmony_ci * to care about.
148c2ecf20Sopenharmony_ci */
158c2ecf20Sopenharmony_cienum panfrost_hw_issue {
168c2ecf20Sopenharmony_ci	/* Need way to guarantee that all previously-translated memory accesses
178c2ecf20Sopenharmony_ci	 * are commited */
188c2ecf20Sopenharmony_ci	HW_ISSUE_6367,
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci	/* On job complete with non-done the cache is not flushed */
218c2ecf20Sopenharmony_ci	HW_ISSUE_6787,
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci	/* Write of PRFCNT_CONFIG_MODE_MANUAL to PRFCNT_CONFIG causes a
248c2ecf20Sopenharmony_ci	 * instrumentation dump if PRFCNT_TILER_EN is enabled */
258c2ecf20Sopenharmony_ci	HW_ISSUE_8186,
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci	/* TIB: Reports faults from a vtile which has not yet been allocated */
288c2ecf20Sopenharmony_ci	HW_ISSUE_8245,
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	/* uTLB deadlock could occur when writing to an invalid page at the
318c2ecf20Sopenharmony_ci	 * same time as access to a valid page in the same uTLB cache line ( ==
328c2ecf20Sopenharmony_ci	 * 4 PTEs == 16K block of mapping) */
338c2ecf20Sopenharmony_ci	HW_ISSUE_8316,
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci	/* HT: TERMINATE for RUN command ignored if previous LOAD_DESCRIPTOR is
368c2ecf20Sopenharmony_ci	 * still executing */
378c2ecf20Sopenharmony_ci	HW_ISSUE_8394,
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	/* CSE: Sends a TERMINATED response for a task that should not be
408c2ecf20Sopenharmony_ci	 * terminated */
418c2ecf20Sopenharmony_ci	HW_ISSUE_8401,
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	/* Repeatedly Soft-stopping a job chain consisting of (Vertex Shader,
448c2ecf20Sopenharmony_ci	 * Cache Flush, Tiler) jobs causes DATA_INVALID_FAULT on tiler job. */
458c2ecf20Sopenharmony_ci	HW_ISSUE_8408,
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci	/* Disable the Pause Buffer in the LS pipe. */
488c2ecf20Sopenharmony_ci	HW_ISSUE_8443,
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci	/* Change in RMUs in use causes problems related with the core's SDC */
518c2ecf20Sopenharmony_ci	HW_ISSUE_8987,
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci	/* Compute endpoint has a 4-deep queue of tasks, meaning a soft stop
548c2ecf20Sopenharmony_ci	 * won't complete until all 4 tasks have completed */
558c2ecf20Sopenharmony_ci	HW_ISSUE_9435,
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	/* HT: Tiler returns TERMINATED for non-terminated command */
588c2ecf20Sopenharmony_ci	HW_ISSUE_9510,
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci	/* Occasionally the GPU will issue multiple page faults for the same
618c2ecf20Sopenharmony_ci	 * address before the MMU page table has been read by the GPU */
628c2ecf20Sopenharmony_ci	HW_ISSUE_9630,
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci	/* RA DCD load request to SDC returns invalid load ignore causing
658c2ecf20Sopenharmony_ci	 * colour buffer mismatch */
668c2ecf20Sopenharmony_ci	HW_ISSUE_10327,
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci	/* MMU TLB invalidation hazards */
698c2ecf20Sopenharmony_ci	HW_ISSUE_10649,
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci	/* Missing cache flush in multi core-group configuration */
728c2ecf20Sopenharmony_ci	HW_ISSUE_10676,
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	/* Chicken bit on T72X for a hardware workaround in compiler */
758c2ecf20Sopenharmony_ci	HW_ISSUE_10797,
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	/* Soft-stopping fragment jobs might fail with TILE_RANGE_FAULT */
788c2ecf20Sopenharmony_ci	HW_ISSUE_10817,
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci	/* Intermittent missing interrupt on job completion */
818c2ecf20Sopenharmony_ci	HW_ISSUE_10883,
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci	/* Soft-stopping fragment jobs might fail with TILE_RANGE_ERROR
848c2ecf20Sopenharmony_ci	 * (similar to issue 10817) and can use #10817 workaround */
858c2ecf20Sopenharmony_ci	HW_ISSUE_10959,
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci	/* Soft-stopped fragment shader job can restart with out-of-bound
888c2ecf20Sopenharmony_ci	 * restart index */
898c2ecf20Sopenharmony_ci	HW_ISSUE_10969,
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci	/* Race condition can cause tile list corruption */
928c2ecf20Sopenharmony_ci	HW_ISSUE_11020,
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci	/* Write buffer can cause tile list corruption */
958c2ecf20Sopenharmony_ci	HW_ISSUE_11024,
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci	/* Pause buffer can cause a fragment job hang */
988c2ecf20Sopenharmony_ci	HW_ISSUE_11035,
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci	/* Dynamic Core Scaling not supported due to errata */
1018c2ecf20Sopenharmony_ci	HW_ISSUE_11056,
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci	/* Clear encoder state for a hard stopped fragment job which is AFBC
1048c2ecf20Sopenharmony_ci	 * encoded by soft resetting the GPU. Only for T76X r0p0, r0p1 and
1058c2ecf20Sopenharmony_ci	 * r0p1_50rel0 */
1068c2ecf20Sopenharmony_ci	HW_ISSUE_T76X_3542,
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci	/* Keep tiler module clock on to prevent GPU stall */
1098c2ecf20Sopenharmony_ci	HW_ISSUE_T76X_3953,
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci	/* Must ensure L2 is not transitioning when we reset. Workaround with a
1128c2ecf20Sopenharmony_ci	 * busy wait until L2 completes transition; ensure there is a maximum
1138c2ecf20Sopenharmony_ci	 * loop count as she may never complete her transition. (On chips
1148c2ecf20Sopenharmony_ci	 * without this errata, it's totally okay if L2 transitions.) */
1158c2ecf20Sopenharmony_ci	HW_ISSUE_TMIX_8463,
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci	/* Don't set SC_LS_ATTR_CHECK_DISABLE/SC_LS_ALLOW_ATTR_TYPES */
1188c2ecf20Sopenharmony_ci	GPUCORE_1619,
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	/* When a hard-stop follows close after a soft-stop, the completion
1218c2ecf20Sopenharmony_ci	 * code for the terminated job may be incorrectly set to STOPPED */
1228c2ecf20Sopenharmony_ci	HW_ISSUE_TMIX_8438,
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci	/* "Protected mode" is buggy on Mali-G31 some Bifrost chips, so the
1258c2ecf20Sopenharmony_ci	 * kernel must fiddle with L2 caches to prevent data leakage */
1268c2ecf20Sopenharmony_ci	HW_ISSUE_TGOX_R1_1234,
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci	HW_ISSUE_END
1298c2ecf20Sopenharmony_ci};
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci#define hw_issues_all (\
1328c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_9435))
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci#define hw_issues_t600 (\
1358c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_6367) | \
1368c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_6787) | \
1378c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_8408) | \
1388c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_9510) | \
1398c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10649) | \
1408c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10676) | \
1418c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10883) | \
1428c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11020) | \
1438c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11035) | \
1448c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11056) | \
1458c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_TMIX_8438))
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci#define hw_issues_t600_r0p0_15dev0 (\
1488c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_8186) | \
1498c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_8245) | \
1508c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_8316) | \
1518c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_8394) | \
1528c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_8401) | \
1538c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_8443) | \
1548c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_8987) | \
1558c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_9630) | \
1568c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10969) | \
1578c2ecf20Sopenharmony_ci	BIT_ULL(GPUCORE_1619))
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci#define hw_issues_t620 (\
1608c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10649) | \
1618c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10883) | \
1628c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10959) | \
1638c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11056) | \
1648c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_TMIX_8438))
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci#define hw_issues_t620_r0p1 (\
1678c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10327) | \
1688c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10676) | \
1698c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10817) | \
1708c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11020) | \
1718c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11024) | \
1728c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11035))
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci#define hw_issues_t620_r1p0 (\
1758c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11020) | \
1768c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11024))
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci#define hw_issues_t720 (\
1798c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10649) | \
1808c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10797) | \
1818c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10883) | \
1828c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11056) | \
1838c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_TMIX_8438))
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci#define hw_issues_t760 (\
1868c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10883) | \
1878c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_T76X_3953) | \
1888c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_TMIX_8438))
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ci#define hw_issues_t760_r0p0 (\
1918c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11020) | \
1928c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11024) | \
1938c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_T76X_3542))
1948c2ecf20Sopenharmony_ci
1958c2ecf20Sopenharmony_ci#define hw_issues_t760_r0p1 (\
1968c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11020) | \
1978c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11024) | \
1988c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_T76X_3542))
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci#define hw_issues_t760_r0p1_50rel0 (\
2018c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_T76X_3542))
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci#define hw_issues_t760_r0p2 (\
2048c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11020) | \
2058c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_11024) | \
2068c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_T76X_3542))
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci#define hw_issues_t760_r0p3 (\
2098c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_T76X_3542))
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci#define hw_issues_t820 (\
2128c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10883) | \
2138c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_T76X_3953) | \
2148c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_TMIX_8438))
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ci#define hw_issues_t830 (\
2178c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10883) | \
2188c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_T76X_3953) | \
2198c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_TMIX_8438))
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci#define hw_issues_t860 (\
2228c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10883) | \
2238c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_T76X_3953) | \
2248c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_TMIX_8438))
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ci#define hw_issues_t880 (\
2278c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_10883) | \
2288c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_T76X_3953) | \
2298c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_TMIX_8438))
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci#define hw_issues_g31 0
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci#define hw_issues_g31_r1p0 (\
2348c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_TGOX_R1_1234))
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci#define hw_issues_g51 0
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ci#define hw_issues_g52 0
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ci#define hw_issues_g71 (\
2418c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_TMIX_8463) | \
2428c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_TMIX_8438))
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci#define hw_issues_g71_r0p0_05dev0 (\
2458c2ecf20Sopenharmony_ci	BIT_ULL(HW_ISSUE_T76X_3953))
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ci#define hw_issues_g72 0
2488c2ecf20Sopenharmony_ci
2498c2ecf20Sopenharmony_ci#define hw_issues_g76 0
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_cistatic inline bool panfrost_has_hw_issue(struct panfrost_device *pfdev,
2528c2ecf20Sopenharmony_ci					 enum panfrost_hw_issue issue)
2538c2ecf20Sopenharmony_ci{
2548c2ecf20Sopenharmony_ci	return test_bit(issue, pfdev->features.hw_issues);
2558c2ecf20Sopenharmony_ci}
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ci#endif /* __PANFROST_ISSUES_H__ */
258