xref: /linux/drivers/gpu/drm/xe/xe_pat.h (revision aec2f682d47c54ef434b2d440992626d80b1ebdc)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2023 Intel Corporation
4  */
5 
6 #ifndef _XE_PAT_H_
7 #define _XE_PAT_H_
8 
9 #include <linux/types.h>
10 
11 struct drm_printer;
12 struct xe_device;
13 struct xe_gt;
14 
15 #define XE_PAT_INVALID_IDX	U16_MAX
16 
17 /**
18  * struct xe_pat_table_entry - The pat_index encoding and other meta information.
19  */
20 struct xe_pat_table_entry {
21 	/**
22 	 * @value: The platform specific value encoding the various memory
23 	 * attributes (this maps to some fixed pat_index). So things like
24 	 * caching, coherency, compression etc can be encoded here.
25 	 */
26 	u32 value;
27 
28 	/**
29 	 * @coh_mode: The GPU coherency mode that @value maps to.
30 	 */
31 #define XE_COH_NONE		1
32 #define XE_COH_1WAY		2
33 #define XE_COH_2WAY		3
34 	u16 coh_mode;
35 
36 	/**
37 	 * @valid: Set to 1 if the entry is valid, 0 if it's reserved.
38 	 */
39 	u16 valid;
40 };
41 
42 /**
43  * xe_pat_init_early - SW initialization, setting up data based on device
44  * @xe: xe device
45  */
46 void xe_pat_init_early(struct xe_device *xe);
47 
48 /**
49  * xe_pat_init - Program HW PAT table
50  * @gt: GT structure
51  */
52 void xe_pat_init(struct xe_gt *gt);
53 
54 int xe_pat_dump(struct xe_gt *gt, struct drm_printer *p);
55 int xe_pat_dump_sw_config(struct xe_gt *gt, struct drm_printer *p);
56 
57 /**
58  * xe_pat_index_get_coh_mode - Extract the coherency mode for the given
59  * pat_index.
60  * @xe: xe device
61  * @pat_index: The pat_index to query
62  */
63 u16 xe_pat_index_get_coh_mode(struct xe_device *xe, u16 pat_index);
64 
65 /**
66  * xe_pat_index_get_comp_en - Extract the compression enable flag for
67  * the given pat_index.
68  * @xe: xe device
69  * @pat_index: The pat_index to query
70  *
71  * Return: true if compression is enabled for this pat_index, false otherwise.
72  */
73 bool xe_pat_index_get_comp_en(struct xe_device *xe, u16 pat_index);
74 
75 #define XE_L3_POLICY_WB		0 /* Write-back */
76 #define XE_L3_POLICY_XD		1 /* WB - Transient Display */
77 #define XE_L3_POLICY_UC		3 /* Uncached */
78 /**
79  * xe_pat_index_get_l3_policy - Extract the L3 policy for the given pat_index.
80  * @xe: xe device
81  * @pat_index: The pat_index to query
82  */
83 u16 xe_pat_index_get_l3_policy(struct xe_device *xe, u16 pat_index);
84 
85 #endif
86