24
24
*
25
25
* vram_d3cold_threshold - Report/change vram used threshold(in MB) below
26
26
* which vram save/restore is permissible during runtime D3cold entry/exit.
27
+ *
28
+ * lb_fan_control_version - Fan control version provisioned by late binding.
29
+ * Exposed only if supported by the device.
30
+ *
31
+ * lb_voltage_regulator_version - Voltage regulator version provisioned by late
32
+ * binding. Exposed only if supported by the device.
27
33
*/
28
34
29
35
static ssize_t
@@ -65,6 +71,135 @@ vram_d3cold_threshold_store(struct device *dev, struct device_attribute *attr,
65
71
66
72
static DEVICE_ATTR_RW (vram_d3cold_threshold );
67
73
74
+ static ssize_t
75
+ lb_fan_control_version_show (struct device * dev , struct device_attribute * attr , char * buf )
76
+ {
77
+ struct xe_device * xe = pdev_to_xe_device (to_pci_dev (dev ));
78
+ struct xe_tile * root = xe_device_get_root_tile (xe );
79
+ u32 cap , ver_low = FAN_TABLE , ver_high = FAN_TABLE ;
80
+ u16 major = 0 , minor = 0 , hotfix = 0 , build = 0 ;
81
+ int ret ;
82
+
83
+ xe_pm_runtime_get (xe );
84
+
85
+ ret = xe_pcode_read (root , PCODE_MBOX (PCODE_LATE_BINDING , GET_CAPABILITY_STATUS , 0 ),
86
+ & cap , NULL );
87
+ if (ret )
88
+ goto out ;
89
+
90
+ if (REG_FIELD_GET (V1_FAN_PROVISIONED , cap )) {
91
+ ret = xe_pcode_read (root , PCODE_MBOX (PCODE_LATE_BINDING , GET_VERSION_LOW , 0 ),
92
+ & ver_low , NULL );
93
+ if (ret )
94
+ goto out ;
95
+
96
+ ret = xe_pcode_read (root , PCODE_MBOX (PCODE_LATE_BINDING , GET_VERSION_HIGH , 0 ),
97
+ & ver_high , NULL );
98
+ if (ret )
99
+ goto out ;
100
+
101
+ major = REG_FIELD_GET (MAJOR_VERSION_MASK , ver_low );
102
+ minor = REG_FIELD_GET (MINOR_VERSION_MASK , ver_low );
103
+ hotfix = REG_FIELD_GET (HOTFIX_VERSION_MASK , ver_high );
104
+ build = REG_FIELD_GET (BUILD_VERSION_MASK , ver_high );
105
+ }
106
+ out :
107
+ xe_pm_runtime_put (xe );
108
+
109
+ return ret ?: sysfs_emit (buf , "%u.%u.%u.%u\n" , major , minor , hotfix , build );
110
+ }
111
+ static DEVICE_ATTR_ADMIN_RO (lb_fan_control_version );
112
+
113
+ static ssize_t
114
+ lb_voltage_regulator_version_show (struct device * dev , struct device_attribute * attr , char * buf )
115
+ {
116
+ struct xe_device * xe = pdev_to_xe_device (to_pci_dev (dev ));
117
+ struct xe_tile * root = xe_device_get_root_tile (xe );
118
+ u32 cap , ver_low = VR_CONFIG , ver_high = VR_CONFIG ;
119
+ u16 major = 0 , minor = 0 , hotfix = 0 , build = 0 ;
120
+ int ret ;
121
+
122
+ xe_pm_runtime_get (xe );
123
+
124
+ ret = xe_pcode_read (root , PCODE_MBOX (PCODE_LATE_BINDING , GET_CAPABILITY_STATUS , 0 ),
125
+ & cap , NULL );
126
+ if (ret )
127
+ goto out ;
128
+
129
+ if (REG_FIELD_GET (VR_PARAMS_PROVISIONED , cap )) {
130
+ ret = xe_pcode_read (root , PCODE_MBOX (PCODE_LATE_BINDING , GET_VERSION_LOW , 0 ),
131
+ & ver_low , NULL );
132
+ if (ret )
133
+ goto out ;
134
+
135
+ ret = xe_pcode_read (root , PCODE_MBOX (PCODE_LATE_BINDING , GET_VERSION_HIGH , 0 ),
136
+ & ver_high , NULL );
137
+ if (ret )
138
+ goto out ;
139
+
140
+ major = REG_FIELD_GET (MAJOR_VERSION_MASK , ver_low );
141
+ minor = REG_FIELD_GET (MINOR_VERSION_MASK , ver_low );
142
+ hotfix = REG_FIELD_GET (HOTFIX_VERSION_MASK , ver_high );
143
+ build = REG_FIELD_GET (BUILD_VERSION_MASK , ver_high );
144
+ }
145
+ out :
146
+ xe_pm_runtime_put (xe );
147
+
148
+ return ret ?: sysfs_emit (buf , "%u.%u.%u.%u\n" , major , minor , hotfix , build );
149
+ }
150
+ static DEVICE_ATTR_ADMIN_RO (lb_voltage_regulator_version );
151
+
152
+ static int late_bind_create_files (struct device * dev )
153
+ {
154
+ struct xe_device * xe = pdev_to_xe_device (to_pci_dev (dev ));
155
+ struct xe_tile * root = xe_device_get_root_tile (xe );
156
+ u32 cap ;
157
+ int ret ;
158
+
159
+ xe_pm_runtime_get (xe );
160
+
161
+ ret = xe_pcode_read (root , PCODE_MBOX (PCODE_LATE_BINDING , GET_CAPABILITY_STATUS , 0 ),
162
+ & cap , NULL );
163
+ if (ret )
164
+ goto out ;
165
+
166
+ if (REG_FIELD_GET (V1_FAN_SUPPORTED , cap )) {
167
+ ret = sysfs_create_file (& dev -> kobj , & dev_attr_lb_fan_control_version .attr );
168
+ if (ret )
169
+ goto out ;
170
+ }
171
+
172
+ if (REG_FIELD_GET (VR_PARAMS_SUPPORTED , cap ))
173
+ ret = sysfs_create_file (& dev -> kobj , & dev_attr_lb_voltage_regulator_version .attr );
174
+ out :
175
+ xe_pm_runtime_put (xe );
176
+
177
+ return ret ;
178
+ }
179
+
180
+ static void late_bind_remove_files (struct device * dev )
181
+ {
182
+ struct xe_device * xe = pdev_to_xe_device (to_pci_dev (dev ));
183
+ struct xe_tile * root = xe_device_get_root_tile (xe );
184
+ u32 cap ;
185
+ int ret ;
186
+
187
+ xe_pm_runtime_get (xe );
188
+
189
+ ret = xe_pcode_read (root , PCODE_MBOX (PCODE_LATE_BINDING , GET_CAPABILITY_STATUS , 0 ),
190
+ & cap , NULL );
191
+ if (ret )
192
+ goto out ;
193
+
194
+ if (REG_FIELD_GET (V1_FAN_SUPPORTED , cap ))
195
+ sysfs_remove_file (& dev -> kobj , & dev_attr_lb_fan_control_version .attr );
196
+
197
+ if (REG_FIELD_GET (VR_PARAMS_SUPPORTED , cap ))
198
+ sysfs_remove_file (& dev -> kobj , & dev_attr_lb_voltage_regulator_version .attr );
199
+ out :
200
+ xe_pm_runtime_put (xe );
201
+ }
202
+
68
203
/**
69
204
* DOC: PCIe Gen5 Limitations
70
205
*
@@ -151,8 +286,10 @@ static void xe_device_sysfs_fini(void *arg)
151
286
if (xe -> d3cold .capable )
152
287
sysfs_remove_file (& xe -> drm .dev -> kobj , & dev_attr_vram_d3cold_threshold .attr );
153
288
154
- if (xe -> info .platform == XE_BATTLEMAGE )
289
+ if (xe -> info .platform == XE_BATTLEMAGE ) {
155
290
sysfs_remove_files (& xe -> drm .dev -> kobj , auto_link_downgrade_attrs );
291
+ late_bind_remove_files (xe -> drm .dev );
292
+ }
156
293
}
157
294
158
295
int xe_device_sysfs_init (struct xe_device * xe )
@@ -170,6 +307,10 @@ int xe_device_sysfs_init(struct xe_device *xe)
170
307
ret = sysfs_create_files (& dev -> kobj , auto_link_downgrade_attrs );
171
308
if (ret )
172
309
return ret ;
310
+
311
+ ret = late_bind_create_files (dev );
312
+ if (ret )
313
+ return ret ;
173
314
}
174
315
175
316
return devm_add_action_or_reset (dev , xe_device_sysfs_fini , xe );
0 commit comments